@selesai/code 0.8.5 → 0.8.7
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 +28 -0
- package/dist/core/agent-session.js +13 -1
- package/dist/core/extensions/types.d.ts +2 -0
- package/dist/core/provider-composer.js +17 -4
- package/dist/core/settings-manager.d.ts +2 -0
- package/dist/core/settings-manager.js +3 -0
- package/dist/core/system-prompt.js +2 -8
- package/dist/core/system-prompt.test.js +6 -0
- package/dist/core/tools/index.d.ts +1 -0
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/schema-prune.d.ts +16 -0
- package/dist/core/tools/schema-prune.js +39 -0
- package/dist/core/tools/schema-prune.test.d.ts +1 -0
- package/dist/core/tools/schema-prune.test.js +111 -0
- package/dist/defaults/models.json +5 -0
- package/dist/defaults/settings.json +1 -0
- package/dist/extensions/agent-browser.test.ts +178 -2
- package/dist/extensions/agent-browser.ts +2 -0
- package/dist/extensions/copy-turn.test.ts +229 -0
- package/dist/extensions/copy-turn.ts +11 -0
- package/dist/extensions/grep-app/index.test.ts +356 -1
- package/dist/extensions/grep-app/index.ts +6 -1
- package/dist/extensions/handoff-new.test.ts +351 -161
- package/dist/extensions/handoff-new.ts +3 -0
- package/dist/extensions/inline-skills.test.ts +93 -0
- package/dist/extensions/inline-skills.ts +3 -0
- package/dist/extensions/model-prompt-injector/config.json +10 -0
- package/dist/extensions/model-prompt-injector/index.test.ts +112 -0
- package/dist/extensions/model-prompt-injector/index.ts +151 -0
- package/dist/extensions/package.json +1 -0
- package/dist/extensions/pi-subagents/CHANGELOG.md +158 -90
- package/dist/extensions/pi-subagents/UPSTREAM-V0.50-MAPPING.md +172 -0
- package/dist/extensions/pi-subagents/agents/builder.md +5 -2
- package/dist/extensions/pi-subagents/agents/commentator.md +1 -1
- package/dist/extensions/pi-subagents/agents/oracle.md +7 -5
- package/dist/extensions/pi-subagents/agents/reviewer.md +2 -2
- package/dist/extensions/pi-subagents/agents/scout.md +1 -1
- package/dist/extensions/pi-subagents/agents/worker.md +1 -1
- package/dist/extensions/pi-subagents/docs/configuration.md +78 -11
- package/dist/extensions/pi-subagents/docs/extension-api.md +36 -0
- package/dist/extensions/pi-subagents/docs/missions.md +5 -3
- package/dist/extensions/pi-subagents/docs/models.md +1 -1
- package/dist/extensions/pi-subagents/docs/observability.md +42 -2
- package/dist/extensions/pi-subagents/docs/tool-reference.md +20 -3
- package/dist/extensions/pi-subagents/docs/workflows.md +4 -4
- package/dist/extensions/pi-subagents/install.mjs +2 -2
- package/dist/extensions/pi-subagents/package-lock.json +1470 -1472
- package/dist/extensions/pi-subagents/package.json +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +5 -4
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +16 -15
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +5 -5
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +46 -26
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +2 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +37 -12
- package/dist/extensions/pi-subagents/src/api/external-runs.ts +174 -84
- package/dist/extensions/pi-subagents/src/api/preflight.ts +13 -7
- package/dist/extensions/pi-subagents/src/extension/config.ts +59 -0
- package/dist/extensions/pi-subagents/src/extension/index.ts +146 -23
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +34 -6
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +5 -1
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +31 -30
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +10 -9
- package/dist/extensions/pi-subagents/src/inspectors/herdr/actions.ts +13 -8
- package/dist/extensions/pi-subagents/src/inspectors/herdr/inspector-runner.ts +16 -3
- package/dist/extensions/pi-subagents/src/inspectors/herdr/project-panes.ts +2 -6
- package/dist/extensions/pi-subagents/src/inspectors/herdr/shell-command.ts +16 -0
- package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +5 -4
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +19 -42
- package/dist/extensions/pi-subagents/src/missions/goal-driver.ts +3 -1
- package/dist/extensions/pi-subagents/src/missions/store.ts +8 -3
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +82 -25
- package/dist/extensions/pi-subagents/src/runs/background/active-run-index.ts +71 -1
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +73 -43
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +17 -6
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +14 -6
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +277 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +11 -3
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +2 -2
- package/dist/extensions/pi-subagents/src/runs/background/completion-replay.ts +11 -1
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +21 -6
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +5 -2
- package/dist/extensions/pi-subagents/src/runs/background/result-files.ts +437 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +224 -42
- package/dist/extensions/pi-subagents/src/runs/background/resume-guidance.ts +27 -7
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +76 -19
- package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +35 -26
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +108 -9
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +54 -28
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +27 -13
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +298 -33
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +5 -2
- package/dist/extensions/pi-subagents/src/runs/background/wait-subscriptions.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/async-dismiss-action.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +16 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +219 -15
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +7 -4
- package/dist/extensions/pi-subagents/src/runs/foreground/prompt-audit.ts +4 -3
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +368 -50
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +107 -1
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-runner.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/shared/llm-intent-arbiter.ts +39 -23
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +16 -2
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +66 -62
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +376 -0
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +15 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +1 -9
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +12 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-timeout.ts +95 -0
- package/dist/extensions/pi-subagents/src/shared/agent-stream-options.ts +5 -0
- package/dist/extensions/pi-subagents/src/shared/artifacts.ts +0 -4
- package/dist/extensions/pi-subagents/src/shared/display-text.ts +50 -0
- package/dist/extensions/pi-subagents/src/shared/node-executable.ts +21 -0
- package/dist/extensions/pi-subagents/src/shared/session-lineage.ts +71 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +66 -4
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +34 -25
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +4 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +160 -45
- package/dist/extensions/pi-subagents/src/tui/fleet-transcript.ts +1 -48
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +129 -17
- package/dist/extensions/pi-subagents/src/tui/render.ts +122 -44
- package/dist/extensions/pi-subagents/src/watchdog/permission-arbiter.ts +2 -1
- package/dist/extensions/pi-subagents/src/watchdog/review.ts +4 -3
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +10 -2
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +272 -76
- package/dist/extensions/pi-subagents/src/workflows/workflow-auto-relaunch.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/types.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +68 -9
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +27 -1
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +49 -0
- package/dist/extensions/pi-subagents/test/integration/external-cli-runner.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +26 -1
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +144 -0
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +26 -0
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +369 -98
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +111 -78
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +49 -1
- package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +12 -0
- package/dist/extensions/pi-subagents/test/support/node-command.ts +15 -0
- package/dist/extensions/pi-subagents/test/unit/active-async-capacity.test.ts +50 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +28 -0
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +61 -0
- package/dist/extensions/pi-subagents/test/unit/agent-stream-options.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +76 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +2 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-snapshot.test.ts +162 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +209 -10
- package/dist/extensions/pi-subagents/test/unit/completion-replay.test.ts +41 -1
- package/dist/extensions/pi-subagents/test/unit/external-runs.test.ts +135 -42
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +252 -1
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +192 -6
- package/dist/extensions/pi-subagents/test/unit/handoff-adoption.test.ts +103 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector-bootstrap.test.ts +32 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-shell-command.test.ts +59 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +91 -0
- package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +23 -4
- package/dist/extensions/pi-subagents/test/unit/llm-intent-arbiter.test.ts +56 -1
- package/dist/extensions/pi-subagents/test/unit/mission-goal-driver.test.ts +67 -3
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +18 -0
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +25 -2
- package/dist/extensions/pi-subagents/test/unit/node-executable.test.ts +26 -0
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +8 -0
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +348 -0
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +5 -2
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +6 -1
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +92 -0
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +175 -0
- package/dist/extensions/pi-subagents/test/unit/retained-children.test.ts +127 -17
- package/dist/extensions/pi-subagents/test/unit/run-id-resolver.test.ts +44 -0
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +247 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +107 -2
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +5 -8
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +456 -4
- package/dist/extensions/pi-subagents/test/unit/session-lineage.test.ts +73 -0
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +128 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +28 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +16 -7
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +15 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +79 -15
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +12 -12
- package/dist/extensions/pi-subagents/test/unit/tool-timeout.test.ts +109 -0
- package/dist/extensions/pi-subagents/test/unit/wait-subscriptions.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-auto-relaunch.test.ts +45 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +94 -1
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +42 -2
- package/dist/extensions/ponytail/index.js +11 -0
- package/dist/extensions/ponytail/ponytail-config.cjs +2 -0
- package/dist/extensions/ponytail/ponytail-instructions.cjs +6 -0
- package/dist/extensions/ponytail/test/extension.test.js +274 -140
- package/dist/extensions/ponytail/test/helpers.test.js +280 -92
- package/dist/extensions/question/index.ts +33 -0
- package/dist/extensions/question/question-list.ts +28 -0
- package/dist/extensions/question/row-layout.ts +3 -0
- package/dist/extensions/question/tests/batch.test.ts +103 -65
- package/dist/extensions/question/tests/exp.test.ts +70 -0
- package/dist/extensions/question/tests/exp2.test.ts +59 -0
- package/dist/extensions/question/tests/exp3.test.ts +47 -0
- package/dist/extensions/question/tests/helpers.test.ts +75 -35
- package/dist/extensions/question/tests/question-list.test.ts +640 -198
- package/dist/extensions/question/tests/row-layout.test.ts +193 -114
- package/dist/extensions/question/tests/schemas.test.ts +42 -19
- package/dist/extensions/question/tests/selection-mode.test.ts +54 -0
- package/dist/extensions/question/tests/shortcuts.test.ts +106 -84
- package/dist/extensions/question/tests/wizard.test.ts +771 -50
- package/dist/extensions/question/tests/zz-ig3.test.ts +20 -0
- package/dist/extensions/question/tests/zz-probe.test.ts +29 -0
- package/dist/extensions/rtk.test.ts +180 -1
- package/dist/extensions/tokenin-onboarding.ts +3 -0
- package/dist/extensions/undo.test.ts +720 -0
- package/dist/extensions/undo.ts +6 -0
- package/dist/extensions/web-agent-onboarding.test.ts +415 -0
- package/dist/extensions/workflow/extension.ts +3 -3
- package/dist/extensions/workflow/modes.ts +41 -19
- package/dist/skills/pi-subagents/SKILL.md +1 -1
- package/dist/skills/pi-subagents/references/constraints-and-recipes.md +5 -4
- package/dist/skills/pi-subagents/references/execution-controls.md +16 -15
- package/dist/skills/pi-subagents/references/management-authoring-rpc.md +5 -5
- package/dist/skills/pi-subagents/references/prompting-and-roles.md +46 -26
- package/docs/plans/workflow-autoloop-reference.md +1 -2
- package/docs/plans/workflow-handoff-carryover.md +108 -0
- package/docs/settings.md +6 -0
- package/package.json +4 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the chain of session identities whose workflow estate the current
|
|
5
|
+
* session should adopt. Session files record their parent in the header's
|
|
6
|
+
* `parentSession` field, so a fresh session created by handoff/new/fork can
|
|
7
|
+
* walk back to every predecessor and re-attach its persisted async runs,
|
|
8
|
+
* results, retained children, and wait subscriptions.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface SessionLineageInput {
|
|
12
|
+
sessionManager: {
|
|
13
|
+
getSessionFile(): string | null | undefined;
|
|
14
|
+
getHeader?(): { parentSession?: string | null } | null;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SessionLineageOptions {
|
|
19
|
+
/** Maximum number of session identities retained in the lineage. Defaults to 8. */
|
|
20
|
+
depth?: number;
|
|
21
|
+
/** Explicit parent session file (e.g. SessionStartEvent.previousSessionFile). */
|
|
22
|
+
parentHint?: string | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const MAX_HEADER_BYTES = 2048;
|
|
26
|
+
|
|
27
|
+
function readParentSessionHeader(sessionFile: string): string | undefined {
|
|
28
|
+
let text: string;
|
|
29
|
+
try {
|
|
30
|
+
const fd = fs.openSync(sessionFile, "r");
|
|
31
|
+
try {
|
|
32
|
+
const buffer = Buffer.alloc(MAX_HEADER_BYTES);
|
|
33
|
+
const read = fs.readSync(fd, buffer, 0, buffer.length, 0);
|
|
34
|
+
text = buffer.subarray(0, read).toString("utf-8");
|
|
35
|
+
} finally {
|
|
36
|
+
fs.closeSync(fd);
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const newline = text.indexOf("\n");
|
|
42
|
+
const line = newline >= 0 ? text.slice(0, newline) : text;
|
|
43
|
+
if (!line.trim()) return undefined;
|
|
44
|
+
try {
|
|
45
|
+
const header = JSON.parse(line) as { type?: unknown; parentSession?: unknown };
|
|
46
|
+
if (header.type !== "session") return undefined;
|
|
47
|
+
return typeof header.parentSession === "string" && header.parentSession ? header.parentSession : undefined;
|
|
48
|
+
} catch {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function resolveSessionLineage(input: SessionLineageInput, options: SessionLineageOptions = {}): string[] {
|
|
54
|
+
const depth = Math.max(1, Math.floor(options.depth ?? 8));
|
|
55
|
+
const lineage: string[] = [];
|
|
56
|
+
const seen = new Set<string>();
|
|
57
|
+
const current = input.sessionManager.getSessionFile();
|
|
58
|
+
if (current) {
|
|
59
|
+
lineage.push(current);
|
|
60
|
+
seen.add(current);
|
|
61
|
+
}
|
|
62
|
+
let parent = options.parentHint ?? input.sessionManager.getHeader?.()?.parentSession;
|
|
63
|
+
if (!parent && current) parent = readParentSessionHeader(current);
|
|
64
|
+
while (parent && lineage.length < depth && !seen.has(parent)) {
|
|
65
|
+
if (!fs.existsSync(parent)) break;
|
|
66
|
+
lineage.push(parent);
|
|
67
|
+
seen.add(parent);
|
|
68
|
+
parent = readParentSessionHeader(parent);
|
|
69
|
+
}
|
|
70
|
+
return lineage;
|
|
71
|
+
}
|
|
@@ -215,7 +215,7 @@ export interface ControlEvent {
|
|
|
215
215
|
nestedRunId?: string;
|
|
216
216
|
nestingPath?: NestedRunAddress["path"];
|
|
217
217
|
message: string;
|
|
218
|
-
reason?: "idle" | "completion_guard" | "active_long_running" | "tool_failures" | "supervisor_request" | "time_threshold" | "turn_threshold" | "token_threshold";
|
|
218
|
+
reason?: "idle" | "completion_guard" | "active_long_running" | "tool_failures" | "supervisor_request" | "time_threshold" | "turn_threshold" | "token_threshold" | "tool_open_threshold";
|
|
219
219
|
turns?: number;
|
|
220
220
|
tokens?: number;
|
|
221
221
|
toolCount?: number;
|
|
@@ -528,6 +528,8 @@ export interface SteeringRecoveryDescriptor {
|
|
|
528
528
|
structuredOutputSchema?: JsonSchemaObject;
|
|
529
529
|
acceptance?: AcceptanceInput;
|
|
530
530
|
controlConfig?: ResolvedControlConfig;
|
|
531
|
+
/** Raw per-run bridge override. Omitted descriptors continue to use global config. */
|
|
532
|
+
intercomBridge?: IntercomBridgeConfig;
|
|
531
533
|
absoluteDeadlineAt?: number;
|
|
532
534
|
initialTurnBudget?: ResolvedTurnBudget;
|
|
533
535
|
initialToolBudget?: ResolvedToolBudget;
|
|
@@ -1029,6 +1031,7 @@ export interface Details {
|
|
|
1029
1031
|
controlEvents?: ControlEvent[];
|
|
1030
1032
|
steering?: SteerActionResult;
|
|
1031
1033
|
asyncId?: string;
|
|
1034
|
+
background?: boolean;
|
|
1032
1035
|
asyncDir?: string;
|
|
1033
1036
|
timeoutMs?: number;
|
|
1034
1037
|
deadlineAt?: number;
|
|
@@ -1086,7 +1089,7 @@ export interface Details {
|
|
|
1086
1089
|
trace: Array<{
|
|
1087
1090
|
operation: "run" | "status";
|
|
1088
1091
|
key: string;
|
|
1089
|
-
state: "started" | "completed" | "failed" | "reused";
|
|
1092
|
+
state: "started" | "completed" | "failed" | "detached" | "stopped" | "reused";
|
|
1090
1093
|
agent?: string;
|
|
1091
1094
|
runId?: string;
|
|
1092
1095
|
phase?: string;
|
|
@@ -1259,6 +1262,8 @@ export interface AsyncStartedEvent {
|
|
|
1259
1262
|
asyncDir?: string;
|
|
1260
1263
|
/** Parent-resolved launch directory, used as a trusted artifact root while this session is live. */
|
|
1261
1264
|
cwd?: string;
|
|
1265
|
+
/** Parent-resolved child session root, used only while this session owns the live run. */
|
|
1266
|
+
sessionRoot?: string;
|
|
1262
1267
|
pid?: number;
|
|
1263
1268
|
sessionId?: string;
|
|
1264
1269
|
mode?: SubagentRunMode;
|
|
@@ -1361,6 +1366,8 @@ export interface AsyncStatus {
|
|
|
1361
1366
|
pendingAppends?: number;
|
|
1362
1367
|
parallelGroups?: AsyncParallelGroupStatus[];
|
|
1363
1368
|
workflowGraph?: WorkflowGraphSnapshot;
|
|
1369
|
+
/** Auto-relaunch count when a workflow budget result triggered a fresh top-level run. */
|
|
1370
|
+
workflowRelaunchCount?: number;
|
|
1364
1371
|
checkpoint?: ChainCheckpointState;
|
|
1365
1372
|
processTerminal?: ProcessTerminalV1;
|
|
1366
1373
|
runFanoutBudget?: RunFanoutBudgetSnapshot;
|
|
@@ -1460,8 +1467,14 @@ export type AsyncJobStep = NonNullable<AsyncStatus["steps"]>[number] & {
|
|
|
1460
1467
|
export interface AsyncJobState {
|
|
1461
1468
|
asyncId: string;
|
|
1462
1469
|
asyncDir: string;
|
|
1470
|
+
/** True when the job was adopted from a previous session via lineage carry-over. */
|
|
1471
|
+
adopted?: boolean;
|
|
1472
|
+
/** Host tool-call id retained when it differs from the internal run id. */
|
|
1473
|
+
toolCallId?: string;
|
|
1463
1474
|
/** Parent-resolved launch directory retained for trusted live artifact lookup. */
|
|
1464
1475
|
cwd?: string;
|
|
1476
|
+
/** Parent-resolved child session root retained for trusted live transcript lookup. */
|
|
1477
|
+
sessionRoot?: string;
|
|
1465
1478
|
status: "queued" | "running" | "complete" | "failed" | "paused" | "stopped" | "rejected";
|
|
1466
1479
|
/** Short caller-facing task/goal shown in fleet surfaces when available. */
|
|
1467
1480
|
description?: string;
|
|
@@ -1654,6 +1667,12 @@ export interface ActiveAsyncCapacitySnapshot {
|
|
|
1654
1667
|
export interface SubagentState {
|
|
1655
1668
|
baseCwd: string;
|
|
1656
1669
|
currentSessionId: string | null;
|
|
1670
|
+
/** Ordered session identities (session file paths) whose workflow estate this session adopts, self first. */
|
|
1671
|
+
sessionLineage?: string[];
|
|
1672
|
+
/** Earliest result-file mtime eligible for adoption from lineage sessions (replay guard). */
|
|
1673
|
+
adoptedResultWindowStart?: number;
|
|
1674
|
+
/** Set when a session switch adopted live workflows; consumed on the first settled turn to inject a carry-over summary. */
|
|
1675
|
+
handoffResumePending?: boolean;
|
|
1657
1676
|
/** Runtime-owned artifact resolution inputs used by Fleet transcript targeting. */
|
|
1658
1677
|
artifactDirPreference?: ArtifactDirPreference;
|
|
1659
1678
|
/** Runtime authority snapshot used by optional inspector controls. */
|
|
@@ -1661,6 +1680,10 @@ export interface SubagentState {
|
|
|
1661
1680
|
/** Runtime mission-store snapshot used by optional inspector context. */
|
|
1662
1681
|
missionStoreConfig?: MissionStoreConfig;
|
|
1663
1682
|
parentSessionFile?: string | null;
|
|
1683
|
+
/** Extension-owned roots trusted for child session transcript reads. */
|
|
1684
|
+
trustedSessionRoots?: string[];
|
|
1685
|
+
/** Live async session roots created by this parent executor, keyed by run id. */
|
|
1686
|
+
liveAsyncSessionRoots?: Map<string, string>;
|
|
1664
1687
|
/** Last valid parent session model observed for this session; used when continuation contexts omit ctx.model. */
|
|
1665
1688
|
lastParentModel?: { provider: string; id: string };
|
|
1666
1689
|
subagentInProgress?: boolean;
|
|
@@ -1757,6 +1780,10 @@ export interface RunSyncOptions {
|
|
|
1757
1780
|
interruptSignal?: AbortSignal;
|
|
1758
1781
|
timeoutMs?: number;
|
|
1759
1782
|
deadlineAt?: number;
|
|
1783
|
+
/** Per-call per-tool timeout (ms), resolved with the agent/config/environment ladder at execution. */
|
|
1784
|
+
toolTimeoutMs?: number;
|
|
1785
|
+
/** Raw global config.toolTimeoutMs, used by the per-child resolver. */
|
|
1786
|
+
configToolTimeoutMs?: number;
|
|
1760
1787
|
turnBudget?: ResolvedTurnBudget;
|
|
1761
1788
|
usageBudget?: UsageBudgetConfig;
|
|
1762
1789
|
/** Enforce maxTurns + graceTurns as a hard model-turn boundary. */
|
|
@@ -1821,6 +1848,8 @@ export interface RunSyncOptions {
|
|
|
1821
1848
|
};
|
|
1822
1849
|
/** Private live callback for the exact child prompt after runtime acceptance injection. */
|
|
1823
1850
|
onEffectivePrompt?: (prompt: string) => void;
|
|
1851
|
+
/** Internal lifecycle hook for the observer shared across retries of one logical child. */
|
|
1852
|
+
onOrcaProgressTabCreated?: (tab: import("../runs/shared/orca-progress-tabs.ts").OrcaProgressTab) => void;
|
|
1824
1853
|
}
|
|
1825
1854
|
|
|
1826
1855
|
export type IntercomBridgeMode = "off" | "fork-only" | "always";
|
|
@@ -1882,8 +1911,22 @@ export const FLEET_KEYBINDING_ACTIONS = [
|
|
|
1882
1911
|
export type FleetKeybindingAction = typeof FLEET_KEYBINDING_ACTIONS[number];
|
|
1883
1912
|
export type FleetKeybindingsConfig = Partial<Record<FleetKeybindingAction, string[]>>;
|
|
1884
1913
|
|
|
1914
|
+
export interface OrcaProgressTabsConfig {
|
|
1915
|
+
/** Create one Orca terminal tab per running subagent. Experimental and opt-in. */
|
|
1916
|
+
enabled?: boolean;
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
export interface MainWindowRendererConfig {
|
|
1920
|
+
/** Unit of horizontal space in main chat subagent call/result rows. Omit to preserve current spacing. Set 0 for no extra padding. */
|
|
1921
|
+
horizontalSpacing?: number;
|
|
1922
|
+
/** Maximum collapsed rich-result rows. Expanded output is not capped. */
|
|
1923
|
+
compactResultMaxLines?: number;
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1885
1926
|
export interface ExtensionConfig {
|
|
1886
1927
|
asyncByDefault?: boolean;
|
|
1928
|
+
/** Optional shortcut that detaches the active foreground single-subagent run. */
|
|
1929
|
+
foregroundDetachShortcut?: string;
|
|
1887
1930
|
/** Show the Claude Code-style navigable fleet. Defaults to true. */
|
|
1888
1931
|
fleetView?: boolean;
|
|
1889
1932
|
/** Place the persistent FleetView above or below the editor. Defaults to belowEditor. */
|
|
@@ -1892,12 +1935,16 @@ export interface ExtensionConfig {
|
|
|
1892
1935
|
fleetKeybindings?: FleetKeybindingsConfig;
|
|
1893
1936
|
/** Show the under-editor async runs widget. Defaults to true, including when FleetView is enabled. */
|
|
1894
1937
|
asyncWidget?: boolean;
|
|
1895
|
-
/** Tool description variant registered for the parent-facing subagent tool. Defaults to
|
|
1938
|
+
/** Tool description variant registered for the parent-facing subagent tool. Defaults to compact. */
|
|
1896
1939
|
toolDescriptionMode?: ToolDescriptionMode;
|
|
1897
1940
|
/** Include legacy append-step and checkpoint controls in the registered tool schema. Defaults to false. */
|
|
1898
1941
|
legacyChainControls?: boolean;
|
|
1899
1942
|
/** Inline chat rendering for the subagent tool. Defaults to rich. */
|
|
1900
1943
|
inlineToolDisplay?: InlineToolDisplay;
|
|
1944
|
+
/** Density controls for the main chat subagent call/result renderer. */
|
|
1945
|
+
mainWindowRenderer?: MainWindowRendererConfig;
|
|
1946
|
+
/** Experimental observer: mirror each native subagent's progress into a new Orca tab. */
|
|
1947
|
+
orcaProgressTabs?: OrcaProgressTabsConfig;
|
|
1901
1948
|
forceTopLevelAsync?: boolean;
|
|
1902
1949
|
waitTool?: WaitToolConfig;
|
|
1903
1950
|
defaultSessionDir?: string;
|
|
@@ -1907,6 +1954,12 @@ export interface ExtensionConfig {
|
|
|
1907
1954
|
maxSubagentSpawnsPerSession?: number;
|
|
1908
1955
|
/** Cumulative logical-child cap for one top-level run tree. Defaults to 64. */
|
|
1909
1956
|
maxSubagentSpawnsPerRun?: number;
|
|
1957
|
+
/**
|
|
1958
|
+
* Max auto-relaunches when a scripted workflow ends with a fan-out budget
|
|
1959
|
+
* result before the goal is clean. Each relaunch is a fresh top-level run
|
|
1960
|
+
* with a new fan-out budget. Defaults to 12; 0 means unlimited.
|
|
1961
|
+
*/
|
|
1962
|
+
maxWorkflowAutoRelaunches?: number;
|
|
1910
1963
|
/** Optional active top-level async run cap per parent session. Unset or 0 means unlimited. */
|
|
1911
1964
|
maxActiveAsyncRunsPerSession?: number;
|
|
1912
1965
|
/** Global cap on simultaneously-running subagent tasks within a single run. Defaults to 20. */
|
|
@@ -1921,6 +1974,15 @@ export interface ExtensionConfig {
|
|
|
1921
1974
|
* Must be a positive integer; invalid values are ignored.
|
|
1922
1975
|
*/
|
|
1923
1976
|
timeoutMs?: number;
|
|
1977
|
+
/**
|
|
1978
|
+
* Optional hard per-tool-call timeout in milliseconds. Bounds a single
|
|
1979
|
+
* subagent tool call inside the child; the run-level timeout remains
|
|
1980
|
+
* authoritative. Known-fast built-in tools have a five-minute default when
|
|
1981
|
+
* this is undefined. Precedence: call param > agent frontmatter > this config >
|
|
1982
|
+
* SELESAI_SUBAGENT_TOOL_TIMEOUT_MS. Must be a positive integer; invalid values
|
|
1983
|
+
* are rejected with an error.
|
|
1984
|
+
*/
|
|
1985
|
+
toolTimeoutMs?: number;
|
|
1924
1986
|
control?: ControlConfig;
|
|
1925
1987
|
completionBatch?: CompletionBatchConfig;
|
|
1926
1988
|
turnBudget?: TurnBudgetConfig;
|
|
@@ -2044,7 +2106,7 @@ export const SLASH_SUBAGENT_CANCEL_EVENT = "subagent:slash:cancel";
|
|
|
2044
2106
|
export const POLL_INTERVAL_MS = 250;
|
|
2045
2107
|
export const MAX_WIDGET_JOBS = 4;
|
|
2046
2108
|
export const DEFAULT_SUBAGENT_MAX_DEPTH = 2;
|
|
2047
|
-
export const SUBAGENT_ACTIONS = ["list", "get", "models", "children.list", "guide", "create", "update", "delete", "eject", "disable", "enable", "reset", "mission.create", "mission.list", "mission.show", "mission.update", "mission.resolve-decision", "mission.attach-run", "mission.close", "worktree.discard", "refine", "refine.show", "refine.rollback", "inspector.open", "inspector.status", "inspector.close", "project.open", "project.status", "project.close", "status", "grant-spawn-budget", "interrupt", "resume", "steer", "stop", "dismiss", "append-step", "approve-checkpoint", "reject-checkpoint", "doctor", "watchdog.status", "watchdog.check", "watchdog.configure", "watchdog.recommend-model", "schedule.create", "schedule.list", "schedule.show", "schedule.history", "schedule.pause", "schedule.resume", "schedule.run", "schedule.run-due", "schedule.delete"] as const;
|
|
2109
|
+
export const SUBAGENT_ACTIONS = ["list", "get", "models", "children.list", "guide", "create", "update", "delete", "eject", "disable", "enable", "reset", "mission.create", "mission.list", "mission.show", "mission.update", "mission.resolve-decision", "mission.attach-run", "mission.close", "worktree.discard", "refine", "refine.show", "refine.rollback", "inspector.open", "inspector.status", "inspector.close", "project.open", "project.status", "project.close", "status", "debug.run", "grant-spawn-budget", "interrupt", "resume", "steer", "stop", "dismiss", "append-step", "approve-checkpoint", "reject-checkpoint", "doctor", "watchdog.status", "watchdog.check", "watchdog.configure", "watchdog.recommend-model", "schedule.create", "schedule.list", "schedule.show", "schedule.history", "schedule.pause", "schedule.resume", "schedule.run", "schedule.run-due", "schedule.delete"] as const;
|
|
2048
2110
|
|
|
2049
2111
|
export const DEFAULT_FORK_PREAMBLE =
|
|
2050
2112
|
"You are a delegated subagent running from a fork of the parent session. " +
|
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { keyText, type ExtensionAPI, type ExtensionContext } from "@selesai/code";
|
|
5
|
-
import { Key, matchesKey, truncateToWidth, type Component, type TUI } from "@earendil-works/pi-tui";
|
|
5
|
+
import { Key, matchesKey, truncateToWidth, type Component, type KeyId, type TUI } from "@earendil-works/pi-tui";
|
|
6
6
|
import { BUILTIN_AGENT_NAMES, discoverAgents } from "../agents/agents.ts";
|
|
7
7
|
import { registerInlineSubagentInvocation } from "./inline-subagents.ts";
|
|
8
8
|
import { resolveExistingReadPaths } from "../shared/settings.ts";
|
|
@@ -632,7 +632,7 @@ function slashRunWorkflowScript(key: string, child: Record<string, unknown>): st
|
|
|
632
632
|
export function registerSlashCommands(
|
|
633
633
|
pi: ExtensionAPI,
|
|
634
634
|
state: SubagentState,
|
|
635
|
-
options: { fleetKeybindings?: FleetKeybindingsConfig } = {},
|
|
635
|
+
options: { fleetKeybindings?: FleetKeybindingsConfig; foregroundDetachShortcut?: string } = {},
|
|
636
636
|
): void {
|
|
637
637
|
registerInlineSubagentInvocation(pi, state);
|
|
638
638
|
let fleetOpen = false;
|
|
@@ -743,33 +743,42 @@ export function registerSlashCommands(
|
|
|
743
743
|
handler: async (ctx) => showFleet(ctx),
|
|
744
744
|
});
|
|
745
745
|
|
|
746
|
+
const detachForegroundRun = (args: string, ctx: ExtensionContext): void => {
|
|
747
|
+
const id = args.trim();
|
|
748
|
+
let control: ReturnType<typeof selectForegroundDetachControl>;
|
|
749
|
+
try {
|
|
750
|
+
control = selectForegroundDetachControl(state, id);
|
|
751
|
+
} catch (error) {
|
|
752
|
+
ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
if (!control) {
|
|
756
|
+
ctx.ui.notify(id ? `No active foreground run found for '${id}'.` : "No active foreground single-subagent run to detach.", "info");
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
if (control.mode !== "single") {
|
|
760
|
+
ctx.ui.notify("/subagents-detach currently supports single-subagent runs only.", "error");
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
if (!control.detach?.()) {
|
|
764
|
+
ctx.ui.notify(`Foreground run ${control.runId} is not currently detachable.`, "info");
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
sendSlashText(pi, `Detached foreground run ${control.runId} without terminating its child. Use subagent({ action: "status", id: ${JSON.stringify(control.runId)} }) or subagent_wait({ id: ${JSON.stringify(control.runId)} }) to recover the eventual result. This does not daemonize the process or guarantee survival across Pi reload/restart.`);
|
|
768
|
+
};
|
|
769
|
+
|
|
746
770
|
pi.registerCommand("subagents-detach", {
|
|
747
771
|
description: "Detach the active foreground single-subagent run without terminating it",
|
|
748
|
-
handler: async (args, ctx) =>
|
|
749
|
-
const id = args.trim();
|
|
750
|
-
let control: ReturnType<typeof selectForegroundDetachControl>;
|
|
751
|
-
try {
|
|
752
|
-
control = selectForegroundDetachControl(state, id);
|
|
753
|
-
} catch (error) {
|
|
754
|
-
ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
755
|
-
return;
|
|
756
|
-
}
|
|
757
|
-
if (!control) {
|
|
758
|
-
ctx.ui.notify(id ? `No active foreground run found for '${id}'.` : "No active foreground single-subagent run to detach.", "info");
|
|
759
|
-
return;
|
|
760
|
-
}
|
|
761
|
-
if (control.mode !== "single") {
|
|
762
|
-
ctx.ui.notify("/subagents-detach currently supports single-subagent runs only.", "error");
|
|
763
|
-
return;
|
|
764
|
-
}
|
|
765
|
-
if (!control.detach?.()) {
|
|
766
|
-
ctx.ui.notify(`Foreground run ${control.runId} is not currently detachable.`, "info");
|
|
767
|
-
return;
|
|
768
|
-
}
|
|
769
|
-
sendSlashText(pi, `Detached foreground run ${control.runId} without terminating its child. Use subagent({ action: "status", id: ${JSON.stringify(control.runId)} }) or subagent_wait({ id: ${JSON.stringify(control.runId)} }) to recover the eventual result. This does not daemonize the process or guarantee survival across Pi reload/restart.`);
|
|
770
|
-
},
|
|
772
|
+
handler: async (args, ctx) => detachForegroundRun(args, ctx),
|
|
771
773
|
});
|
|
772
774
|
|
|
775
|
+
if (options.foregroundDetachShortcut) {
|
|
776
|
+
pi.registerShortcut(options.foregroundDetachShortcut as KeyId, {
|
|
777
|
+
description: "Detach the active foreground subagent and keep it running in the background",
|
|
778
|
+
handler: async (ctx) => detachForegroundRun("", ctx),
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
|
|
773
782
|
pi.registerCommand("subagents-stop", {
|
|
774
783
|
description: "Stop a current-session async subagent run",
|
|
775
784
|
handler: async (args, ctx) => {
|
|
@@ -81,6 +81,7 @@ function buildParallelInitialResult(params: SubagentParamsLike): AgentToolResult
|
|
|
81
81
|
content: [{ type: "text", text: tasks.map((task) => `${task.agent}: ${task.task}`).join("\n\n") }],
|
|
82
82
|
details: {
|
|
83
83
|
mode: "parallel",
|
|
84
|
+
...(params.async ? { background: true } : {}),
|
|
84
85
|
...(params.context ? { context: params.context } : {}),
|
|
85
86
|
results: tasks.map((task, index) => createPlaceholderResult(task.agent, task.task, "running", index)),
|
|
86
87
|
progress: tasks.map((task, index) => ({
|
|
@@ -136,6 +137,7 @@ function buildChainInitialResult(params: SubagentParamsLike): AgentToolResult<De
|
|
|
136
137
|
}],
|
|
137
138
|
details: {
|
|
138
139
|
mode: "chain",
|
|
140
|
+
...(params.async ? { background: true } : {}),
|
|
139
141
|
...(params.context ? { context: params.context } : {}),
|
|
140
142
|
results,
|
|
141
143
|
progress: results.map((result, index) => ({
|
|
@@ -164,6 +166,7 @@ function buildSingleInitialResult(params: SubagentParamsLike): AgentToolResult<D
|
|
|
164
166
|
content: [{ type: "text", text: task }],
|
|
165
167
|
details: {
|
|
166
168
|
mode: "single",
|
|
169
|
+
...(params.async ? { background: true } : {}),
|
|
167
170
|
...(params.context ? { context: params.context } : {}),
|
|
168
171
|
results: [createPlaceholderResult(agent, task, "running", 0)],
|
|
169
172
|
progress: [{
|
|
@@ -189,6 +192,7 @@ function buildWorkflowInitialResult(params: SubagentParamsLike): AgentToolResult
|
|
|
189
192
|
details: {
|
|
190
193
|
mode: "workflow",
|
|
191
194
|
...(params.context ? { context: params.context } : {}),
|
|
195
|
+
...(params.async ? { background: true } : {}),
|
|
192
196
|
results: [],
|
|
193
197
|
workflow: { trace: [], emits: [], console: [] },
|
|
194
198
|
},
|