@bastani/atomic 0.9.15 → 0.9.16-alpha.2
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 +19 -0
- package/dist/builtin/intercom/CHANGELOG.md +10 -0
- package/dist/builtin/intercom/README.md +8 -8
- package/dist/builtin/intercom/contact-supervisor-tool.ts +68 -32
- package/dist/builtin/intercom/index-heavy.ts +1 -0
- package/dist/builtin/intercom/index.ts +21 -15
- package/dist/builtin/intercom/intercom-tool.ts +66 -10
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/parent-ask-handoff.ts +72 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +26 -0
- package/dist/builtin/subagents/README.md +37 -114
- package/dist/builtin/subagents/agents/worker.md +2 -2
- package/dist/builtin/subagents/package.json +1 -5
- package/dist/builtin/subagents/skills/subagent/SKILL.md +26 -103
- package/dist/builtin/subagents/src/extension/index.ts +5 -30
- package/dist/builtin/subagents/src/extension/notification-content.ts +1 -1
- package/dist/builtin/subagents/src/extension/schemas.ts +2 -14
- package/dist/builtin/subagents/src/extension/tool-description.ts +1 -4
- package/dist/builtin/subagents/src/extension/tool-rendering.ts +53 -0
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +1 -54
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -4
- package/dist/builtin/subagents/src/runs/foreground/execution-parent-ask-handoff.ts +78 -0
- package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +7 -5
- package/dist/builtin/subagents/src/runs/foreground/notify.ts +5 -6
- package/dist/builtin/subagents/src/runs/foreground/parent-ask-output.ts +48 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-burst-display.ts +46 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-burst.ts +403 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +48 -9
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +3 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-live-update.ts +11 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +164 -93
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +36 -29
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parent-ask-projection.ts +11 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +42 -17
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +3 -121
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +7 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +30 -257
- package/dist/builtin/subagents/src/runs/inprocess/control-status.ts +0 -34
- package/dist/builtin/subagents/src/runs/inprocess/index.ts +0 -12
- package/dist/builtin/subagents/src/runs/inprocess/prompt-behavior.ts +1 -1
- package/dist/builtin/subagents/src/runs/inprocess/runner.ts +2 -141
- package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +8 -0
- package/dist/builtin/subagents/src/shared/status-format.ts +3 -3
- package/dist/builtin/subagents/src/shared/types-config.ts +41 -0
- package/dist/builtin/subagents/src/shared/types-foreground-state.ts +7 -15
- package/dist/builtin/subagents/src/shared/types-results.ts +3 -1
- package/dist/builtin/subagents/src/shared/types-runtime.ts +1 -11
- package/dist/builtin/subagents/src/slash/slash-commands.ts +4 -468
- package/dist/builtin/subagents/src/tui/render-progress.ts +2 -2
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +2 -2
- package/dist/builtin/subagents/src/tui/render-result.ts +38 -14
- package/dist/builtin/subagents/src/tui/render-status-progress.ts +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +16 -0
- package/dist/builtin/workflows/README.md +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/skills/bro/LICENSE.txt +21 -0
- package/dist/builtin/workflows/skills/bro/SKILL.md +14 -0
- package/dist/builtin/workflows/skills/how/LICENSE.txt +21 -0
- package/dist/builtin/workflows/skills/how/SKILL.md +162 -0
- package/dist/builtin/workflows/skills/how/references/critic-prompt.md +59 -0
- package/dist/builtin/workflows/skills/how/references/critique-rubric.md +58 -0
- package/dist/builtin/workflows/skills/how/references/explainer-prompt.md +55 -0
- package/dist/builtin/workflows/skills/how/references/explorer-prompt.md +52 -0
- package/dist/builtin/workflows/skills/teach/LICENSE.txt +21 -0
- package/dist/builtin/workflows/skills/teach/SKILL.md +28 -0
- package/dist/builtin/workflows/skills/unslop/LICENSE.txt +21 -0
- package/dist/builtin/workflows/skills/unslop/SKILL.md +87 -0
- package/dist/builtin/workflows/skills/why/LICENSE.txt +21 -0
- package/dist/builtin/workflows/skills/why/SKILL.md +267 -0
- package/dist/builtin/workflows/skills/why/references/epistemics.md +144 -0
- package/dist/builtin/workflows/skills/why/references/investigator-prompt.md +103 -0
- package/dist/builtin/workflows/skills/why/references/source-playbook.md +17 -0
- package/dist/builtin/workflows/skills/why/references/sources/code-archaeology.md +88 -0
- package/dist/builtin/workflows/skills/why/references/sources/databricks.md +70 -0
- package/dist/builtin/workflows/skills/why/references/sources/datadog.md +99 -0
- package/dist/builtin/workflows/skills/why/references/sources/incident-postmortem.md +15 -0
- package/dist/builtin/workflows/skills/why/references/sources/linear.md +48 -0
- package/dist/builtin/workflows/skills/why/references/sources/notion.md +55 -0
- package/dist/builtin/workflows/skills/why/references/sources/sentry.md +100 -0
- package/dist/builtin/workflows/skills/why/references/sources/slack.md +54 -0
- package/dist/builtin/workflows/skills/why/references/synthesizer-prompt.md +135 -0
- package/dist/builtin/workflows/src/durable/dbos-embedded-postgres-root.ts +548 -39
- package/dist/builtin/workflows/src/durable/dbos-embedded-postgres.ts +529 -65
- package/dist/builtin/workflows/src/durable/dbos-lifecycle.ts +30 -8
- package/dist/builtin/workflows/src/durable/dbos-local-postgres.ts +36 -3
- package/dist/builtin/workflows/src/durable/local-command.ts +68 -10
- package/dist/builtin/workflows/src/extension/companions.ts +1 -1
- package/dist/builtin/workflows/src/extension/dispatcher.ts +7 -1
- package/dist/builtin/workflows/src/extension/extension-factory.ts +2 -2
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1094 -298
- package/dist/builtin/workflows/src/extension/public-types.ts +2 -2
- package/dist/builtin/workflows/src/extension/render-result.ts +16 -2
- package/dist/builtin/workflows/src/extension/runtime.ts +8 -1
- package/dist/builtin/workflows/src/extension/workflow-request-abort.ts +15 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +4 -3
- package/dist/builtin/workflows/src/extension/workflow-tool-registration.ts +107 -13
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +22 -12
- package/dist/builtin/workflows/src/tui/widget.ts +25 -6
- package/dist/core/agent-session-auto-compaction.js +10 -10
- 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 +11 -13
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +1 -1
- 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 +5 -7
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-prompt.js +4 -4
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +4 -4
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +8 -34
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +4 -4
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +3 -10
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js +19 -3
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +0 -3
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +0 -12
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/modes/interactive-engine/remote-command-catalog.d.ts +1 -1
- package/dist/modes/interactive-engine/remote-command-catalog.js +1 -1
- package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -1
- package/docs/intercom.md +29 -27
- package/docs/settings.md +2 -2
- package/docs/subagents.md +18 -15
- package/docs/usage.md +0 -9
- package/docs/workflows.md +27 -10
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
- package/dist/builtin/subagents/prompts/gather-context-and-clarify.md +0 -27
- package/dist/builtin/subagents/prompts/parallel-cleanup.md +0 -61
- package/dist/builtin/subagents/prompts/parallel-context-build.md +0 -43
- package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +0 -47
- package/dist/builtin/subagents/prompts/parallel-research.md +0 -34
- package/dist/builtin/subagents/prompts/parallel-review.md +0 -47
- package/dist/builtin/subagents/prompts/review-loop.md +0 -39
- package/dist/builtin/subagents/src/extension/doctor.ts +0 -188
- package/dist/builtin/subagents/src/runs/inprocess/attempt-handles.ts +0 -104
- /package/dist/builtin/subagents/src/runs/foreground/{subagent-executor-resume.ts → subagent-executor-cwd.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { appendFileSync, existsSync, mkdirSync,
|
|
1
|
+
import { appendFileSync, existsSync, mkdirSync, statSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
3
3
|
import {
|
|
4
4
|
type AgentSession,
|
|
@@ -45,7 +45,6 @@ import {
|
|
|
45
45
|
type MaxOutputConfig,
|
|
46
46
|
truncateOutput,
|
|
47
47
|
} from "../../shared/types.js";
|
|
48
|
-
import { type InProcessAttemptResumeOutcome, registerInProcessAttempt } from "./attempt-handles.js";
|
|
49
48
|
import { type ChildModePolicy, resolveChildModePolicy } from "./child-policy.js";
|
|
50
49
|
import { createInProcessChildPromptBehavior, createInProcessChildSystemPromptTransform } from "./prompt-behavior.js";
|
|
51
50
|
|
|
@@ -673,9 +672,6 @@ export class SubagentControlRuntime {
|
|
|
673
672
|
readonly native: SubagentControl;
|
|
674
673
|
readonly parent: ParentContext;
|
|
675
674
|
readonly sessionRoot: string;
|
|
676
|
-
private readonly sessions = new Map<string, AgentSession>();
|
|
677
|
-
private readonly specs = new Map<string, ChildSpec>();
|
|
678
|
-
private readonly sessionFiles = new Map<string, string>();
|
|
679
675
|
private readonly runningAttempts = new Map<number, RunningAttempt>();
|
|
680
676
|
private readonly attemptTokens = new Map<string, number>();
|
|
681
677
|
private readonly attemptTerminators = new Map<string, (cause: TerminationCauseName) => Promise<void>>();
|
|
@@ -713,7 +709,6 @@ export class SubagentControlRuntime {
|
|
|
713
709
|
? dirname(spec.sessionFile)
|
|
714
710
|
: sessionDirectory(this.sessionRoot, identity.path);
|
|
715
711
|
mkdirSync(sessionDir, { recursive: true });
|
|
716
|
-
this.specs.set(identity.path, spec);
|
|
717
712
|
return {
|
|
718
713
|
admitted: AdmittedChild.create({
|
|
719
714
|
identity,
|
|
@@ -896,10 +891,9 @@ export class SubagentControlRuntime {
|
|
|
896
891
|
})
|
|
897
892
|
).session,
|
|
898
893
|
};
|
|
894
|
+
await created.session.extensionRunner.emit({ type: "session_start", reason: "startup" });
|
|
899
895
|
}
|
|
900
896
|
session = created.session;
|
|
901
|
-
if (session.sessionFile) this.sessionFiles.set(admitted.identity.path, session.sessionFile);
|
|
902
|
-
this.sessions.set(admitted.identity.path, session);
|
|
903
897
|
const initialModelId = modelIdForSession(session) ?? candidateModelId;
|
|
904
898
|
effectiveModelId = initialModelId;
|
|
905
899
|
effectiveThinking =
|
|
@@ -1070,7 +1064,6 @@ export class SubagentControlRuntime {
|
|
|
1070
1064
|
} catch {
|
|
1071
1065
|
// Session teardown must not replace the attempt result.
|
|
1072
1066
|
}
|
|
1073
|
-
this.sessions.delete(admitted.identity.path);
|
|
1074
1067
|
if (this.attemptTokens.get(admitted.identity.path) === token)
|
|
1075
1068
|
this.attemptTokens.delete(admitted.identity.path);
|
|
1076
1069
|
if (this.attemptTerminators.get(admitted.identity.path) === terminate)
|
|
@@ -1142,56 +1135,6 @@ export class SubagentControlRuntime {
|
|
|
1142
1135
|
return running.child.identity.path;
|
|
1143
1136
|
}
|
|
1144
1137
|
|
|
1145
|
-
reloadColdChild(pathValue: string, message: string): AdmittedResult {
|
|
1146
|
-
let sessionDir: string;
|
|
1147
|
-
try {
|
|
1148
|
-
sessionDir = sessionDirectory(this.sessionRoot, pathValue);
|
|
1149
|
-
} catch (error) {
|
|
1150
|
-
return {
|
|
1151
|
-
refusal: {
|
|
1152
|
-
kind: "invalidCwd",
|
|
1153
|
-
reason: error instanceof Error ? error.message : String(error),
|
|
1154
|
-
},
|
|
1155
|
-
};
|
|
1156
|
-
}
|
|
1157
|
-
const identity = this.native.listChildren().find((child) => child.path === pathValue);
|
|
1158
|
-
if (!identity)
|
|
1159
|
-
return {
|
|
1160
|
-
refusal: { kind: "unknownAgent", reason: "unknown child identity" },
|
|
1161
|
-
};
|
|
1162
|
-
const sessionFile = this.sessionFiles.get(pathValue) ?? this.findSessionFile(sessionDir);
|
|
1163
|
-
if (!sessionFile)
|
|
1164
|
-
return {
|
|
1165
|
-
refusal: {
|
|
1166
|
-
kind: "invalidCwd",
|
|
1167
|
-
reason: "child session file is missing",
|
|
1168
|
-
},
|
|
1169
|
-
};
|
|
1170
|
-
sessionDir = dirname(sessionFile);
|
|
1171
|
-
const native = this.native.reloadColdChild(pathValue, message);
|
|
1172
|
-
if (!native.child) return refusal(native);
|
|
1173
|
-
const previous = this.specs.get(pathValue);
|
|
1174
|
-
if (!previous)
|
|
1175
|
-
return {
|
|
1176
|
-
refusal: {
|
|
1177
|
-
kind: "unknownAgent",
|
|
1178
|
-
reason: "child policy is not resident",
|
|
1179
|
-
},
|
|
1180
|
-
};
|
|
1181
|
-
const spec: ChildSpec = { ...previous, task: message };
|
|
1182
|
-
this.specs.set(pathValue, spec);
|
|
1183
|
-
return {
|
|
1184
|
-
admitted: AdmittedChild.create({
|
|
1185
|
-
identity: native.child,
|
|
1186
|
-
spec,
|
|
1187
|
-
policy: { ...this.policyFor(spec, native.child.depth) },
|
|
1188
|
-
sessionDir,
|
|
1189
|
-
sessionFile,
|
|
1190
|
-
control: this,
|
|
1191
|
-
}),
|
|
1192
|
-
};
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
1138
|
getChildMetadata(pathValue: string): ChildRuntimeMetadata | undefined {
|
|
1196
1139
|
const running = [...this.runningAttempts.values()].find(
|
|
1197
1140
|
(attempt) =>
|
|
@@ -1209,34 +1152,6 @@ export class SubagentControlRuntime {
|
|
|
1209
1152
|
};
|
|
1210
1153
|
}
|
|
1211
1154
|
|
|
1212
|
-
/** Expose a direct child's live attempt so `interrupt`/`resume` can reach it by run id or path. */
|
|
1213
|
-
registerAttempt(runId: string, running: RunningAttempt, candidate: ModelCandidate): void {
|
|
1214
|
-
registerInProcessAttempt({
|
|
1215
|
-
runId,
|
|
1216
|
-
path: running.child.identity.path,
|
|
1217
|
-
status: () => running.status,
|
|
1218
|
-
interrupt: () => this.terminateChildAttempt(running, "interrupt"),
|
|
1219
|
-
resume: async (message): Promise<InProcessAttemptResumeOutcome> => {
|
|
1220
|
-
const admission = this.reloadColdChild(running.child.identity.path, message);
|
|
1221
|
-
if (!admission.admitted) {
|
|
1222
|
-
throw new Error(admission.refusal?.reason ?? "child cold reload was refused");
|
|
1223
|
-
}
|
|
1224
|
-
const neverAbort = new AbortController().signal;
|
|
1225
|
-
const resumed = this.startAttempt(admission.admitted, candidate, {
|
|
1226
|
-
abort: neverAbort,
|
|
1227
|
-
interrupt: neverAbort,
|
|
1228
|
-
});
|
|
1229
|
-
const outcome = await resumed.promise;
|
|
1230
|
-
return {
|
|
1231
|
-
status: outcome.status,
|
|
1232
|
-
path: outcome.path,
|
|
1233
|
-
sessionFile: outcome.sessionFile,
|
|
1234
|
-
envelope: outcome.envelope,
|
|
1235
|
-
};
|
|
1236
|
-
},
|
|
1237
|
-
});
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
1155
|
async terminateChildAttempt(running: RunningAttempt, cause: TerminationCauseName): Promise<void> {
|
|
1241
1156
|
if (running.status !== "running" && running.status !== "continued") return;
|
|
1242
1157
|
await running.terminate?.(cause);
|
|
@@ -1285,50 +1200,11 @@ export class SubagentControlRuntime {
|
|
|
1285
1200
|
await this.terminateChildAttempt(running, "interrupt");
|
|
1286
1201
|
return true;
|
|
1287
1202
|
}
|
|
1288
|
-
async resumeChild(
|
|
1289
|
-
pathValue: string,
|
|
1290
|
-
message: string,
|
|
1291
|
-
candidate: ModelCandidate,
|
|
1292
|
-
signals: AttemptSignals = {
|
|
1293
|
-
abort: new AbortController().signal,
|
|
1294
|
-
interrupt: new AbortController().signal,
|
|
1295
|
-
},
|
|
1296
|
-
): Promise<AttemptOutcome> {
|
|
1297
|
-
const admission = this.reloadColdChild(pathValue, message);
|
|
1298
|
-
if (!admission.admitted) {
|
|
1299
|
-
const reason = admission.refusal?.reason ?? "cold child reload was refused";
|
|
1300
|
-
return {
|
|
1301
|
-
status: "error",
|
|
1302
|
-
cause: reason,
|
|
1303
|
-
stats: { ...EMPTY_STATS, sessionId: pathValue },
|
|
1304
|
-
path: pathValue,
|
|
1305
|
-
envelope: boundedEnvelope(reason),
|
|
1306
|
-
};
|
|
1307
|
-
}
|
|
1308
|
-
const running = this.startAttempt(admission.admitted, candidate, signals);
|
|
1309
|
-
return running.promise;
|
|
1310
|
-
}
|
|
1311
1203
|
|
|
1312
1204
|
subscribe(pathValue: string, callback: (status: ChildStatus) => void): void {
|
|
1313
1205
|
this.native.subscribeChildStatus(pathValue, callback);
|
|
1314
1206
|
}
|
|
1315
1207
|
|
|
1316
|
-
private policyFor(spec: ChildSpec, depth: number): ChildPolicy {
|
|
1317
|
-
return {
|
|
1318
|
-
...resolveChildModePolicy(spec),
|
|
1319
|
-
cwd: spec.cwd,
|
|
1320
|
-
tools: spec.tools ?? spec.agent.tools,
|
|
1321
|
-
excludedTools: spec.excludedTools,
|
|
1322
|
-
mcpDirectTools: spec.mcpDirectTools ?? spec.agent.mcpDirectTools,
|
|
1323
|
-
skills: [...(spec.skills ?? spec.agent.skills ?? [])],
|
|
1324
|
-
customTools: spec.customTools,
|
|
1325
|
-
model: spec.model,
|
|
1326
|
-
thinkingLevel: spec.thinkingLevel ?? (spec.agent.thinking as ChildPolicy["thinkingLevel"]),
|
|
1327
|
-
intercomGroup: spec.parent?.intercomGroup,
|
|
1328
|
-
depth,
|
|
1329
|
-
};
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
1208
|
private async terminateRunningAttempt(running: RunningAttempt, cause: TerminationCauseName): Promise<void> {
|
|
1333
1209
|
const terminate = this.attemptTerminators.get(running.child.identity.path);
|
|
1334
1210
|
if (terminate) {
|
|
@@ -1346,17 +1222,6 @@ export class SubagentControlRuntime {
|
|
|
1346
1222
|
// The runner's signal path owns the race with terminal completion.
|
|
1347
1223
|
}
|
|
1348
1224
|
}
|
|
1349
|
-
|
|
1350
|
-
private findSessionFile(sessionDir: string): string | undefined {
|
|
1351
|
-
try {
|
|
1352
|
-
const entry = readdirSync(sessionDir, { withFileTypes: true }).find(
|
|
1353
|
-
(candidate) => candidate.isFile() && candidate.name.endsWith(".jsonl"),
|
|
1354
|
-
);
|
|
1355
|
-
return entry ? join(sessionDir, entry.name) : undefined;
|
|
1356
|
-
} catch {
|
|
1357
|
-
return undefined;
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
1225
|
}
|
|
1361
1226
|
|
|
1362
1227
|
export function createSubagentControl(parent: ParentContext, sessionRoot?: string): SubagentControlRuntime {
|
|
@@ -1398,10 +1263,6 @@ export function continue_detached(
|
|
|
1398
1263
|
return control.continueDetached(running, reason);
|
|
1399
1264
|
}
|
|
1400
1265
|
|
|
1401
|
-
export function reload_cold_child(control: SubagentControlRuntime, pathValue: string, message: string): AdmittedResult {
|
|
1402
|
-
return control.reloadColdChild(pathValue, message);
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
1266
|
export function terminate_child_attempt(
|
|
1406
1267
|
control: SubagentControlRuntime,
|
|
1407
1268
|
running: RunningAttempt,
|
|
@@ -59,4 +59,12 @@ export function aggregateParallelOutputs(
|
|
|
59
59
|
.join("\n\n");
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
export function formatParallelResultContent(
|
|
63
|
+
results: ParallelTaskResult[],
|
|
64
|
+
headerFormat: (index: number, agent: string) => string,
|
|
65
|
+
): string {
|
|
66
|
+
const ok = results.filter((result) => result.status === "ok").length;
|
|
67
|
+
return `${ok}/${results.length} succeeded\n\n${aggregateParallelOutputs(results, headerFormat)}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
62
70
|
export const MAX_PARALLEL_CONCURRENCY = 4;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ActivityState } from "./types.js";
|
|
2
2
|
|
|
3
|
-
type StepStatus = "pending" | "running" | "complete" | "completed" | "failed" | "
|
|
3
|
+
type StepStatus = "pending" | "running" | "complete" | "completed" | "failed" | "interrupted";
|
|
4
4
|
type StepStatusLike = { status: StepStatus };
|
|
5
5
|
|
|
6
6
|
function formatActivityAge(ms: number): string {
|
|
@@ -41,10 +41,10 @@ export function formatParallelOutcome(
|
|
|
41
41
|
const running = steps.filter((step) => step.status === "running").length;
|
|
42
42
|
const done = steps.filter((step) => isCompletedStepStatus(step.status)).length;
|
|
43
43
|
const failed = steps.filter((step) => step.status === "failed").length;
|
|
44
|
-
const
|
|
44
|
+
const interrupted = steps.filter((step) => step.status === "interrupted").length;
|
|
45
45
|
const parts = [`${done}/${total} done`];
|
|
46
46
|
if (options.showRunning !== false && running > 0) parts.unshift(formatAgentRunningLabel(running));
|
|
47
47
|
if (failed > 0) parts.push(`${failed} failed`);
|
|
48
|
-
if (
|
|
48
|
+
if (interrupted > 0) parts.push(`${interrupted} interrupted`);
|
|
49
49
|
return parts.join(" · ");
|
|
50
50
|
}
|
|
@@ -41,6 +41,7 @@ export interface IntercomEventBus {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export const INTERCOM_DETACH_REQUEST_EVENT = "pi-intercom:detach-request";
|
|
44
|
+
export const PARENT_ASK_HANDOFF_REQUEST_EVENT = "subagent:parent-ask-handoff-request";
|
|
44
45
|
export const SUBAGENT_COMPLETE_EVENT = "subagent:complete";
|
|
45
46
|
export const INTERCOM_DETACH_RESPONSE_EVENT = "pi-intercom:detach-response";
|
|
46
47
|
export const SUBAGENT_CONTROL_EVENT = "subagent:control-event";
|
|
@@ -49,6 +50,44 @@ export const SUBAGENT_RESULT_INTERCOM_EVENT = "subagent:result-intercom";
|
|
|
49
50
|
export const SUBAGENT_TERMINAL_ORDERING_BARRIER_EVENT = "subagent:terminal-ordering-barrier";
|
|
50
51
|
export const SUBAGENT_RESULT_INTERCOM_DELIVERY_EVENT = "subagent:result-intercom-delivery";
|
|
51
52
|
|
|
53
|
+
export type ParentAskKind = "decision" | "interview" | "intercom";
|
|
54
|
+
|
|
55
|
+
export interface ParentAskInterviewQuestion extends Record<string, unknown> {
|
|
56
|
+
id: string;
|
|
57
|
+
type: "single" | "multi" | "text" | "image" | "info";
|
|
58
|
+
question: string;
|
|
59
|
+
options?: unknown[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ParentAskInterviewRequest extends Record<string, unknown> {
|
|
63
|
+
title?: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
questions: ParentAskInterviewQuestion[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ParentAskAttachment {
|
|
69
|
+
type: "file" | "snippet" | "context";
|
|
70
|
+
name: string;
|
|
71
|
+
content: string;
|
|
72
|
+
language?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface ParentAskHandoffRequest {
|
|
76
|
+
runId: string;
|
|
77
|
+
index: number;
|
|
78
|
+
agent: string;
|
|
79
|
+
childIntercomTarget: string;
|
|
80
|
+
orchestratorTarget: string;
|
|
81
|
+
kind: ParentAskKind;
|
|
82
|
+
question: string;
|
|
83
|
+
attachments?: ParentAskAttachment[];
|
|
84
|
+
interview?: ParentAskInterviewRequest;
|
|
85
|
+
resolvedTargetId?: string;
|
|
86
|
+
/** Original delegated task supplied by the parent model for a fresh-child handoff. */
|
|
87
|
+
taskContext?: string;
|
|
88
|
+
claimed: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
52
91
|
// ============================================================================
|
|
53
92
|
// Execution Options
|
|
54
93
|
// ============================================================================
|
|
@@ -64,6 +103,8 @@ export interface RunSyncOptions {
|
|
|
64
103
|
intercomDetachSignal?: AbortSignal;
|
|
65
104
|
/** Releases every active foreground sibling only after this exact child accepts a detach commit. */
|
|
66
105
|
onIntercomDetachCommit?: () => void;
|
|
106
|
+
/** Claims a blocking ask from this exact child and ends it with a fresh-child handoff. */
|
|
107
|
+
onParentAskHandoff?: (request: ParentAskHandoffRequest) => void;
|
|
67
108
|
onUpdate?: (r: AgentToolResult<Details>) => void;
|
|
68
109
|
onControlEvent?: (event: ControlEvent) => void;
|
|
69
110
|
controlConfig?: ResolvedControlConfig;
|
|
@@ -7,29 +7,21 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { ExtensionContext } from "@bastani/atomic";
|
|
10
|
-
import type {
|
|
10
|
+
import type { ParentAskHandoffRequest } from "./types-config.js";
|
|
11
11
|
|
|
12
|
-
export interface
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
result?: SingleResult;
|
|
12
|
+
export interface ForegroundParentAskHandoff {
|
|
13
|
+
askingChildIndex: number;
|
|
14
|
+
releasedChildIndices: number[];
|
|
15
|
+
unlaunchedChildIndices: number[];
|
|
16
|
+
request: ParentAskHandoffRequest;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
runId: string;
|
|
22
|
-
mode: SubagentRunMode;
|
|
23
|
-
cwd: string;
|
|
24
|
-
updatedAt: number;
|
|
25
|
-
children: ForegroundResumeChild[];
|
|
26
|
-
}
|
|
19
|
+
import type { ActivityState, SubagentRunMode } from "./types-results.js";
|
|
27
20
|
|
|
28
21
|
export interface SubagentState {
|
|
29
22
|
baseCwd: string;
|
|
30
23
|
currentSessionId: string | null;
|
|
31
24
|
subagentInProgress?: boolean;
|
|
32
|
-
foregroundRuns?: Map<string, ForegroundResumeRun>;
|
|
33
25
|
foregroundControls: Map<
|
|
34
26
|
string,
|
|
35
27
|
{
|
|
@@ -91,7 +91,7 @@ export interface ControlEvent {
|
|
|
91
91
|
recentFailureSummary?: string;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export type SubagentResultStatus = "completed" | "failed" | "
|
|
94
|
+
export type SubagentResultStatus = "completed" | "failed" | "interrupted" | "detached";
|
|
95
95
|
export type SubagentRunMode = "single" | "parallel";
|
|
96
96
|
|
|
97
97
|
export interface SubagentResultIntercomChild {
|
|
@@ -220,6 +220,8 @@ export interface Details {
|
|
|
220
220
|
controlEvents?: ControlEvent[];
|
|
221
221
|
progress?: AgentProgress[];
|
|
222
222
|
totalSteps?: number;
|
|
223
|
+
/** Parent ask ended the current child and returned a fresh-subagent handoff. */
|
|
224
|
+
parentAskYielded?: boolean;
|
|
223
225
|
progressSummary?: ProgressSummary;
|
|
224
226
|
artifacts?: {
|
|
225
227
|
dir: string;
|
|
@@ -81,17 +81,7 @@ export const SLASH_SUBAGENT_STARTED_EVENT = "subagent:slash:started";
|
|
|
81
81
|
export const SLASH_SUBAGENT_RESPONSE_EVENT = "subagent:slash:response";
|
|
82
82
|
export const SLASH_SUBAGENT_UPDATE_EVENT = "subagent:slash:update";
|
|
83
83
|
export const SLASH_SUBAGENT_CANCEL_EVENT = "subagent:slash:cancel";
|
|
84
|
-
export const SUBAGENT_ACTIONS = [
|
|
85
|
-
"list",
|
|
86
|
-
"get",
|
|
87
|
-
"create",
|
|
88
|
-
"update",
|
|
89
|
-
"delete",
|
|
90
|
-
"status",
|
|
91
|
-
"interrupt",
|
|
92
|
-
"resume",
|
|
93
|
-
"doctor",
|
|
94
|
-
] as const;
|
|
84
|
+
export const SUBAGENT_ACTIONS = ["list", "get", "create", "update", "delete", "status", "interrupt"] as const;
|
|
95
85
|
|
|
96
86
|
export const DEFAULT_FORK_PREAMBLE =
|
|
97
87
|
"You are a delegated subagent running from a fork of the parent session. " +
|