@vicary/pi-subagents 0.84.0 → 0.86.0
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 +83 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-VQVVHSY6.js → chunk-2DITXA3H.js} +22 -11
- package/bundle/{chunk-V2BZYLEP.js → chunk-374MZFF4.js} +7 -2
- package/bundle/{chunk-4E7BKDTX.js → chunk-3RKFH2UZ.js} +11 -156
- package/bundle/{chunk-F4ASL6OV.js → chunk-5H4BICQZ.js} +1 -1
- package/bundle/{chunk-PALJGGYC.js → chunk-6VD7BGIC.js} +6 -3
- package/bundle/{chunk-C5P5CHYK.js → chunk-77ASNIEM.js} +1 -1
- package/bundle/{chunk-PV63UFUR.js → chunk-7QA7ZA46.js} +183 -28
- package/bundle/{chunk-NKQ6JNAS.js → chunk-7ZUFN6ME.js} +2 -1
- package/bundle/{chunk-L3WFKBEI.js → chunk-BGXEAYUM.js} +247 -153
- package/bundle/{chunk-J5YL7LYR.js → chunk-BU6PFPVX.js} +59 -27
- package/bundle/{chunk-7BWGNDNK.js → chunk-CJHFDQFJ.js} +196 -1183
- package/bundle/{chunk-DZDETGRJ.js → chunk-DD22RXYJ.js} +259 -216
- package/bundle/{chunk-CGN2TVE7.js → chunk-GJGTMLPE.js} +322 -18
- package/bundle/{chunk-XDQORLZ5.js → chunk-GLVJMI6R.js} +15 -6
- package/bundle/{chunk-D3JAFGMO.js → chunk-GRJHIXYF.js} +1 -1
- package/bundle/chunk-HXRB42AF.js +108 -0
- package/bundle/{chunk-LFDBD4PW.js → chunk-LGINOOY5.js} +2 -2
- package/bundle/{chunk-G2Z6ZH26.js → chunk-NAFLUJ26.js} +1 -1
- package/bundle/{chunk-2DHZTCOL.js → chunk-PYOAIN3V.js} +2 -2
- package/bundle/{chunk-RSLHTEQV.js → chunk-QFLPV64W.js} +324 -111
- package/bundle/{chunk-LNRJCP2Y.js → chunk-QGO6HXHG.js} +417 -242
- package/bundle/{chunk-2S4K53MV.js → chunk-S2Q75LP3.js} +1 -1
- package/bundle/{chunk-NENDSQUY.js → chunk-UR7OW5S7.js} +9 -6
- package/bundle/{chunk-RWPNQZHS.js → chunk-WHC2XHGF.js} +217 -106
- package/bundle/{chunk-AKOIVLA5.js → chunk-WN2E5XHN.js} +135 -77
- package/bundle/{chunk-4NIY3BE6.js → chunk-XOFYXQKZ.js} +2 -2
- package/bundle/{chunk-2D52JFLF.js → chunk-YK3QYNLE.js} +41 -117
- package/bundle/chunk-ZPY5QZCS.js +1067 -0
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +8 -8
- package/bundle/project-panes.js +3 -3
- package/docs/agents.md +24 -3
- package/docs/configuration.md +9 -9
- package/docs/extension-api.md +16 -1
- package/docs/observability.md +1 -1
- package/docs/tool-reference.md +3 -1
- package/docs/workflows.md +31 -3
- package/package.json +2 -2
- package/src/agents/agent-management.js +27 -11
- package/src/agents/agent-memory.d.ts +1 -4
- package/src/agents/agent-memory.js +1 -4
- package/src/agents/agents.d.ts +1 -3
- package/src/agents/agents.js +7 -6
- package/src/agents/frontmatter.js +1 -8
- package/src/agents/global-npm-root.d.ts +1 -0
- package/src/agents/global-npm-root.js +11 -3
- package/src/agents/skills.d.ts +0 -3
- package/src/agents/skills.js +0 -3
- package/src/extension/config.js +7 -1
- package/src/extension/herdr-pi-bridge.js +10 -2
- package/src/extension/index.d.ts +0 -13
- package/src/extension/index.js +43 -32
- package/src/extension/public-execution.d.ts +1 -0
- package/src/extension/public-execution.js +4 -0
- package/src/extension/reply-workflow-script.js +24 -4
- package/src/extension/schemas.d.ts +8 -3
- package/src/extension/schemas.js +6 -4
- package/src/extension/session-switch.d.ts +25 -0
- package/src/extension/session-switch.js +138 -0
- package/src/extension/subagent-guide.d.ts +1 -1
- package/src/extension/subagent-guide.js +1 -1
- package/src/extension/subagent-launch-tool.d.ts +25 -0
- package/src/extension/subagent-launch-tool.js +48 -0
- package/src/extension/tool-activation.js +35 -12
- package/src/extension/tool-description.d.ts +1 -1
- package/src/extension/tool-description.js +14 -8
- package/src/inspectors/herdr/actions.d.ts +0 -1
- package/src/inspectors/herdr/actions.js +0 -1
- package/src/inspectors/session-roots-codec.d.ts +0 -1
- package/src/inspectors/session-roots-codec.js +0 -1
- package/src/inspectors/tmux/actions.d.ts +0 -1
- package/src/inspectors/tmux/actions.js +0 -1
- package/src/integrations/herdr-status.js +3 -8
- package/src/intercom/native-supervisor-channel.js +65 -9
- package/src/runs/background/async-execution.d.ts +5 -10
- package/src/runs/background/async-execution.js +63 -29
- package/src/runs/background/async-job-tracker.js +12 -0
- package/src/runs/background/async-resume.d.ts +2 -1
- package/src/runs/background/async-resume.js +112 -39
- package/src/runs/background/async-retention.js +6 -1
- package/src/runs/background/auto-drain.d.ts +0 -1
- package/src/runs/background/auto-drain.js +7 -6
- package/src/runs/background/boot-id.d.ts +1 -3
- package/src/runs/background/boot-id.js +1 -3
- package/src/runs/background/completion-batcher.d.ts +3 -4
- package/src/runs/background/completion-batcher.js +2 -3
- package/src/runs/background/control-channel.d.ts +0 -6
- package/src/runs/background/control-channel.js +0 -6
- package/src/runs/background/fleet-view.js +2 -3
- package/src/runs/background/notify.d.ts +0 -2
- package/src/runs/background/notify.js +0 -2
- package/src/runs/background/result-watcher.d.ts +1 -0
- package/src/runs/background/result-watcher.js +59 -29
- package/src/runs/background/resume-guidance.js +4 -2
- package/src/runs/background/retained-children.js +2 -1
- package/src/runs/background/run-child-session.d.ts +0 -1
- package/src/runs/background/run-child-session.js +1 -1
- package/src/runs/background/run-status.js +9 -7
- package/src/runs/background/scheduled-runs.d.ts +3 -1
- package/src/runs/background/scheduled-runs.js +13 -16
- package/src/runs/background/subagent-runner.d.ts +2 -4
- package/src/runs/background/subagent-runner.js +15 -12
- package/src/runs/background/subagent-wait.js +12 -15
- package/src/runs/background/wait-config.d.ts +2 -0
- package/src/runs/background/wait-config.js +17 -3
- package/src/runs/background/wait-tool.js +4 -2
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +0 -1
- package/src/runs/foreground/execution.d.ts +0 -3
- package/src/runs/foreground/execution.js +17 -9
- package/src/runs/foreground/subagent-executor.d.ts +7 -8
- package/src/runs/foreground/subagent-executor.js +113 -44
- package/src/runs/shared/acceptance.js +69 -26
- package/src/runs/shared/child-commands.js +15 -2
- package/src/runs/shared/child-hooks.d.ts +1 -7
- package/src/runs/shared/child-hooks.js +13 -5
- package/src/runs/shared/child-launch.js +6 -2
- package/src/runs/shared/child-runtime-config.d.ts +0 -1
- package/src/runs/shared/child-session.d.ts +1 -1
- package/src/runs/shared/child-session.js +21 -2
- package/src/runs/shared/child-tool-plan.d.ts +0 -1
- package/src/runs/shared/child-tool-plan.js +0 -1
- package/src/runs/shared/claude-code-adapter.js +11 -0
- package/src/runs/shared/external-cli-contract.d.ts +49 -0
- package/src/runs/shared/external-cli-contract.js +18 -13
- package/src/runs/shared/external-cli-runner.js +26 -6
- package/src/runs/shared/herdr-connection.js +2 -1
- package/src/runs/shared/herdr-pane-host.d.ts +2 -2
- package/src/runs/shared/herdr-pane-host.js +17 -1
- package/src/runs/shared/herdr-placed-run.js +48 -22
- package/src/runs/shared/lane-metadata.d.ts +0 -1
- package/src/runs/shared/lane-metadata.js +0 -1
- package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
- package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
- package/src/runs/shared/model-resolution.d.ts +2 -2
- package/src/runs/shared/model-resolution.js +7 -1
- package/src/runs/shared/model-scope.d.ts +1 -5
- package/src/runs/shared/model-scope.js +1 -5
- package/src/runs/shared/mutation-evidence.d.ts +1 -1
- package/src/runs/shared/mutation-evidence.js +52 -7
- package/src/runs/shared/nested-events.d.ts +1 -0
- package/src/runs/shared/nested-events.js +1 -1
- package/src/runs/shared/parallel-utils.d.ts +0 -1
- package/src/runs/shared/permissions.js +5 -3
- package/src/runs/shared/placement-host.d.ts +5 -1
- package/src/runs/shared/rex-pane-host.d.ts +0 -1
- package/src/runs/shared/rex-pane-host.js +0 -2
- package/src/runs/shared/run-launch-folder.d.ts +12 -0
- package/src/runs/shared/run-launch-folder.js +21 -0
- package/src/runs/shared/runner-launcher.d.ts +12 -1
- package/src/runs/shared/runner-launcher.js +16 -0
- package/src/runs/shared/single-output.d.ts +3 -3
- package/src/runs/shared/single-output.js +5 -3
- package/src/runs/shared/structured-output.d.ts +8 -0
- package/src/runs/shared/structured-output.js +40 -5
- package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js +4 -2
- package/src/runs/shared/tool-timeout.js +2 -1
- package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
- package/src/runs/shared/worktree-cleanup-plan.js +0 -1
- package/src/runs/shared/worktree.d.ts +3 -0
- package/src/runs/shared/worktree.js +20 -0
- package/src/shared/capacity-resilient-json.d.ts +1 -1
- package/src/shared/child-cache-retention.d.ts +1 -2
- package/src/shared/child-cache-retention.js +1 -2
- package/src/shared/fleet-transcript-reader.d.ts +51 -0
- package/src/shared/fleet-transcript-reader.js +333 -0
- package/src/shared/formatters.d.ts +0 -18
- package/src/shared/formatters.js +0 -18
- package/src/shared/session-succession.d.ts +16 -1
- package/src/shared/session-succession.js +41 -2
- package/src/shared/session-warnings.d.ts +7 -0
- package/src/shared/session-warnings.js +26 -0
- package/src/shared/settings.d.ts +0 -23
- package/src/shared/settings.js +3 -35
- package/src/shared/types.d.ts +90 -65
- package/src/shared/types.js +0 -12
- package/src/shared/utils.d.ts +0 -14
- package/src/shared/utils.js +0 -22
- package/src/shared/wait-tool-name.d.ts +8 -0
- package/src/shared/wait-tool-name.js +13 -0
- package/src/slash/slash-commands.js +2 -1
- package/src/slash/subagent-cost.d.ts +3 -2
- package/src/slash/subagent-cost.js +22 -3
- package/src/slash/subagents-admin.js +0 -1
- package/src/tui/fleet-status.d.ts +0 -5
- package/src/tui/fleet-status.js +4 -24
- package/src/tui/fleet-transcript.d.ts +1 -44
- package/src/tui/fleet-transcript.js +1 -327
- package/src/tui/fleet.js +6 -4
- package/src/tui/render.d.ts +0 -9
- package/src/tui/render.js +161 -66
- package/src/tui/subagent-messages.js +3 -2
- package/src/watchdog/register-child.d.ts +2 -3
- package/src/watchdog/register-child.js +2 -3
- package/src/watchdog/turn-delta.js +2 -1
- package/src/workflows/scripted-workflow.js +241 -20
- package/src/workflows/workflow-launch-record.d.ts +15 -6
- package/src/workflows/workflow-launch-record.js +30 -12
- package/src/workflows/workflow-receipt.js +36 -53
- package/src/workflows/workflow-resume-claim.js +2 -2
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +11 -8
- package/src/workflows/workflow-script-worker.d.ts +13 -0
- package/src/workflows/workflow-script-worker.js +79 -0
- package/workflow-script-process.cjs +36 -0
- package/workflow-script-worker.cjs +4 -1
package/src/shared/settings.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chain behavior, template resolution, and directory management
|
|
3
|
-
*/
|
|
4
1
|
import { type AgentConfig, type AgentScope, type UnknownAgentDiagnosticContext } from "../agents/agents.ts";
|
|
5
2
|
import { type OutputOverrideInput, type ResolvedStepBehavior } from "../runs/shared/child-launch-plan.ts";
|
|
6
3
|
import { type AcceptanceInput, type AgentContract, type ChainGateLayer, type JsonSchemaObject, type OutputMode, type ToolBudgetConfig } from "./types.ts";
|
|
7
4
|
export { planChildLaunch, resolveStepBehavior, resolveTaskTextForFileUpdatePolicy, suppressProgressForReadOnlyTask, taskDisallowsFileUpdates, } from "../runs/shared/child-launch-plan.ts";
|
|
8
5
|
export type { ChildLaunchPlan, ChildLaunchPlanInput, OutputOverrideInput, ResolvedStepBehavior, StepOverrides } from "../runs/shared/child-launch-plan.ts";
|
|
9
|
-
/** Sequential step: single agent execution */
|
|
10
6
|
export interface SequentialStep {
|
|
11
7
|
agent: string;
|
|
12
8
|
task?: string;
|
|
@@ -30,7 +26,6 @@ export interface SequentialStep {
|
|
|
30
26
|
/** Internal workflow child isolation; public workflow scripts supply this on runs.run. */
|
|
31
27
|
worktree?: boolean;
|
|
32
28
|
}
|
|
33
|
-
/** Parallel task item within a parallel step */
|
|
34
29
|
export interface ParallelTaskItem {
|
|
35
30
|
agent: string;
|
|
36
31
|
task?: string;
|
|
@@ -80,7 +75,6 @@ export interface DynamicParallelStep {
|
|
|
80
75
|
agentContract?: AgentContract;
|
|
81
76
|
gateOn?: ChainGateLayer;
|
|
82
77
|
}
|
|
83
|
-
/** Parallel step: multiple agents running concurrently */
|
|
84
78
|
export interface ParallelStep {
|
|
85
79
|
parallel: ParallelTaskItem[];
|
|
86
80
|
concurrency?: number;
|
|
@@ -91,21 +85,15 @@ export interface ParallelStep {
|
|
|
91
85
|
agentContract?: AgentContract;
|
|
92
86
|
gateOn?: ChainGateLayer;
|
|
93
87
|
}
|
|
94
|
-
/** Union type for chain steps */
|
|
95
88
|
export type ChainStep = SequentialStep | ParallelStep | DynamicParallelStep;
|
|
96
89
|
export declare function isParallelStep(step: ChainStep): step is ParallelStep;
|
|
97
90
|
export declare function isDynamicParallelStep(step: ChainStep): step is DynamicParallelStep;
|
|
98
|
-
/** Get all agent names in a step (single for sequential, multiple for parallel) */
|
|
99
91
|
export declare function getStepAgents(step: ChainStep): string[];
|
|
100
92
|
export declare function createChainDir(runId: string, baseDir?: string): string;
|
|
101
93
|
export declare function removeChainDir(chainDir: string): void;
|
|
102
94
|
export declare function cleanupOldChainDirs(): void;
|
|
103
95
|
/** Resolved templates for a chain - string for sequential, string[] for parallel */
|
|
104
96
|
export type ResolvedTemplates = (string | string[])[];
|
|
105
|
-
/**
|
|
106
|
-
* Resolve templates for a chain with parallel step support.
|
|
107
|
-
* Returns string for sequential steps, string[] for parallel steps.
|
|
108
|
-
*/
|
|
109
97
|
export declare function resolveChainTemplates(steps: ChainStep[]): ResolvedTemplates;
|
|
110
98
|
/**
|
|
111
99
|
* Expand a leading `~`/`~/` to the user's home directory. Other forms (relative,
|
|
@@ -119,28 +107,17 @@ export declare function expandHomePath(filePath: string): string;
|
|
|
119
107
|
export declare function resolveChainPath(filePath: string, chainDir: string): string;
|
|
120
108
|
export declare function resolveExistingReadInstructionPaths(reads: readonly string[], instructionCwd: string, existenceCwd?: string): string[];
|
|
121
109
|
export declare function resolveExistingReadPaths(reads: readonly string[], cwd: string): string[];
|
|
122
|
-
/**
|
|
123
|
-
* Build chain instructions from resolved behavior.
|
|
124
|
-
* These are appended to the task to tell the agent what to read/write.
|
|
125
|
-
*/
|
|
126
110
|
export declare function writeInitialProgressFile(progressDir: string): void;
|
|
127
111
|
export declare function buildChainInstructions(behavior: ResolvedStepBehavior, chainDir: string, isFirstProgressAgent: boolean, previousSummary?: string, readExistenceDir?: string): {
|
|
128
112
|
prefix: string;
|
|
129
113
|
suffix: string;
|
|
130
114
|
};
|
|
131
|
-
/**
|
|
132
|
-
* Resolve behaviors for all tasks in a parallel step.
|
|
133
|
-
* Creates namespaced output paths to avoid collisions.
|
|
134
|
-
*/
|
|
135
115
|
/** Exact discovery context, or explicit input for defensive fallback discovery. */
|
|
136
116
|
export type ParallelBehaviorDiagnostics = UnknownAgentDiagnosticContext | {
|
|
137
117
|
cwd: string;
|
|
138
118
|
scope?: AgentScope;
|
|
139
119
|
};
|
|
140
120
|
export declare function resolveParallelBehaviors(tasks: ParallelTaskItem[], agentConfigs: AgentConfig[], stepIndex: number, chainSkills?: string[], diagnostics?: ParallelBehaviorDiagnostics): ResolvedStepBehavior[];
|
|
141
|
-
/**
|
|
142
|
-
* Create subdirectories for parallel step outputs
|
|
143
|
-
*/
|
|
144
121
|
export declare function createParallelDirs(chainDir: string, stepIndex: number, taskCount: number, agentNames: string[]): void;
|
|
145
122
|
export type { ParallelTaskResult } from "../runs/shared/parallel-utils.ts";
|
|
146
123
|
export { aggregateParallelOutputs } from "../runs/shared/parallel-utils.ts";
|
package/src/shared/settings.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chain behavior, template resolution, and directory management
|
|
3
|
-
*/
|
|
4
1
|
import * as fs from "node:fs";
|
|
5
2
|
import * as os from "node:os";
|
|
6
3
|
import * as path from "node:path";
|
|
@@ -8,19 +5,15 @@ import { discoverAgents, formatUnknownAgentError, unknownAgentDiagnosticContext
|
|
|
8
5
|
import { normalizeSkillInput } from "../agents/skills.js";
|
|
9
6
|
import { normalizeOutputOverride } from "../runs/shared/child-launch-plan.js";
|
|
10
7
|
import { CHAIN_RUNS_DIR } from "./types.js";
|
|
11
|
-
const CHAIN_DIR_MAX_AGE_MS = 24 * 60 * 60 * 1000;
|
|
8
|
+
const CHAIN_DIR_MAX_AGE_MS = 24 * 60 * 60 * 1000;
|
|
12
9
|
const INITIAL_PROGRESS_CONTENT = "# Progress\n\n## Status\nIn Progress\n\n## Tasks\n\n## Files Changed\n\n## Notes\n";
|
|
13
10
|
export { planChildLaunch, resolveStepBehavior, resolveTaskTextForFileUpdatePolicy, suppressProgressForReadOnlyTask, taskDisallowsFileUpdates, } from "../runs/shared/child-launch-plan.js";
|
|
14
|
-
// =============================================================================
|
|
15
|
-
// Type Guards
|
|
16
|
-
// =============================================================================
|
|
17
11
|
export function isParallelStep(step) {
|
|
18
12
|
return "parallel" in step && Array.isArray(step.parallel);
|
|
19
13
|
}
|
|
20
14
|
export function isDynamicParallelStep(step) {
|
|
21
15
|
return "expand" in step && "collect" in step && "parallel" in step && !Array.isArray(step.parallel);
|
|
22
16
|
}
|
|
23
|
-
/** Get all agent names in a step (single for sequential, multiple for parallel) */
|
|
24
17
|
export function getStepAgents(step) {
|
|
25
18
|
if (isParallelStep(step)) {
|
|
26
19
|
return step.parallel.map((t) => t.agent);
|
|
@@ -30,9 +23,6 @@ export function getStepAgents(step) {
|
|
|
30
23
|
}
|
|
31
24
|
return [step.agent];
|
|
32
25
|
}
|
|
33
|
-
// =============================================================================
|
|
34
|
-
// Chain Directory Management
|
|
35
|
-
// =============================================================================
|
|
36
26
|
export function createChainDir(runId, baseDir) {
|
|
37
27
|
const chainDir = path.join(baseDir ? path.resolve(baseDir) : CHAIN_RUNS_DIR, runId);
|
|
38
28
|
fs.mkdirSync(chainDir, { recursive: true });
|
|
@@ -72,35 +62,24 @@ export function cleanupOldChainDirs() {
|
|
|
72
62
|
}
|
|
73
63
|
}
|
|
74
64
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Resolve templates for a chain with parallel step support.
|
|
77
|
-
* Returns string for sequential steps, string[] for parallel steps.
|
|
78
|
-
*/
|
|
79
65
|
export function resolveChainTemplates(steps) {
|
|
80
66
|
return steps.map((step, i) => {
|
|
81
67
|
if (isParallelStep(step)) {
|
|
82
|
-
// Parallel step: resolve each task's template
|
|
83
68
|
return step.parallel.map((task) => {
|
|
84
69
|
if (task.task)
|
|
85
70
|
return task.task;
|
|
86
|
-
// Default for parallel tasks is {previous}
|
|
87
71
|
return "{previous}";
|
|
88
72
|
});
|
|
89
73
|
}
|
|
90
74
|
if (isDynamicParallelStep(step)) {
|
|
91
75
|
return step.parallel.task ?? "{previous}";
|
|
92
76
|
}
|
|
93
|
-
// Sequential step: existing logic
|
|
94
77
|
const seq = step;
|
|
95
78
|
if (seq.task)
|
|
96
79
|
return seq.task;
|
|
97
|
-
// Default: first step uses {task}, others use {previous}
|
|
98
80
|
return i === 0 ? "{task}" : "{previous}";
|
|
99
81
|
});
|
|
100
82
|
}
|
|
101
|
-
// =============================================================================
|
|
102
|
-
// Chain Instruction Injection
|
|
103
|
-
// =============================================================================
|
|
104
83
|
/**
|
|
105
84
|
* Expand a leading `~`/`~/` to the user's home directory. Other forms (relative,
|
|
106
85
|
* absolute, `~user/`) pass through unchanged.
|
|
@@ -130,10 +109,6 @@ export function resolveExistingReadInstructionPaths(reads, instructionCwd, exist
|
|
|
130
109
|
export function resolveExistingReadPaths(reads, cwd) {
|
|
131
110
|
return resolveExistingReadInstructionPaths(reads, cwd);
|
|
132
111
|
}
|
|
133
|
-
/**
|
|
134
|
-
* Build chain instructions from resolved behavior.
|
|
135
|
-
* These are appended to the task to tell the agent what to read/write.
|
|
136
|
-
*/
|
|
137
112
|
export function writeInitialProgressFile(progressDir) {
|
|
138
113
|
fs.mkdirSync(progressDir, { recursive: true });
|
|
139
114
|
fs.writeFileSync(path.join(progressDir, "progress.md"), INITIAL_PROGRESS_CONTENT);
|
|
@@ -162,7 +137,6 @@ export function buildChainInstructions(behavior, chainDir, isFirstProgressAgent,
|
|
|
162
137
|
suffixParts.push(`Update progress at: ${progressPath}`);
|
|
163
138
|
}
|
|
164
139
|
}
|
|
165
|
-
// Include previous step's summary in suffix if available
|
|
166
140
|
if (previousSummary && previousSummary.trim()) {
|
|
167
141
|
suffixParts.push(`Previous step output:\n${previousSummary.trim()}`);
|
|
168
142
|
}
|
|
@@ -185,7 +159,6 @@ export function resolveParallelBehaviors(tasks, agentConfigs, stepIndex, chainSk
|
|
|
185
159
|
: unknownAgentDiagnosticContext(discoverAgents(path.resolve(diagnostics.cwd), diagnostics.scope ?? "both"));
|
|
186
160
|
throw new Error(formatUnknownAgentError(task.agent, context));
|
|
187
161
|
}
|
|
188
|
-
// Build subdirectory path for this parallel task
|
|
189
162
|
const subdir = path.join(`parallel-${stepIndex}`, `${taskIndex}-${task.agent}`);
|
|
190
163
|
// Output: task override > agent default (namespaced) > false
|
|
191
164
|
// Absolute paths pass through unchanged; relative paths get namespaced under subdir
|
|
@@ -197,19 +170,17 @@ export function resolveParallelBehaviors(tasks, agentConfigs, stepIndex, chainSk
|
|
|
197
170
|
output = false;
|
|
198
171
|
}
|
|
199
172
|
else if (path.isAbsolute(taskOutput)) {
|
|
200
|
-
output = taskOutput;
|
|
173
|
+
output = taskOutput;
|
|
201
174
|
}
|
|
202
175
|
else {
|
|
203
|
-
output = path.join(subdir, taskOutput);
|
|
176
|
+
output = path.join(subdir, taskOutput);
|
|
204
177
|
}
|
|
205
178
|
}
|
|
206
179
|
else if (configOutput) {
|
|
207
180
|
// Agent defaults are always relative, so namespace them
|
|
208
181
|
output = path.join(subdir, configOutput);
|
|
209
182
|
}
|
|
210
|
-
// Reads: task override > agent default > false
|
|
211
183
|
const reads = task.reads !== undefined ? task.reads : config.defaultReads ?? false;
|
|
212
|
-
// Progress: task override > agent default > false
|
|
213
184
|
const progress = task.progress !== undefined
|
|
214
185
|
? task.progress
|
|
215
186
|
: config.defaultProgress ?? false;
|
|
@@ -235,9 +206,6 @@ export function resolveParallelBehaviors(tasks, agentConfigs, stepIndex, chainSk
|
|
|
235
206
|
return { output, outputMode, reads, progress, skills, model };
|
|
236
207
|
});
|
|
237
208
|
}
|
|
238
|
-
/**
|
|
239
|
-
* Create subdirectories for parallel step outputs
|
|
240
|
-
*/
|
|
241
209
|
export function createParallelDirs(chainDir, stepIndex, taskCount, agentNames) {
|
|
242
210
|
for (let i = 0; i < taskCount; i++) {
|
|
243
211
|
const subdir = path.join(chainDir, `parallel-${stepIndex}`, `${i}-${agentNames[i]}`);
|
package/src/shared/types.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for the subagent extension
|
|
3
|
-
*/
|
|
4
1
|
import type { Message } from "@earendil-works/pi-ai";
|
|
5
2
|
import type { SubagentDelegationProviderDiagnostics } from "../api/delegation.ts";
|
|
6
3
|
import type { AgentConfig } from "../agents/agents.ts";
|
|
@@ -340,6 +337,8 @@ export interface WaitToolConfigObject {
|
|
|
340
337
|
enabled?: boolean;
|
|
341
338
|
/** Default blocking window for bg_wait calls that omit timeoutMs. */
|
|
342
339
|
defaultTimeoutMs?: number;
|
|
340
|
+
/** Registers the wait tool under this name instead of bg_wait, e.g. when another extension uses bg_wait. */
|
|
341
|
+
name?: string;
|
|
343
342
|
}
|
|
344
343
|
export type WaitToolConfig = boolean | WaitToolConfigObject;
|
|
345
344
|
export interface ControlEvent {
|
|
@@ -749,13 +748,29 @@ export interface SteeringRecoveryDescriptor {
|
|
|
749
748
|
requiredExtensions?: RequiredChildExtensionSnapshot;
|
|
750
749
|
runFanoutBudget: RunFanoutBudgetDescriptor;
|
|
751
750
|
sourceRunId: string;
|
|
751
|
+
/** The session that launched the run; only it, or a session that replaced it, may resume the run. */
|
|
752
|
+
sessionId?: string;
|
|
752
753
|
agentContract?: AgentContract;
|
|
753
754
|
agent: string;
|
|
754
755
|
sessionFile?: string;
|
|
756
|
+
/**
|
|
757
|
+
* The managed worktree the launch chose, so a resume never takes its cwd from the run's own
|
|
758
|
+
* handoff.json alone: the native cwd the parent computed, or the Worktrunk branch it requested.
|
|
759
|
+
*/
|
|
760
|
+
managedWorktree?: {
|
|
761
|
+
provider: "native";
|
|
762
|
+
cwd: string;
|
|
763
|
+
} | {
|
|
764
|
+
provider: "worktrunk";
|
|
765
|
+
branch: string;
|
|
766
|
+
};
|
|
755
767
|
/** Git ref used to allocate managed worktrees for this run. */
|
|
756
768
|
baseRef?: string;
|
|
757
|
-
/** Launcher name the run was wrapped with; resume re-reads its argv from current user config.
|
|
758
|
-
|
|
769
|
+
/** Launcher name the run was wrapped with, or null when it ran unwrapped; resume re-reads its argv from current user config.
|
|
770
|
+
* Absence (descriptors written before null was recorded) means unknown: resume uses the agent file's current launcher. */
|
|
771
|
+
launcher?: string | null;
|
|
772
|
+
/** The launcher and agent definition digest the launch required; a resume refuses unless both still hold. */
|
|
773
|
+
requiredLauncher?: RequiredRunnerLauncher;
|
|
759
774
|
cwd: string;
|
|
760
775
|
model?: string;
|
|
761
776
|
modelProvider?: string;
|
|
@@ -789,7 +804,6 @@ export interface SteeringRecoveryDescriptor {
|
|
|
789
804
|
structuredOutputSchema?: JsonSchemaObject;
|
|
790
805
|
acceptance?: AcceptanceInput;
|
|
791
806
|
controlConfig?: ResolvedControlConfig;
|
|
792
|
-
/** Resolved launch context for this async child. */
|
|
793
807
|
context?: "fresh" | "fork";
|
|
794
808
|
/** Raw per-run bridge override. Omitted descriptors continue to use global config. */
|
|
795
809
|
intercomBridge?: IntercomBridgeConfig;
|
|
@@ -1147,7 +1161,6 @@ export interface SingleResult {
|
|
|
1147
1161
|
/** Human-readable display name for the child's own session (agent + task
|
|
1148
1162
|
* excerpt), when the launcher derived one. Display metadata only. */
|
|
1149
1163
|
sessionName?: string;
|
|
1150
|
-
/** Resolved launch context for this child. */
|
|
1151
1164
|
context?: "fresh" | "fork";
|
|
1152
1165
|
exitCode: number;
|
|
1153
1166
|
processSignal?: string | null;
|
|
@@ -1247,7 +1260,6 @@ export interface WaitCompletionChild {
|
|
|
1247
1260
|
runId?: string;
|
|
1248
1261
|
/** Bounded accounting projection used by /subagent-cost after async completion. */
|
|
1249
1262
|
usage?: Usage;
|
|
1250
|
-
/** Persisted Pi child session when available. */
|
|
1251
1263
|
sessionFile?: string;
|
|
1252
1264
|
success?: boolean;
|
|
1253
1265
|
outputState?: SubagentOutputState;
|
|
@@ -1315,6 +1327,7 @@ export interface AgentCapabilityRow {
|
|
|
1315
1327
|
model?: {
|
|
1316
1328
|
value?: string;
|
|
1317
1329
|
thinking?: string | false;
|
|
1330
|
+
unavailable?: true;
|
|
1318
1331
|
};
|
|
1319
1332
|
execution?: {
|
|
1320
1333
|
defaultAsync?: boolean;
|
|
@@ -1721,54 +1734,9 @@ export interface ExternalCliReceiptMetadata {
|
|
|
1721
1734
|
};
|
|
1722
1735
|
capabilities: ExternalCliCapabilities;
|
|
1723
1736
|
machine?: ExternalCliMachineStatus;
|
|
1724
|
-
safety?:
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
ephemeral: true;
|
|
1728
|
-
} | {
|
|
1729
|
-
access: "workspace-write";
|
|
1730
|
-
sandbox: "workspace-write";
|
|
1731
|
-
approvalPolicy: "never";
|
|
1732
|
-
ephemeral: true;
|
|
1733
|
-
} | {
|
|
1734
|
-
permissionMode: "plan";
|
|
1735
|
-
tools: "none";
|
|
1736
|
-
mcp: "empty-strict";
|
|
1737
|
-
settingSources: "none";
|
|
1738
|
-
sessionPersistence: false;
|
|
1739
|
-
} | {
|
|
1740
|
-
access: "read-only";
|
|
1741
|
-
authentication: "existing-cli-required";
|
|
1742
|
-
permissionMode: "plan";
|
|
1743
|
-
tools: "none";
|
|
1744
|
-
mcp: "empty-strict";
|
|
1745
|
-
settingSources: "user";
|
|
1746
|
-
userSettingsTrust: "required";
|
|
1747
|
-
sessionPersistence: false;
|
|
1748
|
-
} | {
|
|
1749
|
-
access: "workspace-write";
|
|
1750
|
-
authentication: "existing-cli-required";
|
|
1751
|
-
permissionMode: "acceptEdits";
|
|
1752
|
-
tools: "Read,Write,Edit,Glob,Grep";
|
|
1753
|
-
mcp: "empty-strict";
|
|
1754
|
-
settingSources: "user";
|
|
1755
|
-
userSettingsTrust: "required";
|
|
1756
|
-
sessionPersistence: false;
|
|
1757
|
-
} | {
|
|
1758
|
-
access: "read-only";
|
|
1759
|
-
authentication: "cursor-api-key-or-existing-login";
|
|
1760
|
-
mode: "ask";
|
|
1761
|
-
sandbox: "enabled";
|
|
1762
|
-
workspaceTrust: "existing-required";
|
|
1763
|
-
sessionReuse: false;
|
|
1764
|
-
} | {
|
|
1765
|
-
access: "workspace-write";
|
|
1766
|
-
authentication: "cursor-api-key-or-existing-login";
|
|
1767
|
-
mode: "print";
|
|
1768
|
-
sandbox: "enabled";
|
|
1769
|
-
workspaceTrust: "existing-required";
|
|
1770
|
-
sessionReuse: false;
|
|
1771
|
-
};
|
|
1737
|
+
safety?: ExternalCliProfileSafety;
|
|
1738
|
+
/** Where `safety` came from. Nothing in it is measured from the launched process. */
|
|
1739
|
+
safetySource?: ExternalCliSafetySource;
|
|
1772
1740
|
outputArtifacts?: {
|
|
1773
1741
|
stdoutPath?: string;
|
|
1774
1742
|
stderrPath?: string;
|
|
@@ -1783,6 +1751,59 @@ export interface ExternalCliReceiptMetadata {
|
|
|
1783
1751
|
};
|
|
1784
1752
|
nonResumableReason: string;
|
|
1785
1753
|
}
|
|
1754
|
+
export type ExternalCliProfileSafety = {
|
|
1755
|
+
sandbox: "read-only";
|
|
1756
|
+
approvalPolicy: "never";
|
|
1757
|
+
ephemeral: true;
|
|
1758
|
+
} | {
|
|
1759
|
+
access: "workspace-write";
|
|
1760
|
+
sandbox: "workspace-write";
|
|
1761
|
+
approvalPolicy: "never";
|
|
1762
|
+
ephemeral: true;
|
|
1763
|
+
} | {
|
|
1764
|
+
permissionMode: "plan";
|
|
1765
|
+
tools: "none";
|
|
1766
|
+
mcp: "empty-strict";
|
|
1767
|
+
settingSources: "none";
|
|
1768
|
+
sessionPersistence: false;
|
|
1769
|
+
} | {
|
|
1770
|
+
access: "read-only";
|
|
1771
|
+
authentication: "existing-cli-required";
|
|
1772
|
+
permissionMode: "plan";
|
|
1773
|
+
tools: "none";
|
|
1774
|
+
mcp: "empty-strict";
|
|
1775
|
+
settingSources: "user";
|
|
1776
|
+
userSettingsTrust: "required";
|
|
1777
|
+
sessionPersistence: false;
|
|
1778
|
+
} | {
|
|
1779
|
+
access: "workspace-write";
|
|
1780
|
+
authentication: "existing-cli-required";
|
|
1781
|
+
permissionMode: "acceptEdits";
|
|
1782
|
+
tools: "Read,Write,Edit,Glob,Grep";
|
|
1783
|
+
mcp: "empty-strict";
|
|
1784
|
+
settingSources: "user";
|
|
1785
|
+
userSettingsTrust: "required";
|
|
1786
|
+
sessionPersistence: false;
|
|
1787
|
+
} | {
|
|
1788
|
+
access: "read-only";
|
|
1789
|
+
authentication: "cursor-api-key-or-existing-login";
|
|
1790
|
+
mode: "ask";
|
|
1791
|
+
sandbox: "enabled";
|
|
1792
|
+
workspaceTrust: "existing-required";
|
|
1793
|
+
sessionReuse: false;
|
|
1794
|
+
} | {
|
|
1795
|
+
access: "workspace-write";
|
|
1796
|
+
authentication: "cursor-api-key-or-existing-login";
|
|
1797
|
+
mode: "print";
|
|
1798
|
+
sandbox: "enabled";
|
|
1799
|
+
workspaceTrust: "existing-required";
|
|
1800
|
+
sessionReuse: false;
|
|
1801
|
+
};
|
|
1802
|
+
export interface ExternalCliSafetySource {
|
|
1803
|
+
measured: false;
|
|
1804
|
+
/** The launch command, absent on a Herdr saved machine. A wrapper script here can grant more or less than the adapter profile. */
|
|
1805
|
+
command?: string;
|
|
1806
|
+
}
|
|
1786
1807
|
export interface ExternalCliRunnerStatus {
|
|
1787
1808
|
type: "external-cli";
|
|
1788
1809
|
command: string;
|
|
@@ -1790,6 +1811,7 @@ export interface ExternalCliRunnerStatus {
|
|
|
1790
1811
|
promptDelivery: "stdin" | "prompt-file";
|
|
1791
1812
|
adapter: ExternalCliReceiptMetadata["adapter"];
|
|
1792
1813
|
safety?: ExternalCliReceiptMetadata["safety"];
|
|
1814
|
+
safetySource?: ExternalCliSafetySource;
|
|
1793
1815
|
capabilities: ExternalCliCapabilities;
|
|
1794
1816
|
unsupportedReasons: Record<Exclude<keyof ExternalCliCapabilities, "stop">, string>;
|
|
1795
1817
|
nonResumableReason: string;
|
|
@@ -1928,7 +1950,6 @@ export interface AsyncStatus {
|
|
|
1928
1950
|
runner?: ExternalCliRunnerStatus | ExternalJobRunnerStatus;
|
|
1929
1951
|
externalProcess?: ExternalProcessStatus;
|
|
1930
1952
|
externalJob?: ExternalJobStatus;
|
|
1931
|
-
/** Resolved launch context for this child step. */
|
|
1932
1953
|
context?: "fresh" | "fork";
|
|
1933
1954
|
/** Short caller-facing task/goal shown in fleet surfaces when available. */
|
|
1934
1955
|
description?: string;
|
|
@@ -2403,6 +2424,11 @@ export interface RunnerLauncher {
|
|
|
2403
2424
|
name: string;
|
|
2404
2425
|
argv: string[];
|
|
2405
2426
|
}
|
|
2427
|
+
/** A call's requirement that its agent runs under this launcher with this agent definition digest. */
|
|
2428
|
+
export interface RequiredRunnerLauncher {
|
|
2429
|
+
name: string;
|
|
2430
|
+
definitionDigest: string;
|
|
2431
|
+
}
|
|
2406
2432
|
export declare const SUBAGENT_ASYNC_COMPLETE_EVENT = "subagent:async-complete";
|
|
2407
2433
|
export declare const SUBAGENT_PROCESS_TERMINAL_EVENT = "subagent:process-terminal";
|
|
2408
2434
|
export declare const SUBAGENT_FOREGROUND_COMPLETE_EVENT = "subagent:foreground-complete";
|
|
@@ -2457,7 +2483,6 @@ export interface RunSyncOptions {
|
|
|
2457
2483
|
parentSessionId?: string;
|
|
2458
2484
|
/** The parent session's file, recorded as a new child session's `parentSession` header. */
|
|
2459
2485
|
parentSessionFile?: string;
|
|
2460
|
-
/** Resolved launch context for this child. */
|
|
2461
2486
|
context?: "fresh" | "fork";
|
|
2462
2487
|
cwd?: string;
|
|
2463
2488
|
/** Resolved pane-native saved-machine placement. */
|
|
@@ -2485,6 +2510,8 @@ export interface RunSyncOptions {
|
|
|
2485
2510
|
/** Internal structured-delegation transport optimization: skip unchanged live snapshots. */
|
|
2486
2511
|
suppressUnchangedDelegationUpdates?: boolean;
|
|
2487
2512
|
onControlEvent?: (event: ControlEvent) => void;
|
|
2513
|
+
/** Reports a problem found by a timer callback, with a stable key to de-duplicate it; without it the message goes to stderr. */
|
|
2514
|
+
onWarning?: (message: string, key: string) => void;
|
|
2488
2515
|
/** Exposes a non-terminating detach callback while the child is active. */
|
|
2489
2516
|
onDetachReady?: (detach: (reason?: string) => boolean) => void;
|
|
2490
2517
|
/** Internal foreground receipt proposal; returns true only when the outer waiter accepted it. */
|
|
@@ -2540,7 +2567,6 @@ export interface RunSyncOptions {
|
|
|
2540
2567
|
preferredModelProvider?: string;
|
|
2541
2568
|
/** Parent Pi event host used to snapshot runtime-registered MCP servers before child launch. */
|
|
2542
2569
|
runtimeSnapshotHost?: import("../runs/shared/mcp-direct-tool-allowlist.ts").McpRuntimeSnapshotHost;
|
|
2543
|
-
/** Optional subagent model-scope enforcement. */
|
|
2544
2570
|
modelScope?: ModelScopeRule | ModelScopeRule[];
|
|
2545
2571
|
/** Skills to make available (overrides agent default if provided) */
|
|
2546
2572
|
skills?: string[];
|
|
@@ -2682,12 +2708,11 @@ export interface ExtensionConfig {
|
|
|
2682
2708
|
/** Global cap on simultaneously-running subagent tasks within a single run. Defaults to 20. */
|
|
2683
2709
|
globalConcurrencyLimit?: number;
|
|
2684
2710
|
/**
|
|
2685
|
-
* Global default runtime deadline in milliseconds
|
|
2686
|
-
*
|
|
2687
|
-
*
|
|
2688
|
-
*
|
|
2689
|
-
*
|
|
2690
|
-
* stay unbounded at the top level by design — their children are bounded individually.
|
|
2711
|
+
* Global default runtime deadline in milliseconds for foreground launches and
|
|
2712
|
+
* plain single-agent async runs when neither the call (`timeoutMs`/`maxRuntimeMs`)
|
|
2713
|
+
* nor the selected agent provides a timeout. Without a configured deadline,
|
|
2714
|
+
* these launches are unbounded. Explicit call values and agent frontmatter
|
|
2715
|
+
* defaults still win. Composite async runs stay unbounded at the top level.
|
|
2691
2716
|
* Must be a positive integer; invalid values are ignored.
|
|
2692
2717
|
*/
|
|
2693
2718
|
timeoutMs?: number;
|
package/src/shared/types.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for the subagent extension
|
|
3
|
-
*/
|
|
4
1
|
import * as os from "node:os";
|
|
5
2
|
import * as path from "node:path";
|
|
6
3
|
export const SUBAGENT_LIFECYCLE_ARTIFACT_VERSION = 3;
|
|
@@ -39,9 +36,6 @@ export const FLEET_KEYBINDING_ACTIONS = [
|
|
|
39
36
|
"stop",
|
|
40
37
|
"toggleTools",
|
|
41
38
|
];
|
|
42
|
-
// ============================================================================
|
|
43
|
-
// Constants
|
|
44
|
-
// ============================================================================
|
|
45
39
|
export const DEFAULT_MAX_OUTPUT = {
|
|
46
40
|
bytes: 200 * 1024,
|
|
47
41
|
lines: 5000,
|
|
@@ -165,9 +159,6 @@ export function wrapForkTask(task, preamble) {
|
|
|
165
159
|
return task;
|
|
166
160
|
return `${wrappedPrefix}${task}`;
|
|
167
161
|
}
|
|
168
|
-
// ============================================================================
|
|
169
|
-
// Recursion Depth Guard
|
|
170
|
-
// ============================================================================
|
|
171
162
|
function normalizeNonNegativeInteger(value) {
|
|
172
163
|
const parsed = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
|
|
173
164
|
if (!Number.isInteger(parsed) || parsed < 0)
|
|
@@ -227,9 +218,6 @@ export function resolveMaxSubagentSpawnsPerRun(configMaxSpawns) {
|
|
|
227
218
|
?? normalizeMaxSubagentSpawnsPerRun(configMaxSpawns)
|
|
228
219
|
?? DEFAULT_MAX_SUBAGENT_SPAWNS_PER_RUN;
|
|
229
220
|
}
|
|
230
|
-
// ============================================================================
|
|
231
|
-
// Utility Functions
|
|
232
|
-
// ============================================================================
|
|
233
221
|
function formatBytes(bytes) {
|
|
234
222
|
if (bytes < 1024)
|
|
235
223
|
return `${bytes}B`;
|
package/src/shared/utils.d.ts
CHANGED
|
@@ -11,9 +11,6 @@ export declare function getProjectConfigDir(projectRoot: string): string;
|
|
|
11
11
|
export declare function getAgentDir(): string;
|
|
12
12
|
export declare function pruneStatusCacheForAsyncRoot(asyncDirRoot: string, runIds: Iterable<string>): number;
|
|
13
13
|
export declare function resolveChildCwd(baseCwd: string, childCwd: string | undefined): string;
|
|
14
|
-
/**
|
|
15
|
-
* Read async job status from disk (with mtime-based caching)
|
|
16
|
-
*/
|
|
17
14
|
export declare function readStatus(asyncDir: string): AsyncStatus | null;
|
|
18
15
|
export declare function getLastActivity(outputFile: string | undefined): string;
|
|
19
16
|
export declare function findLatestSessionFile(sessionDir: string): string | null;
|
|
@@ -30,13 +27,9 @@ export declare function assistantMessageError(message: {
|
|
|
30
27
|
}): string | undefined;
|
|
31
28
|
export declare function getFinalOutput(messages: Message[]): string;
|
|
32
29
|
export declare function getSingleResultOutput(result: Pick<SingleResult, "finalOutput" | "messages">): string;
|
|
33
|
-
/**
|
|
34
|
-
* Extract display items (text and tool calls) from messages
|
|
35
|
-
*/
|
|
36
30
|
export declare function getDisplayItems(messages: Message[] | undefined): DisplayItem[];
|
|
37
31
|
export declare function sumResultsUsage(results: SingleResult[]): Usage;
|
|
38
32
|
export declare function toAgentToolUsage(usage: Usage): PiUsage;
|
|
39
|
-
/** Sum input tokens, output tokens, and cost across a set of SingleResults. */
|
|
40
33
|
export declare function sumResultsCost(results: SingleResult[]): NonNullable<Details["totalCost"]>;
|
|
41
34
|
export declare function compactForegroundResult(result: SingleResult): SingleResult;
|
|
42
35
|
export declare function compactForegroundDetails(details: Details): Details;
|
|
@@ -56,7 +49,6 @@ export declare function compactForegroundDetails(details: Details): Details;
|
|
|
56
49
|
export declare const MAX_STREAMED_RECENT_TOOLS = 32;
|
|
57
50
|
export declare const MAX_STREAMED_TOOL_CALLS = 64;
|
|
58
51
|
export declare const MAX_STREAMED_OUTPUT_LINE_CHARS = 2000;
|
|
59
|
-
/** Keep only the most recent tool-history entries in a streamed snapshot. */
|
|
60
52
|
export declare function boundStreamedRecentTools(recentTools: AgentProgress["recentTools"]): AgentProgress["recentTools"];
|
|
61
53
|
/** Cap per-line length of recent output so one long line can't inflate a snapshot. */
|
|
62
54
|
export declare function boundStreamedRecentOutput(recentOutput: string[]): string[];
|
|
@@ -72,12 +64,6 @@ export declare function formatEmptyTerminalAssistantResponseError(messages: Mess
|
|
|
72
64
|
* Detect errors in subagent execution from messages (only errors with no subsequent success)
|
|
73
65
|
*/
|
|
74
66
|
export declare function detectSubagentError(messages: Message[]): ErrorInfo;
|
|
75
|
-
/**
|
|
76
|
-
* Extract a preview of tool arguments for display
|
|
77
|
-
*/
|
|
78
67
|
export declare function extractToolArgsPreview(args: Record<string, unknown>): string;
|
|
79
|
-
/**
|
|
80
|
-
* Extract text content from various message content formats
|
|
81
|
-
*/
|
|
82
68
|
export declare function extractTextFromContent(content: unknown): string;
|
|
83
69
|
export { mapConcurrent } from "../runs/shared/parallel-utils.ts";
|
package/src/shared/utils.js
CHANGED
|
@@ -119,9 +119,6 @@ function isNotFoundError(error) {
|
|
|
119
119
|
&& "code" in error
|
|
120
120
|
&& error.code === "ENOENT";
|
|
121
121
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Read async job status from disk (with mtime-based caching)
|
|
124
|
-
*/
|
|
125
122
|
export function readStatus(asyncDir) {
|
|
126
123
|
if (Buffer.byteLength(path.basename(asyncDir), "utf-8") > 255) {
|
|
127
124
|
return null;
|
|
@@ -291,9 +288,6 @@ export function getFinalOutput(messages) {
|
|
|
291
288
|
export function getSingleResultOutput(result) {
|
|
292
289
|
return result.finalOutput ?? getFinalOutput(result.messages ?? []);
|
|
293
290
|
}
|
|
294
|
-
/**
|
|
295
|
-
* Extract display items (text and tool calls) from messages
|
|
296
|
-
*/
|
|
297
291
|
export function getDisplayItems(messages) {
|
|
298
292
|
if (!messages || messages.length === 0)
|
|
299
293
|
return [];
|
|
@@ -387,7 +381,6 @@ function addNestedCost(total, children) {
|
|
|
387
381
|
addNestedCost(total, step.children);
|
|
388
382
|
}
|
|
389
383
|
}
|
|
390
|
-
/** Sum input tokens, output tokens, and cost across a set of SingleResults. */
|
|
391
384
|
export function sumResultsCost(results) {
|
|
392
385
|
const total = { inputTokens: 0, outputTokens: 0, costUsd: 0 };
|
|
393
386
|
for (const result of results) {
|
|
@@ -435,7 +428,6 @@ export function compactForegroundDetails(details) {
|
|
|
435
428
|
export const MAX_STREAMED_RECENT_TOOLS = 32;
|
|
436
429
|
export const MAX_STREAMED_TOOL_CALLS = 64;
|
|
437
430
|
export const MAX_STREAMED_OUTPUT_LINE_CHARS = 2000;
|
|
438
|
-
/** Keep only the most recent tool-history entries in a streamed snapshot. */
|
|
439
431
|
export function boundStreamedRecentTools(recentTools) {
|
|
440
432
|
return recentTools.slice(-MAX_STREAMED_RECENT_TOOLS).map((tool) => ({ ...tool }));
|
|
441
433
|
}
|
|
@@ -519,9 +511,6 @@ export function detectSubagentError(messages) {
|
|
|
519
511
|
}
|
|
520
512
|
return { hasError: false };
|
|
521
513
|
}
|
|
522
|
-
/**
|
|
523
|
-
* Extract a preview of tool arguments for display
|
|
524
|
-
*/
|
|
525
514
|
export function extractToolArgsPreview(args) {
|
|
526
515
|
const stringifyPreviewValue = (value) => {
|
|
527
516
|
if (typeof value === "string" && value.trim().length > 0)
|
|
@@ -573,32 +562,24 @@ export function extractToolArgsPreview(args) {
|
|
|
573
562
|
}
|
|
574
563
|
return "";
|
|
575
564
|
}
|
|
576
|
-
/**
|
|
577
|
-
* Extract text content from various message content formats
|
|
578
|
-
*/
|
|
579
565
|
export function extractTextFromContent(content) {
|
|
580
566
|
if (!content)
|
|
581
567
|
return "";
|
|
582
|
-
// Handle string content directly
|
|
583
568
|
if (typeof content === "string")
|
|
584
569
|
return content;
|
|
585
|
-
// Handle array content
|
|
586
570
|
if (!Array.isArray(content))
|
|
587
571
|
return "";
|
|
588
572
|
const texts = [];
|
|
589
573
|
for (const part of content) {
|
|
590
574
|
if (part && typeof part === "object") {
|
|
591
|
-
// Handle { type: "text", text: "..." }
|
|
592
575
|
if ("type" in part && part.type === "text" && "text" in part) {
|
|
593
576
|
texts.push(String(part.text));
|
|
594
577
|
}
|
|
595
|
-
// Handle { type: "tool_result", content: "..." }
|
|
596
578
|
else if ("type" in part && part.type === "tool_result" && "content" in part) {
|
|
597
579
|
const inner = extractTextFromContent(part.content);
|
|
598
580
|
if (inner)
|
|
599
581
|
texts.push(inner);
|
|
600
582
|
}
|
|
601
|
-
// Handle { text: "..." } without type
|
|
602
583
|
else if ("text" in part) {
|
|
603
584
|
texts.push(String(part.text));
|
|
604
585
|
}
|
|
@@ -606,7 +587,4 @@ export function extractTextFromContent(content) {
|
|
|
606
587
|
}
|
|
607
588
|
return texts.join("\n");
|
|
608
589
|
}
|
|
609
|
-
// ============================================================================
|
|
610
|
-
// Concurrency Utilities
|
|
611
|
-
// ============================================================================
|
|
612
590
|
export { mapConcurrent } from "../runs/shared/parallel-utils.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const DEFAULT_WAIT_TOOL_NAME = "bg_wait";
|
|
2
|
+
/**
|
|
3
|
+
* The name pi-subagents registers its wait tool under (`config.waitTool.name`). One value per process: the parent
|
|
4
|
+
* sets it from config, a child runtime from its launch config, and an async runner from its runner config, because
|
|
5
|
+
* every runtime in a process descends from the same parent setting.
|
|
6
|
+
*/
|
|
7
|
+
export declare function waitToolName(): string;
|
|
8
|
+
export declare function setWaitToolName(name: string): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const DEFAULT_WAIT_TOOL_NAME = "bg_wait";
|
|
2
|
+
let current = DEFAULT_WAIT_TOOL_NAME;
|
|
3
|
+
/**
|
|
4
|
+
* The name pi-subagents registers its wait tool under (`config.waitTool.name`). One value per process: the parent
|
|
5
|
+
* sets it from config, a child runtime from its launch config, and an async runner from its runner config, because
|
|
6
|
+
* every runtime in a process descends from the same parent setting.
|
|
7
|
+
*/
|
|
8
|
+
export function waitToolName() {
|
|
9
|
+
return current;
|
|
10
|
+
}
|
|
11
|
+
export function setWaitToolName(name) {
|
|
12
|
+
current = name;
|
|
13
|
+
}
|