@bastani/atomic 0.9.79 → 0.9.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/package.json +1 -1
  5. package/dist/builtin/web-access/package.json +1 -1
  6. package/dist/builtin/workflows/CHANGELOG.md +16 -0
  7. package/dist/builtin/workflows/package.json +1 -1
  8. package/dist/builtin/workflows/src/extension/index.bundle.mjs +2 -11
  9. package/dist/core/package-manager-storage-adapters.d.ts +11 -3
  10. package/dist/core/package-manager-storage-adapters.d.ts.map +1 -1
  11. package/dist/core/package-manager-storage-adapters.js +45 -4
  12. package/dist/core/package-manager-storage-adapters.js.map +1 -1
  13. package/dist/core/resource-loader-core.d.ts.map +1 -1
  14. package/dist/core/resource-loader-core.js +2 -0
  15. package/dist/core/resource-loader-core.js.map +1 -1
  16. package/dist/core/storage/host-adapters.d.ts +12 -0
  17. package/dist/core/storage/host-adapters.d.ts.map +1 -0
  18. package/dist/core/storage/host-adapters.js +51 -0
  19. package/dist/core/storage/host-adapters.js.map +1 -0
  20. package/dist/core/storage/session/released-history-files.d.ts.map +1 -1
  21. package/dist/core/storage/session/released-history-files.js +5 -0
  22. package/dist/core/storage/session/released-history-files.js.map +1 -1
  23. package/dist/main.d.ts.map +1 -1
  24. package/dist/main.js +3 -0
  25. package/dist/main.js.map +1 -1
  26. package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -1
  27. package/dist/modes/interactive-engine/remote-renderer.js +5 -4
  28. package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
  29. package/dist/utils/child-process.d.ts.map +1 -1
  30. package/dist/utils/child-process.js +10 -1
  31. package/dist/utils/child-process.js.map +1 -1
  32. package/docs/packages/authoring.md +1 -1
  33. package/docs/sdk.md +2 -0
  34. package/docs/settings.md +1 -1
  35. package/docs/storage.md +14 -2
  36. package/docs/workflows/operations.md +1 -1
  37. package/npm-shrinkwrap.json +32 -32
  38. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"remote-renderer.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,IAAI,oBAAoB,GAAG,CAAC,CAAC;AAE7B,MAAM,aAAa,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAErD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,YAAY,GAAG,IAAI,GAAG,EAAoB,CAAC;AAEjD,SAAS,aAAa,CAAC,GAAW,EAAE,KAAe;IAClD,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACzB,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,IAAI,YAAY,CAAC,IAAI,GAAG,wBAAwB,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;QAChD,IAAI,MAAM,KAAK,SAAS;YAAE,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;AACF,CAAC;AAED,6GAA6G;AAC7G,MAAM,eAAe,GAAG,IAAI,OAAO,EAA2D,CAAC;AAE/F,SAAS,cAAc,CAAC,OAAmC;IAC1D,IAAI,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;QAClD,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,EAAE,EAAE;YACnC,IAAI,aAAa,IAAI,O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EAAE,CAAC;aAC1E,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChG,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { Component } from \"@earendil-works/pi-tui\";\nimport type { CustomMessage } from \"../../core/messages.ts\";\nimport type { ToolExecutionComponent } from \"../interactive/components/tool-execution.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\nimport type { InteractiveEngineCommand, InteractiveEngineMessage, JsonObject, JsonValue } from \"./protocol.ts\";\nimport { RemoteFrameWidthClamp } from \"./remote-frame-clamp.ts\";\n\ntype RenderableToolResult = Parameters<ToolExecutionComponent[\"updateResult\"]>[0];\ntype RemoteRenderCommand = Extract<InteractiveEngineCommand, { type: \"engine_tool_render\" | \"engine_message_render\" }>;\n\nlet nextRemoteRendererId = 0;\n\nconst LOADING_LINES = [\"Loading isolated renderer…\"];\n\n/**\n * How many rows' last frames are kept, by row identity (a tool call, a custom message), to repaint rebuilt rows. A chat\n * rebuild (compaction, `/reload`, a switched session) recreates every row, and each new row waits for the engine to\n * render it. Showing the row's last frame meanwhile keeps the rebuilt chat painted, instead of a screen of placeholders\n * that lasts as long as the engine is busy.\n */\nexport const REMOTE_FRAME_CACHE_LIMIT = 2_000;\nconst recentFrames = new Map<string, string[]>();\n\nfunction rememberFrame(key: string, lines: string[]): void {\n\trecentFrames.delete(key);\n\trecentFrames.set(key, lines);\n\tif (recentFrames.size > REMOTE_FRAME_CACHE_LIMIT) {\n\t\tconst oldest = recentFrames.keys().next().value;\n\t\tif (oldest !== undefined) recentFrames.delete(oldest);\n\t}\n}\n\n/** One engine-message subscription per runtime, routed by component id, however many rows the chat holds. */\nconst routesByRuntime = new WeakMap<IsolatedInteractiveRuntime, Map<string, RemoteRenderer>>();\n\nfunction rendererRoutes(runtime: IsolatedInteractiveRuntime): Map<string, RemoteRenderer> {\n\tlet routes = routesByRuntime.get(runtime);\n\tif (routes === undefined) {\n\t\tconst created = new Map<string, RemoteRenderer>();\n\t\truntime.onEngineMessage((message) => {\n\t\t\tif (\"componentId\" in message) created.get(message.componentId)?.receive(message);\n\t\t});\n\t\troutesByRuntime.set(runtime, created);\n\t\troutes = created;\n\t}\n\treturn routes;\n}\n\nfunction jsonValue(value: unknown): JsonValue {\n\tif (value === undefined) return null;\n\tconst encoded = JSON.stringify(value);\n\treturn encoded === undefined ? null : (JSON.parse(encoded) as JsonValue);\n}\n\nabstract class RemoteRenderer implements Component {\n\tprotected readonly componentId = `remote_renderer_${++nextRemoteRendererId}`;\n\tprivate lines = LOADING_LINES;\n\tprivate width = 0;\n\tprivate requestId = 0;\n\tprivate appliedRequestId = 0;\n\tprivate dirty = true;\n\tprivate disposed = false;\n\tprivate readonly frameClamp = new RemoteFrameWidthClamp();\n\tprivate readonly routes: Map<string, RemoteRenderer>;\n\t/**\n\t * What each unanswered request showed (its frame identity, expansion included), by request id. A frame is\n\t * remembered under the identity of the request it answers, not under the row's state when it arrives: a row\n\t * collapsed while its expanded frame was in flight must not have that frame remembered as its collapsed one.\n\t */\n\tprivate readonly requestIdentities = new Map<number, string>();\n\n\tprotected readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly requestRender: () => void;\n\n\tconstructor(runtime: IsolatedInteractiveRuntime, requestRender: () => void) {\n\t\tthis.runtime = runtime;\n\t\tthis.requestRender = requestRender;\n\t\tthis.routes = rendererRoutes(runtime);\n\t\tthis.routes.set(this.componentId, this);\n\t}\n\n\t/** An engine message addressed to this row. */\n\treceive(message: InteractiveEngineMessage): void {\n\t\tif (message.type === \"engine_custom_frame\") {\n\t\t\tif (message.requestId < this.appliedRequestId) return;\n\t\t\tthis.appliedRequestId = message.requestId;\n\t\t\tthis.lines = message.lines;\n\t\t\tconst identity = this.requestIdentities.get(message.requestId);\n\t\t\tfor (const requestId of this.requestIdentities.keys())\n\t\t\t\tif (requestId <= message.requestId) this.requestIdentities.delete(requestId);\n\t\t\tif (identity !== undefined) rememberFrame(identity, message.lines);\n\t\t\tthis.requestRender();\n\t\t} else if (message.type === \"engine_custom_invalidate\") {\n\t\t\tthis.changed();\n\t\t}\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.disposed && (this.dirty || width !== this.width)) {\n\t\t\tthis.width = width;\n\t\t\tthis.dirty = false;\n\t\t\t// A row rebuilt for a row the engine already rendered paints its last frame until the fresh one arrives.\n\t\t\tconst identity = this.frameIdentity();\n\t\t\tif (this.lines === LOADING_LINES) this.lines = recentFrames.get(identity) ?? LOADING_LINES;\n\t\t\tthis.requestIdentities.set(++this.requestId, identity);\n\t\t\tthis.runtime.sendEngineCommand(this.command(this.requestId, width));\n\t\t}\n\t\t// The engine child re-renders asynchronously; until the fresh frame\n\t\t// arrives, the previous frame may be wrapped for an older terminal\n\t\t// width. Clamp so a resize never replays overflowing lines (pi-tui\n\t\t// crashes on any rendered line wider than the terminal).\n\t\treturn this.frameClamp.clamp(this.lines, width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.markDirty();\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tif (this.routes.get(this.componentId) === this) this.routes.delete(this.componentId);\n\t\tthis.requestIdentities.clear();\n\t\tthis.runtime.sendEngineCommand({ type: \"engine_render_dispose\", componentId: this.componentId });\n\t}\n\n\tprotected changed(): void {\n\t\tthis.markDirty();\n\t\tthis.requestRender();\n\t}\n\n\tprotected abstract command(requestId: number, width: number): RemoteRenderCommand;\n\n\t/** Names what this row shows, the same for every row recreated for it. */\n\tprotected abstract frameIdentity(): string;\n\n\tprivate markDirty(): void {\n\t\tthis.dirty = true;\n\t}\n}\n\n/**\n * Disposes the rows rendered by the engine among `components`, which a cleared chat no longer shows: each one\n * otherwise keeps its renderer alive in the engine for the rest of the session.\n */\nexport function disposeRemoteRenderers(components: readonly Component[]): void {\n\tfor (const component of components) if (component instanceof RemoteRenderer) component.dispose();\n}\n\nexport class RemoteToolExecutionComponent extends RemoteRenderer {\n\tprivate readonly toolName: string;\n\tprivate readonly toolCallId: string;\n\tprivate args: unknown;\n\tprivate result: RenderableToolResult | undefined;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate isPartial = true;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate outputPad: number;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: unknown,\n\t\toptions: { showImages?: boolean; imageWidthCells?: number; outputPad?: number },\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t) {\n\t\tsuper(runtime, requestRender);\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.outputPad = options.outputPad ?? 1;\n\t}\n\n\tsetOutputPad(outputPad: number): void {\n\t\tthis.outputPad = outputPad;\n\t\tthis.changed();\n\t}\n\tupdateArgs(args: unknown): void {\n\t\tthis.args = args;\n\t\tthis.changed();\n\t}\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.changed();\n\t}\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.changed();\n\t}\n\tupdateResult(result: RenderableToolResult, isPartial = false): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.changed();\n\t}\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.changed();\n\t}\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.changed();\n\t}\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.changed();\n\t}\n\n\tprotected command(requestId: number, width: number): RemoteRenderCommand {\n\t\treturn {\n\t\t\ttype: \"engine_tool_render\",\n\t\t\tcomponentId: this.componentId,\n\t\t\trequestId,\n\t\t\twidth,\n\t\t\ttoolName: this.toolName,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\targs: jsonValue(this.args),\n\t\t\tresult: this.result ? (jsonValue(this.result) as JsonObject) : undefined,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\timageWidthCells: this.imageWidthCells,\n\t\t\toutputPad: this.outputPad,\n\t\t};\n\t}\n\n\tprotected frameIdentity(): string {\n\t\treturn JSON.stringify([\"tool\", this.toolName, this.toolCallId, this.expanded]);\n\t}\n}\n\nexport class RemoteCustomMessageComponent extends RemoteRenderer {\n\tprivate readonly message: CustomMessage<unknown>;\n\tprivate contentDigest: string | undefined;\n\tprivate expanded = false;\n\tprivate outputPad: number;\n\tconstructor(\n\t\tmessage: CustomMessage<unknown>,\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t\toutputPad = 1,\n\t) {\n\t\tsuper(runtime, requestRender);\n\t\tthis.message = message;\n\t\tthis.outputPad = outputPad;\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.changed();\n\t}\n\tsetOutputPad(outputPad: number): void {\n\t\tthis.outputPad = outputPad;\n\t\tthis.changed();\n\t}\n\n\tprotected command(requestId: number, width: number): RemoteRenderCommand {\n\t\treturn {\n\t\t\ttype: \"engine_message_render\",\n\t\t\tcomponentId: this.componentId,\n\t\t\trequestId,\n\t\t\twidth,\n\t\t\tmessage: jsonValue(this.message) as JsonObject,\n\t\t\texpanded: this.expanded,\n\t\t\toutputPad: this.outputPad,\n\t\t};\n\t}\n\n\tprotected frameIdentity(): string {\n\t\t// Not the timestamp: a message shown live and the same message restored from the session can differ in it.\n\t\tthis.contentDigest ??= createHash(\"sha1\")\n\t\t\t.update(JSON.stringify([this.message.content, this.message.details]) ?? \"\")\n\t\t\t.digest(\"base64\");\n\t\treturn JSON.stringify([\"message\", this.message.customType, this.contentDigest, this.expanded]);\n\t}\n}\n"]}
