@caupulican/pi-adaptative 0.93.3 → 0.93.5

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 (182) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/core/agent-session.d.ts.map +1 -1
  3. package/dist/core/agent-session.js +15 -9
  4. package/dist/core/agent-session.js.map +1 -1
  5. package/dist/core/autonomy/approval-gate.d.ts +1 -0
  6. package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
  7. package/dist/core/autonomy/approval-gate.js +4 -1
  8. package/dist/core/autonomy/approval-gate.js.map +1 -1
  9. package/dist/core/autonomy/composite-tool-gate.d.ts +13 -0
  10. package/dist/core/autonomy/composite-tool-gate.d.ts.map +1 -0
  11. package/dist/core/autonomy/composite-tool-gate.js +44 -0
  12. package/dist/core/autonomy/composite-tool-gate.js.map +1 -0
  13. package/dist/core/autonomy/envelope-enforcement.d.ts +2 -0
  14. package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
  15. package/dist/core/autonomy/envelope-enforcement.js +48 -7
  16. package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
  17. package/dist/core/autonomy/gates.d.ts.map +1 -1
  18. package/dist/core/autonomy/gates.js +48 -76
  19. package/dist/core/autonomy/gates.js.map +1 -1
  20. package/dist/core/autonomy/path-scope.d.ts.map +1 -1
  21. package/dist/core/autonomy/path-scope.js +7 -7
  22. package/dist/core/autonomy/path-scope.js.map +1 -1
  23. package/dist/core/background-tool-task-controller.d.ts +2 -0
  24. package/dist/core/background-tool-task-controller.d.ts.map +1 -1
  25. package/dist/core/background-tool-task-controller.js +13 -5
  26. package/dist/core/background-tool-task-controller.js.map +1 -1
  27. package/dist/core/compaction-controller.d.ts +3 -0
  28. package/dist/core/compaction-controller.d.ts.map +1 -1
  29. package/dist/core/compaction-controller.js +132 -97
  30. package/dist/core/compaction-controller.js.map +1 -1
  31. package/dist/core/delegation/session-root-mailbox.d.ts.map +1 -1
  32. package/dist/core/delegation/session-root-mailbox.js +14 -1
  33. package/dist/core/delegation/session-root-mailbox.js.map +1 -1
  34. package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
  35. package/dist/core/delegation/worker-agent-control-coordinator.js +6 -9
  36. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
  37. package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
  38. package/dist/core/delegation/worker-authority-resolver.js +3 -2
  39. package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
  40. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
  41. package/dist/core/delegation/worker-execution-policy.js +10 -8
  42. package/dist/core/delegation/worker-execution-policy.js.map +1 -1
  43. package/dist/core/foreground-recovery-controller.d.ts +2 -0
  44. package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
  45. package/dist/core/foreground-recovery-controller.js +18 -9
  46. package/dist/core/foreground-recovery-controller.js.map +1 -1
  47. package/dist/core/goal-loop-controller.d.ts.map +1 -1
  48. package/dist/core/goal-loop-controller.js +3 -5
  49. package/dist/core/goal-loop-controller.js.map +1 -1
  50. package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
  51. package/dist/core/goals/goal-auto-continue-controller.js +6 -0
  52. package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
  53. package/dist/core/goals/goal-state.d.ts.map +1 -1
  54. package/dist/core/goals/goal-state.js +1 -0
  55. package/dist/core/goals/goal-state.js.map +1 -1
  56. package/dist/core/goals/goal-tool-core.d.ts +2 -0
  57. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  58. package/dist/core/goals/goal-tool-core.js +1 -1
  59. package/dist/core/goals/goal-tool-core.js.map +1 -1
  60. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
  61. package/dist/core/orchestration/capability-gateway.js +32 -9
  62. package/dist/core/orchestration/capability-gateway.js.map +1 -1
  63. package/dist/core/orchestration/lane-tool-manifests.js +5 -5
  64. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  65. package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
  66. package/dist/core/orchestration/policy-compiler.js +7 -0
  67. package/dist/core/orchestration/policy-compiler.js.map +1 -1
  68. package/dist/core/orchestration/profile-registry.js +2 -2
  69. package/dist/core/orchestration/profile-registry.js.map +1 -1
  70. package/dist/core/pipelines/active-context.d.ts +16 -0
  71. package/dist/core/pipelines/active-context.d.ts.map +1 -0
  72. package/dist/core/pipelines/active-context.js +29 -0
  73. package/dist/core/pipelines/active-context.js.map +1 -0
  74. package/dist/core/pipelines/context.d.ts +1 -1
  75. package/dist/core/pipelines/context.d.ts.map +1 -1
  76. package/dist/core/pipelines/context.js +40 -31
  77. package/dist/core/pipelines/context.js.map +1 -1
  78. package/dist/core/pipelines/discover.d.ts +5 -1
  79. package/dist/core/pipelines/discover.d.ts.map +1 -1
  80. package/dist/core/pipelines/discover.js +91 -33
  81. package/dist/core/pipelines/discover.js.map +1 -1
  82. package/dist/core/pipelines/increment.d.ts +0 -2
  83. package/dist/core/pipelines/increment.d.ts.map +1 -1
  84. package/dist/core/pipelines/increment.js +35 -13
  85. package/dist/core/pipelines/increment.js.map +1 -1
  86. package/dist/core/pipelines/index.d.ts +4 -3
  87. package/dist/core/pipelines/index.d.ts.map +1 -1
  88. package/dist/core/pipelines/index.js +4 -3
  89. package/dist/core/pipelines/index.js.map +1 -1
  90. package/dist/core/pipelines/run-state.d.ts +8 -0
  91. package/dist/core/pipelines/run-state.d.ts.map +1 -1
  92. package/dist/core/pipelines/run-state.js +172 -38
  93. package/dist/core/pipelines/run-state.js.map +1 -1
  94. package/dist/core/pipelines/types.d.ts +2 -0
  95. package/dist/core/pipelines/types.d.ts.map +1 -1
  96. package/dist/core/pipelines/types.js +21 -4
  97. package/dist/core/pipelines/types.js.map +1 -1
  98. package/dist/core/runtime-builder.d.ts +2 -1
  99. package/dist/core/runtime-builder.d.ts.map +1 -1
  100. package/dist/core/runtime-builder.js +46 -10
  101. package/dist/core/runtime-builder.js.map +1 -1
  102. package/dist/core/skill-vault.d.ts +18 -14
  103. package/dist/core/skill-vault.d.ts.map +1 -1
  104. package/dist/core/skill-vault.js +140 -81
  105. package/dist/core/skill-vault.js.map +1 -1
  106. package/dist/core/system-prompt-builder.d.ts +1 -0
  107. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  108. package/dist/core/system-prompt-builder.js +25 -1
  109. package/dist/core/system-prompt-builder.js.map +1 -1
  110. package/dist/core/system-prompt.d.ts.map +1 -1
  111. package/dist/core/system-prompt.js +6 -1
  112. package/dist/core/system-prompt.js.map +1 -1
  113. package/dist/core/tasks/task-projection.d.ts +2 -0
  114. package/dist/core/tasks/task-projection.d.ts.map +1 -1
  115. package/dist/core/tasks/task-projection.js +2 -0
  116. package/dist/core/tasks/task-projection.js.map +1 -1
  117. package/dist/core/tasks/task-state.d.ts +10 -0
  118. package/dist/core/tasks/task-state.d.ts.map +1 -1
  119. package/dist/core/tasks/task-state.js +43 -2
  120. package/dist/core/tasks/task-state.js.map +1 -1
  121. package/dist/core/tool-capability-policy.d.ts +13 -3
  122. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  123. package/dist/core/tool-capability-policy.js +136 -28
  124. package/dist/core/tool-capability-policy.js.map +1 -1
  125. package/dist/core/tools/bash.d.ts +3 -1
  126. package/dist/core/tools/bash.d.ts.map +1 -1
  127. package/dist/core/tools/bash.js +13 -4
  128. package/dist/core/tools/bash.js.map +1 -1
  129. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  130. package/dist/core/tools/edit-diff.js +45 -7
  131. package/dist/core/tools/edit-diff.js.map +1 -1
  132. package/dist/core/tools/edit.d.ts.map +1 -1
  133. package/dist/core/tools/edit.js +4 -0
  134. package/dist/core/tools/edit.js.map +1 -1
  135. package/dist/core/tools/goal.d.ts.map +1 -1
  136. package/dist/core/tools/goal.js +17 -1
  137. package/dist/core/tools/goal.js.map +1 -1
  138. package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
  139. package/dist/core/tools/orchestration-panel.js +1 -0
  140. package/dist/core/tools/orchestration-panel.js.map +1 -1
  141. package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -1
  142. package/dist/core/tools/persistent-process-coordinator.js +12 -7
  143. package/dist/core/tools/persistent-process-coordinator.js.map +1 -1
  144. package/dist/core/tools/pipeline.d.ts +1 -0
  145. package/dist/core/tools/pipeline.d.ts.map +1 -1
  146. package/dist/core/tools/pipeline.js +95 -44
  147. package/dist/core/tools/pipeline.js.map +1 -1
  148. package/dist/core/tools/secret-store.d.ts.map +1 -1
  149. package/dist/core/tools/secret-store.js +2 -1
  150. package/dist/core/tools/secret-store.js.map +1 -1
  151. package/dist/core/tools/shell-session.d.ts +3 -1
  152. package/dist/core/tools/shell-session.d.ts.map +1 -1
  153. package/dist/core/tools/shell-session.js +96 -16
  154. package/dist/core/tools/shell-session.js.map +1 -1
  155. package/dist/core/tools/skill.d.ts +1 -1
  156. package/dist/core/tools/skill.d.ts.map +1 -1
  157. package/dist/core/tools/skill.js +20 -11
  158. package/dist/core/tools/skill.js.map +1 -1
  159. package/dist/core/tools/task-steps.d.ts +10 -0
  160. package/dist/core/tools/task-steps.d.ts.map +1 -1
  161. package/dist/core/tools/task-steps.js +70 -29
  162. package/dist/core/tools/task-steps.js.map +1 -1
  163. package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
  164. package/dist/core/tools/windows-shell-engine.js +6 -1
  165. package/dist/core/tools/windows-shell-engine.js.map +1 -1
  166. package/dist/core/util/bounded-file.d.ts +8 -0
  167. package/dist/core/util/bounded-file.d.ts.map +1 -1
  168. package/dist/core/util/bounded-file.js +81 -16
  169. package/dist/core/util/bounded-file.js.map +1 -1
  170. package/dist/index.d.ts +1 -1
  171. package/dist/index.d.ts.map +1 -1
  172. package/dist/index.js +1 -1
  173. package/dist/index.js.map +1 -1
  174. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  175. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  176. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  177. package/examples/extensions/sandbox/package-lock.json +2 -2
  178. package/examples/extensions/sandbox/package.json +1 -1
  179. package/examples/extensions/with-deps/package-lock.json +2 -2
  180. package/examples/extensions/with-deps/package.json +1 -1
  181. package/npm-shrinkwrap.json +12 -12
  182. package/package.json +4 -4
@@ -1,6 +1,7 @@
1
1
  import { Type } from "typebox";
2
2
  import { advanceTaskSteps } from "../pipelines/increment.js";
3
- import { addTaskStep, clearTaskSteps, compactTaskSteps, createTaskStepsState, findOpenDuplicateStep, formatTaskSteps, hasUnverifiedCompletedStep, MAX_TASK_STEPS, resolveTaskStepSelector, setTaskSteps, updateTaskStep, } from "../tasks/task-state.js";
3
+ import { MAX_PIPELINE_STAGE_ID_LENGTH } from "../pipelines/types.js";
4
+ import { addTaskStep, clearTaskSteps, compactTaskSteps, createTaskStepsState, findOpenDuplicateStep, formatTaskSteps, hasUnverifiedCompletedStep, MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH, MAX_TASK_STEPS, normalizeTaskStepPipelineLink, resolveTaskStepSelector, setTaskSteps, TaskStepsError, updateTaskStep, } from "../tasks/task-state.js";
4
5
  import { emptyOrchestrationCall, OrchestrationPanelComponent, taskStepPanelRow, } from "./orchestration-panel.js";
5
6
  const statusSchema = Type.Union([
6
7
  Type.Literal("pending"),
@@ -19,6 +20,19 @@ function optionalTaskStepFields(requirementIdsDescription) {
19
20
  maxItems: 32,
20
21
  description: requirementIdsDescription,
21
22
  })),
23
+ pipelineRunId: Type.Optional(Type.String({
24
+ minLength: 1,
25
+ maxLength: MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH,
26
+ description: "Active pipeline run id this step advances. Supply together with pipelineStageId.",
27
+ })),
28
+ pipelineStageId: Type.Optional(Type.String({
29
+ minLength: 1,
30
+ maxLength: MAX_PIPELINE_STAGE_ID_LENGTH,
31
+ description: "Stage id in pipelineRunId this step advances. Supply both ids together.",
32
+ })),
33
+ clearPipelineLink: Type.Optional(Type.Boolean({
34
+ description: "Remove both pipeline ids. Cannot be combined with pipelineRunId/pipelineStageId.",
35
+ })),
22
36
  note: Type.Optional(Type.String({ maxLength: 4_000 })),
23
37
  evidence: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 2_000 }), { maxItems: 32 })),
24
38
  };
@@ -53,18 +67,43 @@ const taskStepsSchema = Type.Object({
53
67
  showCompleted: Type.Optional(Type.Boolean({ description: "Include completed and cancelled steps in output." })),
54
68
  maxItems: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TASK_STEPS })),
