@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,279 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { getEnvValue } from "@bastani/atomic";
|
|
4
|
-
import { buildSkillInjection, resolveSkillsWithFallback } from "../../agents/skills.ts";
|
|
5
|
-
import {
|
|
6
|
-
getSubagentCodexFastModeSettings,
|
|
7
|
-
resolveSubagentCodexFastModeScope,
|
|
8
|
-
resolveSubagentModelFastModeMetadata,
|
|
9
|
-
} from "../../shared/fast-mode.ts";
|
|
10
|
-
import { resolveEffectiveThinking } from "../../shared/model-info.ts";
|
|
11
|
-
import { injectSingleProgressInstruction, writeInitialProgressFile } from "../../shared/settings.ts";
|
|
12
|
-
import {
|
|
13
|
-
ASYNC_DIR,
|
|
14
|
-
RESULTS_DIR,
|
|
15
|
-
resolveChildMaxSubagentDepth,
|
|
16
|
-
SUBAGENT_ASYNC_STARTED_EVENT,
|
|
17
|
-
} from "../../shared/types.ts";
|
|
18
|
-
import { workflowSessionEnv } from "../../shared/types-depth.ts";
|
|
19
|
-
import { resolveChildCwd } from "../../shared/utils.ts";
|
|
20
|
-
import { resolveChildIntercomGroup } from "../shared/intercom-group.ts";
|
|
21
|
-
import { filterSpawnableModelCandidates } from "../shared/model-candidate-filter.ts";
|
|
22
|
-
import { buildModelCandidates, resolveModelCandidate } from "../shared/model-fallback.ts";
|
|
23
|
-
import {
|
|
24
|
-
NESTED_RUNS_DIR,
|
|
25
|
-
nestedResultsPath,
|
|
26
|
-
resolveInheritedNestedRouteFromEnv,
|
|
27
|
-
resolveNestedParentAddressFromEnv,
|
|
28
|
-
writeNestedEvent,
|
|
29
|
-
} from "../shared/nested-events.ts";
|
|
30
|
-
import { applyThinkingSuffix, SUBAGENT_INTERCOM_SESSION_NAME_ENV } from "../shared/pi-args.ts";
|
|
31
|
-
import {
|
|
32
|
-
injectSingleOutputInstruction,
|
|
33
|
-
normalizeSingleOutputOverride,
|
|
34
|
-
resolveSingleOutputPath,
|
|
35
|
-
validateFileOnlyOutputMode,
|
|
36
|
-
} from "../shared/single-output.ts";
|
|
37
|
-
import {
|
|
38
|
-
spawnRunner as defaultSpawnRunner,
|
|
39
|
-
formatAsyncStartError,
|
|
40
|
-
formatAsyncStartedMessage,
|
|
41
|
-
piPackageRoot,
|
|
42
|
-
UNAVAILABLE_SUBAGENT_SKILL_ERROR,
|
|
43
|
-
} from "./async-execution-common.ts";
|
|
44
|
-
import type { AsyncExecutionResult, AsyncSingleParams, AsyncSpawnResult } from "./async-execution-types.ts";
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Execute a single agent asynchronously
|
|
48
|
-
*/
|
|
49
|
-
export function executeAsyncSingle(id: string, params: AsyncSingleParams): AsyncExecutionResult {
|
|
50
|
-
const {
|
|
51
|
-
agent,
|
|
52
|
-
agentConfig,
|
|
53
|
-
ctx,
|
|
54
|
-
cwd,
|
|
55
|
-
maxOutput,
|
|
56
|
-
artifactsDir,
|
|
57
|
-
artifactConfig,
|
|
58
|
-
shareEnabled,
|
|
59
|
-
sessionRoot,
|
|
60
|
-
sessionFile,
|
|
61
|
-
maxSubagentDepth,
|
|
62
|
-
workflowStageSubagentGuard,
|
|
63
|
-
worktreeSetupHook,
|
|
64
|
-
worktreeSetupHookTimeoutMs,
|
|
65
|
-
controlConfig,
|
|
66
|
-
controlIntercomTarget,
|
|
67
|
-
childIntercomTarget,
|
|
68
|
-
supervisorAuthorization,
|
|
69
|
-
nestedRoute,
|
|
70
|
-
spawnRunner = defaultSpawnRunner,
|
|
71
|
-
} = params;
|
|
72
|
-
const task = params.task ?? "";
|
|
73
|
-
const runnerCwd = resolveChildCwd(ctx.cwd, cwd);
|
|
74
|
-
const skillNames = params.skills ?? agentConfig.skills ?? [];
|
|
75
|
-
const availableModels = params.availableModels;
|
|
76
|
-
const knownModelProviders = params.knownModelProviders;
|
|
77
|
-
const { resolved: resolvedSkills, missing: missingSkills } = resolveSkillsWithFallback(
|
|
78
|
-
skillNames,
|
|
79
|
-
runnerCwd,
|
|
80
|
-
ctx.cwd,
|
|
81
|
-
);
|
|
82
|
-
if (missingSkills.includes("subagent")) return formatAsyncStartError("single", UNAVAILABLE_SUBAGENT_SKILL_ERROR);
|
|
83
|
-
let systemPrompt = agentConfig.systemPrompt?.trim() ?? "";
|
|
84
|
-
if (resolvedSkills.length > 0) {
|
|
85
|
-
const injection = buildSkillInjection(resolvedSkills);
|
|
86
|
-
systemPrompt = systemPrompt ? `${systemPrompt}\n\n${injection}` : injection;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const inheritedNestedRoute = resolveInheritedNestedRouteFromEnv();
|
|
90
|
-
const nestedAddress = inheritedNestedRoute ? resolveNestedParentAddressFromEnv() : undefined;
|
|
91
|
-
const asyncDir = inheritedNestedRoute
|
|
92
|
-
? path.join(NESTED_RUNS_DIR, inheritedNestedRoute.rootRunId, id)
|
|
93
|
-
: path.join(ASYNC_DIR, id);
|
|
94
|
-
try {
|
|
95
|
-
fs.mkdirSync(asyncDir, { recursive: true });
|
|
96
|
-
} catch (error) {
|
|
97
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
98
|
-
return {
|
|
99
|
-
content: [{ type: "text", text: `Failed to create async run directory '${asyncDir}': ${message}` }],
|
|
100
|
-
isError: true,
|
|
101
|
-
details: { mode: "single" as const, results: [] },
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const effectiveOutput = normalizeSingleOutputOverride(params.output, agentConfig.output);
|
|
106
|
-
const outputPath = resolveSingleOutputPath(effectiveOutput, ctx.cwd, runnerCwd);
|
|
107
|
-
const outputMode = params.outputMode ?? "inline";
|
|
108
|
-
const validationError = validateFileOnlyOutputMode(outputMode, outputPath, `Async single run (${agent})`);
|
|
109
|
-
if (validationError) return formatAsyncStartError("single", validationError);
|
|
110
|
-
let taskWithOutputInstruction = injectSingleOutputInstruction(task, outputPath);
|
|
111
|
-
// Keep each child's progress contract outside its cwd and isolated by run;
|
|
112
|
-
// artifacts-disabled async runs use their already run-owned async directory.
|
|
113
|
-
if (params.progress) {
|
|
114
|
-
const progressDir =
|
|
115
|
-
artifactConfig.enabled && artifactsDir
|
|
116
|
-
? path.join(artifactsDir, "progress", id)
|
|
117
|
-
: path.join(asyncDir, "progress");
|
|
118
|
-
writeInitialProgressFile(progressDir);
|
|
119
|
-
taskWithOutputInstruction = injectSingleProgressInstruction(taskWithOutputInstruction, progressDir);
|
|
120
|
-
}
|
|
121
|
-
const model = applyThinkingSuffix(
|
|
122
|
-
resolveModelCandidate(params.modelOverride ?? agentConfig.model, availableModels, ctx.currentModelProvider),
|
|
123
|
-
agentConfig.thinking,
|
|
124
|
-
);
|
|
125
|
-
const rawModelCandidates = buildModelCandidates(
|
|
126
|
-
params.modelOverride ?? agentConfig.model,
|
|
127
|
-
agentConfig.fallbackModels,
|
|
128
|
-
availableModels,
|
|
129
|
-
ctx.currentModelProvider,
|
|
130
|
-
ctx.currentModel,
|
|
131
|
-
)
|
|
132
|
-
.map((candidate) => applyThinkingSuffix(candidate, agentConfig.thinking))
|
|
133
|
-
.filter((candidate): candidate is string => typeof candidate === "string");
|
|
134
|
-
const filteredCandidates = filterSpawnableModelCandidates({
|
|
135
|
-
candidates: rawModelCandidates,
|
|
136
|
-
availableModels,
|
|
137
|
-
knownModelProviders,
|
|
138
|
-
currentModel: applyThinkingSuffix(ctx.currentModel, agentConfig.thinking),
|
|
139
|
-
});
|
|
140
|
-
const modelCandidates = filteredCandidates.candidates;
|
|
141
|
-
const fastModeSettings = getSubagentCodexFastModeSettings(runnerCwd);
|
|
142
|
-
const fastModeScope = resolveSubagentCodexFastModeScope(workflowStageSubagentGuard);
|
|
143
|
-
let spawnResult: AsyncSpawnResult = {};
|
|
144
|
-
try {
|
|
145
|
-
spawnResult = spawnRunner(
|
|
146
|
-
{
|
|
147
|
-
id,
|
|
148
|
-
steps: [
|
|
149
|
-
{
|
|
150
|
-
agent,
|
|
151
|
-
task: taskWithOutputInstruction,
|
|
152
|
-
intercomGroup: resolveChildIntercomGroup(params.group, ctx.intercomGroup, undefined),
|
|
153
|
-
cwd: runnerCwd,
|
|
154
|
-
model,
|
|
155
|
-
thinking: resolveEffectiveThinking(model, agentConfig.thinking),
|
|
156
|
-
...resolveSubagentModelFastModeMetadata({
|
|
157
|
-
model,
|
|
158
|
-
modelCandidates,
|
|
159
|
-
cwd: runnerCwd,
|
|
160
|
-
settings: fastModeSettings,
|
|
161
|
-
scope: fastModeScope,
|
|
162
|
-
}),
|
|
163
|
-
modelCandidates,
|
|
164
|
-
modelAttempts: filteredCandidates.skippedAttempts,
|
|
165
|
-
codexFastModeSettings: fastModeSettings,
|
|
166
|
-
codexFastModeScope: fastModeScope,
|
|
167
|
-
tools: agentConfig.tools,
|
|
168
|
-
extensions: agentConfig.extensions,
|
|
169
|
-
mcpDirectTools: agentConfig.mcpDirectTools,
|
|
170
|
-
systemPrompt,
|
|
171
|
-
systemPromptMode: agentConfig.systemPromptMode,
|
|
172
|
-
inheritProjectContext: agentConfig.inheritProjectContext,
|
|
173
|
-
inheritSkills: agentConfig.inheritSkills,
|
|
174
|
-
skills: resolvedSkills.map((r) => r.name),
|
|
175
|
-
outputPath,
|
|
176
|
-
outputMode,
|
|
177
|
-
sessionFile,
|
|
178
|
-
maxSubagentDepth: resolveChildMaxSubagentDepth(maxSubagentDepth, agentConfig.maxSubagentDepth),
|
|
179
|
-
workflowStageSubagentGuard,
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
resultPath: inheritedNestedRoute
|
|
183
|
-
? nestedResultsPath(inheritedNestedRoute.rootRunId, id)
|
|
184
|
-
: path.join(RESULTS_DIR, `${id}.json`),
|
|
185
|
-
cwd: runnerCwd,
|
|
186
|
-
placeholder: "{previous}",
|
|
187
|
-
maxOutput,
|
|
188
|
-
artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
|
|
189
|
-
artifactConfig,
|
|
190
|
-
share: shareEnabled,
|
|
191
|
-
sessionDir: sessionRoot ? path.join(sessionRoot, `async-${id}`) : undefined,
|
|
192
|
-
asyncDir,
|
|
193
|
-
sessionId: ctx.currentSessionId,
|
|
194
|
-
piPackageRoot,
|
|
195
|
-
piArgv1: process.argv[1],
|
|
196
|
-
worktreeSetupHook,
|
|
197
|
-
worktreeSetupHookTimeoutMs,
|
|
198
|
-
controlConfig,
|
|
199
|
-
controlIntercomTarget,
|
|
200
|
-
childIntercomTargets: childIntercomTarget ? [childIntercomTarget(agent, 0)] : undefined,
|
|
201
|
-
supervisorAuthorizations: supervisorAuthorization ? [supervisorAuthorization] : undefined,
|
|
202
|
-
resultMode: "single",
|
|
203
|
-
nestedRoute: nestedRoute ?? inheritedNestedRoute,
|
|
204
|
-
workflowStageSubagentGuard,
|
|
205
|
-
nestedSelf:
|
|
206
|
-
inheritedNestedRoute && nestedAddress
|
|
207
|
-
? {
|
|
208
|
-
parentRunId: nestedAddress.parentRunId,
|
|
209
|
-
parentStepIndex: nestedAddress.parentStepIndex,
|
|
210
|
-
depth: nestedAddress.depth,
|
|
211
|
-
path: nestedAddress.path,
|
|
212
|
-
}
|
|
213
|
-
: undefined,
|
|
214
|
-
},
|
|
215
|
-
id,
|
|
216
|
-
runnerCwd,
|
|
217
|
-
workflowSessionEnv(ctx.workflowSessionMetadata),
|
|
218
|
-
);
|
|
219
|
-
} catch (error) {
|
|
220
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
221
|
-
return formatAsyncStartError("single", `Failed to start async run '${id}': ${message}`);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (spawnResult.error) {
|
|
225
|
-
return formatAsyncStartError("single", `Failed to start async run '${id}': ${spawnResult.error}`);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (spawnResult.pid) {
|
|
229
|
-
if (inheritedNestedRoute && nestedAddress) {
|
|
230
|
-
const now = Date.now();
|
|
231
|
-
try {
|
|
232
|
-
writeNestedEvent(inheritedNestedRoute, {
|
|
233
|
-
type: "subagent.nested.started",
|
|
234
|
-
ts: now,
|
|
235
|
-
parentRunId: nestedAddress.parentRunId,
|
|
236
|
-
parentStepIndex: nestedAddress.parentStepIndex,
|
|
237
|
-
child: {
|
|
238
|
-
id,
|
|
239
|
-
parentRunId: nestedAddress.parentRunId,
|
|
240
|
-
parentStepIndex: nestedAddress.parentStepIndex,
|
|
241
|
-
depth: nestedAddress.depth,
|
|
242
|
-
path: nestedAddress.path,
|
|
243
|
-
asyncDir,
|
|
244
|
-
pid: spawnResult.pid,
|
|
245
|
-
ownerIntercomTarget: getEnvValue(SUBAGENT_INTERCOM_SESSION_NAME_ENV),
|
|
246
|
-
leafIntercomTarget: childIntercomTarget?.(agent, 0),
|
|
247
|
-
intercomTarget: childIntercomTarget?.(agent, 0),
|
|
248
|
-
ownerState: "live",
|
|
249
|
-
mode: "single",
|
|
250
|
-
state: "running",
|
|
251
|
-
agent,
|
|
252
|
-
agents: [agent],
|
|
253
|
-
chainStepCount: 1,
|
|
254
|
-
startedAt: now,
|
|
255
|
-
lastUpdate: now,
|
|
256
|
-
},
|
|
257
|
-
});
|
|
258
|
-
} catch (error) {
|
|
259
|
-
console.error("Failed to emit nested async start event:", error);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
ctx.pi.events.emit(SUBAGENT_ASYNC_STARTED_EVENT, {
|
|
263
|
-
id,
|
|
264
|
-
pid: spawnResult.pid,
|
|
265
|
-
sessionId: ctx.currentSessionId,
|
|
266
|
-
mode: "single",
|
|
267
|
-
agent,
|
|
268
|
-
task: task?.slice(0, 50),
|
|
269
|
-
cwd: runnerCwd,
|
|
270
|
-
asyncDir,
|
|
271
|
-
nestedRoute,
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return {
|
|
276
|
-
content: [{ type: "text", text: formatAsyncStartedMessage(`Async: ${agent} [${id}]`) }],
|
|
277
|
-
details: { mode: "single", runId: id, results: [], asyncId: id, asyncDir },
|
|
278
|
-
};
|
|
279
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import type { ExtensionAPI, SessionWorkflowMetadata } from "@bastani/atomic";
|
|
2
|
-
import type { AgentConfig } from "../../agents/agents.ts";
|
|
3
|
-
import type { SupervisorAuthorization } from "../../intercom/supervisor-authorization.ts";
|
|
4
|
-
import type { ChainStep } from "../../shared/settings.ts";
|
|
5
|
-
import type {
|
|
6
|
-
ArtifactConfig,
|
|
7
|
-
Details,
|
|
8
|
-
MaxOutputConfig,
|
|
9
|
-
NestedRouteInfo,
|
|
10
|
-
ResolvedControlConfig,
|
|
11
|
-
SubagentRunMode,
|
|
12
|
-
} from "../../shared/types.ts";
|
|
13
|
-
import type { AvailableModelInfo } from "../shared/model-fallback.ts";
|
|
14
|
-
|
|
15
|
-
export interface AsyncExecutionContext {
|
|
16
|
-
pi: ExtensionAPI;
|
|
17
|
-
cwd: string;
|
|
18
|
-
currentSessionId: string;
|
|
19
|
-
currentModelProvider?: string;
|
|
20
|
-
currentModel?: string;
|
|
21
|
-
intercomGroup?: string;
|
|
22
|
-
workflowSessionMetadata?: SessionWorkflowMetadata;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface AsyncChainParams {
|
|
26
|
-
chain: ChainStep[];
|
|
27
|
-
task?: string;
|
|
28
|
-
group?: string | true;
|
|
29
|
-
resultMode?: Exclude<SubagentRunMode, "single">;
|
|
30
|
-
agents: AgentConfig[];
|
|
31
|
-
ctx: AsyncExecutionContext;
|
|
32
|
-
availableModels?: AvailableModelInfo[];
|
|
33
|
-
knownModelProviders?: string[];
|
|
34
|
-
cwd?: string;
|
|
35
|
-
maxOutput?: MaxOutputConfig;
|
|
36
|
-
artifactsDir?: string;
|
|
37
|
-
artifactConfig: ArtifactConfig;
|
|
38
|
-
shareEnabled: boolean;
|
|
39
|
-
sessionRoot?: string;
|
|
40
|
-
chainSkills?: string[];
|
|
41
|
-
sessionFilesByFlatIndex?: (string | undefined)[];
|
|
42
|
-
dynamicFanoutMaxItems?: number;
|
|
43
|
-
maxSubagentDepth: number;
|
|
44
|
-
workflowStageSubagentGuard?: boolean;
|
|
45
|
-
worktreeSetupHook?: string;
|
|
46
|
-
worktreeSetupHookTimeoutMs?: number;
|
|
47
|
-
controlConfig?: ResolvedControlConfig;
|
|
48
|
-
controlIntercomTarget?: string;
|
|
49
|
-
childIntercomTarget?: (agent: string, index: number) => string | undefined;
|
|
50
|
-
supervisorAuthorizations?: Array<SupervisorAuthorization | undefined>;
|
|
51
|
-
dynamicSupervisorAuthorizations?: Record<number, SupervisorAuthorization[]>;
|
|
52
|
-
/** Internal launch seam used by focused runtime tests. */
|
|
53
|
-
spawnRunner?: (config: object, suffix: string, cwd: string, env?: Record<string, string>) => AsyncSpawnResult;
|
|
54
|
-
nestedRoute?: NestedRouteInfo;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface AsyncSingleParams {
|
|
58
|
-
agent: string;
|
|
59
|
-
task?: string;
|
|
60
|
-
group?: string | true;
|
|
61
|
-
agentConfig: AgentConfig;
|
|
62
|
-
ctx: AsyncExecutionContext;
|
|
63
|
-
cwd?: string;
|
|
64
|
-
maxOutput?: MaxOutputConfig;
|
|
65
|
-
artifactsDir?: string;
|
|
66
|
-
artifactConfig: ArtifactConfig;
|
|
67
|
-
shareEnabled: boolean;
|
|
68
|
-
sessionRoot?: string;
|
|
69
|
-
sessionFile?: string;
|
|
70
|
-
skills?: string[];
|
|
71
|
-
output?: string | boolean;
|
|
72
|
-
outputMode?: "inline" | "file-only";
|
|
73
|
-
progress?: boolean;
|
|
74
|
-
modelOverride?: string;
|
|
75
|
-
availableModels?: AvailableModelInfo[];
|
|
76
|
-
knownModelProviders?: string[];
|
|
77
|
-
maxSubagentDepth: number;
|
|
78
|
-
workflowStageSubagentGuard?: boolean;
|
|
79
|
-
worktreeSetupHook?: string;
|
|
80
|
-
worktreeSetupHookTimeoutMs?: number;
|
|
81
|
-
controlConfig?: ResolvedControlConfig;
|
|
82
|
-
controlIntercomTarget?: string;
|
|
83
|
-
childIntercomTarget?: (agent: string, index: number) => string | undefined;
|
|
84
|
-
supervisorAuthorization?: SupervisorAuthorization;
|
|
85
|
-
nestedRoute?: NestedRouteInfo;
|
|
86
|
-
/** Internal launch seam used by focused runtime tests. */
|
|
87
|
-
spawnRunner?: (config: object, suffix: string, cwd: string, env?: Record<string, string>) => AsyncSpawnResult;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface AsyncExecutionResult {
|
|
91
|
-
content: Array<{ type: "text"; text: string }>;
|
|
92
|
-
details: Details;
|
|
93
|
-
isError?: boolean;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface AsyncSpawnResult {
|
|
97
|
-
pid?: number;
|
|
98
|
-
error?: string;
|
|
99
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Async execution logic for subagent tool
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export { executeAsyncChain } from "./async-execution-chain.ts";
|
|
6
|
-
export {
|
|
7
|
-
formatAsyncStartedMessage,
|
|
8
|
-
isAsyncAvailable,
|
|
9
|
-
writeAsyncRunnerConfig,
|
|
10
|
-
} from "./async-execution-common.ts";
|
|
11
|
-
export { executeAsyncSingle } from "./async-execution-single.ts";
|
|
12
|
-
export type {
|
|
13
|
-
AsyncChainParams,
|
|
14
|
-
AsyncExecutionContext,
|
|
15
|
-
AsyncExecutionResult,
|
|
16
|
-
AsyncSingleParams,
|
|
17
|
-
} from "./async-execution-types.ts";
|