@bastani/atomic 0.9.12 → 0.9.13-alpha.1
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 +20 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +5 -12
- package/dist/builtin/intercom/broker/client.ts +11 -2
- package/dist/builtin/intercom/contact-supervisor-tool.ts +13 -3
- package/dist/builtin/intercom/index-heavy.ts +13 -3
- package/dist/builtin/intercom/index.ts +43 -19
- package/dist/builtin/intercom/intercom-utils.ts +15 -29
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/source-ownership.ts +9 -12
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/README.md +3 -1
- package/dist/builtin/mcp/index.ts +10 -16
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/mcp/startup-warmup.ts +20 -8
- package/dist/builtin/subagents/CHANGELOG.md +30 -0
- package/dist/builtin/subagents/README.md +22 -30
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/doctor.ts +1 -1
- package/dist/builtin/subagents/src/extension/fanout-child.ts +76 -56
- package/dist/builtin/subagents/src/extension/index.ts +23 -32
- package/dist/builtin/subagents/src/extension/startup-maintenance.ts +25 -44
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +7 -7
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +166 -434
- package/dist/builtin/subagents/src/runs/background/notify.ts +29 -8
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +4 -4
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +1 -281
- package/dist/builtin/subagents/src/runs/foreground/execution-structured-retries.ts +11 -75
- package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +457 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +119 -246
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +1 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +18 -9
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +1 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +4 -4
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +1 -646
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +2 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +5 -5
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +7 -8
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +14 -5
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +158 -93
- package/dist/builtin/subagents/src/runs/inprocess/background-single.ts +179 -0
- package/dist/builtin/subagents/src/runs/inprocess/background.ts +89 -0
- package/dist/builtin/subagents/src/runs/inprocess/child-policy.ts +27 -0
- package/dist/builtin/subagents/src/runs/inprocess/control-registry.ts +55 -0
- package/dist/builtin/subagents/src/runs/inprocess/control-status.ts +106 -0
- package/dist/builtin/subagents/src/runs/inprocess/index.ts +50 -0
- package/dist/builtin/subagents/src/runs/inprocess/nested-routing.ts +218 -0
- package/dist/builtin/subagents/src/runs/{shared/subagent-prompt-runtime.ts → inprocess/prompt-behavior.ts} +37 -75
- package/dist/builtin/subagents/src/runs/inprocess/runner.ts +1138 -0
- package/dist/builtin/subagents/src/runs/{shared/nested-events.ts → inprocess/runtime-support/nested-api.ts} +13 -7
- package/dist/builtin/subagents/src/runs/{shared/nested-events-control.ts → inprocess/runtime-support/nested-control.ts} +18 -17
- package/dist/builtin/subagents/src/runs/{shared/nested-events-core.ts → inprocess/runtime-support/nested-core.ts} +14 -61
- package/dist/builtin/subagents/src/runs/{shared/nested-events-projection.ts → inprocess/runtime-support/nested-projection.ts} +4 -10
- package/dist/builtin/subagents/src/runs/{shared/nested-events-registry.ts → inprocess/runtime-support/nested-registry.ts} +19 -4
- package/dist/builtin/subagents/src/runs/{shared/nested-render.ts → inprocess/runtime-support/nested-rendering.ts} +3 -3
- package/dist/builtin/subagents/src/runs/{shared/nested-events-sanitize.ts → inprocess/runtime-support/nested-sanitize.ts} +3 -3
- package/dist/builtin/subagents/src/runs/inprocess.ts +1 -0
- package/dist/builtin/subagents/src/runs/shared/dynamic-fanout.ts +10 -4
- package/dist/builtin/subagents/src/runs/shared/model-candidate-filter.ts +0 -1
- package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +15 -492
- package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +13 -11
- package/dist/builtin/subagents/src/runs/shared/run-history.ts +3 -5
- package/dist/builtin/subagents/src/runs/shared/single-output.ts +4 -4
- package/dist/builtin/subagents/src/runs/shared/workflow-graph.ts +5 -5
- package/dist/builtin/subagents/src/shared/types-async.ts +0 -1
- package/dist/builtin/subagents/src/shared/types-config.ts +18 -0
- package/dist/builtin/subagents/src/shared/types-results.ts +9 -2
- package/dist/builtin/subagents/src/slash/prompt-template-bridge.ts +2 -3
- package/dist/builtin/subagents/src/slash/slash-live-state.ts +2 -2
- package/dist/builtin/subagents/src/tui/render-chain-graph.ts +10 -4
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +12 -11
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +49 -12
- package/dist/builtin/subagents/src/tui/render-result.ts +46 -17
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -1
- package/dist/builtin/subagents/src/tui/render-status-progress.ts +8 -5
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +0 -8
- package/dist/builtin/subagents/src/tui/render-widget.ts +0 -24
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +25 -0
- package/dist/builtin/workflows/README.md +13 -3
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/durable/backend.ts +7 -0
- package/dist/builtin/workflows/src/durable/dbos-metadata.ts +11 -1
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +1 -0
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +4 -28
- package/dist/builtin/workflows/src/durable/types.ts +5 -0
- package/dist/builtin/workflows/src/engine/run.ts +17 -1
- package/dist/builtin/workflows/src/extension/atomic-stage-session.ts +12 -39
- package/dist/builtin/workflows/src/extension/config-file-loader.ts +10 -1
- package/dist/builtin/workflows/src/extension/config-loader.ts +1 -1
- package/dist/builtin/workflows/src/extension/dispatcher.ts +4 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1151 -737
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +303 -38
- package/dist/builtin/workflows/src/extension/render-result.ts +4 -0
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +6 -3
- package/dist/builtin/workflows/src/extension/runtime.ts +7 -1
- package/dist/builtin/workflows/src/extension/wiring.ts +53 -11
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +12 -3
- package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +5 -2
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +9 -7
- package/dist/builtin/workflows/src/extension/workflow-status-summary.ts +11 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +18 -1
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +10 -8
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +9 -4
- package/dist/builtin/workflows/src/runs/background/quit.ts +28 -4
- package/dist/builtin/workflows/src/runs/background/resume-acknowledgements.ts +2 -1
- package/dist/builtin/workflows/src/runs/background/status.ts +55 -8
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +4 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +3 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +688 -38
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +3 -1
- package/dist/builtin/workflows/src/runs/shared/model-fallback-failures.ts +19 -514
- package/dist/builtin/workflows/src/runs/shared/retry.ts +44 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +5 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +6 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +5 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +5 -0
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +5 -0
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +3 -0
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +4 -0
- package/dist/builtin/workflows/src/shared/run-indicator-status.ts +75 -0
- package/dist/builtin/workflows/src/shared/store-public-types.ts +43 -7
- package/dist/builtin/workflows/src/shared/store-run-methods.ts +42 -8
- package/dist/builtin/workflows/src/shared/store-stage-methods.ts +31 -8
- package/dist/builtin/workflows/src/shared/store-types.ts +34 -0
- package/dist/builtin/workflows/src/shared/timing.ts +10 -0
- package/dist/builtin/workflows/src/tui/chat-surface-message.ts +22 -2
- package/dist/builtin/workflows/src/tui/session-list.ts +1 -1
- package/dist/builtin/workflows/src/tui/session-overlays.ts +14 -10
- package/dist/builtin/workflows/src/tui/session-picker.ts +20 -4
- package/dist/builtin/workflows/src/tui/status-list.ts +31 -47
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +9 -1
- package/dist/builtin/workflows/src/tui/widget.ts +16 -46
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +54 -11
- 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 +49 -14
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +13 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +12 -1
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +4 -0
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +21 -4
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +232 -106
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +2 -1
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +12 -0
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +1 -1
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +3 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +12 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +25 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +2 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +4 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +3 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +30 -0
- package/dist/core/model-fallback-failures.d.ts.map +1 -0
- package/dist/core/model-fallback-failures.js +610 -0
- package/dist/core/model-fallback-failures.js.map +1 -0
- package/dist/core/retry-policy.d.ts +30 -0
- package/dist/core/retry-policy.d.ts.map +1 -0
- package/dist/core/retry-policy.js +25 -0
- package/dist/core/retry-policy.js.map +1 -0
- package/dist/core/sdk-types.d.ts +8 -2
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +6 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +2 -0
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +7 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/docs/intercom.md +5 -10
- package/docs/settings.md +7 -1
- package/docs/subagents.md +19 -19
- package/docs/workflows.md +21 -5
- package/examples/extensions/gondolin/package-lock.json +3 -3
- package/npm-shrinkwrap.json +29 -29
- package/package.json +2 -2
- package/dist/builtin/subagents/src/runs/background/async-event-journal.ts +0 -112
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +0 -543
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +0 -140
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +0 -279
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +0 -99
- package/dist/builtin/subagents/src/runs/background/async-execution.ts +0 -17
- package/dist/builtin/subagents/src/runs/background/async-resume.ts +0 -402
- package/dist/builtin/subagents/src/runs/background/async-status.ts +0 -411
- package/dist/builtin/subagents/src/runs/background/completion-claims.ts +0 -196
- package/dist/builtin/subagents/src/runs/background/completion-dedupe.ts +0 -102
- package/dist/builtin/subagents/src/runs/background/parallel-groups.ts +0 -59
- package/dist/builtin/subagents/src/runs/background/result-delivery-processor.ts +0 -300
- package/dist/builtin/subagents/src/runs/background/result-file-claims.ts +0 -166
- package/dist/builtin/subagents/src/runs/background/result-quarantine.ts +0 -77
- package/dist/builtin/subagents/src/runs/background/result-retry-scheduler.ts +0 -48
- package/dist/builtin/subagents/src/runs/background/result-status.ts +0 -87
- package/dist/builtin/subagents/src/runs/background/result-watcher-data.ts +0 -72
- package/dist/builtin/subagents/src/runs/background/result-watcher.ts +0 -320
- package/dist/builtin/subagents/src/runs/background/run-id-resolver.ts +0 -105
- package/dist/builtin/subagents/src/runs/background/run-status.ts +0 -358
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +0 -457
- package/dist/builtin/subagents/src/runs/background/subagent-runner-dynamic.ts +0 -376
- package/dist/builtin/subagents/src/runs/background/subagent-runner-finalize.ts +0 -150
- package/dist/builtin/subagents/src/runs/background/subagent-runner-output.ts +0 -109
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel-helpers.ts +0 -128
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel.ts +0 -309
- package/dist/builtin/subagents/src/runs/background/subagent-runner-sequential.ts +0 -173
- package/dist/builtin/subagents/src/runs/background/subagent-runner-state.ts +0 -578
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +0 -330
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +0 -330
- package/dist/builtin/subagents/src/runs/background/subagent-runner-types.ts +0 -210
- package/dist/builtin/subagents/src/runs/background/subagent-runner-utils.ts +0 -69
- package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +0 -90
- package/dist/builtin/subagents/src/runs/background/top-level-async.ts +0 -12
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-control.ts +0 -140
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +0 -108
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-types.ts +0 -17
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +0 -558
- package/dist/builtin/subagents/src/runs/shared/attempt-watchdog.ts +0 -126
- package/dist/builtin/subagents/src/runs/shared/final-drain.ts +0 -39
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +0 -339
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +0 -165
- package/dist/builtin/subagents/src/runs/shared/spawn-env.ts +0 -21
- package/dist/builtin/subagents/src/shared/post-exit-stdio-guard.ts +0 -86
- /package/dist/builtin/subagents/src/runs/{shared/nested-path.ts → inprocess/runtime-support/nested-paths.ts} +0 -0
|
@@ -1,31 +1,19 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
1
|
import { APP_NAME } from "@bastani/atomic";
|
|
3
2
|
import { normalizeSkillInput } from "../../agents/skills.ts";
|
|
4
3
|
import { resolveSubagentIntercomTarget } from "../../intercom/intercom-bridge.ts";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "../../intercom/supervisor-authorization.ts";
|
|
9
|
-
import { collectKnownModelProviders, type ModelInfo, toModelInfo } from "../../shared/model-info.ts";
|
|
10
|
-
import {
|
|
11
|
-
type ChainStep,
|
|
12
|
-
isDynamicParallelStep,
|
|
13
|
-
isParallelStep,
|
|
14
|
-
resolveSingleProgress,
|
|
15
|
-
type SequentialStep,
|
|
16
|
-
} from "../../shared/settings.ts";
|
|
4
|
+
import { collectKnownModelProviders, toModelInfo } from "../../shared/model-info.ts";
|
|
5
|
+
import type { ChainStep } from "../../shared/settings.ts";
|
|
6
|
+
import type { SingleResult, SubagentToolResult } from "../../shared/types.ts";
|
|
17
7
|
import {
|
|
18
8
|
resolveChildMaxSubagentDepth,
|
|
19
9
|
resolveSubagentDepthPolicy,
|
|
20
|
-
resolveTopLevelParallelConcurrency,
|
|
21
10
|
resolveTopLevelParallelMaxTasks,
|
|
22
11
|
workflowSessionMetadataFromContext,
|
|
23
12
|
wrapForkTask,
|
|
24
13
|
} from "../../shared/types.ts";
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import { collectChainSessionFiles, wrapChainTasksForFork } from "./subagent-executor-input.ts";
|
|
14
|
+
import { formatAsyncStartedMessage } from "../inprocess/background.ts";
|
|
15
|
+
import { runChainPath } from "./subagent-executor-chain.ts";
|
|
16
|
+
import { runParallelPath } from "./subagent-executor-parallel.ts";
|
|
29
17
|
import type { ExecutionContextData, ResolvedExecutorDeps } from "./subagent-executor-types.ts";
|
|
30
18
|
import {
|
|
31
19
|
buildChainWorktreeTaskCwdError,
|
|
@@ -33,285 +21,170 @@ import {
|
|
|
33
21
|
buildParallelWorktreeTaskCwdError,
|
|
34
22
|
} from "./subagent-executor-worktree.ts";
|
|
35
23
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
function continuedResult(data: ExecutionContextData, mode: "single" | "parallel" | "chain"): SingleResult {
|
|
25
|
+
const path = `${data.runId}/orchestration_1`;
|
|
26
|
+
return {
|
|
27
|
+
agent: mode,
|
|
28
|
+
task: data.params.task ?? `${mode} subagent run`,
|
|
29
|
+
status: "continued",
|
|
30
|
+
path,
|
|
31
|
+
envelope: "Child continued in background.",
|
|
32
|
+
detached: true,
|
|
33
|
+
detachedReason: "async-requested",
|
|
34
|
+
messages: [],
|
|
35
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 },
|
|
36
|
+
progress: {
|
|
37
|
+
index: 0,
|
|
38
|
+
agent: mode,
|
|
39
|
+
status: "running",
|
|
40
|
+
task: data.params.task ?? `${mode} subagent run`,
|
|
41
|
+
recentTools: [],
|
|
42
|
+
recentOutput: [],
|
|
43
|
+
toolCount: 0,
|
|
44
|
+
turnCount: 0,
|
|
45
|
+
tokens: 0,
|
|
46
|
+
durationMs: 0,
|
|
47
|
+
lastActivityAt: Date.now(),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
41
50
|
}
|
|
42
51
|
|
|
43
|
-
|
|
44
|
-
chain
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
): Promise<{
|
|
49
|
-
authorizations?: Array<SupervisorAuthorization | undefined>;
|
|
50
|
-
dynamic?: Record<number, SupervisorAuthorization[]>;
|
|
51
|
-
}> {
|
|
52
|
-
if (!childTarget) return {};
|
|
53
|
-
const authorizations: Array<SupervisorAuthorization | undefined> = [];
|
|
54
|
-
const dynamic: Record<number, SupervisorAuthorization[]> = {};
|
|
55
|
-
for (let stepIndex = 0; stepIndex < chain.length; stepIndex++) {
|
|
56
|
-
const step = chain[stepIndex]!;
|
|
57
|
-
if (isDynamicParallelStep(step)) {
|
|
58
|
-
authorizations.push(undefined);
|
|
52
|
+
function modeFor(data: ExecutionContextData): "single" | "parallel" | "chain" {
|
|
53
|
+
if ((data.params.chain?.length ?? 0) > 0) return "chain";
|
|
54
|
+
if ((data.params.tasks?.length ?? 0) > 0) return "parallel";
|
|
55
|
+
return "single";
|
|
56
|
+
}
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
authorizations,
|
|
73
|
-
...(Object.keys(dynamic).length > 0 ? { dynamic } : {}),
|
|
74
|
-
};
|
|
58
|
+
function runForegroundInBackground(
|
|
59
|
+
data: ExecutionContextData,
|
|
60
|
+
deps: ResolvedExecutorDeps,
|
|
61
|
+
mode: "parallel" | "chain",
|
|
62
|
+
): void {
|
|
63
|
+
const backgroundData: ExecutionContextData = { ...data, effectiveAsync: false };
|
|
64
|
+
const work = mode === "chain" ? runChainPath(backgroundData, deps) : runParallelPath(backgroundData, deps);
|
|
65
|
+
void work.catch((error) => {
|
|
66
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
67
|
+
console.error(`[${APP_NAME}-subagents] in-process async ${mode} failed: ${message}`);
|
|
68
|
+
});
|
|
75
69
|
}
|
|
76
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Async is a don't-wait request over the same in-process foreground executor.
|
|
73
|
+
*
|
|
74
|
+
* Single runs retain the focused background-single helper because it owns the
|
|
75
|
+
* child admission and terminal artifact delivery. Chain and parallel runs use
|
|
76
|
+
* the existing foreground executors un-awaited; their child sessions are
|
|
77
|
+
* admitted by runSync as the executor advances, so chain substitution,
|
|
78
|
+
* dynamic fanout, worktrees, structured output, and fail-fast remain one code
|
|
79
|
+
* path rather than a second serialized runner.
|
|
80
|
+
*/
|
|
77
81
|
export async function runAsyncPath(
|
|
78
82
|
data: ExecutionContextData,
|
|
79
83
|
deps: ResolvedExecutorDeps,
|
|
80
|
-
): Promise<
|
|
81
|
-
|
|
82
|
-
params,
|
|
83
|
-
effectiveCwd,
|
|
84
|
-
agents,
|
|
85
|
-
ctx,
|
|
86
|
-
shareEnabled,
|
|
87
|
-
sessionRoot,
|
|
88
|
-
sessionFileForIndex,
|
|
89
|
-
artifactConfig,
|
|
90
|
-
artifactsDir,
|
|
91
|
-
effectiveAsync,
|
|
92
|
-
controlConfig,
|
|
93
|
-
intercomBridge,
|
|
94
|
-
nestedRoute,
|
|
95
|
-
} = data;
|
|
96
|
-
const hasChain = (params.chain?.length ?? 0) > 0;
|
|
97
|
-
const hasTasks = (params.tasks?.length ?? 0) > 0;
|
|
98
|
-
const hasSingle = !hasChain && !hasTasks && Boolean(params.agent);
|
|
99
|
-
if (!effectiveAsync) return null;
|
|
84
|
+
): Promise<SubagentToolResult | null> {
|
|
85
|
+
if (!data.effectiveAsync) return null;
|
|
100
86
|
|
|
101
|
-
|
|
87
|
+
const mode = modeFor(data);
|
|
88
|
+
const { params, effectiveCwd } = data;
|
|
89
|
+
if (mode === "chain" && params.chain) {
|
|
102
90
|
const chainWorktreeTaskCwdError = buildChainWorktreeTaskCwdError(params.chain as ChainStep[], effectiveCwd);
|
|
103
91
|
if (chainWorktreeTaskCwdError) {
|
|
104
92
|
return {
|
|
105
93
|
content: [{ type: "text", text: chainWorktreeTaskCwdError }],
|
|
106
94
|
isError: true,
|
|
107
|
-
details: { mode: "chain"
|
|
95
|
+
details: { mode: "chain", results: [] },
|
|
108
96
|
};
|
|
109
97
|
}
|
|
110
98
|
}
|
|
111
|
-
|
|
112
|
-
if (hasTasks && params.tasks) {
|
|
99
|
+
if (mode === "parallel" && params.tasks) {
|
|
113
100
|
const maxParallelTasks = resolveTopLevelParallelMaxTasks(deps.config.parallel?.maxTasks);
|
|
114
|
-
if (params.tasks.length > maxParallelTasks) {
|
|
115
|
-
return buildParallelModeError(`Max ${maxParallelTasks} tasks`);
|
|
116
|
-
}
|
|
101
|
+
if (params.tasks.length > maxParallelTasks) return buildParallelModeError(`Max ${maxParallelTasks} tasks`);
|
|
117
102
|
if (params.worktree) {
|
|
118
103
|
const worktreeTaskCwdError = buildParallelWorktreeTaskCwdError(params.tasks, effectiveCwd);
|
|
119
104
|
if (worktreeTaskCwdError) return buildParallelModeError(worktreeTaskCwdError);
|
|
120
105
|
}
|
|
121
106
|
}
|
|
122
|
-
|
|
123
107
|
if (!deps.runtime.isAsyncAvailable()) {
|
|
124
108
|
return {
|
|
125
109
|
content: [
|
|
126
110
|
{
|
|
127
111
|
type: "text",
|
|
128
|
-
text: `Async mode requires
|
|
112
|
+
text: `Async mode requires the in-process runner but it could not be initialized. Ensure the ${APP_NAME}-subagents package is installed.`,
|
|
129
113
|
},
|
|
130
114
|
],
|
|
131
115
|
isError: true,
|
|
132
|
-
details: { mode
|
|
116
|
+
details: { mode, results: [] },
|
|
133
117
|
};
|
|
134
118
|
}
|
|
135
|
-
const id = randomUUID();
|
|
136
|
-
const asyncCtx = {
|
|
137
|
-
pi: deps.pi,
|
|
138
|
-
cwd: ctx.cwd,
|
|
139
|
-
currentSessionId: deps.state.currentSessionId!,
|
|
140
|
-
currentModelProvider: ctx.model?.provider,
|
|
141
|
-
currentModel: currentModelFullId(ctx.model),
|
|
142
|
-
workflowSessionMetadata: workflowSessionMetadataFromContext(ctx),
|
|
143
|
-
intercomGroup: inheritedIntercomGroup(ctx),
|
|
144
|
-
};
|
|
145
|
-
const availableModels: ModelInfo[] = ctx.modelRegistry.getAvailable().map(toModelInfo);
|
|
146
|
-
const knownModelProviders = collectKnownModelProviders(ctx.modelRegistry);
|
|
147
|
-
const depthPolicy = resolveSubagentDepthPolicy(ctx, deps.config.maxSubagentDepth);
|
|
148
|
-
const currentMaxSubagentDepth = depthPolicy.maxSubagentDepth;
|
|
149
|
-
const workflowStageSubagentGuard = depthPolicy.workflowStageSubagentGuard;
|
|
150
|
-
const currentProvider = ctx.model?.provider;
|
|
151
|
-
const controlIntercomTarget = intercomBridge.active ? intercomBridge.orchestratorTarget : undefined;
|
|
152
|
-
const childIntercomTarget = intercomBridge.active
|
|
153
|
-
? (agent: string, index: number) => resolveSubagentIntercomTarget(id, agent, index)
|
|
154
|
-
: undefined;
|
|
155
119
|
|
|
156
|
-
if (
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
resolveModelCandidate(task.model ?? agentConfigs[index]?.model, availableModels, currentProvider),
|
|
160
|
-
);
|
|
161
|
-
const skillOverrides = params.tasks.map((task) => normalizeSkillInput(task.skill));
|
|
162
|
-
const parallelTasks = params.tasks.map((task, index) => ({
|
|
163
|
-
agent: task.agent,
|
|
164
|
-
task: params.context === "fork" ? wrapForkTask(task.task) : task.task,
|
|
165
|
-
cwd: task.cwd,
|
|
166
|
-
group: task.group,
|
|
167
|
-
...(modelOverrides[index] ? { model: modelOverrides[index] } : {}),
|
|
168
|
-
...(skillOverrides[index] !== undefined ? { skill: skillOverrides[index] } : {}),
|
|
169
|
-
...(task.output === true
|
|
170
|
-
? agentConfigs[index]?.output
|
|
171
|
-
? { output: agentConfigs[index]!.output }
|
|
172
|
-
: {}
|
|
173
|
-
: task.output !== undefined
|
|
174
|
-
? { output: task.output }
|
|
175
|
-
: {}),
|
|
176
|
-
...(task.outputMode !== undefined ? { outputMode: task.outputMode } : {}),
|
|
177
|
-
...(task.reads !== undefined && task.reads !== true ? { reads: task.reads } : {}),
|
|
178
|
-
...(task.progress !== undefined ? { progress: task.progress } : {}),
|
|
179
|
-
}));
|
|
180
|
-
const supervisorAuthorizations = childIntercomTarget
|
|
181
|
-
? await Promise.all(
|
|
182
|
-
params.tasks.map((task, index) => authorizeChild(deps, childIntercomTarget(task.agent, index))),
|
|
183
|
-
)
|
|
184
|
-
: undefined;
|
|
185
|
-
return deps.runtime.executeAsyncChain(id, {
|
|
186
|
-
chain: [
|
|
187
|
-
{
|
|
188
|
-
parallel: parallelTasks,
|
|
189
|
-
group: params.group,
|
|
190
|
-
concurrency: resolveTopLevelParallelConcurrency(params.concurrency, deps.config.parallel?.concurrency),
|
|
191
|
-
worktree: params.worktree,
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
resultMode: "parallel",
|
|
195
|
-
group: params.group,
|
|
196
|
-
agents,
|
|
197
|
-
ctx: asyncCtx,
|
|
198
|
-
availableModels,
|
|
199
|
-
knownModelProviders,
|
|
200
|
-
cwd: effectiveCwd,
|
|
201
|
-
maxOutput: params.maxOutput,
|
|
202
|
-
artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
|
|
203
|
-
artifactConfig,
|
|
204
|
-
shareEnabled,
|
|
205
|
-
sessionRoot,
|
|
206
|
-
chainSkills: [],
|
|
207
|
-
sessionFilesByFlatIndex: params.tasks.map((_, index) => sessionFileForIndex(index)),
|
|
208
|
-
maxSubagentDepth: currentMaxSubagentDepth,
|
|
209
|
-
workflowStageSubagentGuard,
|
|
210
|
-
worktreeSetupHook: deps.config.worktreeSetupHook,
|
|
211
|
-
worktreeSetupHookTimeoutMs: deps.config.worktreeSetupHookTimeoutMs,
|
|
212
|
-
controlConfig,
|
|
213
|
-
controlIntercomTarget,
|
|
214
|
-
childIntercomTarget,
|
|
215
|
-
supervisorAuthorizations,
|
|
216
|
-
nestedRoute,
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (hasChain && params.chain) {
|
|
221
|
-
const normalized = normalizeSkillInput(params.skill);
|
|
222
|
-
const chainSkills = normalized === false ? [] : (normalized ?? []);
|
|
223
|
-
const chain = wrapChainTasksForFork(params.chain as ChainStep[], params.context);
|
|
224
|
-
const supervisor = await authorizeAsyncChain(
|
|
225
|
-
chain,
|
|
226
|
-
childIntercomTarget,
|
|
227
|
-
deps.config.chain?.dynamicFanout?.maxItems,
|
|
228
|
-
deps,
|
|
229
|
-
);
|
|
230
|
-
return deps.runtime.executeAsyncChain(id, {
|
|
231
|
-
chain,
|
|
232
|
-
task: params.task,
|
|
233
|
-
group: params.group,
|
|
234
|
-
agents,
|
|
235
|
-
ctx: asyncCtx,
|
|
236
|
-
availableModels,
|
|
237
|
-
knownModelProviders,
|
|
238
|
-
cwd: effectiveCwd,
|
|
239
|
-
maxOutput: params.maxOutput,
|
|
240
|
-
artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
|
|
241
|
-
artifactConfig,
|
|
242
|
-
shareEnabled,
|
|
243
|
-
sessionRoot,
|
|
244
|
-
chainSkills,
|
|
245
|
-
sessionFilesByFlatIndex: collectChainSessionFiles(chain, sessionFileForIndex),
|
|
246
|
-
dynamicFanoutMaxItems: deps.config.chain?.dynamicFanout?.maxItems,
|
|
247
|
-
maxSubagentDepth: currentMaxSubagentDepth,
|
|
248
|
-
workflowStageSubagentGuard,
|
|
249
|
-
worktreeSetupHook: deps.config.worktreeSetupHook,
|
|
250
|
-
worktreeSetupHookTimeoutMs: deps.config.worktreeSetupHookTimeoutMs,
|
|
251
|
-
controlConfig,
|
|
252
|
-
controlIntercomTarget,
|
|
253
|
-
childIntercomTarget,
|
|
254
|
-
supervisorAuthorizations: supervisor.authorizations,
|
|
255
|
-
dynamicSupervisorAuthorizations: supervisor.dynamic,
|
|
256
|
-
nestedRoute,
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (hasSingle) {
|
|
261
|
-
const a = agents.find((x) => x.name === params.agent);
|
|
262
|
-
if (!a) {
|
|
120
|
+
if (mode === "single") {
|
|
121
|
+
const agent = data.agents.find((candidate) => candidate.name === params.agent);
|
|
122
|
+
if (!agent) {
|
|
263
123
|
return {
|
|
264
124
|
content: [{ type: "text", text: `Unknown agent: ${params.agent}` }],
|
|
265
125
|
isError: true,
|
|
266
|
-
details: { mode: "single"
|
|
126
|
+
details: { mode: "single", results: [] },
|
|
267
127
|
};
|
|
268
128
|
}
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
const
|
|
129
|
+
const availableModels = data.ctx.modelRegistry.getAvailable().map(toModelInfo);
|
|
130
|
+
const knownModelProviders = collectKnownModelProviders(data.ctx.modelRegistry);
|
|
131
|
+
const depthPolicy = resolveSubagentDepthPolicy(data.ctx, deps.config.maxSubagentDepth);
|
|
272
132
|
const normalizedSkills = normalizeSkillInput(params.skill);
|
|
273
133
|
const skills = normalizedSkills === false ? [] : normalizedSkills;
|
|
274
|
-
const
|
|
275
|
-
const
|
|
276
|
-
(
|
|
277
|
-
availableModels,
|
|
278
|
-
currentProvider,
|
|
279
|
-
);
|
|
280
|
-
const progress = resolveSingleProgress(a, params.progress, params.task);
|
|
281
|
-
const supervisorAuthorization = childIntercomTarget
|
|
282
|
-
? await authorizeChild(deps, childIntercomTarget(params.agent!, 0))
|
|
134
|
+
const task = params.context === "fork" ? wrapForkTask(params.task ?? "") : (params.task ?? "");
|
|
135
|
+
const childIntercomTarget = data.intercomBridge.active
|
|
136
|
+
? (childAgent: string, index: number) => resolveSubagentIntercomTarget(data.runId, childAgent, index)
|
|
283
137
|
: undefined;
|
|
284
|
-
|
|
138
|
+
const currentModel = data.ctx.model ? `${data.ctx.model.provider}/${data.ctx.model.id}` : undefined;
|
|
139
|
+
const modelOverride = params.model ?? agent.model;
|
|
140
|
+
return deps.runtime.executeAsyncSingle(data.runId, {
|
|
285
141
|
agent: params.agent!,
|
|
286
|
-
task
|
|
142
|
+
task,
|
|
287
143
|
group: params.group,
|
|
288
|
-
agentConfig:
|
|
289
|
-
ctx:
|
|
290
|
-
|
|
291
|
-
|
|
144
|
+
agentConfig: agent,
|
|
145
|
+
ctx: {
|
|
146
|
+
pi: deps.pi,
|
|
147
|
+
cwd: data.ctx.cwd,
|
|
148
|
+
currentSessionId: deps.state.currentSessionId ?? data.ctx.sessionManager.getSessionId(),
|
|
149
|
+
currentModelProvider: data.ctx.model?.provider,
|
|
150
|
+
currentModel,
|
|
151
|
+
intercomGroup: data.ctx.orchestrationContext?.intercomGroup,
|
|
152
|
+
workflowSessionMetadata: workflowSessionMetadataFromContext(data.ctx),
|
|
153
|
+
},
|
|
292
154
|
cwd: effectiveCwd,
|
|
293
155
|
maxOutput: params.maxOutput,
|
|
294
|
-
artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
|
|
295
|
-
artifactConfig,
|
|
296
|
-
shareEnabled,
|
|
297
|
-
sessionRoot,
|
|
298
|
-
sessionFile: sessionFileForIndex(0),
|
|
156
|
+
artifactsDir: data.artifactConfig.enabled ? data.artifactsDir : undefined,
|
|
157
|
+
artifactConfig: data.artifactConfig,
|
|
158
|
+
shareEnabled: data.shareEnabled,
|
|
159
|
+
sessionRoot: data.sessionRoot,
|
|
160
|
+
sessionFile: data.sessionFileForIndex(0),
|
|
299
161
|
skills,
|
|
300
|
-
output:
|
|
301
|
-
outputMode:
|
|
302
|
-
progress,
|
|
162
|
+
output: params.output,
|
|
163
|
+
outputMode: params.outputMode,
|
|
164
|
+
progress: params.progress,
|
|
303
165
|
modelOverride,
|
|
304
|
-
|
|
305
|
-
|
|
166
|
+
availableModels,
|
|
167
|
+
knownModelProviders,
|
|
168
|
+
maxSubagentDepth: resolveChildMaxSubagentDepth(depthPolicy.maxSubagentDepth, agent.maxSubagentDepth),
|
|
169
|
+
workflowStageSubagentGuard: depthPolicy.workflowStageSubagentGuard,
|
|
306
170
|
worktreeSetupHook: deps.config.worktreeSetupHook,
|
|
307
171
|
worktreeSetupHookTimeoutMs: deps.config.worktreeSetupHookTimeoutMs,
|
|
308
|
-
controlConfig,
|
|
309
|
-
controlIntercomTarget,
|
|
310
|
-
childIntercomTarget
|
|
311
|
-
|
|
312
|
-
nestedRoute,
|
|
172
|
+
controlConfig: data.controlConfig,
|
|
173
|
+
controlIntercomTarget: data.intercomBridge.active ? data.intercomBridge.orchestratorTarget : undefined,
|
|
174
|
+
childIntercomTarget,
|
|
175
|
+
nestedRoute: data.nestedRoute,
|
|
313
176
|
});
|
|
314
177
|
}
|
|
315
178
|
|
|
316
|
-
|
|
179
|
+
const continued = continuedResult(data, mode);
|
|
180
|
+
if (mode === "chain" || mode === "parallel") runForegroundInBackground(data, deps, mode);
|
|
181
|
+
return {
|
|
182
|
+
content: [{ type: "text", text: formatAsyncStartedMessage(`Async ${mode}: ${data.runId}`) }],
|
|
183
|
+
details: {
|
|
184
|
+
mode,
|
|
185
|
+
runId: data.runId,
|
|
186
|
+
asyncId: data.runId,
|
|
187
|
+
results: [continued],
|
|
188
|
+
},
|
|
189
|
+
};
|
|
317
190
|
}
|
|
@@ -3,7 +3,7 @@ import { resolveSubagentIntercomTarget } from "../../intercom/intercom-bridge.ts
|
|
|
3
3
|
import type { ChainStep } from "../../shared/settings.ts";
|
|
4
4
|
import { resolveSubagentDepthPolicy } from "../../shared/types.ts";
|
|
5
5
|
import { compactForegroundDetails } from "../../shared/utils.ts";
|
|
6
|
-
import { updateForegroundNestedProjection } from "../
|
|
6
|
+
import { updateForegroundNestedProjection } from "../inprocess/runtime-support/nested-api.ts";
|
|
7
7
|
import { executeChain } from "./chain-execution.ts";
|
|
8
8
|
import { wrapChainTasksForFork } from "./subagent-executor-input.ts";
|
|
9
9
|
import {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import type { ExtensionContext } from "@bastani/atomic";
|
|
5
5
|
import { resolveExecutionAgentScope } from "../../agents/agent-scope.ts";
|
|
6
6
|
import {
|
|
7
7
|
applyIntercomBridgeToAgent,
|
|
@@ -25,14 +25,17 @@ import {
|
|
|
25
25
|
type SubagentToolResult,
|
|
26
26
|
subagentDepthBlockedMessage,
|
|
27
27
|
} from "../../shared/types.ts";
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
function applyForceTopLevelAsyncOverride<T extends { async?: boolean }>(params: T, depth: number, force: boolean): T {
|
|
30
|
+
return depth === 0 && force ? { ...params, async: true } : params;
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
import {
|
|
30
34
|
createNestedRoute,
|
|
31
35
|
resolveInheritedNestedRouteFromEnv,
|
|
32
36
|
resolveNestedParentAddressFromEnv,
|
|
33
37
|
writeNestedEvent,
|
|
34
|
-
} from "../
|
|
35
|
-
import { SUBAGENT_INTERCOM_SESSION_NAME_ENV } from "../shared/pi-args.ts";
|
|
38
|
+
} from "../inprocess/runtime-support/nested-api.ts";
|
|
36
39
|
import { resolveControlConfig } from "../shared/subagent-control.ts";
|
|
37
40
|
import {
|
|
38
41
|
applyAgentDefaultContext,
|
|
@@ -133,7 +136,7 @@ export function prepareExecutionContext(input: {
|
|
|
133
136
|
...DEFAULT_ARTIFACT_CONFIG,
|
|
134
137
|
enabled: effectiveParams.artifacts !== false,
|
|
135
138
|
};
|
|
136
|
-
const artifactsDir =
|
|
139
|
+
const artifactsDir = getArtifactsDir(parentSessionFile);
|
|
137
140
|
|
|
138
141
|
let sessionRoot: string;
|
|
139
142
|
if (effectiveParams.sessionDir) {
|
|
@@ -212,9 +215,9 @@ export function prepareExecutionContext(input: {
|
|
|
212
215
|
const state =
|
|
213
216
|
type === "subagent.nested.started"
|
|
214
217
|
? "running"
|
|
215
|
-
: result?.isError || details?.results.some((child) => child.
|
|
218
|
+
: result?.isError || details?.results.some((child) => child.status === "error")
|
|
216
219
|
? "failed"
|
|
217
|
-
: details?.results.some((child) => child.interrupted)
|
|
220
|
+
: details?.results.some((child) => child.interrupted || child.status === "interrupted")
|
|
218
221
|
? "paused"
|
|
219
222
|
: "complete";
|
|
220
223
|
const errorText = result?.isError ? result.content.find((item) => item.type === "text")?.text : undefined;
|
|
@@ -246,7 +249,8 @@ export function prepareExecutionContext(input: {
|
|
|
246
249
|
parentStepIndex: nestedParentAddress.parentStepIndex,
|
|
247
250
|
depth: nestedParentAddress.depth,
|
|
248
251
|
path: nestedParentAddress.path,
|
|
249
|
-
ownerIntercomTarget:
|
|
252
|
+
ownerIntercomTarget:
|
|
253
|
+
ctx.subagentPolicy?.intercom?.sessionName ?? ctx.subagentPolicy?.intercom?.orchestratorTarget,
|
|
250
254
|
leafIntercomTarget,
|
|
251
255
|
intercomTarget: leafIntercomTarget,
|
|
252
256
|
ownerState: state === "running" ? "live" : "gone",
|
|
@@ -262,7 +266,12 @@ export function prepareExecutionContext(input: {
|
|
|
262
266
|
? {
|
|
263
267
|
steps: details.results.map((child) => ({
|
|
264
268
|
agent: child.agent,
|
|
265
|
-
status:
|
|
269
|
+
status:
|
|
270
|
+
child.interrupted || child.status === "interrupted"
|
|
271
|
+
? "paused"
|
|
272
|
+
: child.status === "ok"
|
|
273
|
+
? "complete"
|
|
274
|
+
: "failed",
|
|
266
275
|
...(child.sessionFile ? { sessionFile: child.sessionFile } : {}),
|
|
267
276
|
...(child.error ? { error: child.error } : {}),
|
|
268
277
|
})),
|
|
@@ -67,7 +67,7 @@ export async function runForegroundParallelTasks(input: ForegroundParallelRunInp
|
|
|
67
67
|
return {
|
|
68
68
|
agent: task.agent,
|
|
69
69
|
task: input.taskTexts[index] ?? task.task,
|
|
70
|
-
|
|
70
|
+
status: "skipped",
|
|
71
71
|
messages: [],
|
|
72
72
|
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 },
|
|
73
73
|
error: "Skipped after foreground group detached for intercom coordination",
|
|
@@ -20,9 +20,9 @@ import {
|
|
|
20
20
|
wrapForkTask,
|
|
21
21
|
} from "../../shared/types.ts";
|
|
22
22
|
import { compactForegroundDetails, getSingleResultOutput } from "../../shared/utils.ts";
|
|
23
|
+
import { updateForegroundNestedProjection } from "../inprocess/runtime-support/nested-api.ts";
|
|
23
24
|
import { sharedAutoGroupForSet } from "../shared/intercom-group.ts";
|
|
24
25
|
import { resolveModelCandidate } from "../shared/model-fallback.ts";
|
|
25
|
-
import { updateForegroundNestedProjection } from "../shared/nested-events.ts";
|
|
26
26
|
import { aggregateParallelOutputs } from "../shared/parallel-utils.ts";
|
|
27
27
|
import { recordRun } from "../shared/run-history.ts";
|
|
28
28
|
import { resolveSingleOutputPath, validateFileOnlyOutputMode } from "../shared/single-output.ts";
|
|
@@ -234,7 +234,7 @@ export async function runParallelPath(
|
|
|
234
234
|
});
|
|
235
235
|
for (let i = 0; i < results.length; i++) {
|
|
236
236
|
const run = results[i]!;
|
|
237
|
-
recordRun(run.agent, taskTexts[i]!, run.
|
|
237
|
+
recordRun(run.agent, taskTexts[i]!, run.status, run.progressSummary?.durationMs ?? 0);
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
for (const result of results) {
|
|
@@ -296,12 +296,12 @@ export async function runParallelPath(
|
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
const worktreeSuffix = buildParallelWorktreeSuffix(worktreeSetup, artifactsDir, tasks as TaskParam[]);
|
|
299
|
-
const ok = results.filter((result) => result.
|
|
299
|
+
const ok = results.filter((result) => result.status === "ok").length;
|
|
300
300
|
const aggregatedOutput = aggregateParallelOutputs(
|
|
301
301
|
results.map((result) => ({
|
|
302
302
|
agent: result.agent,
|
|
303
303
|
output: result.truncation?.text || getSingleResultOutput(result),
|
|
304
|
-
|
|
304
|
+
status: result.status,
|
|
305
305
|
error: result.error,
|
|
306
306
|
})),
|
|
307
307
|
(i, agent) => `=== Task ${i + 1}: ${agent} ===`,
|