@ashx-j/lunr-dev 0.2.40-dev.54.2 → 0.2.40-dev.58.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/builtin-extensions/pi-subagents/src/runs/background/attempt-usage.d.ts +5 -0
  2. package/dist/builtin-extensions/pi-subagents/src/runs/background/attempt-usage.js +31 -0
  3. package/dist/builtin-extensions/pi-subagents/src/runs/background/child-stream.d.ts +65 -0
  4. package/dist/builtin-extensions/pi-subagents/src/runs/background/child-stream.js +456 -0
  5. package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-group-status.d.ts +42 -0
  6. package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-group-status.js +79 -0
  7. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-log.d.ts +18 -0
  8. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-log.js +43 -0
  9. package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-event-log.d.ts +3 -0
  10. package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-event-log.js +70 -0
  11. package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-single-step.d.ts +92 -0
  12. package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-single-step.js +491 -0
  13. package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-status.d.ts +64 -0
  14. package/dist/builtin-extensions/pi-subagents/src/runs/background/runner-status.js +26 -0
  15. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts +1 -115
  16. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +17 -1160
  17. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-run-control.d.ts +19 -0
  18. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-run-control.js +331 -0
  19. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution-input.d.ts +37 -0
  20. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution-input.js +321 -0
  21. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/executor-types.d.ts +124 -0
  22. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/executor-types.js +2 -0
  23. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/foreground-notifications.d.ts +17 -0
  24. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/foreground-notifications.js +98 -0
  25. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/foreground-run-registry.d.ts +40 -0
  26. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/foreground-run-registry.js +172 -0
  27. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/fork-policy.d.ts +14 -0
  28. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/fork-policy.js +161 -0
  29. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/nested-run-control.d.ts +46 -0
  30. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/nested-run-control.js +195 -0
  31. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/parallel-run.d.ts +10 -0
  32. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/parallel-run.js +537 -0
  33. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts +5 -81
  34. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +26 -1763
  35. package/dist/builtin-extensions/pi-subagents/src/shared/settings.d.ts +1 -1
  36. package/dist/core/credential-files.d.ts +3 -2
  37. package/dist/core/credential-files.js +10 -4
  38. package/dist/core/permissions.d.ts +6 -0
  39. package/dist/core/permissions.js +6 -0
  40. package/dist/core/tool-call-hooks.js +3 -2
  41. package/dist/node-runtime/{acp-mode-CFYSYACH.js → acp-mode-5KZPFZBO.js} +2 -2
  42. package/dist/node-runtime/{agent-session-services-3ZHQJIKF.js → agent-session-services-KH5CIGC3.js} +5 -5
  43. package/dist/node-runtime/{builtin-extensions-VQHK3YKF.js → builtin-extensions-RZS4SMIS.js} +3 -3
  44. package/dist/node-runtime/{chunk-UZMXBZQT.js → chunk-AKQRASEH.js} +9 -9
  45. package/dist/node-runtime/{chunk-4ZEDT3YW.js → chunk-BJXBM6KD.js} +3 -3
  46. package/dist/node-runtime/{chunk-BNNBTBXY.js → chunk-EJMB4PAV.js} +3 -3
  47. package/dist/node-runtime/{chunk-HVXDYQNN.js → chunk-JI7AUY2T.js} +1 -1
  48. package/dist/node-runtime/{chunk-ITVBE3HR.js → chunk-JJTHGEUS.js} +5 -4
  49. package/dist/node-runtime/{chunk-YDY7A2WB.js → chunk-K24P7GMM.js} +7 -7
  50. package/dist/node-runtime/{chunk-KTCZH72R.js → chunk-LGRRFSE7.js} +3 -2
  51. package/dist/node-runtime/{chunk-7LCR56AK.js → chunk-NWYFKXP5.js} +1 -1
  52. package/dist/node-runtime/{chunk-SV42POA3.js → chunk-PGWSMQ4K.js} +1 -1
  53. package/dist/node-runtime/{chunk-YDMZHLBV.js → chunk-QX5I7QEW.js} +1 -1
  54. package/dist/node-runtime/{chunk-BNZXW77G.js → chunk-RXDLSXEC.js} +1 -1
  55. package/dist/node-runtime/{chunk-N574FRFF.js → chunk-TSZESZ6H.js} +2 -2
  56. package/dist/node-runtime/{chunk-VIYDTWDK.js → chunk-U7MTVVT3.js} +606 -604
  57. package/dist/node-runtime/{chunk-MFDTF25H.js → chunk-UTZCCNFC.js} +5 -5
  58. package/dist/node-runtime/{chunk-U2LTTIWZ.js → chunk-WYJUGRVE.js} +1 -1
  59. package/dist/node-runtime/{chunk-7LNPTBQJ.js → chunk-XPKOWSYN.js} +6 -2
  60. package/dist/node-runtime/{chunk-2ZI6Q6JG.js → chunk-YFXGOLZ6.js} +1 -1
  61. package/dist/node-runtime/{command-SRDEBPUR.js → command-6S6C62CX.js} +1 -1
  62. package/dist/node-runtime/{commands-7EETGZ7V.js → commands-GSZWAQJW.js} +5 -5
  63. package/dist/node-runtime/{commands-CV2JUYHM.js → commands-MM2TPV5I.js} +4 -4
  64. package/dist/node-runtime/{direct-tool-executor-DNZ2MS6Z.js → direct-tool-executor-WJLVHH7U.js} +6 -6
  65. package/dist/node-runtime/{gateway-AMEMDTUT.js → gateway-CWIWPUVC.js} +6 -6
  66. package/dist/node-runtime/index.js +10 -10
  67. package/dist/node-runtime/{init-G23PFPKF.js → init-P3RQ6EFK.js} +5 -5
  68. package/dist/node-runtime/{interactive-mode-7GX3UJFX.js → interactive-mode-2L5JMVKQ.js} +6 -6
  69. package/dist/node-runtime/{lunr-cron-OMQBN3UK.js → lunr-cron-LT3O64NO.js} +4 -4
  70. package/dist/node-runtime/main.js +7 -7
  71. package/dist/node-runtime/{mobile-commands-JQJU35OT.js → mobile-commands-PFXEWP2R.js} +3 -3
  72. package/dist/node-runtime/{pi-mcp-adapter-NKAL5CFR.js → pi-mcp-adapter-2OP5BBC6.js} +8 -8
  73. package/dist/node-runtime/{pi-subagents-36KOL5SV.js → pi-subagents-G2T5XRAX.js} +6 -6
  74. package/dist/node-runtime/{print-mode-Y363FXY4.js → print-mode-S6ZUVPMU.js} +6 -6
  75. package/dist/node-runtime/{proxy-modes-EEYRUGQL.js → proxy-modes-RD2PQ6UH.js} +6 -6
  76. package/dist/node-runtime/rpc-entry.js +7 -7
  77. package/dist/node-runtime/{rpc-mode-ENVT7AXW.js → rpc-mode-C33WERBG.js} +3 -3
  78. package/dist/node-runtime/{src-Y3S2FIS5.js → src-J6FSKIFT.js} +1 -1
  79. package/dist/node-runtime/{subagent-executor-D42G55F5.js → subagent-executor-RTGKJ35C.js} +1924 -1901
  80. package/install-lock/package-lock.json +24 -24
  81. package/install-lock/package.json +2 -2
  82. package/npm-shrinkwrap.json +12 -12
  83. package/package.json +4 -4
