Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plugin/pi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,9 @@ function spawnAndWaitForEngram(deadline: number, expectedID = ""): Promise<void>

try {
proc = spawn(ENGRAM_BIN, ["serve"], {
// Opt into cloud autosync like the Claude Code and Codex launchers; the
// server skips it on its own when no cloud server or token is configured.
env: { ...process.env, ENGRAM_CLOUD_AUTOSYNC: "1" },
windowsHide: true,
detached: true,
stdio: "ignore",
Expand Down
19 changes: 19 additions & 0 deletions plugin/pi/test/startup-lifecycle.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ if (process.argv.includes("sync") || process.argv.includes("--import")) { append
const isServe = process.argv[2] === "serve" || isSyntheticServe;
if (isServe) {
appendFileSync(${JSON.stringify(spawnLog)}, "serve\\n");
appendFileSync(${JSON.stringify(spawnLog)}, "autosync=" + (process.env.ENGRAM_CLOUD_AUTOSYNC ?? "<unset>") + "\\n");
${exitCode === undefined
? `const server = createServer(async (req, res) => {
if (req.url === "/sessions") {
Expand Down Expand Up @@ -260,6 +261,24 @@ test("a slow health probe never authorizes a duplicate spawn", async () => {
});
});

test("a plugin-launched server starts with cloud autosync enabled", async () => {
const previous = process.env.ENGRAM_CLOUD_AUTOSYNC;
delete process.env.ENGRAM_CLOUD_AUTOSYNC;
try {
await withFixture({ readyAfterMs: 0 }, async ({ hooks, ctx, spawnLog }) => {
await hooks.get("session_start")({}, ctx);

assert.equal(await countSpawns(spawnLog), 1, "the plugin spawns the server");
const log = await readFile(spawnLog, "utf8");
assert.ok(log.split("\n").includes("autosync=1"),
"the daemon must opt into cloud autosync, like the Claude Code and Codex launchers");
});
} finally {
if (previous === undefined) delete process.env.ENGRAM_CLOUD_AUTOSYNC;
else process.env.ENGRAM_CLOUD_AUTOSYNC = previous;
}
});

test("a child that exits before readiness surfaces a normalized tool error", async () => {
await withFixture({ exitCode: 1 }, async ({ tools, ctx }) => {
const memSearch = tools.get("mem_search");
Expand Down
Loading