@bastani/atomic 0.9.5-alpha.8 → 0.9.5
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 +122 -0
- package/README.md +2 -2
- package/dist/builtin/cursor/CHANGELOG.md +12 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/cursor/src/model-mapper.ts +6 -3
- package/dist/builtin/intercom/CHANGELOG.md +37 -0
- package/dist/builtin/intercom/README.md +4 -2
- package/dist/builtin/intercom/broker/broker.ts +6 -114
- package/dist/builtin/intercom/broker/client.ts +29 -54
- package/dist/builtin/intercom/broker/delivered-message-cache.ts +44 -0
- package/dist/builtin/intercom/broker/pending-send-registry.ts +142 -0
- package/dist/builtin/intercom/broker/send-handler.ts +106 -0
- package/dist/builtin/intercom/broker/send-signature.ts +37 -0
- package/dist/builtin/intercom/foreground-detach-handoff.ts +136 -0
- package/dist/builtin/intercom/index-heavy.ts +49 -53
- package/dist/builtin/intercom/index.ts +278 -262
- package/dist/builtin/intercom/lazy-heavy-proxy.ts +114 -0
- package/dist/builtin/intercom/lazy-subagent-ack.ts +20 -0
- package/dist/builtin/intercom/lazy-tool-execution.ts +39 -0
- package/dist/builtin/intercom/lifecycle-lease.ts +51 -0
- package/dist/builtin/intercom/lifecycle.ts +37 -20
- package/dist/builtin/intercom/package.json +3 -6
- package/dist/builtin/intercom/reply-routing.ts +17 -0
- package/dist/builtin/intercom/subagent-relay.ts +58 -12
- package/dist/builtin/intercom/types.ts +3 -3
- package/dist/builtin/mcp/CHANGELOG.md +38 -0
- package/dist/builtin/mcp/OAUTH.md +1 -0
- package/dist/builtin/mcp/README.md +10 -6
- package/dist/builtin/mcp/apps-cancellation.ts +32 -0
- package/dist/builtin/mcp/call-tool-result.ts +9 -0
- package/dist/builtin/mcp/caller-wait.ts +50 -0
- package/dist/builtin/mcp/command-registration.ts +82 -0
- package/dist/builtin/mcp/direct-tool-executor.ts +279 -0
- package/dist/builtin/mcp/direct-tools.ts +40 -255
- package/dist/builtin/mcp/host-html-template.ts +4 -2
- package/dist/builtin/mcp/index.ts +274 -239
- package/dist/builtin/mcp/init.ts +96 -126
- package/dist/builtin/mcp/mcp-auth-flow.ts +247 -237
- package/dist/builtin/mcp/mcp-callback-server.ts +89 -68
- package/dist/builtin/mcp/mcp-oauth-provider.ts +23 -1
- package/dist/builtin/mcp/metadata-hydration.ts +52 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/proxy-auth.ts +4 -4
- package/dist/builtin/mcp/proxy-call.ts +111 -40
- package/dist/builtin/mcp/proxy-connect.ts +35 -15
- package/dist/builtin/mcp/proxy-info-modes.ts +106 -23
- package/dist/builtin/mcp/proxy-modes.ts +3 -3
- package/dist/builtin/mcp/session-cleanup-barrier.ts +43 -0
- package/dist/builtin/mcp/startup-warmup.ts +98 -0
- package/dist/builtin/mcp/state-lease.ts +12 -0
- package/dist/builtin/mcp/tool-result-renderer.ts +3 -3
- package/dist/builtin/mcp/ui-server.ts +8 -8
- package/dist/builtin/mcp/ui-session.ts +9 -18
- package/dist/builtin/subagents/CHANGELOG.md +78 -0
- package/dist/builtin/subagents/README.md +30 -29
- package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
- package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +2 -2
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
- package/dist/builtin/subagents/agents/debugger.md +2 -2
- package/dist/builtin/subagents/agents/worker.md +2 -2
- package/dist/builtin/subagents/package.json +5 -5
- package/dist/builtin/subagents/prompts/review-loop.md +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +37 -36
- package/dist/builtin/subagents/src/extension/api-lifecycle.ts +64 -0
- package/dist/builtin/subagents/src/extension/fanout-child.ts +44 -51
- package/dist/builtin/subagents/src/extension/index.ts +289 -320
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +7 -10
- package/dist/builtin/subagents/src/extension/schemas.ts +22 -5
- package/dist/builtin/subagents/src/extension/startup-maintenance.ts +89 -0
- package/dist/builtin/subagents/src/extension/tool-description.ts +29 -0
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +13 -2
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -4
- package/dist/builtin/subagents/src/runs/background/async-event-journal.ts +106 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +26 -20
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +13 -2
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +3 -0
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/completion-claims.ts +189 -0
- package/dist/builtin/subagents/src/runs/background/completion-dedupe.ts +44 -7
- package/dist/builtin/subagents/src/runs/background/completion-notification.ts +34 -0
- package/dist/builtin/subagents/src/runs/background/notify.ts +72 -22
- package/dist/builtin/subagents/src/runs/background/result-delivery-processor.ts +232 -0
- package/dist/builtin/subagents/src/runs/background/result-file-claims.ts +151 -0
- package/dist/builtin/subagents/src/runs/background/result-quarantine.ts +72 -0
- package/dist/builtin/subagents/src/runs/background/result-retry-scheduler.ts +48 -0
- package/dist/builtin/subagents/src/runs/background/result-status.ts +81 -0
- package/dist/builtin/subagents/src/runs/background/result-watcher-data.ts +59 -0
- package/dist/builtin/subagents/src/runs/background/result-watcher.ts +177 -233
- package/dist/builtin/subagents/src/runs/background/run-id-resolver.ts +3 -2
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +73 -14
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +29 -15
- package/dist/builtin/subagents/src/runs/background/top-level-async.ts +1 -2
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +7 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +3 -13
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +2 -15
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +63 -46
- package/dist/builtin/subagents/src/runs/foreground/execution-detach-reservations.ts +48 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-detach-route.ts +17 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +39 -26
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +3 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +3 -51
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +6 -11
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +11 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +5 -112
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +68 -118
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +79 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +3 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -2
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +55 -12
- package/dist/builtin/subagents/src/shared/artifacts.ts +22 -11
- package/dist/builtin/subagents/src/shared/event-jsonl-writer.ts +294 -0
- package/dist/builtin/subagents/src/shared/exclusive-file-publication.ts +44 -0
- package/dist/builtin/subagents/src/shared/jsonl-writer.ts +1 -0
- package/dist/builtin/subagents/src/shared/model-info.ts +2 -2
- package/dist/builtin/subagents/src/shared/settings.ts +20 -10
- package/dist/builtin/subagents/src/shared/types-async.ts +3 -1
- package/dist/builtin/subagents/src/shared/types-config.ts +2 -0
- package/dist/builtin/subagents/src/shared/types-runtime.ts +3 -2
- package/dist/builtin/subagents/src/slash/slash-commands.ts +9 -12
- package/dist/builtin/subagents/src/slash/slash-live-state.ts +63 -32
- package/dist/builtin/subagents/src/tui/render-result.ts +7 -0
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -0
- package/dist/builtin/subagents/src/tui/render-widget.ts +157 -89
- package/dist/builtin/web-access/CHANGELOG.md +28 -0
- package/dist/builtin/web-access/README.md +4 -0
- package/dist/builtin/web-access/content-tools.ts +8 -3
- package/dist/builtin/web-access/index-heavy.ts +1 -1
- package/dist/builtin/web-access/index.ts +190 -46
- package/dist/builtin/web-access/lifecycle-lease.ts +38 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/web-access/result-renderers.ts +1 -1
- package/dist/builtin/web-access/summary-review.ts +1 -1
- package/dist/builtin/web-access/web-search-activity.ts +1 -1
- package/dist/builtin/web-access/web-search-return.ts +7 -0
- package/dist/builtin/web-access/web-search-summary.ts +1 -1
- package/dist/builtin/web-access/web-search-tool.ts +4 -2
- package/dist/builtin/workflows/CHANGELOG.md +86 -0
- package/dist/builtin/workflows/README.md +5 -5
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +27 -4
- package/dist/builtin/workflows/builtin/goal-runner.ts +86 -27
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +10 -0
- package/dist/builtin/workflows/builtin/ralph-core.ts +9 -9
- package/dist/builtin/workflows/builtin/ralph-models.ts +71 -36
- package/dist/builtin/workflows/builtin/ralph-runner.ts +20 -31
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +16 -13
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -0
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +58 -0
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +40 -0
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +139 -0
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +69 -62
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +21 -7
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +92 -0
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +29 -7
- package/dist/builtin/workflows/skills/impeccable/reference/ios.md +45 -0
- package/dist/builtin/workflows/skills/impeccable/reference/layout.md +25 -1
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +23 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +2 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +75 -14
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +31 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +64 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +118 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +16 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +66 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +42 -10
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +30 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +4 -6
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +660 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-before-edit.mjs +516 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +1764 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +61 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +4 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +13 -16
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +17 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +104 -37
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +9 -0
- package/dist/builtin/workflows/src/durable/backend.ts +12 -0
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +17 -1
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +12 -0
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +5 -2
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +2 -1
- package/dist/builtin/workflows/src/durable/types.ts +16 -0
- package/dist/builtin/workflows/src/engine/primitives/task.ts +3 -1
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +1 -2
- package/dist/builtin/workflows/src/engine/run-returned-status.ts +50 -16
- package/dist/builtin/workflows/src/engine/run.ts +20 -19
- package/dist/builtin/workflows/src/engine/runtime.ts +5 -0
- package/dist/builtin/workflows/src/extension/extension-factory.ts +3 -0
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +9 -2
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +137 -27
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +22 -6
- package/dist/builtin/workflows/src/extension/public-types.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +13 -1
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +19 -4
- package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +9 -0
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +17 -22
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +48 -23
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +15 -2
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +20 -8
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +24 -8
- package/dist/builtin/workflows/src/runs/background/status.ts +4 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +29 -8
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +3 -2
- package/dist/builtin/workflows/src/runs/shared/model-fallback-candidates.ts +1 -1
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +155 -20
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +6 -0
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +2 -2
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +2 -2
- package/dist/builtin/workflows/src/shared/resume-continuation.ts +2 -0
- package/dist/builtin/workflows/src/shared/returned-run-status.ts +116 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-decisions.ts +2 -0
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +21 -3
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +3 -0
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +3 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +1 -23
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +54 -9
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +5 -2
- package/dist/builtin/workflows/src/tui/status-list.ts +22 -15
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +4 -4
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +23 -3
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +129 -17
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +9 -1
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +1 -1
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +6 -3
- 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-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +2 -2
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +1 -1
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +3 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +4 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +4 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-thinking-guard.d.ts +5 -5
- package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
- package/dist/core/anthropic-thinking-guard.js +42 -32
- package/dist/core/anthropic-thinking-guard.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +15 -15
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +14 -9
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +79 -46
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/context-assistant-turns.d.ts +42 -0
- package/dist/core/compaction/context-assistant-turns.d.ts.map +1 -0
- package/dist/core/compaction/context-assistant-turns.js +87 -0
- package/dist/core/compaction/context-assistant-turns.js.map +1 -0
- package/dist/core/compaction/context-compaction-critical.d.ts +1 -1
- package/dist/core/compaction/context-compaction-critical.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-critical.js +2 -2
- package/dist/core/compaction/context-compaction-critical.js.map +1 -1
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts +18 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.js +186 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.js.map +1 -0
- package/dist/core/compaction/context-compaction-eviction.d.ts +10 -2
- package/dist/core/compaction/context-compaction-eviction.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-eviction.js +196 -146
- package/dist/core/compaction/context-compaction-eviction.js.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.js +1 -1
- package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
- package/dist/core/compaction/context-compaction-types.d.ts +2 -0
- package/dist/core/compaction/context-compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-types.js.map +1 -1
- package/dist/core/compaction/context-deletion-application.d.ts +5 -4
- package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-application.js +17 -15
- package/dist/core/compaction/context-deletion-application.js.map +1 -1
- package/dist/core/compaction/context-deletion-store.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-store.js +1 -1
- package/dist/core/compaction/context-deletion-store.js.map +1 -1
- package/dist/core/compaction/context-deletion-targets.d.ts +2 -1
- package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-targets.js +36 -31
- package/dist/core/compaction/context-deletion-targets.js.map +1 -1
- package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-tool-helpers.js +116 -43
- package/dist/core/compaction/context-deletion-tool-helpers.js.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.d.ts +1 -2
- package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.js +33 -37
- package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
- package/dist/core/copilot-model-synthesis.d.ts.map +1 -1
- package/dist/core/copilot-model-synthesis.js +3 -1
- package/dist/core/copilot-model-synthesis.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +8 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +2 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +2 -7
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +6 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +72 -29
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/messages.d.ts +9 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +100 -18
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +5 -0
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-custom-loader.d.ts.map +1 -1
- package/dist/core/model-registry-custom-loader.js +49 -8
- package/dist/core/model-registry-custom-loader.js.map +1 -1
- package/dist/core/model-registry-dynamic.d.ts.map +1 -1
- package/dist/core/model-registry-dynamic.js +11 -5
- package/dist/core/model-registry-dynamic.js.map +1 -1
- package/dist/core/model-registry-loader.d.ts.map +1 -1
- package/dist/core/model-registry-loader.js +8 -0
- package/dist/core/model-registry-loader.js.map +1 -1
- package/dist/core/model-registry-schemas.d.ts +93 -8
- package/dist/core/model-registry-schemas.d.ts.map +1 -1
- package/dist/core/model-registry-schemas.js +24 -12
- package/dist/core/model-registry-schemas.js.map +1 -1
- package/dist/core/model-registry-types.d.ts +7 -6
- package/dist/core/model-registry-types.d.ts.map +1 -1
- package/dist/core/model-registry-types.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +23 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts.map +1 -1
- package/dist/core/model-resolver-cli.js +33 -5
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-initial.d.ts +6 -1
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.js +12 -7
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts +1 -0
- package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.js +24 -9
- package/dist/core/openai-responses-payload-sanitizer.js.map +1 -1
- package/dist/core/resource-loader-context-files.d.ts +1 -0
- package/dist/core/resource-loader-context-files.d.ts.map +1 -1
- package/dist/core/resource-loader-context-files.js +13 -10
- package/dist/core/resource-loader-context-files.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +2 -2
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-entry-normalization.d.ts +7 -0
- package/dist/core/session-entry-normalization.d.ts.map +1 -0
- package/dist/core/session-entry-normalization.js +14 -0
- package/dist/core/session-entry-normalization.js.map +1 -0
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +1 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +2 -2
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +127 -108
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +2 -2
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-types.d.ts +1 -1
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts +2 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +141 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +11 -8
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main-deferred-startup.d.ts.map +1 -1
- package/dist/main-deferred-startup.js +2 -2
- package/dist/main-deferred-startup.js.map +1 -1
- package/dist/main-early-input.d.ts.map +1 -1
- package/dist/main-early-input.js +7 -0
- package/dist/main-early-input.js.map +1 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +1 -0
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +0 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-options.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-options.js +3 -1
- package/dist/modes/interactive/components/settings-selector-options.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +2 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +3 -1
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +21 -9
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-child-ordering.d.ts +7 -0
- package/dist/modes/interactive/interactive-child-ordering.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-child-ordering.js +26 -0
- package/dist/modes/interactive/interactive-child-ordering.js.map +1 -0
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +43 -30
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +1 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +41 -6
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +3 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +2 -2
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +2 -2
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +11 -4
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +0 -3
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +15 -1
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +5 -1
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +20 -21
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/global-theme.js +26 -2
- package/dist/modes/interactive/theme/global-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +2 -0
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +3 -0
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +24 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +60 -5
- package/dist/utils/fs-watch.js.map +1 -1
- package/docs/changelog.mdx +19 -0
- package/docs/compaction.md +60 -49
- package/docs/custom-provider.md +18 -5
- package/docs/development.md +4 -0
- package/docs/extensions.md +11 -2
- package/docs/json.md +1 -1
- package/docs/models.md +69 -10
- package/docs/providers.md +1 -1
- package/docs/quickstart.md +12 -8
- package/docs/rpc.md +2 -2
- package/docs/sdk.md +1 -1
- package/docs/settings.md +4 -4
- package/docs/subagents.md +40 -5
- package/docs/tools.md +1 -1
- package/docs/usage.md +4 -2
- package/docs/windows.md +4 -0
- package/docs/workflows.md +33 -48
- package/examples/extensions/preset.ts +2 -2
- package/examples/extensions/subagent/README.md +2 -2
- package/examples/extensions/subagent/index.ts +1 -2
- package/examples/extensions/subagent/schemas.ts +4 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/npm-shrinkwrap.json +48 -51
- package/package.json +7 -7
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-behavior.ts +0 -75
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-component.ts +0 -202
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-edit.ts +0 -97
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-editor.ts +0 -160
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-frame.ts +0 -72
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-modes.ts +0 -161
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-selectors.ts +0 -203
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-selectors.ts +0 -234
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-state.ts +0 -103
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-types.ts +0 -29
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify.ts +0 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-clarify.ts +0 -117
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type { DrainableSource, JsonlWriteStream } from "./jsonl-writer.ts";
|
|
4
|
+
|
|
5
|
+
interface TelemetryState {
|
|
6
|
+
telemetryBytes: number;
|
|
7
|
+
telemetryTruncated: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface SharedEventWriter extends TelemetryState {
|
|
11
|
+
stream: JsonlWriteStream;
|
|
12
|
+
sources: Set<DrainableSource>;
|
|
13
|
+
refs: number;
|
|
14
|
+
backpressured: boolean;
|
|
15
|
+
closed: boolean;
|
|
16
|
+
failed: boolean;
|
|
17
|
+
filePath: string;
|
|
18
|
+
key: string;
|
|
19
|
+
closingLines: string[];
|
|
20
|
+
settled: Promise<void>;
|
|
21
|
+
resolveSettled: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const writers = new Map<string, SharedEventWriter>();
|
|
25
|
+
|
|
26
|
+
interface TelemetryHydration extends TelemetryState {
|
|
27
|
+
dev: number;
|
|
28
|
+
ino: number;
|
|
29
|
+
size: number;
|
|
30
|
+
mtimeMs: number;
|
|
31
|
+
ctimeMs: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const hydrationCache = new Map<string, TelemetryHydration>();
|
|
35
|
+
const MAX_HYDRATION_ENTRIES = 512;
|
|
36
|
+
const HYDRATION_CHUNK_BYTES = 64 * 1024;
|
|
37
|
+
const TRUNCATION_MARKER = '"type":"subagent.child.telemetry_truncated"';
|
|
38
|
+
let hydrationScanCount = 0;
|
|
39
|
+
let hydrationScannedBytes = 0;
|
|
40
|
+
|
|
41
|
+
function keyFor(filePath: string): string {
|
|
42
|
+
return path.resolve(filePath);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function cacheHydration(key: string, hydration: TelemetryHydration): void {
|
|
46
|
+
hydrationCache.delete(key);
|
|
47
|
+
hydrationCache.set(key, hydration);
|
|
48
|
+
while (hydrationCache.size > MAX_HYDRATION_ENTRIES) {
|
|
49
|
+
const oldest = hydrationCache.keys().next().value as string | undefined;
|
|
50
|
+
if (oldest === undefined) break;
|
|
51
|
+
hydrationCache.delete(oldest);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function scanForTruncationMarker(filePath: string): boolean {
|
|
56
|
+
hydrationScanCount += 1;
|
|
57
|
+
const handle = fs.openSync(filePath, "r");
|
|
58
|
+
try {
|
|
59
|
+
const buffer = Buffer.allocUnsafe(HYDRATION_CHUNK_BYTES);
|
|
60
|
+
let offset = 0;
|
|
61
|
+
let overlap = "";
|
|
62
|
+
while (true) {
|
|
63
|
+
const count = fs.readSync(handle, buffer, 0, buffer.length, offset);
|
|
64
|
+
if (count === 0) return false;
|
|
65
|
+
hydrationScannedBytes += count;
|
|
66
|
+
const text = overlap + buffer.subarray(0, count).toString("utf-8");
|
|
67
|
+
if (text.includes(TRUNCATION_MARKER)) return true;
|
|
68
|
+
overlap = text.slice(-(TRUNCATION_MARKER.length - 1));
|
|
69
|
+
offset += count;
|
|
70
|
+
}
|
|
71
|
+
} finally {
|
|
72
|
+
fs.closeSync(handle);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function hydrationFromStat(stat: fs.Stats, state: TelemetryState): TelemetryHydration {
|
|
77
|
+
return { dev: Number(stat.dev), ino: Number(stat.ino), size: stat.size, mtimeMs: stat.mtimeMs, ctimeMs: stat.ctimeMs, ...state };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function existingTelemetryState(filePath: string, seed?: TelemetryState): TelemetryState {
|
|
81
|
+
const key = keyFor(filePath);
|
|
82
|
+
try {
|
|
83
|
+
const stat = fs.statSync(filePath);
|
|
84
|
+
const telemetryTruncated = Boolean(seed?.telemetryTruncated) || scanForTruncationMarker(filePath);
|
|
85
|
+
const telemetryBytes = Math.max(stat.size, seed?.telemetryBytes ?? 0);
|
|
86
|
+
cacheHydration(key, hydrationFromStat(stat, { telemetryBytes, telemetryTruncated }));
|
|
87
|
+
return { telemetryBytes, telemetryTruncated };
|
|
88
|
+
} catch {
|
|
89
|
+
hydrationCache.delete(key);
|
|
90
|
+
return seed
|
|
91
|
+
? { telemetryBytes: seed.telemetryBytes, telemetryTruncated: seed.telemetryTruncated }
|
|
92
|
+
: { telemetryBytes: 0, telemetryTruncated: false };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function cacheSettledWriter(writer: SharedEventWriter): void {
|
|
97
|
+
try {
|
|
98
|
+
const stat = fs.statSync(writer.filePath);
|
|
99
|
+
cacheHydration(writer.key, hydrationFromStat(stat, {
|
|
100
|
+
telemetryBytes: Math.max(stat.size, writer.telemetryBytes),
|
|
101
|
+
telemetryTruncated: writer.telemetryTruncated,
|
|
102
|
+
}));
|
|
103
|
+
} catch { hydrationCache.delete(writer.key); }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function resetEventWriterHydrationCacheForTests(): void {
|
|
107
|
+
hydrationCache.clear();
|
|
108
|
+
hydrationScanCount = 0;
|
|
109
|
+
hydrationScannedBytes = 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function eventWriterHydrationCacheSizeForTests(): number {
|
|
113
|
+
return hydrationCache.size;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function eventWriterHydrationScanStatsForTests(): { scans: number; bytes: number } {
|
|
117
|
+
return { scans: hydrationScanCount, bytes: hydrationScannedBytes };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function resumeSources(writer: SharedEventWriter): void {
|
|
121
|
+
for (const source of writer.sources) source.resume();
|
|
122
|
+
writer.sources.clear();
|
|
123
|
+
writer.backpressured = false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function settleWriter(writer: SharedEventWriter): void {
|
|
127
|
+
if (!writer.failed) cacheSettledWriter(writer);
|
|
128
|
+
if (writers.get(writer.key) === writer) writers.delete(writer.key);
|
|
129
|
+
resumeSources(writer);
|
|
130
|
+
writer.resolveSettled();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function failWriter(writer: SharedEventWriter): void {
|
|
134
|
+
if (writer.failed) return;
|
|
135
|
+
writer.failed = true;
|
|
136
|
+
writer.closed = true;
|
|
137
|
+
settleWriter(writer);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function write(writer: SharedEventWriter, chunk: string): void {
|
|
141
|
+
if (writer.closed || writer.failed) return;
|
|
142
|
+
try {
|
|
143
|
+
const accepted = writer.stream.write(chunk);
|
|
144
|
+
if (!accepted && !writer.backpressured) {
|
|
145
|
+
writer.backpressured = true;
|
|
146
|
+
for (const source of writer.sources) source.pause();
|
|
147
|
+
writer.stream.once("drain", () => {
|
|
148
|
+
writer.backpressured = false;
|
|
149
|
+
if (!writer.closed && !writer.failed) for (const source of writer.sources) source.resume();
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
} catch {
|
|
153
|
+
failWriter(writer);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface EventWriterLease {
|
|
158
|
+
reserveTelemetry(bytes: number, maxBytes: number): boolean;
|
|
159
|
+
claimTruncationMarker(): boolean;
|
|
160
|
+
writeLine(line: string): void;
|
|
161
|
+
close(): Promise<void>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type StreamFactory = (filePath: string) => JsonlWriteStream;
|
|
165
|
+
|
|
166
|
+
function createDeferredLease(
|
|
167
|
+
closingWriter: SharedEventWriter,
|
|
168
|
+
filePath: string,
|
|
169
|
+
source: DrainableSource,
|
|
170
|
+
createWriteStream: StreamFactory,
|
|
171
|
+
): EventWriterLease {
|
|
172
|
+
const bufferedLines: string[] = [];
|
|
173
|
+
let inner: EventWriterLease | undefined;
|
|
174
|
+
let closePromise: Promise<void> | undefined;
|
|
175
|
+
const activate = async (): Promise<void> => {
|
|
176
|
+
await closingWriter.settled;
|
|
177
|
+
inner = acquireEventWriterInternal(filePath, source, createWriteStream, closingWriter);
|
|
178
|
+
if (!inner) return;
|
|
179
|
+
for (const line of bufferedLines) inner.writeLine(line);
|
|
180
|
+
bufferedLines.length = 0;
|
|
181
|
+
};
|
|
182
|
+
const activated = activate();
|
|
183
|
+
return {
|
|
184
|
+
reserveTelemetry(bytes, maxBytes) {
|
|
185
|
+
if (inner) return inner.reserveTelemetry(bytes, maxBytes);
|
|
186
|
+
if (closingWriter.telemetryTruncated || closingWriter.telemetryBytes + bytes > maxBytes) return false;
|
|
187
|
+
closingWriter.telemetryBytes += bytes;
|
|
188
|
+
return true;
|
|
189
|
+
},
|
|
190
|
+
claimTruncationMarker() {
|
|
191
|
+
if (inner) return inner.claimTruncationMarker();
|
|
192
|
+
if (closingWriter.telemetryTruncated) return false;
|
|
193
|
+
closingWriter.telemetryTruncated = true;
|
|
194
|
+
return true;
|
|
195
|
+
},
|
|
196
|
+
writeLine(line) {
|
|
197
|
+
if (!line.trim()) return;
|
|
198
|
+
if (inner) inner.writeLine(line);
|
|
199
|
+
else bufferedLines.push(line);
|
|
200
|
+
},
|
|
201
|
+
close() {
|
|
202
|
+
closePromise ??= activated.then(() => inner?.close());
|
|
203
|
+
return closePromise;
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function createWriter(filePath: string, key: string, createWriteStream: StreamFactory, seed?: TelemetryState): SharedEventWriter | undefined {
|
|
209
|
+
let stream: JsonlWriteStream;
|
|
210
|
+
try {
|
|
211
|
+
stream = createWriteStream(filePath);
|
|
212
|
+
} catch {
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
let resolveSettled = () => {};
|
|
216
|
+
const settled = new Promise<void>((resolve) => { resolveSettled = resolve; });
|
|
217
|
+
const writer: SharedEventWriter = {
|
|
218
|
+
stream, sources: new Set(), refs: 0, backpressured: false,
|
|
219
|
+
...existingTelemetryState(filePath, seed),
|
|
220
|
+
closed: false, failed: false, filePath, key, closingLines: [], settled, resolveSettled,
|
|
221
|
+
};
|
|
222
|
+
stream.on?.("error", () => failWriter(writer));
|
|
223
|
+
writers.set(key, writer);
|
|
224
|
+
return writer;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function acquireEventWriterInternal(
|
|
228
|
+
filePath: string,
|
|
229
|
+
source: DrainableSource,
|
|
230
|
+
createWriteStream: StreamFactory,
|
|
231
|
+
seed?: TelemetryState,
|
|
232
|
+
): EventWriterLease | undefined {
|
|
233
|
+
const key = keyFor(filePath);
|
|
234
|
+
let writer = writers.get(key);
|
|
235
|
+
if (writer?.closed) return createDeferredLease(writer, filePath, source, createWriteStream);
|
|
236
|
+
writer ??= createWriter(filePath, key, createWriteStream, seed);
|
|
237
|
+
if (!writer) return undefined;
|
|
238
|
+
writer.refs += 1;
|
|
239
|
+
writer.sources.add(source);
|
|
240
|
+
if (writer.backpressured) source.pause();
|
|
241
|
+
let closePromise: Promise<void> | undefined;
|
|
242
|
+
return {
|
|
243
|
+
reserveTelemetry(bytes, maxBytes) {
|
|
244
|
+
if (writer!.failed || writer!.telemetryTruncated || writer!.telemetryBytes + bytes > maxBytes) return false;
|
|
245
|
+
writer!.telemetryBytes += bytes;
|
|
246
|
+
return true;
|
|
247
|
+
},
|
|
248
|
+
claimTruncationMarker() {
|
|
249
|
+
if (writer!.failed || writer!.telemetryTruncated) return false;
|
|
250
|
+
writer!.telemetryTruncated = true;
|
|
251
|
+
return true;
|
|
252
|
+
},
|
|
253
|
+
writeLine(line) {
|
|
254
|
+
if (line.trim()) write(writer!, `${line}\n`);
|
|
255
|
+
},
|
|
256
|
+
close() {
|
|
257
|
+
if (closePromise) return closePromise;
|
|
258
|
+
writer!.sources.delete(source);
|
|
259
|
+
writer!.refs -= 1;
|
|
260
|
+
if (writer!.refs > 0 || writer!.failed) return closePromise = Promise.resolve();
|
|
261
|
+
writer!.closed = true;
|
|
262
|
+
try {
|
|
263
|
+
writer!.stream.end(() => {
|
|
264
|
+
if (!writer!.failed) {
|
|
265
|
+
for (const line of writer!.closingLines) {
|
|
266
|
+
try { fs.appendFileSync(writer!.filePath, line); } catch { /* telemetry failure is non-fatal */ }
|
|
267
|
+
}
|
|
268
|
+
settleWriter(writer!);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
} catch {
|
|
272
|
+
failWriter(writer!);
|
|
273
|
+
}
|
|
274
|
+
return closePromise = writer!.settled;
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export function acquireEventWriter(
|
|
280
|
+
filePath: string,
|
|
281
|
+
source: DrainableSource,
|
|
282
|
+
createWriteStream: StreamFactory = (target) => fs.createWriteStream(target, { flags: "a" }),
|
|
283
|
+
): EventWriterLease | undefined {
|
|
284
|
+
return acquireEventWriterInternal(filePath, source, createWriteStream);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** Route lifecycle/control appends through an active child writer to avoid mixed handles. */
|
|
288
|
+
export function appendToActiveEventWriter(filePath: string, line: string): boolean {
|
|
289
|
+
const writer = writers.get(keyFor(filePath));
|
|
290
|
+
if (!writer) return false;
|
|
291
|
+
if (writer.closed) writer.closingLines.push(`${line}\n`);
|
|
292
|
+
else write(writer, `${line}\n`);
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
|
|
3
|
+
export interface ExclusivePublicationFs {
|
|
4
|
+
linkSync?: typeof fs.linkSync;
|
|
5
|
+
copyFileSync?: typeof fs.copyFileSync;
|
|
6
|
+
unlinkSync: typeof fs.unlinkSync;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function errorCode(error: unknown): string | undefined {
|
|
10
|
+
return typeof error === "object" && error !== null && "code" in error
|
|
11
|
+
? (error as NodeJS.ErrnoException).code
|
|
12
|
+
: undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Publish an existing file without ever replacing the destination. */
|
|
16
|
+
export function publishFileExclusive(
|
|
17
|
+
source: string,
|
|
18
|
+
destination: string,
|
|
19
|
+
fsApi: ExclusivePublicationFs = fs,
|
|
20
|
+
): "published" | "exists" {
|
|
21
|
+
try {
|
|
22
|
+
(fsApi.linkSync ?? fs.linkSync)(source, destination);
|
|
23
|
+
return "published";
|
|
24
|
+
} catch (error) {
|
|
25
|
+
const code = errorCode(error);
|
|
26
|
+
if (code === "EEXIST") return "exists";
|
|
27
|
+
if (code !== "EPERM" && code !== "EACCES" && code !== "ENOTSUP" && code !== "EXDEV") throw error;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
(fsApi.copyFileSync ?? fs.copyFileSync)(source, destination, fs.constants.COPYFILE_EXCL);
|
|
31
|
+
return "published";
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (errorCode(error) === "EEXIST") return "exists";
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function unlinkIfPresent(file: string, fsApi: Pick<typeof fs, "unlinkSync"> = fs): void {
|
|
39
|
+
try {
|
|
40
|
+
fsApi.unlinkSync(file);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (errorCode(error) !== "ENOENT") throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -7,6 +7,7 @@ export interface DrainableSource {
|
|
|
7
7
|
|
|
8
8
|
export interface JsonlWriteStream {
|
|
9
9
|
write(chunk: string): boolean;
|
|
10
|
+
on?(event: "error", listener: (error: Error) => void): JsonlWriteStream;
|
|
10
11
|
once(event: "drain", listener: () => void): JsonlWriteStream;
|
|
11
12
|
end(callback?: () => void): void;
|
|
12
13
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"] as const;
|
|
1
|
+
export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const;
|
|
2
2
|
export type ThinkingLevel = typeof THINKING_LEVELS[number];
|
|
3
3
|
export type ThinkingLevelMap = Partial<Record<ThinkingLevel, string | null>>;
|
|
4
4
|
|
|
@@ -87,7 +87,7 @@ export function getSupportedThinkingLevels(model: ModelInfo | undefined): Thinki
|
|
|
87
87
|
const levels = THINKING_LEVELS.filter((level) => {
|
|
88
88
|
const mapped = model.thinkingLevelMap?.[level];
|
|
89
89
|
if (mapped === null) return false;
|
|
90
|
-
if (level === "xhigh") return mapped !== undefined;
|
|
90
|
+
if (level === "xhigh" || level === "max") return mapped !== undefined;
|
|
91
91
|
return true;
|
|
92
92
|
});
|
|
93
93
|
return levels;
|
|
@@ -286,15 +286,21 @@ export function suppressProgressForReadOnlyTask(behavior: ResolvedStepBehavior,
|
|
|
286
286
|
return behavior.progress && taskDisallowsFileUpdates(policyTask) ? { ...behavior, progress: false } : behavior;
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
/** Resolve single-agent progress, preserving read-only suppression only for inherited defaults. */
|
|
290
|
+
export function resolveSingleProgress(agentConfig: AgentConfig, override: boolean | undefined, task: string | undefined): boolean {
|
|
291
|
+
const behavior = resolveStepBehavior(agentConfig, { progress: override });
|
|
292
|
+
return override !== undefined ? behavior.progress : suppressProgressForReadOnlyTask(behavior, task).progress;
|
|
293
|
+
}
|
|
294
|
+
|
|
289
295
|
// =============================================================================
|
|
290
296
|
// Chain Instruction Injection
|
|
291
297
|
// =============================================================================
|
|
292
298
|
|
|
293
|
-
/**
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return
|
|
299
|
+
/** Build the common read prefix, resolving relative paths against the child's effective cwd. */
|
|
300
|
+
export function buildReadInstruction(reads: string[] | false | undefined, cwd: string): string {
|
|
301
|
+
if (!reads || reads.length === 0) return "";
|
|
302
|
+
const files = reads.map((file) => path.resolve(cwd, file));
|
|
303
|
+
return `[Read from: ${files.join(", ")}]`;
|
|
298
304
|
}
|
|
299
305
|
|
|
300
306
|
/**
|
|
@@ -302,9 +308,15 @@ function resolveChainPath(filePath: string, chainDir: string): string {
|
|
|
302
308
|
* These are appended to the task to tell the agent what to read/write.
|
|
303
309
|
*/
|
|
304
310
|
export function writeInitialProgressFile(progressDir: string): void {
|
|
311
|
+
fs.mkdirSync(progressDir, { recursive: true });
|
|
305
312
|
fs.writeFileSync(path.join(progressDir, "progress.md"), INITIAL_PROGRESS_CONTENT);
|
|
306
313
|
}
|
|
307
314
|
|
|
315
|
+
/** Add the child-facing instruction for a single-agent progress file. */
|
|
316
|
+
export function injectSingleProgressInstruction(task: string, progressDir: string): string {
|
|
317
|
+
return `${task}\n\n---\nCreate and maintain progress at: ${path.join(progressDir, "progress.md")}`;
|
|
318
|
+
}
|
|
319
|
+
|
|
308
320
|
export function buildChainInstructions(
|
|
309
321
|
behavior: ResolvedStepBehavior,
|
|
310
322
|
chainDir: string,
|
|
@@ -315,14 +327,12 @@ export function buildChainInstructions(
|
|
|
315
327
|
const suffixParts: string[] = [];
|
|
316
328
|
|
|
317
329
|
// READS - prepend to override any hardcoded filenames in task text
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
prefixParts.push(`[Read from: ${files.join(", ")}]`);
|
|
321
|
-
}
|
|
330
|
+
const readInstruction = buildReadInstruction(behavior.reads, chainDir);
|
|
331
|
+
if (readInstruction) prefixParts.push(readInstruction);
|
|
322
332
|
|
|
323
333
|
// OUTPUT - prepend so agent knows where to write
|
|
324
334
|
if (behavior.output) {
|
|
325
|
-
const outputPath =
|
|
335
|
+
const outputPath = path.isAbsolute(behavior.output) ? behavior.output : path.join(chainDir, behavior.output);
|
|
326
336
|
prefixParts.push(`[Write to: ${outputPath}]`);
|
|
327
337
|
}
|
|
328
338
|
|
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
ActivityState,
|
|
9
9
|
ChainOutputMap,
|
|
10
10
|
ModelAttempt,
|
|
11
|
+
SingleResult,
|
|
11
12
|
SubagentResultStatus,
|
|
12
13
|
SubagentRunMode,
|
|
13
14
|
TokenUsage,
|
|
@@ -216,6 +217,7 @@ export interface ForegroundResumeChild {
|
|
|
216
217
|
index: number;
|
|
217
218
|
sessionFile?: string;
|
|
218
219
|
status: SubagentResultStatus;
|
|
220
|
+
result?: SingleResult;
|
|
219
221
|
}
|
|
220
222
|
|
|
221
223
|
export interface ForegroundResumeRun {
|
|
@@ -256,7 +258,7 @@ export interface SubagentState {
|
|
|
256
258
|
cleanupTimers: Map<string, ReturnType<typeof setTimeout>>;
|
|
257
259
|
lastUiContext: ExtensionContext | null;
|
|
258
260
|
poller: NodeJS.Timeout | null;
|
|
259
|
-
completionSeen: Map<string, number>;
|
|
261
|
+
completionSeen: Map<string, number | { seenAt: number; signature?: string }>;
|
|
260
262
|
watcher: FSWatcher | null;
|
|
261
263
|
watcherRestartTimer: ReturnType<typeof setTimeout> | null;
|
|
262
264
|
resultFileCoalescer: {
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
MaxOutputConfig,
|
|
14
14
|
OutputMode,
|
|
15
15
|
ResolvedControlConfig,
|
|
16
|
+
SingleResult,
|
|
16
17
|
} from "./types-results.ts";
|
|
17
18
|
|
|
18
19
|
// ============================================================================
|
|
@@ -58,6 +59,7 @@ export interface RunSyncOptions {
|
|
|
58
59
|
interruptSignal?: AbortSignal;
|
|
59
60
|
allowIntercomDetach?: boolean;
|
|
60
61
|
intercomEvents?: IntercomEventBus;
|
|
62
|
+
onDetachedExit?: (result: SingleResult) => void;
|
|
61
63
|
onUpdate?: (r: AgentToolResult<Details>) => void;
|
|
62
64
|
onControlEvent?: (event: ControlEvent) => void;
|
|
63
65
|
controlConfig?: ResolvedControlConfig;
|
|
@@ -77,7 +77,7 @@ export function resolveTempScopeId(options?: {
|
|
|
77
77
|
return "shared";
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
const
|
|
80
|
+
export const MAX_PARALLEL_TASKS = 50;
|
|
81
81
|
export const MAX_CONCURRENCY = 4;
|
|
82
82
|
export const TEMP_ROOT_DIR = path.join(os.tmpdir(), `${APP_NAME}-subagents-${resolveTempScopeId()}`);
|
|
83
83
|
export const RESULTS_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-results");
|
|
@@ -110,7 +110,8 @@ function normalizeTopLevelParallelValue(value: unknown): number | undefined {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
export function resolveTopLevelParallelMaxTasks(value: unknown): number {
|
|
113
|
-
|
|
113
|
+
const configuredMax = normalizeTopLevelParallelValue(value);
|
|
114
|
+
return configuredMax === undefined ? MAX_PARALLEL_TASKS : Math.min(configuredMax, MAX_PARALLEL_TASKS);
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
export function resolveTopLevelParallelConcurrency(
|
|
@@ -160,7 +160,7 @@ async function requestSlashRun(
|
|
|
160
160
|
if (done || !data || typeof data !== "object") return;
|
|
161
161
|
const update = data as SlashSubagentUpdate;
|
|
162
162
|
if (update.requestId !== requestId) return;
|
|
163
|
-
applySlashUpdate(requestId, update);
|
|
163
|
+
applySlashUpdate(requestId, update, pi);
|
|
164
164
|
if (!ctx.hasUI) return;
|
|
165
165
|
const tool = update.currentTool ? ` ${update.currentTool}` : "";
|
|
166
166
|
const count = update.toolCount ?? 0;
|
|
@@ -260,7 +260,7 @@ async function runSlashSubagent(
|
|
|
260
260
|
): Promise<void> {
|
|
261
261
|
if (ctx.hasUI) ctx.ui.setToolsExpanded(false);
|
|
262
262
|
const requestId = randomUUID();
|
|
263
|
-
const initialDetails = buildSlashInitialResult(requestId, params);
|
|
263
|
+
const initialDetails = buildSlashInitialResult(requestId, params, pi);
|
|
264
264
|
const initialText = extractSlashMessageText(initialDetails.result.content) || "Running subagent...";
|
|
265
265
|
pi.sendMessage({
|
|
266
266
|
customType: SLASH_RESULT_TYPE,
|
|
@@ -272,7 +272,7 @@ async function runSlashSubagent(
|
|
|
272
272
|
|
|
273
273
|
try {
|
|
274
274
|
const response = await requestSlashRun(pi, ctx, requestId, params);
|
|
275
|
-
const finalDetails = finalizeSlashResult(response);
|
|
275
|
+
const finalDetails = finalizeSlashResult(response, pi);
|
|
276
276
|
pi.sendMessage({
|
|
277
277
|
customType: SLASH_RESULT_TYPE,
|
|
278
278
|
content: buildSlashExportText(response),
|
|
@@ -288,7 +288,7 @@ async function runSlashSubagent(
|
|
|
288
288
|
}
|
|
289
289
|
} catch (error) {
|
|
290
290
|
const message = error instanceof Error ? error.message : String(error);
|
|
291
|
-
const failedDetails = failSlashResult(requestId, params, message);
|
|
291
|
+
const failedDetails = failSlashResult(requestId, params, message, pi);
|
|
292
292
|
pi.sendMessage({
|
|
293
293
|
customType: SLASH_RESULT_TYPE,
|
|
294
294
|
content: `## Subagent result\n\n${message}`,
|
|
@@ -402,11 +402,8 @@ export function registerSlashCommands(
|
|
|
402
402
|
if (!state.baseCwd) { ctx.ui.notify("Subagent session cwd is not initialized yet", "error"); return; }
|
|
403
403
|
const agents = discoverAgents(state.baseCwd, "both").agents;
|
|
404
404
|
if (!agents.find((a) => a.name === agentName)) { ctx.ui.notify(`Unknown agent: ${agentName}`, "error"); return; }
|
|
405
|
-
|
|
406
|
-
if (inline.reads
|
|
407
|
-
finalTask = `[Read from: ${inline.reads.join(", ")}]\n\n${finalTask}`;
|
|
408
|
-
}
|
|
409
|
-
const params: SubagentParamsLike = { agent: agentName, task: finalTask, clarify: false, agentScope: "both" };
|
|
405
|
+
const params: SubagentParamsLike = { agent: agentName, task, agentScope: "both" };
|
|
406
|
+
if (inline.reads !== undefined) params.reads = inline.reads;
|
|
410
407
|
if (inline.output !== undefined) params.output = inline.output;
|
|
411
408
|
if (inline.outputMode !== undefined) params.outputMode = inline.outputMode;
|
|
412
409
|
if (inline.skill !== undefined) params.skill = inline.skill;
|
|
@@ -433,7 +430,7 @@ export function registerSlashCommands(
|
|
|
433
430
|
...(config.skill !== undefined ? { skill: config.skill } : {}),
|
|
434
431
|
...(config.progress !== undefined ? { progress: config.progress } : {}),
|
|
435
432
|
}));
|
|
436
|
-
const params: SubagentParamsLike = { chain, task: parsed.task,
|
|
433
|
+
const params: SubagentParamsLike = { chain, task: parsed.task, agentScope: "both" };
|
|
437
434
|
if (bg) params.async = true;
|
|
438
435
|
if (fork) params.context = "fork";
|
|
439
436
|
await runSlashSubagent(pi, ctx, params);
|
|
@@ -462,7 +459,7 @@ export function registerSlashCommands(
|
|
|
462
459
|
ctx.ui.notify(`Unknown chain: ${chainName}`, "error");
|
|
463
460
|
return;
|
|
464
461
|
}
|
|
465
|
-
const params: SubagentParamsLike = { chain: mapSavedChainSteps(chain), task,
|
|
462
|
+
const params: SubagentParamsLike = { chain: mapSavedChainSteps(chain), task, agentScope: "both" };
|
|
466
463
|
if (bg) params.async = true;
|
|
467
464
|
if (fork) params.context = "fork";
|
|
468
465
|
await runSlashSubagent(pi, ctx, params);
|
|
@@ -485,7 +482,7 @@ export function registerSlashCommands(
|
|
|
485
482
|
...(config.skill !== undefined ? { skill: config.skill } : {}),
|
|
486
483
|
...(config.progress !== undefined ? { progress: config.progress } : {}),
|
|
487
484
|
}));
|
|
488
|
-
const params: SubagentParamsLike = { tasks,
|
|
485
|
+
const params: SubagentParamsLike = { tasks, agentScope: "both" };
|
|
489
486
|
if (bg) params.async = true;
|
|
490
487
|
if (fork) params.context = "fork";
|
|
491
488
|
await runSlashSubagent(pi, ctx, params);
|