@@ -0,0 +1,321 @@
1
+ import { normalizeChildSpec } from "../../shared/child-spec.js";
2
+ import { isParallelStep, isDynamicParallelStep } from "../../shared/settings.js";
3
+ import { normalizeSkillInput } from "../../agents/skills.js";
4
+ import { validateChainOutputBindingsWithContext, ChainOutputValidationError } from "../shared/chain-outputs.js";
5
+ import { validateExecutionAcceptance } from "../shared/acceptance.js";
6
+ import { validateToolBudgetConfig } from "../shared/tool-budget.js";
7
+ import { withForkContext } from "./fork-policy.js";
8
+ export function validateExecutionInput(params, hasChain, hasTasks, hasSingle, allowClarifyTaskPrompt) {
9
+ if (Number(hasChain) + Number(hasTasks) + Number(hasSingle) !== 1) {
10
+ return {
11
+ content: [
12
+ {
13
+ type: "text",
14
+ text: "Provide exactly one mode: { task, description, permissions? }, { tasks: [...] }, or { chain: [...] }.",
15
+ },
16
+ ],
17
+ isError: true,
18
+ details: { mode: "single", results: [] },
19
+ };
20
+ }
21
+ const acceptanceErrors = validateExecutionAcceptance(params);
22
+ if (acceptanceErrors.length > 0) {
23
+ return {
24
+ content: [{ type: "text", text: acceptanceErrors.join(" ") }],
25
+ isError: true,
26
+ details: { mode: getRequestedModeLabel(params), results: [] },
27
+ };
28
+ }
29
+ if (hasSingle && !params.description) {
30
+ return {
31
+ content: [{ type: "text", text: "description is required and must be a concise single-line label (max 80 characters)." }],
32
+ isError: true,
33
+ details: { mode: "single", results: [] },
34
+ };
35
+ }
36
+ if (hasTasks && params.tasks) {
37
+ for (let i = 0; i < params.tasks.length; i++) {
38
+ const task = params.tasks[i];
39
+ if (!task.description) {
40
+ return {
41
+ content: [{ type: "text", text: `description is required (task ${i + 1})` }],
42
+ isError: true,
43
+ details: { mode: "parallel", results: [] },
44
+ };
45
+ }
46
+ }
47
+ }
48
+ if (hasChain && params.chain) {
49
+ if (params.chain.length === 0) {
50
+ return {
51
+ content: [{ type: "text", text: "Chain must have at least one step" }],
52
+ isError: true,
53
+ details: { mode: "chain", results: [] },
54
+ };
55
+ }
56
+ const firstStep = params.chain[0];
57
+ if (isParallelStep(firstStep)) {
58
+ const missingTaskIndex = firstStep.parallel.findIndex((t) => !t.task);
59
+ if (missingTaskIndex !== -1) {
60
+ return {
61
+ content: [{ type: "text", text: `First parallel step: task ${missingTaskIndex + 1} must have a task (no previous output to reference)` }],
62
+ isError: true,
63
+ details: { mode: "chain", results: [] },
64
+ };
65
+ }
66
+ }
67
+ else if (isDynamicParallelStep(firstStep)) {
68
+ return {
69
+ content: [{ type: "text", text: "First step in chain cannot be dynamic fanout; expand.from requires a prior structured named output" }],
70
+ isError: true,
71
+ details: { mode: "chain", results: [] },
72
+ };
73
+ }
74
+ else if (!firstStep.task && !params.task && !allowClarifyTaskPrompt) {
75
+ return {
76
+ content: [{ type: "text", text: "First step in chain must have a task" }],
77
+ isError: true,
78
+ details: { mode: "chain", results: [] },
79
+ };
80
+ }
81
+ for (let i = 0; i < params.chain.length; i++) {
82
+ const step = params.chain[i];
83
+ if (!isParallelStep(step) && !isDynamicParallelStep(step) && !step.description) {
84
+ return {
85
+ content: [{ type: "text", text: `description is required (step ${i + 1})` }],
86
+ isError: true,
87
+ details: { mode: "chain", results: [] },
88
+ };
89
+ }
90
+ if (isParallelStep(step)) {
91
+ const missing = step.parallel.findIndex((t) => !t.description);
92
+ if (missing !== -1) {
93
+ return {
94
+ content: [{ type: "text", text: `description is required (step ${i + 1}, parallel task ${missing + 1})` }],
95
+ isError: true,
96
+ details: { mode: "chain", results: [] },
97
+ };
98
+ }
99
+ }
100
+ if (isParallelStep(step) && step.parallel.length === 0) {
101
+ return {
102
+ content: [{ type: "text", text: `Parallel step ${i + 1} must have at least one task` }],
103
+ isError: true,
104
+ details: { mode: "chain", results: [] },
105
+ };
106
+ }
107
+ }
108
+ }
109
+ return null;
110
+ }
111
+ export function validateExecutionChainBindings(params, dynamicFanoutMaxItems) {
112
+ if ((params.chain?.length ?? 0) === 0)
113
+ return null;
114
+ try {
115
+ validateChainOutputBindingsWithContext(params.chain, { maxItems: dynamicFanoutMaxItems });
116
+ }
117
+ catch (error) {
118
+ if (error instanceof ChainOutputValidationError) {
119
+ return {
120
+ content: [{ type: "text", text: error.message }],
121
+ isError: true,
122
+ details: { mode: "chain", results: [] },
123
+ };
124
+ }
125
+ throw error;
126
+ }
127
+ return null;
128
+ }
129
+ function getRequestedModeLabel(params) {
130
+ if ((params.chain?.length ?? 0) > 0)
131
+ return "chain";
132
+ if ((params.tasks?.length ?? 0) > 0)
133
+ return "parallel";
134
+ if (params.task)
135
+ return "single";
136
+ return "single";
137
+ }
138
+ export function buildRequestedModeError(params, message) {
139
+ return withForkContext({
140
+ content: [{ type: "text", text: message }],
141
+ isError: true,
142
+ details: { mode: getRequestedModeLabel(params), results: [] },
143
+ }, params.context);
144
+ }
145
+ function runtimeConfigFromChildSpec(spec) {
146
+ return {
147
+ name: spec.childId,
148
+ description: spec.description,
149
+ model: spec.model,
150
+ thinking: undefined,
151
+ systemPromptMode: "append",
152
+ inheritProjectContext: true,
153
+ inheritSkills: false,
154
+ acceptanceRole: spec.effectivePermissions === "read-only" ? "read-only" : "writer",
155
+ systemPrompt: "",
156
+ skills: spec.skill === false ? [] : normalizeSkillInput(spec.skill) || undefined,
157
+ output: typeof spec.output === "string" ? spec.output : undefined,
158
+ toolBudget: spec.toolBudget,
159
+ };
160
+ }
161
+ // The 3 casts to MaterializedParams below: a call sets only one of tasks, chain or task.
162
+ // The lists this function leaves alone are empty, or validateExecutionInput (execute) or the
163
+ // append-step guard rejects the call before anything runs.
164
+ export function internalizePromptDrivenChildren(params, options) {
165
+ const agents = [];
166
+ let flatIndex = 0;
167
+ const normalize = (input, defaultTask) => {
168
+ const spec = normalizeChildSpec(input, {
169
+ parentMode: options.parentMode,
170
+ runId: options.runId,
171
+ index: flatIndex,
172
+ defaultTask,
173
+ });
174
+ agents.push(runtimeConfigFromChildSpec(spec));
175
+ return { input: { ...input, agent: spec.childId }, spec };
176
+ };
177
+ if ((params.tasks?.length ?? 0) > 0) {
178
+ const tasks = params.tasks.map((task) => {
179
+ const normalized = normalize(task);
180
+ flatIndex++;
181
+ return normalized.input;
182
+ });
183
+ return { params: { ...params, tasks }, agents };
184
+ }
185
+ if ((params.chain?.length ?? 0) > 0) {
186
+ const chain = params.chain.map((step) => {
187
+ if (isParallelStep(step)) {
188
+ const parallel = step.parallel.map((task) => {
189
+ const normalized = normalize(task, flatIndex === 0 ? params.task : "{previous}");
190
+ flatIndex++;
191
+ return normalized.input;
192
+ });
193
+ return { ...step, parallel };
194
+ }
195
+ if (isDynamicParallelStep(step)) {
196
+ const normalized = normalize(step.parallel, "{previous}");
197
+ const reserved = step.expand.maxItems ?? options.dynamicFanoutMaxItems ?? 1;
198
+ flatIndex += Math.max(1, reserved);
199
+ return { ...step, parallel: normalized.input };
200
+ }
201
+ const normalized = normalize(step, flatIndex === 0 ? params.task : "{previous}");
202
+ flatIndex++;
203
+ return normalized.input;
204
+ });
205
+ return { params: { ...params, chain }, agents };
206
+ }
207
+ const normalized = normalize({
208
+ agent: params.agent,
209
+ task: params.task ?? "",
210
+ description: params.description,
211
+ permissions: params.permissions,
212
+ cwd: params.cwd,
213
+ model: params.model,
214
+ tier: params.tier,
215
+ thinking: params.thinking,
216
+ skill: params.skill,
217
+ output: params.output,
218
+ outputMode: params.outputMode,
219
+ acceptance: params.acceptance,
220
+ toolBudget: params.toolBudget,
221
+ });
222
+ return {
223
+ params: { ...params, agent: normalized.spec.childId },
224
+ agents,
225
+ };
226
+ }
227
+ export function resolveForegroundTimeout(params) {
228
+ const rawTimeout = params.timeoutMs;
229
+ const rawMaxRuntime = params.maxRuntimeMs;
230
+ if (rawTimeout === undefined && rawMaxRuntime === undefined)
231
+ return {};
232
+ for (const [name, value] of [["timeoutMs", rawTimeout], ["maxRuntimeMs", rawMaxRuntime]]) {
233
+ if (value === undefined)
234
+ continue;
235
+ if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
236
+ return { error: `${name} must be a positive integer.` };
237
+ }
238
+ }
239
+ if (rawTimeout !== undefined && rawMaxRuntime !== undefined && rawTimeout !== rawMaxRuntime) {
240
+ return { error: "timeoutMs and maxRuntimeMs are aliases; provide only one value or use the same value for both." };
241
+ }
242
+ return { timeoutMs: rawTimeout ?? rawMaxRuntime };
243
+ }
244
+ export function resolveToolBudget(raw, label = "toolBudget") {
245
+ const resolved = validateToolBudgetConfig(raw, label);
246
+ return { toolBudget: resolved.budget, error: resolved.error };
247
+ }
248
+ export function resolveEffectiveToolBudget(input) {
249
+ if (input.stepBudget !== undefined)
250
+ return resolveToolBudget(input.stepBudget, "toolBudget");
251
+ if (input.runBudget !== undefined)
252
+ return { toolBudget: input.runBudget };
253
+ if (input.agentBudget !== undefined)
254
+ return resolveToolBudget(input.agentBudget, "agent.toolBudget");
255
+ return resolveToolBudget(input.configBudget, "config.toolBudget");
256
+ }
257
+ function expandTopLevelTaskCounts(tasks) {
258
+ const expanded = [];
259
+ for (let taskIndex = 0; taskIndex < tasks.length; taskIndex++) {
260
+ const task = tasks[taskIndex];
261
+ const rawCount = task.count;
262
+ if (rawCount !== undefined && (typeof rawCount !== "number" || !Number.isInteger(rawCount) || rawCount < 1)) {
263
+ return { error: `tasks[${taskIndex}].count must be an integer >= 1` };
264
+ }
265
+ const { count, ...concreteTask } = task;
266
+ for (let repeat = 0; repeat < (rawCount ?? 1); repeat++) {
267
+ expanded.push({ ...concreteTask });
268
+ }
269
+ }
270
+ return { tasks: expanded };
271
+ }
272
+ function expandChainParallelCounts(chain) {
273
+ const expandedChain = [];
274
+ for (let stepIndex = 0; stepIndex < chain.length; stepIndex++) {
275
+ const step = chain[stepIndex];
276
+ if (!isParallelStep(step)) {
277
+ expandedChain.push(step);
278
+ continue;
279
+ }
280
+ const expandedParallel = [];
281
+ for (let taskIndex = 0; taskIndex < step.parallel.length; taskIndex++) {
282
+ const task = step.parallel[taskIndex];
283
+ const rawCount = task.count;
284
+ if (rawCount !== undefined && (typeof rawCount !== "number" || !Number.isInteger(rawCount) || rawCount < 1)) {
285
+ return { error: `chain[${stepIndex}].parallel[${taskIndex}].count must be an integer >= 1` };
286
+ }
287
+ const { count, ...concreteTask } = task;
288
+ for (let repeat = 0; repeat < (rawCount ?? 1); repeat++) {
289
+ expandedParallel.push({ ...concreteTask });
290
+ }
291
+ }
292
+ expandedChain.push({ ...step, parallel: expandedParallel });
293
+ }
294
+ return { chain: expandedChain };
295
+ }
296
+ export function normalizeRepeatedParallelCounts(params) {
297
+ if (params.tasks) {
298
+ const expandedTasks = expandTopLevelTaskCounts(params.tasks);
299
+ if (expandedTasks.error) {
300
+ return { error: buildRequestedModeError(params, expandedTasks.error) };
301
+ }
302
+ return { params: { ...params, tasks: expandedTasks.tasks } };
303
+ }
304
+ if (params.chain) {
305
+ const expandedChain = expandChainParallelCounts(params.chain);
306
+ if (expandedChain.error) {
307
+ return { error: buildRequestedModeError(params, expandedChain.error) };
308
+ }
309
+ return { params: { ...params, chain: expandedChain.chain } };
310
+ }
311
+ return { params };
312
+ }
313
+ export function toExecutionErrorResult(params, error) {
314
+ const message = error instanceof Error ? error.message : String(error);
315
+ return withForkContext({
316
+ content: [{ type: "text", text: message }],
317
+ isError: true,
318
+ details: { mode: getRequestedModeLabel(params), results: [] },
319
+ }, params.context);
320
+ }
321
+ //# sourceMappingURL=execution-input.js.map
@@ -0,0 +1,124 @@
1
+ import type { ThinkingLevel, AgentToolResult } from "@ashx-j/lunr-agent";
2
+ import type { ExtensionAPI, ExtensionContext } from "@ashx-j/lunr-dev";
3
+ import type { MainWatchdogRuntime } from "../../watchdog/runtime.ts";
4
+ import type { ModelScopeConfig } from "../shared/model-scope.ts";
5
+ import type { ChainStep, Materialized, MaterializedChainStep } from "../../shared/settings.ts";
6
+ import type { IntercomBridgeState } from "../../intercom/intercom-bridge.ts";
7
+ import type { AcceptanceInput, ToolBudgetConfig, TurnBudgetConfig, ControlConfig, MaxOutputConfig, SubagentState, ExtensionConfig, Details, ChildRuntimeConfig, ArtifactConfig, ResolvedControlConfig, NestedRouteInfo, ResolvedTurnBudget, ResolvedToolBudget } from "../../shared/types.ts";
8
+ export interface TaskParam {
9
+ agent?: string;
10
+ task: string;
11
+ thinking?: ThinkingLevel;
12
+ description?: string;
13
+ permissions?: "full" | "read-only";
14
+ cwd?: string;
15
+ count?: number;
16
+ output?: string | boolean;
17
+ outputMode?: "inline" | "file-only";
18
+ reads?: string[] | boolean;
19
+ progress?: boolean;
20
+ model?: string;
21
+ tier?: "light" | "standard" | "heavy";
22
+ skill?: string | string[] | boolean;
23
+ acceptance?: AcceptanceInput;
24
+ toolBudget?: ToolBudgetConfig;
25
+ }
26
+ export interface SubagentParamsLike {
27
+ action?: string;
28
+ id?: string;
29
+ runId?: string;
30
+ dir?: string;
31
+ index?: number;
32
+ view?: "fleet" | "transcript";
33
+ lines?: number;
34
+ agent?: string;
35
+ task?: string;
36
+ description?: string;
37
+ permissions?: "full" | "read-only";
38
+ message?: string;
39
+ chain?: ChainStep[];
40
+ tasks?: TaskParam[];
41
+ concurrency?: number;
42
+ worktree?: boolean;
43
+ context?: "fresh" | "fork";
44
+ async?: boolean;
45
+ foregroundOnly?: boolean;
46
+ timeoutMs?: number;
47
+ maxRuntimeMs?: number;
48
+ turnBudget?: TurnBudgetConfig;
49
+ toolBudget?: ToolBudgetConfig;
50
+ clarify?: boolean;
51
+ control?: ControlConfig;
52
+ sessionDir?: string;
53
+ cwd?: string;
54
+ maxOutput?: MaxOutputConfig;
55
+ artifacts?: boolean;
56
+ includeProgress?: boolean;
57
+ model?: string;
58
+ tier?: "light" | "standard" | "heavy";
59
+ thinking?: string | false;
60
+ scope?: string;
61
+ target?: string;
62
+ skill?: string | string[] | boolean;
63
+ output?: string | boolean;
64
+ outputMode?: "inline" | "file-only";
65
+ chainDir?: string;
66
+ acceptance?: AcceptanceInput;
67
+ schedule?: string;
68
+ scheduleName?: string;
69
+ }
70
+ /** SubagentParamsLike after internalizePromptDrivenChildren gave every child its agent (the child id). */
71
+ export type MaterializedParams = Omit<SubagentParamsLike, "tasks" | "chain"> & {
72
+ tasks?: Materialized<TaskParam>[];
73
+ chain?: MaterializedChainStep[];
74
+ };
75
+ export interface ExecutorDeps {
76
+ pi: ExtensionAPI;
77
+ state: SubagentState;
78
+ config: ExtensionConfig;
79
+ waitToolEnabled?: boolean;
80
+ handleScheduledRunAction?: (params: SubagentParamsLike, ctx: ExtensionContext) => Promise<AgentToolResult<Details>>;
81
+ watchdog?: MainWatchdogRuntime;
82
+ tempArtifactsDir: string;
83
+ getSubagentSessionRoot: (parentSessionFile: string | null) => string;
84
+ expandTilde: (p: string) => string;
85
+ allowMutatingManagementActions?: boolean;
86
+ kill?: (pid: number, signal?: NodeJS.Signals | 0) => boolean;
87
+ }
88
+ export type ForkSessionFileForTask = (agentName: string, idx?: number, modelOverride?: string) => string | undefined;
89
+ export type ForkThinkingOverrideForTask = (agentName: string, idx?: number, modelOverride?: string) => ChildRuntimeConfig["thinking"] | undefined;
90
+ export interface ExecutionContextData {
91
+ params: MaterializedParams;
92
+ effectiveCwd: string;
93
+ ctx: ExtensionContext;
94
+ signal: AbortSignal | undefined;
95
+ onUpdate?: (r: AgentToolResult<Details>) => void;
96
+ agents: ChildRuntimeConfig[];
97
+ runId: string;
98
+ sessionRoot: string;
99
+ sessionDirForIndex: (idx?: number) => string;
100
+ sessionFileForIndex: (idx?: number) => string | undefined;
101
+ sessionFileForTask: ForkSessionFileForTask;
102
+ thinkingOverrideForTask: ForkThinkingOverrideForTask;
103
+ artifactConfig: ArtifactConfig;
104
+ artifactsDir: string;
105
+ backgroundRequestedWhileClarifying: boolean;
106
+ effectiveAsync: boolean;
107
+ controlConfig: ResolvedControlConfig;
108
+ intercomBridge: IntercomBridgeState;
109
+ nestedRoute?: NestedRouteInfo;
110
+ timeoutMs?: number;
111
+ deadlineAt?: number;
112
+ turnBudget?: ResolvedTurnBudget;
113
+ toolBudget?: ResolvedToolBudget;
114
+ configToolBudget?: ResolvedToolBudget;
115
+ contextPolicy: AgentDefaultContextPolicy;
116
+ modelScope?: ModelScopeConfig;
117
+ parentSessionId: string | null;
118
+ }
119
+ export interface AgentDefaultContextPolicy<P extends SubagentParamsLike = SubagentParamsLike> {
120
+ params: P;
121
+ contextForAgent(agentName: string): "fresh" | "fork";
122
+ usesFork: boolean;
123
+ }
124
+ //# sourceMappingURL=executor-types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=executor-types.js.map
@@ -0,0 +1,17 @@
1
+ import type { ExtensionAPI } from "@ashx-j/lunr-dev";
2
+ import { type IntercomBridgeState } from "../../intercom/intercom-bridge.ts";
3
+ import { type ControlEvent, type SubagentRunMode, type NestedRunSummary, type Details } from "../../shared/types.ts";
4
+ import type { ExecutionContextData, ExecutorDeps } from "./executor-types.ts";
5
+ export declare function createForegroundControlNotifier(data: Pick<ExecutionContextData, "controlConfig" | "intercomBridge">, deps: Pick<ExecutorDeps, "pi">): (event: ControlEvent) => void;
6
+ export declare function maybeBuildForegroundIntercomReceipt(input: {
7
+ pi: ExtensionAPI;
8
+ intercomBridge: IntercomBridgeState;
9
+ runId: string;
10
+ mode: SubagentRunMode;
11
+ details: Details;
12
+ nestedChildren?: NestedRunSummary[];
13
+ }): Promise<{
14
+ text: string;
15
+ details: Details;
16
+ } | null>;
17
+ //# sourceMappingURL=foreground-notifications.d.ts.map
@@ -0,0 +1,98 @@
1
+ import { getSingleResultOutput } from "../../shared/utils.js";
2
+ import { resolveSubagentIntercomTarget } from "../../intercom/intercom-bridge.js";
3
+ import { shouldNotifyControlEvent, formatControlNoticeMessage, formatControlIntercomMessage } from "../shared/subagent-control.js";
4
+ import { buildSubagentResultIntercomPayload, resolveSubagentResultStatus, attachNestedChildrenToResultChildren, deliverSubagentResultIntercomEvent, formatSubagentResultReceipt, stripDetailsOutputsForIntercomReceipt } from "../../intercom/result-intercom.js";
5
+ import { SUBAGENT_CONTROL_EVENT, SUBAGENT_CONTROL_INTERCOM_EVENT } from "../../shared/types.js";
6
+ function emitControlNotification(input) {
7
+ if (!shouldNotifyControlEvent(input.controlConfig, input.event))
8
+ return;
9
+ const childIntercomTarget = input.intercomBridge.active
10
+ ? resolveSubagentIntercomTarget(input.event.runId, input.event.agent, input.event.index)
11
+ : undefined;
12
+ const payload = {
13
+ event: input.event,
14
+ source: "foreground",
15
+ childIntercomTarget,
16
+ noticeText: formatControlNoticeMessage(input.event, childIntercomTarget),
17
+ };
18
+ if (input.controlConfig.notifyChannels.includes("event")) {
19
+ input.pi.events.emit(SUBAGENT_CONTROL_EVENT, payload);
20
+ }
21
+ if (input.event.type !== "active_long_running" && input.controlConfig.notifyChannels.includes("intercom") && input.intercomBridge.active && input.intercomBridge.orchestratorTarget) {
22
+ input.pi.events.emit(SUBAGENT_CONTROL_INTERCOM_EVENT, {
23
+ ...payload,
24
+ to: input.intercomBridge.orchestratorTarget,
25
+ message: formatControlIntercomMessage(input.event, childIntercomTarget),
26
+ });
27
+ }
28
+ }
29
+ function resultSummaryForIntercom(result) {
30
+ const output = getSingleResultOutput(result);
31
+ if (result.exitCode !== 0 && result.error) {
32
+ return output ? `${result.error}\n\nOutput:\n${output}` : result.error;
33
+ }
34
+ const summary = output || result.error || "(no output)";
35
+ // Inline mode sends the reply as the summary, so name the saved output file too: a relative
36
+ // `output` lands in the run's directory, not where the model would guess.
37
+ const reference = result.outputReference?.message;
38
+ return reference && !summary.includes(reference) ? `${summary}\n\n${reference}` : summary;
39
+ }
40
+ export function createForegroundControlNotifier(data, deps) {
41
+ return (event) => emitControlNotification({
42
+ pi: deps.pi,
43
+ controlConfig: data.controlConfig,
44
+ intercomBridge: data.intercomBridge,
45
+ event,
46
+ });
47
+ }
48
+ async function emitForegroundResultIntercom(input) {
49
+ if (!input.intercomBridge.active || !input.intercomBridge.orchestratorTarget)
50
+ return null;
51
+ const children = input.results.flatMap((result, index) => result.detached ? [] : [{
52
+ agent: result.agent,
53
+ status: resolveSubagentResultStatus({
54
+ exitCode: result.exitCode,
55
+ interrupted: result.interrupted,
56
+ detached: result.detached,
57
+ }),
58
+ summary: resultSummaryForIntercom(result),
59
+ index,
60
+ artifactPath: result.artifactPaths?.outputPath,
61
+ sessionPath: result.sessionFile,
62
+ intercomTarget: resolveSubagentIntercomTarget(input.runId, result.agent, index),
63
+ }]);
64
+ if (children.length === 0)
65
+ return null;
66
+ const payload = buildSubagentResultIntercomPayload({
67
+ to: input.intercomBridge.orchestratorTarget,
68
+ runId: input.runId,
69
+ mode: input.mode,
70
+ source: "foreground",
71
+ children: attachNestedChildrenToResultChildren(input.runId, children, input.nestedChildren),
72
+ ...(typeof input.chainSteps === "number" ? { chainSteps: input.chainSteps } : {}),
73
+ });
74
+ const delivered = await deliverSubagentResultIntercomEvent(input.pi.events, payload);
75
+ if (!delivered)
76
+ return null;
77
+ return payload;
78
+ }
79
+ export async function maybeBuildForegroundIntercomReceipt(input) {
80
+ const payload = await emitForegroundResultIntercom({
81
+ pi: input.pi,
82
+ intercomBridge: input.intercomBridge,
83
+ runId: input.runId,
84
+ mode: input.mode,
85
+ results: input.details.results,
86
+ ...(typeof input.details.totalSteps === "number" ? { chainSteps: input.details.totalSteps } : {}),
87
+ ...(input.nestedChildren?.length ? { nestedChildren: input.nestedChildren } : {}),
88
+ });
89
+ if (!payload)
90
+ return null;
91
+ // The receipt replaces the result text, so output files that failed to save must be named here.
92
+ const warnings = input.details.results.flatMap((result) => result.outputSaveError ? [`Output warning (${result.agent}): ${result.outputSaveError}`] : []);
93
+ return {
94
+ text: [formatSubagentResultReceipt({ mode: input.mode, runId: input.runId, payload }), ...warnings].join("\n"),
95
+ details: stripDetailsOutputsForIntercomReceipt(input.details),
96
+ };
97
+ }
98
+ //# sourceMappingURL=foreground-notifications.js.map
@@ -0,0 +1,40 @@
1
+ import type { AgentToolResult } from "@ashx-j/lunr-agent";
2
+ import { type SubagentState, type Details, type SingleResult, type IntercomEventBus } from "../../shared/types.ts";
3
+ export declare function getForegroundControl(state: SubagentState, runId: string | undefined): {
4
+ runId: string;
5
+ mode: import("../../shared/types.ts").SubagentRunMode;
6
+ startedAt: number;
7
+ updatedAt: number;
8
+ currentAgent?: string | undefined;
9
+ currentChildId?: string | undefined;
10
+ currentIndex?: number | undefined;
11
+ currentActivityState?: import("../../shared/types.ts").ActivityState | undefined;
12
+ lastActivityAt?: number | undefined;
13
+ currentTool?: string | undefined;
14
+ currentToolStartedAt?: number | undefined;
15
+ currentPath?: string | undefined;
16
+ turnCount?: number | undefined;
17
+ tokens?: number | undefined;
18
+ toolCount?: number | undefined;
19
+ nestedRoute?: import("../../shared/types.ts").NestedRouteInfo | undefined;
20
+ nestedChildren?: import("../../shared/types.ts").NestedRunSummary[] | undefined;
21
+ interrupt?: (() => boolean) | undefined;
22
+ } | undefined;
23
+ export declare function foregroundStatusResult(control: SubagentState["foregroundControls"] extends Map<string, infer T> ? T : never): AgentToolResult<Details>;
24
+ export declare function rememberForegroundRun(state: SubagentState, input: {
25
+ runId: string;
26
+ mode: "single" | "parallel" | "chain";
27
+ cwd: string;
28
+ sessionId: string | null;
29
+ results: SingleResult[];
30
+ }): void;
31
+ export declare function updateRememberedForegroundChild(state: SubagentState, input: {
32
+ runId: string;
33
+ mode: "single" | "parallel" | "chain";
34
+ cwd: string;
35
+ sessionId: string | null;
36
+ index: number;
37
+ result: SingleResult;
38
+ events: IntercomEventBus;
39
+ }): void;
40
+ //# sourceMappingURL=foreground-run-registry.d.ts.map