1
+ {"version":3,"file":"remote-renderer.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,IAAI,oBAAoB,GAAG,CAAC,CAAC;AAE7B,+GAA+G;AAC/G,MAAM,gBAAgB,GAAa,EAAE,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,YAAY,GAAG,IAAI,GAAG,EAAoB,CAAC;AAEjD,SAAS,aAAa,CAAC,GAAW,EAAE,KAAe;IAClD,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACzB,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,IAAI,YAAY,CAAC,IAAI,GAAG,wBAAwB,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;QAChD,IAAI,MAAM,KAAK,SAAS;YAAE,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;AACF,CAAC;AAED,6GAA6G;AAC7G,MAAM,eAAe,GAAG,IAAI,OAAO,EAA2D,CAAC;AAE/F,SAAS,cAAc,CAAC,OAAmC;IAC1D,IAAI,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;QA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AAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;aAC1E,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChG,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { Component } from \"@earendil-works/pi-tui\";\nimport type { CustomMessage } from \"../../core/messages.ts\";\nimport type { ToolExecutionComponent } from \"../interactive/components/tool-execution.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\nimport type { InteractiveEngineCommand, InteractiveEngineMessage, JsonObject, JsonValue } from \"./protocol.ts\";\nimport { RemoteFrameWidthClamp } from \"./remote-frame-clamp.ts\";\n\ntype RenderableToolResult = Parameters<ToolExecutionComponent[\"updateResult\"]>[0];\ntype RemoteRenderCommand = Extract<InteractiveEngineCommand, { type: \"engine_tool_render\" | \"engine_message_render\" }>;\n\nlet nextRemoteRendererId = 0;\n\n/** A row the engine has not rendered yet draws nothing, rather than a placeholder that flickers in and out. */\nconst NOT_RENDERED_YET: string[] = [];\n\n/**\n * How many rows' last frames are kept, by row identity (a tool call, a custom message), to repaint rebuilt rows. A chat\n * rebuild (compaction, `/reload`, a switched session) recreates every row, and each new row waits for the engine to\n * render it. Showing the row's last frame meanwhile keeps the rebuilt chat painted, instead of a screen of placeholders\n * that lasts as long as the engine is busy.\n */\nexport const REMOTE_FRAME_CACHE_LIMIT = 2_000;\nconst recentFrames = new Map<string, string[]>();\n\nfunction rememberFrame(key: string, lines: string[]): void {\n\trecentFrames.delete(key);\n\trecentFrames.set(key, lines);\n\tif (recentFrames.size > REMOTE_FRAME_CACHE_LIMIT) {\n\t\tconst oldest = recentFrames.keys().next().value;\n\t\tif (oldest !== undefined) recentFrames.delete(oldest);\n\t}\n}\n\n/** One engine-message subscription per runtime, routed by component id, however many rows the chat holds. */\nconst routesByRuntime = new WeakMap<IsolatedInteractiveRuntime, Map<string, RemoteRenderer>>();\n\nfunction rendererRoutes(runtime: IsolatedInteractiveRuntime): Map<string, RemoteRenderer> {\n\tlet routes = routesByRuntime.get(runtime);\n\tif (routes === undefined) {\n\t\tconst created = new Map<string, RemoteRenderer>();\n\t\truntime.onEngineMessage((message) => {\n\t\t\tif (\"componentId\" in message) created.get(message.componentId)?.receive(message);\n\t\t});\n\t\troutesByRuntime.set(runtime, created);\n\t\troutes = created;\n\t}\n\treturn routes;\n}\n\nfunction jsonValue(value: unknown): JsonValue {\n\tif (value === undefined) return null;\n\tconst encoded = JSON.stringify(value);\n\treturn encoded === undefined ? null : (JSON.parse(encoded) as JsonValue);\n}\n\nabstract class RemoteRenderer implements Component {\n\tprotected readonly componentId = `remote_renderer_${++nextRemoteRendererId}`;\n\tprivate lines = NOT_RENDERED_YET;\n\tprivate width = 0;\n\tprivate requestId = 0;\n\tprivate appliedRequestId = 0;\n\tprivate dirty = true;\n\tprivate disposed = false;\n\tprivate readonly frameClamp = new RemoteFrameWidthClamp();\n\tprivate readonly routes: Map<string, RemoteRenderer>;\n\t/**\n\t * What each unanswered request showed (its frame identity, expansion included), by request id. A frame is\n\t * remembered under the identity of the request it answers, not under the row's state when it arrives: a row\n\t * collapsed while its expanded frame was in flight must not have that frame remembered as its collapsed one.\n\t */\n\tprivate readonly requestIdentities = new Map<number, string>();\n\n\tprotected readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly requestRender: () => void;\n\n\tconstructor(runtime: IsolatedInteractiveRuntime, requestRender: () => void) {\n\t\tthis.runtime = runtime;\n\t\tthis.requestRender = requestRender;\n\t\tthis.routes = rendererRoutes(runtime);\n\t\tthis.routes.set(this.componentId, this);\n\t}\n\n\t/** An engine message addressed to this row. */\n\treceive(message: InteractiveEngineMessage): void {\n\t\tif (message.type === \"engine_custom_frame\") {\n\t\t\tif (message.requestId < this.appliedRequestId) return;\n\t\t\tthis.appliedRequestId = message.requestId;\n\t\t\tthis.lines = message.lines;\n\t\t\tconst identity = this.requestIdentities.get(message.requestId);\n\t\t\tfor (const requestId of this.requestIdentities.keys())\n\t\t\t\tif (requestId <= message.requestId) this.requestIdentities.delete(requestId);\n\t\t\tif (identity !== undefined) rememberFrame(identity, message.lines);\n\t\t\tthis.requestRender();\n\t\t} else if (message.type === \"engine_custom_invalidate\") {\n\t\t\tthis.changed();\n\t\t}\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.disposed && (this.dirty || width !== this.width)) {\n\t\t\tthis.width = width;\n\t\t\tthis.dirty = false;\n\t\t\t// A row rebuilt for a row the engine already rendered paints its last frame until the fresh one arrives.\n\t\t\tconst identity = this.frameIdentity();\n\t\t\tif (this.lines === NOT_RENDERED_YET) this.lines = recentFrames.get(identity) ?? NOT_RENDERED_YET;\n\t\t\tthis.requestIdentities.set(++this.requestId, identity);\n\t\t\tthis.runtime.sendEngineCommand(this.command(this.requestId, width));\n\t\t}\n\t\t// The engine child re-renders asynchronously; until the fresh frame\n\t\t// arrives, the previous frame may be wrapped for an older terminal\n\t\t// width. Clamp so a resize never replays overflowing lines (pi-tui\n\t\t// crashes on any rendered line wider than the terminal).\n\t\treturn this.frameClamp.clamp(this.lines, width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.markDirty();\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tif (this.routes.get(this.componentId) === this) this.routes.delete(this.componentId);\n\t\tthis.requestIdentities.clear();\n\t\tthis.runtime.sendEngineCommand({ type: \"engine_render_dispose\", componentId: this.componentId });\n\t}\n\n\tprotected changed(): void {\n\t\tthis.markDirty();\n\t\tthis.requestRender();\n\t}\n\n\tprotected abstract command(requestId: number, width: number): RemoteRenderCommand;\n\n\t/** Names what this row shows, the same for every row recreated for it. */\n\tprotected abstract frameIdentity(): string;\n\n\tprivate markDirty(): void {\n\t\tthis.dirty = true;\n\t}\n}\n\n/**\n * Disposes the rows rendered by the engine among `components`, which a cleared chat no longer shows: each one\n * otherwise keeps its renderer alive in the engine for the rest of the session.\n */\nexport function disposeRemoteRenderers(components: readonly Component[]): void {\n\tfor (const component of components) if (component instanceof RemoteRenderer) component.dispose();\n}\n\nexport class RemoteToolExecutionComponent extends RemoteRenderer {\n\tprivate readonly toolName: string;\n\tprivate readonly toolCallId: string;\n\tprivate args: unknown;\n\tprivate result: RenderableToolResult | undefined;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate isPartial = true;\n\tprivate expanded = false;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate outputPad: number;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: unknown,\n\t\toptions: { showImages?: boolean; imageWidthCells?: number; outputPad?: number },\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t) {\n\t\tsuper(runtime, requestRender);\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.outputPad = options.outputPad ?? 1;\n\t}\n\n\tsetOutputPad(outputPad: number): void {\n\t\tthis.outputPad = outputPad;\n\t\tthis.changed();\n\t}\n\tupdateArgs(args: unknown): void {\n\t\tthis.args = args;\n\t\tthis.changed();\n\t}\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.changed();\n\t}\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.changed();\n\t}\n\tupdateResult(result: RenderableToolResult, isPartial = false): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.changed();\n\t}\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.changed();\n\t}\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.changed();\n\t}\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.changed();\n\t}\n\n\tprotected command(requestId: number, width: number): RemoteRenderCommand {\n\t\treturn {\n\t\t\ttype: \"engine_tool_render\",\n\t\t\tcomponentId: this.componentId,\n\t\t\trequestId,\n\t\t\twidth,\n\t\t\ttoolName: this.toolName,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\targs: jsonValue(this.args),\n\t\t\tresult: this.result ? (jsonValue(this.result) as JsonObject) : undefined,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\timageWidthCells: this.imageWidthCells,\n\t\t\toutputPad: this.outputPad,\n\t\t};\n\t}\n\n\tprotected frameIdentity(): string {\n\t\treturn JSON.stringify([\"tool\", this.toolName, this.toolCallId, this.expanded]);\n\t}\n}\n\nexport class RemoteCustomMessageComponent extends RemoteRenderer {\n\tprivate readonly message: CustomMessage<unknown>;\n\tprivate contentDigest: string | undefined;\n\tprivate expanded = false;\n\tprivate outputPad: number;\n\tconstructor(\n\t\tmessage: CustomMessage<unknown>,\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t\toutputPad = 1,\n\t) {\n\t\tsuper(runtime, requestRender);\n\t\tthis.message = message;\n\t\tthis.outputPad = outputPad;\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.changed();\n\t}\n\tsetOutputPad(outputPad: number): void {\n\t\tthis.outputPad = outputPad;\n\t\tthis.changed();\n\t}\n\n\tprotected command(requestId: number, width: number): RemoteRenderCommand {\n\t\treturn {\n\t\t\ttype: \"engine_message_render\",\n\t\t\tcomponentId: this.componentId,\n\t\t\trequestId,\n\t\t\twidth,\n\t\t\tmessage: jsonValue(this.message) as JsonObject,\n\t\t\texpanded: this.expanded,\n\t\t\toutputPad: this.outputPad,\n\t\t};\n\t}\n\n\tprotected frameIdentity(): string {\n\t\t// Not the timestamp: a message shown live and the same message restored from the session can differ in it.\n\t\tthis.contentDigest ??= createHash(\"sha1\")\n\t\t\t.update(JSON.stringify([this.message.content, this.message.details]) ?? \"\")\n\t\t\t.digest(\"base64\");\n\t\treturn JSON.stringify([\"message\", this.message.customType, this.contentDigest, this.expanded]);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"child-process.d.ts","sourceRoot":"","sources":["../../src/utils/child-process.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,mBAAmB,EAGxB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,kCAAkC,EACvC,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAU5C,4DAA4D;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,wBAAgB,6BAA6B,CAC5C,SAAS,CAAC,EAAE,MAAM,CAAC,UAAU,EAC7B,OAAO,GAAE,MAAM,CAAC,UAAwB,GACtC,MAAM,CAAC,UAAU,CAInB;AAED,KAAK,0BAA0B,GAAG;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,qBAAqB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACjD,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAIF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAI9D;AAED,wBAAgB,YAAY,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAA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C,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACjD,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAIF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAI9D;AAED,wBAAgB,YAAY,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,0BAA0B,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,GAClE,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACjD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY,CAAC;AAWnG,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,kCAAkC,GACzC,gBAAgB,CAAC,MAAM,CAAC,CAQ1B;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAO1D;AAYD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE,0BAA+B,GACtC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA8IxB"}
@@ -3,6 +3,7 @@ import { constants as osConstants } from "node:os";
3
3
  import { basename } from "node:path";
4
4
  import crossSpawn from "cross-spawn";
5
5
  import { applyDebugSettingToChildEnvironment } from "../core/debug-setting.js";
6
+ import { HOST_STORAGE_ADAPTERS_ENV, hostStorageAdaptersEnvironment } from "../core/storage/host-adapters.js";
6
7
  import { ATOMIC_AI_AGENT } from "./agent-attribution.js";
7
8
  const EXIT_STDIO_IDLE_GRACE_MS = 100;
8
9
  const EXIT_STDIO_ACTIVE_DRAIN_HARD_CAP_MS = 5_000;
@@ -11,7 +12,15 @@ const WINDOWS_EXIT_CODE_GRACE_MS = 1_000;
11
12
  /** Build the environment for every Atomic child process. */
12
13
  export { ATOMIC_AI_AGENT } from "./agent-attribution.js";
13
14
  export function createChildProcessEnvironment(overrides, baseEnv = process.env) {
14
- const env = { ...baseEnv, ...overrides, AI_AGENT: ATOMIC_AI_AGENT };
15
+ // The host's adapters are the default. A caller that set the variable itself, to another map or to nothing, keeps
16
+ // its choice; an unchanged copy of this process's environment does not count as a choice.
17
+ const callerChose = baseEnv !== process.env && baseEnv[HOST_STORAGE_ADAPTERS_ENV] !== process.env[HOST_STORAGE_ADAPTERS_ENV];
18
+ const env = {
19
+ ...baseEnv,
20
+ ...(callerChose ? {} : hostStorageAdaptersEnvironment()),
21
+ ...overrides,
22
+ AI_AGENT: ATOMIC_AI_AGENT,
23
+ };
15
24
  applyDebugSettingToChildEnvironment(env);
16
25
  return env;
17
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"child-process.js","sourceRoot":"","sources":["../../src/utils/child-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,IAAI,SAAS,EAClB,SAAS,IAAI,aAAa,GAO1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,mCAAmC,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,MAAM,mCAAmC,GAAG,KAAK,CAAC;AAClD,MAAM,6BAA6B,GAAG,EAAE,CAAC;AACzC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAEzC,4DAA4D;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,MAAM,UAAU,6BAA6B,C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;IAC9B,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n\ttype ChildProcess,\n\ttype ChildProcessByStdio,\n\tspawn as nodeSpawn,\n\tspawnSync as nodeSpawnSync,\n\ttype SpawnOptions,\n\ttype SpawnOptionsWithStdioTuple,\n\ttype SpawnSyncOptionsWithStringEncoding,\n\ttype SpawnSyncReturns,\n\ttype StdioNull,\n\ttype StdioPipe,\n} from \"node:child_process\";\nimport { constants as osConstants } from \"node:os\";\nimport { basename } from \"node:path\";\nimport type { Readable } from \"node:stream\";\nimport crossSpawn from \"cross-spawn\";\nimport { applyDebugSettingToChildEnvironment } from \"../core/debug-setting.ts\";\nimport { ATOMIC_AI_AGENT } from \"./agent-attribution.ts\";\n\nconst EXIT_STDIO_IDLE_GRACE_MS = 100;\nconst EXIT_STDIO_ACTIVE_DRAIN_HARD_CAP_MS = 5_000;\nconst WINDOWS_EXIT_POLL_INTERVAL_MS = 50;\nconst WINDOWS_EXIT_CODE_GRACE_MS = 1_000;\n\n/** Build the environment for every Atomic child process. */\nexport { ATOMIC_AI_AGENT } from \"./agent-attribution.ts\";\nexport function createChildProcessEnvironment(\n\toverrides?: NodeJS.ProcessEnv,\n\tbaseEnv: NodeJS.ProcessEnv = process.env,\n): NodeJS.ProcessEnv {\n\tconst env = { ...baseEnv, ...overrides, AI_AGENT: ATOMIC_AI_AGENT };\n\tapplyDebugSettingToChildEnvironment(env);\n\treturn env;\n}\n\ntype WaitForChildProcessOptions = {\n\tplatform?: NodeJS.Platform;\n\tisWindowsProcessAlive?: (pid: number) => boolean;\n\twindowsExitPollIntervalMs?: number;\n\twindowsExitCodeGraceMs?: number;\n};\n\nconst WINDOWS_SHELL_COMMANDS = new Set([\"bun\", \"npm\", \"npx\", \"pnpm\", \"yarn\", \"yarnpkg\", \"corepack\"]);\n\nexport function shouldUseWindowsShell(command: string): boolean {\n\tif (process.platform !== \"win32\") return false;\n\tconst commandName = basename(command).toLowerCase();\n\treturn commandName.endsWith(\".cmd\") || commandName.endsWith(\".bat\") || WINDOWS_SHELL_COMMANDS.has(commandName);\n}\n\nexport function spawnProcess(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): ChildProcessByStdio<null, Readable, Readable>;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess {\n\tconst childOptions = {\n\t\t...options,\n\t\tenv: options.env ? createChildProcessEnvironment(undefined, options.env) : createChildProcessEnvironment(),\n\t};\n\treturn process.platform === \"win32\"\n\t\t? crossSpawn(command, args, childOptions)\n\t\t: nodeSpawn(command, args, childOptions);\n}\n\nexport function spawnProcessSync(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnSyncOptionsWithStringEncoding,\n): SpawnSyncReturns<string> {\n\tconst childOptions = {\n\t\t...options,\n\t\tenv: options.env ? createChildProcessEnvironment(undefined, options.env) : createChildProcessEnvironment(),\n\t};\n\treturn process.platform === \"win32\"\n\t\t? crossSpawn.sync(command, args, childOptions)\n\t\t: nodeSpawnSync(command, args, childOptions);\n}\n\nexport function isWindowsProcessAlive(pid: number): boolean {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch (error) {\n\t\treturn (error as NodeJS.ErrnoException).code !== \"ESRCH\";\n\t}\n}\n\nfunction mapSignalExitCode(\n\tcode: number | null,\n\tsignal: NodeJS.Signals | null,\n\tplatform: NodeJS.Platform,\n): number | null {\n\tif (code !== null || signal === null || platform === \"win32\") return code;\n\tconst signalNumber = osConstants.signals[signal] ?? 0;\n\treturn 128 + signalNumber;\n}\n\n/**\n * Wait for a child process to terminate without hanging on inherited stdio handles.\n *\n * A short-lived child can `exit` while a detached descendant keeps its stdout/stderr\n * pipe open. We must not resolve and destroy the streams on a short fixed deadline\n * measured from `exit`, or finite post-exit output still being written past that\n * deadline is silently lost (earendil-works/pi#5303). Instead, after `exit` we wait\n * for the pipes to fall idle: the grace timer is re-armed on every chunk, so finite\n * post-exit writers drain while active, while a quiet inherited handle (e.g. a\n * Windows daemonized descendant that never lets `close` fire) releases promptly\n * after the grace elapses. A longer active-drain hard cap is armed once on `exit`\n * so an endlessly noisy descendant cannot keep the wait pending forever.\n */\nexport function waitForChildProcess(\n\tchild: ChildProcess,\n\toptions: WaitForChildProcessOptions = {},\n): Promise<number | null> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet settled = false;\n\t\tlet exited = false;\n\t\tlet exitCode: number | null = null;\n\t\tlet postExitIdleTimer: NodeJS.Timeout | undefined;\n\t\tlet postExitActiveDrainHardCapTimer: NodeJS.Timeout | undefined;\n\t\tlet stdoutEnded = child.stdout === null;\n\t\tlet stderrEnded = child.stderr === null;\n\t\tlet windowsExitPoll: NodeJS.Timeout | undefined;\n\t\tlet windowsExitCodeGraceTimer: NodeJS.Timeout | undefined;\n\t\tconst platform = options.platform ?? process.platform;\n\t\tconst processAlive = options.isWindowsProcessAlive ?? isWindowsProcessAlive;\n\t\tconst windowsExitPollIntervalMs = options.windowsExitPollIntervalMs ?? WINDOWS_EXIT_POLL_INTERVAL_MS;\n\t\tconst windowsExitCodeGraceMs = options.windowsExitCodeGraceMs ?? WINDOWS_EXIT_CODE_GRACE_MS;\n\n\t\tconst cleanup = () => {\n\t\t\tif (windowsExitPoll) {\n\t\t\t\tclearInterval(windowsExitPoll);\n\t\t\t\twindowsExitPoll = undefined;\n\t\t\t}\n\t\t\tif (postExitIdleTimer) {\n\t\t\t\tclearTimeout(postExitIdleTimer);\n\t\t\t\tpostExitIdleTimer = undefined;\n\t\t\t}\n\t\t\tif (postExitActiveDrainHardCapTimer) {\n\t\t\t\tclearTimeout(postExitActiveDrainHardCapTimer);\n\t\t\t\tpostExitActiveDrainHardCapTimer = undefined;\n\t\t\t}\n\t\t\tif (windowsExitCodeGraceTimer) {\n\t\t\t\tclearTimeout(windowsExitCodeGraceTimer);\n\t\t\t\twindowsExitCodeGraceTimer = undefined;\n\t\t\t}\n\t\t\tchild.removeListener(\"error\", onError);\n\t\t\tchild.removeListener(\"exit\", onExit);\n\t\t\tchild.removeListener(\"close\", onClose);\n\t\t\tchild.stdout?.removeListener(\"end\", onStdoutEnd);\n\t\t\tchild.stderr?.removeListener(\"end\", onStderrEnd);\n\t\t\tchild.stdout?.removeListener(\"data\", onData);\n\t\t\tchild.stderr?.removeListener(\"data\", onData);\n\t\t};\n\n\t\tconst finalize = (code: number | null) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\tchild.stdout?.destroy();\n\t\t\tchild.stderr?.destroy();\n\t\t\tresolve(code);\n\t\t};\n\n\t\tconst maybeFinalizeAfterExit = () => {\n\t\t\tif (!exited || settled) return;\n\t\t\tif (stdoutEnded && stderrEnded) {\n\t\t\t\tfinalize(exitCode);\n\t\t\t}\n\t\t};\n\n\t\tconst armIdleTimer = () => {\n\t\t\tif (postExitIdleTimer) clearTimeout(postExitIdleTimer);\n\t\t\tpostExitIdleTimer = setTimeout(() => finalize(exitCode), EXIT_STDIO_IDLE_GRACE_MS);\n\t\t};\n\n\t\tconst armActiveDrainHardCapTimer = () => {\n\t\t\tif (postExitActiveDrainHardCapTimer) return;\n\t\t\tpostExitActiveDrainHardCapTimer = setTimeout(() => finalize(exitCode), EXIT_STDIO_ACTIVE_DRAIN_HARD_CAP_MS);\n\t\t};\n\n\t\tconst onData = () => {\n\t\t\t// Output is still arriving after exit; keep extending the idle grace\n\t\t\t// so active finite writers can drain without truncating the tail.\n\t\t\tif (exited && !settled) armIdleTimer();\n\t\t};\n\n\t\tconst onStdoutEnd = () => {\n\t\t\tstdoutEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onStderrEnd = () => {\n\t\t\tstderrEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onError = (err: Error) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\treject(err);\n\t\t};\n\t\tconst onExit = (code: number | null, signal: NodeJS.Signals | null) => {\n\t\t\tif (windowsExitCodeGraceTimer) {\n\t\t\t\tclearTimeout(windowsExitCodeGraceTimer);\n\t\t\t\twindowsExitCodeGraceTimer = undefined;\n\t\t\t}\n\t\t\texited = true;\n\t\t\texitCode = mapSignalExitCode(code, signal, platform);\n\t\t\tmaybeFinalizeAfterExit();\n\t\t\tif (!settled) {\n\t\t\t\tarmActiveDrainHardCapTimer();\n\t\t\t\tarmIdleTimer();\n\t\t\t}\n\t\t};\n\n\t\tconst armWindowsExitCodeGraceTimer = () => {\n\t\t\tif (windowsExitCodeGraceTimer) return;\n\t\t\tif (windowsExitPoll) {\n\t\t\t\tclearInterval(windowsExitPoll);\n\t\t\t\twindowsExitPoll = undefined;\n\t\t\t}\n\t\t\twindowsExitCodeGraceTimer = setTimeout(() => {\n\t\t\t\twindowsExitCodeGraceTimer = undefined;\n\t\t\t\tonExit(child.exitCode ?? 0, null);\n\t\t\t}, windowsExitCodeGraceMs);\n\t\t};\n\n\t\tconst pollWindowsExit = () => {\n\t\t\tif (platform !== \"win32\" || !child.pid || exited || settled) return;\n\t\t\tif (!processAlive(child.pid)) {\n\t\t\t\tif (child.exitCode !== null) {\n\t\t\t\t\tonExit(child.exitCode, null);\n\t\t\t\t} else {\n\t\t\t\t\tarmWindowsExitCodeGraceTimer();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tconst onClose = (code: number | null, signal: NodeJS.Signals | null) => {\n\t\t\tfinalize(mapSignalExitCode(code, signal, platform));\n\t\t};\n\n\t\tif (platform === \"win32\" && child.pid) {\n\t\t\twindowsExitPoll = setInterval(pollWindowsExit, windowsExitPollIntervalMs);\n\t\t}\n\t\tchild.stdout?.once(\"end\", onStdoutEnd);\n\t\tchild.stderr?.once(\"end\", onStderrEnd);\n\t\tchild.stdout?.on(\"data\", onData);\n\t\tchild.stderr?.on(\"data\", onData);\n\t\tchild.once(\"error\", onError);\n\t\tchild.once(\"exit\", onExit);\n\t\tchild.once(\"close\", onClose);\n\t});\n}\n"]}
1
+ {"version":3,"file":"child-process.js","sourceRoot":"","sources":["../../src/utils/child-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,IAAI,SAAS,EAClB,SAAS,IAAI,aAAa,GAO1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,mCAAmC,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7G,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,MAAM,mCAAmC,GAAG,KAAK,CAAC;AAClD,MAAM,6BAA6B,GAAG,EAAE,CAAC;AACzC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAEzC,4DAA4D;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,MAAM,UAAU,6BAA6B,CAC5C,SAA6B,EAC7B,OAAO,GAAsB,OAAO,CAAC,GAAG;IAExC,kHAAkH;IAClH,0FAA0F;IAC1F,MAAM,WAAW,GAChB,OAAO,KAAK,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,yBAAyB,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IAC1G,MAAM,GAAG,GAAG;QACX,GAAG,OAAO;QACV,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,8BAA8B,EAAE,CAAC;QACxD,GAAG,SAAS;QACZ,QAAQ,EAAE,eAAe;KACzB,CAAC;IACF,mCAAmC,CAAC,GAAG,CAAC,CAAC;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yncOptionsWithStringEncoding,\n\ttype SpawnSyncReturns,\n\ttype StdioNull,\n\ttype StdioPipe,\n} from \"node:child_process\";\nimport { constants as osConstants } from \"node:os\";\nimport { basename } from \"node:path\";\nimport type { Readable } from \"node:stream\";\nimport crossSpawn from \"cross-spawn\";\nimport { applyDebugSettingToChildEnvironment } from \"../core/debug-setting.ts\";\nimport { HOST_STORAGE_ADAPTERS_ENV, hostStorageAdaptersEnvironment } from \"../core/storage/host-adapters.ts\";\nimport { ATOMIC_AI_AGENT } from \"./agent-attribution.ts\";\n\nconst EXIT_STDIO_IDLE_GRACE_MS = 100;\nconst EXIT_STDIO_ACTIVE_DRAIN_HARD_CAP_MS = 5_000;\nconst WINDOWS_EXIT_POLL_INTERVAL_MS = 50;\nconst WINDOWS_EXIT_CODE_GRACE_MS = 1_000;\n\n/** Build the environment for every Atomic child process. */\nexport { ATOMIC_AI_AGENT } from \"./agent-attribution.ts\";\nexport function createChildProcessEnvironment(\n\toverrides?: NodeJS.ProcessEnv,\n\tbaseEnv: NodeJS.ProcessEnv = process.env,\n): NodeJS.ProcessEnv {\n\t// The host's adapters are the default. A caller that set the variable itself, to another map or to nothing, keeps\n\t// its choice; an unchanged copy of this process's environment does not count as a choice.\n\tconst callerChose =\n\t\tbaseEnv !== process.env && baseEnv[HOST_STORAGE_ADAPTERS_ENV] !== process.env[HOST_STORAGE_ADAPTERS_ENV];\n\tconst env = {\n\t\t...baseEnv,\n\t\t...(callerChose ? {} : hostStorageAdaptersEnvironment()),\n\t\t...overrides,\n\t\tAI_AGENT: ATOMIC_AI_AGENT,\n\t};\n\tapplyDebugSettingToChildEnvironment(env);\n\treturn env;\n}\n\ntype WaitForChildProcessOptions = {\n\tplatform?: NodeJS.Platform;\n\tisWindowsProcessAlive?: (pid: number) => boolean;\n\twindowsExitPollIntervalMs?: number;\n\twindowsExitCodeGraceMs?: number;\n};\n\nconst WINDOWS_SHELL_COMMANDS = new Set([\"bun\", \"npm\", \"npx\", \"pnpm\", \"yarn\", \"yarnpkg\", \"corepack\"]);\n\nexport function shouldUseWindowsShell(command: string): boolean {\n\tif (process.platform !== \"win32\") return false;\n\tconst commandName = basename(command).toLowerCase();\n\treturn commandName.endsWith(\".cmd\") || commandName.endsWith(\".bat\") || WINDOWS_SHELL_COMMANDS.has(commandName);\n}\n\nexport function spawnProcess(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): ChildProcessByStdio<null, Readable, Readable>;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess;\nexport function spawnProcess(command: string, args: string[], options: SpawnOptions): ChildProcess {\n\tconst childOptions = {\n\t\t...options,\n\t\tenv: options.env ? createChildProcessEnvironment(undefined, options.env) : createChildProcessEnvironment(),\n\t};\n\treturn process.platform === \"win32\"\n\t\t? crossSpawn(command, args, childOptions)\n\t\t: nodeSpawn(command, args, childOptions);\n}\n\nexport function spawnProcessSync(\n\tcommand: string,\n\targs: string[],\n\toptions: SpawnSyncOptionsWithStringEncoding,\n): SpawnSyncReturns<string> {\n\tconst childOptions = {\n\t\t...options,\n\t\tenv: options.env ? createChildProcessEnvironment(undefined, options.env) : createChildProcessEnvironment(),\n\t};\n\treturn process.platform === \"win32\"\n\t\t? crossSpawn.sync(command, args, childOptions)\n\t\t: nodeSpawnSync(command, args, childOptions);\n}\n\nexport function isWindowsProcessAlive(pid: number): boolean {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch (error) {\n\t\treturn (error as NodeJS.ErrnoException).code !== \"ESRCH\";\n\t}\n}\n\nfunction mapSignalExitCode(\n\tcode: number | null,\n\tsignal: NodeJS.Signals | null,\n\tplatform: NodeJS.Platform,\n): number | null {\n\tif (code !== null || signal === null || platform === \"win32\") return code;\n\tconst signalNumber = osConstants.signals[signal] ?? 0;\n\treturn 128 + signalNumber;\n}\n\n/**\n * Wait for a child process to terminate without hanging on inherited stdio handles.\n *\n * A short-lived child can `exit` while a detached descendant keeps its stdout/stderr\n * pipe open. We must not resolve and destroy the streams on a short fixed deadline\n * measured from `exit`, or finite post-exit output still being written past that\n * deadline is silently lost (earendil-works/pi#5303). Instead, after `exit` we wait\n * for the pipes to fall idle: the grace timer is re-armed on every chunk, so finite\n * post-exit writers drain while active, while a quiet inherited handle (e.g. a\n * Windows daemonized descendant that never lets `close` fire) releases promptly\n * after the grace elapses. A longer active-drain hard cap is armed once on `exit`\n * so an endlessly noisy descendant cannot keep the wait pending forever.\n */\nexport function waitForChildProcess(\n\tchild: ChildProcess,\n\toptions: WaitForChildProcessOptions = {},\n): Promise<number | null> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet settled = false;\n\t\tlet exited = false;\n\t\tlet exitCode: number | null = null;\n\t\tlet postExitIdleTimer: NodeJS.Timeout | undefined;\n\t\tlet postExitActiveDrainHardCapTimer: NodeJS.Timeout | undefined;\n\t\tlet stdoutEnded = child.stdout === null;\n\t\tlet stderrEnded = child.stderr === null;\n\t\tlet windowsExitPoll: NodeJS.Timeout | undefined;\n\t\tlet windowsExitCodeGraceTimer: NodeJS.Timeout | undefined;\n\t\tconst platform = options.platform ?? process.platform;\n\t\tconst processAlive = options.isWindowsProcessAlive ?? isWindowsProcessAlive;\n\t\tconst windowsExitPollIntervalMs = options.windowsExitPollIntervalMs ?? WINDOWS_EXIT_POLL_INTERVAL_MS;\n\t\tconst windowsExitCodeGraceMs = options.windowsExitCodeGraceMs ?? WINDOWS_EXIT_CODE_GRACE_MS;\n\n\t\tconst cleanup = () => {\n\t\t\tif (windowsExitPoll) {\n\t\t\t\tclearInterval(windowsExitPoll);\n\t\t\t\twindowsExitPoll = undefined;\n\t\t\t}\n\t\t\tif (postExitIdleTimer) {\n\t\t\t\tclearTimeout(postExitIdleTimer);\n\t\t\t\tpostExitIdleTimer = undefined;\n\t\t\t}\n\t\t\tif (postExitActiveDrainHardCapTimer) {\n\t\t\t\tclearTimeout(postExitActiveDrainHardCapTimer);\n\t\t\t\tpostExitActiveDrainHardCapTimer = undefined;\n\t\t\t}\n\t\t\tif (windowsExitCodeGraceTimer) {\n\t\t\t\tclearTimeout(windowsExitCodeGraceTimer);\n\t\t\t\twindowsExitCodeGraceTimer = undefined;\n\t\t\t}\n\t\t\tchild.removeListener(\"error\", onError);\n\t\t\tchild.removeListener(\"exit\", onExit);\n\t\t\tchild.removeListener(\"close\", onClose);\n\t\t\tchild.stdout?.removeListener(\"end\", onStdoutEnd);\n\t\t\tchild.stderr?.removeListener(\"end\", onStderrEnd);\n\t\t\tchild.stdout?.removeListener(\"data\", onData);\n\t\t\tchild.stderr?.removeListener(\"data\", onData);\n\t\t};\n\n\t\tconst finalize = (code: number | null) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\tchild.stdout?.destroy();\n\t\t\tchild.stderr?.destroy();\n\t\t\tresolve(code);\n\t\t};\n\n\t\tconst maybeFinalizeAfterExit = () => {\n\t\t\tif (!exited || settled) return;\n\t\t\tif (stdoutEnded && stderrEnded) {\n\t\t\t\tfinalize(exitCode);\n\t\t\t}\n\t\t};\n\n\t\tconst armIdleTimer = () => {\n\t\t\tif (postExitIdleTimer) clearTimeout(postExitIdleTimer);\n\t\t\tpostExitIdleTimer = setTimeout(() => finalize(exitCode), EXIT_STDIO_IDLE_GRACE_MS);\n\t\t};\n\n\t\tconst armActiveDrainHardCapTimer = () => {\n\t\t\tif (postExitActiveDrainHardCapTimer) return;\n\t\t\tpostExitActiveDrainHardCapTimer = setTimeout(() => finalize(exitCode), EXIT_STDIO_ACTIVE_DRAIN_HARD_CAP_MS);\n\t\t};\n\n\t\tconst onData = () => {\n\t\t\t// Output is still arriving after exit; keep extending the idle grace\n\t\t\t// so active finite writers can drain without truncating the tail.\n\t\t\tif (exited && !settled) armIdleTimer();\n\t\t};\n\n\t\tconst onStdoutEnd = () => {\n\t\t\tstdoutEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onStderrEnd = () => {\n\t\t\tstderrEnded = true;\n\t\t\tmaybeFinalizeAfterExit();\n\t\t};\n\n\t\tconst onError = (err: Error) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\treject(err);\n\t\t};\n\t\tconst onExit = (code: number | null, signal: NodeJS.Signals | null) => {\n\t\t\tif (windowsExitCodeGraceTimer) {\n\t\t\t\tclearTimeout(windowsExitCodeGraceTimer);\n\t\t\t\twindowsExitCodeGraceTimer = undefined;\n\t\t\t}\n\t\t\texited = true;\n\t\t\texitCode = mapSignalExitCode(code, signal, platform);\n\t\t\tmaybeFinalizeAfterExit();\n\t\t\tif (!settled) {\n\t\t\t\tarmActiveDrainHardCapTimer();\n\t\t\t\tarmIdleTimer();\n\t\t\t}\n\t\t};\n\n\t\tconst armWindowsExitCodeGraceTimer = () => {\n\t\t\tif (windowsExitCodeGraceTimer) return;\n\t\t\tif (windowsExitPoll) {\n\t\t\t\tclearInterval(windowsExitPoll);\n\t\t\t\twindowsExitPoll = undefined;\n\t\t\t}\n\t\t\twindowsExitCodeGraceTimer = setTimeout(() => {\n\t\t\t\twindowsExitCodeGraceTimer = undefined;\n\t\t\t\tonExit(child.exitCode ?? 0, null);\n\t\t\t}, windowsExitCodeGraceMs);\n\t\t};\n\n\t\tconst pollWindowsExit = () => {\n\t\t\tif (platform !== \"win32\" || !child.pid || exited || settled) return;\n\t\t\tif (!processAlive(child.pid)) {\n\t\t\t\tif (child.exitCode !== null) {\n\t\t\t\t\tonExit(child.exitCode, null);\n\t\t\t\t} else {\n\t\t\t\t\tarmWindowsExitCodeGraceTimer();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tconst onClose = (code: number | null, signal: NodeJS.Signals | null) => {\n\t\t\tfinalize(mapSignalExitCode(code, signal, platform));\n\t\t};\n\n\t\tif (platform === \"win32\" && child.pid) {\n\t\t\twindowsExitPoll = setInterval(pollWindowsExit, windowsExitPollIntervalMs);\n\t\t}\n\t\tchild.stdout?.once(\"end\", onStdoutEnd);\n\t\tchild.stderr?.once(\"end\", onStderrEnd);\n\t\tchild.stdout?.on(\"data\", onData);\n\t\tchild.stderr?.on(\"data\", onData);\n\t\tchild.once(\"error\", onError);\n\t\tchild.once(\"exit\", onExit);\n\t\tchild.once(\"close\", onClose);\n\t});\n}\n"]}
@@ -65,7 +65,7 @@ A package can provide [storage adapters](/storage#selecting-an-adapter) with `st
65
65
  }
66
66
  ```
67
67
 
68
- Users select the adapter with the package name, for example `"storage": { "adapter": "@example/atomic-libsql" }`, or with `<package>/<name>` when the package lists several adapters, where `<name>` is the adapter file's name without its extension. Storage adapters are only read from the manifest, never from a convention directory, and only from packages in user settings. See [Adapters from Atomic packages](/storage#adapters-from-atomic-packages).
68
+ Users select the adapter with the package name, for example `"storage": { "adapter": "@example/atomic-libsql" }`, or with `<package>/<name>` when the package lists several adapters, where `<name>` is the adapter file's name without its extension. Storage adapters are only read from the manifest, never from a convention directory, and only from packages in user settings or package directories the process was given as extension paths. An application that embeds Atomic and loads its own package with `additionalExtensionPaths: [packageRoot]` or `--extension <dir>` can select its adapter by its package name without installing the package; Atomic checks those packages before the ones in settings. See [Adapters from Atomic packages](/storage#adapters-from-atomic-packages).
69
69
 
70
70
  ### Gallery Metadata
71
71
 
package/docs/sdk.md CHANGED
@@ -233,6 +233,8 @@ const { session } = await createAgentSession({
233
233
 
234
234
  Other selections are `{ kind: "jsonl", dir }`, `{ kind: "memory" }`, `{ kind: "database", database, prefix? }`, and `{ kind: "adapter", module, options?, secrets?, prefix? }`. `database` must implement the async `SqliteDatabase` facade. Install your own driver and expose an adapter module for a remote database; Atomic bundles only its local `node:sqlite` adapter. See [Storage adapters](/storage).
235
235
 
236
+ An application that ships its adapter in its own Atomic package can select it by package name. List the adapter under `storageAdapters` in the package manifest, pass the package directory to `new DefaultResourceLoader({ additionalExtensionPaths: [packageRoot] })` before opening storage, and use `module: "@example/app"` (or `adapter` in settings, `journal`, and the storage variables). The processes Atomic starts receive the resolved module. See [Adapters from Atomic packages](/storage#adapters-from-atomic-packages).
237
+
236
238
  `createAgentSession({ storage })` takes a selection in the form of the top-level `storage` setting, such as the one `teamProfileSelection()` returns, for both the session store and the session's `workflow` tool journal; `sessionStore` and `journal` outrank it for their domain. See [Team and CI setup](/guides/team-setup#from-the-sdk).
237
239
 
238
240
  `sessionStore` also accepts a `SessionStore` instance. A supplied `sessionManager` takes precedence and remains caller-owned. Otherwise, explicit SDK storage wins over the process-level variables (`ATOMIC_SESSIONS_STORAGE` or the session-directory variable, then `ATOMIC_STORAGE`), `sessions.storage`, shared `storage`, and the persistent default. Memory is never a default or an opening-failure fallback. The `sessionDir` factory option has been removed; use a JSONL `sessionStore` selection instead. See [Session storage settings](/settings#sessions) for scope and path rules, and [Selecting storage per process](/storage#selecting-storage-per-process) to choose storage for the processes a host starts, such as `atomic --mode rpc` children, without editing settings.
package/docs/settings.md CHANGED
@@ -707,7 +707,7 @@ To keep workflow records only in memory, set `"journal": { "memory": true }`. Do
707
707
 
708
708
  Project `workflows.journal` and `storage` each replace their global selection as a whole, including options, secrets, and prefix. For example, a project can select `{ "memory": true }` over a global path. Invalid selected settings raise `StorageConfigError` instead of trying a lower-precedence selection. Combining `memory: true` with a non-empty `path` is an error.
709
709
 
710
- To use your own database driver, install an adapter module, for example as an [Atomic package](/storage#adapters-from-atomic-packages), and select it by package name or module path:
710
+ To use your own database driver, install an adapter module, for example as an [Atomic package](/storage#adapters-from-atomic-packages), and select it by package name or module path. A package name also selects an adapter from a package directory the process was given with `--extension` or the SDK's `additionalExtensionPaths`, ahead of the packages in settings:
711
711
 
712
712
  ```json
713
713
  {
package/docs/storage.md CHANGED
@@ -320,7 +320,7 @@ export default {
320
320
  } satisfies StorageAdapterModule;
321
321
  ```
322
322
 
323
- Select it with `sessions.storage: { "adapter": "./storage/libsql-adapter.ts" }`, `workflows.journal`, or shared top-level `storage` in [settings](/settings#workflow-storage). SDK sessions accept `sessionStore: { kind: "adapter", module, options, secrets, prefix }`; workflow runs accept `journal: { adapter, options, secrets, prefix }`. Relative module paths resolve from the agent directory, normally `~/.atomic/agent`; absolute module paths also work. A package name selects an adapter from an [installed Atomic package](#adapters-from-atomic-packages), or otherwise resolves from the agent directory. Project settings follow the same trust boundary as project extensions. A module executes with Atomic's privileges.
323
+ Select it with `sessions.storage: { "adapter": "./storage/libsql-adapter.ts" }`, `workflows.journal`, or shared top-level `storage` in [settings](/settings#workflow-storage). SDK sessions accept `sessionStore: { kind: "adapter", module, options, secrets, prefix }`; workflow runs accept `journal: { adapter, options, secrets, prefix }`. Relative module paths resolve from the agent directory, normally `~/.atomic/agent`; absolute module paths also work. A package name selects an adapter from an [Atomic package](#adapters-from-atomic-packages) that the host loaded or that is installed, or otherwise resolves from the agent directory. Project settings follow the same trust boundary as project extensions. A module executes with Atomic's privileges.
324
324
 
325
325
  Adapter modules import `@bastani/atomic/storage` and `@bastani/atomic` from the running Atomic, in the npm package and the standalone binary alike, exactly as extensions do. This covers the adapter's entry file and the ES module and TypeScript files it imports by relative path, including `.mjs` files and `.js` files in a `"type": "module"` package. CommonJS files other than the entry file, such as a `.cjs` file or a `.js` file outside a `"type": "module"` package, resolve these specifiers from `node_modules` instead. Import the module in an ES module file and pass it to them. Adapters need no installed or linked copy of Atomic, and Atomic recognizes the storage errors they throw. List `@bastani/atomic` in an adapter package's `peerDependencies`, not its `dependencies`.
326
326
 
@@ -363,7 +363,17 @@ Install it with `atomic install npm:@example/atomic-libsql` and select it by pac
363
363
  }
364
364
  ```
365
365
 
366
- The package name selects the package's first listed adapter. When a package lists several, select one with `<package>/<name>`, where `<name>` is the adapter file's name without its extension, for example `@example/atomic-libsql/libsql-adapter`. Atomic searches the packages in your effective global settings, including legacy `~/.pi/agent/settings.json` settings where applicable; an explicit agent directory does not inherit packages from another home. `atomic install` writes user settings without `-l`; project packages are not searched. When no installed package lists a matching adapter, the name resolves from the agent directory as before.
366
+ The package name selects the package's first listed adapter. When a package lists several, select one with `<package>/<name>`, where `<name>` is the adapter file's name without its extension, for example `@example/atomic-libsql/libsql-adapter`.
367
+
368
+ An application that embeds Atomic can select an adapter from its own package the same way, without installing it. Pass the package directory as an extension path, with `--extension <dir>` on the command line or `additionalExtensionPaths: [packageRoot]` on the SDK's `DefaultResourceLoader`, and select `"adapter": "@example/app"` or `"@example/app/<name>"` in settings, `--storage`, `--storage-file`, or the [storage variables](#selecting-storage-per-process). The selection then keeps working when the application is reinstalled in another location. Only package directories the process was given to load as code count. Construct the loader before opening any storage that names the package.
369
+
370
+ Atomic looks up a package name in this order:
371
+
372
+ 1. Package directories the process was given as extension paths, in the order given, and those of the Atomic process that started it.
373
+ 2. Packages in your effective global settings, including legacy `~/.pi/agent/settings.json` settings where applicable. An explicit agent directory does not inherit packages from another home. `atomic install` writes user settings without `-l`; project packages are not searched.
374
+ 3. The agent directory, which resolves the name as a module specifier, as before.
375
+
376
+ Processes that Atomic starts, such as local workflow workers, child workflow processes, and the Intercom broker, receive the adapter modules resolved from the host's packages in the `ATOMIC_HOST_STORAGE_ADAPTERS` variable. They open the same storage by the same name without loading the host's package. The variable holds absolute module paths, so like a storage variable that names a module, it should only come from a process you trust. `atomic storage status` shows the resolved module (`from <path>`) when it runs in such a process. Run directly from a shell, it does not load the host's package, so it can only resolve the name from settings packages or the agent directory.
367
377
 
368
378
  ## Selecting storage per process
369
379
 
@@ -385,6 +395,8 @@ ATOMIC_STORAGE='{"adapter":"@example/atomic-sqlite","options":{"url":"libsql://t
385
395
  atomic --mode rpc --storage-file /etc/atomic/storage.json
386
396
  ```
387
397
 
398
+ An adapter selected by package name can come from a package the host passes with `--extension <dir>` (see [Adapters from Atomic packages](#adapters-from-atomic-packages)), so the selection holds no absolute module path.
399
+
388
400
  Nothing is written to settings. A process started without these options keeps using its settings, so an interactive `atomic` and an RPC child started with `ATOMIC_STORAGE` in the same account each keep their own sessions and workflow runs, and `/resume` in each lists only its own store. `--storage` and `--storage-file` cannot be combined. The interactive CLI passes its `--storage` selection to its background engine process. Other processes that Atomic starts inherit the environment variables but not the flag.
389
401
 
390
402
  The Intercom broker an Atomic process starts uses the same selection for multi-node routing: `--storage`, `--storage-file`, `ATOMIC_STORAGE`, or `ATOMIC_PROFILE=ci` from that process outranks the top-level `storage` setting, and a broker started by a process without them reads settings. One broker serves every session in an agent directory, so it keeps the selection of the process that started it until it exits or `atomic intercom restart` replaces it. Project settings never select the broker's storage.
@@ -210,7 +210,7 @@ Common controls:
210
210
  Surface behavior:
211
211
 
212
212
  - **Graph vs. stage chat** - Use `connect` for the workflow graph. Use `attach` when you want a chat pane for a specific stage.
213
- - **Run state** - The graph header puts the run's state before its stage counts and colors the ORCHESTRATOR pill to match: `↑ blocked`, followed by the exit reason when the workflow gave one and shortened to fit; `❚❚ paused`; `○ quit`; or `● resumed` while a resumed run is live, so you know more stages will appear. `↑ N` counts blocked stages. The stage switcher (`/`), `/workflow status`, and the `/workflow connect` picker show the same state.
213
+ - **Run state** - The graph header puts the run's state before its stage counts and colors the ORCHESTRATOR pill to match: `↑ blocked`, followed by the exit reason when the workflow gave one and shortened to fit; `❚❚ paused`; or `○ quit`. A running run shows no state, including one you resumed. `↑ N` counts blocked stages. The stage switcher (`/`), `/workflow status`, and the `/workflow connect` picker show the same state.
214
214
  - **Hierarchy chord** - `ctrl+x` is the workflow hierarchy chord: in an attached stage chat it means **return to graph**, and in the graph it means **return to main chat**. The workflow surface handles `ctrl+x` before configurable editor or tool actions, including while a composer draft, primitive prompt, custom question, stage switcher, or legacy prompt card owns input.
215
215
  - **Stage input label** - Attached stage chats show `[stage: name]` on the composer top rule, a mounted question's top rule, and awaiting-input prompt borders so you can tell which stage owns the input. Long names truncate with `…`. A subagent's transcript opened from `/tasks` labels its prompt `[subagent: name]` the same way.
216
216
  - **Draft preservation** - Leaving a stage preserves unsent composer and prompt drafts and keeps pending custom questions unresolved so they reappear when you attach again.
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.79",
3
+ "version": "0.9.80",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bastani/atomic",
9
- "version": "0.9.79",
9
+ "version": "0.9.80",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@bastani/atomic-natives": "0.9.79",
13
- "@bastani/pi-ai": "0.9.79",
12
+ "@bastani/atomic-natives": "0.9.80",
13
+ "@bastani/pi-ai": "0.9.80",
14
14
  "@earendil-works/pi-agent-core": "1.5.2",
15
15
  "@earendil-works/pi-codemode": "1.5.2",
16
16
  "@earendil-works/pi-tui": "1.5.2",
@@ -427,18 +427,18 @@
427
427
  }
428
428
  },
429
429
  "node_modules/@bastani/atomic-natives": {
430
- "version": "0.9.79",
431
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.79.tgz",
430
+ "version": "0.9.80",
431
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.80.tgz",
432
432
  "license": "MIT",
433
433
  "optionalDependencies": {
434
- "@bastani/atomic-natives-darwin-arm64": "0.9.79",
435
- "@bastani/atomic-natives-darwin-x64": "0.9.79",
436
- "@bastani/atomic-natives-linux-arm64-gnu": "0.9.79",
437
- "@bastani/atomic-natives-linux-arm64-musl": "0.9.79",
438
- "@bastani/atomic-natives-linux-x64-gnu": "0.9.79",
439
- "@bastani/atomic-natives-linux-x64-musl": "0.9.79",
440
- "@bastani/atomic-natives-win32-arm64-msvc": "0.9.79",
441
- "@bastani/atomic-natives-win32-x64-msvc": "0.9.79"
434
+ "@bastani/atomic-natives-darwin-arm64": "0.9.80",
435
+ "@bastani/atomic-natives-darwin-x64": "0.9.80",
436
+ "@bastani/atomic-natives-linux-arm64-gnu": "0.9.80",
437
+ "@bastani/atomic-natives-linux-arm64-musl": "0.9.80",
438
+ "@bastani/atomic-natives-linux-x64-gnu": "0.9.80",
439
+ "@bastani/atomic-natives-linux-x64-musl": "0.9.80",
440
+ "@bastani/atomic-natives-win32-arm64-msvc": "0.9.80",
441
+ "@bastani/atomic-natives-win32-x64-msvc": "0.9.80"
442
442
  },
443
443
  "engines": {
444
444
  "bun": ">=1.4.2",
@@ -446,8 +446,8 @@
446
446
  }
447
447
  },
448
448
  "node_modules/@bastani/atomic-natives-darwin-arm64": {
449
- "version": "0.9.79",
450
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.79.tgz",
449
+ "version": "0.9.80",
450
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.80.tgz",
451
451
  "license": "MIT",
452
452
  "os": [
453
453
  "darwin"
@@ -458,8 +458,8 @@
458
458
  "optional": true
459
459
  },
460
460
  "node_modules/@bastani/atomic-natives-darwin-x64": {
461
- "version": "0.9.79",
462
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.79.tgz",
461
+ "version": "0.9.80",
462
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.80.tgz",
463
463
  "license": "MIT",
464
464
  "os": [
465
465
  "darwin"
@@ -470,8 +470,8 @@
470
470
  "optional": true
471
471
  },
472
472
  "node_modules/@bastani/atomic-natives-linux-arm64-gnu": {
473
- "version": "0.9.79",
474
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.79.tgz",
473
+ "version": "0.9.80",
474
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.80.tgz",
475
475
  "license": "MIT",
476
476
  "os": [
477
477
  "linux"
@@ -485,8 +485,8 @@
485
485
  "optional": true
486
486
  },
487
487
  "node_modules/@bastani/atomic-natives-linux-arm64-musl": {
488
- "version": "0.9.79",
489
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.79.tgz",
488
+ "version": "0.9.80",
489
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.80.tgz",
490
490
  "license": "MIT",
491
491
  "os": [
492
492
  "linux"
@@ -500,8 +500,8 @@
500
500
  "optional": true
501
501
  },
502
502
  "node_modules/@bastani/atomic-natives-linux-x64-gnu": {
503
- "version": "0.9.79",
504
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.79.tgz",
503
+ "version": "0.9.80",
504
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.80.tgz",
505
505
  "license": "MIT",
506
506
  "os": [
507
507
  "linux"
@@ -515,8 +515,8 @@
515
515
  "optional": true
516
516
  },
517
517
  "node_modules/@bastani/atomic-natives-linux-x64-musl": {
518
- "version": "0.9.79",
519
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.79.tgz",
518
+ "version": "0.9.80",
519
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.80.tgz",
520
520
  "license": "MIT",
521
521
  "os": [
522
522
  "linux"
@@ -530,8 +530,8 @@
530
530
  "optional": true
531
531
  },
532
532
  "node_modules/@bastani/atomic-natives-win32-arm64-msvc": {
533
- "version": "0.9.79",
534
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.79.tgz",
533
+ "version": "0.9.80",
534
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.80.tgz",
535
535
  "license": "MIT",
536
536
  "os": [
537
537
  "win32"
@@ -542,8 +542,8 @@
542
542
  "optional": true
543
543
  },
544
544
  "node_modules/@bastani/atomic-natives-win32-x64-msvc": {
545
- "version": "0.9.79",
546
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.79.tgz",
545
+ "version": "0.9.80",
546
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.80.tgz",
547
547
  "license": "MIT",
548
548
  "os": [
549
549
  "win32"
@@ -554,8 +554,8 @@
554
554
  "optional": true
555
555
  },
556
556
  "node_modules/@bastani/pi-ai": {
557
- "version": "0.9.79",
558
- "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.79.tgz",
557
+ "version": "0.9.80",
558
+ "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.80.tgz",
559
559
  "license": "MIT",
560
560
  "dependencies": {
561
561
  "@anthropic-ai/sdk": "0.129.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.79",
3
+ "version": "0.9.80",
4
4
  "description": "Atomic coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "atomicConfig": {
@@ -89,8 +89,8 @@
89
89
  "prepublishOnly": "bun run clean && bun run build && bun run shrinkwrap"
90
90
  },
91
91
  "dependencies": {
92
- "@bastani/atomic-natives": "0.9.79",
93
- "@bastani/pi-ai": "0.9.79",
92
+ "@bastani/atomic-natives": "0.9.80",
93
+ "@bastani/pi-ai": "0.9.80",
94
94
  "@earendil-works/pi-agent-core": "1.5.2",
95
95
  "@earendil-works/pi-codemode": "1.5.2",
96
96
  "@earendil-works/pi-tui": "1.5.2",