@bastani/atomic 0.9.13-alpha.2 → 0.9.13-alpha.3
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 +14 -0
- package/README.md +1 -1
- package/dist/builtin/i-have-adhd/package.json +1 -1
- package/dist/builtin/intercom/CHANGELOG.md +14 -0
- package/dist/builtin/intercom/README.md +12 -12
- package/dist/builtin/intercom/incoming-message-delivery.ts +1 -1
- package/dist/builtin/intercom/index.ts +1 -1
- package/dist/builtin/intercom/intercom-tool.ts +1 -1
- package/dist/builtin/intercom/intercom-utils.ts +3 -6
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/result-renderers.ts +1 -1
- package/dist/builtin/intercom/session-target.ts +1 -15
- package/dist/builtin/intercom/skills/intercom/SKILL.md +6 -6
- package/dist/builtin/intercom/terminal-ordering-barrier.ts +2 -2
- package/dist/builtin/intercom/ui/inline-message.ts +7 -5
- package/dist/builtin/intercom/ui/session-list.ts +23 -10
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +19 -0
- package/dist/builtin/subagents/README.md +29 -73
- package/dist/builtin/subagents/package.json +2 -2
- package/dist/builtin/subagents/prompts/parallel-cleanup.md +1 -1
- package/dist/builtin/subagents/prompts/parallel-review.md +1 -1
- package/dist/builtin/subagents/prompts/review-loop.md +2 -2
- package/dist/builtin/subagents/skills/subagent/SKILL.md +23 -59
- package/dist/builtin/subagents/skills/tmux/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/control-notices.ts +2 -3
- package/dist/builtin/subagents/src/extension/doctor.ts +2 -14
- package/dist/builtin/subagents/src/extension/fanout-child.ts +1 -17
- package/dist/builtin/subagents/src/extension/index.ts +9 -70
- package/dist/builtin/subagents/src/extension/notification-content.ts +1 -1
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +2 -2
- package/dist/builtin/subagents/src/extension/schemas.ts +2 -8
- package/dist/builtin/subagents/src/extension/tool-description.ts +2 -3
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +1 -1
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +5 -46
- package/dist/builtin/subagents/src/runs/{background → foreground}/completion-notification.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +25 -88
- package/dist/builtin/subagents/src/runs/{background → foreground}/notify.ts +5 -5
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +11 -28
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +3 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +0 -5
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +30 -20
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +4 -4
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +0 -13
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +104 -48
- package/dist/builtin/subagents/src/runs/inprocess/index.ts +1 -1
- package/dist/builtin/subagents/src/runs/inprocess/runner.ts +5 -5
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-api.ts +0 -7
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-core.ts +0 -10
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-projection.ts +3 -108
- package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-sanitize.ts +0 -4
- package/dist/builtin/subagents/src/runs/shared/subagent-control.ts +1 -1
- package/dist/builtin/subagents/src/shared/formatters.ts +3 -5
- package/dist/builtin/subagents/src/shared/model-resolution.ts +78 -0
- package/dist/builtin/subagents/src/shared/status-format.ts +4 -11
- package/dist/builtin/subagents/src/shared/types-config.ts +10 -9
- package/dist/builtin/subagents/src/shared/types-nested.ts +127 -0
- package/dist/builtin/subagents/src/shared/types-results.ts +2 -8
- package/dist/builtin/subagents/src/shared/types-runtime.ts +0 -9
- package/dist/builtin/subagents/src/shared/types.ts +1 -1
- package/dist/builtin/subagents/src/shared/utils.ts +1 -109
- package/dist/builtin/subagents/src/slash/slash-commands.ts +7 -17
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -252
- package/dist/builtin/subagents/src/tui/render-layout.ts +4 -4
- package/dist/builtin/subagents/src/tui/render-result.ts +0 -9
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -34
- package/dist/builtin/subagents/src/tui/render.ts +0 -2
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +12 -0
- package/dist/builtin/workflows/README.md +3 -3
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/durable/backend.ts +11 -0
- package/dist/builtin/workflows/src/durable/completed-catalog-stage-groups.ts +63 -25
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +166 -25
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +42 -24
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +2 -1
- package/dist/builtin/workflows/src/durable/run-timing.ts +28 -7
- package/dist/builtin/workflows/src/durable/scoped-backend.ts +4 -0
- package/dist/builtin/workflows/src/durable/targeted-inspection.ts +110 -0
- package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +2 -2
- package/dist/builtin/workflows/src/engine/runtime.ts +19 -2
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +3 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +680 -152
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +6 -0
- package/dist/builtin/workflows/src/extension/ui-surface.ts +2 -0
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +6 -1
- package/dist/builtin/workflows/src/extension/workflow-targets.ts +18 -10
- package/dist/builtin/workflows/src/extension/workflow-tool-inspection.ts +31 -16
- package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +75 -3
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +53 -6
- package/dist/builtin/workflows/src/runs/background/run-inspect.ts +5 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +94 -60
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-context.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +7 -7
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +25 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +4 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +2 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +142 -4
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +2 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-session-heartbeat.ts +88 -0
- package/dist/builtin/workflows/src/tui/run-detail.ts +25 -12
- package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +1 -0
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +16 -5
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +2 -1
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +8 -4
- 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 +5 -0
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-summary.d.ts +21 -0
- package/dist/core/agent-session-summary.d.ts.map +1 -0
- package/dist/core/agent-session-summary.js +156 -0
- package/dist/core/agent-session-summary.js.map +1 -0
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +0 -4
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-transfer.d.ts.map +1 -1
- package/dist/core/agent-session-transfer.js +0 -2
- package/dist/core/agent-session-transfer.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +6 -0
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session.d.ts +7 -3
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +8 -5
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/atomic-guide-command.js +2 -2
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/session-summarization.d.ts +41 -0
- package/dist/core/compaction/session-summarization.d.ts.map +1 -0
- package/dist/core/compaction/session-summarization.js +97 -0
- package/dist/core/compaction/session-summarization.js.map +1 -0
- package/dist/core/extensions/ui-types.d.ts +2 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +3 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +9 -1
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +24 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +48 -0
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +10 -0
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +10 -1
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +3 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +5 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-types.d.ts +4 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash.d.ts +0 -15
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -81
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/fetch-url.d.ts +12 -0
- package/dist/core/tools/fetch-url.d.ts.map +1 -1
- package/dist/core/tools/fetch-url.js +76 -10
- package/dist/core/tools/fetch-url.js.map +1 -1
- package/dist/core/tools/index.js +4 -4
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/session-temp-dir.d.ts +2 -2
- package/dist/core/tools/session-temp-dir.d.ts.map +1 -1
- package/dist/core/tools/session-temp-dir.js +6 -7
- package/dist/core/tools/session-temp-dir.js.map +1 -1
- package/dist/core/usage-totals.js +1 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/host-session-picker.d.ts.map +1 -1
- package/dist/modes/interactive/components/host-session-picker.js +1 -0
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +29 -4
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +6 -0
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +4 -1
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/docs/environment-variables.md +1 -1
- package/docs/intercom.md +20 -21
- package/docs/quickstart.md +5 -1
- package/docs/sdk.md +1 -1
- package/docs/session-format.md +15 -0
- package/docs/sessions.md +8 -0
- package/docs/settings.md +6 -0
- package/docs/subagents.md +19 -31
- package/docs/tools.md +3 -5
- package/docs/usage.md +1 -1
- package/docs/windows.md +1 -1
- package/docs/workflows.md +60 -32
- package/npm-shrinkwrap.json +29 -29
- package/package.json +2 -2
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +0 -331
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +0 -161
- package/dist/builtin/subagents/src/runs/inprocess/background-single.ts +0 -195
- package/dist/builtin/subagents/src/runs/inprocess/background.ts +0 -90
- package/dist/builtin/subagents/src/shared/types-async.ts +0 -247
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +0 -217
- package/dist/builtin/subagents/src/tui/render-widget.ts +0 -366
- package/dist/core/async/format.d.ts +0 -3
- package/dist/core/async/format.d.ts.map +0 -1
- package/dist/core/async/format.js +0 -52
- package/dist/core/async/format.js.map +0 -1
- package/dist/core/async/job-manager.d.ts +0 -40
- package/dist/core/async/job-manager.d.ts.map +0 -1
- package/dist/core/async/job-manager.js +0 -293
- package/dist/core/async/job-manager.js.map +0 -1
- package/dist/core/async/session-manager.d.ts +0 -16
- package/dist/core/async/session-manager.d.ts.map +0 -1
- package/dist/core/async/session-manager.js +0 -34
- package/dist/core/async/session-manager.js.map +0 -1
- package/dist/core/async/types.d.ts +0 -23
- package/dist/core/async/types.d.ts.map +0 -1
- package/dist/core/async/types.js +0 -2
- package/dist/core/async/types.js.map +0 -1
- package/dist/core/tools/bash-async-execution.d.ts +0 -27
- package/dist/core/tools/bash-async-execution.d.ts.map +0 -1
- package/dist/core/tools/bash-async-execution.js +0 -81
- package/dist/core/tools/bash-async-execution.js.map +0 -1
- package/dist/core/tools/bash-async-jobs.d.ts +0 -30
- package/dist/core/tools/bash-async-jobs.d.ts.map +0 -1
- package/dist/core/tools/bash-async-jobs.js +0 -87
- package/dist/core/tools/bash-async-jobs.js.map +0 -1
- package/dist/core/tools/bash-async-output.d.ts +0 -13
- package/dist/core/tools/bash-async-output.d.ts.map +0 -1
- package/dist/core/tools/bash-async-output.js +0 -122
- package/dist/core/tools/bash-async-output.js.map +0 -1
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import type { SessionWorkflowMetadata } from "@bastani/atomic";
|
|
6
6
|
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
7
|
-
import type {
|
|
7
|
+
import type { CandidateModelResolver } from "./model-resolution.ts";
|
|
8
|
+
import type { NestedRouteInfo } from "./types-nested.ts";
|
|
8
9
|
import type {
|
|
9
10
|
ArtifactConfig,
|
|
10
11
|
ControlConfig,
|
|
@@ -41,9 +42,8 @@ export interface IntercomEventBus {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
export const INTERCOM_DETACH_REQUEST_EVENT = "pi-intercom:detach-request";
|
|
45
|
+
export const SUBAGENT_COMPLETE_EVENT = "subagent:complete";
|
|
44
46
|
export const INTERCOM_DETACH_RESPONSE_EVENT = "pi-intercom:detach-response";
|
|
45
|
-
export const SUBAGENT_ASYNC_STARTED_EVENT = "subagent:async-started";
|
|
46
|
-
export const SUBAGENT_ASYNC_COMPLETE_EVENT = "subagent:async-complete";
|
|
47
47
|
export const SUBAGENT_CONTROL_EVENT = "subagent:control-event";
|
|
48
48
|
export const SUBAGENT_CONTROL_INTERCOM_EVENT = "subagent:control-intercom";
|
|
49
49
|
export const SUBAGENT_RESULT_INTERCOM_EVENT = "subagent:result-intercom";
|
|
@@ -59,8 +59,6 @@ export interface RunSyncOptions {
|
|
|
59
59
|
signal?: AbortSignal;
|
|
60
60
|
interruptSignal?: AbortSignal;
|
|
61
61
|
allowIntercomDetach?: boolean;
|
|
62
|
-
/** Start the admitted child and settle this call with a continued result immediately. */
|
|
63
|
-
backgroundContinuation?: boolean;
|
|
64
62
|
intercomEvents?: IntercomEventBus;
|
|
65
63
|
onDetachedExit?: (result: SingleResult) => void;
|
|
66
64
|
/** Shared foreground-group signal used to release sibling supervision after one exact child commits Intercom detach. */
|
|
@@ -87,8 +85,6 @@ export interface RunSyncOptions {
|
|
|
87
85
|
index?: number;
|
|
88
86
|
sessionDir?: string;
|
|
89
87
|
sessionFile?: string;
|
|
90
|
-
/** Override the Atomic CLI entrypoint used by foreground child processes. */
|
|
91
|
-
piArgv1?: string;
|
|
92
88
|
share?: boolean;
|
|
93
89
|
outputPath?: string;
|
|
94
90
|
outputMode?: OutputMode;
|
|
@@ -104,6 +100,13 @@ export interface RunSyncOptions {
|
|
|
104
100
|
availableModels?: Array<{ provider: string; id: string; fullId: string }>;
|
|
105
101
|
/** Providers known to the registry before auth filtering */
|
|
106
102
|
knownModelProviders?: string[];
|
|
103
|
+
/**
|
|
104
|
+
* Resolve the selected `provider/model[:thinking]` candidate to a concrete
|
|
105
|
+
* registry model. Without it the child session receives no model and a
|
|
106
|
+
* fork-context child silently runs on the model restored from the parent's
|
|
107
|
+
* session file.
|
|
108
|
+
*/
|
|
109
|
+
resolveCandidateModel?: CandidateModelResolver;
|
|
107
110
|
/** Current parent-session provider to prefer for ambiguous bare model ids */
|
|
108
111
|
preferredModelProvider?: string;
|
|
109
112
|
/** Current parent-session model to try after configured fallback models */
|
|
@@ -144,8 +147,6 @@ interface TopLevelParallelConfig {
|
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
export interface ExtensionConfig {
|
|
147
|
-
asyncByDefault?: boolean;
|
|
148
|
-
forceTopLevelAsync?: boolean;
|
|
149
150
|
defaultSessionDir?: string;
|
|
150
151
|
maxSubagentDepth?: number;
|
|
151
152
|
control?: ControlConfig;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nested foreground run and extension state public types.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ExtensionContext } from "@bastani/atomic";
|
|
6
|
+
import type {
|
|
7
|
+
ActivityState,
|
|
8
|
+
SingleResult,
|
|
9
|
+
SubagentResultStatus,
|
|
10
|
+
SubagentRunMode,
|
|
11
|
+
TokenUsage,
|
|
12
|
+
} from "./types-results.ts";
|
|
13
|
+
|
|
14
|
+
export type NestedRunState = "queued" | "running" | "complete" | "failed" | "paused";
|
|
15
|
+
export type NestedOwnerState = "live" | "gone" | "unknown";
|
|
16
|
+
|
|
17
|
+
export interface NestedRunAddress {
|
|
18
|
+
id: string;
|
|
19
|
+
parentRunId: string;
|
|
20
|
+
parentStepIndex?: number;
|
|
21
|
+
parentAgent?: string;
|
|
22
|
+
depth: number;
|
|
23
|
+
path: Array<{ runId: string; stepIndex?: number; agent?: string }>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface NestedStepSummary {
|
|
27
|
+
agent: string;
|
|
28
|
+
status: "pending" | "running" | "complete" | "completed" | "failed" | "paused";
|
|
29
|
+
sessionFile?: string;
|
|
30
|
+
activityState?: ActivityState;
|
|
31
|
+
lastActivityAt?: number;
|
|
32
|
+
currentTool?: string;
|
|
33
|
+
currentToolStartedAt?: number;
|
|
34
|
+
currentPath?: string;
|
|
35
|
+
turnCount?: number;
|
|
36
|
+
toolCount?: number;
|
|
37
|
+
startedAt?: number;
|
|
38
|
+
endedAt?: number;
|
|
39
|
+
error?: string;
|
|
40
|
+
children?: NestedRunSummary[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface NestedRunSummary extends NestedRunAddress {
|
|
44
|
+
sessionId?: string;
|
|
45
|
+
sessionFile?: string;
|
|
46
|
+
intercomTarget?: string;
|
|
47
|
+
ownerIntercomTarget?: string;
|
|
48
|
+
leafIntercomTarget?: string;
|
|
49
|
+
ownerState?: NestedOwnerState;
|
|
50
|
+
controlInbox?: string;
|
|
51
|
+
capabilityToken?: string;
|
|
52
|
+
mode?: SubagentRunMode;
|
|
53
|
+
state: NestedRunState;
|
|
54
|
+
agent?: string;
|
|
55
|
+
agents?: string[];
|
|
56
|
+
steps?: NestedStepSummary[];
|
|
57
|
+
children?: NestedRunSummary[];
|
|
58
|
+
activityState?: ActivityState;
|
|
59
|
+
lastActivityAt?: number;
|
|
60
|
+
currentTool?: string;
|
|
61
|
+
currentToolStartedAt?: number;
|
|
62
|
+
currentPath?: string;
|
|
63
|
+
turnCount?: number;
|
|
64
|
+
toolCount?: number;
|
|
65
|
+
totalTokens?: TokenUsage;
|
|
66
|
+
startedAt?: number;
|
|
67
|
+
endedAt?: number;
|
|
68
|
+
lastUpdate?: number;
|
|
69
|
+
error?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface NestedRouteInfo {
|
|
73
|
+
rootRunId: string;
|
|
74
|
+
eventSink: string;
|
|
75
|
+
controlInbox: string;
|
|
76
|
+
capabilityToken: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface ForegroundResumeChild {
|
|
80
|
+
agent: string;
|
|
81
|
+
index: number;
|
|
82
|
+
sessionFile?: string;
|
|
83
|
+
status: SubagentResultStatus;
|
|
84
|
+
result?: SingleResult;
|
|
85
|
+
/** Effective delegation limit retained for a resumed child. */
|
|
86
|
+
maxSubagentDepth?: number;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ForegroundResumeRun {
|
|
90
|
+
runId: string;
|
|
91
|
+
mode: SubagentRunMode;
|
|
92
|
+
cwd: string;
|
|
93
|
+
updatedAt: number;
|
|
94
|
+
children: ForegroundResumeChild[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface SubagentState {
|
|
98
|
+
baseCwd: string;
|
|
99
|
+
currentSessionId: string | null;
|
|
100
|
+
subagentInProgress?: boolean;
|
|
101
|
+
foregroundRuns?: Map<string, ForegroundResumeRun>;
|
|
102
|
+
foregroundControls: Map<
|
|
103
|
+
string,
|
|
104
|
+
{
|
|
105
|
+
runId: string;
|
|
106
|
+
mode: SubagentRunMode;
|
|
107
|
+
startedAt: number;
|
|
108
|
+
updatedAt: number;
|
|
109
|
+
currentAgent?: string;
|
|
110
|
+
currentIndex?: number;
|
|
111
|
+
currentActivityState?: ActivityState;
|
|
112
|
+
lastActivityAt?: number;
|
|
113
|
+
currentTool?: string;
|
|
114
|
+
currentToolStartedAt?: number;
|
|
115
|
+
currentPath?: string;
|
|
116
|
+
turnCount?: number;
|
|
117
|
+
tokens?: number;
|
|
118
|
+
toolCount?: number;
|
|
119
|
+
nestedRoute?: NestedRouteInfo;
|
|
120
|
+
nestedChildren?: NestedRunSummary[];
|
|
121
|
+
interrupt?: () => boolean;
|
|
122
|
+
}
|
|
123
|
+
>;
|
|
124
|
+
lastForegroundControlId: string | null;
|
|
125
|
+
pendingForegroundControlNotices?: Map<string, ReturnType<typeof setTimeout>>;
|
|
126
|
+
lastUiContext: ExtensionContext | null;
|
|
127
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { SessionStats } from "@bastani/atomic";
|
|
6
6
|
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
7
7
|
import type { Message } from "@earendil-works/pi-ai/compat";
|
|
8
|
-
import type { NestedRunAddress, NestedRunSummary, NestedStepSummary } from "./types-
|
|
8
|
+
import type { NestedRunAddress, NestedRunSummary, NestedStepSummary } from "./types-nested.ts";
|
|
9
9
|
|
|
10
10
|
export interface MaxOutputConfig {
|
|
11
11
|
bytes?: number;
|
|
@@ -46,7 +46,7 @@ export interface TokenUsage {
|
|
|
46
46
|
|
|
47
47
|
export type ActivityState = "active_long_running" | "needs_attention";
|
|
48
48
|
export type ControlEventType = "active_long_running" | "needs_attention";
|
|
49
|
-
export type ControlNotificationChannel = "event" | "
|
|
49
|
+
export type ControlNotificationChannel = "event" | "intercom";
|
|
50
50
|
|
|
51
51
|
export interface ControlConfig {
|
|
52
52
|
enabled?: boolean;
|
|
@@ -122,7 +122,6 @@ export type PublicNestedRunSummary = Pick<
|
|
|
122
122
|
| "parentAgent"
|
|
123
123
|
| "depth"
|
|
124
124
|
| "path"
|
|
125
|
-
| "asyncDir"
|
|
126
125
|
| "sessionId"
|
|
127
126
|
| "sessionFile"
|
|
128
127
|
| "intercomTarget"
|
|
@@ -169,10 +168,7 @@ export interface SubagentResultIntercomPayload {
|
|
|
169
168
|
mode: SubagentRunMode;
|
|
170
169
|
status: SubagentResultStatus;
|
|
171
170
|
summary: string;
|
|
172
|
-
source: "foreground" | "async";
|
|
173
171
|
children: SubagentResultIntercomChild[];
|
|
174
|
-
asyncId?: string;
|
|
175
|
-
asyncDir?: string;
|
|
176
172
|
agent?: string;
|
|
177
173
|
index?: number;
|
|
178
174
|
artifactPath?: string;
|
|
@@ -278,8 +274,6 @@ export interface Details {
|
|
|
278
274
|
context?: "fresh" | "fork";
|
|
279
275
|
results: SingleResult[];
|
|
280
276
|
controlEvents?: ControlEvent[];
|
|
281
|
-
asyncId?: string;
|
|
282
|
-
asyncDir?: string;
|
|
283
277
|
progress?: AgentProgress[];
|
|
284
278
|
totalSteps?: number;
|
|
285
279
|
progressSummary?: ProgressSummary;
|
|
@@ -74,18 +74,13 @@ export function resolveTempScopeId(options?: {
|
|
|
74
74
|
export const MAX_PARALLEL_TASKS = 50;
|
|
75
75
|
export const MAX_CONCURRENCY = 4;
|
|
76
76
|
export const TEMP_ROOT_DIR = path.join(os.tmpdir(), `${APP_NAME}-subagents-${resolveTempScopeId()}`);
|
|
77
|
-
export const RESULTS_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-results");
|
|
78
|
-
export const ASYNC_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-runs");
|
|
79
77
|
export const TEMP_ARTIFACTS_DIR = path.join(TEMP_ROOT_DIR, "artifacts");
|
|
80
|
-
export const WIDGET_KEY = "subagent-async";
|
|
81
78
|
export const SLASH_RESULT_TYPE = "subagent-slash-result";
|
|
82
79
|
export const SLASH_SUBAGENT_REQUEST_EVENT = "subagent:slash:request";
|
|
83
80
|
export const SLASH_SUBAGENT_STARTED_EVENT = "subagent:slash:started";
|
|
84
81
|
export const SLASH_SUBAGENT_RESPONSE_EVENT = "subagent:slash:response";
|
|
85
82
|
export const SLASH_SUBAGENT_UPDATE_EVENT = "subagent:slash:update";
|
|
86
83
|
export const SLASH_SUBAGENT_CANCEL_EVENT = "subagent:slash:cancel";
|
|
87
|
-
export const POLL_INTERVAL_MS = 250;
|
|
88
|
-
export const MAX_WIDGET_JOBS = 4;
|
|
89
84
|
export const MAX_SUBAGENT_NESTING_DEPTH = 5;
|
|
90
85
|
export const DEFAULT_SUBAGENT_MAX_DEPTH = MAX_SUBAGENT_NESTING_DEPTH;
|
|
91
86
|
export const SUBAGENT_ACTIONS = [
|
|
@@ -121,10 +116,6 @@ export function resolveTopLevelParallelConcurrency(override: unknown, configValu
|
|
|
121
116
|
return normalizeTopLevelParallelValue(override) ?? normalizeTopLevelParallelValue(configValue) ?? MAX_CONCURRENCY;
|
|
122
117
|
}
|
|
123
118
|
|
|
124
|
-
export function getAsyncConfigPath(suffix: string): string {
|
|
125
|
-
return path.join(TEMP_ROOT_DIR, `async-cfg-${suffix}.json`);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
119
|
export function wrapForkTask(task: string, preamble?: string | false): string {
|
|
129
120
|
if (preamble === false) return task;
|
|
130
121
|
const effectivePreamble = preamble ?? DEFAULT_FORK_PREAMBLE;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* focused sibling modules that hold the concrete type groups and helpers.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export * from "./types-async.ts";
|
|
9
8
|
export * from "./types-config.ts";
|
|
10
9
|
export * from "./types-depth.ts";
|
|
10
|
+
export * from "./types-nested.ts";
|
|
11
11
|
export * from "./types-output.ts";
|
|
12
12
|
export * from "./types-results.ts";
|
|
13
13
|
export * from "./types-runtime.ts";
|
|
@@ -2,20 +2,11 @@
|
|
|
2
2
|
* General utility functions for the subagent extension
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
5
|
import * as path from "node:path";
|
|
7
6
|
import { getAgentDir as getAtomicAgentDir } from "@bastani/atomic";
|
|
8
7
|
import type { Message } from "@earendil-works/pi-ai/compat";
|
|
9
8
|
import { formatToolCall } from "./formatters.ts";
|
|
10
|
-
import type {
|
|
11
|
-
AgentProgress,
|
|
12
|
-
AsyncStatus,
|
|
13
|
-
Details,
|
|
14
|
-
DisplayItem,
|
|
15
|
-
ErrorInfo,
|
|
16
|
-
SingleResult,
|
|
17
|
-
ToolCallSummary,
|
|
18
|
-
} from "./types.ts";
|
|
9
|
+
import type { AgentProgress, Details, DisplayItem, ErrorInfo, SingleResult, ToolCallSummary } from "./types.ts";
|
|
19
10
|
|
|
20
11
|
// ============================================================================
|
|
21
12
|
// File System Utilities
|
|
@@ -25,110 +16,11 @@ export function getAgentDir(): string {
|
|
|
25
16
|
return getAtomicAgentDir();
|
|
26
17
|
}
|
|
27
18
|
|
|
28
|
-
const statusCache = new Map<string, { mtime: number; status: AsyncStatus }>();
|
|
29
|
-
|
|
30
|
-
function getErrorMessage(error: unknown): string {
|
|
31
|
-
return error instanceof Error ? error.message : String(error);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
19
|
export function resolveChildCwd(baseCwd: string, childCwd: string | undefined): string {
|
|
35
20
|
if (!childCwd) return baseCwd;
|
|
36
21
|
return path.isAbsolute(childCwd) ? childCwd : path.resolve(baseCwd, childCwd);
|
|
37
22
|
}
|
|
38
23
|
|
|
39
|
-
function isNotFoundError(error: unknown): boolean {
|
|
40
|
-
return (
|
|
41
|
-
typeof error === "object" &&
|
|
42
|
-
error !== null &&
|
|
43
|
-
"code" in error &&
|
|
44
|
-
(error as NodeJS.ErrnoException).code === "ENOENT"
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Read async job status from disk (with mtime-based caching)
|
|
50
|
-
*/
|
|
51
|
-
export function readStatus(asyncDir: string): AsyncStatus | null {
|
|
52
|
-
const statusPath = path.join(asyncDir, "status.json");
|
|
53
|
-
|
|
54
|
-
let stat: fs.Stats;
|
|
55
|
-
try {
|
|
56
|
-
stat = fs.statSync(statusPath);
|
|
57
|
-
} catch (error) {
|
|
58
|
-
if (isNotFoundError(error)) return null;
|
|
59
|
-
throw new Error(`Failed to inspect async status file '${statusPath}': ${getErrorMessage(error)}`, {
|
|
60
|
-
cause: error instanceof Error ? error : undefined,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const cached = statusCache.get(statusPath);
|
|
65
|
-
if (cached && cached.mtime === stat.mtimeMs) {
|
|
66
|
-
return cached.status;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
let content: string;
|
|
70
|
-
try {
|
|
71
|
-
content = fs.readFileSync(statusPath, "utf-8");
|
|
72
|
-
} catch (error) {
|
|
73
|
-
if (isNotFoundError(error)) return null;
|
|
74
|
-
throw new Error(`Failed to read async status file '${statusPath}': ${getErrorMessage(error)}`, {
|
|
75
|
-
cause: error instanceof Error ? error : undefined,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
let status: AsyncStatus;
|
|
80
|
-
try {
|
|
81
|
-
status = JSON.parse(content) as AsyncStatus;
|
|
82
|
-
} catch (error) {
|
|
83
|
-
throw new Error(`Failed to parse async status file '${statusPath}': ${getErrorMessage(error)}`, {
|
|
84
|
-
cause: error instanceof Error ? error : undefined,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
statusCache.set(statusPath, { mtime: stat.mtimeMs, status });
|
|
89
|
-
if (statusCache.size > 50) {
|
|
90
|
-
const firstKey = statusCache.keys().next().value;
|
|
91
|
-
if (firstKey) statusCache.delete(firstKey);
|
|
92
|
-
}
|
|
93
|
-
return status;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Get human-readable last activity time for a file
|
|
98
|
-
*/
|
|
99
|
-
export function getLastActivity(outputFile: string | undefined): string {
|
|
100
|
-
if (!outputFile) return "";
|
|
101
|
-
try {
|
|
102
|
-
const stat = fs.statSync(outputFile);
|
|
103
|
-
const ago = Date.now() - stat.mtimeMs;
|
|
104
|
-
if (ago < 1000) return "active now";
|
|
105
|
-
if (ago < 60000) return `active ${Math.floor(ago / 1000)}s ago`;
|
|
106
|
-
return `active ${Math.floor(ago / 60000)}m ago`;
|
|
107
|
-
} catch {
|
|
108
|
-
// Last-activity text is best effort; missing files should simply omit the hint.
|
|
109
|
-
return "";
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Find the latest session file in a directory
|
|
115
|
-
*/
|
|
116
|
-
export function findLatestSessionFile(sessionDir: string): string | null {
|
|
117
|
-
if (!fs.existsSync(sessionDir)) return null;
|
|
118
|
-
const files = fs
|
|
119
|
-
.readdirSync(sessionDir)
|
|
120
|
-
.filter((f) => f.endsWith(".jsonl"))
|
|
121
|
-
.map((f) => {
|
|
122
|
-
const filePath = path.join(sessionDir, f);
|
|
123
|
-
return {
|
|
124
|
-
path: filePath,
|
|
125
|
-
mtime: fs.statSync(filePath).mtimeMs,
|
|
126
|
-
};
|
|
127
|
-
})
|
|
128
|
-
.sort((a, b) => b.mtime - a.mtime);
|
|
129
|
-
return files.length > 0 ? files[0].path : null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
24
|
// ============================================================================
|
|
133
25
|
// Message Parsing Utilities
|
|
134
26
|
// ============================================================================
|
|
@@ -80,17 +80,10 @@ const parseAgentToken = (token: string): { name: string; config: InlineConfig }
|
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
const extractExecutionFlags = (rawArgs: string): { args: string;
|
|
83
|
+
const extractExecutionFlags = (rawArgs: string): { args: string; fork: boolean } => {
|
|
84
84
|
let args = rawArgs.trim();
|
|
85
|
-
let bg = false;
|
|
86
85
|
let fork = false;
|
|
87
|
-
|
|
88
86
|
while (true) {
|
|
89
|
-
if (args.endsWith(" --bg") || args === "--bg") {
|
|
90
|
-
bg = true;
|
|
91
|
-
args = args === "--bg" ? "" : args.slice(0, -5).trim();
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
87
|
if (args.endsWith(" --fork") || args === "--fork") {
|
|
95
88
|
fork = true;
|
|
96
89
|
args = args === "--fork" ? "" : args.slice(0, -7).trim();
|
|
@@ -98,8 +91,7 @@ const extractExecutionFlags = (rawArgs: string): { args: string; bg: boolean; fo
|
|
|
98
91
|
}
|
|
99
92
|
break;
|
|
100
93
|
}
|
|
101
|
-
|
|
102
|
-
return { args, bg, fork };
|
|
94
|
+
return { args, fork };
|
|
103
95
|
};
|
|
104
96
|
|
|
105
97
|
const makeAgentCompletions = (state: SubagentState, multiAgent: boolean) => (prefix: string) => {
|
|
@@ -413,14 +405,14 @@ const parseAgentArgs = (
|
|
|
413
405
|
};
|
|
414
406
|
export function registerSlashCommands(pi: ExtensionAPI, state: SubagentState): void {
|
|
415
407
|
pi.registerCommand("run", {
|
|
416
|
-
description: "Run a subagent directly: /run agent[output=file] [task] [--
|
|
408
|
+
description: "Run a subagent directly: /run agent[output=file] [task] [--fork]",
|
|
417
409
|
getArgumentCompletions: makeAgentCompletions(state, false),
|
|
418
410
|
handler: async (args, ctx) => {
|
|
419
|
-
const { args: cleanedArgs,
|
|
411
|
+
const { args: cleanedArgs, fork } = extractExecutionFlags(args);
|
|
420
412
|
const input = cleanedArgs.trim();
|
|
421
413
|
const firstSpace = input.indexOf(" ");
|
|
422
414
|
if (!input) {
|
|
423
|
-
ctx.ui.notify("Usage: /run <agent> [task] [--
|
|
415
|
+
ctx.ui.notify("Usage: /run <agent> [task] [--fork]", "error");
|
|
424
416
|
return;
|
|
425
417
|
}
|
|
426
418
|
const { name: agentName, config: inline } = parseAgentToken(
|
|
@@ -442,16 +434,15 @@ export function registerSlashCommands(pi: ExtensionAPI, state: SubagentState): v
|
|
|
442
434
|
if (inline.outputMode !== undefined) params.outputMode = inline.outputMode;
|
|
443
435
|
if (inline.skill !== undefined) params.skill = inline.skill;
|
|
444
436
|
if (inline.model) params.model = inline.model;
|
|
445
|
-
if (bg) params.async = true;
|
|
446
437
|
if (fork) params.context = "fork";
|
|
447
438
|
await runSlashSubagent(pi, ctx, params);
|
|
448
439
|
},
|
|
449
440
|
});
|
|
450
441
|
pi.registerCommand("parallel", {
|
|
451
|
-
description: 'Run agents in parallel: /parallel scout "task1" -> reviewer "task2" [--
|
|
442
|
+
description: 'Run agents in parallel: /parallel scout "task1" -> reviewer "task2" [--fork]',
|
|
452
443
|
getArgumentCompletions: makeAgentCompletions(state, true),
|
|
453
444
|
handler: async (args, ctx) => {
|
|
454
|
-
const { args: cleanedArgs,
|
|
445
|
+
const { args: cleanedArgs, fork } = extractExecutionFlags(args);
|
|
455
446
|
const parsed = parseAgentArgs(state, cleanedArgs, "parallel", ctx);
|
|
456
447
|
if (!parsed) return;
|
|
457
448
|
const tasks = parsed.steps.map(({ name, config, task: stepTask }) => ({
|
|
@@ -465,7 +456,6 @@ export function registerSlashCommands(pi: ExtensionAPI, state: SubagentState): v
|
|
|
465
456
|
...(config.progress !== undefined ? { progress: config.progress } : {}),
|
|
466
457
|
}));
|
|
467
458
|
const params: SubagentParamsLike = { tasks, agentScope: "both" };
|
|
468
|
-
if (bg) params.async = true;
|
|
469
459
|
if (fork) params.context = "fork";
|
|
470
460
|
await runSlashSubagent(pi, ctx, params);
|
|
471
461
|
},
|