@bastani/atomic 0.9.20-alpha.8 → 0.9.20
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.
- package/CHANGELOG.md +288 -0
- package/dist/builtin/intercom/CHANGELOG.md +25 -0
- package/dist/builtin/intercom/package.json +3 -5
- package/dist/builtin/mcp/CHANGELOG.md +13 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/subagents/CHANGELOG.md +56 -0
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/skills/tdd/SKILL.md +10 -2
- package/dist/builtin/subagents/skills/tdd/mocking.md +4 -0
- package/dist/builtin/subagents/skills/tdd/test-audit.md +105 -0
- package/dist/builtin/subagents/skills/tdd/tests.md +3 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +13 -3
- package/dist/builtin/web-access/CHANGELOG.md +13 -0
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +169 -0
- package/dist/builtin/workflows/README.md +1 -1
- package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
- package/dist/builtin/workflows/builtin/{chunk-njmf5ze7.js → chunk-0nrgfbag.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-hmt5w62g.js → chunk-2hak3b7g.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-2hzrv5y8.js → chunk-73c5tayt.js} +1020 -200
- package/dist/builtin/workflows/builtin/{chunk-ffdrv23t.js → chunk-bzdvx2xr.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-5724b0cf.js → chunk-crw7q5g1.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-7n51c5gh.js → chunk-cw86srkf.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-dxjxtgmp.js → chunk-jaj27rqc.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-3tx8ry44.js → chunk-kspvwc24.js} +3 -2
- package/dist/builtin/workflows/builtin/{chunk-7bzcersz.js → chunk-maqv731g.js} +3 -3
- package/dist/builtin/workflows/builtin/{chunk-9z3ztr2a.js → chunk-vkmpdat4.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-vn0wb31x.js → chunk-w18kbz63.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-jngsbbpm.js → chunk-wh19f5ee.js} +3 -3
- package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
- package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
- package/dist/builtin/workflows/builtin/goal.js +4 -4
- package/dist/builtin/workflows/builtin/index.js +12 -12
- package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
- package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +4 -4
- package/dist/builtin/workflows/builtin/steering-context.js +1 -1
- package/dist/builtin/workflows/builtin/tournament.js +3 -3
- package/dist/builtin/workflows/package.json +4 -4
- package/dist/builtin/workflows/src/authoring.d.ts +6 -3
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +12164 -11365
- package/dist/builtin/workflows/src/index.js +41685 -12907
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +13 -0
- package/dist/core/agent-session-boundaries.d.ts.map +1 -1
- package/dist/core/agent-session-boundaries.js +9 -4
- package/dist/core/agent-session-boundaries.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +4 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +3 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
- package/dist/core/agent-session-queue-pause.js +2 -1
- package/dist/core/agent-session-queue-pause.js.map +1 -1
- package/dist/core/agent-session-tasks.js +4 -4
- package/dist/core/agent-session-tasks.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +4 -3
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +3 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/cache-stats.d.ts +7 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +24 -5
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/context-tool-pairing.d.ts +10 -14
- package/dist/core/context-tool-pairing.d.ts.map +1 -1
- package/dist/core/context-tool-pairing.js +99 -28
- package/dist/core/context-tool-pairing.js.map +1 -1
- package/dist/core/execution-model-router.d.ts +1 -1
- package/dist/core/execution-model-router.d.ts.map +1 -1
- package/dist/core/execution-model-router.js +23 -14
- package/dist/core/execution-model-router.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +9 -1
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +2 -1
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/event-types.d.ts +2 -2
- package/dist/core/extensions/event-types.d.ts.map +1 -1
- package/dist/core/extensions/event-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +1 -0
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +34 -16
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +4 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/tool-types.d.ts +9 -0
- package/dist/core/extensions/tool-types.d.ts.map +1 -1
- package/dist/core/extensions/tool-types.js.map +1 -1
- package/dist/core/fast-model-routing.d.ts.map +1 -1
- package/dist/core/fast-model-routing.js +1 -0
- package/dist/core/fast-model-routing.js.map +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +2 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry.d.ts +3 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +6 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-runtime-auth.d.ts +2 -2
- package/dist/core/model-runtime-auth.d.ts.map +1 -1
- package/dist/core/model-runtime-auth.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +2 -1
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime.d.ts +11 -3
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +41 -6
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager-npm.d.ts.map +1 -1
- package/dist/core/package-manager-npm.js +32 -8
- package/dist/core/package-manager-npm.js.map +1 -1
- package/dist/core/package-manager-resolver.js +3 -1
- package/dist/core/package-manager-resolver.js.map +1 -1
- package/dist/core/package-manager-types.d.ts +1 -0
- package/dist/core/package-manager-types.d.ts.map +1 -1
- package/dist/core/package-manager-types.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts +40 -21
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +22 -20
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/provider-composer.d.ts +3 -3
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +54 -10
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +8 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +46 -4
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +7 -3
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-extension-warnings.d.ts +9 -0
- package/dist/core/resource-loader-extension-warnings.d.ts.map +1 -0
- package/dist/core/resource-loader-extension-warnings.js +54 -0
- package/dist/core/resource-loader-extension-warnings.js.map +1 -0
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +1 -0
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +6 -0
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +3 -1
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.js +16 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +4 -4
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/structured-output/choice-schema.d.ts +8 -0
- package/dist/core/structured-output/choice-schema.d.ts.map +1 -0
- package/dist/core/structured-output/choice-schema.js +79 -0
- package/dist/core/structured-output/choice-schema.js.map +1 -0
- package/dist/core/structured-output/index.d.ts +3 -5
- package/dist/core/structured-output/index.d.ts.map +1 -1
- package/dist/core/structured-output/index.js +218 -41
- package/dist/core/structured-output/index.js.map +1 -1
- package/dist/core/structured-output/resolver.d.ts +0 -46
- package/dist/core/structured-output/resolver.d.ts.map +1 -1
- package/dist/core/structured-output/resolver.js +15 -93
- package/dist/core/structured-output/resolver.js.map +1 -1
- package/dist/core/structured-output/types.d.ts +27 -21
- package/dist/core/structured-output/types.d.ts.map +1 -1
- package/dist/core/structured-output/types.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +9 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/owner-store.d.ts +6 -0
- package/dist/core/tasks/owner-store.d.ts.map +1 -1
- package/dist/core/tasks/owner-store.js +16 -3
- package/dist/core/tasks/owner-store.js.map +1 -1
- package/dist/core/tasks/pause.js +1 -1
- package/dist/core/tasks/pause.js.map +1 -1
- package/dist/core/tasks/supervisor.d.ts +4 -2
- package/dist/core/tasks/supervisor.d.ts.map +1 -1
- package/dist/core/tasks/supervisor.js +9 -3
- package/dist/core/tasks/supervisor.js.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.js +1 -0
- package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +1 -0
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +1 -0
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-coordinator.d.ts +4 -3
- package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-coordinator.js +45 -38
- package/dist/core/tools/file-mutation-coordinator.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/structured-output.d.ts +9 -6
- package/dist/core/tools/structured-output.d.ts.map +1 -1
- package/dist/core/tools/structured-output.js +36 -8
- package/dist/core/tools/structured-output.js.map +1 -1
- package/dist/core/tools/todos.d.ts.map +1 -1
- package/dist/core/tools/todos.js +1 -0
- package/dist/core/tools/todos.js.map +1 -1
- package/dist/core/tools/tool-concurrency.d.ts +23 -0
- package/dist/core/tools/tool-concurrency.d.ts.map +1 -0
- package/dist/core/tools/tool-concurrency.js +58 -0
- package/dist/core/tools/tool-concurrency.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +4 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +1 -0
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +4 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +11 -9
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/task-inspector.d.ts +1 -0
- package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-inspector.js +11 -11
- package/dist/modes/interactive/components/task-inspector.js.map +1 -1
- package/dist/modes/interactive/components/task-list.d.ts +9 -3
- package/dist/modes/interactive/components/task-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-list.js +26 -2
- package/dist/modes/interactive/components/task-list.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +3 -9
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +1 -1
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +3 -9
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +6 -9
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +1 -0
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +2 -4
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +5 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +14 -17
- package/dist/utils/clipboard-image.js.map +1 -1
- package/docs/background-tasks.md +1 -0
- package/docs/computer-use.md +33 -9
- package/docs/custom-provider/registration.md +1 -1
- package/docs/custom-provider.md +43 -1
- package/docs/extensions/authoring.md +22 -3
- package/docs/extensions/events.md +18 -0
- package/docs/extensions/examples.md +1 -0
- package/docs/getting-started/first-session.md +1 -1
- package/docs/models/evals.md +31 -79
- package/docs/models/model-selection.md +5 -1
- package/docs/packages/authoring.md +3 -1
- package/docs/providers.md +7 -11
- package/docs/sdk/reference.md +18 -42
- package/docs/sdk/structured-decisions.md +44 -89
- package/docs/sdk.md +1 -1
- package/docs/settings.md +6 -6
- package/docs/skills.md +2 -2
- package/docs/subagents/reference.md +7 -8
- package/docs/usage.md +13 -0
- package/docs/workflows/api-reference.md +38 -35
- package/docs/workflows/authoring.md +113 -1
- package/docs/workflows/builtins.md +1 -1
- package/docs/workflows/operations.md +53 -29
- package/docs/workflows/reliable-design.md +1 -1
- package/docs/workflows/verification.md +38 -7
- package/docs/workflows.md +1 -1
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/debug-provider.ts +90 -0
- package/examples/extensions/structured-output.ts +6 -0
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
- package/dist/builtin/workflows/src/durable/dependency-doctor-types.d.ts +0 -42
- package/dist/core/decision-provider.d.ts +0 -4
- package/dist/core/decision-provider.d.ts.map +0 -1
- package/dist/core/decision-provider.js +0 -12
- package/dist/core/decision-provider.js.map +0 -1
- package/dist/core/structured-output/jev-client.d.ts +0 -25
- package/dist/core/structured-output/jev-client.d.ts.map +0 -1
- package/dist/core/structured-output/jev-client.js +0 -174
- package/dist/core/structured-output/jev-client.js.map +0 -1
- package/dist/core/structured-output/jev.d.ts +0 -5
- package/dist/core/structured-output/jev.d.ts.map +0 -1
- package/dist/core/structured-output/jev.js +0 -249
- package/dist/core/structured-output/jev.js.map +0 -1
|
@@ -167,23 +167,20 @@ function readClipboardImageViaXclip() {
|
|
|
167
167
|
const targets = runCommand("xclip", ["-selection", "clipboard", "-t", "TARGETS", "-o"], {
|
|
168
168
|
timeoutMs: DEFAULT_LIST_TIMEOUT_MS,
|
|
169
169
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return null;
|
|
170
|
+
if (!targets.ok)
|
|
171
|
+
return null;
|
|
172
|
+
const candidateTypes = targets.stdout
|
|
173
|
+
.toString("utf-8")
|
|
174
|
+
.split(/\r?\n/)
|
|
175
|
+
.map((t) => t.trim())
|
|
176
|
+
.filter(Boolean);
|
|
177
|
+
const preferred = selectPreferredImageMimeType(candidateTypes);
|
|
178
|
+
if (!preferred)
|
|
179
|
+
return null;
|
|
180
|
+
const data = runCommand("xclip", ["-selection", "clipboard", "-t", preferred, "-o"]);
|
|
181
|
+
if (!data.ok || data.stdout.length === 0)
|
|
182
|
+
return null;
|
|
183
|
+
return { bytes: data.stdout, mimeType: baseMimeType(preferred) };
|
|
187
184
|
}
|
|
188
185
|
async function readClipboardImageViaNativeClipboard() {
|
|
189
186
|
if (!clipboard?.hasImage()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":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AO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAEtC,IAAI,OAAO,IAAI,GAAG,EAAE,CAAC;YACpB,KAAK,GAAG,4BAA4B,EAAE,IAAI,0BAA0B,EAAE,CAAC;QACxE,CAAC;QAED,IAAI,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;YACnB,KAAK,GAAG,+BAA+B,EAAE,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;YACxB,KAAK,GAAG,MAAM,oCAAoC,EAAE,CAAC;YACrD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACZ,KAAK,GAAG,0BAA0B,EAAE,CAAC;YACtC,CAAC;QACF,CAAC;IACF,CAAC;SAAM,CAAC;QACP,KAAK,GAAG,MAAM,oCAAoC,EAAE,CAAC;IACtD,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;IAED,2DAA2D;IAC3D,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { spawnSync } from \"child_process\";\nimport { randomUUID } from \"crypto\";\nimport { readFileSync, unlinkSync } from \"fs\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\n\nimport { createChildProcessEnvironment } from \"./child-process.ts\";\nimport { clipboard } from \"./clipboard-native.ts\";\nimport { loadPhoton } from \"./photon.ts\";\nimport { isWSL } from \"./wsl.ts\";\n\nexport type ClipboardImage = {\n\tbytes: Uint8Array;\n\tmimeType: string;\n};\n\nconst SUPPORTED_IMAGE_MIME_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"] as const;\n\nconst DEFAULT_LIST_TIMEOUT_MS = 1000;\nconst DEFAULT_READ_TIMEOUT_MS = 3000;\nconst DEFAULT_POWERSHELL_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;\n\nexport function isWaylandSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === \"wayland\";\n}\n\nfunction baseMimeType(mimeType: string): string {\n\treturn mimeType.split(\";\")[0]?.trim().toLowerCase() ?? mimeType.toLowerCase();\n}\n\nexport function extensionForImageMimeType(mimeType: string): string | null {\n\tswitch (baseMimeType(mimeType)) {\n\t\tcase \"image/png\":\n\t\t\treturn \"png\";\n\t\tcase \"image/jpeg\":\n\t\t\treturn \"jpg\";\n\t\tcase \"image/webp\":\n\t\t\treturn \"webp\";\n\t\tcase \"image/gif\":\n\t\t\treturn \"gif\";\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction selectPreferredImageMimeType(mimeTypes: string[]): string | null {\n\tconst normalized = mimeTypes\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean)\n\t\t.map((t) => ({ raw: t, base: baseMimeType(t) }));\n\n\tfor (const preferred of SUPPORTED_IMAGE_MIME_TYPES) {\n\t\tconst match = normalized.find((t) => t.base === preferred);\n\t\tif (match) {\n\t\t\treturn match.raw;\n\t\t}\n\t}\n\n\tconst anyImage = normalized.find((t) => t.base.startsWith(\"image/\"));\n\treturn anyImage?.raw ?? null;\n}\n\nfunction isSupportedImageMimeType(mimeType: string): boolean {\n\tconst base = baseMimeType(mimeType);\n\treturn SUPPORTED_IMAGE_MIME_TYPES.some((t) => t === base);\n}\n\n/**\n * Convert unsupported image formats to PNG using Photon.\n * Returns null if conversion is unavailable or fails.\n */\nasync function convertToPng(bytes: Uint8Array): Promise<Uint8Array | null> {\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst image = photon.PhotonImage.new_from_byteslice(bytes);\n\t\ttry {\n\t\t\treturn image.get_bytes();\n\t\t} finally {\n\t\t\timage.free();\n\t\t}\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction runCommand(\n\tcommand: string,\n\targs: string[],\n\toptions?: { timeoutMs?: number; maxBufferBytes?: number; env?: NodeJS.ProcessEnv },\n): { stdout: Buffer; ok: boolean } {\n\tconst timeoutMs = options?.timeoutMs ?? DEFAULT_READ_TIMEOUT_MS;\n\tconst maxBufferBytes = options?.maxBufferBytes ?? DEFAULT_MAX_BUFFER_BYTES;\n\n\tconst result = spawnSync(command, args, {\n\t\ttimeout: timeoutMs,\n\t\tmaxBuffer: maxBufferBytes,\n\t\tenv: options?.env ? createChildProcessEnvironment(undefined, options.env) : createChildProcessEnvironment(),\n\t});\n\n\tif (result.error) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tif (result.status !== 0) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tconst stdout = Buffer.isBuffer(result.stdout)\n\t\t? result.stdout\n\t\t: Buffer.from(result.stdout ?? \"\", typeof result.stdout === \"string\" ? \"utf-8\" : undefined);\n\n\treturn { ok: true, stdout };\n}\n\nfunction readClipboardImageViaWlPaste(): ClipboardImage | null {\n\tconst list = runCommand(\"wl-paste\", [\"--list-types\"], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\tif (!list.ok) {\n\t\treturn null;\n\t}\n\n\tconst types = list.stdout\n\t\t.toString(\"utf-8\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean);\n\n\tconst selectedType = selectPreferredImageMimeType(types);\n\tif (!selectedType) {\n\t\treturn null;\n\t}\n\n\tconst data = runCommand(\"wl-paste\", [\"--type\", selectedType, \"--no-newline\"]);\n\tif (!data.ok || data.stdout.length === 0) {\n\t\treturn null;\n\t}\n\n\treturn { bytes: data.stdout, mimeType: baseMimeType(selectedType) };\n}\n\n/**\n * On WSL, the Linux clipboard (Wayland/X11) does not receive image data from\n * Windows screenshots (Win+Shift+S). PowerShell can access the Windows clipboard\n * directly, so we use it as a fallback.\n */\nfunction readClipboardImageViaPowerShell(): ClipboardImage | null {\n\tconst tmpFile = join(tmpdir(), `pi-wsl-clip-${randomUUID()}.png`);\n\n\ttry {\n\t\tconst winPathResult = runCommand(\"wslpath\", [\"-w\", tmpFile], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\t\tif (!winPathResult.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst winPath = winPathResult.stdout.toString(\"utf-8\").trim();\n\t\tif (!winPath) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst psQuotedWinPath = winPath.replaceAll(\"'\", \"''\");\n\t\tconst psScript = [\n\t\t\t\"Add-Type -AssemblyName System.Windows.Forms\",\n\t\t\t\"Add-Type -AssemblyName System.Drawing\",\n\t\t\t`$path = '${psQuotedWinPath}'`,\n\t\t\t\"$img = [System.Windows.Forms.Clipboard]::GetImage()\",\n\t\t\t\"if ($img) { $img.Save($path, [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' } else { Write-Output 'empty' }\",\n\t\t].join(\"; \");\n\n\t\tconst result = runCommand(\"powershell.exe\", [\"-NoProfile\", \"-Command\", psScript], {\n\t\t\ttimeoutMs: DEFAULT_POWERSHELL_TIMEOUT_MS,\n\t\t});\n\t\tif (!result.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst output = result.stdout.toString(\"utf-8\").trim();\n\t\tif (output !== \"ok\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst bytes = readFileSync(tmpFile);\n\t\tif (bytes.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn { bytes: new Uint8Array(bytes), mimeType: \"image/png\" };\n\t} catch {\n\t\treturn null;\n\t} finally {\n\t\ttry {\n\t\t\tunlinkSync(tmpFile);\n\t\t} catch {\n\t\t\t// Ignore cleanup errors.\n\t\t}\n\t}\n}\n\nfunction readClipboardImageViaXclip(): ClipboardImage | null {\n\tconst targets = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", \"TARGETS\", \"-o\"], {\n\t\ttimeoutMs: DEFAULT_LIST_TIMEOUT_MS,\n\t});\n\n\tlet candidateTypes: string[] = [];\n\tif (targets.ok) {\n\t\tcandidateTypes = targets.stdout\n\t\t\t.toString(\"utf-8\")\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((t) => t.trim())\n\t\t\t.filter(Boolean);\n\t}\n\n\tconst preferred = candidateTypes.length > 0 ? selectPreferredImageMimeType(candidateTypes) : null;\n\tconst tryTypes = preferred ? [preferred, ...SUPPORTED_IMAGE_MIME_TYPES] : [...SUPPORTED_IMAGE_MIME_TYPES];\n\n\tfor (const mimeType of tryTypes) {\n\t\tconst data = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", mimeType, \"-o\"]);\n\t\tif (data.ok && data.stdout.length > 0) {\n\t\t\treturn { bytes: data.stdout, mimeType: baseMimeType(mimeType) };\n\t\t}\n\t}\n\n\treturn null;\n}\n\nasync function readClipboardImageViaNativeClipboard(): Promise<ClipboardImage | null> {\n\tif (!clipboard?.hasImage()) {\n\t\treturn null;\n\t}\n\n\tconst imageData = await clipboard.getImageBinary();\n\tif (!imageData || imageData.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst bytes = imageData instanceof Uint8Array ? imageData : Uint8Array.from(imageData);\n\treturn { bytes, mimeType: \"image/png\" };\n}\n\nexport async function readClipboardImage(options?: {\n\tenv?: NodeJS.ProcessEnv;\n\tplatform?: NodeJS.Platform;\n}): Promise<ClipboardImage | null> {\n\tconst env = options?.env ?? process.env;\n\tconst platform = options?.platform ?? process.platform;\n\n\tif (env.TERMUX_VERSION) {\n\t\treturn null;\n\t}\n\n\tlet image: ClipboardImage | null = null;\n\n\tif (platform === \"linux\") {\n\t\tconst wsl = isWSL(env);\n\t\tconst wayland = isWaylandSession(env);\n\n\t\tif (wayland || wsl) {\n\t\t\timage = readClipboardImageViaWlPaste() ?? readClipboardImageViaXclip();\n\t\t}\n\n\t\tif (!image && wsl) {\n\t\t\timage = readClipboardImageViaPowerShell();\n\t\t}\n\n\t\tif (!image && !wayland) {\n\t\t\timage = await readClipboardImageViaNativeClipboard();\n\t\t\tif (!image) {\n\t\t\t\timage = readClipboardImageViaXclip();\n\t\t\t}\n\t\t}\n\t} else {\n\t\timage = await readClipboardImageViaNativeClipboard();\n\t}\n\n\tif (!image) {\n\t\treturn null;\n\t}\n\n\t// Convert unsupported formats (e.g., BMP from WSLg) to PNG\n\tif (!isSupportedImageMimeType(image.mimeType)) {\n\t\tconst pngBytes = await convertToPng(image.bytes);\n\t\tif (!pngBytes) {\n\t\t\treturn null;\n\t\t}\n\t\treturn { bytes: pngBytes, mimeType: \"image/png\" };\n\t}\n\n\treturn image;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"clipboard-image.js","sourceRoot":"","sources":["../../src/utils/clipboard-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAOjC,MAAM,0BAA0B,GAAG,CAAC,WAAW,EAAE,YAAY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AAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { spawnSync } from \"child_process\";\nimport { randomUUID } from \"crypto\";\nimport { readFileSync, unlinkSync } from \"fs\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\n\nimport { createChildProcessEnvironment } from \"./child-process.ts\";\nimport { clipboard } from \"./clipboard-native.ts\";\nimport { loadPhoton } from \"./photon.ts\";\nimport { isWSL } from \"./wsl.ts\";\n\nexport type ClipboardImage = {\n\tbytes: Uint8Array;\n\tmimeType: string;\n};\n\nconst SUPPORTED_IMAGE_MIME_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"] as const;\n\nconst DEFAULT_LIST_TIMEOUT_MS = 1000;\nconst DEFAULT_READ_TIMEOUT_MS = 3000;\nconst DEFAULT_POWERSHELL_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;\n\nexport function isWaylandSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === \"wayland\";\n}\n\nfunction baseMimeType(mimeType: string): string {\n\treturn mimeType.split(\";\")[0]?.trim().toLowerCase() ?? mimeType.toLowerCase();\n}\n\nexport function extensionForImageMimeType(mimeType: string): string | null {\n\tswitch (baseMimeType(mimeType)) {\n\t\tcase \"image/png\":\n\t\t\treturn \"png\";\n\t\tcase \"image/jpeg\":\n\t\t\treturn \"jpg\";\n\t\tcase \"image/webp\":\n\t\t\treturn \"webp\";\n\t\tcase \"image/gif\":\n\t\t\treturn \"gif\";\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction selectPreferredImageMimeType(mimeTypes: string[]): string | null {\n\tconst normalized = mimeTypes\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean)\n\t\t.map((t) => ({ raw: t, base: baseMimeType(t) }));\n\n\tfor (const preferred of SUPPORTED_IMAGE_MIME_TYPES) {\n\t\tconst match = normalized.find((t) => t.base === preferred);\n\t\tif (match) {\n\t\t\treturn match.raw;\n\t\t}\n\t}\n\n\tconst anyImage = normalized.find((t) => t.base.startsWith(\"image/\"));\n\treturn anyImage?.raw ?? null;\n}\n\nfunction isSupportedImageMimeType(mimeType: string): boolean {\n\tconst base = baseMimeType(mimeType);\n\treturn SUPPORTED_IMAGE_MIME_TYPES.some((t) => t === base);\n}\n\n/**\n * Convert unsupported image formats to PNG using Photon.\n * Returns null if conversion is unavailable or fails.\n */\nasync function convertToPng(bytes: Uint8Array): Promise<Uint8Array | null> {\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst image = photon.PhotonImage.new_from_byteslice(bytes);\n\t\ttry {\n\t\t\treturn image.get_bytes();\n\t\t} finally {\n\t\t\timage.free();\n\t\t}\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction runCommand(\n\tcommand: string,\n\targs: string[],\n\toptions?: { timeoutMs?: number; maxBufferBytes?: number; env?: NodeJS.ProcessEnv },\n): { stdout: Buffer; ok: boolean } {\n\tconst timeoutMs = options?.timeoutMs ?? DEFAULT_READ_TIMEOUT_MS;\n\tconst maxBufferBytes = options?.maxBufferBytes ?? DEFAULT_MAX_BUFFER_BYTES;\n\n\tconst result = spawnSync(command, args, {\n\t\ttimeout: timeoutMs,\n\t\tmaxBuffer: maxBufferBytes,\n\t\tenv: options?.env ? createChildProcessEnvironment(undefined, options.env) : createChildProcessEnvironment(),\n\t});\n\n\tif (result.error) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tif (result.status !== 0) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tconst stdout = Buffer.isBuffer(result.stdout)\n\t\t? result.stdout\n\t\t: Buffer.from(result.stdout ?? \"\", typeof result.stdout === \"string\" ? \"utf-8\" : undefined);\n\n\treturn { ok: true, stdout };\n}\n\nfunction readClipboardImageViaWlPaste(): ClipboardImage | null {\n\tconst list = runCommand(\"wl-paste\", [\"--list-types\"], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\tif (!list.ok) {\n\t\treturn null;\n\t}\n\n\tconst types = list.stdout\n\t\t.toString(\"utf-8\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean);\n\n\tconst selectedType = selectPreferredImageMimeType(types);\n\tif (!selectedType) {\n\t\treturn null;\n\t}\n\n\tconst data = runCommand(\"wl-paste\", [\"--type\", selectedType, \"--no-newline\"]);\n\tif (!data.ok || data.stdout.length === 0) {\n\t\treturn null;\n\t}\n\n\treturn { bytes: data.stdout, mimeType: baseMimeType(selectedType) };\n}\n\n/**\n * On WSL, the Linux clipboard (Wayland/X11) does not receive image data from\n * Windows screenshots (Win+Shift+S). PowerShell can access the Windows clipboard\n * directly, so we use it as a fallback.\n */\nfunction readClipboardImageViaPowerShell(): ClipboardImage | null {\n\tconst tmpFile = join(tmpdir(), `pi-wsl-clip-${randomUUID()}.png`);\n\n\ttry {\n\t\tconst winPathResult = runCommand(\"wslpath\", [\"-w\", tmpFile], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\t\tif (!winPathResult.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst winPath = winPathResult.stdout.toString(\"utf-8\").trim();\n\t\tif (!winPath) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst psQuotedWinPath = winPath.replaceAll(\"'\", \"''\");\n\t\tconst psScript = [\n\t\t\t\"Add-Type -AssemblyName System.Windows.Forms\",\n\t\t\t\"Add-Type -AssemblyName System.Drawing\",\n\t\t\t`$path = '${psQuotedWinPath}'`,\n\t\t\t\"$img = [System.Windows.Forms.Clipboard]::GetImage()\",\n\t\t\t\"if ($img) { $img.Save($path, [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' } else { Write-Output 'empty' }\",\n\t\t].join(\"; \");\n\n\t\tconst result = runCommand(\"powershell.exe\", [\"-NoProfile\", \"-Command\", psScript], {\n\t\t\ttimeoutMs: DEFAULT_POWERSHELL_TIMEOUT_MS,\n\t\t});\n\t\tif (!result.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst output = result.stdout.toString(\"utf-8\").trim();\n\t\tif (output !== \"ok\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst bytes = readFileSync(tmpFile);\n\t\tif (bytes.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn { bytes: new Uint8Array(bytes), mimeType: \"image/png\" };\n\t} catch {\n\t\treturn null;\n\t} finally {\n\t\ttry {\n\t\t\tunlinkSync(tmpFile);\n\t\t} catch {\n\t\t\t// Ignore cleanup errors.\n\t\t}\n\t}\n}\n\nfunction readClipboardImageViaXclip(): ClipboardImage | null {\n\tconst targets = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", \"TARGETS\", \"-o\"], {\n\t\ttimeoutMs: DEFAULT_LIST_TIMEOUT_MS,\n\t});\n\n\tif (!targets.ok) return null;\n\n\tconst candidateTypes = targets.stdout\n\t\t.toString(\"utf-8\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean);\n\tconst preferred = selectPreferredImageMimeType(candidateTypes);\n\tif (!preferred) return null;\n\n\tconst data = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", preferred, \"-o\"]);\n\tif (!data.ok || data.stdout.length === 0) return null;\n\treturn { bytes: data.stdout, mimeType: baseMimeType(preferred) };\n}\n\nasync function readClipboardImageViaNativeClipboard(): Promise<ClipboardImage | null> {\n\tif (!clipboard?.hasImage()) {\n\t\treturn null;\n\t}\n\n\tconst imageData = await clipboard.getImageBinary();\n\tif (!imageData || imageData.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst bytes = imageData instanceof Uint8Array ? imageData : Uint8Array.from(imageData);\n\treturn { bytes, mimeType: \"image/png\" };\n}\n\nexport async function readClipboardImage(options?: {\n\tenv?: NodeJS.ProcessEnv;\n\tplatform?: NodeJS.Platform;\n}): Promise<ClipboardImage | null> {\n\tconst env = options?.env ?? process.env;\n\tconst platform = options?.platform ?? process.platform;\n\n\tif (env.TERMUX_VERSION) {\n\t\treturn null;\n\t}\n\n\tlet image: ClipboardImage | null = null;\n\n\tif (platform === \"linux\") {\n\t\tconst wsl = isWSL(env);\n\t\tconst wayland = isWaylandSession(env);\n\n\t\tif (wayland || wsl) {\n\t\t\timage = readClipboardImageViaWlPaste() ?? readClipboardImageViaXclip();\n\t\t}\n\n\t\tif (!image && wsl) {\n\t\t\timage = readClipboardImageViaPowerShell();\n\t\t}\n\n\t\tif (!image && !wayland) {\n\t\t\timage = await readClipboardImageViaNativeClipboard();\n\t\t\tif (!image) {\n\t\t\t\timage = readClipboardImageViaXclip();\n\t\t\t}\n\t\t}\n\t} else {\n\t\timage = await readClipboardImageViaNativeClipboard();\n\t}\n\n\tif (!image) {\n\t\treturn null;\n\t}\n\n\t// Convert unsupported formats (e.g., BMP from WSLg) to PNG\n\tif (!isSupportedImageMimeType(image.mimeType)) {\n\t\tconst pngBytes = await convertToPng(image.bytes);\n\t\tif (!pngBytes) {\n\t\t\treturn null;\n\t\t}\n\t\treturn { bytes: pngBytes, mimeType: \"image/png\" };\n\t}\n\n\treturn image;\n}\n"]}
|
package/docs/background-tasks.md
CHANGED
|
@@ -20,6 +20,7 @@ The indicator counts active agents and shells, including queued, stopping, and a
|
|
|
20
20
|
Run `/tasks` to inspect work without stopping it:
|
|
21
21
|
|
|
22
22
|
- The compact picker opens in the editor slot, with the conversation visible above it. It lists only tasks owned by that chat.
|
|
23
|
+
- Within the **Agents** and **Shells** sections, tasks are ordered by status: running (tasks needing attention first), stopping, queued, failed, cancelled, then completed. The newest launch or settlement comes first within each status, and your selection follows its task when it moves.
|
|
23
24
|
- Detail, transcript, input, and cancellation-confirmation pages use the full screen.
|
|
24
25
|
- Escape returns to the picker with your selection preserved, then to chat.
|
|
25
26
|
- Completed background work remains available, including after a later foreground wait. Foreground-only commands are excluded.
|
package/docs/computer-use.md
CHANGED
|
@@ -19,8 +19,8 @@ Start with the result you need, not the application you could click through. If
|
|
|
19
19
|
| --- | --- | --- |
|
|
20
20
|
| Create or edit files, such as presentations, documents, spreadsheets, or media | **A file library or CLI** | Use an app API or UI when the library cannot preserve required features, or when you need rendering or visual adjustments. |
|
|
21
21
|
| Interactive terminal or TUI | **Herdr** | Use tmux on macOS/Linux or native Windows psmux when Herdr cannot be used. Ordinary shell commands need no multiplexer. |
|
|
22
|
-
| Website or web app in Chrome/Chromium, Electron desktop app (VS Code, Slack, Discord, Figma, Notion, Spotify), Slack workspace, or cloud browser | **agent-browser** |
|
|
23
|
-
| Native desktop application, iOS
|
|
22
|
+
| Website or web app in Chrome/Chromium, Mobile Safari in the iOS Simulator or on a connected iPhone/iPad, Electron desktop app (VS Code, Slack, Discord, Figma, Notion, Spotify) or another app that exposes a Chrome DevTools Protocol (CDP) port, Slack workspace, or cloud browser | **agent-browser** | Prefer it whenever the target is web content it can reach: its text snapshots and element refs cost far fewer tokens than screenshot-driven CUA. See [what agent-browser covers](#what-agent-browser-covers). Use Cua Driver for anything outside that list or whenever agent-browser hits a limitation. Keep existing browser test suites for repeatable tests. |
|
|
23
|
+
| Native desktop application, native iOS app in the iOS Simulator, Android emulator, desktop Safari, Firefox or another non-Chromium browser, browser chrome, OS dialogs and permission prompts, work across apps, or any agent-browser limitation | **Cua Driver**: the `cua-driver` CLI through the bundled `cua-driver` skill when a model chooses each action; the `@trycua/cua-driver` TypeScript SDK inside `ctx.tool` when workflow code owns the scenario | Use application scripting or a CLI when they make the task easier, safer, or more reliable. |
|
|
24
24
|
|
|
25
25
|
You can combine tools without driving the whole task through a desktop. Generate a presentation with `python-pptx`, then inspect rendered slides for layout problems. Use Blender's Python API to generate repeated objects, then Cua Driver for adjustments in the visible editor. Use browser DOM controls rather than desktop clicks for a web form. For a supported web-service operation that does not require browser interaction, an authorized API request may be enough.
|
|
26
26
|
|
|
@@ -190,13 +190,13 @@ Atomic uses Cua Driver through two faces of one typed surface. Choose by who dec
|
|
|
190
190
|
| A language model chooses each action: an interactive session driving, inspecting, or automating a desktop app, simulator, or emulator window, or any workflow stage acting outside `ctx.tool` | `cua-driver` CLI through the bundled `cua-driver` skill | The model decides turn by turn; the skill's loop is written for one-shot `cua-driver call <tool>` commands, and the evidence is the JSON results and `screenshot_out_file` images it saves. |
|
|
191
191
|
| A custom workflow's TypeScript owns the scenario and its postcondition, run inside `ctx.tool(name, args, fn, { timeoutMs })` | `@trycua/cua-driver` TypeScript SDK | Code owns the sequence; the result is durably checkpointed and replayed on resume. |
|
|
192
192
|
|
|
193
|
-
The rule of thumb: **when a model chooses the next action, use the CLI; when TypeScript code owns the sequence and the postcondition, use the SDK.**
|
|
193
|
+
The rule of thumb: **when a model chooses the next action, use the CLI; when TypeScript code owns the sequence and the postcondition, use the SDK.** Before reaching for either, check whether [agent-browser covers the target](#what-agent-browser-covers): websites and web apps in Chrome/Chromium, Mobile Safari in the iOS Simulator, Electron and other CDP-exposing apps, Slack, and cloud browsers. It is much cheaper than CUA there. Use Cua Driver for everything else, including native desktop apps, native iOS apps in the Simulator, Android emulators, OS dialogs, desktop Safari and other non-Chromium browsers, and whenever agent-browser hits a limitation. Terminals stay with [Herdr](#terminal-automation-with-herdr), falling back to tmux or psmux. Both faces share tool names (`list_apps`, `list_windows`, `get_window_state`, `click`, `type_text`, and the rest), so a scenario worked out interactively translates directly into code.
|
|
194
194
|
|
|
195
|
-
The bundled `cua-driver` skill is the upstream skill, vendored verbatim, and is the only place the driving loop is described. Do not run `cua-driver skills install`:
|
|
195
|
+
The bundled `cua-driver` skill is the upstream skill, vendored verbatim, and is the only place the driving loop is described. The executable installer below does not install an agent skill. Do not run `cua-driver skills install`, `cua-driver skills update`, or `clawhub install @cua/driver`: upstream's README describes those optional skill commands for other agents. Do not link or copy another skill into `~/.agents/skills/cua-driver`, `~/.claude/skills`, or other agent directories. Atomic already supplies its bundled copy; leave any existing user-level skill alone.
|
|
196
196
|
|
|
197
197
|
### Install if missing
|
|
198
198
|
|
|
199
|
-
Check `cua-driver --version`. If the executable is missing, make **one bounded attempt** with upstream's one-line installer for the host. It needs no administrator access:
|
|
199
|
+
Check `cua-driver --version`. If the executable is missing, make **one bounded attempt** with upstream's one-line executable installer for the host. It needs no administrator access and does not install an agent skill:
|
|
200
200
|
|
|
201
201
|
```sh
|
|
202
202
|
# macOS (14 Sonoma or later) and Linux
|
|
@@ -275,7 +275,31 @@ One controller owns a desktop at a time. Use a dedicated session or account wher
|
|
|
275
275
|
|
|
276
276
|
## Browser automation with agent-browser
|
|
277
277
|
|
|
278
|
-
Prefer [agent-browser](https://
|
|
278
|
+
Prefer [agent-browser](https://agent-browser.dev/) for any target it can reach. Its `snapshot` returns a compact text accessibility tree with `@eN` element refs, usually a few hundred tokens, so each step costs far less context than a screenshot-driven CUA step, and actions land on real controls rather than screen coordinates. Anything outside the scope below, or a limitation you hit inside it, goes to [Cua Driver](#desktop-automation-with-cua-driver). For data retrieval or batch operations, consider a supported API first when it meets the request and you have permission to use it.
|
|
279
|
+
|
|
280
|
+
### What agent-browser covers
|
|
281
|
+
|
|
282
|
+
| Target | How | Notes |
|
|
283
|
+
| --- | --- | --- |
|
|
284
|
+
| Websites and web apps in Chrome/Chromium on macOS, Linux, and Windows | Default engine, headless or `--headed`; `--executable-path` for another Chromium-based browser such as Brave; `--engine lightpanda` for the Lightpanda engine | The full command set: forms, uploads and downloads, JavaScript `alert`/`confirm`/`prompt` dialogs (`dialog accept`/`dismiss`), clipboard, tabs, iframes, network routing and HAR, console and errors, `a11y` audits, Web Vitals and React inspection, `record` videos. |
|
|
285
|
+
| Mobile Safari in the iOS Simulator, or on a USB-connected iPhone/iPad | `agent-browser -p ios --device "iPhone 16 Pro" open <url>`, then the usual `snapshot`, `tap`, `fill`, `swipe`, `screenshot`; `agent-browser device list` shows simulators | macOS with Xcode simulator runtimes, plus `npm install -g appium` and `appium driver install xcuitest`. A real device also needs a signed WebDriverAgent. One tab only; no `record` video, PDF export, streaming, `screenshot --annotate`, `a11y` audits, or `--allowed-domains`. For a video, record the simulator with `xcrun simctl io booted recordVideo <file>.mp4`. First launch takes 30–60 seconds; `agent-browser -p ios close` shuts the simulator down. |
|
|
286
|
+
| Mobile web layout in Chrome | `agent-browser set device "iPhone 14"` or `set viewport <w> <h> <scale>` | Emulates a viewport and user agent in Chromium. It is not WebKit; use `-p ios` when Safari behavior matters. |
|
|
287
|
+
| Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, and others) | Relaunch the app with `--remote-debugging-port=<port>`, then `agent-browser connect <port>`; load `agent-browser skills get electron` | Windows and `<webview>` targets appear in `agent-browser tab`. |
|
|
288
|
+
| Other apps and browsers that expose CDP | `agent-browser connect <port\|ws-url>` or `--auto-connect` for a running Chrome | WebView2 apps on Windows and Chrome started with remote debugging. Attach to a personal browser only when authorized. |
|
|
289
|
+
| Slack workspaces | `agent-browser skills get slack` | Browser-based Slack automation. |
|
|
290
|
+
| Cloud and sandboxed browsers | `-p browserbase`, `browserless`, `browseruse`, `kernel`, or `agentcore`; `agent-browser skills get vercel-sandbox` | Provider credentials come from the provider's environment variables. |
|
|
291
|
+
| Local HTML or PDF files | `agent-browser --allow-file-access open file:///path/to/file` | Chromium only. |
|
|
292
|
+
|
|
293
|
+
Hand the task to Cua Driver when it needs any of these:
|
|
294
|
+
|
|
295
|
+
- A native desktop app that exposes no CDP port (AppKit, SwiftUI, Win32/WPF, GTK, Qt), or an Electron app that cannot be relaunched with remote debugging.
|
|
296
|
+
- A native iOS app in the Simulator. agent-browser's iOS mode drives Mobile Safari only. Android emulators are not supported by agent-browser at all.
|
|
297
|
+
- Desktop Safari, Firefox, or another browser that is neither Chromium-based nor iOS Safari.
|
|
298
|
+
- Browser chrome outside the page: the toolbar, extension popups, native print or save dialogs, or permission prompts.
|
|
299
|
+
- OS dialogs and pickers the page cannot bypass. Try `agent-browser upload` for file inputs first.
|
|
300
|
+
- Work across several applications, or a capability the installed agent-browser version rejects.
|
|
301
|
+
|
|
302
|
+
Check the installed CLI (`agent-browser --help`, `agent-browser skills get core`) before relying on a version-dependent command.
|
|
279
303
|
|
|
280
304
|
### Setup and first session
|
|
281
305
|
|
|
@@ -306,10 +330,10 @@ For a real task, act between the snapshot and final capture. Read element refere
|
|
|
306
330
|
- Prefer a fresh profile. Attach to an existing personal browser only when authorized; stored sessions can expose private tabs and credentials.
|
|
307
331
|
- Use headed mode for visual work. Headless mode can verify DOM behavior, but does not establish that desktop integration or native dialogs work.
|
|
308
332
|
- Inspect visible results and relevant console/network output (`agent-browser console`, `agent-browser errors`, `agent-browser network requests`). Keep semantic locators and assertions in a maintained browser test suite for repeatable regression coverage.
|
|
309
|
-
- Use the CLI's file-upload support for supported file inputs rather than driving an OS file picker. Switch to
|
|
333
|
+
- Use the CLI's file-upload support for supported file inputs rather than driving an OS file picker. Switch to Cua Driver or native tooling only for UI outside the page, and then recheck focus before returning to browser control.
|
|
310
334
|
- Treat cookies, saved authentication state, and network logs as sensitive. Do not commit or attach a browser profile as evidence.
|
|
311
335
|
- Keep `screenshot` PNGs and `record` recordings from the verified flow; when the work ends in a PR, attach them to the PR body with `gh pr create --attach` on supported GitHub, each next to the scenario it proves. See [Verification and evidence](/workflows/verification#native-github-media).
|
|
312
|
-
-
|
|
336
|
+
- `set device` emulates a mobile viewport in Chromium; `-p ios` runs real Mobile Safari. Neither exercises a native Android or iOS app, which needs Cua Driver.
|
|
313
337
|
|
|
314
338
|
For verification captures and recordings, see [browser evidence](/workflows/verification#browser-changes).
|
|
315
339
|
|
|
@@ -383,7 +407,7 @@ Use `osascript` for AppleScript or JavaScript for Automation when an app's scrip
|
|
|
383
407
|
|
|
384
408
|
### Browser and terminal
|
|
385
409
|
|
|
386
|
-
agent-browser
|
|
410
|
+
agent-browser's default session is Chrome/Chromium, which is not proof of Safari-specific behavior. For Mobile Safari, use `agent-browser -p ios` against an iOS Simulator (requires Xcode, Appium, and the XCUITest driver). For desktop Safari, use Cua Driver.
|
|
387
411
|
|
|
388
412
|
Herdr is the first choice for interactive terminals when eligible. Homebrew provides Herdr and tmux. Preserve the shell, terminal dimensions, and keyboard behavior relevant to the task rather than silently changing them to make a scenario pass.
|
|
389
413
|
|
|
@@ -68,7 +68,7 @@ pi.registerProvider("my-llm", {
|
|
|
68
68
|
});
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
When `models` is provided, it **replaces** all existing models for that provider.
|
|
71
|
+
When `models` is provided, it **replaces** all existing chat, image, and classifier models for that provider. A missing `type` means chat; image and classifier models need `type: "image"` or `type: "classifier"` and implementations in the `images` or `classifiers` maps keyed by each model's `api`. See the [mixed-operation provider example](/custom-provider#quick-reference).
|
|
72
72
|
|
|
73
73
|
## Unregister Provider
|
|
74
74
|
|
package/docs/custom-provider.md
CHANGED
|
@@ -78,6 +78,48 @@ export default function (pi: ExtensionAPI) {
|
|
|
78
78
|
|
|
79
79
|
The extension factory can also be `async`. For dynamic model discovery, fetch and register models in the factory instead of `session_start`. Atomic waits for the factory before startup continues, so the provider is available during interactive startup and to `atomic --list-models`.
|
|
80
80
|
|
|
81
|
+
Registering only `baseUrl` or `headers` for an existing provider preserves its built-in models. Supplying `models` in the legacy form replaces that provider's models across chat, image, and classifier operations. An omitted `type` means `"chat"`; image and classifier models require explicit discriminants and implementations keyed by their `api` values through the `images` and `classifiers` fields.
|
|
82
|
+
|
|
83
|
+
For example, a mixed-operation provider can register non-chat models and their implementations together:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
pi.registerProvider("media-tools", {
|
|
87
|
+
apiKey: "$MEDIA_TOOLS_API_KEY",
|
|
88
|
+
models: [
|
|
89
|
+
{
|
|
90
|
+
type: "image",
|
|
91
|
+
id: "image-v1",
|
|
92
|
+
name: "Image V1",
|
|
93
|
+
api: "media-images",
|
|
94
|
+
baseUrl: "https://media.example.com/v1",
|
|
95
|
+
input: ["text"],
|
|
96
|
+
output: ["image"],
|
|
97
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: "classifier",
|
|
101
|
+
id: "classifier-v1",
|
|
102
|
+
name: "Classifier V1",
|
|
103
|
+
api: "media-classifier",
|
|
104
|
+
baseUrl: "https://media.example.com/v1",
|
|
105
|
+
input: ["text"],
|
|
106
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
107
|
+
contextWindow: 64000,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
images: {
|
|
111
|
+
"media-images": { generateImages: async (model, context, options) => result },
|
|
112
|
+
},
|
|
113
|
+
classifiers: {
|
|
114
|
+
"media-classifier": { classify: async (model, context, options) => result },
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Model-level `baseUrl` values take precedence over the provider endpoint. If no `models` list is supplied, built-in models of every operation remain registered. Equal model IDs in different operations remain distinct, including their model-specific headers.
|
|
120
|
+
|
|
121
|
+
Every model needs an ID, display name, input capabilities, and cost metadata. Chat and classifier models also need a context window; chat models need an output limit and reasoning support; image models declare their output modalities. Choose the API implementation at the provider level unless one model requires an override.
|
|
122
|
+
|
|
81
123
|
## Override Existing Provider
|
|
82
124
|
|
|
83
125
|
Moved to [Override an existing provider](/custom-provider/override#override-existing-provider).
|
|
@@ -104,7 +146,7 @@ Moved to [Provider OAuth](/custom-provider/oauth#oauth-support).
|
|
|
104
146
|
|
|
105
147
|
## Dynamic model catalog refresh
|
|
106
148
|
|
|
107
|
-
Moved to [Provider OAuth](/custom-provider/oauth#dynamic-model-catalog-refresh).
|
|
149
|
+
Moved to [Provider OAuth](/custom-provider/oauth#dynamic-model-catalog-refresh). A complete `Provider` calls `context.publish({ update })` to install provider-owned model state, then exposes the latest list through `getModels()`. Legacy `ProviderConfig.refreshModels` returns mixed-operation model definitions that replace that registration's live models.
|
|
108
150
|
|
|
109
151
|
### OAuthLoginCallbacks
|
|
110
152
|
|
|
@@ -315,9 +315,7 @@ pi.registerTool({
|
|
|
315
315
|
|
|
316
316
|
Return `terminate: true` from `execute()` to skip the automatic follow-up model call only when every finalized result in the tool batch also terminates.
|
|
317
317
|
|
|
318
|
-
For a schema-backed
|
|
319
|
-
|
|
320
|
-
Include a custom name such as `final_decision` in any explicit tool allowlist. The default `structured_output` name is likewise available only in the session/runtime where you register it.
|
|
318
|
+
For a schema-backed decision, use `createStructuredOutputTool({ schema, name })`. Atomic does not register `structured_output` in normal sessions by default. The calling model supplies `instructions`, nonempty named `state`, and optional `model` and `fallbackModels`. The tool resolves those exact IDs through the session model registry, infers a value matching `schema`, and returns that value as terminating JSON. It does not treat the calling model's arguments as the result. Omit `model` to use the current session chat model; explicit fallbacks run next, and the current chat model is the terminal fallback. A registered classifier runs only for a finite Choice schema. An incompatible schema skips that classifier. Provider errors, including refusals, advance to the next model. Plain-text responses without the required result are repaired up to three times before advancing. Cancellation stops the call. Include a custom name such as `final_decision` in any explicit tool allowlist.
|
|
321
319
|
|
|
322
320
|
```typescript
|
|
323
321
|
// Correct: throw to signal an error
|
|
@@ -388,6 +386,27 @@ pi.registerTool({
|
|
|
388
386
|
});
|
|
389
387
|
```
|
|
390
388
|
|
|
389
|
+
**Call ordering:** when one assistant message contains several tool calls, Atomic starts them in message order and runs them concurrently unless a tool declares `concurrency`:
|
|
390
|
+
|
|
391
|
+
- `"shared"` (default): may overlap other shared calls, but starts only after the latest earlier `"exclusive"` call finishes.
|
|
392
|
+
- `"exclusive"`: starts only after every earlier call in the message finishes, and later calls wait for it.
|
|
393
|
+
- A function `(args) => "shared" | "exclusive"` decides per call. If it throws, the call runs exclusively.
|
|
394
|
+
|
|
395
|
+
Built-in `edit`, `write`, `todo`, and `ask_user_question` are exclusive, and `bash` is exclusive when it runs with `pty: true`. Other `bash` calls are shared, so a later call in the same message can run before a shell command's file changes land. Declare `"exclusive"` for a tool that changes state later calls depend on. `executionMode: "sequential"` still runs the whole message one call at a time.
|
|
396
|
+
|
|
397
|
+
```typescript
|
|
398
|
+
pi.registerTool({
|
|
399
|
+
name: "apply_migration",
|
|
400
|
+
label: "Apply Migration",
|
|
401
|
+
description: "Apply one database migration",
|
|
402
|
+
parameters: Type.Object({ name: Type.String(), dryRun: Type.Optional(Type.Boolean()) }),
|
|
403
|
+
concurrency: (args) => (args.dryRun === true ? "shared" : "exclusive"),
|
|
404
|
+
async execute(toolCallId, params) {
|
|
405
|
+
return { content: [{ type: "text", text: `Applied ${params.name}` }], details: {} };
|
|
406
|
+
},
|
|
407
|
+
});
|
|
408
|
+
```
|
|
409
|
+
|
|
391
410
|
### Fireworks deferred tool loading
|
|
392
411
|
|
|
393
412
|
Extensions making requests directly through `@bastani/pi-ai` can use native deferred tool loading with Fireworks `anthropic-messages` models. Keep the discovery tool in `context.tools`. After the discovery tool result, append a chronological system message with `toolsAdded` (and `toolsRemoved` if needed) containing the newly loaded tool definitions. The provider serializes deferred definitions with `defer_loading` and inserts `tool_reference` content at the load point.
|
|
@@ -36,6 +36,7 @@ user sends prompt ────────────────────
|
|
|
36
36
|
│ ├─► context_with_system (can modify the full transcript)
|
|
37
37
|
│ ├─► before_provider_request (can inspect or replace payload)
|
|
38
38
|
│ ├─► after_provider_response (status + headers, before stream consume)
|
|
39
|
+
│ ├─► provider_stream_event (each parsed provider event, before normalization)
|
|
39
40
|
│ │ │ │
|
|
40
41
|
│ │ LLM responds, may call tools: │ │
|
|
41
42
|
│ │ ├─► tool_execution_start │ │
|
|
@@ -537,6 +538,23 @@ pi.on("after_provider_response", (event, ctx) => {
|
|
|
537
538
|
|
|
538
539
|
Header availability depends on provider and transport. Providers that abstract HTTP responses may not expose headers.
|
|
539
540
|
|
|
541
|
+
#### provider_stream_event
|
|
542
|
+
|
|
543
|
+
Fired for each parsed provider stream event before Atomic normalizes it into assistant message events. Use it to inspect provider-specific fields that Atomic does not keep in the assistant message.
|
|
544
|
+
|
|
545
|
+
```typescript
|
|
546
|
+
pi.on("provider_stream_event", (event, ctx) => {
|
|
547
|
+
// event.provider, event.api, event.model - the model that produced the event
|
|
548
|
+
// event.data - the parsed provider event (read-only)
|
|
549
|
+
const chunk = event.data as Record<string, unknown>;
|
|
550
|
+
if (chunk.openrouter_metadata) console.log(chunk.openrouter_metadata);
|
|
551
|
+
});
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
`event.data` is the earliest structured value available to Atomic, not necessarily the original HTTP bytes or SSE frame, and SDK-backed providers expose only the fields their SDK keeps. Treat it as read-only: changing it can change how the response is normalized. The event is notification-only and is not saved to the session. Cache-warming requests do not emit it.
|
|
555
|
+
|
|
556
|
+
Handlers run in stream order and are awaited, so a slow handler delays the response. Handler errors are reported without changing the provider response. Custom providers registered with `streamSimple` emit this event only if they call `options.onProviderStreamEvent`. See [`debug-provider.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/debug-provider.ts) for an opt-in viewer.
|
|
557
|
+
|
|
540
558
|
### Model Events
|
|
541
559
|
|
|
542
560
|
#### model_select
|
|
@@ -80,6 +80,7 @@ All examples in [examples/extensions/](https://github.com/bastani-inc/atomic/tre
|
|
|
80
80
|
| `custom-provider-gitlab-duo/` | GitLab Duo integration | `registerProvider` with OAuth |
|
|
81
81
|
| **Messages & Communication** |||
|
|
82
82
|
| `message-renderer.ts` | Custom message rendering | `registerMessageRenderer`, `sendMessage` |
|
|
83
|
+
| `debug-provider.ts` | Capture raw provider stream events per assistant message with `/debug-provider` | `on("provider_stream_event")`, `registerEntryRenderer`, `appendEntry` |
|
|
83
84
|
| `event-bus.ts` | Inter-extension events | `pi.events` |
|
|
84
85
|
| **Session Metadata** |||
|
|
85
86
|
| `session-name.ts` | Name sessions for selector | `setSessionName`, `getSessionName` |
|
|
@@ -15,7 +15,7 @@ On a fresh install with no prior startup state, Atomic shows a one-time explanat
|
|
|
15
15
|
|
|
16
16
|
The normal Atomic input is ready from the start. Type a message, run `/login` if no provider is connected, or launch a workflow command. No separate onboarding step is required.
|
|
17
17
|
|
|
18
|
-
The agent decides whether a workflow fits.
|
|
18
|
+
The agent decides whether a workflow fits. Non-trivial work with structure and a verifiable objective runs as a workflow unless you ask for inline execution: implementation, bug fixes, debugging, migrations, multi-file changes with validation, and requests phrased as "repeat until" or "fix until green". Brainstorming, discussion, unclear goals, tiny low-risk answers or edits, or an explicit request to work inline, quickly or without a workflow stays inline. To launch, inspect the input contract with `workflow inputs`, then call `workflow run` with the registered workflow name and inputs. Ask only for genuinely missing information.
|
|
19
19
|
|
|
20
20
|
Atomic can discover and run named builtin, project, user, and package workflows; author a rich custom TypeScript `workflow({...})` inline; and compositionally import reusable workflow definitions—including builtins from `@bastani/atomic/workflows/builtin`—into parent workflows with `ctx.workflow(...)`. Nested children can nest again within `maxDepth`, so custom graphs can combine proven research, implementation, design, verification, and approval workflows instead of copying them. They can also classify and branch, dynamically fan out and synthesize artifacts, run adversarial repair cycles, tournament-rank candidates, and loop until checks pass with explicit bounds.
|
|
21
21
|
|
package/docs/models/evals.md
CHANGED
|
@@ -12,38 +12,38 @@ Key:
|
|
|
12
12
|
- `∅`=source null/absent, not zero.
|
|
13
13
|
- Values are rounded to 1 decimal from the [model leaderboard](https://artificialanalysis.ai/leaderboards/models) payload, Coding Index and Agentic Index fields on free `GET /api/v2/language/models/free`, and default-chart constituent fields on the [Intelligence Index](https://artificialanalysis.ai/evaluations/artificial-analysis-intelligence-index) page.
|
|
14
14
|
- A chart label may show the nearest integer of `idx`.
|
|
15
|
-
- `idx`: Intelligence Index points.
|
|
16
|
-
- `Cod`: Coding Index points.
|
|
17
|
-
- `Agt`: Agentic Index points.
|
|
18
|
-
- `Brief`: AA-Briefcase normalized Elo `clamp((Elo-500)/2000)*100`.
|
|
19
|
-
- `Gn`: GDPval-AA normalized Elo `clamp((Elo-500)/2000)*100`.
|
|
20
|
-
- `Omni`: Omniscience Index, -100 to 100.
|
|
21
|
-
- `Open`: Openness Index points.
|
|
15
|
+
- `idx`: Intelligence Index points, aggregate performance across knowledge, reasoning, coding, and agentic work.
|
|
16
|
+
- `Cod`: Coding Index points, aggregate coding capability, including scientific code generation and terminal tasks; distinct from the Coding Agent Index.
|
|
17
|
+
- `Agt`: Agentic Index points, aggregate performance on multi-step tasks using tools.
|
|
18
|
+
- `Brief`: AA-Briefcase, long-horizon business knowledge work producing spreadsheets, presentations, and memos; normalized Elo `clamp((Elo-500)/2000)*100`.
|
|
19
|
+
- `Gn`: GDPval-AA, economically valuable professional work across occupations; normalized Elo `clamp((Elo-500)/2000)*100`.
|
|
20
|
+
- `Omni`: Omniscience Index, factual knowledge reliability, rewarding correct answers and penalizing incorrect guesses without penalizing abstention; -100 to 100.
|
|
21
|
+
- `Open`: Openness Index points, model availability and transparency of training data and methodology, not task-solving ability.
|
|
22
22
|
- Other score columns are percent.
|
|
23
|
-
- `OA`: Omniscience accuracy.
|
|
24
|
-
- `ONH`: the 6,000-question ONH rate `(partial+notattempted)/(incorrect+partial+notattempted)`, not 1 minus the hallucination rate.
|
|
25
|
-
- `PDF`: GDP.pdf All-pass.
|
|
26
|
-
- `Auto`: AutomationBench-AA.
|
|
27
|
-
- `TB4`: Terminal-Bench 4.0.
|
|
28
|
-
- `TB21`: Terminal-Bench 2.1.
|
|
29
|
-
- `TBh`: Terminal-Bench Hard.
|
|
30
|
-
- `Sci`: SciCode.
|
|
31
|
-
- `HLE`: Humanity's Last Exam.
|
|
32
|
-
- `Crit`: CritPt.
|
|
33
|
-
- `LCR`: AA-LCR.
|
|
34
|
-
- `GPQA`: GPQA Diamond.
|
|
35
|
-
- `IF`: IFBench.
|
|
36
|
-
- `MMMU`: MMMU-Pro.
|
|
37
|
-
- `tau2`:
|
|
38
|
-
- `tauB`: τ²-Banking.
|
|
39
|
-
- `Analyst`:
|
|
40
|
-
- `ITB`: ITBench SRE.
|
|
41
|
-
- `Apex`:
|
|
42
|
-
- `AIME`: AIME 2025.
|
|
43
|
-
- `LCB`: LiveCodeBench.
|
|
44
|
-
- `Harvey`: Harvey
|
|
45
|
-
- `MLCR`:
|
|
46
|
-
- `Ent`: EnterpriseOps
|
|
23
|
+
- `OA`: Omniscience accuracy, factual recall across knowledge domains.
|
|
24
|
+
- `ONH`: Omniscience non-hallucination, avoiding incorrect guesses when unable to answer fully; the 6,000-question ONH rate `(partial+notattempted)/(incorrect+partial+notattempted)`, not 1 minus the hallucination rate.
|
|
25
|
+
- `PDF`: GDP.pdf All-pass, reasoning over long professional documents while satisfying every task-specific criterion.
|
|
26
|
+
- `Auto`: AutomationBench-AA, completing multi-step SaaS workflows without guardrail violations.
|
|
27
|
+
- `TB4`: Terminal-Bench 4.0, agentic coding and terminal work across software engineering, systems administration, data processing, model training, and security.
|
|
28
|
+
- `TB21`: Terminal-Bench 2.1, an earlier terminal-task suite covering coding, systems administration, data processing, model training, and security.
|
|
29
|
+
- `TBh`: Terminal-Bench Hard, the legacy hard terminal-task subset testing coding, systems administration, and data processing.
|
|
30
|
+
- `Sci`: SciCode, writing scientific Python code to solve scientist-curated research problems, graded by execution tests.
|
|
31
|
+
- `HLE`: Humanity's Last Exam, expert-level academic knowledge and reasoning across mathematics, sciences, and humanities.
|
|
32
|
+
- `Crit`: CritPt, research-level physics reasoning.
|
|
33
|
+
- `LCR`: AA-LCR, extracting, reasoning about, and synthesizing information across long documents.
|
|
34
|
+
- `GPQA`: GPQA Diamond, graduate-level scientific reasoning in biology, physics, and chemistry.
|
|
35
|
+
- `IF`: IFBench, precise instruction following under verifiable output constraints.
|
|
36
|
+
- `MMMU`: MMMU-Pro, multimodal understanding and visual reasoning across academic disciplines.
|
|
37
|
+
- `tau2`: τ²-Bench Telecom, conversational tool use and coordination with a simulated user to resolve telecom support issues.
|
|
38
|
+
- `tauB`: Banking tool-use benchmark, knowledge retrieval and multi-step customer-support workflows; the snapshot labels this τ²-Banking, while the current source calls it τ³-Banking.
|
|
39
|
+
- `Analyst`: AA-AnalystAgent, end-to-end quantitative analysis of real-world spreadsheets and documents.
|
|
40
|
+
- `ITB`: ITBench SRE, identifying Kubernetes incident root causes from alerts, events, traces, and topology.
|
|
41
|
+
- `Apex`: [APEX-Agents](https://www.mercor.com/apex/apex-agents-leaderboard/), long-horizon, cross-application work in investment banking, consulting, and corporate law.
|
|
42
|
+
- `AIME`: AIME 2025, competition-level mathematical problem solving.
|
|
43
|
+
- `LCB`: LiveCodeBench, generating correct code for recent competitive programming problems.
|
|
44
|
+
- `Harvey`: Harvey LAB-AA, producing legal deliverables from case documents, graded against task-specific criteria.
|
|
45
|
+
- `MLCR`: Medical Long Context Reasoning overall, synthesizing long, fragmented medical records for healthcare and insurance case review.
|
|
46
|
+
- `Ent`: EnterpriseOps-Gym-AA, stateful, multi-step business workflows using tools, graded on the resulting database state.
|
|
47
47
|
- `Brief`, `Auto`, `PDF`, `AIME`, `LCB`, `Harvey`, `MLCR`, `Open`, and `Ent` are published for default-chart models; other rows are `∅` for those columns.
|
|
48
48
|
|
|
49
49
|
## Artificial Analysis Intelligence Index v4.3.2
|
|
@@ -79,51 +79,3 @@ Table: top 26 catalog models by Intelligence Index, plus GPT-6 Luna (max) from b
|
|
|
79
79
|
| qwen3-8-max | Qwen3.8 Max (0902) | 45.4 | 57 | 58.4 | 56.2 | 38.9 | 52.1 | 43.1 | 22.8 | 17.7 | 31.7 | 71.2 | 80.3 | 76.2 | 56 | 12 | 92.8 | 88.8 | ∅ | ∅ | 82.8 | ∅ | 47.8 | ∅ | ∅ | ∅ | ∅ | ∅ | ∅ | 20 | ∅ | ∅ |
|
|
80
80
|
| muse-spark-1-3-xhigh | Muse Spark 1.3 (xhigh) | 45.1 | ∅ | 56.4 | 56.8 | 16.7 | 59.7 | 47.5 | 24.2 | 26 | 41.5 | 68.5 | 83 | 76.5 | 51.5 | 23.1 | 94.1 | 85.4 | ∅ | ∅ | 82 | ∅ | 47.2 | ∅ | ∅ | ∅ | ∅ | ∅ | 95.5 | ∅ | ∅ | ∅ |
|
|
81
81
|
| gpt-6-luna | GPT-6 Luna (max) | 37.3 | ∅ | 43.4 | ∅ | 12.6 | 54.6 | 38.5 | ∅ | 19.4 | 43.8 | 23.3 | 83.3 | ∅ | ∅ | 0.7 | ∅ | ∅ | ∅ | ∅ | 75.5 | ∅ | ∅ | ∅ | ∅ | ∅ | ∅ | ∅ | ∅ | ∅ | ∅ | ∅ |
|
|
82
|
-
|
|
83
|
-
## Cognition FrontierCode 1.1
|
|
84
|
-
|
|
85
|
-
[FrontierCode](https://cognition.com/frontiercode) 1.1 (revision 2026-07-07; [data](https://cognition.com/data/frontiercode-leaderboard/data.json); [methods](https://cognition.com/blog/frontier-code-1.1) and https://cognition.com/blog/frontier-code) measures code quality rather than only correctness: would the maintainer merge this PR. Tasks come from 36 open-source repositories whose maintainers wrote the rubrics, grading behavioral correctness, regression safety, lint and style, test correctness, scope discipline, and adherence to codebase conventions. A run passes only if it clears every blocker criterion; score is the weighted aggregate of all rubric items, and blocker or unfair-internet-use failures score zero. Main is 100 tasks and Extended is 150.
|
|
86
|
-
|
|
87
|
-
Table: Main Best rows in source order. Columns: model, source effort label, harness, score, pass, flag (percent), USD/task, output k-tokens. Harness: `cc`=claude-code, `gb`=grok-build, `msa`=mini-swe-agent. `—`=source null, not 0; Inkling `0.99` is unexplained. Extended values remain linked (not routed).
|
|
88
|
-
|
|
89
|
-
| ID | Model | Effort | Harness | score | pass | flag | USD/task | output k-tokens |
|
|
90
|
-
| --- | --- | --- | --- | ---: | ---: | ---: | ---: | ---: |
|
|
91
|
-
| F01 | Claude Opus 5.5 | medium | cc | 54.6 | 59.6 | 0.0 | 0.80 | 18.5 |
|
|
92
|
-
| F02 | Claude Fable 5 | xhigh | cc | 53.5 | 58.9 | 0.3 | 13.09 | 58.6 |
|
|
93
|
-
| F03 | Claude Opus 5 | medium | cc | 53.4 | 58.9 | 0.6 | 4.31 | 33.6 |
|
|
94
|
-
| F04 | GPT-6 Astra | max | codex | 53.3 | 58.8 | — | 4.59 | 30.1 |
|
|
95
|
-
| F05 | Claude Fable 5.1 | medium | cc | 50.9 | 55.5 | 0.0 | 3.28 | 26.1 |
|
|
96
|
-
| F06 | SWE-2 | max | devin | 50.0 | 55.5 | — | 1.18 | 72.8 |
|
|
97
|
-
| F07 | GPT-6 Sol | max | codex | 49.3 | 54.3 | 0.0 | 2.07 | 41.3 |
|
|
98
|
-
| F08 | Grok 4.6 | high | gb | 48.0 | 53.1 | 0.7 | 2.88 | 36.8 |
|
|
99
|
-
| F09 | GPT-5.6 Sol | max | codex | 47.5 | 52.9 | 0.0 | 5.19 | 33.2 |
|
|
100
|
-
| F10 | Claude Opus 4.8 | max | cc | 46.5 | 51.6 | 0.6 | 9.62 | 95.9 |
|
|
101
|
-
| F11 | Kimi K3 | none | msa | 44.2 | 48.9 | 0.2 | 3.82 | 53.6 |
|
|
102
|
-
| F12 | Gemini 3.7 Flash | medium | chisel | 43.6 | 48.9 | 0.0 | 1.82 | 51.1 |
|
|
103
|
-
| F13 | GPT-5.5 | xhigh | codex | 43.0 | 48.2 | 0.4 | 4.03 | 25.0 |
|
|
104
|
-
| F14 | Claude Sonnet 5 | xhigh | cc | 42.7 | 47.6 | 0.5 | 10.07 | 87.9 |
|
|
105
|
-
| F15 | Grok 4.5 | high | gb | 42.4 | 47.2 | 0.0 | 1.30 | 15.3 |
|
|
106
|
-
| F16 | GPT-6 Luna | max | codex | 42.4 | 47.8 | 0.0 | 0.10 | 56.6 |
|
|
107
|
-
| F17 | SWE-1.7 | none | chisel | 42.0 | 47.4 | 1.2 | 1.97 | 64.8 |
|
|
108
|
-
| F18 | GPT-5.6 Terra | max | codex | 41.3 | 46.3 | 0.1 | 1.87 | 40.5 |
|
|
109
|
-
| F19 | Gemini 3.8 Flash | medium | chisel | 41.2 | 46.7 | 0.0 | 2.60 | 78.9 |
|
|
110
|
-
| F20 | GLM 5.3 | max | chisel | 40.1 | 44.7 | 0.0 | 16.91 | 112.2 |
|
|
111
|
-
| F21 | GPT-5.6 Luna | max | codex | 39.8 | 44.7 | 0.1 | 0.37 | 37.4 |
|
|
112
|
-
| F22 | Claude Opus 4.7 | max | cc | 38.5 | 42.8 | 0.1 | 9.09 | 49.1 |
|
|
113
|
-
| F23 | Gemini 3.6 Flash | medium | chisel | 34.4 | 38.9 | 0.0 | 4.04 | 46.7 |
|
|
114
|
-
| F24 | GLM 5.3 Flash | max | chisel | 31.8 | 35.7 | 0.0 | 1.15 | 169.3 |
|
|
115
|
-
| F25 | Kimi K2.7 | none | msa | 30.1 | 33.6 | 0.0 | 3.01 | 43.9 |
|
|
116
|
-
| F26 | DeepSeek V4 Pro 0813 | high | chisel | 28.5 | 31.8 | 10.6 | 1.81 | 104.7 |
|
|
117
|
-
| F27 | GPT-5.4-mini | xhigh | codex | 27.0 | 30.8 | 0.0 | 1.52 | 90.9 |
|
|
118
|
-
| F28 | Claude Opus 4.6 | high | cc | 26.6 | 29.7 | 0.1 | 3.98 | 26.7 |
|
|
119
|
-
| F29 | Composer 2.5 | none | cursor | 25.6 | 29.3 | 2.4 | 3.09 | 16.0 |
|
|
120
|
-
| F30 | GLM 5.2 | none | msa | 24.5 | 27.4 | 0.0 | 2.47 | 17.8 |
|
|
121
|
-
| F31 | Claude Sonnet 4.6 | max | cc | 24.3 | 27.5 | 0.2 | 2.90 | 44.2 |
|
|
122
|
-
| F32 | DeepSeek V4 Flash 0731 | high | chisel | 18.8 | 21.1 | 25.5 | 1.53 | 94.4 |
|
|
123
|
-
| F33 | DeepSeek V4 Pro | none | msa | 17.6 | 20.0 | 1.0 | 1.55 | 28.8 |
|
|
124
|
-
| F34 | MiniMax M3 | none | msa | 14.7 | 16.6 | 1.5 | 0.68 | 34.0 |
|
|
125
|
-
| F35 | Inkling | 0.99 | msa | 14.0 | 15.9 | 7.6 | 3.60 | 33.6 |
|
|
126
|
-
| F36 | Nemotron 3 Ultra | none | chisel | 13.6 | 15.4 | 0.2 | 1.47 | 27.7 |
|
|
127
|
-
| F37 | Qwen 3.7 Plus | none | msa | 10.2 | 11.5 | 0.9 | 0.24 | 45.3 |
|
|
128
|
-
| F38 | SWE-1.6 | none | chisel | 9.4 | 10.4 | 0.0 | 0.49 | 19.8 |
|
|
129
|
-
| F39 | Mistral 3.5 Medium | none | chisel | 8.0 | 9.0 | 0.6 | 1.35 | 22.5 |
|
|
@@ -19,7 +19,11 @@ Subagent and workflow-stage `model: "auto"` routes before execution starts. Atom
|
|
|
19
19
|
- hard `modelConstraints`, and
|
|
20
20
|
- the factual markdown tables in [Evals](/models/evals).
|
|
21
21
|
|
|
22
|
-
The router returns one primary `{ model, effort }` pair and up to two ordered fallback pairs. It cannot add candidates, bypass constraints, alter the execution prompt, change the selected chat model
|
|
22
|
+
The router returns one primary `{ model, effort }` pair and up to two ordered fallback pairs. It cannot add candidates, bypass constraints, alter the execution prompt, or change the selected chat model. [`routerModel`](/settings#routermodel) chooses the decision model only: an explicit registered classifier or chat language model. Unset and `auto` use the current chat model, regardless of saved classifier credentials. An image-generation model cannot decide.
|
|
23
|
+
|
|
24
|
+
Only chat language models are eligible for execution `auto`, including models that accept image or PDF input. Image-generation and classifier models cannot be execution candidates, even when a classifier makes the routing decision.
|
|
25
|
+
|
|
26
|
+
In authored workflows, a classifier can make a structured triage decision without executing the stage; an image model can generate an asset inside a durable tool step. See [classifier and image models in `ctx.tool`](/workflows/authoring#classifier-and-image-models-in-ctx-tool).
|
|
23
27
|
|
|
24
28
|
Long tasks may be excerpted for routing so the decision fits the decision provider's input budget. Execution still receives the full task. Put essential selection requirements in `<keepContext>...</keepContext>` spans because the excerpt preserves those spans, plus the beginning and end of the task.
|
|
25
29
|
|
|
@@ -68,7 +68,9 @@ When a package manifest exists, declared resource arrays normally define what lo
|
|
|
68
68
|
|
|
69
69
|
Third-party runtime dependencies belong in `dependencies` in `package.json`. Dependencies that do not register extensions, skills, prompt templates, themes, or workflows also belong in `dependencies`. When Atomic installs a package from npm or git, it runs the configured npm-compatible install command, so those dependencies are installed automatically.
|
|
70
70
|
|
|
71
|
-
Atomic bundles core packages for extensions and skills. If you import any of these, list them in `peerDependencies` with a `"*"` range and do not bundle them: `@bastani/pi-ai`, `@earendil-works/pi-agent-core`, `@bastani/atomic`, `@earendil-works/pi-tui`, `typebox`.
|
|
71
|
+
Atomic bundles core packages for extensions and skills. If you import any of these, list them in `peerDependencies` with a `"*"` range and do not bundle them: `@bastani/pi-ai`, `@earendil-works/pi-agent-core`, `@bastani/atomic`, `@earendil-works/pi-tui`, `typebox`. Atomic does not install peer dependencies for npm packages or for git packages installed with npm, pnpm, or Bun. Local packages are not installed or modified, so their dependency tree is up to the package author.
|
|
72
|
+
|
|
73
|
+
Do not list these host-provided packages in `dependencies`. An installed copy can bypass Atomic's extension module mapping and create duplicate classes, registries, and startup work. Atomic shows an extension warning when a package's `dependencies` include one of them.
|
|
72
74
|
|
|
73
75
|
Workflow packages import `workflow` from `@bastani/atomic/workflows`, import `Type` from `typebox`, and export definitions returned by `workflow({ ... })`. List `@bastani/atomic` and `typebox` in `peerDependencies` so package consumers receive the workflow SDK and schema library.
|
|
74
76
|
|