@caupulican/pi-adaptative 0.93.2 → 0.93.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +6 -6
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +2 -2
- package/dist/core/agent-session-contracts.d.ts.map +1 -1
- package/dist/core/agent-session-contracts.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +16 -11
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts +1 -0
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js +4 -1
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/composite-tool-gate.d.ts +13 -0
- package/dist/core/autonomy/composite-tool-gate.d.ts.map +1 -0
- package/dist/core/autonomy/composite-tool-gate.js +44 -0
- package/dist/core/autonomy/composite-tool-gate.js.map +1 -0
- package/dist/core/autonomy/envelope-enforcement.d.ts +2 -0
- package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.js +48 -7
- package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js +48 -76
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/path-scope.d.ts.map +1 -1
- package/dist/core/autonomy/path-scope.js +7 -7
- package/dist/core/autonomy/path-scope.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.d.ts +1 -1
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/background-tool-task-controller.d.ts +2 -0
- package/dist/core/background-tool-task-controller.d.ts.map +1 -1
- package/dist/core/background-tool-task-controller.js +13 -5
- package/dist/core/background-tool-task-controller.js.map +1 -1
- package/dist/core/compaction-controller.d.ts +3 -0
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +132 -97
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/cost-guard.js +1 -1
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/delegation/session-root-mailbox.d.ts.map +1 -1
- package/dist/core/delegation/session-root-mailbox.js +14 -1
- package/dist/core/delegation/session-root-mailbox.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +6 -9
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +7 -5
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.js +3 -2
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts +5 -2
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-request.js +1 -1
- package/dist/core/delegation/worker-delegation-request.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js +10 -8
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +2 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
- package/dist/core/foreground-recovery-controller.js +18 -9
- package/dist/core/foreground-recovery-controller.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +3 -5
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js +6 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
- package/dist/core/goals/goal-session-controller.js +1 -1
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +1 -0
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +2 -0
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +1 -1
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/model-router-controller.js +2 -2
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +32 -9
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js +5 -5
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
- package/dist/core/orchestration/policy-compiler.js +7 -0
- package/dist/core/orchestration/policy-compiler.js.map +1 -1
- package/dist/core/orchestration/profile-registry.js +2 -2
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/risk-budget.d.ts +0 -10
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
- package/dist/core/orchestration/risk-budget.js +0 -14
- package/dist/core/orchestration/risk-budget.js.map +1 -1
- package/dist/core/pipelines/active-context.d.ts +16 -0
- package/dist/core/pipelines/active-context.d.ts.map +1 -0
- package/dist/core/pipelines/active-context.js +29 -0
- package/dist/core/pipelines/active-context.js.map +1 -0
- package/dist/core/pipelines/context.d.ts +1 -1
- package/dist/core/pipelines/context.d.ts.map +1 -1
- package/dist/core/pipelines/context.js +40 -31
- package/dist/core/pipelines/context.js.map +1 -1
- package/dist/core/pipelines/discover.d.ts +5 -1
- package/dist/core/pipelines/discover.d.ts.map +1 -1
- package/dist/core/pipelines/discover.js +91 -33
- package/dist/core/pipelines/discover.js.map +1 -1
- package/dist/core/pipelines/increment.d.ts +0 -2
- package/dist/core/pipelines/increment.d.ts.map +1 -1
- package/dist/core/pipelines/increment.js +35 -13
- package/dist/core/pipelines/increment.js.map +1 -1
- package/dist/core/pipelines/index.d.ts +4 -3
- package/dist/core/pipelines/index.d.ts.map +1 -1
- package/dist/core/pipelines/index.js +4 -3
- package/dist/core/pipelines/index.js.map +1 -1
- package/dist/core/pipelines/run-state.d.ts +8 -0
- package/dist/core/pipelines/run-state.d.ts.map +1 -1
- package/dist/core/pipelines/run-state.js +172 -38
- package/dist/core/pipelines/run-state.js.map +1 -1
- package/dist/core/pipelines/types.d.ts +2 -0
- package/dist/core/pipelines/types.d.ts.map +1 -1
- package/dist/core/pipelines/types.js +21 -4
- package/dist/core/pipelines/types.js.map +1 -1
- package/dist/core/provider-prompt-contracts.d.ts +1 -0
- package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
- package/dist/core/provider-prompt-contracts.js +6 -5
- package/dist/core/provider-prompt-contracts.js.map +1 -1
- package/dist/core/reflection-controller.js +1 -1
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +2 -1
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +46 -10
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/settings-manager.d.ts +5 -6
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +8 -13
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +2 -4
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +35 -11
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +6 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/task-projection.d.ts +2 -0
- package/dist/core/tasks/task-projection.d.ts.map +1 -1
- package/dist/core/tasks/task-projection.js +2 -0
- package/dist/core/tasks/task-projection.js.map +1 -1
- package/dist/core/tasks/task-state.d.ts +10 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +43 -2
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +13 -3
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js +136 -28
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +0 -16
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +21 -11
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +45 -7
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +5 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +17 -1
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
- package/dist/core/tools/orchestration-panel.js +1 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -1
- package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -1
- package/dist/core/tools/persistent-process-coordinator.js +12 -7
- package/dist/core/tools/persistent-process-coordinator.js.map +1 -1
- package/dist/core/tools/pipeline.d.ts +1 -0
- package/dist/core/tools/pipeline.d.ts.map +1 -1
- package/dist/core/tools/pipeline.js +95 -44
- package/dist/core/tools/pipeline.js.map +1 -1
- package/dist/core/tools/profile-writer.d.ts +0 -9
- package/dist/core/tools/profile-writer.d.ts.map +1 -1
- package/dist/core/tools/profile-writer.js +0 -3
- package/dist/core/tools/profile-writer.js.map +1 -1
- package/dist/core/tools/secret-store.d.ts.map +1 -1
- package/dist/core/tools/secret-store.js +2 -1
- package/dist/core/tools/secret-store.js.map +1 -1
- package/dist/core/tools/shell-session.d.ts.map +1 -1
- package/dist/core/tools/shell-session.js +6 -1
- package/dist/core/tools/shell-session.js.map +1 -1
- package/dist/core/tools/task-steps.d.ts +10 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +70 -29
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +6 -1
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/util/bounded-file.d.ts +8 -0
- package/dist/core/util/bounded-file.d.ts.map +1 -1
- package/dist/core/util/bounded-file.js +81 -16
- package/dist/core/util/bounded-file.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +7 -16
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +2 -11
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +1 -10
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/modes/interactive/thinking-level-descriptions.d.ts +4 -0
- package/dist/modes/interactive/thinking-level-descriptions.d.ts.map +1 -0
- package/dist/modes/interactive/thinking-level-descriptions.js +12 -0
- package/dist/modes/interactive/thinking-level-descriptions.js.map +1 -0
- package/docs/resources.md +1 -1
- package/docs/settings.md +7 -5
- package/docs/worker-profiles.md +3 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MAX_PIPELINE_STAGE_ID_LENGTH } from "../pipelines/types.js";
|
|
1
2
|
import { isPlainRecord } from "../util/value-guards.js";
|
|
2
3
|
export const TASK_STEP_STATUSES = ["pending", "in_progress", "completed", "blocked", "cancelled"];
|
|
3
4
|
export const TASK_STEP_PRIORITIES = ["low", "normal", "high"];
|
|
@@ -9,6 +10,7 @@ const MAX_TASK_STEP_EVIDENCE = 32;
|
|
|
9
10
|
const MAX_TASK_STEP_EVIDENCE_LENGTH = 2_000;
|
|
10
11
|
const MAX_TASK_STEP_REQUIREMENTS = 32;
|
|
11
12
|
const MAX_TASK_STEP_REQUIREMENT_ID_LENGTH = 200;
|
|
13
|
+
export const MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH = 128;
|
|
12
14
|
export class TaskStepsError extends Error {
|
|
13
15
|
constructor(message) {
|
|
14
16
|
super(message);
|
|
@@ -25,6 +27,11 @@ function hasOptionalString(record, key, maxLength) {
|
|
|
25
27
|
const value = record[key];
|
|
26
28
|
return value === undefined || (typeof value === "string" && value.length <= maxLength);
|
|
27
29
|
}
|
|
30
|
+
function hasOptionalNormalizedString(record, key, maxLength) {
|
|
31
|
+
const value = record[key];
|
|
32
|
+
return (value === undefined ||
|
|
33
|
+
(typeof value === "string" && value.length > 0 && value.length <= maxLength && value.trim() === value));
|
|
34
|
+
}
|
|
28
35
|
function isBoundedStringArray(value, maxItems, maxLength) {
|
|
29
36
|
return (Array.isArray(value) &&
|
|
30
37
|
value.length <= maxItems &&
|
|
@@ -44,6 +51,9 @@ function isTaskStep(value) {
|
|
|
44
51
|
hasOptionalString(value, "owner", MAX_TASK_STEP_OWNER_LENGTH) &&
|
|
45
52
|
(value.requirementIds === undefined ||
|
|
46
53
|
isBoundedStringArray(value.requirementIds, MAX_TASK_STEP_REQUIREMENTS, MAX_TASK_STEP_REQUIREMENT_ID_LENGTH)) &&
|
|
54
|
+
hasOptionalNormalizedString(value, "pipelineRunId", MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH) &&
|
|
55
|
+
hasOptionalNormalizedString(value, "pipelineStageId", MAX_PIPELINE_STAGE_ID_LENGTH) &&
|
|
56
|
+
(value.pipelineRunId === undefined) === (value.pipelineStageId === undefined) &&
|
|
47
57
|
isBoundedStringArray(value.notes, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_NOTE_LENGTH) &&
|
|
48
58
|
isBoundedStringArray(value.evidence, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_EVIDENCE_LENGTH) &&
|
|
49
59
|
typeof value.createdAt === "string" &&
|
|
@@ -153,6 +163,20 @@ function normalizeInputNotes(input) {
|
|
|
153
163
|
notes.push(note);
|
|
154
164
|
return notes;
|
|
155
165
|
}
|
|
166
|
+
export function normalizeTaskStepPipelineLink(pipelineRunId, pipelineStageId, clearPipelineLink = false) {
|
|
167
|
+
if (clearPipelineLink) {
|
|
168
|
+
if (pipelineRunId !== undefined || pipelineStageId !== undefined) {
|
|
169
|
+
throw new TaskStepsError("Task step cannot supply pipeline ids while clearPipelineLink is true.");
|
|
170
|
+
}
|
|
171
|
+
return {};
|
|
172
|
+
}
|
|
173
|
+
const runId = optionalBoundedText(pipelineRunId, "Task step pipeline run id", MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH);
|
|
174
|
+
const stageId = optionalBoundedText(pipelineStageId, "Task step pipeline stage id", MAX_PIPELINE_STAGE_ID_LENGTH);
|
|
175
|
+
if ((runId === undefined) !== (stageId === undefined)) {
|
|
176
|
+
throw new TaskStepsError("Task step pipelineRunId and pipelineStageId must be supplied together.");
|
|
177
|
+
}
|
|
178
|
+
return runId && stageId ? { pipelineRunId: runId, pipelineStageId: stageId } : {};
|
|
179
|
+
}
|
|
156
180
|
/**
|
|
157
181
|
* Find an OPEN (non-terminal) step whose content matches `content` case-insensitively.
|
|
158
182
|
* Terminal steps (completed/cancelled) are deliberately excluded so a legitimate re-add of
|
|
@@ -195,6 +219,9 @@ function createStep(args) {
|
|
|
195
219
|
const requirementIds = args.input.requirementIds === undefined
|
|
196
220
|
? [...(existing?.requirementIds ?? [])]
|
|
197
221
|
: normalizeStrings(args.input.requirementIds, "Task step requirement id", MAX_TASK_STEP_REQUIREMENT_ID_LENGTH);
|
|
222
|
+
const pipelineLink = args.input.clearPipelineLink
|
|
223
|
+
? normalizeTaskStepPipelineLink(args.input.pipelineRunId, args.input.pipelineStageId, true)
|
|
224
|
+
: normalizeTaskStepPipelineLink(args.input.pipelineRunId === undefined ? existing?.pipelineRunId : args.input.pipelineRunId, args.input.pipelineStageId === undefined ? existing?.pipelineStageId : args.input.pipelineStageId);
|
|
198
225
|
return {
|
|
199
226
|
id: args.id,
|
|
200
227
|
content: requireBoundedText(args.input.content, "Task step content", MAX_TASK_STEP_CONTENT_LENGTH),
|
|
@@ -207,6 +234,7 @@ function createStep(args) {
|
|
|
207
234
|
? existing?.owner
|
|
208
235
|
: optionalBoundedText(args.input.owner, "Task step owner", MAX_TASK_STEP_OWNER_LENGTH),
|
|
209
236
|
requirementIds,
|
|
237
|
+
...pipelineLink,
|
|
210
238
|
notes,
|
|
211
239
|
evidence,
|
|
212
240
|
createdAt: args.createdAt,
|
|
@@ -299,7 +327,10 @@ export function updateTaskStep(state, selector, update, now) {
|
|
|
299
327
|
? appendUniqueStrings(current.notes, [note], "Task step note", MAX_TASK_STEP_NOTE_LENGTH)
|
|
300
328
|
: [...current.notes];
|
|
301
329
|
const evidence = appendUniqueStrings(current.evidence, update.evidence, "Task step evidence", MAX_TASK_STEP_EVIDENCE_LENGTH);
|
|
302
|
-
|
|
330
|
+
const pipelineLink = update.clearPipelineLink
|
|
331
|
+
? normalizeTaskStepPipelineLink(update.pipelineRunId, update.pipelineStageId, true)
|
|
332
|
+
: normalizeTaskStepPipelineLink(update.pipelineRunId === undefined ? current.pipelineRunId : update.pipelineRunId, update.pipelineStageId === undefined ? current.pipelineStageId : update.pipelineStageId);
|
|
333
|
+
const nextStep = {
|
|
303
334
|
...current,
|
|
304
335
|
content: update.content === undefined
|
|
305
336
|
? current.content
|
|
@@ -315,10 +346,16 @@ export function updateTaskStep(state, selector, update, now) {
|
|
|
315
346
|
requirementIds: update.requirementIds === undefined
|
|
316
347
|
? [...(current.requirementIds ?? [])]
|
|
317
348
|
: normalizeStrings(update.requirementIds, "Task step requirement id", MAX_TASK_STEP_REQUIREMENT_ID_LENGTH),
|
|
349
|
+
...pipelineLink,
|
|
318
350
|
notes,
|
|
319
351
|
evidence,
|
|
320
352
|
updatedAt: now,
|
|
321
353
|
};
|
|
354
|
+
if (!pipelineLink.pipelineRunId) {
|
|
355
|
+
delete nextStep.pipelineRunId;
|
|
356
|
+
delete nextStep.pipelineStageId;
|
|
357
|
+
}
|
|
358
|
+
steps[selectedIndex] = nextStep;
|
|
322
359
|
if (steps[selectedIndex].status === "in_progress")
|
|
323
360
|
demoteOtherActiveSteps(steps, selectedIndex);
|
|
324
361
|
return nextState(state, steps, now);
|
|
@@ -360,6 +397,9 @@ export function formatTaskSteps(state, options = {}) {
|
|
|
360
397
|
step.priority,
|
|
361
398
|
step.owner,
|
|
362
399
|
step.requirementIds?.length ? `requirements: ${step.requirementIds.join(", ")}` : undefined,
|
|
400
|
+
step.pipelineRunId && step.pipelineStageId
|
|
401
|
+
? `pipeline: ${step.pipelineRunId}/${step.pipelineStageId}`
|
|
402
|
+
: undefined,
|
|
363
403
|
]
|
|
364
404
|
.filter(Boolean)
|
|
365
405
|
.join(", ");
|
|
@@ -386,8 +426,9 @@ export function formatTaskStepsContext(state, maxItems = 12, exhaustedRecovery =
|
|
|
386
426
|
...open.slice(0, limit).map((step) => {
|
|
387
427
|
const label = step.activeForm || step.content;
|
|
388
428
|
const requirementIds = step.requirementIds?.length ? ` requirements=${step.requirementIds.join(",")}` : "";
|
|
429
|
+
const pipeline = step.pipelineRunId && step.pipelineStageId ? ` pipeline=${step.pipelineRunId}/${step.pipelineStageId}` : "";
|
|
389
430
|
const evidence = step.evidence?.length ? ` evidence=${step.evidence.join(",")}` : "";
|
|
390
|
-
return `- [${step.status}] ${label}${requirementIds}${evidence}`;
|
|
431
|
+
return `- [${step.status}] ${label}${requirementIds}${pipeline}${evidence}`;
|
|
391
432
|
}),
|
|
392
433
|
];
|
|
393
434
|
if (open.length > limit)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-state.js","sourceRoot":"","sources":["../../../src/core/tasks/task-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,CAAU,CAAC;AAG3G,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAGvE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAClC,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAClD,MAAM,yBAAyB,GAAG,KAAK,CAAC;AACxC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,6BAA6B,GAAG,KAAK,CAAC;AAC5C,MAAM,0BAA0B,GAAG,EAAE,CAAC;AACtC,MAAM,mCAAmC,GAAG,GAAG,CAAC;AAwDhD,MAAM,OAAO,cAAe,SAAQ,KAAK;IACxC,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC9B,CAAC;CACD;AAED,SAAS,gBAAgB,CAAC,KAAc;IACvC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACzC,OAAO,oBAAoB,CAAC,IAAI,CAAC,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AO,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3E,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["import { isPlainRecord } from \"../util/value-guards.ts\";\n\nexport const TASK_STEP_STATUSES = [\"pending\", \"in_progress\", \"completed\", \"blocked\", \"cancelled\"] as const;\nexport type TaskStepStatus = (typeof TASK_STEP_STATUSES)[number];\n\nexport const TASK_STEP_PRIORITIES = [\"low\", \"normal\", \"high\"] as const;\nexport type TaskStepPriority = (typeof TASK_STEP_PRIORITIES)[number];\n\nexport const MAX_TASK_STEPS = 100;\nexport const MAX_TASK_STEP_CONTENT_LENGTH = 2_000;\nconst MAX_TASK_STEP_NOTE_LENGTH = 4_000;\nconst MAX_TASK_STEP_OWNER_LENGTH = 200;\nconst MAX_TASK_STEP_EVIDENCE = 32;\nconst MAX_TASK_STEP_EVIDENCE_LENGTH = 2_000;\nconst MAX_TASK_STEP_REQUIREMENTS = 32;\nconst MAX_TASK_STEP_REQUIREMENT_ID_LENGTH = 200;\n\nexport interface TaskStepInput {\n\tcontent: string;\n\tactiveForm?: string;\n\tstatus?: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\trequirementIds?: readonly string[];\n\tnote?: string;\n\tnotes?: readonly string[];\n\tevidence?: readonly string[];\n}\n\nexport interface TaskStep {\n\tid: string;\n\tcontent: string;\n\tactiveForm?: string;\n\tstatus: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\t/** Goal requirements this foreground step advances. Optional only for snapshots from older sessions. */\n\trequirementIds?: readonly string[];\n\tnotes: readonly string[];\n\tevidence: readonly string[];\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskStepsArchive {\n\tcompleted: number;\n\tcancelled: number;\n\tcompactedAt?: string;\n}\n\nexport interface TaskStepsState {\n\tversion: 1;\n\trevision: number;\n\tnextStepNumber: number;\n\tsteps: readonly TaskStep[];\n\tarchive: TaskStepsArchive;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskStepUpdate {\n\tcontent?: string;\n\tactiveForm?: string;\n\tstatus?: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\trequirementIds?: readonly string[];\n\tnote?: string;\n\tevidence?: readonly string[];\n}\n\nexport class TaskStepsError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"TaskStepsError\";\n\t}\n}\n\nfunction isTaskStepStatus(value: unknown): value is TaskStepStatus {\n\treturn TASK_STEP_STATUSES.some((status) => status === value);\n}\n\nfunction isTaskStepPriority(value: unknown): value is TaskStepPriority {\n\treturn TASK_STEP_PRIORITIES.some((priority) => priority === value);\n}\n\nfunction hasOptionalString(record: Record<string, unknown>, key: string, maxLength: number): boolean {\n\tconst value = record[key];\n\treturn value === undefined || (typeof value === \"string\" && value.length <= maxLength);\n}\n\nfunction isBoundedStringArray(value: unknown, maxItems: number, maxLength: number): value is readonly string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length <= maxItems &&\n\t\tvalue.every((item) => typeof item === \"string\" && item.length > 0 && item.length <= maxLength)\n\t);\n}\n\nfunction isTaskStep(value: unknown): value is TaskStep {\n\tif (!isPlainRecord(value)) return false;\n\treturn (\n\t\ttypeof value.id === \"string\" &&\n\t\t/^step-[1-9]\\d*$/.test(value.id) &&\n\t\ttypeof value.content === \"string\" &&\n\t\tvalue.content.length > 0 &&\n\t\tvalue.content.length <= MAX_TASK_STEP_CONTENT_LENGTH &&\n\t\thasOptionalString(value, \"activeForm\", MAX_TASK_STEP_CONTENT_LENGTH) &&\n\t\tisTaskStepStatus(value.status) &&\n\t\t(value.priority === undefined || isTaskStepPriority(value.priority)) &&\n\t\thasOptionalString(value, \"owner\", MAX_TASK_STEP_OWNER_LENGTH) &&\n\t\t(value.requirementIds === undefined ||\n\t\t\tisBoundedStringArray(value.requirementIds, MAX_TASK_STEP_REQUIREMENTS, MAX_TASK_STEP_REQUIREMENT_ID_LENGTH)) &&\n\t\tisBoundedStringArray(value.notes, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_NOTE_LENGTH) &&\n\t\tisBoundedStringArray(value.evidence, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_EVIDENCE_LENGTH) &&\n\t\ttypeof value.createdAt === \"string\" &&\n\t\ttypeof value.updatedAt === \"string\"\n\t);\n}\n\nfunction isTaskStepsArchive(value: unknown): value is TaskStepsArchive {\n\tif (!isPlainRecord(value)) return false;\n\treturn (\n\t\tNumber.isInteger(value.completed) &&\n\t\tNumber(value.completed) >= 0 &&\n\t\tNumber.isInteger(value.cancelled) &&\n\t\tNumber(value.cancelled) >= 0 &&\n\t\thasOptionalString(value, \"compactedAt\", 100)\n\t);\n}\n\nexport function isTaskStepsState(value: unknown): value is TaskStepsState {\n\tif (!isPlainRecord(value)) return false;\n\tif (\n\t\tvalue.version !== 1 ||\n\t\t!Number.isInteger(value.revision) ||\n\t\tNumber(value.revision) < 0 ||\n\t\t!Number.isInteger(value.nextStepNumber) ||\n\t\tNumber(value.nextStepNumber) < 1 ||\n\t\t!Array.isArray(value.steps) ||\n\t\tvalue.steps.length > MAX_TASK_STEPS ||\n\t\t!value.steps.every(isTaskStep) ||\n\t\t!isTaskStepsArchive(value.archive) ||\n\t\ttypeof value.createdAt !== \"string\" ||\n\t\ttypeof value.updatedAt !== \"string\"\n\t) {\n\t\treturn false;\n\t}\n\tconst ids = new Set(value.steps.map((step) => step.id));\n\treturn ids.size === value.steps.length && value.steps.filter((step) => step.status === \"in_progress\").length <= 1;\n}\n\nfunction cloneTaskStep(step: TaskStep): TaskStep {\n\treturn {\n\t\t...step,\n\t\trequirementIds: [...(step.requirementIds ?? [])],\n\t\tnotes: [...step.notes],\n\t\tevidence: [...step.evidence],\n\t};\n}\n\nexport function cloneTaskStepsState(state: TaskStepsState): TaskStepsState {\n\treturn {\n\t\t...state,\n\t\tsteps: state.steps.map(cloneTaskStep),\n\t\tarchive: { ...state.archive },\n\t};\n}\n\nexport function createTaskStepsState(now: string): TaskStepsState {\n\treturn {\n\t\tversion: 1,\n\t\trevision: 0,\n\t\tnextStepNumber: 1,\n\t\tsteps: [],\n\t\tarchive: { completed: 0, cancelled: 0 },\n\t\tcreatedAt: now,\n\t\tupdatedAt: now,\n\t};\n}\n\nfunction requireBoundedText(value: string, label: string, maxLength: number): string {\n\tconst normalized = value.trim();\n\tif (!normalized) throw new TaskStepsError(`${label} is required.`);\n\tif (normalized.length > maxLength) throw new TaskStepsError(`${label} must be at most ${maxLength} characters.`);\n\treturn normalized;\n}\n\nfunction optionalBoundedText(value: string | undefined, label: string, maxLength: number): string | undefined {\n\tif (value === undefined) return undefined;\n\tconst normalized = value.trim();\n\tif (!normalized) return undefined;\n\tif (normalized.length > maxLength) throw new TaskStepsError(`${label} must be at most ${maxLength} characters.`);\n\treturn normalized;\n}\n\nfunction normalizeStrings(values: readonly string[] | undefined, label: string, maxLength: number): string[] {\n\tif (!values) return [];\n\tconst normalized: string[] = [];\n\tfor (const value of values) {\n\t\tconst item = requireBoundedText(value, label, maxLength);\n\t\tif (!normalized.includes(item)) normalized.push(item);\n\t}\n\tif (normalized.length > MAX_TASK_STEP_EVIDENCE) {\n\t\tthrow new TaskStepsError(`${label} supports at most ${MAX_TASK_STEP_EVIDENCE} entries.`);\n\t}\n\treturn normalized;\n}\n\nfunction appendUniqueStrings(\n\tcurrent: readonly string[],\n\tvalues: readonly string[] | undefined,\n\tlabel: string,\n\tmaxLength: number,\n): string[] {\n\tconst appended = [...current];\n\tfor (const value of normalizeStrings(values, label, maxLength)) {\n\t\tif (!appended.includes(value)) appended.push(value);\n\t}\n\tif (appended.length > MAX_TASK_STEP_EVIDENCE) {\n\t\tthrow new TaskStepsError(`${label} supports at most ${MAX_TASK_STEP_EVIDENCE} entries.`);\n\t}\n\treturn appended;\n}\n\nfunction normalizeInputNotes(input: TaskStepInput): string[] {\n\tconst notes = normalizeStrings(input.notes, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tconst note = optionalBoundedText(input.note, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tif (note && !notes.includes(note)) notes.push(note);\n\treturn notes;\n}\n\n/**\n * Find an OPEN (non-terminal) step whose content matches `content` case-insensitively.\n * Terminal steps (completed/cancelled) are deliberately excluded so a legitimate re-add of\n * previously finished work still creates a new step.\n */\nexport function findOpenDuplicateStep(steps: readonly TaskStep[], content: string): TaskStep | undefined {\n\tconst normalized = content.trim().toLocaleLowerCase();\n\tif (!normalized) return undefined;\n\treturn steps.find(\n\t\t(step) =>\n\t\t\tstep.status !== \"completed\" && step.status !== \"cancelled\" && step.content.toLocaleLowerCase() === normalized,\n\t);\n}\n\n/** True when a completed step has no evidence attached (a verification nudge candidate). */\nexport function hasUnverifiedCompletedStep(state: TaskStepsState): boolean {\n\treturn state.steps.some((step) => step.status === \"completed\" && step.evidence.length === 0);\n}\n\nfunction demoteOtherActiveSteps(steps: TaskStep[], activeIndex: number): void {\n\tfor (let index = 0; index < steps.length; index++) {\n\t\tif (index !== activeIndex && steps[index].status === \"in_progress\") {\n\t\t\tsteps[index] = { ...steps[index], status: \"pending\" };\n\t\t}\n\t}\n}\n\nfunction nextState(state: TaskStepsState, steps: readonly TaskStep[], now: string): TaskStepsState {\n\treturn {\n\t\t...state,\n\t\trevision: state.revision + 1,\n\t\tsteps: steps.map(cloneTaskStep),\n\t\tarchive: { ...state.archive },\n\t\tupdatedAt: now,\n\t};\n}\n\nfunction createStep(args: {\n\tinput: TaskStepInput;\n\tid: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n\texisting?: TaskStep;\n}): TaskStep {\n\tconst existing = args.existing;\n\tconst notes =\n\t\targs.input.note === undefined && args.input.notes === undefined\n\t\t\t? [...(existing?.notes ?? [])]\n\t\t\t: normalizeInputNotes(args.input);\n\tconst evidence =\n\t\targs.input.evidence === undefined\n\t\t\t? [...(existing?.evidence ?? [])]\n\t\t\t: normalizeStrings(args.input.evidence, \"Task step evidence\", MAX_TASK_STEP_EVIDENCE_LENGTH);\n\tconst requirementIds =\n\t\targs.input.requirementIds === undefined\n\t\t\t? [...(existing?.requirementIds ?? [])]\n\t\t\t: normalizeStrings(args.input.requirementIds, \"Task step requirement id\", MAX_TASK_STEP_REQUIREMENT_ID_LENGTH);\n\treturn {\n\t\tid: args.id,\n\t\tcontent: requireBoundedText(args.input.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tactiveForm:\n\t\t\targs.input.activeForm === undefined\n\t\t\t\t? existing?.activeForm\n\t\t\t\t: optionalBoundedText(args.input.activeForm, \"Task step active form\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tstatus: args.input.status ?? existing?.status ?? \"pending\",\n\t\tpriority: args.input.priority ?? existing?.priority,\n\t\towner:\n\t\t\targs.input.owner === undefined\n\t\t\t\t? existing?.owner\n\t\t\t\t: optionalBoundedText(args.input.owner, \"Task step owner\", MAX_TASK_STEP_OWNER_LENGTH),\n\t\trequirementIds,\n\t\tnotes,\n\t\tevidence,\n\t\tcreatedAt: args.createdAt,\n\t\tupdatedAt: args.updatedAt,\n\t};\n}\n\nexport function setTaskSteps(state: TaskStepsState, inputs: readonly TaskStepInput[], now: string): TaskStepsState {\n\tif (inputs.length > MAX_TASK_STEPS) {\n\t\tthrow new TaskStepsError(`Task steps supports at most ${MAX_TASK_STEPS} steps.`);\n\t}\n\tconst existingByContent = new Map<string, TaskStep[]>();\n\tfor (const step of state.steps) {\n\t\tconst key = step.content.toLocaleLowerCase();\n\t\tconst matches = existingByContent.get(key) ?? [];\n\t\tmatches.push(step);\n\t\texistingByContent.set(key, matches);\n\t}\n\n\tlet nextStepNumber = state.nextStepNumber;\n\tconst steps = inputs.map((input) => {\n\t\tconst content = requireBoundedText(input.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH);\n\t\tconst matches = existingByContent.get(content.toLocaleLowerCase());\n\t\tconst existing = matches?.shift();\n\t\tconst id = existing?.id ?? `step-${nextStepNumber++}`;\n\t\treturn createStep({\n\t\t\tinput: { ...input, content },\n\t\t\tid,\n\t\t\tcreatedAt: existing?.createdAt ?? now,\n\t\t\tupdatedAt: now,\n\t\t\texisting,\n\t\t});\n\t});\n\tconst activeIndex = steps.findLastIndex((step) => step.status === \"in_progress\");\n\tif (activeIndex >= 0) demoteOtherActiveSteps(steps, activeIndex);\n\treturn { ...nextState(state, steps, now), nextStepNumber };\n}\n\nexport function addTaskStep(state: TaskStepsState, input: TaskStepInput, now: string): TaskStepsState {\n\t// Dedupe against OPEN steps only, before the capacity check: a duplicate re-add of an\n\t// already-open step is a no-op regardless of whether the list happens to be full. Terminal\n\t// (completed/cancelled) matches are excluded so a legitimate re-add still creates a step.\n\tif (findOpenDuplicateStep(state.steps, input.content)) return state;\n\tif (state.steps.length >= MAX_TASK_STEPS) {\n\t\tthrow new TaskStepsError(`Task steps already has the maximum ${MAX_TASK_STEPS} steps.`);\n\t}\n\tconst step = createStep({ input, id: `step-${state.nextStepNumber}`, createdAt: now, updatedAt: now });\n\tconst steps = [...state.steps.map(cloneTaskStep), step];\n\tif (step.status === \"in_progress\") demoteOtherActiveSteps(steps, steps.length - 1);\n\treturn { ...nextState(state, steps, now), nextStepNumber: state.nextStepNumber + 1 };\n}\n\nexport function resolveTaskStepSelector(steps: readonly TaskStep[], selector: string): TaskStep {\n\tconst normalized = selector.trim().toLocaleLowerCase();\n\tif (!normalized) throw new TaskStepsError(\"Task step selector is required.\");\n\tif (normalized === \"current\" || normalized === \"active\") {\n\t\tconst active = steps.find((step) => step.status === \"in_progress\");\n\t\tif (!active) throw new TaskStepsError(\"No in_progress task step was found.\");\n\t\treturn active;\n\t}\n\n\tconst exactId = steps.find((step) => step.id.toLocaleLowerCase() === normalized);\n\tif (exactId) return exactId;\n\tconst idPrefix = steps.filter((step) => step.id.toLocaleLowerCase().startsWith(normalized));\n\tif (idPrefix.length === 1) return idPrefix[0];\n\tif (idPrefix.length > 1) {\n\t\tthrow new TaskStepsError(`Task step selector is ambiguous: ${idPrefix.map((step) => step.id).join(\", \")}.`);\n\t}\n\n\tconst exactContent = steps.filter((step) => step.content.toLocaleLowerCase() === normalized);\n\tif (exactContent.length === 1) return exactContent[0];\n\tconst contentMatches = steps.filter((step) => step.content.toLocaleLowerCase().includes(normalized));\n\tif (contentMatches.length === 1) return contentMatches[0];\n\tif (exactContent.length > 1 || contentMatches.length > 1) {\n\t\tconst matches = exactContent.length > 1 ? exactContent : contentMatches;\n\t\tthrow new TaskStepsError(`Task step selector is ambiguous: ${matches.map((step) => step.id).join(\", \")}.`);\n\t}\n\tthrow new TaskStepsError(`Task step not found for selector: ${selector}.`);\n}\n\nexport function updateTaskStep(\n\tstate: TaskStepsState,\n\tselector: string,\n\tupdate: TaskStepUpdate,\n\tnow: string,\n): TaskStepsState {\n\tconst selected = resolveTaskStepSelector(state.steps, selector);\n\tconst selectedIndex = state.steps.findIndex((step) => step.id === selected.id);\n\tconst steps = state.steps.map(cloneTaskStep);\n\tconst current = steps[selectedIndex];\n\tconst note = optionalBoundedText(update.note, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tconst notes = note\n\t\t? appendUniqueStrings(current.notes, [note], \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH)\n\t\t: [...current.notes];\n\tconst evidence = appendUniqueStrings(\n\t\tcurrent.evidence,\n\t\tupdate.evidence,\n\t\t\"Task step evidence\",\n\t\tMAX_TASK_STEP_EVIDENCE_LENGTH,\n\t);\n\tsteps[selectedIndex] = {\n\t\t...current,\n\t\tcontent:\n\t\t\tupdate.content === undefined\n\t\t\t\t? current.content\n\t\t\t\t: requireBoundedText(update.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tactiveForm:\n\t\t\tupdate.activeForm === undefined\n\t\t\t\t? current.activeForm\n\t\t\t\t: optionalBoundedText(update.activeForm, \"Task step active form\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tstatus: update.status ?? current.status,\n\t\tpriority: update.priority ?? current.priority,\n\t\towner:\n\t\t\tupdate.owner === undefined\n\t\t\t\t? current.owner\n\t\t\t\t: optionalBoundedText(update.owner, \"Task step owner\", MAX_TASK_STEP_OWNER_LENGTH),\n\t\trequirementIds:\n\t\t\tupdate.requirementIds === undefined\n\t\t\t\t? [...(current.requirementIds ?? [])]\n\t\t\t\t: normalizeStrings(update.requirementIds, \"Task step requirement id\", MAX_TASK_STEP_REQUIREMENT_ID_LENGTH),\n\t\tnotes,\n\t\tevidence,\n\t\tupdatedAt: now,\n\t};\n\tif (steps[selectedIndex].status === \"in_progress\") demoteOtherActiveSteps(steps, selectedIndex);\n\treturn nextState(state, steps, now);\n}\n\nexport function clearTaskSteps(state: TaskStepsState, now: string): TaskStepsState {\n\treturn {\n\t\t...nextState(state, [], now),\n\t\tarchive: { completed: 0, cancelled: 0 },\n\t};\n}\n\nexport function compactTaskSteps(state: TaskStepsState, now: string): TaskStepsState {\n\tconst completed = state.steps.filter((step) => step.status === \"completed\").length;\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\").length;\n\tconst open = state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\treturn {\n\t\t...nextState(state, open, now),\n\t\tarchive: {\n\t\t\tcompleted: state.archive.completed + completed,\n\t\t\tcancelled: state.archive.cancelled + cancelled,\n\t\t\tcompactedAt: now,\n\t\t},\n\t};\n}\n\nexport function formatTaskSteps(\n\tstate: TaskStepsState,\n\toptions: { includeTerminal?: boolean; maxItems?: number } = {},\n): string {\n\tconst visible = options.includeTerminal\n\t\t? state.steps\n\t\t: state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\tconst maxItems = Math.max(1, Math.min(MAX_TASK_STEPS, Math.floor(options.maxItems ?? 20)));\n\tconst statusMarker: Record<TaskStepStatus, string> = {\n\t\tpending: \" \",\n\t\tin_progress: \">\",\n\t\tcompleted: \"x\",\n\t\tblocked: \"!\",\n\t\tcancelled: \"-\",\n\t};\n\tconst lines = [`Task steps (${visible.length} visible, ${state.steps.length} tracked):`];\n\tfor (const step of visible.slice(0, maxItems)) {\n\t\tconst details = [\n\t\t\tstep.priority,\n\t\t\tstep.owner,\n\t\t\tstep.requirementIds?.length ? `requirements: ${step.requirementIds.join(\", \")}` : undefined,\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\", \");\n\t\tlines.push(\n\t\t\t`- [${statusMarker[step.status]}] ${step.id} ${step.activeForm || step.content}${details ? ` (${details})` : \"\"}`,\n\t\t);\n\t\tfor (const note of step.notes.slice(-2)) lines.push(` note: ${note}`);\n\t\tfor (const evidence of step.evidence.slice(-2)) lines.push(` evidence: ${evidence}`);\n\t}\n\tif (visible.length > maxItems) lines.push(`- … ${visible.length - maxItems} more`);\n\tif (state.archive.completed || state.archive.cancelled) {\n\t\tlines.push(\n\t\t\t`Archived terminal steps: ${state.archive.completed} completed, ${state.archive.cancelled} cancelled.`,\n\t\t);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function formatTaskStepsContext(\n\tstate: TaskStepsState,\n\tmaxItems = 12,\n\texhaustedRecovery = false,\n): string | undefined {\n\tconst open = state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\tif (open.length === 0) return undefined;\n\tconst limit = Math.max(1, Math.min(MAX_TASK_STEPS, Math.floor(maxItems)));\n\tconst lines = [\n\t\t\"TASK STEPS\",\n\t\t...open.slice(0, limit).map((step) => {\n\t\t\tconst label = step.activeForm || step.content;\n\t\t\tconst requirementIds = step.requirementIds?.length ? ` requirements=${step.requirementIds.join(\",\")}` : \"\";\n\t\t\tconst evidence = step.evidence?.length ? ` evidence=${step.evidence.join(\",\")}` : \"\";\n\t\t\treturn `- [${step.status}] ${label}${requirementIds}${evidence}`;\n\t\t}),\n\t];\n\tif (open.length > limit) lines.push(`- omitted=${open.length - limit}`);\n\tconst active = open.find((step) => step.status === \"in_progress\");\n\tlines.push(\n\t\tactive\n\t\t\t? exhaustedRecovery\n\t\t\t\t? `FIRST: recovery exhausted for the last unchanged operation on in_progress step: ${active.activeForm || active.content}. Do not repeat that call. Change arguments/approach or set the step blocked/cancelled.`\n\t\t\t\t: `FIRST: continue in_progress step: ${active.activeForm || active.content}. Evidence known: set completed/blocked/cancelled.`\n\t\t\t: `No in_progress step. Start first: ${open[0].activeForm || open[0].content}.`,\n\t\t\"Keep task_steps current; no stale in_progress before final.\",\n\t);\n\tif (hasUnverifiedCompletedStep(state)) {\n\t\tlines.push(\"Completed step lacks evidence; attach via task_steps before verified.\");\n\t}\n\t// Wrapped in a marker (mirrors the <memory_context> precedent) so context-gc's\n\t// semantic-memory packer can recognize this as a deterministic, re-derivable context page and\n\t// pack stale copies down to the most recent one instead of letting a full page accumulate every\n\t// turn. The revision (monotonic per mutation) lets a reader tell which page is current.\n\treturn `<task_steps_context revision=${state.revision}>\\n${lines.join(\"\\n\")}\\n</task_steps_context>`;\n}\n\nexport function serializeTaskStepsState(state: TaskStepsState): string {\n\treturn JSON.stringify(cloneTaskStepsState(state), null, 2);\n}\n\nexport function parseTaskStepsState(text: string): TaskStepsState | undefined {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(text);\n\t\treturn isTaskStepsState(parsed) ? cloneTaskStepsState(parsed) : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"task-state.js","sourceRoot":"","sources":["../../../src/core/tasks/task-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,CAAU,CAAC;AAG3G,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAK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ELINE_STAGE_ID_LENGTH } from \"../pipelines/types.ts\";\nimport { isPlainRecord } from \"../util/value-guards.ts\";\n\nexport const TASK_STEP_STATUSES = [\"pending\", \"in_progress\", \"completed\", \"blocked\", \"cancelled\"] as const;\nexport type TaskStepStatus = (typeof TASK_STEP_STATUSES)[number];\n\nexport const TASK_STEP_PRIORITIES = [\"low\", \"normal\", \"high\"] as const;\nexport type TaskStepPriority = (typeof TASK_STEP_PRIORITIES)[number];\n\nexport const MAX_TASK_STEPS = 100;\nexport const MAX_TASK_STEP_CONTENT_LENGTH = 2_000;\nconst MAX_TASK_STEP_NOTE_LENGTH = 4_000;\nconst MAX_TASK_STEP_OWNER_LENGTH = 200;\nconst MAX_TASK_STEP_EVIDENCE = 32;\nconst MAX_TASK_STEP_EVIDENCE_LENGTH = 2_000;\nconst MAX_TASK_STEP_REQUIREMENTS = 32;\nconst MAX_TASK_STEP_REQUIREMENT_ID_LENGTH = 200;\nexport const MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH = 128;\n\nexport interface TaskStepInput {\n\tcontent: string;\n\tactiveForm?: string;\n\tstatus?: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\trequirementIds?: readonly string[];\n\tpipelineRunId?: string;\n\tpipelineStageId?: string;\n\tclearPipelineLink?: boolean;\n\tnote?: string;\n\tnotes?: readonly string[];\n\tevidence?: readonly string[];\n}\n\nexport interface TaskStep {\n\tid: string;\n\tcontent: string;\n\tactiveForm?: string;\n\tstatus: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\t/** Goal requirements this foreground step advances. Optional only for snapshots from older sessions. */\n\trequirementIds?: readonly string[];\n\tpipelineRunId?: string;\n\tpipelineStageId?: string;\n\tnotes: readonly string[];\n\tevidence: readonly string[];\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskStepsArchive {\n\tcompleted: number;\n\tcancelled: number;\n\tcompactedAt?: string;\n}\n\nexport interface TaskStepsState {\n\tversion: 1;\n\trevision: number;\n\tnextStepNumber: number;\n\tsteps: readonly TaskStep[];\n\tarchive: TaskStepsArchive;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskStepUpdate {\n\tcontent?: string;\n\tactiveForm?: string;\n\tstatus?: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\trequirementIds?: readonly string[];\n\tpipelineRunId?: string;\n\tpipelineStageId?: string;\n\tclearPipelineLink?: boolean;\n\tnote?: string;\n\tevidence?: readonly string[];\n}\n\nexport class TaskStepsError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"TaskStepsError\";\n\t}\n}\n\nfunction isTaskStepStatus(value: unknown): value is TaskStepStatus {\n\treturn TASK_STEP_STATUSES.some((status) => status === value);\n}\n\nfunction isTaskStepPriority(value: unknown): value is TaskStepPriority {\n\treturn TASK_STEP_PRIORITIES.some((priority) => priority === value);\n}\n\nfunction hasOptionalString(record: Record<string, unknown>, key: string, maxLength: number): boolean {\n\tconst value = record[key];\n\treturn value === undefined || (typeof value === \"string\" && value.length <= maxLength);\n}\n\nfunction hasOptionalNormalizedString(record: Record<string, unknown>, key: string, maxLength: number): boolean {\n\tconst value = record[key];\n\treturn (\n\t\tvalue === undefined ||\n\t\t(typeof value === \"string\" && value.length > 0 && value.length <= maxLength && value.trim() === value)\n\t);\n}\n\nfunction isBoundedStringArray(value: unknown, maxItems: number, maxLength: number): value is readonly string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length <= maxItems &&\n\t\tvalue.every((item) => typeof item === \"string\" && item.length > 0 && item.length <= maxLength)\n\t);\n}\n\nfunction isTaskStep(value: unknown): value is TaskStep {\n\tif (!isPlainRecord(value)) return false;\n\treturn (\n\t\ttypeof value.id === \"string\" &&\n\t\t/^step-[1-9]\\d*$/.test(value.id) &&\n\t\ttypeof value.content === \"string\" &&\n\t\tvalue.content.length > 0 &&\n\t\tvalue.content.length <= MAX_TASK_STEP_CONTENT_LENGTH &&\n\t\thasOptionalString(value, \"activeForm\", MAX_TASK_STEP_CONTENT_LENGTH) &&\n\t\tisTaskStepStatus(value.status) &&\n\t\t(value.priority === undefined || isTaskStepPriority(value.priority)) &&\n\t\thasOptionalString(value, \"owner\", MAX_TASK_STEP_OWNER_LENGTH) &&\n\t\t(value.requirementIds === undefined ||\n\t\t\tisBoundedStringArray(value.requirementIds, MAX_TASK_STEP_REQUIREMENTS, MAX_TASK_STEP_REQUIREMENT_ID_LENGTH)) &&\n\t\thasOptionalNormalizedString(value, \"pipelineRunId\", MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH) &&\n\t\thasOptionalNormalizedString(value, \"pipelineStageId\", MAX_PIPELINE_STAGE_ID_LENGTH) &&\n\t\t(value.pipelineRunId === undefined) === (value.pipelineStageId === undefined) &&\n\t\tisBoundedStringArray(value.notes, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_NOTE_LENGTH) &&\n\t\tisBoundedStringArray(value.evidence, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_EVIDENCE_LENGTH) &&\n\t\ttypeof value.createdAt === \"string\" &&\n\t\ttypeof value.updatedAt === \"string\"\n\t);\n}\n\nfunction isTaskStepsArchive(value: unknown): value is TaskStepsArchive {\n\tif (!isPlainRecord(value)) return false;\n\treturn (\n\t\tNumber.isInteger(value.completed) &&\n\t\tNumber(value.completed) >= 0 &&\n\t\tNumber.isInteger(value.cancelled) &&\n\t\tNumber(value.cancelled) >= 0 &&\n\t\thasOptionalString(value, \"compactedAt\", 100)\n\t);\n}\n\nexport function isTaskStepsState(value: unknown): value is TaskStepsState {\n\tif (!isPlainRecord(value)) return false;\n\tif (\n\t\tvalue.version !== 1 ||\n\t\t!Number.isInteger(value.revision) ||\n\t\tNumber(value.revision) < 0 ||\n\t\t!Number.isInteger(value.nextStepNumber) ||\n\t\tNumber(value.nextStepNumber) < 1 ||\n\t\t!Array.isArray(value.steps) ||\n\t\tvalue.steps.length > MAX_TASK_STEPS ||\n\t\t!value.steps.every(isTaskStep) ||\n\t\t!isTaskStepsArchive(value.archive) ||\n\t\ttypeof value.createdAt !== \"string\" ||\n\t\ttypeof value.updatedAt !== \"string\"\n\t) {\n\t\treturn false;\n\t}\n\tconst ids = new Set(value.steps.map((step) => step.id));\n\treturn ids.size === value.steps.length && value.steps.filter((step) => step.status === \"in_progress\").length <= 1;\n}\n\nfunction cloneTaskStep(step: TaskStep): TaskStep {\n\treturn {\n\t\t...step,\n\t\trequirementIds: [...(step.requirementIds ?? [])],\n\t\tnotes: [...step.notes],\n\t\tevidence: [...step.evidence],\n\t};\n}\n\nexport function cloneTaskStepsState(state: TaskStepsState): TaskStepsState {\n\treturn {\n\t\t...state,\n\t\tsteps: state.steps.map(cloneTaskStep),\n\t\tarchive: { ...state.archive },\n\t};\n}\n\nexport function createTaskStepsState(now: string): TaskStepsState {\n\treturn {\n\t\tversion: 1,\n\t\trevision: 0,\n\t\tnextStepNumber: 1,\n\t\tsteps: [],\n\t\tarchive: { completed: 0, cancelled: 0 },\n\t\tcreatedAt: now,\n\t\tupdatedAt: now,\n\t};\n}\n\nfunction requireBoundedText(value: string, label: string, maxLength: number): string {\n\tconst normalized = value.trim();\n\tif (!normalized) throw new TaskStepsError(`${label} is required.`);\n\tif (normalized.length > maxLength) throw new TaskStepsError(`${label} must be at most ${maxLength} characters.`);\n\treturn normalized;\n}\n\nfunction optionalBoundedText(value: string | undefined, label: string, maxLength: number): string | undefined {\n\tif (value === undefined) return undefined;\n\tconst normalized = value.trim();\n\tif (!normalized) return undefined;\n\tif (normalized.length > maxLength) throw new TaskStepsError(`${label} must be at most ${maxLength} characters.`);\n\treturn normalized;\n}\n\nfunction normalizeStrings(values: readonly string[] | undefined, label: string, maxLength: number): string[] {\n\tif (!values) return [];\n\tconst normalized: string[] = [];\n\tfor (const value of values) {\n\t\tconst item = requireBoundedText(value, label, maxLength);\n\t\tif (!normalized.includes(item)) normalized.push(item);\n\t}\n\tif (normalized.length > MAX_TASK_STEP_EVIDENCE) {\n\t\tthrow new TaskStepsError(`${label} supports at most ${MAX_TASK_STEP_EVIDENCE} entries.`);\n\t}\n\treturn normalized;\n}\n\nfunction appendUniqueStrings(\n\tcurrent: readonly string[],\n\tvalues: readonly string[] | undefined,\n\tlabel: string,\n\tmaxLength: number,\n): string[] {\n\tconst appended = [...current];\n\tfor (const value of normalizeStrings(values, label, maxLength)) {\n\t\tif (!appended.includes(value)) appended.push(value);\n\t}\n\tif (appended.length > MAX_TASK_STEP_EVIDENCE) {\n\t\tthrow new TaskStepsError(`${label} supports at most ${MAX_TASK_STEP_EVIDENCE} entries.`);\n\t}\n\treturn appended;\n}\n\nfunction normalizeInputNotes(input: TaskStepInput): string[] {\n\tconst notes = normalizeStrings(input.notes, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tconst note = optionalBoundedText(input.note, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tif (note && !notes.includes(note)) notes.push(note);\n\treturn notes;\n}\n\nexport function normalizeTaskStepPipelineLink(\n\tpipelineRunId: string | undefined,\n\tpipelineStageId: string | undefined,\n\tclearPipelineLink = false,\n): Pick<TaskStep, \"pipelineRunId\" | \"pipelineStageId\"> {\n\tif (clearPipelineLink) {\n\t\tif (pipelineRunId !== undefined || pipelineStageId !== undefined) {\n\t\t\tthrow new TaskStepsError(\"Task step cannot supply pipeline ids while clearPipelineLink is true.\");\n\t\t}\n\t\treturn {};\n\t}\n\tconst runId = optionalBoundedText(pipelineRunId, \"Task step pipeline run id\", MAX_TASK_STEP_PIPELINE_RUN_ID_LENGTH);\n\tconst stageId = optionalBoundedText(pipelineStageId, \"Task step pipeline stage id\", MAX_PIPELINE_STAGE_ID_LENGTH);\n\tif ((runId === undefined) !== (stageId === undefined)) {\n\t\tthrow new TaskStepsError(\"Task step pipelineRunId and pipelineStageId must be supplied together.\");\n\t}\n\treturn runId && stageId ? { pipelineRunId: runId, pipelineStageId: stageId } : {};\n}\n\n/**\n * Find an OPEN (non-terminal) step whose content matches `content` case-insensitively.\n * Terminal steps (completed/cancelled) are deliberately excluded so a legitimate re-add of\n * previously finished work still creates a new step.\n */\nexport function findOpenDuplicateStep(steps: readonly TaskStep[], content: string): TaskStep | undefined {\n\tconst normalized = content.trim().toLocaleLowerCase();\n\tif (!normalized) return undefined;\n\treturn steps.find(\n\t\t(step) =>\n\t\t\tstep.status !== \"completed\" && step.status !== \"cancelled\" && step.content.toLocaleLowerCase() === normalized,\n\t);\n}\n\n/** True when a completed step has no evidence attached (a verification nudge candidate). */\nexport function hasUnverifiedCompletedStep(state: TaskStepsState): boolean {\n\treturn state.steps.some((step) => step.status === \"completed\" && step.evidence.length === 0);\n}\n\nfunction demoteOtherActiveSteps(steps: TaskStep[], activeIndex: number): void {\n\tfor (let index = 0; index < steps.length; index++) {\n\t\tif (index !== activeIndex && steps[index].status === \"in_progress\") {\n\t\t\tsteps[index] = { ...steps[index], status: \"pending\" };\n\t\t}\n\t}\n}\n\nfunction nextState(state: TaskStepsState, steps: readonly TaskStep[], now: string): TaskStepsState {\n\treturn {\n\t\t...state,\n\t\trevision: state.revision + 1,\n\t\tsteps: steps.map(cloneTaskStep),\n\t\tarchive: { ...state.archive },\n\t\tupdatedAt: now,\n\t};\n}\n\nfunction createStep(args: {\n\tinput: TaskStepInput;\n\tid: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n\texisting?: TaskStep;\n}): TaskStep {\n\tconst existing = args.existing;\n\tconst notes =\n\t\targs.input.note === undefined && args.input.notes === undefined\n\t\t\t? [...(existing?.notes ?? [])]\n\t\t\t: normalizeInputNotes(args.input);\n\tconst evidence =\n\t\targs.input.evidence === undefined\n\t\t\t? [...(existing?.evidence ?? [])]\n\t\t\t: normalizeStrings(args.input.evidence, \"Task step evidence\", MAX_TASK_STEP_EVIDENCE_LENGTH);\n\tconst requirementIds =\n\t\targs.input.requirementIds === undefined\n\t\t\t? [...(existing?.requirementIds ?? [])]\n\t\t\t: normalizeStrings(args.input.requirementIds, \"Task step requirement id\", MAX_TASK_STEP_REQUIREMENT_ID_LENGTH);\n\tconst pipelineLink = args.input.clearPipelineLink\n\t\t? normalizeTaskStepPipelineLink(args.input.pipelineRunId, args.input.pipelineStageId, true)\n\t\t: normalizeTaskStepPipelineLink(\n\t\t\t\targs.input.pipelineRunId === undefined ? existing?.pipelineRunId : args.input.pipelineRunId,\n\t\t\t\targs.input.pipelineStageId === undefined ? existing?.pipelineStageId : args.input.pipelineStageId,\n\t\t\t);\n\treturn {\n\t\tid: args.id,\n\t\tcontent: requireBoundedText(args.input.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tactiveForm:\n\t\t\targs.input.activeForm === undefined\n\t\t\t\t? existing?.activeForm\n\t\t\t\t: optionalBoundedText(args.input.activeForm, \"Task step active form\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tstatus: args.input.status ?? existing?.status ?? \"pending\",\n\t\tpriority: args.input.priority ?? existing?.priority,\n\t\towner:\n\t\t\targs.input.owner === undefined\n\t\t\t\t? existing?.owner\n\t\t\t\t: optionalBoundedText(args.input.owner, \"Task step owner\", MAX_TASK_STEP_OWNER_LENGTH),\n\t\trequirementIds,\n\t\t...pipelineLink,\n\t\tnotes,\n\t\tevidence,\n\t\tcreatedAt: args.createdAt,\n\t\tupdatedAt: args.updatedAt,\n\t};\n}\n\nexport function setTaskSteps(state: TaskStepsState, inputs: readonly TaskStepInput[], now: string): TaskStepsState {\n\tif (inputs.length > MAX_TASK_STEPS) {\n\t\tthrow new TaskStepsError(`Task steps supports at most ${MAX_TASK_STEPS} steps.`);\n\t}\n\tconst existingByContent = new Map<string, TaskStep[]>();\n\tfor (const step of state.steps) {\n\t\tconst key = step.content.toLocaleLowerCase();\n\t\tconst matches = existingByContent.get(key) ?? [];\n\t\tmatches.push(step);\n\t\texistingByContent.set(key, matches);\n\t}\n\n\tlet nextStepNumber = state.nextStepNumber;\n\tconst steps = inputs.map((input) => {\n\t\tconst content = requireBoundedText(input.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH);\n\t\tconst matches = existingByContent.get(content.toLocaleLowerCase());\n\t\tconst existing = matches?.shift();\n\t\tconst id = existing?.id ?? `step-${nextStepNumber++}`;\n\t\treturn createStep({\n\t\t\tinput: { ...input, content },\n\t\t\tid,\n\t\t\tcreatedAt: existing?.createdAt ?? now,\n\t\t\tupdatedAt: now,\n\t\t\texisting,\n\t\t});\n\t});\n\tconst activeIndex = steps.findLastIndex((step) => step.status === \"in_progress\");\n\tif (activeIndex >= 0) demoteOtherActiveSteps(steps, activeIndex);\n\treturn { ...nextState(state, steps, now), nextStepNumber };\n}\n\nexport function addTaskStep(state: TaskStepsState, input: TaskStepInput, now: string): TaskStepsState {\n\t// Dedupe against OPEN steps only, before the capacity check: a duplicate re-add of an\n\t// already-open step is a no-op regardless of whether the list happens to be full. Terminal\n\t// (completed/cancelled) matches are excluded so a legitimate re-add still creates a step.\n\tif (findOpenDuplicateStep(state.steps, input.content)) return state;\n\tif (state.steps.length >= MAX_TASK_STEPS) {\n\t\tthrow new TaskStepsError(`Task steps already has the maximum ${MAX_TASK_STEPS} steps.`);\n\t}\n\tconst step = createStep({ input, id: `step-${state.nextStepNumber}`, createdAt: now, updatedAt: now });\n\tconst steps = [...state.steps.map(cloneTaskStep), step];\n\tif (step.status === \"in_progress\") demoteOtherActiveSteps(steps, steps.length - 1);\n\treturn { ...nextState(state, steps, now), nextStepNumber: state.nextStepNumber + 1 };\n}\n\nexport function resolveTaskStepSelector(steps: readonly TaskStep[], selector: string): TaskStep {\n\tconst normalized = selector.trim().toLocaleLowerCase();\n\tif (!normalized) throw new TaskStepsError(\"Task step selector is required.\");\n\tif (normalized === \"current\" || normalized === \"active\") {\n\t\tconst active = steps.find((step) => step.status === \"in_progress\");\n\t\tif (!active) throw new TaskStepsError(\"No in_progress task step was found.\");\n\t\treturn active;\n\t}\n\n\tconst exactId = steps.find((step) => step.id.toLocaleLowerCase() === normalized);\n\tif (exactId) return exactId;\n\tconst idPrefix = steps.filter((step) => step.id.toLocaleLowerCase().startsWith(normalized));\n\tif (idPrefix.length === 1) return idPrefix[0];\n\tif (idPrefix.length > 1) {\n\t\tthrow new TaskStepsError(`Task step selector is ambiguous: ${idPrefix.map((step) => step.id).join(\", \")}.`);\n\t}\n\n\tconst exactContent = steps.filter((step) => step.content.toLocaleLowerCase() === normalized);\n\tif (exactContent.length === 1) return exactContent[0];\n\tconst contentMatches = steps.filter((step) => step.content.toLocaleLowerCase().includes(normalized));\n\tif (contentMatches.length === 1) return contentMatches[0];\n\tif (exactContent.length > 1 || contentMatches.length > 1) {\n\t\tconst matches = exactContent.length > 1 ? exactContent : contentMatches;\n\t\tthrow new TaskStepsError(`Task step selector is ambiguous: ${matches.map((step) => step.id).join(\", \")}.`);\n\t}\n\tthrow new TaskStepsError(`Task step not found for selector: ${selector}.`);\n}\n\nexport function updateTaskStep(\n\tstate: TaskStepsState,\n\tselector: string,\n\tupdate: TaskStepUpdate,\n\tnow: string,\n): TaskStepsState {\n\tconst selected = resolveTaskStepSelector(state.steps, selector);\n\tconst selectedIndex = state.steps.findIndex((step) => step.id === selected.id);\n\tconst steps = state.steps.map(cloneTaskStep);\n\tconst current = steps[selectedIndex];\n\tconst note = optionalBoundedText(update.note, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tconst notes = note\n\t\t? appendUniqueStrings(current.notes, [note], \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH)\n\t\t: [...current.notes];\n\tconst evidence = appendUniqueStrings(\n\t\tcurrent.evidence,\n\t\tupdate.evidence,\n\t\t\"Task step evidence\",\n\t\tMAX_TASK_STEP_EVIDENCE_LENGTH,\n\t);\n\tconst pipelineLink = update.clearPipelineLink\n\t\t? normalizeTaskStepPipelineLink(update.pipelineRunId, update.pipelineStageId, true)\n\t\t: normalizeTaskStepPipelineLink(\n\t\t\t\tupdate.pipelineRunId === undefined ? current.pipelineRunId : update.pipelineRunId,\n\t\t\t\tupdate.pipelineStageId === undefined ? current.pipelineStageId : update.pipelineStageId,\n\t\t\t);\n\tconst nextStep: TaskStep = {\n\t\t...current,\n\t\tcontent:\n\t\t\tupdate.content === undefined\n\t\t\t\t? current.content\n\t\t\t\t: requireBoundedText(update.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tactiveForm:\n\t\t\tupdate.activeForm === undefined\n\t\t\t\t? current.activeForm\n\t\t\t\t: optionalBoundedText(update.activeForm, \"Task step active form\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tstatus: update.status ?? current.status,\n\t\tpriority: update.priority ?? current.priority,\n\t\towner:\n\t\t\tupdate.owner === undefined\n\t\t\t\t? current.owner\n\t\t\t\t: optionalBoundedText(update.owner, \"Task step owner\", MAX_TASK_STEP_OWNER_LENGTH),\n\t\trequirementIds:\n\t\t\tupdate.requirementIds === undefined\n\t\t\t\t? [...(current.requirementIds ?? [])]\n\t\t\t\t: normalizeStrings(update.requirementIds, \"Task step requirement id\", MAX_TASK_STEP_REQUIREMENT_ID_LENGTH),\n\t\t...pipelineLink,\n\t\tnotes,\n\t\tevidence,\n\t\tupdatedAt: now,\n\t};\n\tif (!pipelineLink.pipelineRunId) {\n\t\tdelete nextStep.pipelineRunId;\n\t\tdelete nextStep.pipelineStageId;\n\t}\n\tsteps[selectedIndex] = nextStep;\n\tif (steps[selectedIndex].status === \"in_progress\") demoteOtherActiveSteps(steps, selectedIndex);\n\treturn nextState(state, steps, now);\n}\n\nexport function clearTaskSteps(state: TaskStepsState, now: string): TaskStepsState {\n\treturn {\n\t\t...nextState(state, [], now),\n\t\tarchive: { completed: 0, cancelled: 0 },\n\t};\n}\n\nexport function compactTaskSteps(state: TaskStepsState, now: string): TaskStepsState {\n\tconst completed = state.steps.filter((step) => step.status === \"completed\").length;\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\").length;\n\tconst open = state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\treturn {\n\t\t...nextState(state, open, now),\n\t\tarchive: {\n\t\t\tcompleted: state.archive.completed + completed,\n\t\t\tcancelled: state.archive.cancelled + cancelled,\n\t\t\tcompactedAt: now,\n\t\t},\n\t};\n}\n\nexport function formatTaskSteps(\n\tstate: TaskStepsState,\n\toptions: { includeTerminal?: boolean; maxItems?: number } = {},\n): string {\n\tconst visible = options.includeTerminal\n\t\t? state.steps\n\t\t: state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\tconst maxItems = Math.max(1, Math.min(MAX_TASK_STEPS, Math.floor(options.maxItems ?? 20)));\n\tconst statusMarker: Record<TaskStepStatus, string> = {\n\t\tpending: \" \",\n\t\tin_progress: \">\",\n\t\tcompleted: \"x\",\n\t\tblocked: \"!\",\n\t\tcancelled: \"-\",\n\t};\n\tconst lines = [`Task steps (${visible.length} visible, ${state.steps.length} tracked):`];\n\tfor (const step of visible.slice(0, maxItems)) {\n\t\tconst details = [\n\t\t\tstep.priority,\n\t\t\tstep.owner,\n\t\t\tstep.requirementIds?.length ? `requirements: ${step.requirementIds.join(\", \")}` : undefined,\n\t\t\tstep.pipelineRunId && step.pipelineStageId\n\t\t\t\t? `pipeline: ${step.pipelineRunId}/${step.pipelineStageId}`\n\t\t\t\t: undefined,\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\", \");\n\t\tlines.push(\n\t\t\t`- [${statusMarker[step.status]}] ${step.id} ${step.activeForm || step.content}${details ? ` (${details})` : \"\"}`,\n\t\t);\n\t\tfor (const note of step.notes.slice(-2)) lines.push(` note: ${note}`);\n\t\tfor (const evidence of step.evidence.slice(-2)) lines.push(` evidence: ${evidence}`);\n\t}\n\tif (visible.length > maxItems) lines.push(`- … ${visible.length - maxItems} more`);\n\tif (state.archive.completed || state.archive.cancelled) {\n\t\tlines.push(\n\t\t\t`Archived terminal steps: ${state.archive.completed} completed, ${state.archive.cancelled} cancelled.`,\n\t\t);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function formatTaskStepsContext(\n\tstate: TaskStepsState,\n\tmaxItems = 12,\n\texhaustedRecovery = false,\n): string | undefined {\n\tconst open = state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\tif (open.length === 0) return undefined;\n\tconst limit = Math.max(1, Math.min(MAX_TASK_STEPS, Math.floor(maxItems)));\n\tconst lines = [\n\t\t\"TASK STEPS\",\n\t\t...open.slice(0, limit).map((step) => {\n\t\t\tconst label = step.activeForm || step.content;\n\t\t\tconst requirementIds = step.requirementIds?.length ? ` requirements=${step.requirementIds.join(\",\")}` : \"\";\n\t\t\tconst pipeline =\n\t\t\t\tstep.pipelineRunId && step.pipelineStageId ? ` pipeline=${step.pipelineRunId}/${step.pipelineStageId}` : \"\";\n\t\t\tconst evidence = step.evidence?.length ? ` evidence=${step.evidence.join(\",\")}` : \"\";\n\t\t\treturn `- [${step.status}] ${label}${requirementIds}${pipeline}${evidence}`;\n\t\t}),\n\t];\n\tif (open.length > limit) lines.push(`- omitted=${open.length - limit}`);\n\tconst active = open.find((step) => step.status === \"in_progress\");\n\tlines.push(\n\t\tactive\n\t\t\t? exhaustedRecovery\n\t\t\t\t? `FIRST: recovery exhausted for the last unchanged operation on in_progress step: ${active.activeForm || active.content}. Do not repeat that call. Change arguments/approach or set the step blocked/cancelled.`\n\t\t\t\t: `FIRST: continue in_progress step: ${active.activeForm || active.content}. Evidence known: set completed/blocked/cancelled.`\n\t\t\t: `No in_progress step. Start first: ${open[0].activeForm || open[0].content}.`,\n\t\t\"Keep task_steps current; no stale in_progress before final.\",\n\t);\n\tif (hasUnverifiedCompletedStep(state)) {\n\t\tlines.push(\"Completed step lacks evidence; attach via task_steps before verified.\");\n\t}\n\t// Wrapped in a marker (mirrors the <memory_context> precedent) so context-gc's\n\t// semantic-memory packer can recognize this as a deterministic, re-derivable context page and\n\t// pack stale copies down to the most recent one instead of letting a full page accumulate every\n\t// turn. The revision (monotonic per mutation) lets a reader tell which page is current.\n\treturn `<task_steps_context revision=${state.revision}>\\n${lines.join(\"\\n\")}\\n</task_steps_context>`;\n}\n\nexport function serializeTaskStepsState(state: TaskStepsState): string {\n\treturn JSON.stringify(cloneTaskStepsState(state), null, 2);\n}\n\nexport function parseTaskStepsState(text: string): TaskStepsState | undefined {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(text);\n\t\treturn isTaskStepsState(parsed) ? cloneTaskStepsState(parsed) : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import type { HarnessCapability } from "./capability-contract.ts";
|
|
2
2
|
import type { CapabilityEnforcementKind, OrchestrationProfile } from "./orchestration/contracts.ts";
|
|
3
3
|
export interface ToolCapabilityPolicy {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/** AND across clauses; OR across the capability alternatives inside one clause. */
|
|
5
|
+
capabilityClauses: readonly (readonly HarnessCapability[])[];
|
|
6
|
+
enforcements: readonly CapabilityEnforcementKind[];
|
|
6
7
|
}
|
|
8
|
+
export type ToolPathAccess = "none" | "read" | "write";
|
|
7
9
|
export declare function getToolCapabilityPolicy(toolName: string): ToolCapabilityPolicy | undefined;
|
|
8
10
|
export declare function hasToolCapabilityPolicy(toolName: string): boolean;
|
|
11
|
+
export declare function toolUsesPathScope(toolName: string): boolean;
|
|
12
|
+
export declare function toolCapabilityRequirementClauses(toolName: string, args?: unknown): readonly (readonly HarnessCapability[])[];
|
|
9
13
|
export declare function requiredEnvelopeCapabilities(toolName: string, args?: unknown): readonly HarnessCapability[];
|
|
14
|
+
export declare function formatToolCapabilityRequirement(toolName: string, args?: unknown): string;
|
|
10
15
|
export declare function envelopeHasToolCapability(capabilities: readonly HarnessCapability[], toolName: string, args?: unknown): boolean;
|
|
11
|
-
|
|
16
|
+
/** Resolve the exact alternative selected from every conjunctive clause for one invocation. */
|
|
17
|
+
export declare function resolveToolCallCapabilities(capabilities: readonly HarnessCapability[], toolName: string, args?: unknown): readonly HarnessCapability[] | undefined;
|
|
18
|
+
export declare function resolveCapabilityPathAccess(capabilities: readonly HarnessCapability[]): Exclude<ToolPathAccess, "none"> | undefined;
|
|
19
|
+
/** Resolve whether one authorized invocation exposes caller-controlled paths to a scoped boundary. */
|
|
20
|
+
export declare function resolveToolCallPathAccess(capabilities: readonly HarnessCapability[], toolName: string, args?: unknown): ToolPathAccess;
|
|
21
|
+
export declare function resolveProfileToolCapabilities(profile: Pick<OrchestrationProfile, "capabilityCeiling">, toolName: string): readonly HarnessCapability[] | undefined;
|
|
12
22
|
export declare function describeToolCapabilityAuthority(toolName: string): string;
|
|
13
23
|
//# sourceMappingURL=tool-capability-policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-capability-policy.d.ts","sourceRoot":"","sources":["../../src/core/tool-capability-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAK,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpG,MAAM,WAAW,oBAAoB;IACpC,
|
|
1
|
+
{"version":3,"file":"tool-capability-policy.d.ts","sourceRoot":"","sources":["../../src/core/tool-capability-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAK,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpG,MAAM,WAAW,oBAAoB;IACpC,mFAAmF;IACnF,iBAAiB,EAAE,SAAS,CAAC,SAAS,iBAAiB,EAAE,CAAC,EAAE,CAAC;IAC7D,YAAY,EAAE,SAAS,yBAAyB,EAAE,CAAC;CACnD;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AA6DvD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAE1F;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EA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AAM,CAqCxE"}
|
|
@@ -1,29 +1,53 @@
|
|
|
1
1
|
import { GOAL_LIFECYCLE_TOOL_NAMES } from "./goals/goal-tool-names.js";
|
|
2
|
-
|
|
2
|
+
const READ_PATH_CAPABILITIES = new Set([
|
|
3
|
+
"filesystem.read",
|
|
4
|
+
"worktree.read",
|
|
5
|
+
"skill.read",
|
|
6
|
+
"source.read",
|
|
7
|
+
]);
|
|
8
|
+
const WRITE_PATH_CAPABILITIES = new Set([
|
|
9
|
+
"filesystem.write",
|
|
10
|
+
"worktree.mutate",
|
|
11
|
+
"skill.write",
|
|
12
|
+
"source.write",
|
|
13
|
+
]);
|
|
14
|
+
function policy(capabilityClauses, enforcements) {
|
|
3
15
|
return Object.freeze({
|
|
4
|
-
|
|
5
|
-
|
|
16
|
+
capabilityClauses: Object.freeze(capabilityClauses.map((clause) => Object.freeze([...clause]))),
|
|
17
|
+
enforcements: Object.freeze(typeof enforcements === "string" ? [enforcements] : [...enforcements]),
|
|
6
18
|
});
|
|
7
19
|
}
|
|
8
|
-
const READ_POLICY = policy(["filesystem.read", "worktree.read"], "path-scope");
|
|
9
|
-
const WRITE_POLICY = policy(["filesystem.write", "worktree.mutate"], "path-scope");
|
|
10
|
-
const PROCESS_POLICY = policy(["process.exec", "tests.execute"], "process-launcher");
|
|
11
|
-
const NETWORK_POLICY = policy(["network.http", "service.mcp"], "service-proxy");
|
|
12
|
-
const DELEGATE_POLICY = policy(["workflow.delegate"], "control-plane");
|
|
20
|
+
const READ_POLICY = policy([["filesystem.read", "worktree.read"]], "path-scope");
|
|
21
|
+
const WRITE_POLICY = policy([["filesystem.write", "worktree.mutate"]], "path-scope");
|
|
22
|
+
const PROCESS_POLICY = policy([["process.exec", "tests.execute"]], "process-launcher");
|
|
23
|
+
const NETWORK_POLICY = policy([["network.http", "service.mcp"]], "service-proxy");
|
|
24
|
+
const DELEGATE_POLICY = policy([["workflow.delegate"]], "control-plane");
|
|
13
25
|
const TOOL_CAPABILITY_POLICIES = new Map([
|
|
14
26
|
...["read", "ls", "grep", "find"].map((toolName) => [toolName, READ_POLICY]),
|
|
15
27
|
...["write", "edit", "edit-diff"].map((toolName) => [toolName, WRITE_POLICY]),
|
|
16
28
|
...["bash", "python", "powershell", "shell", "run_toolkit_script", "run_process"].map((toolName) => [toolName, PROCESS_POLICY]),
|
|
17
29
|
...["fetch", "web_search"].map((toolName) => [toolName, NETWORK_POLICY]),
|
|
18
|
-
["skill", policy(["skill.read"], "path-scope")],
|
|
19
|
-
["skill_audit", policy(["skill.read"], "path-scope")],
|
|
20
|
-
["skillify", policy(["skill.write"], "path-scope")],
|
|
21
|
-
["extensionify", policy(["source.write"], "path-scope")],
|
|
22
|
-
|
|
23
|
-
[
|
|
24
|
-
[
|
|
30
|
+
["skill", policy([["skill.read"]], "path-scope")],
|
|
31
|
+
["skill_audit", policy([["skill.read"]], "path-scope")],
|
|
32
|
+
["skillify", policy([["skill.write"]], "path-scope")],
|
|
33
|
+
["extensionify", policy([["source.write"]], "path-scope")],
|
|
34
|
+
["goal", policy([["memory.mutate", "memory.query"]], "memory-broker")],
|
|
35
|
+
[GOAL_LIFECYCLE_TOOL_NAMES[0], policy([["memory.mutate"]], "memory-broker")],
|
|
36
|
+
[GOAL_LIFECYCLE_TOOL_NAMES[1], policy([["memory.query"]], "memory-broker")],
|
|
37
|
+
[GOAL_LIFECYCLE_TOOL_NAMES[2], policy([["memory.mutate"]], "memory-broker")],
|
|
38
|
+
["memory", policy([["memory.mutate", "memory.query"]], "memory-broker")],
|
|
39
|
+
["secret_store", policy([["credentials.use"]], ["service-proxy", "path-scope"])],
|
|
25
40
|
["delegate", DELEGATE_POLICY],
|
|
26
|
-
["model_fitness", policy(["research.execute"], "control-plane")],
|
|
41
|
+
["model_fitness", policy([["research.execute"]], "control-plane")],
|
|
42
|
+
["task_steps", policy([["workflow.plan", "memory.mutate"]], "control-plane")],
|
|
43
|
+
["pipeline", policy([["workflow.plan"], ["filesystem.write", "worktree.mutate"]], ["control-plane", "path-scope"])],
|
|
44
|
+
["tool_task", policy([["process.exec", "workflow.delegate"]], "control-plane")],
|
|
45
|
+
["worktree_sync", policy([["worktree.mutate", "filesystem.write"]], "path-scope")],
|
|
46
|
+
["ask_question", policy([["workflow.plan", "memory.query"]], "control-plane")],
|
|
47
|
+
["artifact_retrieve", policy([["filesystem.read"]], "path-scope")],
|
|
48
|
+
["context_scout", policy([["filesystem.read"]], "path-scope")],
|
|
49
|
+
["tmux_dispatch", policy([["process.exec", "workflow.delegate"]], "process-launcher")],
|
|
50
|
+
["improvement_loop", policy([["process.exec", "tests.execute"]], "process-launcher")],
|
|
27
51
|
]);
|
|
28
52
|
export function getToolCapabilityPolicy(toolName) {
|
|
29
53
|
return TOOL_CAPABILITY_POLICIES.get(toolName.toLowerCase());
|
|
@@ -31,18 +55,108 @@ export function getToolCapabilityPolicy(toolName) {
|
|
|
31
55
|
export function hasToolCapabilityPolicy(toolName) {
|
|
32
56
|
return getToolCapabilityPolicy(toolName) !== undefined;
|
|
33
57
|
}
|
|
58
|
+
export function toolUsesPathScope(toolName) {
|
|
59
|
+
return getToolCapabilityPolicy(toolName)?.enforcements.includes("path-scope") ?? false;
|
|
60
|
+
}
|
|
61
|
+
export function toolCapabilityRequirementClauses(toolName, args) {
|
|
62
|
+
const name = toolName.toLowerCase();
|
|
63
|
+
if (name === "memory" && args !== undefined) {
|
|
64
|
+
const record = args && typeof args === "object" && !Array.isArray(args) ? args : undefined;
|
|
65
|
+
const isUnambiguousQuery = record !== undefined &&
|
|
66
|
+
typeof record.query === "string" &&
|
|
67
|
+
Object.keys(record).every((key) => key === "query");
|
|
68
|
+
return isUnambiguousQuery ? [["memory.query"]] : [["memory.mutate"]];
|
|
69
|
+
}
|
|
70
|
+
if (name === "goal" && args !== undefined) {
|
|
71
|
+
const action = args && typeof args === "object" && !Array.isArray(args) && "action" in args
|
|
72
|
+
? args.action
|
|
73
|
+
: undefined;
|
|
74
|
+
return action === "get" ? [["memory.query"]] : [["memory.mutate"]];
|
|
75
|
+
}
|
|
76
|
+
if (name === "pipeline") {
|
|
77
|
+
const action = args && typeof args === "object" && "action" in args ? args.action : undefined;
|
|
78
|
+
if (action === "list" || action === "status") {
|
|
79
|
+
return [["workflow.plan", "filesystem.read"]];
|
|
80
|
+
}
|
|
81
|
+
return [["workflow.plan"], ["filesystem.write", "worktree.mutate"]];
|
|
82
|
+
}
|
|
83
|
+
const itemPolicy = getToolCapabilityPolicy(name);
|
|
84
|
+
if (!itemPolicy)
|
|
85
|
+
return [];
|
|
86
|
+
return itemPolicy.capabilityClauses;
|
|
87
|
+
}
|
|
34
88
|
export function requiredEnvelopeCapabilities(toolName, args) {
|
|
35
|
-
|
|
89
|
+
const clauses = toolCapabilityRequirementClauses(toolName, args);
|
|
90
|
+
return clauses.map((clause) => clause[0]).filter((c) => c !== undefined);
|
|
91
|
+
}
|
|
92
|
+
export function formatToolCapabilityRequirement(toolName, args) {
|
|
93
|
+
return toolCapabilityRequirementClauses(toolName, args)
|
|
94
|
+
.map((clause) => (clause.length === 1 ? clause[0] : `(${clause.join(" or ")})`))
|
|
95
|
+
.filter((clause) => clause !== undefined)
|
|
96
|
+
.join(" and ");
|
|
36
97
|
}
|
|
37
98
|
export function envelopeHasToolCapability(capabilities, toolName, args) {
|
|
38
|
-
|
|
39
|
-
return candidates.length > 0 && candidates.some((capability) => capabilities.includes(capability));
|
|
99
|
+
return resolveToolCallCapabilities(capabilities, toolName, args) !== undefined;
|
|
40
100
|
}
|
|
41
|
-
|
|
42
|
-
|
|
101
|
+
/** Resolve the exact alternative selected from every conjunctive clause for one invocation. */
|
|
102
|
+
export function resolveToolCallCapabilities(capabilities, toolName, args) {
|
|
103
|
+
const clauses = toolCapabilityRequirementClauses(toolName, args);
|
|
104
|
+
if (clauses.length === 0)
|
|
105
|
+
return undefined;
|
|
106
|
+
const resolved = [];
|
|
107
|
+
for (const clause of clauses) {
|
|
108
|
+
const match = clause.find((capability) => capabilities.includes(capability));
|
|
109
|
+
if (!match)
|
|
110
|
+
return undefined;
|
|
111
|
+
resolved.push(match);
|
|
112
|
+
}
|
|
113
|
+
return resolved;
|
|
114
|
+
}
|
|
115
|
+
export function resolveCapabilityPathAccess(capabilities) {
|
|
116
|
+
if (capabilities.some((capability) => WRITE_PATH_CAPABILITIES.has(capability)))
|
|
117
|
+
return "write";
|
|
118
|
+
if (capabilities.some((capability) => READ_PATH_CAPABILITIES.has(capability)))
|
|
119
|
+
return "read";
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
/** Resolve whether one authorized invocation exposes caller-controlled paths to a scoped boundary. */
|
|
123
|
+
export function resolveToolCallPathAccess(capabilities, toolName, args) {
|
|
124
|
+
const policy = getToolCapabilityPolicy(toolName);
|
|
125
|
+
if (!policy?.enforcements.includes("path-scope"))
|
|
126
|
+
return "none";
|
|
127
|
+
const selected = resolveToolCallCapabilities(capabilities, toolName, args);
|
|
128
|
+
if (!selected)
|
|
129
|
+
return "none";
|
|
130
|
+
const name = toolName.toLowerCase();
|
|
131
|
+
// These tools accept identifiers or natural-language queries, not filesystem paths. Their
|
|
132
|
+
// fixed stores are owned by the tool, while context_scout gates each concrete child read.
|
|
133
|
+
if (name === "artifact_retrieve" || name === "context_scout")
|
|
134
|
+
return "none";
|
|
135
|
+
if (name === "pipeline" && selected.includes("workflow.plan") && selected.length === 1)
|
|
136
|
+
return "none";
|
|
137
|
+
if (name === "secret_store") {
|
|
138
|
+
const action = args && typeof args === "object" && !Array.isArray(args) && "action" in args
|
|
139
|
+
? args.action
|
|
140
|
+
: undefined;
|
|
141
|
+
return action === "migrate" ? "read" : "none";
|
|
142
|
+
}
|
|
143
|
+
return resolveCapabilityPathAccess(selected) ?? "none";
|
|
144
|
+
}
|
|
145
|
+
export function resolveProfileToolCapabilities(profile, toolName) {
|
|
146
|
+
const clauses = toolCapabilityRequirementClauses(toolName);
|
|
147
|
+
if (clauses.length === 0)
|
|
148
|
+
return undefined;
|
|
149
|
+
const resolved = [];
|
|
150
|
+
for (const clause of clauses) {
|
|
151
|
+
const match = clause.find((capability) => profile.capabilityCeiling.includes(capability));
|
|
152
|
+
if (!match)
|
|
153
|
+
return undefined;
|
|
154
|
+
resolved.push(match);
|
|
155
|
+
}
|
|
156
|
+
return resolved;
|
|
43
157
|
}
|
|
44
158
|
export function describeToolCapabilityAuthority(toolName) {
|
|
45
|
-
switch (getToolCapabilityPolicy(toolName)?.
|
|
159
|
+
switch (getToolCapabilityPolicy(toolName)?.capabilityClauses[0]?.[0]) {
|
|
46
160
|
case "filesystem.read":
|
|
47
161
|
case "worktree.read":
|
|
48
162
|
return "read";
|
|
@@ -79,10 +193,4 @@ export function describeToolCapabilityAuthority(toolName) {
|
|
|
79
193
|
return "capability";
|
|
80
194
|
}
|
|
81
195
|
}
|
|
82
|
-
function toolCapabilityCandidates(toolName, args) {
|
|
83
|
-
if (toolName.toLowerCase() === "memory") {
|
|
84
|
-
return args && typeof args === "object" && "query" in args ? ["memory.query"] : ["memory.mutate"];
|
|
85
|
-
}
|
|
86
|
-
return getToolCapabilityPolicy(toolName)?.capabilityCandidates ?? [];
|
|
87
|
-
}
|
|
88
196
|
//# sourceMappingURL=tool-capability-policy.js.map
|