55
69
  }, { additionalProperties: false });
56
- function toTaskStepInput(input) {
70
+ function toTaskStepUpdate(input) {
57
71
  return {
58
- content: input.content ?? "",
72
+ content: input.content,
59
73
  activeForm: input.activeForm,
60
74
  status: input.status,
61
75
  priority: input.priority,
62
76
  owner: input.owner,
63
77
  requirementIds: input.requirementIds,
78
+ pipelineRunId: input.pipelineRunId,
79
+ pipelineStageId: input.pipelineStageId,
80
+ clearPipelineLink: input.clearPipelineLink,
64
81
  note: input.note,
65
82
  evidence: input.evidence,
66
83
  };
67
84
  }
85
+ function toTaskStepInput(input) {
86
+ return { ...toTaskStepUpdate(input), content: input.content ?? "" };
87
+ }
88
+ function validatePipelineLink(deps, pipelineRunId, pipelineStageId, clearPipelineLink = false) {
89
+ const { pipelineRunId: runId, pipelineStageId: stageId } = normalizeTaskStepPipelineLink(pipelineRunId, pipelineStageId, clearPipelineLink);
90
+ if (!runId || !stageId)
91
+ return;
92
+ const active = deps.getActivePipelineScope?.();
93
+ if (!active)
94
+ throw new TaskStepsError("Task step pipeline linkage requires an active pipeline run.");
95
+ if (runId !== active.runId) {
96
+ throw new TaskStepsError(`Task step pipelineRunId must match active run '${active.runId}'.`);
97
+ }
98
+ if (!active.stageIds.includes(stageId)) {
99
+ throw new TaskStepsError(`Task step pipelineStageId '${stageId}' is not in active run '${active.runId}'.`);
100
+ }
101
+ }
102
+ function validatePipelineInputs(deps, inputs) {
103
+ for (const input of inputs) {
104
+ validatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);
105
+ }
106
+ }
68
107
  function counts(state) {
69
108
  const openStepCount = state.steps.filter((step) => step.status !== "completed" && step.status !== "cancelled").length;
70
109
  return {
@@ -99,6 +138,7 @@ function errorResult(action, error, state) {
99
138
  return {
100
139
  content: [{ type: "text", text: `task_steps ${action} failed: ${error}` }],
101
140
  details: { action, applied: false, error, state, ...(state ? counts(state) : {}) },
141
+ isError: true,
102
142
  };
103
143
  }
104
144
  function taskStepsPanelModel(details, expanded) {
@@ -177,14 +217,15 @@ export function createTaskStepsToolDefinition(deps) {
177
217
  description: "Track the session's ordered multi-step checklist with status, notes, and evidence. Use goal for durable outcomes and delegate for workers.",
178
218
  promptSnippet: "Track multi-step session work.",
179
219
  promptGuidelines: [
180
- "Use for complex/explicitly tracked work, not one-step work. Keep one in_progress step.",
181
- "Batch transitions. Address first open step; record evidence/blocker. Never call only to narrate unchanged state.",
182
- "intake preserves every supplied item; link steps to active goal requirementIds.",
183
- "advance completes the current step then starts the next pending step.",
184
- "Attach completed tool_task taskIds as evidence. Goal complete refuses while linked steps stay open.",
185
- "Before final: clear stale in_progress, discuss/defer remainder. Goal owns outcomes; delegate owns workers.",
220
+ "Use for multi-step work; keep one in_progress step.",
221
+ "Batch transitions; work the first open step; record evidence/blockers; skip unchanged narration.",
222
+ "intake keeps every item; link goal requirementIds.",
223
+ "advance completes current, then starts next pending.",
224
+ "Attach completed tool_task IDs as evidence; goal completion rejects open linked steps.",
225
+ "Before final, resolve or defer open work. goal owns outcomes; delegate owns workers.",
186
226
  ],
187
227
  parameters: taskStepsSchema,
228
+ executionMode: "sequential",
188
229
  renderShell: "self",
189
230
  renderCall() {
190
231
  return emptyOrchestrationCall();
@@ -214,18 +255,19 @@ export function createTaskStepsToolDefinition(deps) {
214
255
  try {
215
256
  switch (input.action) {
216
257
  case "set":
217
- if (!input.steps)
218
- return errorResult(input.action, "set requires steps[].", current);
219
- state = setTaskSteps(state, input.steps, timestamp);
220
- demotedStepIds = computeDemotedStepIds(before, state, explicitStatusStepIds(input.steps, state.steps));
221
- break;
222
- case "intake":
223
- if (!input.steps)
224
- return errorResult(input.action, "intake requires a complete steps[] list.", current);
225
- state = setTaskSteps(state, input.steps, timestamp);
226
- demotedStepIds = computeDemotedStepIds(before, state, explicitStatusStepIds(input.steps, state.steps));
258
+ case "intake": {
259
+ const steps = input.steps;
260
+ if (!steps) {
261
+ const error = input.action === "set" ? "set requires steps[]." : "intake requires a complete steps[] list.";
262
+ return errorResult(input.action, error, current);
263
+ }
264
+ validatePipelineInputs(deps, steps);
265
+ state = setTaskSteps(state, steps, timestamp);
266
+ demotedStepIds = computeDemotedStepIds(before, state, explicitStatusStepIds(steps, state.steps));
227
267
  break;
268
+ }
228
269
  case "add":
270
+ validatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);
229
271
  state = addTaskStep(state, toTaskStepInput(input), timestamp);
230
272
  if (state === before) {
231
273
  // The reducer returned the unchanged state: an open step already carries this
@@ -237,16 +279,15 @@ export function createTaskStepsToolDefinition(deps) {
237
279
  if (!input.id?.trim())
238
280
  return errorResult(input.action, "update requires id or a unique selector.", current);
239
281
  const selected = resolveTaskStepSelector(before.steps, input.id);
240
- state = updateTaskStep(state, input.id, {
241
- content: input.content,
242
- activeForm: input.activeForm,
243
- status: input.status,
244
- priority: input.priority,
245
- owner: input.owner,
246
- requirementIds: input.requirementIds,
247
- note: input.note,
248
- evidence: input.evidence,
249
- }, timestamp);
282
+ if (input.pipelineRunId !== undefined ||
283
+ input.pipelineStageId !== undefined ||
284
+ input.clearPipelineLink === true) {
285
+ const clearingPipelineLink = input.clearPipelineLink === true;
286
+ validatePipelineLink(deps, clearingPipelineLink ? input.pipelineRunId : (input.pipelineRunId ?? selected.pipelineRunId), clearingPipelineLink
287
+ ? input.pipelineStageId
288
+ : (input.pipelineStageId ?? selected.pipelineStageId), clearingPipelineLink);
289
+ }
290
+ state = updateTaskStep(state, input.id, toTaskStepUpdate(input), timestamp);
250
291
  // Exclude the explicitly targeted step: its own status change was requested by
251
292
  // the caller, so it is never a "silent" demotion even if it moved to pending.
252
293
  demotedStepIds = computeDemotedStepIds(before, state, new Set([selected.id]));
@@ -1 +1 @@
1
- {"version":3,"file":"task-steps.js","sourceRoot":"","sources":["../../../src/core/tools/task-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,uBAAuB,EACvB,YAAY,EAIZ,cAAc,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,sBAAsB,EACtB,2BAA2B,EAE3B,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAElC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC;IAC/B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IAC3B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IACzB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAEvG,SAAS,sBAAsB,CAAC,yBAAiC;IAChE,OAAO;QACN,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QACnC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,cA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E;wBACR;4BACC,IAAI,EAAE,MAAe;4BACrB,IAAI,EAAE,GAAG,YAAY,GAAG,eAAe,CAAC,KAAK,EAAE;gCAC9C,eAAe,EAAE,KAAK,CAAC,aAAa;gCACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ;6BACxB,CAAC,GAAG,OAAO,EAAE;yBACd;qBACD;oBACD,OAAO,EAAE;wBACR,MAAM,EAAE,KAAK,CAAC,MAAM;wBACpB,OAAO,EAAE,IAAI;wBACb,KAAK;wBACL,GAAG,WAAW;wBACd,aAAa,EAAE,KAAK,CAAC,aAAa;wBAClC,iBAAiB,EAAE,eAAe;wBAClC,cAAc,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;qBACvC;iBAChC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;YACnG,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { advanceTaskSteps } from \"../pipelines/increment.ts\";\nimport {\n\taddTaskStep,\n\tclearTaskSteps,\n\tcompactTaskSteps,\n\tcreateTaskStepsState,\n\tfindOpenDuplicateStep,\n\tformatTaskSteps,\n\thasUnverifiedCompletedStep,\n\tMAX_TASK_STEPS,\n\tresolveTaskStepSelector,\n\tsetTaskSteps,\n\ttype TaskStep,\n\ttype TaskStepInput,\n\ttype TaskStepsState,\n\tupdateTaskStep,\n} from \"../tasks/task-state.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n\ttaskStepPanelRow,\n} from \"./orchestration-panel.ts\";\n\nconst statusSchema = Type.Union([\n\tType.Literal(\"pending\"),\n\tType.Literal(\"in_progress\"),\n\tType.Literal(\"completed\"),\n\tType.Literal(\"blocked\"),\n\tType.Literal(\"cancelled\"),\n]);\n\nconst prioritySchema = Type.Union([Type.Literal(\"low\"), Type.Literal(\"normal\"), Type.Literal(\"high\")]);\n\nfunction optionalTaskStepFields(requirementIdsDescription: string) {\n\treturn {\n\t\tstatus: Type.Optional(statusSchema),\n\t\tpriority: Type.Optional(prioritySchema),\n\t\towner: Type.Optional(Type.String({ maxLength: 200 })),\n\t\trequirementIds: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: 200 }), {\n\t\t\t\tmaxItems: 32,\n\t\t\t\tdescription: requirementIdsDescription,\n\t\t\t}),\n\t\t),\n\t\tnote: Type.Optional(Type.String({ maxLength: 4_000 })),\n\t\tevidence: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 2_000 }), { maxItems: 32 })),\n\t};\n}\n\nconst stepInputSchema = Type.Object(\n\t{\n\t\tcontent: Type.String({ minLength: 1, maxLength: 2_000, description: \"Imperative task step text.\" }),\n\t\tactiveForm: Type.Optional(\n\t\t\tType.String({ minLength: 1, maxLength: 2_000, description: \"Short present-progress label for active UI.\" }),\n\t\t),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances.\"),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst taskStepsSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"set\"),\n\t\t\t\tType.Literal(\"add\"),\n\t\t\t\tType.Literal(\"update\"),\n\t\t\t\tType.Literal(\"list\"),\n\t\t\t\tType.Literal(\"clear\"),\n\t\t\t\tType.Literal(\"compact\"),\n\t\t\t\tType.Literal(\"intake\"),\n\t\t\t\tType.Literal(\"advance\"),\n\t\t\t],\n\t\t\t{ description: \"Checklist action. Use list to read without mutation.\" },\n\t\t),\n\t\tsteps: Type.Optional(\n\t\t\tType.Array(stepInputSchema, {\n\t\t\t\tmaxItems: MAX_TASK_STEPS,\n\t\t\t\tdescription: \"Complete replacement list for set/intake. Intake preserves every supplied item in order.\",\n\t\t\t}),\n\t\t),\n\t\tid: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"For update: current/active, exact step id, unique id prefix, or unique content selector.\",\n\t\t\t}),\n\t\t),\n\t\tcontent: Type.Optional(Type.String({ minLength: 1, maxLength: 2_000 })),\n\t\tactiveForm: Type.Optional(Type.String({ maxLength: 2_000 })),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances; [] clears existing links.\"),\n\t\tclearCompleted: Type.Optional(\n\t\t\tType.Boolean({ description: \"For list: compact completed and cancelled steps before rendering.\" }),\n\t\t),\n\t\tshowCompleted: Type.Optional(Type.Boolean({ description: \"Include completed and cancelled steps in output.\" })),\n\t\tmaxItems: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TASK_STEPS })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type TaskStepsToolInput = Static<typeof taskStepsSchema>;\nexport type TaskStepsAction = TaskStepsToolInput[\"action\"];\n\nexport interface TaskStepsToolDetails {\n\taction: TaskStepsAction;\n\tapplied: boolean;\n\terror?: string;\n\tstate?: TaskStepsState;\n\tstepCount?: number;\n\topenStepCount?: number;\n\tverificationNudgeNeeded?: boolean;\n\tshowCompleted?: boolean;\n\t/** Set when `add` was a no-op because an open step already carries this content. */\n\tduplicateOfStepId?: string;\n\t/** Step ids silently demoted to pending because another step became active in this call. */\n\tdemotedStepIds?: readonly string[];\n}\n\nexport interface TaskStepsToolDependencies {\n\tgetTaskStepsState: () => TaskStepsState | undefined;\n\tsaveTaskStepsState: (state: TaskStepsState) => void;\n\tnow?: () => string;\n}\n\nfunction toTaskStepInput(input: TaskStepsToolInput): TaskStepInput {\n\treturn {\n\t\tcontent: input.content ?? \"\",\n\t\tactiveForm: input.activeForm,\n\t\tstatus: input.status,\n\t\tpriority: input.priority,\n\t\towner: input.owner,\n\t\trequirementIds: input.requirementIds,\n\t\tnote: input.note,\n\t\tevidence: input.evidence,\n\t};\n}\n\nfunction counts(\n\tstate: TaskStepsState,\n): Pick<TaskStepsToolDetails, \"stepCount\" | \"openStepCount\" | \"verificationNudgeNeeded\"> {\n\tconst openStepCount = state.steps.filter(\n\t\t(step) => step.status !== \"completed\" && step.status !== \"cancelled\",\n\t).length;\n\treturn {\n\t\tstepCount: state.steps.length,\n\t\topenStepCount,\n\t\tverificationNudgeNeeded: hasUnverifiedCompletedStep(state),\n\t};\n}\n\n/** Ids (from `resultSteps`, index-aligned with `inputs`) whose status was set explicitly by the caller. */\nfunction explicitStatusStepIds(inputs: readonly TaskStepInput[], resultSteps: readonly TaskStep[]): Set<string> {\n\tconst ids = new Set<string>();\n\tinputs.forEach((stepInput, index) => {\n\t\tif (stepInput.status !== undefined) {\n\t\t\tconst id = resultSteps[index]?.id;\n\t\t\tif (id) ids.add(id);\n\t\t}\n\t});\n\treturn ids;\n}\n\n/**\n * Steps that were in_progress before this call and are pending after, excluding any step whose\n * new status was set explicitly by the caller (an explicit change is not a \"silent\" demotion).\n */\nfunction computeDemotedStepIds(\n\tbefore: TaskStepsState,\n\tafter: TaskStepsState,\n\texcludeIds: ReadonlySet<string>,\n): string[] {\n\tconst beforeActiveIds = new Set(before.steps.filter((step) => step.status === \"in_progress\").map((step) => step.id));\n\treturn after.steps\n\t\t.filter((step) => beforeActiveIds.has(step.id) && step.status === \"pending\" && !excludeIds.has(step.id))\n\t\t.map((step) => step.id);\n}\n\nfunction errorResult(action: TaskStepsAction, error: string, state?: TaskStepsState) {\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text: `task_steps ${action} failed: ${error}` }],\n\t\tdetails: { action, applied: false, error, state, ...(state ? counts(state) : {}) } satisfies TaskStepsToolDetails,\n\t};\n}\n\nfunction taskStepsPanelModel(details: TaskStepsToolDetails, expanded: boolean): OrchestrationPanelModel {\n\tconst state = details.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"task steps\",\n\t\t\taction: details.action,\n\t\t\tstatus: details.error ? \"error\" : \"idle\",\n\t\t\temptyText: details.error ?? \"No checklist state.\",\n\t\t};\n\t}\n\tconst active = state.steps.filter((step) => step.status === \"in_progress\");\n\tconst blocked = state.steps.filter((step) => step.status === \"blocked\");\n\tconst pending = state.steps.filter((step) => step.status === \"pending\");\n\tconst completed = state.steps.filter((step) => step.status === \"completed\");\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\");\n\tconst open = [...active, ...blocked, ...pending];\n\tconst terminal = details.showCompleted ? [...completed, ...cancelled] : [];\n\tconst candidates = [...open, ...terminal];\n\tconst limit = expanded ? 24 : 8;\n\tconst rows = candidates.slice(0, limit).map(taskStepPanelRow);\n\tconst archivedDone = state.archive.completed + state.archive.cancelled;\n\tconst done = completed.length + state.archive.completed;\n\tconst summary = [\n\t\tactive.length ? `${active.length} working` : undefined,\n\t\t`${open.length} open`,\n\t\t`${done} done`,\n\t\tblocked.length ? `${blocked.length} blocked` : undefined,\n\t\tarchivedDone ? `${archivedDone} archived` : undefined,\n\t].filter((value): value is string => value !== undefined);\n\tconst notices = [];\n\tif (!details.showCompleted && completed.length + cancelled.length > 0) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${completed.length + cancelled.length} finished step${completed.length + cancelled.length === 1 ? \"\" : \"s\"} hidden`,\n\t\t});\n\t}\n\tif (details.duplicateOfStepId) {\n\t\tnotices.push({ status: \"info\" as const, text: \"Duplicate open step ignored.\" });\n\t}\n\tif (details.demotedStepIds?.length) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${details.demotedStepIds.length} previous working step${details.demotedStepIds.length === 1 ? \"\" : \"s\"} returned to pending.`,\n\t\t});\n\t}\n\tif (details.verificationNudgeNeeded) {\n\t\tnotices.push({ status: \"warning\" as const, text: \"Completed work still needs attached evidence.\" });\n\t}\n\tconst status = details.error\n\t\t? \"error\"\n\t\t: blocked.length > 0\n\t\t\t? \"warning\"\n\t\t\t: active.length > 0\n\t\t\t\t? \"running\"\n\t\t\t\t: open.length === 0 && state.steps.length > 0\n\t\t\t\t\t? \"success\"\n\t\t\t\t\t: \"idle\";\n\treturn {\n\t\tlabel: \"task steps\",\n\t\taction: details.action,\n\t\tstatus,\n\t\tsummary,\n\t\trows,\n\t\tnotices,\n\t\temptyText: state.steps.length === 0 ? \"No tracked steps.\" : \"All open steps are done.\",\n\t\thiddenRowCount: Math.max(0, candidates.length - rows.length),\n\t};\n}\n\nexport function createTaskStepsToolDefinition(deps: TaskStepsToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"task_steps\",\n\t\tlabel: \"Task Steps\",\n\t\tdescription:\n\t\t\t\"Track the session's ordered multi-step checklist with status, notes, and evidence. Use goal for durable outcomes and delegate for workers.\",\n\t\tpromptSnippet: \"Track multi-step session work.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use for complex/explicitly tracked work, not one-step work. Keep one in_progress step.\",\n\t\t\t\"Batch transitions. Address first open step; record evidence/blocker. Never call only to narrate unchanged state.\",\n\t\t\t\"intake preserves every supplied item; link steps to active goal requirementIds.\",\n\t\t\t\"advance completes the current step then starts the next pending step.\",\n\t\t\t\"Attach completed tool_task taskIds as evidence. Goal complete refuses while linked steps stay open.\",\n\t\t\t\"Before final: clear stale in_progress, discuss/defer remainder. Goal owns outcomes; delegate owns workers.\",\n\t\t],\n\t\tparameters: taskStepsSchema,\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tif (isPartial) return emptyOrchestrationCall();\n\t\t\tconst details = result.details as TaskStepsToolDetails | undefined;\n\t\t\tif (!details) {\n\t\t\t\treturn new OrchestrationPanelComponent(theme, {\n\t\t\t\t\tlabel: \"task steps\",\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\temptyText: \"No task-step details were returned.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!expanded && details.applied) return emptyOrchestrationCall();\n\t\t\treturn new OrchestrationPanelComponent(theme, taskStepsPanelModel(details, expanded), expanded);\n\t\t},\n\t\tasync execute(_toolCallId, input: TaskStepsToolInput) {\n\t\t\tconst timestamp = now();\n\t\t\tconst current = deps.getTaskStepsState();\n\t\t\tconst before = current ?? createTaskStepsState(timestamp);\n\t\t\tlet state = before;\n\t\t\tlet duplicateStepId: string | undefined;\n\t\t\tlet demotedStepIds: readonly string[] = [];\n\t\t\ttry {\n\t\t\t\tswitch (input.action) {\n\t\t\t\t\tcase \"set\":\n\t\t\t\t\t\tif (!input.steps) return errorResult(input.action, \"set requires steps[].\", current);\n\t\t\t\t\t\tstate = setTaskSteps(state, input.steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(\n\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\texplicitStatusStepIds(input.steps, state.steps),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"intake\":\n\t\t\t\t\t\tif (!input.steps)\n\t\t\t\t\t\t\treturn errorResult(input.action, \"intake requires a complete steps[] list.\", current);\n\t\t\t\t\t\tstate = setTaskSteps(state, input.steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(\n\t\t\t\t\t\t\tbefore,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\texplicitStatusStepIds(input.steps, state.steps),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"add\":\n\t\t\t\t\t\tstate = addTaskStep(state, toTaskStepInput(input), timestamp);\n\t\t\t\t\t\tif (state === before) {\n\t\t\t\t\t\t\t// The reducer returned the unchanged state: an open step already carries this\n\t\t\t\t\t\t\t// content, so nothing was created. Name the existing step in the response.\n\t\t\t\t\t\t\tduplicateStepId = findOpenDuplicateStep(before.steps, input.content ?? \"\")?.id;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"update\": {\n\t\t\t\t\t\tif (!input.id?.trim())\n\t\t\t\t\t\t\treturn errorResult(input.action, \"update requires id or a unique selector.\", current);\n\t\t\t\t\t\tconst selected = resolveTaskStepSelector(before.steps, input.id);\n\t\t\t\t\t\tstate = updateTaskStep(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tinput.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: input.content,\n\t\t\t\t\t\t\t\tactiveForm: input.activeForm,\n\t\t\t\t\t\t\t\tstatus: input.status,\n\t\t\t\t\t\t\t\tpriority: input.priority,\n\t\t\t\t\t\t\t\towner: input.owner,\n\t\t\t\t\t\t\t\trequirementIds: input.requirementIds,\n\t\t\t\t\t\t\t\tnote: input.note,\n\t\t\t\t\t\t\t\tevidence: input.evidence,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// Exclude the explicitly targeted step: its own status change was requested by\n\t\t\t\t\t\t// the caller, so it is never a \"silent\" demotion even if it moved to pending.\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, new Set([selected.id]));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"clear\":\n\t\t\t\t\t\tstate = clearTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"compact\":\n\t\t\t\t\t\tstate = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"advance\": {\n\t\t\t\t\t\tconst advanced = advanceTaskSteps(before, timestamp);\n\t\t\t\t\t\tstate = advanced.state;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\tif (input.clearCompleted) state = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst isNoopDuplicateAdd = input.action === \"add\" && state === before;\n\t\t\t\tconst mutated = (input.action !== \"list\" || input.clearCompleted === true) && !isNoopDuplicateAdd;\n\t\t\t\tif (mutated) deps.saveTaskStepsState(state);\n\n\t\t\t\tconst stateCounts = counts(state);\n\t\t\t\tconst noticeLines: string[] = [];\n\t\t\t\tif (duplicateStepId) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t`Duplicate open step ignored; existing ${duplicateStepId} already tracks this content.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (demotedStepIds.length > 0) {\n\t\t\t\t\tnoticeLines.push(`Demoted to pending because another step became active: ${demotedStepIds.join(\", \")}.`);\n\t\t\t\t}\n\t\t\t\tif (stateCounts.verificationNudgeNeeded) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t\"Reminder: a completed step has no evidence attached; attach evidence via update before treating it as verified.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst notices = noticeLines.length > 0 ? `\\n${noticeLines.join(\"\\n\")}` : \"\";\n\n\t\t\t\tconst headerAction =\n\t\t\t\t\tinput.action === \"list\"\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: `task_steps ${input.action} ${duplicateStepId ? \"ignored (duplicate)\" : \"recorded\"}.\\n`;\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `${headerAction}${formatTaskSteps(state, {\n\t\t\t\t\t\t\t\tincludeTerminal: input.showCompleted,\n\t\t\t\t\t\t\t\tmaxItems: input.maxItems,\n\t\t\t\t\t\t\t})}${notices}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\taction: input.action,\n\t\t\t\t\t\tapplied: true,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t...stateCounts,\n\t\t\t\t\t\tshowCompleted: input.showCompleted,\n\t\t\t\t\t\tduplicateOfStepId: duplicateStepId,\n\t\t\t\t\t\tdemotedStepIds: demotedStepIds.length > 0 ? demotedStepIds : undefined,\n\t\t\t\t\t} satisfies TaskStepsToolDetails,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn errorResult(input.action, error instanceof Error ? error.message : String(error), current);\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"task-steps.js","sourceRoot":"","sources":["../../../src/core/tools/task-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,oCAAoC,EACpC,cAAc,EACd,6BAA6B,EAC7B,uBAAuB,EACvB,YAAY,EAGZ,cAAc,EAGd,cAAc,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,sBAAsB,EACtB,2BAA2B,EAE3B,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAElC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC;IAC/B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;IAC3B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IACzB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC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O,EAAE,IAAI;wBACb,KAAK;wBACL,GAAG,WAAW;wBACd,aAAa,EAAE,KAAK,CAAC,aAAa;wBAClC,iBAAiB,EAAE,eAAe;wBAClC,cAAc,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;qBACvC;iBAChC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;YACnG,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { advanceTaskSteps } from \"../pipelines/increment.ts\";\nimport { MAX_PIPELINE_STAGE_ID_LENGTH } from \"../pipelines/types.ts\";\nimport {\n\taddTaskStep,\n\tclearTaskSteps,\n\tcompactTaskSteps,\n\tcreateTaskStepsState,\n\tfindOpenDuplicateStep,\n\tformatTaskSteps,\n\thasUnverifiedCompletedStep,\n\tMAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH,\n\tMAX_TASK_STEPS,\n\tnormalizeTaskStepPipelineLink,\n\tresolveTaskStepSelector,\n\tsetTaskSteps,\n\ttype TaskStep,\n\ttype TaskStepInput,\n\tTaskStepsError,\n\ttype TaskStepsState,\n\ttype TaskStepUpdate,\n\tupdateTaskStep,\n} from \"../tasks/task-state.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n\ttaskStepPanelRow,\n} from \"./orchestration-panel.ts\";\n\nconst statusSchema = Type.Union([\n\tType.Literal(\"pending\"),\n\tType.Literal(\"in_progress\"),\n\tType.Literal(\"completed\"),\n\tType.Literal(\"blocked\"),\n\tType.Literal(\"cancelled\"),\n]);\n\nconst prioritySchema = Type.Union([Type.Literal(\"low\"), Type.Literal(\"normal\"), Type.Literal(\"high\")]);\n\nfunction optionalTaskStepFields(requirementIdsDescription: string) {\n\treturn {\n\t\tstatus: Type.Optional(statusSchema),\n\t\tpriority: Type.Optional(prioritySchema),\n\t\towner: Type.Optional(Type.String({ maxLength: 200 })),\n\t\trequirementIds: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: 200 }), {\n\t\t\t\tmaxItems: 32,\n\t\t\t\tdescription: requirementIdsDescription,\n\t\t\t}),\n\t\t),\n\t\tpipelineRunId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH,\n\t\t\t\tdescription: \"Active pipeline run id this step advances. Supply together with pipelineStageId.\",\n\t\t\t}),\n\t\t),\n\t\tpipelineStageId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: MAX_PIPELINE_STAGE_ID_LENGTH,\n\t\t\t\tdescription: \"Stage id in pipelineRunId this step advances. Supply both ids together.\",\n\t\t\t}),\n\t\t),\n\t\tclearPipelineLink: Type.Optional(\n\t\t\tType.Boolean({\n\t\t\t\tdescription: \"Remove both pipeline ids. Cannot be combined with pipelineRunId/pipelineStageId.\",\n\t\t\t}),\n\t\t),\n\t\tnote: Type.Optional(Type.String({ maxLength: 4_000 })),\n\t\tevidence: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 2_000 }), { maxItems: 32 })),\n\t};\n}\n\nconst stepInputSchema = Type.Object(\n\t{\n\t\tcontent: Type.String({ minLength: 1, maxLength: 2_000, description: \"Imperative task step text.\" }),\n\t\tactiveForm: Type.Optional(\n\t\t\tType.String({ minLength: 1, maxLength: 2_000, description: \"Short present-progress label for active UI.\" }),\n\t\t),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances.\"),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst taskStepsSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"set\"),\n\t\t\t\tType.Literal(\"add\"),\n\t\t\t\tType.Literal(\"update\"),\n\t\t\t\tType.Literal(\"list\"),\n\t\t\t\tType.Literal(\"clear\"),\n\t\t\t\tType.Literal(\"compact\"),\n\t\t\t\tType.Literal(\"intake\"),\n\t\t\t\tType.Literal(\"advance\"),\n\t\t\t],\n\t\t\t{ description: \"Checklist action. Use list to read without mutation.\" },\n\t\t),\n\t\tsteps: Type.Optional(\n\t\t\tType.Array(stepInputSchema, {\n\t\t\t\tmaxItems: MAX_TASK_STEPS,\n\t\t\t\tdescription: \"Complete replacement list for set/intake. Intake preserves every supplied item in order.\",\n\t\t\t}),\n\t\t),\n\t\tid: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"For update: current/active, exact step id, unique id prefix, or unique content selector.\",\n\t\t\t}),\n\t\t),\n\t\tcontent: Type.Optional(Type.String({ minLength: 1, maxLength: 2_000 })),\n\t\tactiveForm: Type.Optional(Type.String({ maxLength: 2_000 })),\n\t\t...optionalTaskStepFields(\"Goal requirement ids this foreground step advances; [] clears existing links.\"),\n\t\tclearCompleted: Type.Optional(\n\t\t\tType.Boolean({ description: \"For list: compact completed and cancelled steps before rendering.\" }),\n\t\t),\n\t\tshowCompleted: Type.Optional(Type.Boolean({ description: \"Include completed and cancelled steps in output.\" })),\n\t\tmaxItems: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TASK_STEPS })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type TaskStepsToolInput = Static<typeof taskStepsSchema>;\nexport type TaskStepsAction = TaskStepsToolInput[\"action\"];\n\nexport interface TaskStepsToolDetails {\n\taction: TaskStepsAction;\n\tapplied: boolean;\n\terror?: string;\n\tstate?: TaskStepsState;\n\tstepCount?: number;\n\topenStepCount?: number;\n\tverificationNudgeNeeded?: boolean;\n\tshowCompleted?: boolean;\n\t/** Set when `add` was a no-op because an open step already carries this content. */\n\tduplicateOfStepId?: string;\n\t/** Step ids silently demoted to pending because another step became active in this call. */\n\tdemotedStepIds?: readonly string[];\n}\n\nexport interface TaskStepsToolDependencies {\n\tgetTaskStepsState: () => TaskStepsState | undefined;\n\tsaveTaskStepsState: (state: TaskStepsState) => void;\n\tgetActivePipelineScope?: () => { runId: string; stageIds: readonly string[] } | undefined;\n\tnow?: () => string;\n}\n\nfunction toTaskStepUpdate(input: TaskStepsToolInput): TaskStepUpdate {\n\treturn {\n\t\tcontent: input.content,\n\t\tactiveForm: input.activeForm,\n\t\tstatus: input.status,\n\t\tpriority: input.priority,\n\t\towner: input.owner,\n\t\trequirementIds: input.requirementIds,\n\t\tpipelineRunId: input.pipelineRunId,\n\t\tpipelineStageId: input.pipelineStageId,\n\t\tclearPipelineLink: input.clearPipelineLink,\n\t\tnote: input.note,\n\t\tevidence: input.evidence,\n\t};\n}\n\nfunction toTaskStepInput(input: TaskStepsToolInput): TaskStepInput {\n\treturn { ...toTaskStepUpdate(input), content: input.content ?? \"\" };\n}\n\nfunction validatePipelineLink(\n\tdeps: TaskStepsToolDependencies,\n\tpipelineRunId: string | undefined,\n\tpipelineStageId: string | undefined,\n\tclearPipelineLink = false,\n): void {\n\tconst { pipelineRunId: runId, pipelineStageId: stageId } = normalizeTaskStepPipelineLink(\n\t\tpipelineRunId,\n\t\tpipelineStageId,\n\t\tclearPipelineLink,\n\t);\n\tif (!runId || !stageId) return;\n\tconst active = deps.getActivePipelineScope?.();\n\tif (!active) throw new TaskStepsError(\"Task step pipeline linkage requires an active pipeline run.\");\n\tif (runId !== active.runId) {\n\t\tthrow new TaskStepsError(`Task step pipelineRunId must match active run '${active.runId}'.`);\n\t}\n\tif (!active.stageIds.includes(stageId)) {\n\t\tthrow new TaskStepsError(`Task step pipelineStageId '${stageId}' is not in active run '${active.runId}'.`);\n\t}\n}\n\nfunction validatePipelineInputs(deps: TaskStepsToolDependencies, inputs: readonly TaskStepInput[]): void {\n\tfor (const input of inputs) {\n\t\tvalidatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);\n\t}\n}\n\nfunction counts(\n\tstate: TaskStepsState,\n): Pick<TaskStepsToolDetails, \"stepCount\" | \"openStepCount\" | \"verificationNudgeNeeded\"> {\n\tconst openStepCount = state.steps.filter(\n\t\t(step) => step.status !== \"completed\" && step.status !== \"cancelled\",\n\t).length;\n\treturn {\n\t\tstepCount: state.steps.length,\n\t\topenStepCount,\n\t\tverificationNudgeNeeded: hasUnverifiedCompletedStep(state),\n\t};\n}\n\n/** Ids (from `resultSteps`, index-aligned with `inputs`) whose status was set explicitly by the caller. */\nfunction explicitStatusStepIds(inputs: readonly TaskStepInput[], resultSteps: readonly TaskStep[]): Set<string> {\n\tconst ids = new Set<string>();\n\tinputs.forEach((stepInput, index) => {\n\t\tif (stepInput.status !== undefined) {\n\t\t\tconst id = resultSteps[index]?.id;\n\t\t\tif (id) ids.add(id);\n\t\t}\n\t});\n\treturn ids;\n}\n\n/**\n * Steps that were in_progress before this call and are pending after, excluding any step whose\n * new status was set explicitly by the caller (an explicit change is not a \"silent\" demotion).\n */\nfunction computeDemotedStepIds(\n\tbefore: TaskStepsState,\n\tafter: TaskStepsState,\n\texcludeIds: ReadonlySet<string>,\n): string[] {\n\tconst beforeActiveIds = new Set(before.steps.filter((step) => step.status === \"in_progress\").map((step) => step.id));\n\treturn after.steps\n\t\t.filter((step) => beforeActiveIds.has(step.id) && step.status === \"pending\" && !excludeIds.has(step.id))\n\t\t.map((step) => step.id);\n}\n\nfunction errorResult(action: TaskStepsAction, error: string, state?: TaskStepsState) {\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text: `task_steps ${action} failed: ${error}` }],\n\t\tdetails: { action, applied: false, error, state, ...(state ? counts(state) : {}) } satisfies TaskStepsToolDetails,\n\t\tisError: true as const,\n\t};\n}\n\nfunction taskStepsPanelModel(details: TaskStepsToolDetails, expanded: boolean): OrchestrationPanelModel {\n\tconst state = details.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"task steps\",\n\t\t\taction: details.action,\n\t\t\tstatus: details.error ? \"error\" : \"idle\",\n\t\t\temptyText: details.error ?? \"No checklist state.\",\n\t\t};\n\t}\n\tconst active = state.steps.filter((step) => step.status === \"in_progress\");\n\tconst blocked = state.steps.filter((step) => step.status === \"blocked\");\n\tconst pending = state.steps.filter((step) => step.status === \"pending\");\n\tconst completed = state.steps.filter((step) => step.status === \"completed\");\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\");\n\tconst open = [...active, ...blocked, ...pending];\n\tconst terminal = details.showCompleted ? [...completed, ...cancelled] : [];\n\tconst candidates = [...open, ...terminal];\n\tconst limit = expanded ? 24 : 8;\n\tconst rows = candidates.slice(0, limit).map(taskStepPanelRow);\n\tconst archivedDone = state.archive.completed + state.archive.cancelled;\n\tconst done = completed.length + state.archive.completed;\n\tconst summary = [\n\t\tactive.length ? `${active.length} working` : undefined,\n\t\t`${open.length} open`,\n\t\t`${done} done`,\n\t\tblocked.length ? `${blocked.length} blocked` : undefined,\n\t\tarchivedDone ? `${archivedDone} archived` : undefined,\n\t].filter((value): value is string => value !== undefined);\n\tconst notices = [];\n\tif (!details.showCompleted && completed.length + cancelled.length > 0) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${completed.length + cancelled.length} finished step${completed.length + cancelled.length === 1 ? \"\" : \"s\"} hidden`,\n\t\t});\n\t}\n\tif (details.duplicateOfStepId) {\n\t\tnotices.push({ status: \"info\" as const, text: \"Duplicate open step ignored.\" });\n\t}\n\tif (details.demotedStepIds?.length) {\n\t\tnotices.push({\n\t\t\tstatus: \"info\" as const,\n\t\t\ttext: `${details.demotedStepIds.length} previous working step${details.demotedStepIds.length === 1 ? \"\" : \"s\"} returned to pending.`,\n\t\t});\n\t}\n\tif (details.verificationNudgeNeeded) {\n\t\tnotices.push({ status: \"warning\" as const, text: \"Completed work still needs attached evidence.\" });\n\t}\n\tconst status = details.error\n\t\t? \"error\"\n\t\t: blocked.length > 0\n\t\t\t? \"warning\"\n\t\t\t: active.length > 0\n\t\t\t\t? \"running\"\n\t\t\t\t: open.length === 0 && state.steps.length > 0\n\t\t\t\t\t? \"success\"\n\t\t\t\t\t: \"idle\";\n\treturn {\n\t\tlabel: \"task steps\",\n\t\taction: details.action,\n\t\tstatus,\n\t\tsummary,\n\t\trows,\n\t\tnotices,\n\t\temptyText: state.steps.length === 0 ? \"No tracked steps.\" : \"All open steps are done.\",\n\t\thiddenRowCount: Math.max(0, candidates.length - rows.length),\n\t};\n}\n\nexport function createTaskStepsToolDefinition(deps: TaskStepsToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"task_steps\",\n\t\tlabel: \"Task Steps\",\n\t\tdescription:\n\t\t\t\"Track the session's ordered multi-step checklist with status, notes, and evidence. Use goal for durable outcomes and delegate for workers.\",\n\t\tpromptSnippet: \"Track multi-step session work.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use for multi-step work; keep one in_progress step.\",\n\t\t\t\"Batch transitions; work the first open step; record evidence/blockers; skip unchanged narration.\",\n\t\t\t\"intake keeps every item; link goal requirementIds.\",\n\t\t\t\"advance completes current, then starts next pending.\",\n\t\t\t\"Attach completed tool_task IDs as evidence; goal completion rejects open linked steps.\",\n\t\t\t\"Before final, resolve or defer open work. goal owns outcomes; delegate owns workers.\",\n\t\t],\n\t\tparameters: taskStepsSchema,\n\t\texecutionMode: \"sequential\",\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tif (isPartial) return emptyOrchestrationCall();\n\t\t\tconst details = result.details as TaskStepsToolDetails | undefined;\n\t\t\tif (!details) {\n\t\t\t\treturn new OrchestrationPanelComponent(theme, {\n\t\t\t\t\tlabel: \"task steps\",\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\temptyText: \"No task-step details were returned.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!expanded && details.applied) return emptyOrchestrationCall();\n\t\t\treturn new OrchestrationPanelComponent(theme, taskStepsPanelModel(details, expanded), expanded);\n\t\t},\n\t\tasync execute(_toolCallId, input: TaskStepsToolInput) {\n\t\t\tconst timestamp = now();\n\t\t\tconst current = deps.getTaskStepsState();\n\t\t\tconst before = current ?? createTaskStepsState(timestamp);\n\t\t\tlet state = before;\n\t\t\tlet duplicateStepId: string | undefined;\n\t\t\tlet demotedStepIds: readonly string[] = [];\n\t\t\ttry {\n\t\t\t\tswitch (input.action) {\n\t\t\t\t\tcase \"set\":\n\t\t\t\t\tcase \"intake\": {\n\t\t\t\t\t\tconst steps = input.steps;\n\t\t\t\t\t\tif (!steps) {\n\t\t\t\t\t\t\tconst error =\n\t\t\t\t\t\t\t\tinput.action === \"set\" ? \"set requires steps[].\" : \"intake requires a complete steps[] list.\";\n\t\t\t\t\t\t\treturn errorResult(input.action, error, current);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalidatePipelineInputs(deps, steps);\n\t\t\t\t\t\tstate = setTaskSteps(state, steps, timestamp);\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, explicitStatusStepIds(steps, state.steps));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"add\":\n\t\t\t\t\t\tvalidatePipelineLink(deps, input.pipelineRunId, input.pipelineStageId, input.clearPipelineLink);\n\t\t\t\t\t\tstate = addTaskStep(state, toTaskStepInput(input), timestamp);\n\t\t\t\t\t\tif (state === before) {\n\t\t\t\t\t\t\t// The reducer returned the unchanged state: an open step already carries this\n\t\t\t\t\t\t\t// content, so nothing was created. Name the existing step in the response.\n\t\t\t\t\t\t\tduplicateStepId = findOpenDuplicateStep(before.steps, input.content ?? \"\")?.id;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"update\": {\n\t\t\t\t\t\tif (!input.id?.trim())\n\t\t\t\t\t\t\treturn errorResult(input.action, \"update requires id or a unique selector.\", current);\n\t\t\t\t\t\tconst selected = resolveTaskStepSelector(before.steps, input.id);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tinput.pipelineRunId !== undefined ||\n\t\t\t\t\t\t\tinput.pipelineStageId !== undefined ||\n\t\t\t\t\t\t\tinput.clearPipelineLink === true\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst clearingPipelineLink = input.clearPipelineLink === true;\n\t\t\t\t\t\t\tvalidatePipelineLink(\n\t\t\t\t\t\t\t\tdeps,\n\t\t\t\t\t\t\t\tclearingPipelineLink ? input.pipelineRunId : (input.pipelineRunId ?? selected.pipelineRunId),\n\t\t\t\t\t\t\t\tclearingPipelineLink\n\t\t\t\t\t\t\t\t\t? input.pipelineStageId\n\t\t\t\t\t\t\t\t\t: (input.pipelineStageId ?? selected.pipelineStageId),\n\t\t\t\t\t\t\t\tclearingPipelineLink,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate = updateTaskStep(state, input.id, toTaskStepUpdate(input), timestamp);\n\t\t\t\t\t\t// Exclude the explicitly targeted step: its own status change was requested by\n\t\t\t\t\t\t// the caller, so it is never a \"silent\" demotion even if it moved to pending.\n\t\t\t\t\t\tdemotedStepIds = computeDemotedStepIds(before, state, new Set([selected.id]));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"clear\":\n\t\t\t\t\t\tstate = clearTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"compact\":\n\t\t\t\t\t\tstate = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"advance\": {\n\t\t\t\t\t\tconst advanced = advanceTaskSteps(before, timestamp);\n\t\t\t\t\t\tstate = advanced.state;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\tif (input.clearCompleted) state = compactTaskSteps(state, timestamp);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst isNoopDuplicateAdd = input.action === \"add\" && state === before;\n\t\t\t\tconst mutated = (input.action !== \"list\" || input.clearCompleted === true) && !isNoopDuplicateAdd;\n\t\t\t\tif (mutated) deps.saveTaskStepsState(state);\n\n\t\t\t\tconst stateCounts = counts(state);\n\t\t\t\tconst noticeLines: string[] = [];\n\t\t\t\tif (duplicateStepId) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t`Duplicate open step ignored; existing ${duplicateStepId} already tracks this content.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (demotedStepIds.length > 0) {\n\t\t\t\t\tnoticeLines.push(`Demoted to pending because another step became active: ${demotedStepIds.join(\", \")}.`);\n\t\t\t\t}\n\t\t\t\tif (stateCounts.verificationNudgeNeeded) {\n\t\t\t\t\tnoticeLines.push(\n\t\t\t\t\t\t\"Reminder: a completed step has no evidence attached; attach evidence via update before treating it as verified.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst notices = noticeLines.length > 0 ? `\\n${noticeLines.join(\"\\n\")}` : \"\";\n\n\t\t\t\tconst headerAction =\n\t\t\t\t\tinput.action === \"list\"\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: `task_steps ${input.action} ${duplicateStepId ? \"ignored (duplicate)\" : \"recorded\"}.\\n`;\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `${headerAction}${formatTaskSteps(state, {\n\t\t\t\t\t\t\t\tincludeTerminal: input.showCompleted,\n\t\t\t\t\t\t\t\tmaxItems: input.maxItems,\n\t\t\t\t\t\t\t})}${notices}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\taction: input.action,\n\t\t\t\t\t\tapplied: true,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t...stateCounts,\n\t\t\t\t\t\tshowCompleted: input.showCompleted,\n\t\t\t\t\t\tduplicateOfStepId: duplicateStepId,\n\t\t\t\t\t\tdemotedStepIds: demotedStepIds.length > 0 ? demotedStepIds : undefined,\n\t\t\t\t\t} satisfies TaskStepsToolDetails,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn errorResult(input.action, error instanceof Error ? error.message : String(error), current);\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"windows-shell-engine.d.ts","sourceRoot":"","sources":["../../../src/core/tools/windows-shell-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMrE,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGhD,OAAO,EAKN,KAAK,iBAAiB,EACtB,MAAM,0BAA0B,CAAC;AAMlC,uEAAuE;AACvE,MAAM,WAAW,uBAAuB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACxC,WAAW,EAAE;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAChF;AAiCD,qBAAa,yBAA0B,SAAQ,KAAK;IACnD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,YAAY,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAIlD;CACD;AAsED,MAAM,WAAW,yBAAyB;I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AO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAChF;AAiCD,qBAAa,yBAA0B,SAAQ,KAAK;IACnD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,YAAY,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAIlD;CACD;AAsED,MAAM,WAAW,yBAAyB;IACzC,+FAA+F;IAC/F,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACrD,iGAAiG;IACjG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gGAAgG;IAChG,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,iBAAiB,CAAC;IACrD,sFAAsF;IACtF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,KAAK,YAAY,CAAC;IACjF,2FAA2F;IAC3F,qBAAqB,CAAC,EAAE,MAAM,MAAM,CAAC;CACrC;AA0SD,+FAA+F;AAC/F,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAKlE;AAED,+DAA+D;AAC/D,wBAAgB,kCAAkC,CACjD,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,yBAA8B,GACrC,cAAc,CAQhB"}
@@ -277,8 +277,13 @@ class PersistentWindowsShellEngineSession {
277
277
  fail: (error) => failAndReset(error),
278
278
  };
279
279
  this.activeExec = active;
280
- if (signal)
280
+ if (signal) {
281
281
  signal.addEventListener("abort", onAbort, { once: true });
282
+ if (signal.aborted) {
283
+ onAbort();
284
+ return;
285
+ }
286
+ }
282
287
  if (timeoutMs !== undefined) {
283
288
  timeoutTimer = setTimeout(() => failAndReset(new Error(`timeout:${timeout}`)), timeoutMs);
284
289
  }
@@ -1 +1 @@
1
- {"version":3,"file":"windows-shell-engine.js","sourceRoot":"","sources":["../../../src/core/tools/windows-shell-engine.ts"],"names":[],"mappings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,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC;SACtD,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACd,CAAC;IAEO,SAAS;QAChB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;CACD;AAED,MAAM,cAAc,GAAG,IAAI,GAAG,EAA+C,CAAC;AAE9E,SAAS,gCAAgC,CACxC,GAAW,EACX,OAAkC;IAElC,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,OAAO,GAAG,IAAI,mCAAmC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtE,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,gCAAgC,CAAC,GAAW;IAC3D,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,CAAC,OAAO,EAAE,CAAC;AACnB,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,kCAAkC,CACjD,UAAkB,EAClB,OAAO,GAA8B,EAAE;IAEvC,OAAO;QACN,sFAAsF;QACtF,0FAA0F;QAC1F,uFAAuF;QACvF,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE,CACnC,gCAAgC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC;KACtF,CAAC;AACH,CAAC","sourcesContent":["/**\n * Persistent Windows Python shell-engine sessions.\n *\n * One coordinator process is keyed to each agent session. Requests are serialized as JSON lines;\n * Node remains the sole owner of cwd/environment state and derives each request only after the\n * preceding terminal frame has been applied. Command bytes stream on stdout, followed by a\n * request-specific output barrier. A correlated control frame arrives on stderr. Requiring both\n * channels before settlement prevents cross-pipe tail loss and stale-frame reuse.\n *\n * Timeout, abort, protocol failure, or coordinator death resets the whole process tree. The next\n * request starts a clean coordinator from the last state Node actually acknowledged.\n */\n\nimport type { ChildProcess, SpawnOptions } from \"node:child_process\";\nimport { randomBytes } from \"node:crypto\";\nimport { dirname, join } from \"node:path\";\nimport { getBundledResourcesDir } from \"../../config.ts\";\nimport { spawnProcess } from \"../../utils/child-process.ts\";\nimport { getShellConfig, getShellEnv } from \"../../utils/shell.ts\";\nimport { ensurePythonRuntime, type PythonRuntimeOutcome } from \"../python-runtime.ts\";\nimport { isRecordObject } from \"../util/value-guards.ts\";\nimport type { BashOperations } from \"./bash.ts\";\nimport { PersistentProcessCoordinator } from \"./persistent-process-coordinator.ts\";\nimport { tokenizeShellCommand } from \"./shell-command-parser.ts\";\nimport {\n\tapplyEngineFrame,\n\tgetOrCreateWindowsShellState,\n\tmergeEffectiveEnv,\n\tresolveEffectiveCwd,\n\ttype WindowsShellState,\n} from \"./windows-shell-state.ts\";\n\nconst ENGINE_FRAME_SENTINEL = 0x1e;\nconst MAX_CONTROL_FRAME_BYTES = 64 * 1024;\nconst SOFT_DEADLINE_HEADSTART_MS = 100;\n\n/** State/result fields returned for every completed engine command. */\nexport interface WindowsShellEngineFrame {\n\texitCode: number;\n\tcwd: string;\n\tenvDelta: Record<string, string | null>;\n\tunsupported: { code: \"unsupported\"; construct: string; message: string } | null;\n}\n\ninterface WindowsShellEngineControlFrame extends WindowsShellEngineFrame {\n\trequestId: string;\n}\n\ninterface WindowsShellEngineRequest {\n\trequestId: string;\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n\tpowershellPath?: string;\n\ttimeoutMs?: number;\n}\n\ninterface ParsedControlFrame {\n\tkind: \"frame\";\n\tframe: WindowsShellEngineControlFrame;\n\tframeStart: number;\n\tframeEnd: number;\n}\n\ninterface InvalidControlFrame {\n\tkind: \"invalid\";\n}\n\ninterface ActiveEngineExec {\n\tonStdout(data: Buffer): void;\n\tonStderr(data: Buffer): void;\n\tonChildClose(code: number | null): void;\n\tfail(error: Error): void;\n}\n\nexport class WindowsShellEngineFailure extends Error {\n\treadonly capturedOutput: string;\n\n\tconstructor(message: string, capturedOutput: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WindowsShellEngineFailure\";\n\t\tthis.capturedOutput = capturedOutput;\n\t}\n}\n\nfunction resolveEngineScriptPath(): string {\n\treturn join(getBundledResourcesDir(), \"runtimes\", \"pi-shell-engine\", \"main.py\");\n}\n\nfunction invokesPowerShellScript(command: string): boolean {\n\tconst tokens = tokenizeShellCommand(command);\n\t// An unparseable command is already heading to the authoritative Python parser;\n\t// resolve conservatively so script adaptation cannot lose an explicit host choice.\n\tif (!tokens) return /\\.ps1\\b/iu.test(command);\n\n\tlet atCommandStart = true;\n\tlet skipRedirectTarget = false;\n\tfor (const token of tokens) {\n\t\tif (token.kind === \"operator\" || token.kind === \"pipe\") {\n\t\t\tatCommandStart = true;\n\t\t\tskipRedirectTarget = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (token.kind === \"redirect\") {\n\t\t\tskipRedirectTarget = !/^\\d*[<>]&[\\d-]+$/u.test(token.value);\n\t\t\tcontinue;\n\t\t}\n\t\tif (skipRedirectTarget) {\n\t\t\tskipRedirectTarget = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!atCommandStart || /^[A-Za-z_][A-Za-z0-9_]*=/u.test(token.value)) continue;\n\t\tif (token.value.toLowerCase().endsWith(\".ps1\")) return true;\n\t\tatCommandStart = false;\n\t}\n\treturn false;\n}\n\nfunction parseControlFrame(buffer: Buffer): ParsedControlFrame | InvalidControlFrame | undefined {\n\tconst frameStart = buffer.indexOf(ENGINE_FRAME_SENTINEL);\n\tif (frameStart === -1) return undefined;\n\tconst closeIndex = buffer.indexOf(ENGINE_FRAME_SENTINEL, frameStart + 1);\n\tif (closeIndex === -1) return undefined;\n\ttry {\n\t\tconst raw: unknown = JSON.parse(buffer.subarray(frameStart + 1, closeIndex).toString(\"utf8\"));\n\t\tif (\n\t\t\tisRecordObject(raw) &&\n\t\t\ttypeof raw.requestId === \"string\" &&\n\t\t\t/^[0-9a-f]{16}$/u.test(raw.requestId) &&\n\t\t\ttypeof raw.exitCode === \"number\" &&\n\t\t\tNumber.isInteger(raw.exitCode) &&\n\t\t\ttypeof raw.cwd === \"string\" &&\n\t\t\tisRecordObject(raw.envDelta) &&\n\t\t\t(raw.unsupported === null || isRecordObject(raw.unsupported)) &&\n\t\t\t(raw.unsupported === null ||\n\t\t\t\t(raw.unsupported.code === \"unsupported\" &&\n\t\t\t\t\ttypeof raw.unsupported.construct === \"string\" &&\n\t\t\t\t\ttypeof raw.unsupported.message === \"string\")) &&\n\t\t\tObject.values(raw.envDelta).every((value) => value === null || typeof value === \"string\")\n\t\t) {\n\t\t\treturn {\n\t\t\t\tkind: \"frame\",\n\t\t\t\tframe: raw as unknown as WindowsShellEngineControlFrame,\n\t\t\t\tframeStart,\n\t\t\t\tframeEnd: closeIndex + 1,\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// A complete delimited record that is not JSON is a terminal protocol fault.\n\t}\n\treturn { kind: \"invalid\" };\n}\n\nexport interface WindowsShellEngineOptions {\n\t/** Override for tests: resolves the Python runtime outcome. Default: `ensurePythonRuntime`. */\n\tresolveRuntime?: () => Promise<PythonRuntimeOutcome>;\n\t/** Override for tests: absolute path to the engine's `main.py`. Default: the bundled runtime. */\n\tengineScriptPath?: string;\n\t/** Override for tests: the per-session state store lookup. Default: the shared module store. */\n\tgetState?: (sessionKey: string) => WindowsShellState;\n\t/** Override for tests: spawns the persistent coordinator. Default: `spawnProcess`. */\n\tspawn?: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\t/** Override for tests: selected PowerShell host used to adapt `.ps1` external commands. */\n\tresolvePowerShellPath?: () => string;\n}\n\nfunction degradationError(\n\toutcome: Extract<PythonRuntimeOutcome, { status: \"offline\" | \"uv-unavailable\" | \"python-unavailable\" }>,\n): Error {\n\treturn new Error(\n\t\t`The Windows shell engine (Python) is unavailable: ${outcome.reason} The simple-command PowerShell floor still works; fix the Python runtime (uv/network) to restore for loops, portable builtins such as printf, pipelines, redirection, expansion, and chaining.`,\n\t);\n}\n\nclass PersistentWindowsShellEngineSession {\n\tprivate readonly key: string;\n\tprivate readonly resolveRuntime: () => Promise<PythonRuntimeOutcome>;\n\tprivate readonly engineScriptPath: string;\n\tprivate readonly getState: (sessionKey: string) => WindowsShellState;\n\tprivate readonly spawn: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\tprivate readonly resolvePowerShellPath: () => string;\n\tprivate readonly coordinator = new PersistentProcessCoordinator();\n\tprivate activeExec: ActiveEngineExec | null = null;\n\tprivate disposed = false;\n\n\tconstructor(key: string, options: WindowsShellEngineOptions) {\n\t\tthis.key = key;\n\t\tthis.resolveRuntime = options.resolveRuntime ?? (() => ensurePythonRuntime({ silent: true }));\n\t\tthis.engineScriptPath = options.engineScriptPath ?? resolveEngineScriptPath();\n\t\tthis.getState = options.getState ?? getOrCreateWindowsShellState;\n\t\tthis.spawn = options.spawn ?? spawnProcess;\n\t\tthis.resolvePowerShellPath =\n\t\t\toptions.resolvePowerShellPath ??\n\t\t\t(() => (process.platform === \"win32\" ? getShellConfig(undefined, \"powershell\").shell : \"powershell\"));\n\t}\n\n\texec(\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: Parameters<BashOperations[\"exec\"]>[2],\n\t): Promise<{ exitCode: number | null }> {\n\t\treturn this.coordinator.runSerialized(() => this.execNow(command, cwd, options));\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tconst active = this.activeExec;\n\t\tthis.coordinator.dispose();\n\t\tactive?.fail(new Error(`Windows shell engine session \"${this.key}\" is disposed`));\n\t}\n\n\tprivate async execNow(\n\t\tcommand: string,\n\t\tcwd: string,\n\t\t{ onData, signal, timeout, env }: Parameters<BashOperations[\"exec\"]>[2],\n\t): Promise<{ exitCode: number | null }> {\n\t\tif (this.disposed) throw new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\n\t\tconst state = this.getState(this.key);\n\t\tconst effectiveCwd = resolveEffectiveCwd(state, cwd);\n\t\tconst effectiveEnv = mergeEffectiveEnv(state, env ?? getShellEnv());\n\t\tconst child = await this.ensureChild(effectiveEnv);\n\t\tif (this.disposed) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\t\t}\n\t\tif (signal?.aborted) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(\"aborted\");\n\t\t}\n\t\tif (!child.stdin || !child.stdout || !child.stderr || child !== this.coordinator.child) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(\"Failed to start Windows shell engine coordinator\");\n\t\t}\n\n\t\tconst timeoutMs = timeout !== undefined && timeout > 0 ? timeout * 1000 : undefined;\n\t\tconst requestTimeoutMs =\n\t\t\ttimeoutMs !== undefined ? Math.max(timeoutMs - SOFT_DEADLINE_HEADSTART_MS, 1) : undefined;\n\t\tconst requestId = randomBytes(8).toString(\"hex\");\n\t\tconst request: WindowsShellEngineRequest = {\n\t\t\trequestId,\n\t\t\tcommand,\n\t\t\tcwd: effectiveCwd,\n\t\t\tenv: effectiveEnv,\n\t\t\t...(invokesPowerShellScript(command) ? { powershellPath: this.resolvePowerShellPath() } : {}),\n\t\t\t...(requestTimeoutMs !== undefined ? { timeoutMs: requestTimeoutMs } : {}),\n\t\t};\n\t\tconst outputBarrier = Buffer.from(`\\x1e${requestId}\\x1e`, \"latin1\");\n\n\t\tthis.coordinator.setLoopRef(true);\n\t\ttry {\n\t\t\treturn await new Promise<{ exitCode: number | null }>((resolve, reject) => {\n\t\t\t\tlet settled = false;\n\t\t\t\tlet pendingOutput: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n\t\t\t\tlet controlBuffer: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n\t\t\t\tlet controlOverflow = false;\n\t\t\t\tlet sawOutputBarrier = false;\n\t\t\t\tlet controlFrame: WindowsShellEngineControlFrame | undefined;\n\t\t\t\tlet completionScheduled = false;\n\t\t\t\tlet timeoutTimer: NodeJS.Timeout | undefined;\n\n\t\t\t\tconst settle = (finish: () => void): void => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\tsettled = true;\n\t\t\t\t\tif (timeoutTimer) clearTimeout(timeoutTimer);\n\t\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\tif (this.activeExec === active) this.activeExec = null;\n\t\t\t\t\tfinish();\n\t\t\t\t};\n\n\t\t\t\tconst emitPending = (upTo: number): void => {\n\t\t\t\t\tif (upTo <= 0) return;\n\t\t\t\t\tonData(pendingOutput.subarray(0, upTo));\n\t\t\t\t\tpendingOutput = pendingOutput.subarray(upTo);\n\t\t\t\t};\n\n\t\t\t\tconst capturedControl = (): string =>\n\t\t\t\t\tcontrolOverflow\n\t\t\t\t\t\t? `control frame exceeded ${MAX_CONTROL_FRAME_BYTES} bytes`\n\t\t\t\t\t\t: controlBuffer.toString(\"utf8\");\n\n\t\t\t\tconst failAndReset = (error: Error): void => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\temitPending(pendingOutput.length);\n\t\t\t\t\tthis.killChild();\n\t\t\t\t\tsettle(() => reject(error));\n\t\t\t\t};\n\n\t\t\t\tconst protocolFailure = (message: string): WindowsShellEngineFailure => {\n\t\t\t\t\tconst capturedOutput = capturedControl();\n\t\t\t\t\treturn new WindowsShellEngineFailure(`${message}\\n${capturedOutput}`, capturedOutput);\n\t\t\t\t};\n\n\t\t\t\tconst maybeComplete = (): void => {\n\t\t\t\t\tif (!sawOutputBarrier || !controlFrame || settled || completionScheduled) return;\n\t\t\t\t\tcompletionScheduled = true;\n\t\t\t\t\t// stdout and stderr are independent pipes. Keep this request active through the\n\t\t\t\t\t// next check phase so already-delivered post-barrier bytes are rejected here,\n\t\t\t\t\t// never forwarded into a queued request that starts in a promise microtask.\n\t\t\t\t\tsetImmediate(() => {\n\t\t\t\t\t\tif (settled || this.activeExec !== active || !controlFrame) return;\n\t\t\t\t\t\tapplyEngineFrame(state, controlFrame);\n\t\t\t\t\t\tif (controlFrame.unsupported) {\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\treject(new Error(controlFrame?.unsupported?.message ?? \"Unsupported shell construct\")),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsettle(() => resolve({ exitCode: controlFrame?.exitCode ?? null }));\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tconst onAbort = (): void => failAndReset(new Error(\"aborted\"));\n\n\t\t\t\tconst active: ActiveEngineExec = {\n\t\t\t\t\tonStdout: (data) => {\n\t\t\t\t\t\tif (sawOutputBarrier) {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted output after its terminal barrier.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpendingOutput = pendingOutput.length === 0 ? data : Buffer.concat([pendingOutput, data]);\n\t\t\t\t\t\tconst barrierIndex = pendingOutput.indexOf(outputBarrier);\n\t\t\t\t\t\tif (barrierIndex !== -1) {\n\t\t\t\t\t\t\temitPending(barrierIndex);\n\t\t\t\t\t\t\tpendingOutput = pendingOutput.subarray(outputBarrier.length);\n\t\t\t\t\t\t\tif (pendingOutput.length > 0) {\n\t\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted bytes after its terminal barrier.\"));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsawOutputBarrier = true;\n\t\t\t\t\t\t\tmaybeComplete();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\temitPending(pendingOutput.length - (outputBarrier.length - 1));\n\t\t\t\t\t},\n\t\t\t\t\tonStderr: (data) => {\n\t\t\t\t\t\tif (controlOverflow) return;\n\t\t\t\t\t\tif (controlBuffer.length + data.length > MAX_CONTROL_FRAME_BYTES) {\n\t\t\t\t\t\t\tcontrolOverflow = true;\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine control frame overflowed.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontrolBuffer = controlBuffer.length === 0 ? data : Buffer.concat([controlBuffer, data]);\n\t\t\t\t\t\tconst parsed = parseControlFrame(controlBuffer);\n\t\t\t\t\t\tif (!parsed) return;\n\t\t\t\t\t\tif (parsed.kind === \"invalid\") {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine returned a malformed control frame.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (parsed.frame.requestId !== requestId) {\n\t\t\t\t\t\t\tfailAndReset(\n\t\t\t\t\t\t\t\tprotocolFailure(\n\t\t\t\t\t\t\t\t\t`Windows shell engine returned stale control frame ${parsed.frame.requestId}; expected ${requestId}.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (controlBuffer.subarray(parsed.frameEnd).toString(\"utf8\").trim().length > 0) {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted trailing control bytes.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontrolFrame = parsed.frame;\n\t\t\t\t\t\tmaybeComplete();\n\t\t\t\t\t},\n\t\t\t\t\tonChildClose: (code) => {\n\t\t\t\t\t\tconst capturedOutput = capturedControl();\n\t\t\t\t\t\temitPending(pendingOutput.length);\n\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew WindowsShellEngineFailure(\n\t\t\t\t\t\t\t\t\t`Windows shell engine coordinator exited (${code ?? \"null\"}) before a complete terminal handoff.\\n${capturedOutput}`,\n\t\t\t\t\t\t\t\t\tcapturedOutput,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\tfail: (error) => failAndReset(error),\n\t\t\t\t};\n\n\t\t\t\tthis.activeExec = active;\n\t\t\t\tif (signal) signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\tif (timeoutMs !== undefined) {\n\t\t\t\t\ttimeoutTimer = setTimeout(() => failAndReset(new Error(`timeout:${timeout}`)), timeoutMs);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tchild.stdin?.write(`${JSON.stringify(request)}\\n`, \"utf8\", (error) => {\n\t\t\t\t\t\tif (!error) return;\n\t\t\t\t\t\tfailAndReset(new Error(`Failed to write to Windows shell engine coordinator: ${error.message}`));\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tfailAndReset(new Error(`Failed to write to Windows shell engine coordinator: ${message}`));\n\t\t\t\t}\n\t\t\t});\n\t\t} finally {\n\t\t\tthis.coordinator.setLoopRef(false);\n\t\t}\n\t}\n\n\tprivate async ensureChild(env: NodeJS.ProcessEnv): Promise<ChildProcess> {\n\t\tif (this.coordinator.child) return this.coordinator.child;\n\t\tconst runtime = await this.resolveRuntime();\n\t\tif (runtime.status !== \"ready\") throw degradationError(runtime);\n\t\tif (this.disposed) throw new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\n\t\tconst child = this.spawn(runtime.pythonPath, [\"-B\", this.engineScriptPath, \"--server\"], {\n\t\t\tcwd: dirname(this.engineScriptPath),\n\t\t\tenv: {\n\t\t\t\t...env,\n\t\t\t\tPYTHONDONTWRITEBYTECODE: \"1\",\n\t\t\t\tPYTHONIOENCODING: \"utf-8\",\n\t\t\t\tPYTHONUNBUFFERED: \"1\",\n\t\t\t\tPYTHONUTF8: \"1\",\n\t\t\t},\n\t\t\tdetached: process.platform !== \"win32\",\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\twindowsHide: true,\n\t\t});\n\t\tthis.coordinator.attach(child, {\n\t\t\tonStdout: (data) => {\n\t\t\t\tconst active = this.activeExec;\n\t\t\t\tif (active) active.onStdout(data);\n\t\t\t\telse if (data.length > 0) this.killChild();\n\t\t\t},\n\t\t\tonStderr: (data) => {\n\t\t\t\tconst active = this.activeExec;\n\t\t\t\tif (active) active.onStderr(data);\n\t\t\t\telse if (data.length > 0) this.killChild();\n\t\t\t},\n\t\t\tonError: (error) => this.activeExec?.fail(error),\n\t\t\tonClose: (code) => this.activeExec?.onChildClose(code),\n\t\t});\n\t\treturn child;\n\t}\n\n\tprivate killChild(): void {\n\t\tthis.coordinator.kill();\n\t}\n}\n\nconst engineSessions = new Map<string, PersistentWindowsShellEngineSession>();\n\nfunction acquireWindowsShellEngineSession(\n\tkey: string,\n\toptions: WindowsShellEngineOptions,\n): PersistentWindowsShellEngineSession {\n\tconst existing = engineSessions.get(key);\n\tif (existing) return existing;\n\tconst session = new PersistentWindowsShellEngineSession(key, options);\n\tengineSessions.set(key, session);\n\treturn session;\n}\n\n/** Kill and forget a Python coordinator. The next call for this key starts a clean process. */\nexport function disposeWindowsShellEngineSession(key: string): void {\n\tconst session = engineSessions.get(key);\n\tif (!session) return;\n\tengineSessions.delete(key);\n\tsession.dispose();\n}\n\n/** Create the Python-engine tier for one bash-tool session. */\nexport function createWindowsShellEngineOperations(\n\tsessionKey: string,\n\toptions: WindowsShellEngineOptions = {},\n): BashOperations {\n\treturn {\n\t\t// Resolve through the registry for every command. Session teardown (for example after\n\t\t// credential/environment changes) deletes only this tenant's entry; an already-built tool\n\t\t// then lazily acquires a fresh coordinator instead of retaining the disposed instance.\n\t\texec: (command, cwd, execOptions) =>\n\t\t\tacquireWindowsShellEngineSession(sessionKey, options).exec(command, cwd, execOptions),\n\t};\n}\n"]}
1
+ {"version":3,"file":"windows-shell-engine.js","sourceRoot":"","sources":["../../../src/core/tools/windows-shell-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAA6B,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACN,gBAAgB,EAChB,4BAA4B,EAC5B,iBAAiB,EACjB,mBAAmB,GAEnB,MAAM,0BAA0B,CAAC;AAElC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,uBAAuB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC1C,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAyCvC,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAGnD,YAAY,OAAe,EAAE,cAAsB;QAClD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACtC,CAAC;CACD;AAED,SAAS,uBAAuB;IAC/B,OAAO,IAAI,CAAC,sBAAsB,EAAE,EAAE,UAAU,EAAE,iB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O;QACN,sFAAsF;QACtF,0FAA0F;QAC1F,uFAAuF;QACvF,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE,CACnC,gCAAgC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC;KACtF,CAAC;AACH,CAAC","sourcesContent":["/**\n * Persistent Windows Python shell-engine sessions.\n *\n * One coordinator process is keyed to each agent session. Requests are serialized as JSON lines;\n * Node remains the sole owner of cwd/environment state and derives each request only after the\n * preceding terminal frame has been applied. Command bytes stream on stdout, followed by a\n * request-specific output barrier. A correlated control frame arrives on stderr. Requiring both\n * channels before settlement prevents cross-pipe tail loss and stale-frame reuse.\n *\n * Timeout, abort, protocol failure, or coordinator death resets the whole process tree. The next\n * request starts a clean coordinator from the last state Node actually acknowledged.\n */\n\nimport type { ChildProcess, SpawnOptions } from \"node:child_process\";\nimport { randomBytes } from \"node:crypto\";\nimport { dirname, join } from \"node:path\";\nimport { getBundledResourcesDir } from \"../../config.ts\";\nimport { spawnProcess } from \"../../utils/child-process.ts\";\nimport { getShellConfig, getShellEnv } from \"../../utils/shell.ts\";\nimport { ensurePythonRuntime, type PythonRuntimeOutcome } from \"../python-runtime.ts\";\nimport { isRecordObject } from \"../util/value-guards.ts\";\nimport type { BashOperations } from \"./bash.ts\";\nimport { PersistentProcessCoordinator } from \"./persistent-process-coordinator.ts\";\nimport { tokenizeShellCommand } from \"./shell-command-parser.ts\";\nimport {\n\tapplyEngineFrame,\n\tgetOrCreateWindowsShellState,\n\tmergeEffectiveEnv,\n\tresolveEffectiveCwd,\n\ttype WindowsShellState,\n} from \"./windows-shell-state.ts\";\n\nconst ENGINE_FRAME_SENTINEL = 0x1e;\nconst MAX_CONTROL_FRAME_BYTES = 64 * 1024;\nconst SOFT_DEADLINE_HEADSTART_MS = 100;\n\n/** State/result fields returned for every completed engine command. */\nexport interface WindowsShellEngineFrame {\n\texitCode: number;\n\tcwd: string;\n\tenvDelta: Record<string, string | null>;\n\tunsupported: { code: \"unsupported\"; construct: string; message: string } | null;\n}\n\ninterface WindowsShellEngineControlFrame extends WindowsShellEngineFrame {\n\trequestId: string;\n}\n\ninterface WindowsShellEngineRequest {\n\trequestId: string;\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n\tpowershellPath?: string;\n\ttimeoutMs?: number;\n}\n\ninterface ParsedControlFrame {\n\tkind: \"frame\";\n\tframe: WindowsShellEngineControlFrame;\n\tframeStart: number;\n\tframeEnd: number;\n}\n\ninterface InvalidControlFrame {\n\tkind: \"invalid\";\n}\n\ninterface ActiveEngineExec {\n\tonStdout(data: Buffer): void;\n\tonStderr(data: Buffer): void;\n\tonChildClose(code: number | null): void;\n\tfail(error: Error): void;\n}\n\nexport class WindowsShellEngineFailure extends Error {\n\treadonly capturedOutput: string;\n\n\tconstructor(message: string, capturedOutput: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WindowsShellEngineFailure\";\n\t\tthis.capturedOutput = capturedOutput;\n\t}\n}\n\nfunction resolveEngineScriptPath(): string {\n\treturn join(getBundledResourcesDir(), \"runtimes\", \"pi-shell-engine\", \"main.py\");\n}\n\nfunction invokesPowerShellScript(command: string): boolean {\n\tconst tokens = tokenizeShellCommand(command);\n\t// An unparseable command is already heading to the authoritative Python parser;\n\t// resolve conservatively so script adaptation cannot lose an explicit host choice.\n\tif (!tokens) return /\\.ps1\\b/iu.test(command);\n\n\tlet atCommandStart = true;\n\tlet skipRedirectTarget = false;\n\tfor (const token of tokens) {\n\t\tif (token.kind === \"operator\" || token.kind === \"pipe\") {\n\t\t\tatCommandStart = true;\n\t\t\tskipRedirectTarget = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (token.kind === \"redirect\") {\n\t\t\tskipRedirectTarget = !/^\\d*[<>]&[\\d-]+$/u.test(token.value);\n\t\t\tcontinue;\n\t\t}\n\t\tif (skipRedirectTarget) {\n\t\t\tskipRedirectTarget = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!atCommandStart || /^[A-Za-z_][A-Za-z0-9_]*=/u.test(token.value)) continue;\n\t\tif (token.value.toLowerCase().endsWith(\".ps1\")) return true;\n\t\tatCommandStart = false;\n\t}\n\treturn false;\n}\n\nfunction parseControlFrame(buffer: Buffer): ParsedControlFrame | InvalidControlFrame | undefined {\n\tconst frameStart = buffer.indexOf(ENGINE_FRAME_SENTINEL);\n\tif (frameStart === -1) return undefined;\n\tconst closeIndex = buffer.indexOf(ENGINE_FRAME_SENTINEL, frameStart + 1);\n\tif (closeIndex === -1) return undefined;\n\ttry {\n\t\tconst raw: unknown = JSON.parse(buffer.subarray(frameStart + 1, closeIndex).toString(\"utf8\"));\n\t\tif (\n\t\t\tisRecordObject(raw) &&\n\t\t\ttypeof raw.requestId === \"string\" &&\n\t\t\t/^[0-9a-f]{16}$/u.test(raw.requestId) &&\n\t\t\ttypeof raw.exitCode === \"number\" &&\n\t\t\tNumber.isInteger(raw.exitCode) &&\n\t\t\ttypeof raw.cwd === \"string\" &&\n\t\t\tisRecordObject(raw.envDelta) &&\n\t\t\t(raw.unsupported === null || isRecordObject(raw.unsupported)) &&\n\t\t\t(raw.unsupported === null ||\n\t\t\t\t(raw.unsupported.code === \"unsupported\" &&\n\t\t\t\t\ttypeof raw.unsupported.construct === \"string\" &&\n\t\t\t\t\ttypeof raw.unsupported.message === \"string\")) &&\n\t\t\tObject.values(raw.envDelta).every((value) => value === null || typeof value === \"string\")\n\t\t) {\n\t\t\treturn {\n\t\t\t\tkind: \"frame\",\n\t\t\t\tframe: raw as unknown as WindowsShellEngineControlFrame,\n\t\t\t\tframeStart,\n\t\t\t\tframeEnd: closeIndex + 1,\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// A complete delimited record that is not JSON is a terminal protocol fault.\n\t}\n\treturn { kind: \"invalid\" };\n}\n\nexport interface WindowsShellEngineOptions {\n\t/** Override for tests: resolves the Python runtime outcome. Default: `ensurePythonRuntime`. */\n\tresolveRuntime?: () => Promise<PythonRuntimeOutcome>;\n\t/** Override for tests: absolute path to the engine's `main.py`. Default: the bundled runtime. */\n\tengineScriptPath?: string;\n\t/** Override for tests: the per-session state store lookup. Default: the shared module store. */\n\tgetState?: (sessionKey: string) => WindowsShellState;\n\t/** Override for tests: spawns the persistent coordinator. Default: `spawnProcess`. */\n\tspawn?: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\t/** Override for tests: selected PowerShell host used to adapt `.ps1` external commands. */\n\tresolvePowerShellPath?: () => string;\n}\n\nfunction degradationError(\n\toutcome: Extract<PythonRuntimeOutcome, { status: \"offline\" | \"uv-unavailable\" | \"python-unavailable\" }>,\n): Error {\n\treturn new Error(\n\t\t`The Windows shell engine (Python) is unavailable: ${outcome.reason} The simple-command PowerShell floor still works; fix the Python runtime (uv/network) to restore for loops, portable builtins such as printf, pipelines, redirection, expansion, and chaining.`,\n\t);\n}\n\nclass PersistentWindowsShellEngineSession {\n\tprivate readonly key: string;\n\tprivate readonly resolveRuntime: () => Promise<PythonRuntimeOutcome>;\n\tprivate readonly engineScriptPath: string;\n\tprivate readonly getState: (sessionKey: string) => WindowsShellState;\n\tprivate readonly spawn: (command: string, args: string[], options: SpawnOptions) => ChildProcess;\n\tprivate readonly resolvePowerShellPath: () => string;\n\tprivate readonly coordinator = new PersistentProcessCoordinator();\n\tprivate activeExec: ActiveEngineExec | null = null;\n\tprivate disposed = false;\n\n\tconstructor(key: string, options: WindowsShellEngineOptions) {\n\t\tthis.key = key;\n\t\tthis.resolveRuntime = options.resolveRuntime ?? (() => ensurePythonRuntime({ silent: true }));\n\t\tthis.engineScriptPath = options.engineScriptPath ?? resolveEngineScriptPath();\n\t\tthis.getState = options.getState ?? getOrCreateWindowsShellState;\n\t\tthis.spawn = options.spawn ?? spawnProcess;\n\t\tthis.resolvePowerShellPath =\n\t\t\toptions.resolvePowerShellPath ??\n\t\t\t(() => (process.platform === \"win32\" ? getShellConfig(undefined, \"powershell\").shell : \"powershell\"));\n\t}\n\n\texec(\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: Parameters<BashOperations[\"exec\"]>[2],\n\t): Promise<{ exitCode: number | null }> {\n\t\treturn this.coordinator.runSerialized(() => this.execNow(command, cwd, options));\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tconst active = this.activeExec;\n\t\tthis.coordinator.dispose();\n\t\tactive?.fail(new Error(`Windows shell engine session \"${this.key}\" is disposed`));\n\t}\n\n\tprivate async execNow(\n\t\tcommand: string,\n\t\tcwd: string,\n\t\t{ onData, signal, timeout, env }: Parameters<BashOperations[\"exec\"]>[2],\n\t): Promise<{ exitCode: number | null }> {\n\t\tif (this.disposed) throw new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\n\t\tconst state = this.getState(this.key);\n\t\tconst effectiveCwd = resolveEffectiveCwd(state, cwd);\n\t\tconst effectiveEnv = mergeEffectiveEnv(state, env ?? getShellEnv());\n\t\tconst child = await this.ensureChild(effectiveEnv);\n\t\tif (this.disposed) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\t\t}\n\t\tif (signal?.aborted) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(\"aborted\");\n\t\t}\n\t\tif (!child.stdin || !child.stdout || !child.stderr || child !== this.coordinator.child) {\n\t\t\tthis.killChild();\n\t\t\tthrow new Error(\"Failed to start Windows shell engine coordinator\");\n\t\t}\n\n\t\tconst timeoutMs = timeout !== undefined && timeout > 0 ? timeout * 1000 : undefined;\n\t\tconst requestTimeoutMs =\n\t\t\ttimeoutMs !== undefined ? Math.max(timeoutMs - SOFT_DEADLINE_HEADSTART_MS, 1) : undefined;\n\t\tconst requestId = randomBytes(8).toString(\"hex\");\n\t\tconst request: WindowsShellEngineRequest = {\n\t\t\trequestId,\n\t\t\tcommand,\n\t\t\tcwd: effectiveCwd,\n\t\t\tenv: effectiveEnv,\n\t\t\t...(invokesPowerShellScript(command) ? { powershellPath: this.resolvePowerShellPath() } : {}),\n\t\t\t...(requestTimeoutMs !== undefined ? { timeoutMs: requestTimeoutMs } : {}),\n\t\t};\n\t\tconst outputBarrier = Buffer.from(`\\x1e${requestId}\\x1e`, \"latin1\");\n\n\t\tthis.coordinator.setLoopRef(true);\n\t\ttry {\n\t\t\treturn await new Promise<{ exitCode: number | null }>((resolve, reject) => {\n\t\t\t\tlet settled = false;\n\t\t\t\tlet pendingOutput: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n\t\t\t\tlet controlBuffer: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n\t\t\t\tlet controlOverflow = false;\n\t\t\t\tlet sawOutputBarrier = false;\n\t\t\t\tlet controlFrame: WindowsShellEngineControlFrame | undefined;\n\t\t\t\tlet completionScheduled = false;\n\t\t\t\tlet timeoutTimer: NodeJS.Timeout | undefined;\n\n\t\t\t\tconst settle = (finish: () => void): void => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\tsettled = true;\n\t\t\t\t\tif (timeoutTimer) clearTimeout(timeoutTimer);\n\t\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\tif (this.activeExec === active) this.activeExec = null;\n\t\t\t\t\tfinish();\n\t\t\t\t};\n\n\t\t\t\tconst emitPending = (upTo: number): void => {\n\t\t\t\t\tif (upTo <= 0) return;\n\t\t\t\t\tonData(pendingOutput.subarray(0, upTo));\n\t\t\t\t\tpendingOutput = pendingOutput.subarray(upTo);\n\t\t\t\t};\n\n\t\t\t\tconst capturedControl = (): string =>\n\t\t\t\t\tcontrolOverflow\n\t\t\t\t\t\t? `control frame exceeded ${MAX_CONTROL_FRAME_BYTES} bytes`\n\t\t\t\t\t\t: controlBuffer.toString(\"utf8\");\n\n\t\t\t\tconst failAndReset = (error: Error): void => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\temitPending(pendingOutput.length);\n\t\t\t\t\tthis.killChild();\n\t\t\t\t\tsettle(() => reject(error));\n\t\t\t\t};\n\n\t\t\t\tconst protocolFailure = (message: string): WindowsShellEngineFailure => {\n\t\t\t\t\tconst capturedOutput = capturedControl();\n\t\t\t\t\treturn new WindowsShellEngineFailure(`${message}\\n${capturedOutput}`, capturedOutput);\n\t\t\t\t};\n\n\t\t\t\tconst maybeComplete = (): void => {\n\t\t\t\t\tif (!sawOutputBarrier || !controlFrame || settled || completionScheduled) return;\n\t\t\t\t\tcompletionScheduled = true;\n\t\t\t\t\t// stdout and stderr are independent pipes. Keep this request active through the\n\t\t\t\t\t// next check phase so already-delivered post-barrier bytes are rejected here,\n\t\t\t\t\t// never forwarded into a queued request that starts in a promise microtask.\n\t\t\t\t\tsetImmediate(() => {\n\t\t\t\t\t\tif (settled || this.activeExec !== active || !controlFrame) return;\n\t\t\t\t\t\tapplyEngineFrame(state, controlFrame);\n\t\t\t\t\t\tif (controlFrame.unsupported) {\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\treject(new Error(controlFrame?.unsupported?.message ?? \"Unsupported shell construct\")),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsettle(() => resolve({ exitCode: controlFrame?.exitCode ?? null }));\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tconst onAbort = (): void => failAndReset(new Error(\"aborted\"));\n\n\t\t\t\tconst active: ActiveEngineExec = {\n\t\t\t\t\tonStdout: (data) => {\n\t\t\t\t\t\tif (sawOutputBarrier) {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted output after its terminal barrier.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpendingOutput = pendingOutput.length === 0 ? data : Buffer.concat([pendingOutput, data]);\n\t\t\t\t\t\tconst barrierIndex = pendingOutput.indexOf(outputBarrier);\n\t\t\t\t\t\tif (barrierIndex !== -1) {\n\t\t\t\t\t\t\temitPending(barrierIndex);\n\t\t\t\t\t\t\tpendingOutput = pendingOutput.subarray(outputBarrier.length);\n\t\t\t\t\t\t\tif (pendingOutput.length > 0) {\n\t\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted bytes after its terminal barrier.\"));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsawOutputBarrier = true;\n\t\t\t\t\t\t\tmaybeComplete();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\temitPending(pendingOutput.length - (outputBarrier.length - 1));\n\t\t\t\t\t},\n\t\t\t\t\tonStderr: (data) => {\n\t\t\t\t\t\tif (controlOverflow) return;\n\t\t\t\t\t\tif (controlBuffer.length + data.length > MAX_CONTROL_FRAME_BYTES) {\n\t\t\t\t\t\t\tcontrolOverflow = true;\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine control frame overflowed.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontrolBuffer = controlBuffer.length === 0 ? data : Buffer.concat([controlBuffer, data]);\n\t\t\t\t\t\tconst parsed = parseControlFrame(controlBuffer);\n\t\t\t\t\t\tif (!parsed) return;\n\t\t\t\t\t\tif (parsed.kind === \"invalid\") {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine returned a malformed control frame.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (parsed.frame.requestId !== requestId) {\n\t\t\t\t\t\t\tfailAndReset(\n\t\t\t\t\t\t\t\tprotocolFailure(\n\t\t\t\t\t\t\t\t\t`Windows shell engine returned stale control frame ${parsed.frame.requestId}; expected ${requestId}.`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (controlBuffer.subarray(parsed.frameEnd).toString(\"utf8\").trim().length > 0) {\n\t\t\t\t\t\t\tfailAndReset(protocolFailure(\"Windows shell engine emitted trailing control bytes.\"));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontrolFrame = parsed.frame;\n\t\t\t\t\t\tmaybeComplete();\n\t\t\t\t\t},\n\t\t\t\t\tonChildClose: (code) => {\n\t\t\t\t\t\tconst capturedOutput = capturedControl();\n\t\t\t\t\t\temitPending(pendingOutput.length);\n\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew WindowsShellEngineFailure(\n\t\t\t\t\t\t\t\t\t`Windows shell engine coordinator exited (${code ?? \"null\"}) before a complete terminal handoff.\\n${capturedOutput}`,\n\t\t\t\t\t\t\t\t\tcapturedOutput,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\tfail: (error) => failAndReset(error),\n\t\t\t\t};\n\n\t\t\t\tthis.activeExec = active;\n\t\t\t\tif (signal) {\n\t\t\t\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\tonAbort();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (timeoutMs !== undefined) {\n\t\t\t\t\ttimeoutTimer = setTimeout(() => failAndReset(new Error(`timeout:${timeout}`)), timeoutMs);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tchild.stdin?.write(`${JSON.stringify(request)}\\n`, \"utf8\", (error) => {\n\t\t\t\t\t\tif (!error) return;\n\t\t\t\t\t\tfailAndReset(new Error(`Failed to write to Windows shell engine coordinator: ${error.message}`));\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tfailAndReset(new Error(`Failed to write to Windows shell engine coordinator: ${message}`));\n\t\t\t\t}\n\t\t\t});\n\t\t} finally {\n\t\t\tthis.coordinator.setLoopRef(false);\n\t\t}\n\t}\n\n\tprivate async ensureChild(env: NodeJS.ProcessEnv): Promise<ChildProcess> {\n\t\tif (this.coordinator.child) return this.coordinator.child;\n\t\tconst runtime = await this.resolveRuntime();\n\t\tif (runtime.status !== \"ready\") throw degradationError(runtime);\n\t\tif (this.disposed) throw new Error(`Windows shell engine session \"${this.key}\" is disposed`);\n\n\t\tconst child = this.spawn(runtime.pythonPath, [\"-B\", this.engineScriptPath, \"--server\"], {\n\t\t\tcwd: dirname(this.engineScriptPath),\n\t\t\tenv: {\n\t\t\t\t...env,\n\t\t\t\tPYTHONDONTWRITEBYTECODE: \"1\",\n\t\t\t\tPYTHONIOENCODING: \"utf-8\",\n\t\t\t\tPYTHONUNBUFFERED: \"1\",\n\t\t\t\tPYTHONUTF8: \"1\",\n\t\t\t},\n\t\t\tdetached: process.platform !== \"win32\",\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\twindowsHide: true,\n\t\t});\n\t\tthis.coordinator.attach(child, {\n\t\t\tonStdout: (data) => {\n\t\t\t\tconst active = this.activeExec;\n\t\t\t\tif (active) active.onStdout(data);\n\t\t\t\telse if (data.length > 0) this.killChild();\n\t\t\t},\n\t\t\tonStderr: (data) => {\n\t\t\t\tconst active = this.activeExec;\n\t\t\t\tif (active) active.onStderr(data);\n\t\t\t\telse if (data.length > 0) this.killChild();\n\t\t\t},\n\t\t\tonError: (error) => this.activeExec?.fail(error),\n\t\t\tonClose: (code) => this.activeExec?.onChildClose(code),\n\t\t});\n\t\treturn child;\n\t}\n\n\tprivate killChild(): void {\n\t\tthis.coordinator.kill();\n\t}\n}\n\nconst engineSessions = new Map<string, PersistentWindowsShellEngineSession>();\n\nfunction acquireWindowsShellEngineSession(\n\tkey: string,\n\toptions: WindowsShellEngineOptions,\n): PersistentWindowsShellEngineSession {\n\tconst existing = engineSessions.get(key);\n\tif (existing) return existing;\n\tconst session = new PersistentWindowsShellEngineSession(key, options);\n\tengineSessions.set(key, session);\n\treturn session;\n}\n\n/** Kill and forget a Python coordinator. The next call for this key starts a clean process. */\nexport function disposeWindowsShellEngineSession(key: string): void {\n\tconst session = engineSessions.get(key);\n\tif (!session) return;\n\tengineSessions.delete(key);\n\tsession.dispose();\n}\n\n/** Create the Python-engine tier for one bash-tool session. */\nexport function createWindowsShellEngineOperations(\n\tsessionKey: string,\n\toptions: WindowsShellEngineOptions = {},\n): BashOperations {\n\treturn {\n\t\t// Resolve through the registry for every command. Session teardown (for example after\n\t\t// credential/environment changes) deletes only this tenant's entry; an already-built tool\n\t\t// then lazily acquires a fresh coordinator instead of retaining the disposed instance.\n\t\texec: (command, cwd, execOptions) =>\n\t\t\tacquireWindowsShellEngineSession(sessionKey, options).exec(command, cwd, execOptions),\n\t};\n}\n"]}
@@ -5,6 +5,14 @@ export declare function sameFileVersion(left: Stats, right: Stats): boolean;
5
5
  export declare function readFileDescriptorBoundedSync(fileDescriptor: number, maxBytes: number): Buffer | undefined;
6
6
  /** Bounded, version-stable text read for small durable state files. */
7
7
  export declare function readBoundedTextFileSync(filePath: string, maxBytes: number, label: string): string;
8
+ export interface BoundedFilePrefix {
9
+ content: Buffer;
10
+ truncated: boolean;
11
+ }
12
+ /** Read one stable file prefix without allocating or reading beyond `maxBytes`. */
13
+ export declare function readFilePrefixSync(filePath: string, maxBytes: number, label: string): BoundedFilePrefix;
14
+ /** Count text lines with constant memory and reject a file that changes during the scan. */
15
+ export declare function countFileLinesSync(filePath: string, label: string): number;
8
16
  /**
9
17
  * Enumerate a managed directory incrementally. Unlike `readdirSync`, this never allocates an
10
18
  * unbounded entry array before the caller can reject a corrupt or hostile directory.
@@ -1 +1 @@
1
- {"version":3,"file":"bounded-file.d.ts","sourceRoot":"","sources":["../../../src/core/util/bounded-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAW5F,s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