@agimon-ai/doompi-task 0.0.1-alpha.4 → 0.0.1-alpha.40
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/README.md +110 -15
- package/dist/adapters/node/delegationPlatform.cjs +2 -0
- package/dist/adapters/node/delegationPlatform.cjs.map +1 -0
- package/dist/adapters/node/delegationPlatform.mjs +2 -0
- package/dist/adapters/node/delegationPlatform.mjs.map +1 -0
- package/dist/adapters/pi/extension.cjs +3 -0
- package/dist/adapters/pi/extension.cjs.map +1 -0
- package/dist/adapters/pi/extension.d.cts +10 -0
- package/dist/adapters/pi/extension.d.cts.map +1 -0
- package/dist/adapters/pi/extension.d.mts +10 -0
- package/dist/adapters/pi/extension.d.mts.map +1 -0
- package/dist/adapters/pi/extension.mjs +3 -0
- package/dist/adapters/pi/extension.mjs.map +1 -0
- package/dist/adapters/store/paths.cjs +2 -0
- package/dist/adapters/store/paths.cjs.map +1 -0
- package/dist/adapters/store/paths.d.cts +26 -0
- package/dist/adapters/store/paths.d.cts.map +1 -0
- package/dist/adapters/store/paths.d.mts +26 -0
- package/dist/adapters/store/paths.d.mts.map +1 -0
- package/dist/adapters/store/paths.mjs +2 -0
- package/dist/adapters/store/paths.mjs.map +1 -0
- package/dist/adapters/store/taskStore.cjs +2 -0
- package/dist/adapters/store/taskStore.cjs.map +1 -0
- package/dist/adapters/store/taskStore.d.cts +87 -0
- package/dist/adapters/store/taskStore.d.cts.map +1 -0
- package/dist/adapters/store/taskStore.d.mts +87 -0
- package/dist/adapters/store/taskStore.d.mts.map +1 -0
- package/dist/adapters/store/taskStore.mjs +2 -0
- package/dist/adapters/store/taskStore.mjs.map +1 -0
- package/dist/adapters/telemetry/logSinkTelemetry.cjs +2 -0
- package/dist/adapters/telemetry/logSinkTelemetry.cjs.map +1 -0
- package/dist/adapters/telemetry/logSinkTelemetry.d.cts +23 -0
- package/dist/adapters/telemetry/logSinkTelemetry.d.cts.map +1 -0
- package/dist/adapters/telemetry/logSinkTelemetry.d.mts +23 -0
- package/dist/adapters/telemetry/logSinkTelemetry.d.mts.map +1 -0
- package/dist/adapters/telemetry/logSinkTelemetry.mjs +2 -0
- package/dist/adapters/telemetry/logSinkTelemetry.mjs.map +1 -0
- package/dist/adapters/webTasksChannel.cjs +2 -0
- package/dist/adapters/webTasksChannel.cjs.map +1 -0
- package/dist/adapters/webTasksChannel.d.cts +20 -0
- package/dist/adapters/webTasksChannel.d.cts.map +1 -0
- package/dist/adapters/webTasksChannel.d.mts +20 -0
- package/dist/adapters/webTasksChannel.d.mts.map +1 -0
- package/dist/adapters/webTasksChannel.mjs +2 -0
- package/dist/adapters/webTasksChannel.mjs.map +1 -0
- package/dist/commands/index.cjs +2 -0
- package/dist/commands/index.cjs.map +1 -0
- package/dist/commands/index.d.cts +14 -0
- package/dist/commands/index.d.cts.map +1 -0
- package/dist/commands/index.d.mts +14 -0
- package/dist/commands/index.d.mts.map +1 -0
- package/dist/commands/index.mjs +2 -0
- package/dist/commands/index.mjs.map +1 -0
- package/dist/commands/task/promptGuidelines.cjs +2 -0
- package/dist/commands/task/promptGuidelines.cjs.map +1 -0
- package/dist/commands/task/promptGuidelines.d.cts +5 -0
- package/dist/commands/task/promptGuidelines.d.cts.map +1 -0
- package/dist/commands/task/promptGuidelines.d.mts +5 -0
- package/dist/commands/task/promptGuidelines.d.mts.map +1 -0
- package/dist/commands/task/promptGuidelines.mjs +2 -0
- package/dist/commands/task/promptGuidelines.mjs.map +1 -0
- package/dist/commands/task/responseEnvelope.cjs +7 -0
- package/dist/commands/task/responseEnvelope.cjs.map +1 -0
- package/dist/commands/task/responseEnvelope.d.cts +51 -0
- package/dist/commands/task/responseEnvelope.d.cts.map +1 -0
- package/dist/commands/task/responseEnvelope.d.mts +51 -0
- package/dist/commands/task/responseEnvelope.d.mts.map +1 -0
- package/dist/commands/task/responseEnvelope.mjs +7 -0
- package/dist/commands/task/responseEnvelope.mjs.map +1 -0
- package/dist/commands/task/taskTool.cjs +3 -0
- package/dist/commands/task/taskTool.cjs.map +1 -0
- package/dist/commands/task/taskTool.d.cts +20 -0
- package/dist/commands/task/taskTool.d.cts.map +1 -0
- package/dist/commands/task/taskTool.d.mts +20 -0
- package/dist/commands/task/taskTool.d.mts.map +1 -0
- package/dist/commands/task/taskTool.mjs +3 -0
- package/dist/commands/task/taskTool.mjs.map +1 -0
- package/dist/commands.cjs +1 -2
- package/dist/commands.d.cts +2 -14
- package/dist/commands.d.mts +2 -14
- package/dist/commands.mjs +1 -2
- package/dist/config.cjs +1 -2
- package/dist/config.d.cts +2 -38
- package/dist/config.d.mts +2 -38
- package/dist/config.mjs +1 -2
- package/dist/delegation/manager.cjs +1 -6
- package/dist/delegation/manager.d.cts +3 -189
- package/dist/delegation/manager.d.mts +3 -189
- package/dist/delegation/manager.mjs +1 -6
- package/dist/extension.cjs +1 -3
- package/dist/extension.d.cts +2 -12
- package/dist/extension.d.mts +2 -12
- package/dist/extension.mjs +1 -3
- package/dist/extensions/pi.cjs +1 -2
- package/dist/extensions/pi.d.cts +1 -1
- package/dist/extensions/pi.d.mts +1 -1
- package/dist/extensions/pi.mjs +1 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +15 -14
- package/dist/index.d.mts +15 -14
- package/dist/index.mjs +1 -1
- package/dist/logSinkTelemetry.cjs +1 -2
- package/dist/logSinkTelemetry.d.cts +3 -51
- package/dist/logSinkTelemetry.d.mts +3 -51
- package/dist/logSinkTelemetry.mjs +1 -2
- package/dist/schemas/task.cjs +2 -0
- package/dist/schemas/task.cjs.map +1 -0
- package/dist/schemas/task.d.cts +103 -0
- package/dist/schemas/task.d.cts.map +1 -0
- package/dist/schemas/task.d.mts +103 -0
- package/dist/schemas/task.d.mts.map +1 -0
- package/dist/schemas/task.mjs +2 -0
- package/dist/schemas/task.mjs.map +1 -0
- package/dist/services/contextContribution.cjs +3 -0
- package/dist/services/contextContribution.cjs.map +1 -0
- package/dist/services/contextContribution.mjs +3 -0
- package/dist/services/contextContribution.mjs.map +1 -0
- package/dist/services/delegation/manager.cjs +6 -0
- package/dist/services/delegation/manager.cjs.map +1 -0
- package/dist/services/delegation/manager.d.cts +192 -0
- package/dist/services/delegation/manager.d.cts.map +1 -0
- package/dist/services/delegation/manager.d.mts +192 -0
- package/dist/services/delegation/manager.d.mts.map +1 -0
- package/dist/services/delegation/manager.mjs +6 -0
- package/dist/services/delegation/manager.mjs.map +1 -0
- package/dist/services/narration/taskNarration.cjs +2 -0
- package/dist/services/narration/taskNarration.cjs.map +1 -0
- package/dist/services/narration/taskNarration.mjs +2 -0
- package/dist/services/narration/taskNarration.mjs.map +1 -0
- package/dist/services/store/invariants.cjs +2 -0
- package/dist/services/store/invariants.cjs.map +1 -0
- package/dist/services/store/invariants.d.cts +24 -0
- package/dist/services/store/invariants.d.cts.map +1 -0
- package/dist/services/store/invariants.d.mts +24 -0
- package/dist/services/store/invariants.d.mts.map +1 -0
- package/dist/services/store/invariants.mjs +2 -0
- package/dist/services/store/invariants.mjs.map +1 -0
- package/dist/services/store/processLiveness.cjs +2 -0
- package/dist/services/store/processLiveness.cjs.map +1 -0
- package/dist/services/store/processLiveness.d.cts +12 -0
- package/dist/services/store/processLiveness.d.cts.map +1 -0
- package/dist/services/store/processLiveness.d.mts +12 -0
- package/dist/services/store/processLiveness.d.mts.map +1 -0
- package/dist/services/store/processLiveness.mjs +2 -0
- package/dist/services/store/processLiveness.mjs.map +1 -0
- package/dist/services/store/reconcile.cjs +2 -0
- package/dist/services/store/reconcile.cjs.map +1 -0
- package/dist/services/store/reconcile.d.cts +34 -0
- package/dist/services/store/reconcile.d.cts.map +1 -0
- package/dist/services/store/reconcile.d.mts +34 -0
- package/dist/services/store/reconcile.d.mts.map +1 -0
- package/dist/services/store/reconcile.mjs +2 -0
- package/dist/services/store/reconcile.mjs.map +1 -0
- package/dist/services/store/reducer.cjs +3 -0
- package/dist/services/store/reducer.cjs.map +1 -0
- package/dist/services/store/reducer.d.cts +72 -0
- package/dist/services/store/reducer.d.cts.map +1 -0
- package/dist/services/store/reducer.d.mts +72 -0
- package/dist/services/store/reducer.d.mts.map +1 -0
- package/dist/services/store/reducer.mjs +3 -0
- package/dist/services/store/reducer.mjs.map +1 -0
- package/dist/services/store/taskGraph.cjs +2 -0
- package/dist/services/store/taskGraph.cjs.map +1 -0
- package/dist/services/store/taskGraph.d.cts +25 -0
- package/dist/services/store/taskGraph.d.cts.map +1 -0
- package/dist/services/store/taskGraph.d.mts +25 -0
- package/dist/services/store/taskGraph.d.mts.map +1 -0
- package/dist/services/store/taskGraph.mjs +2 -0
- package/dist/services/store/taskGraph.mjs.map +1 -0
- package/dist/services/store/types.cjs +2 -0
- package/dist/services/store/types.cjs.map +1 -0
- package/dist/services/store/types.d.cts +177 -0
- package/dist/services/store/types.d.cts.map +1 -0
- package/dist/services/store/types.d.mts +177 -0
- package/dist/services/store/types.d.mts.map +1 -0
- package/dist/services/store/types.mjs +2 -0
- package/dist/services/store/types.mjs.map +1 -0
- package/dist/store/invariants.cjs +1 -2
- package/dist/store/invariants.d.cts +2 -14
- package/dist/store/invariants.d.mts +2 -14
- package/dist/store/invariants.mjs +1 -2
- package/dist/store/paths.cjs +1 -2
- package/dist/store/paths.d.cts +2 -23
- package/dist/store/paths.d.mts +2 -23
- package/dist/store/paths.mjs +1 -2
- package/dist/store/processLiveness.cjs +1 -2
- package/dist/store/processLiveness.d.cts +2 -12
- package/dist/store/processLiveness.d.mts +2 -12
- package/dist/store/processLiveness.mjs +1 -2
- package/dist/store/reconcile.cjs +1 -2
- package/dist/store/reconcile.d.cts +2 -34
- package/dist/store/reconcile.d.mts +2 -34
- package/dist/store/reconcile.mjs +1 -2
- package/dist/store/reducer.cjs +1 -3
- package/dist/store/reducer.d.cts +2 -72
- package/dist/store/reducer.d.mts +2 -72
- package/dist/store/reducer.mjs +1 -3
- package/dist/store/taskGraph.cjs +1 -2
- package/dist/store/taskGraph.d.cts +2 -25
- package/dist/store/taskGraph.d.mts +2 -25
- package/dist/store/taskGraph.mjs +1 -2
- package/dist/store/taskStore.cjs +1 -2
- package/dist/store/taskStore.d.cts +2 -77
- package/dist/store/taskStore.d.mts +2 -77
- package/dist/store/taskStore.mjs +1 -2
- package/dist/store/types.cjs +1 -2
- package/dist/store/types.d.cts +2 -165
- package/dist/store/types.d.mts +2 -165
- package/dist/store/types.mjs +1 -2
- package/dist/tool/promptGuidelines.cjs +1 -2
- package/dist/tool/promptGuidelines.d.cts +2 -5
- package/dist/tool/promptGuidelines.d.mts +2 -5
- package/dist/tool/promptGuidelines.mjs +1 -2
- package/dist/tool/responseEnvelope.cjs +1 -6
- package/dist/tool/responseEnvelope.d.cts +2 -39
- package/dist/tool/responseEnvelope.d.mts +2 -39
- package/dist/tool/responseEnvelope.mjs +1 -6
- package/dist/tool/schema.cjs +1 -2
- package/dist/tool/schema.d.cts +2 -86
- package/dist/tool/schema.d.mts +2 -86
- package/dist/tool/schema.mjs +1 -2
- package/dist/tool/taskTool.cjs +1 -3
- package/dist/tool/taskTool.d.cts +3 -17
- package/dist/tool/taskTool.d.mts +3 -17
- package/dist/tool/taskTool.mjs +1 -3
- package/dist/tui/format.cjs +1 -4
- package/dist/tui/format.d.cts +5 -5
- package/dist/tui/format.d.cts.map +1 -1
- package/dist/tui/format.d.mts +5 -5
- package/dist/tui/format.d.mts.map +1 -1
- package/dist/tui/format.mjs +1 -4
- package/dist/tui/format2.cjs +4 -0
- package/dist/tui/format2.cjs.map +1 -0
- package/dist/tui/format2.d.cts +2 -0
- package/dist/tui/format2.d.mts +2 -0
- package/dist/tui/format2.mjs +4 -0
- package/dist/tui/format2.mjs.map +1 -0
- package/dist/tui/selectors.cjs +1 -2
- package/dist/tui/selectors.d.cts +8 -1
- package/dist/tui/selectors.d.cts.map +1 -1
- package/dist/tui/selectors.d.mts +8 -1
- package/dist/tui/selectors.d.mts.map +1 -1
- package/dist/tui/selectors.mjs +1 -2
- package/dist/tui/selectors2.cjs +2 -0
- package/dist/tui/selectors2.cjs.map +1 -0
- package/dist/tui/selectors2.d.cts +2 -0
- package/dist/tui/selectors2.d.mts +2 -0
- package/dist/tui/selectors2.mjs +2 -0
- package/dist/tui/selectors2.mjs.map +1 -0
- package/dist/tui/taskOverlay.cjs +1 -2
- package/dist/tui/taskOverlay.d.cts +2 -2
- package/dist/tui/taskOverlay.d.cts.map +1 -1
- package/dist/tui/taskOverlay.d.mts +2 -2
- package/dist/tui/taskOverlay.d.mts.map +1 -1
- package/dist/tui/taskOverlay.mjs +1 -2
- package/dist/tui/taskOverlay2.cjs +2 -0
- package/dist/tui/taskOverlay2.cjs.map +1 -0
- package/dist/tui/taskOverlay2.d.cts +2 -0
- package/dist/tui/taskOverlay2.d.mts +2 -0
- package/dist/tui/taskOverlay2.mjs +2 -0
- package/dist/tui/taskOverlay2.mjs.map +1 -0
- package/dist/tui/taskSpace.cjs +1 -5
- package/dist/tui/taskSpace.d.cts +4 -4
- package/dist/tui/taskSpace.d.cts.map +1 -1
- package/dist/tui/taskSpace.d.mts +4 -4
- package/dist/tui/taskSpace.d.mts.map +1 -1
- package/dist/tui/taskSpace.mjs +1 -5
- package/dist/tui/taskSpace2.cjs +5 -0
- package/dist/tui/taskSpace2.cjs.map +1 -0
- package/dist/tui/taskSpace2.d.cts +2 -0
- package/dist/tui/taskSpace2.d.mts +2 -0
- package/dist/tui/taskSpace2.mjs +5 -0
- package/dist/tui/taskSpace2.mjs.map +1 -0
- package/dist/types/config.cjs +2 -0
- package/dist/types/config.cjs.map +1 -0
- package/dist/types/config.d.cts +43 -0
- package/dist/types/config.d.cts.map +1 -0
- package/dist/types/config.d.mts +43 -0
- package/dist/types/config.d.mts.map +1 -0
- package/dist/types/config.mjs +2 -0
- package/dist/types/config.mjs.map +1 -0
- package/dist/types/delegation.cjs +2 -0
- package/dist/types/delegation.cjs.map +1 -0
- package/dist/types/delegation.d.cts +6 -0
- package/dist/types/delegation.d.cts.map +1 -0
- package/dist/types/delegation.d.mts +6 -0
- package/dist/types/delegation.d.mts.map +1 -0
- package/dist/types/delegation.mjs +2 -0
- package/dist/types/delegation.mjs.map +1 -0
- package/dist/types/telemetry.cjs +2 -0
- package/dist/types/telemetry.cjs.map +1 -0
- package/dist/types/telemetry.d.cts +35 -0
- package/dist/types/telemetry.d.cts.map +1 -0
- package/dist/types/telemetry.d.mts +35 -0
- package/dist/types/telemetry.d.mts.map +1 -0
- package/dist/types/telemetry.mjs +2 -0
- package/dist/types/telemetry.mjs.map +1 -0
- package/dist/types/webTasks.cjs +2 -0
- package/dist/types/webTasks.cjs.map +1 -0
- package/dist/types/webTasks.mjs +2 -0
- package/dist/types/webTasks.mjs.map +1 -0
- package/dist/webHub.cjs +1 -0
- package/dist/webHub.d.cts +2 -0
- package/dist/webHub.d.mts +2 -0
- package/dist/webHub.mjs +1 -0
- package/package.json +60 -20
- package/src/types/webTasks.ts +24 -0
- package/web/TaskToolMessage.tsx +119 -0
- package/web/TasksActivitySection.tsx +207 -0
- package/web/index.ts +15 -0
- package/web/taskToolFormat.ts +330 -0
- package/web/tasksStore.ts +72 -0
- package/web/tsconfig.json +23 -0
- package/dist/commands.cjs.map +0 -1
- package/dist/commands.d.cts.map +0 -1
- package/dist/commands.d.mts.map +0 -1
- package/dist/commands.mjs.map +0 -1
- package/dist/config.cjs.map +0 -1
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.mts.map +0 -1
- package/dist/config.mjs.map +0 -1
- package/dist/delegation/manager.cjs.map +0 -1
- package/dist/delegation/manager.d.cts.map +0 -1
- package/dist/delegation/manager.d.mts.map +0 -1
- package/dist/delegation/manager.mjs.map +0 -1
- package/dist/extension.cjs.map +0 -1
- package/dist/extension.d.cts.map +0 -1
- package/dist/extension.d.mts.map +0 -1
- package/dist/extension.mjs.map +0 -1
- package/dist/extensions/doom.cjs +0 -2
- package/dist/extensions/doom.cjs.map +0 -1
- package/dist/extensions/doom.d.cts +0 -6
- package/dist/extensions/doom.d.cts.map +0 -1
- package/dist/extensions/doom.d.mts +0 -7
- package/dist/extensions/doom.d.mts.map +0 -1
- package/dist/extensions/doom.mjs +0 -2
- package/dist/extensions/doom.mjs.map +0 -1
- package/dist/extensions/pi.cjs.map +0 -1
- package/dist/extensions/pi.mjs.map +0 -1
- package/dist/logSinkTelemetry.cjs.map +0 -1
- package/dist/logSinkTelemetry.d.cts.map +0 -1
- package/dist/logSinkTelemetry.d.mts.map +0 -1
- package/dist/logSinkTelemetry.mjs.map +0 -1
- package/dist/store/invariants.cjs.map +0 -1
- package/dist/store/invariants.d.cts.map +0 -1
- package/dist/store/invariants.d.mts.map +0 -1
- package/dist/store/invariants.mjs.map +0 -1
- package/dist/store/paths.cjs.map +0 -1
- package/dist/store/paths.d.cts.map +0 -1
- package/dist/store/paths.d.mts.map +0 -1
- package/dist/store/paths.mjs.map +0 -1
- package/dist/store/processLiveness.cjs.map +0 -1
- package/dist/store/processLiveness.d.cts.map +0 -1
- package/dist/store/processLiveness.d.mts.map +0 -1
- package/dist/store/processLiveness.mjs.map +0 -1
- package/dist/store/reconcile.cjs.map +0 -1
- package/dist/store/reconcile.d.cts.map +0 -1
- package/dist/store/reconcile.d.mts.map +0 -1
- package/dist/store/reconcile.mjs.map +0 -1
- package/dist/store/reducer.cjs.map +0 -1
- package/dist/store/reducer.d.cts.map +0 -1
- package/dist/store/reducer.d.mts.map +0 -1
- package/dist/store/reducer.mjs.map +0 -1
- package/dist/store/taskGraph.cjs.map +0 -1
- package/dist/store/taskGraph.d.cts.map +0 -1
- package/dist/store/taskGraph.d.mts.map +0 -1
- package/dist/store/taskGraph.mjs.map +0 -1
- package/dist/store/taskStore.cjs.map +0 -1
- package/dist/store/taskStore.d.cts.map +0 -1
- package/dist/store/taskStore.d.mts.map +0 -1
- package/dist/store/taskStore.mjs.map +0 -1
- package/dist/store/types.cjs.map +0 -1
- package/dist/store/types.d.cts.map +0 -1
- package/dist/store/types.d.mts.map +0 -1
- package/dist/store/types.mjs.map +0 -1
- package/dist/tool/promptGuidelines.cjs.map +0 -1
- package/dist/tool/promptGuidelines.d.cts.map +0 -1
- package/dist/tool/promptGuidelines.d.mts.map +0 -1
- package/dist/tool/promptGuidelines.mjs.map +0 -1
- package/dist/tool/responseEnvelope.cjs.map +0 -1
- package/dist/tool/responseEnvelope.d.cts.map +0 -1
- package/dist/tool/responseEnvelope.d.mts.map +0 -1
- package/dist/tool/responseEnvelope.mjs.map +0 -1
- package/dist/tool/schema.cjs.map +0 -1
- package/dist/tool/schema.d.cts.map +0 -1
- package/dist/tool/schema.d.mts.map +0 -1
- package/dist/tool/schema.mjs.map +0 -1
- package/dist/tool/taskTool.cjs.map +0 -1
- package/dist/tool/taskTool.d.cts.map +0 -1
- package/dist/tool/taskTool.d.mts.map +0 -1
- package/dist/tool/taskTool.mjs.map +0 -1
- package/dist/tui/format.cjs.map +0 -1
- package/dist/tui/format.mjs.map +0 -1
- package/dist/tui/selectors.cjs.map +0 -1
- package/dist/tui/selectors.mjs.map +0 -1
- package/dist/tui/taskOverlay.cjs.map +0 -1
- package/dist/tui/taskOverlay.mjs.map +0 -1
- package/dist/tui/taskSpace.cjs.map +0 -1
- package/dist/tui/taskSpace.mjs.map +0 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { TaskDocument } from "../../services/store/types.cjs";
|
|
2
|
+
import { TaskFailureReporter } from "../../types/telemetry.cjs";
|
|
3
|
+
//#region src/adapters/store/taskStore.d.ts
|
|
4
|
+
type TaskStoreCommitListener = (previous: TaskDocument, committed: TaskDocument) => void;
|
|
5
|
+
interface TaskStoreOptions {
|
|
6
|
+
cwd?: string;
|
|
7
|
+
env?: NodeJS.ProcessEnv;
|
|
8
|
+
storePath?: string;
|
|
9
|
+
onCommitted?: TaskStoreCommitListener;
|
|
10
|
+
/** Backstop poll cadence for change detection. Lowered in tests so they do
|
|
11
|
+
* not depend on `fs.watch`, whose delivery timing is platform-dependent. */
|
|
12
|
+
pollIntervalMs?: number;
|
|
13
|
+
/** How long to wait for the advisory lock before proceeding lock-free. */
|
|
14
|
+
lockTimeoutMs?: number;
|
|
15
|
+
/** Where swallowed failures go, so silent degradation stays visible. */
|
|
16
|
+
report?: TaskFailureReporter;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* File-backed task store shared by one root session and its delegated children.
|
|
20
|
+
*
|
|
21
|
+
* Durability model: the JSON file is the source of truth. Mutations are
|
|
22
|
+
* read-modify-write under an advisory lock so concurrent delegated processes
|
|
23
|
+
* cannot clobber each other, and writes land via temp-file rename so a
|
|
24
|
+
* crash mid-write can never leave a partial document behind.
|
|
25
|
+
*/
|
|
26
|
+
declare class TaskStore {
|
|
27
|
+
storePath: string;
|
|
28
|
+
private readonly cwd;
|
|
29
|
+
private readonly env;
|
|
30
|
+
private cached;
|
|
31
|
+
private lastKnownRev;
|
|
32
|
+
private watcher?;
|
|
33
|
+
private pollTimer?;
|
|
34
|
+
private debounceTimer?;
|
|
35
|
+
private checkInFlight?;
|
|
36
|
+
private checkQueued;
|
|
37
|
+
private watchGeneration;
|
|
38
|
+
private readonly listeners;
|
|
39
|
+
private readonly pollIntervalMs;
|
|
40
|
+
private readonly lockTimeoutMs;
|
|
41
|
+
private readonly report?;
|
|
42
|
+
private readonly onCommitted?;
|
|
43
|
+
constructor(options?: TaskStoreOptions);
|
|
44
|
+
/** Bind a default store to the current session tree before reading or watching it. */
|
|
45
|
+
configureSession(sessionKey: string): void;
|
|
46
|
+
/** Last document read from disk, without hitting the filesystem. */
|
|
47
|
+
get snapshot(): TaskDocument;
|
|
48
|
+
read(): TaskDocument;
|
|
49
|
+
readAsync(shouldApply?: () => boolean): Promise<TaskDocument>;
|
|
50
|
+
private readDocumentAsync;
|
|
51
|
+
/**
|
|
52
|
+
* Apply a mutation under the store lock.
|
|
53
|
+
*
|
|
54
|
+
* `mutate` receives the freshest on-disk document and returns either the next
|
|
55
|
+
* document to commit or `undefined` for a read-only action (list/get), which
|
|
56
|
+
* skips the write entirely so queries never bump `rev`.
|
|
57
|
+
*/
|
|
58
|
+
mutate<T>(mutate: (document: TaskDocument) => {
|
|
59
|
+
document?: TaskDocument;
|
|
60
|
+
value: T;
|
|
61
|
+
}): Promise<{
|
|
62
|
+
document: TaskDocument;
|
|
63
|
+
value: T;
|
|
64
|
+
}>;
|
|
65
|
+
private notifyCommitted;
|
|
66
|
+
private write;
|
|
67
|
+
private acquireLock;
|
|
68
|
+
/** Remove a lock left behind by a dead process or one held implausibly long. */
|
|
69
|
+
private breakStaleLock;
|
|
70
|
+
/**
|
|
71
|
+
* Notify when another process changes the store.
|
|
72
|
+
*
|
|
73
|
+
* `fs.watch` alone is unreliable across the rename-based write (and on some
|
|
74
|
+
* network filesystems), so a slow poll backs it up. Writes made by this
|
|
75
|
+
* process are filtered out by revision so the UI does not redraw twice.
|
|
76
|
+
*/
|
|
77
|
+
onExternalChange(listener: (document: TaskDocument) => void): () => void;
|
|
78
|
+
private startWatching;
|
|
79
|
+
private scheduleCheck;
|
|
80
|
+
private queueChangeCheck;
|
|
81
|
+
private checkForChange;
|
|
82
|
+
private stopWatching;
|
|
83
|
+
dispose(): void;
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { TaskStore, TaskStoreCommitListener, TaskStoreOptions };
|
|
87
|
+
//# sourceMappingURL=taskStore.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskStore.d.cts","names":[],"sources":["../../../src/adapters/store/taskStore.ts"],"mappings":";;;KAmBY,2BAA2B,UAAU,cAAc,WAAW;UAEzD;EACf;EACA,MAAM,OAAO;EACb;EACA,cAAc;;;EAGd;;EAEA;;EAEA,SAAS;;;;;;;;;;cAwCE;EACX;mBAEiB;mBACA;UACT;UACA;UACA;UACA;UACA;UACA;UACA;UACA;mBACS;mBACA;mBACA;mBACA;mBACA;EAEjB,YAAY,UAAS;;EAWrB,iBAAiB;;MASb,YAAY;EAIhB,QAAQ;EAiBF,UAAU,8BAA0C,QAAQ;UASpD;;;;;;;;EAmBR,OAAO,GACX,SAAS,UAAU;IAAmB,WAAW;IAAc,OAAO;MACrE;IAAU,UAAU;IAAc,OAAO;;UAwBpC;UAQA;UAWM;;UAoCN;;;;;;;;EAyBR,iBAAiB,WAAW,UAAU;UAS9B;UAqBA;UAMA;UAiBM;UAuBN;EAWR"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { TaskDocument } from "../../services/store/types.mjs";
|
|
2
|
+
import { TaskFailureReporter } from "../../types/telemetry.mjs";
|
|
3
|
+
//#region src/adapters/store/taskStore.d.ts
|
|
4
|
+
type TaskStoreCommitListener = (previous: TaskDocument, committed: TaskDocument) => void;
|
|
5
|
+
interface TaskStoreOptions {
|
|
6
|
+
cwd?: string;
|
|
7
|
+
env?: NodeJS.ProcessEnv;
|
|
8
|
+
storePath?: string;
|
|
9
|
+
onCommitted?: TaskStoreCommitListener;
|
|
10
|
+
/** Backstop poll cadence for change detection. Lowered in tests so they do
|
|
11
|
+
* not depend on `fs.watch`, whose delivery timing is platform-dependent. */
|
|
12
|
+
pollIntervalMs?: number;
|
|
13
|
+
/** How long to wait for the advisory lock before proceeding lock-free. */
|
|
14
|
+
lockTimeoutMs?: number;
|
|
15
|
+
/** Where swallowed failures go, so silent degradation stays visible. */
|
|
16
|
+
report?: TaskFailureReporter;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* File-backed task store shared by one root session and its delegated children.
|
|
20
|
+
*
|
|
21
|
+
* Durability model: the JSON file is the source of truth. Mutations are
|
|
22
|
+
* read-modify-write under an advisory lock so concurrent delegated processes
|
|
23
|
+
* cannot clobber each other, and writes land via temp-file rename so a
|
|
24
|
+
* crash mid-write can never leave a partial document behind.
|
|
25
|
+
*/
|
|
26
|
+
declare class TaskStore {
|
|
27
|
+
storePath: string;
|
|
28
|
+
private readonly cwd;
|
|
29
|
+
private readonly env;
|
|
30
|
+
private cached;
|
|
31
|
+
private lastKnownRev;
|
|
32
|
+
private watcher?;
|
|
33
|
+
private pollTimer?;
|
|
34
|
+
private debounceTimer?;
|
|
35
|
+
private checkInFlight?;
|
|
36
|
+
private checkQueued;
|
|
37
|
+
private watchGeneration;
|
|
38
|
+
private readonly listeners;
|
|
39
|
+
private readonly pollIntervalMs;
|
|
40
|
+
private readonly lockTimeoutMs;
|
|
41
|
+
private readonly report?;
|
|
42
|
+
private readonly onCommitted?;
|
|
43
|
+
constructor(options?: TaskStoreOptions);
|
|
44
|
+
/** Bind a default store to the current session tree before reading or watching it. */
|
|
45
|
+
configureSession(sessionKey: string): void;
|
|
46
|
+
/** Last document read from disk, without hitting the filesystem. */
|
|
47
|
+
get snapshot(): TaskDocument;
|
|
48
|
+
read(): TaskDocument;
|
|
49
|
+
readAsync(shouldApply?: () => boolean): Promise<TaskDocument>;
|
|
50
|
+
private readDocumentAsync;
|
|
51
|
+
/**
|
|
52
|
+
* Apply a mutation under the store lock.
|
|
53
|
+
*
|
|
54
|
+
* `mutate` receives the freshest on-disk document and returns either the next
|
|
55
|
+
* document to commit or `undefined` for a read-only action (list/get), which
|
|
56
|
+
* skips the write entirely so queries never bump `rev`.
|
|
57
|
+
*/
|
|
58
|
+
mutate<T>(mutate: (document: TaskDocument) => {
|
|
59
|
+
document?: TaskDocument;
|
|
60
|
+
value: T;
|
|
61
|
+
}): Promise<{
|
|
62
|
+
document: TaskDocument;
|
|
63
|
+
value: T;
|
|
64
|
+
}>;
|
|
65
|
+
private notifyCommitted;
|
|
66
|
+
private write;
|
|
67
|
+
private acquireLock;
|
|
68
|
+
/** Remove a lock left behind by a dead process or one held implausibly long. */
|
|
69
|
+
private breakStaleLock;
|
|
70
|
+
/**
|
|
71
|
+
* Notify when another process changes the store.
|
|
72
|
+
*
|
|
73
|
+
* `fs.watch` alone is unreliable across the rename-based write (and on some
|
|
74
|
+
* network filesystems), so a slow poll backs it up. Writes made by this
|
|
75
|
+
* process are filtered out by revision so the UI does not redraw twice.
|
|
76
|
+
*/
|
|
77
|
+
onExternalChange(listener: (document: TaskDocument) => void): () => void;
|
|
78
|
+
private startWatching;
|
|
79
|
+
private scheduleCheck;
|
|
80
|
+
private queueChangeCheck;
|
|
81
|
+
private checkForChange;
|
|
82
|
+
private stopWatching;
|
|
83
|
+
dispose(): void;
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { TaskStore, TaskStoreCommitListener, TaskStoreOptions };
|
|
87
|
+
//# sourceMappingURL=taskStore.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskStore.d.mts","names":[],"sources":["../../../src/adapters/store/taskStore.ts"],"mappings":";;;KAmBY,2BAA2B,UAAU,cAAc,WAAW;UAEzD;EACf;EACA,MAAM,OAAO;EACb;EACA,cAAc;;;EAGd;;EAEA;;EAEA,SAAS;;;;;;;;;;cAwCE;EACX;mBAEiB;mBACA;UACT;UACA;UACA;UACA;UACA;UACA;UACA;UACA;mBACS;mBACA;mBACA;mBACA;mBACA;EAEjB,YAAY,UAAS;;EAWrB,iBAAiB;;MASb,YAAY;EAIhB,QAAQ;EAiBF,UAAU,8BAA0C,QAAQ;UASpD;;;;;;;;EAmBR,OAAO,GACX,SAAS,UAAU;IAAmB,WAAW;IAAc,OAAO;MACrE;IAAU,UAAU;IAAc,OAAO;;UAwBpC;UAQA;UAWM;;UAoCN;;;;;;;;EAyBR,iBAAiB,WAAW,UAAU;UAS9B;UAqBA;UAMA;UAiBM;UAuBN;EAWR"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{canonicalizeTasks as e}from"../../services/store/invariants.mjs";import{emptyDocument as t}from"../../services/store/types.mjs";import{TASK_EVENT as n}from"../../types/telemetry.mjs";import{isProcessAlive as r}from"../../services/store/processLiveness.mjs";import{lockPathFor as i,resolveStorePath as a,tempPathFor as o}from"./paths.mjs";import s from"node:fs";import c from"node:path";const l=`utf8`,u=`ENOENT`,d=`store.path`;function f(e){return new Promise(t=>setTimeout(t,e))}function p(n){if(!n||typeof n!=`object`)return t();let r=n;if(!Array.isArray(r.tasks))return t();let i=e(r.tasks.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`number`)),a=i.reduce((e,t)=>Math.max(e,t.id),0);return{version:typeof r.version==`number`?r.version:1,rev:typeof r.rev==`number`?r.rev:0,nextId:typeof r.nextId==`number`&&r.nextId>a?r.nextId:a+1,tasks:i}}var m=class{storePath;cwd;env;cached=t();lastKnownRev=-1;watcher;pollTimer;debounceTimer;checkInFlight;checkQueued=!1;watchGeneration=0;listeners=new Set;pollIntervalMs;lockTimeoutMs;report;onCommitted;constructor(e={}){this.cwd=e.cwd??process.cwd(),this.env=e.env??process.env,this.storePath=e.storePath??a(this.cwd,this.env),this.pollIntervalMs=e.pollIntervalMs??2e3,this.lockTimeoutMs=e.lockTimeoutMs??2e3,this.report=e.report,this.onCommitted=e.onCommitted}configureSession(e){this.env.DOOM_TASK_STORE?.trim()||(this.stopWatching(),this.storePath=a(this.cwd,this.env,e),this.cached=t(),this.lastKnownRev=-1)}get snapshot(){return this.cached}read(){try{let e=s.readFileSync(this.storePath,l);this.cached=p(JSON.parse(e))}catch(e){e.code!==u&&this.report?.error(n.storeReadFailed,e,{[d]:this.storePath}),this.cached=t()}return this.lastKnownRev=this.cached.rev,this.cached}async readAsync(e=()=>!0){let t=this.storePath,n=await this.readDocumentAsync(t);return e()?(this.cached=n,this.lastKnownRev=n.rev,n):n}async readDocumentAsync(e=this.storePath){try{let t=await s.promises.readFile(e,l);return p(JSON.parse(t))}catch(r){return r.code!==u&&this.report?.error(n.storeReadFailed,r,{[d]:e}),t()}}async mutate(e){let t=await this.acquireLock(),n=(()=>{try{let t=this.read(),n=e(t);if(!n.document)return{result:{document:t,value:n.value}};let r=this.write(n.document);return{result:{document:r,value:n.value},notification:{previous:t,committed:r}}}finally{t()}})();return n.notification&&this.notifyCommitted(n.notification.previous,n.notification.committed),n.result}notifyCommitted(e,t){try{this.onCommitted?.(e,t)}catch(e){this.report?.error(n.storeCommitListenerFailed,e,{[d]:this.storePath})}}write(e){let t={...e,version:1,rev:e.rev+1};s.mkdirSync(c.dirname(this.storePath),{recursive:!0});let n=o(this.storePath);return s.writeFileSync(n,`${JSON.stringify(t,void 0,2)}\n`,l),s.renameSync(n,this.storePath),this.cached=t,this.lastKnownRev=t.rev,t}async acquireLock(){let e=i(this.storePath);s.mkdirSync(c.dirname(this.storePath),{recursive:!0});let t=Date.now()+this.lockTimeoutMs;for(;;)try{let t=s.openSync(e,`wx`);return s.writeSync(t,JSON.stringify({pid:process.pid,time:Date.now()})),s.closeSync(t),()=>s.rmSync(e,{force:!0})}catch(r){if(r.code!==`EEXIST`)throw r;if(Date.now()>=t)return this.report?.warn(n.storeLockTimeout,Error(`Task store lock still held after ${this.lockTimeoutMs}ms; proceeding without it`),{[d]:this.storePath}),()=>{};this.breakStaleLock(e),await f(10+Math.random()*60)}}breakStaleLock(e){try{let t=JSON.parse(s.readFileSync(e,l)),n=typeof t.time==`number`&&Date.now()-t.time>1e4,i=typeof t.pid==`number`&&!r(t.pid);return!n&&!i?!1:(s.unlinkSync(e),!0)}catch(t){return t.code!==u&&this.report?.warn(n.storeLockBreakFailed,t,{[d]:e}),!1}}onExternalChange(e){return this.listeners.add(e),this.startWatching(),()=>{this.listeners.delete(e),this.listeners.size===0&&this.stopWatching()}}startWatching(){if(this.watcher||this.pollTimer)return;this.watchGeneration+=1;let e=c.dirname(this.storePath),t=c.basename(this.storePath);try{s.mkdirSync(e,{recursive:!0}),this.watcher=s.watch(e,(e,n)=>{n&&n!==t||this.scheduleCheck()})}catch(e){this.report?.warn(n.storeWatchFailed,e,{[d]:this.storePath})}this.pollTimer=setInterval(()=>this.queueChangeCheck(),this.pollIntervalMs),this.pollTimer.unref?.()}scheduleCheck(){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>this.queueChangeCheck(),150),this.debounceTimer.unref?.()}queueChangeCheck(){if(this.checkInFlight){this.checkQueued=!0;return}let e=this.watchGeneration,t=(async()=>{do this.checkQueued=!1,await this.checkForChange(e);while(this.checkQueued&&e===this.watchGeneration)})().finally(()=>{this.checkInFlight===t&&(this.checkInFlight=void 0)});this.checkInFlight=t}async checkForChange(e){let t=this.lastKnownRev,r=await this.readDocumentAsync();if(e===this.watchGeneration){if(this.lastKnownRev!==t){this.checkQueued=!0;return}if(this.cached=r,this.lastKnownRev=r.rev,r.rev!==t)for(let e of this.listeners)try{e(r)}catch(e){this.report?.error(n.storeListenerFailed,e,{[d]:this.storePath})}}}stopWatching(){this.watchGeneration+=1,this.checkQueued=!1,this.watcher?.close(),this.watcher=void 0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=void 0,clearTimeout(this.debounceTimer),this.debounceTimer=void 0}dispose(){this.listeners.clear(),this.stopWatching()}};export{m as TaskStore};
|
|
2
|
+
//# sourceMappingURL=taskStore.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskStore.mjs","names":[],"sources":["../../../src/adapters/store/taskStore.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { canonicalizeTasks } from '../../services/store/invariants.ts';\nimport { isProcessAlive } from '../../services/store/processLiveness.ts';\nimport { emptyDocument, STORE_SCHEMA_VERSION, type Task, type TaskDocument } from '../../services/store/types.ts';\nimport { TASK_EVENT, type TaskFailureReporter } from '../../types/telemetry.ts';\nimport { lockPathFor, resolveStorePath, STORE_PATH_ENV, tempPathFor } from './paths.ts';\n\nconst LOCK_TIMEOUT_MS = 2000;\nconst LOCK_STALE_MS = 10_000;\nconst LOCK_RETRY_BASE_MS = 10;\nconst LOCK_RETRY_MAX_MS = 60;\nconst WATCH_DEBOUNCE_MS = 150;\nconst POLL_INTERVAL_MS = 2000;\nconst UTF8_ENCODING = 'utf8';\nconst MISSING_FILE_CODE = 'ENOENT';\nconst LOCK_EXISTS_CODE = 'EEXIST';\nconst STORE_PATH_ATTRIBUTE = 'store.path';\n\nexport type TaskStoreCommitListener = (previous: TaskDocument, committed: TaskDocument) => void;\n\nexport interface TaskStoreOptions {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n storePath?: string;\n onCommitted?: TaskStoreCommitListener;\n /** Backstop poll cadence for change detection. Lowered in tests so they do\n * not depend on `fs.watch`, whose delivery timing is platform-dependent. */\n pollIntervalMs?: number;\n /** How long to wait for the advisory lock before proceeding lock-free. */\n lockTimeoutMs?: number;\n /** Where swallowed failures go, so silent degradation stays visible. */\n report?: TaskFailureReporter;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Coerce arbitrary parsed JSON into a valid document.\n *\n * A corrupt or truncated store must not take the session down: the worst\n * acceptable outcome is starting from an empty list, never a crash on startup.\n */\nfunction normalizeDocument(parsed: unknown): TaskDocument {\n if (!parsed || typeof parsed !== 'object') return emptyDocument();\n const candidate = parsed as Partial<TaskDocument>;\n if (!Array.isArray(candidate.tasks)) return emptyDocument();\n\n const tasks = canonicalizeTasks(\n candidate.tasks.filter(\n (task): task is Task => Boolean(task) && typeof task === 'object' && typeof (task as Task).id === 'number',\n ),\n );\n const maxId = tasks.reduce((max, task) => Math.max(max, task.id), 0);\n return {\n version: typeof candidate.version === 'number' ? candidate.version : STORE_SCHEMA_VERSION,\n rev: typeof candidate.rev === 'number' ? candidate.rev : 0,\n nextId: typeof candidate.nextId === 'number' && candidate.nextId > maxId ? candidate.nextId : maxId + 1,\n tasks,\n };\n}\n\n/**\n * File-backed task store shared by one root session and its delegated children.\n *\n * Durability model: the JSON file is the source of truth. Mutations are\n * read-modify-write under an advisory lock so concurrent delegated processes\n * cannot clobber each other, and writes land via temp-file rename so a\n * crash mid-write can never leave a partial document behind.\n */\nexport class TaskStore {\n storePath: string;\n\n private readonly cwd: string;\n private readonly env: NodeJS.ProcessEnv;\n private cached: TaskDocument = emptyDocument();\n private lastKnownRev = -1;\n private watcher?: fs.FSWatcher;\n private pollTimer?: NodeJS.Timeout;\n private debounceTimer?: NodeJS.Timeout;\n private checkInFlight?: Promise<void>;\n private checkQueued = false;\n private watchGeneration = 0;\n private readonly listeners = new Set<(document: TaskDocument) => void>();\n private readonly pollIntervalMs: number;\n private readonly lockTimeoutMs: number;\n private readonly report?: TaskFailureReporter;\n private readonly onCommitted?: TaskStoreCommitListener;\n\n constructor(options: TaskStoreOptions = {}) {\n this.cwd = options.cwd ?? process.cwd();\n this.env = options.env ?? process.env;\n this.storePath = options.storePath ?? resolveStorePath(this.cwd, this.env);\n this.pollIntervalMs = options.pollIntervalMs ?? POLL_INTERVAL_MS;\n this.lockTimeoutMs = options.lockTimeoutMs ?? LOCK_TIMEOUT_MS;\n this.report = options.report;\n this.onCommitted = options.onCommitted;\n }\n\n /** Bind a default store to the current session tree before reading or watching it. */\n configureSession(sessionKey: string): void {\n if (this.env[STORE_PATH_ENV]?.trim()) return;\n this.stopWatching();\n this.storePath = resolveStorePath(this.cwd, this.env, sessionKey);\n this.cached = emptyDocument();\n this.lastKnownRev = -1;\n }\n\n /** Last document read from disk, without hitting the filesystem. */\n get snapshot(): TaskDocument {\n return this.cached;\n }\n\n read(): TaskDocument {\n try {\n const raw = fs.readFileSync(this.storePath, UTF8_ENCODING);\n this.cached = normalizeDocument(JSON.parse(raw));\n } catch (error) {\n // A missing file is the normal state before the first write. Anything\n // else means the task list just silently became empty, which is worth a\n // record: unreadable or corrupt JSON looks identical to \"no tasks yet\".\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.error(TASK_EVENT.storeReadFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n this.cached = emptyDocument();\n }\n this.lastKnownRev = this.cached.rev;\n return this.cached;\n }\n\n async readAsync(shouldApply: () => boolean = () => true): Promise<TaskDocument> {\n const storePath = this.storePath;\n const document = await this.readDocumentAsync(storePath);\n if (!shouldApply()) return document;\n this.cached = document;\n this.lastKnownRev = document.rev;\n return document;\n }\n\n private async readDocumentAsync(storePath: string = this.storePath): Promise<TaskDocument> {\n try {\n const raw = await fs.promises.readFile(storePath, UTF8_ENCODING);\n return normalizeDocument(JSON.parse(raw));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.error(TASK_EVENT.storeReadFailed, error, { [STORE_PATH_ATTRIBUTE]: storePath });\n }\n return emptyDocument();\n }\n }\n\n /**\n * Apply a mutation under the store lock.\n *\n * `mutate` receives the freshest on-disk document and returns either the next\n * document to commit or `undefined` for a read-only action (list/get), which\n * skips the write entirely so queries never bump `rev`.\n */\n async mutate<T>(\n mutate: (document: TaskDocument) => { document?: TaskDocument; value: T },\n ): Promise<{ document: TaskDocument; value: T }> {\n const release = await this.acquireLock();\n const outcome = (() => {\n try {\n const current = this.read();\n const mutation = mutate(current);\n if (!mutation.document) {\n return { result: { document: current, value: mutation.value } };\n }\n const committed = this.write(mutation.document);\n return {\n result: { document: committed, value: mutation.value },\n notification: { previous: current, committed },\n };\n } finally {\n release();\n }\n })();\n if (outcome.notification) {\n this.notifyCommitted(outcome.notification.previous, outcome.notification.committed);\n }\n return outcome.result;\n }\n\n private notifyCommitted(previous: TaskDocument, committed: TaskDocument): void {\n try {\n this.onCommitted?.(previous, committed);\n } catch (error) {\n this.report?.error(TASK_EVENT.storeCommitListenerFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n }\n\n private write(document: TaskDocument): TaskDocument {\n const next: TaskDocument = { ...document, version: STORE_SCHEMA_VERSION, rev: document.rev + 1 };\n fs.mkdirSync(path.dirname(this.storePath), { recursive: true });\n const temp = tempPathFor(this.storePath);\n fs.writeFileSync(temp, `${JSON.stringify(next, undefined, 2)}\\n`, UTF8_ENCODING);\n fs.renameSync(temp, this.storePath);\n this.cached = next;\n this.lastKnownRev = next.rev;\n return next;\n }\n\n private async acquireLock(): Promise<() => void> {\n const lockPath = lockPathFor(this.storePath);\n fs.mkdirSync(path.dirname(this.storePath), { recursive: true });\n const deadline = Date.now() + this.lockTimeoutMs;\n\n for (;;) {\n try {\n const handle = fs.openSync(lockPath, 'wx');\n fs.writeSync(handle, JSON.stringify({ pid: process.pid, time: Date.now() }));\n fs.closeSync(handle);\n return () => fs.rmSync(lockPath, { force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== LOCK_EXISTS_CODE) throw error;\n // The deadline is checked before breaking a stale lock so a peer that\n // keeps recreating one cannot spin this loop without bound.\n if (Date.now() >= deadline) {\n // Proceeding lock-free beats stalling the agent: the rename is atomic,\n // so the worst case is a lost concurrent update, not a corrupt file.\n // Reported because a lost update here can strand a delegation.\n this.report?.warn(\n TASK_EVENT.storeLockTimeout,\n new Error(`Task store lock still held after ${this.lockTimeoutMs}ms; proceeding without it`),\n { [STORE_PATH_ATTRIBUTE]: this.storePath },\n );\n return () => {};\n }\n // Clearing a dead holder's lock still goes through the backoff. Yielding\n // on every iteration is what stops a peer that keeps recreating the\n // lock from turning this into a spin.\n this.breakStaleLock(lockPath);\n await sleep(LOCK_RETRY_BASE_MS + Math.random() * LOCK_RETRY_MAX_MS);\n }\n }\n }\n\n /** Remove a lock left behind by a dead process or one held implausibly long. */\n private breakStaleLock(lockPath: string): boolean {\n try {\n const holder = JSON.parse(fs.readFileSync(lockPath, UTF8_ENCODING)) as { pid?: number; time?: number };\n const expired = typeof holder.time === 'number' && Date.now() - holder.time > LOCK_STALE_MS;\n const dead = typeof holder.pid === 'number' && !isProcessAlive(holder.pid);\n if (!expired && !dead) return false;\n fs.unlinkSync(lockPath);\n return true;\n } catch (error) {\n // Losing the race to another breaker is normal; a persistent failure here\n // shows up as the lock timeout above, so this stays a warning.\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.warn(TASK_EVENT.storeLockBreakFailed, error, { [STORE_PATH_ATTRIBUTE]: lockPath });\n }\n return false;\n }\n }\n\n /**\n * Notify when another process changes the store.\n *\n * `fs.watch` alone is unreliable across the rename-based write (and on some\n * network filesystems), so a slow poll backs it up. Writes made by this\n * process are filtered out by revision so the UI does not redraw twice.\n */\n onExternalChange(listener: (document: TaskDocument) => void): () => void {\n this.listeners.add(listener);\n this.startWatching();\n return () => {\n this.listeners.delete(listener);\n if (this.listeners.size === 0) this.stopWatching();\n };\n }\n\n private startWatching(): void {\n if (this.watcher || this.pollTimer) return;\n this.watchGeneration += 1;\n const directory = path.dirname(this.storePath);\n const fileName = path.basename(this.storePath);\n\n try {\n fs.mkdirSync(directory, { recursive: true });\n this.watcher = fs.watch(directory, (_event, changed) => {\n if (changed && changed !== fileName) return;\n this.scheduleCheck();\n });\n } catch (error) {\n // Polling still covers change detection, just more slowly.\n this.report?.warn(TASK_EVENT.storeWatchFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n\n this.pollTimer = setInterval(() => this.queueChangeCheck(), this.pollIntervalMs);\n this.pollTimer.unref?.();\n }\n\n private scheduleCheck(): void {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = setTimeout(() => this.queueChangeCheck(), WATCH_DEBOUNCE_MS);\n this.debounceTimer.unref?.();\n }\n\n private queueChangeCheck(): void {\n if (this.checkInFlight) {\n this.checkQueued = true;\n return;\n }\n const generation = this.watchGeneration;\n const execution = (async () => {\n do {\n this.checkQueued = false;\n await this.checkForChange(generation);\n } while (this.checkQueued && generation === this.watchGeneration);\n })().finally(() => {\n if (this.checkInFlight === execution) this.checkInFlight = undefined;\n });\n this.checkInFlight = execution;\n }\n\n private async checkForChange(generation: number): Promise<void> {\n const previousRev = this.lastKnownRev;\n const document = await this.readDocumentAsync();\n if (generation !== this.watchGeneration) return;\n if (this.lastKnownRev !== previousRev) {\n this.checkQueued = true;\n return;\n }\n this.cached = document;\n this.lastKnownRev = document.rev;\n if (document.rev === previousRev) return;\n for (const listener of this.listeners) {\n try {\n listener(document);\n } catch (error) {\n // This runs from a timer and from the fs.watch callback, so an\n // unguarded listener throw is an uncaught exception that takes the\n // harness down rather than a handled render failure.\n this.report?.error(TASK_EVENT.storeListenerFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n }\n }\n\n private stopWatching(): void {\n this.watchGeneration += 1;\n this.checkQueued = false;\n this.watcher?.close();\n this.watcher = undefined;\n if (this.pollTimer) clearInterval(this.pollTimer);\n this.pollTimer = undefined;\n clearTimeout(this.debounceTimer);\n this.debounceTimer = undefined;\n }\n\n dispose(): void {\n this.listeners.clear();\n this.stopWatching();\n }\n}\n"],"mappings":"yYAQA,MAMM,EAAgB,OAChB,EAAoB,SAEpB,EAAuB,aAkB7B,SAAS,EAAM,EAA2B,CACxC,OAAO,IAAI,QAAS,GAAY,WAAW,EAAS,CAAE,CAAC,CACzD,CAQA,SAAS,EAAkB,EAA+B,CACxD,GAAI,CAAC,GAAU,OAAO,GAAW,SAAU,OAAO,EAAc,EAChE,IAAM,EAAY,EAClB,GAAI,CAAC,MAAM,QAAQ,EAAU,KAAK,EAAG,OAAO,EAAc,EAE1D,IAAM,EAAQ,EACZ,EAAU,MAAM,OACb,GAAuB,EAAQ,GAAS,OAAO,GAAS,UAAY,OAAQ,EAAc,IAAO,QACpG,CACF,EACM,EAAQ,EAAM,QAAQ,EAAK,IAAS,KAAK,IAAI,EAAK,EAAK,EAAE,EAAG,CAAC,EACnE,MAAO,CACL,QAAS,OAAO,EAAU,SAAY,SAAW,EAAU,QAAA,EAC3D,IAAK,OAAO,EAAU,KAAQ,SAAW,EAAU,IAAM,EACzD,OAAQ,OAAO,EAAU,QAAW,UAAY,EAAU,OAAS,EAAQ,EAAU,OAAS,EAAQ,EACtG,OACF,CACF,CAUA,IAAa,EAAb,KAAuB,CACrB,UAEA,IACA,IACA,OAA+B,EAAc,EAC7C,aAAuB,GACvB,QACA,UACA,cACA,cACA,YAAsB,GACtB,gBAA0B,EAC1B,UAA6B,IAAI,IACjC,eACA,cACA,OACA,YAEA,YAAY,EAA4B,CAAC,EAAG,CAC1C,KAAK,IAAM,EAAQ,KAAO,QAAQ,IAAI,EACtC,KAAK,IAAM,EAAQ,KAAO,QAAQ,IAClC,KAAK,UAAY,EAAQ,WAAa,EAAiB,KAAK,IAAK,KAAK,GAAG,EACzE,KAAK,eAAiB,EAAQ,gBAAkB,IAChD,KAAK,cAAgB,EAAQ,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AK,SAAS,EAChD,KAAK,UAAY,IAAA,GACjB,aAAa,KAAK,aAAa,EAC/B,KAAK,cAAgB,IAAA,EACvB,CAEA,SAAgB,CACd,KAAK,UAAU,MAAM,EACrB,KAAK,aAAa,CACpB,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../types/telemetry.cjs");let t=require("@agimon-ai/doompi-telemetry");function n(n={}){let r=(0,t.createDoomTelemetry)({serviceName:`doom-task`,packageName:`@agimon-ai/doompi-task`,cwd:n.cwd,workspaceRoot:n.workspaceRoot,env:n.env,telemetryFactory:n.telemetryFactory,warn:n.warn,enableLogs:!0,enableTraces:!0});return{recordError:(e,t,n)=>r.recordError(e,t,n),recordWarning:(e,t,n)=>r.recordWarning(e,t,n),recordEvent:(e,t)=>r.recordEvent(e,t),recordNotificationError:(t,n)=>r.recordError(e.TASK_EVENT.notificationFailed,t,{"task.id":n,"task.operation":`completion_notification`}),flush:()=>r.flush(),shutdown:()=>r.shutdown()}}function r(e){return{error:(t,n,r)=>void e.recordError(t,n,r),warn:(t,n,r)=>void e.recordWarning(t,n,r),event:(t,n)=>void e.recordEvent(t,n)}}exports.TASK_EVENT=e.TASK_EVENT,exports.createTaskErrorReporter=n,exports.toFailureReporter=r;
|
|
2
|
+
//# sourceMappingURL=logSinkTelemetry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry.cjs","names":["createDoomTelemetry","TASK_EVENT"],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\nimport { TASK_EVENT, type TaskErrorAttributes, type TaskFailureReporter } from '../../types/telemetry.ts';\n\nexport {\n TASK_EVENT,\n type TaskErrorAttributes,\n type TaskErrorSink,\n type TaskEventName,\n type TaskEventSink,\n type TaskFailureReporter,\n} from '../../types/telemetry.ts';\n\nconst SERVICE_NAME = 'doom-task';\nconst PACKAGE_NAME = '@agimon-ai/doompi-task';\nconst NOTIFICATION_OPERATION = 'completion_notification';\n\nexport interface TaskErrorReporterOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface TaskErrorReporter {\n recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;\n recordNotificationError(error: unknown, taskId: number): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createTaskErrorReporter(options: TaskErrorReporterOptions = {}): TaskErrorReporter {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n recordNotificationError: (error, taskId) =>\n telemetry.recordError(TASK_EVENT.notificationFailed, error, {\n 'task.id': taskId,\n 'task.operation': NOTIFICATION_OPERATION,\n }),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n\nexport function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter {\n return {\n error: (event, error, attributes) => void reporter.recordError(event, error, attributes),\n warn: (event, error, attributes) => void reporter.recordWarning(event, error, attributes),\n event: (event, attributes) => void reporter.recordEvent(event, attributes),\n };\n}\n"],"mappings":"0FAiCA,SAAgB,EAAwB,EAAoC,CAAC,EAAsB,CACjG,IAAM,GAAA,EAA2BA,EAAAA,oBAAAA,CAAoB,CACnD,YAAa,YACb,YAAa,yBACb,IAAK,EAAQ,IACb,cAAe,EAAQ,cACvB,IAAK,EAAQ,IACb,iBAAkB,EAAQ,iBAC1B,KAAM,EAAQ,KACd,WAAY,GACZ,aAAc,EAChB,CAAC,EACD,MAAO,CACL,aAAc,EAAO,EAAO,IAAe,EAAU,YAAY,EAAO,EAAO,CAAU,EACzF,eAAgB,EAAO,EAAO,IAAe,EAAU,cAAc,EAAO,EAAO,CAAU,EAC7F,aAAc,EAAO,IAAe,EAAU,YAAY,EAAO,CAAU,EAC3E,yBAA0B,EAAO,IAC/B,EAAU,YAAYC,EAAAA,WAAW,mBAAoB,EAAO,CAC1D,UAAW,EACX,iBAAkB,yBACpB,CAAC,EACH,UAAa,EAAU,MAAM,EAC7B,aAAgB,EAAU,SAAS,CACrC,CACF,CAEA,SAAgB,EAAkB,EAAkD,CAClF,MAAO,CACL,OAAQ,EAAO,EAAO,IAAe,KAAK,EAAS,YAAY,EAAO,EAAO,CAAU,EACvF,MAAO,EAAO,EAAO,IAAe,KAAK,EAAS,cAAc,EAAO,EAAO,CAAU,EACxF,OAAQ,EAAO,IAAe,KAAK,EAAS,YAAY,EAAO,CAAU,CAC3E,CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TASK_EVENT, TaskErrorAttributes, TaskErrorSink, TaskEventName, TaskEventSink, TaskFailureReporter } from "../../types/telemetry.cjs";
|
|
2
|
+
import { DoomTelemetryOptions } from "@agimon-ai/doompi-telemetry";
|
|
3
|
+
//#region src/adapters/telemetry/logSinkTelemetry.d.ts
|
|
4
|
+
interface TaskErrorReporterOptions {
|
|
5
|
+
cwd?: string;
|
|
6
|
+
workspaceRoot?: string;
|
|
7
|
+
env?: NodeJS.ProcessEnv;
|
|
8
|
+
telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;
|
|
9
|
+
warn?: (message: string) => void;
|
|
10
|
+
}
|
|
11
|
+
interface TaskErrorReporter {
|
|
12
|
+
recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;
|
|
13
|
+
recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;
|
|
14
|
+
recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;
|
|
15
|
+
recordNotificationError(error: unknown, taskId: number): Promise<void>;
|
|
16
|
+
flush(): Promise<void>;
|
|
17
|
+
shutdown(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
declare function createTaskErrorReporter(options?: TaskErrorReporterOptions): TaskErrorReporter;
|
|
20
|
+
declare function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { TASK_EVENT, type TaskErrorAttributes, TaskErrorReporter, TaskErrorReporterOptions, type TaskErrorSink, type TaskEventName, type TaskEventSink, type TaskFailureReporter, createTaskErrorReporter, toFailureReporter };
|
|
23
|
+
//# sourceMappingURL=logSinkTelemetry.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry.d.cts","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"mappings":";;;UAgBiB;EACf;EACA;EACA,MAAM,OAAO;EACb,mBAAmB,YAAY;EAC/B,QAAQ;;UAGO;EACf,YAAY,eAAe,gBAAgB,aAAa,sBAAsB;EAC9E,cAAc,eAAe,gBAAgB,aAAa,sBAAsB;EAChF,YAAY,eAAe,aAAa,sBAAsB;EAC9D,wBAAwB,gBAAgB,iBAAiB;EACzD,SAAS;EACT,YAAY;;iBAGE,wBAAwB,UAAS,2BAAgC;iBA0BjE,kBAAkB,UAAU,oBAAoB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TASK_EVENT, TaskErrorAttributes, TaskErrorSink, TaskEventName, TaskEventSink, TaskFailureReporter } from "../../types/telemetry.mjs";
|
|
2
|
+
import { DoomTelemetryOptions } from "@agimon-ai/doompi-telemetry";
|
|
3
|
+
//#region src/adapters/telemetry/logSinkTelemetry.d.ts
|
|
4
|
+
interface TaskErrorReporterOptions {
|
|
5
|
+
cwd?: string;
|
|
6
|
+
workspaceRoot?: string;
|
|
7
|
+
env?: NodeJS.ProcessEnv;
|
|
8
|
+
telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;
|
|
9
|
+
warn?: (message: string) => void;
|
|
10
|
+
}
|
|
11
|
+
interface TaskErrorReporter {
|
|
12
|
+
recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;
|
|
13
|
+
recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;
|
|
14
|
+
recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;
|
|
15
|
+
recordNotificationError(error: unknown, taskId: number): Promise<void>;
|
|
16
|
+
flush(): Promise<void>;
|
|
17
|
+
shutdown(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
declare function createTaskErrorReporter(options?: TaskErrorReporterOptions): TaskErrorReporter;
|
|
20
|
+
declare function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { TASK_EVENT, type TaskErrorAttributes, TaskErrorReporter, TaskErrorReporterOptions, type TaskErrorSink, type TaskEventName, type TaskEventSink, type TaskFailureReporter, createTaskErrorReporter, toFailureReporter };
|
|
23
|
+
//# sourceMappingURL=logSinkTelemetry.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry.d.mts","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"mappings":";;;UAgBiB;EACf;EACA;EACA,MAAM,OAAO;EACb,mBAAmB,YAAY;EAC/B,QAAQ;;UAGO;EACf,YAAY,eAAe,gBAAgB,aAAa,sBAAsB;EAC9E,cAAc,eAAe,gBAAgB,aAAa,sBAAsB;EAChF,YAAY,eAAe,aAAa,sBAAsB;EAC9D,wBAAwB,gBAAgB,iBAAiB;EACzD,SAAS;EACT,YAAY;;iBAGE,wBAAwB,UAAS,2BAAgC;iBA0BjE,kBAAkB,UAAU,oBAAoB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{TASK_EVENT as e}from"../../types/telemetry.mjs";import{createDoomTelemetry as t}from"@agimon-ai/doompi-telemetry";function n(n={}){let r=t({serviceName:`doom-task`,packageName:`@agimon-ai/doompi-task`,cwd:n.cwd,workspaceRoot:n.workspaceRoot,env:n.env,telemetryFactory:n.telemetryFactory,warn:n.warn,enableLogs:!0,enableTraces:!0});return{recordError:(e,t,n)=>r.recordError(e,t,n),recordWarning:(e,t,n)=>r.recordWarning(e,t,n),recordEvent:(e,t)=>r.recordEvent(e,t),recordNotificationError:(t,n)=>r.recordError(e.notificationFailed,t,{"task.id":n,"task.operation":`completion_notification`}),flush:()=>r.flush(),shutdown:()=>r.shutdown()}}function r(e){return{error:(t,n,r)=>void e.recordError(t,n,r),warn:(t,n,r)=>void e.recordWarning(t,n,r),event:(t,n)=>void e.recordEvent(t,n)}}export{e as TASK_EVENT,n as createTaskErrorReporter,r as toFailureReporter};
|
|
2
|
+
//# sourceMappingURL=logSinkTelemetry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry.mjs","names":[],"sources":["../../../src/adapters/telemetry/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\nimport { TASK_EVENT, type TaskErrorAttributes, type TaskFailureReporter } from '../../types/telemetry.ts';\n\nexport {\n TASK_EVENT,\n type TaskErrorAttributes,\n type TaskErrorSink,\n type TaskEventName,\n type TaskEventSink,\n type TaskFailureReporter,\n} from '../../types/telemetry.ts';\n\nconst SERVICE_NAME = 'doom-task';\nconst PACKAGE_NAME = '@agimon-ai/doompi-task';\nconst NOTIFICATION_OPERATION = 'completion_notification';\n\nexport interface TaskErrorReporterOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface TaskErrorReporter {\n recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;\n recordNotificationError(error: unknown, taskId: number): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createTaskErrorReporter(options: TaskErrorReporterOptions = {}): TaskErrorReporter {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n recordNotificationError: (error, taskId) =>\n telemetry.recordError(TASK_EVENT.notificationFailed, error, {\n 'task.id': taskId,\n 'task.operation': NOTIFICATION_OPERATION,\n }),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n\nexport function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter {\n return {\n error: (event, error, attributes) => void reporter.recordError(event, error, attributes),\n warn: (event, error, attributes) => void reporter.recordWarning(event, error, attributes),\n event: (event, attributes) => void reporter.recordEvent(event, attributes),\n };\n}\n"],"mappings":"yHAiCA,SAAgB,EAAwB,EAAoC,CAAC,EAAsB,CACjG,IAAM,EAA2B,EAAoB,CACnD,YAAa,YACb,YAAa,yBACb,IAAK,EAAQ,IACb,cAAe,EAAQ,cACvB,IAAK,EAAQ,IACb,iBAAkB,EAAQ,iBAC1B,KAAM,EAAQ,KACd,WAAY,GACZ,aAAc,EAChB,CAAC,EACD,MAAO,CACL,aAAc,EAAO,EAAO,IAAe,EAAU,YAAY,EAAO,EAAO,CAAU,EACzF,eAAgB,EAAO,EAAO,IAAe,EAAU,cAAc,EAAO,EAAO,CAAU,EAC7F,aAAc,EAAO,IAAe,EAAU,YAAY,EAAO,CAAU,EAC3E,yBAA0B,EAAO,IAC/B,EAAU,YAAY,EAAW,mBAAoB,EAAO,CAC1D,UAAW,EACX,iBAAkB,yBACpB,CAAC,EACH,UAAa,EAAU,MAAM,EAC7B,aAAgB,EAAU,SAAS,CACrC,CACF,CAEA,SAAgB,EAAkB,EAAkD,CAClF,MAAO,CACL,OAAQ,EAAO,EAAO,IAAe,KAAK,EAAS,YAAY,EAAO,EAAO,CAAU,EACvF,MAAO,EAAO,EAAO,IAAe,KAAK,EAAS,cAAc,EAAO,EAAO,CAAU,EACxF,OAAQ,EAAO,IAAe,KAAK,EAAS,YAAY,EAAO,CAAU,CAC3E,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./store/paths.cjs"),t=require("./store/taskStore.cjs"),n=require("../types/webTasks.cjs");function r(e){return{tasks:e.tasks.flatMap(e=>{if(e.status===`deleted`)return[];let t={id:e.id,subject:e.subject,status:e.status,blockedBy:e.blockedBy??[]};return e.description&&(t.description=e.description),e.activeForm&&(t.activeForm=e.activeForm),e.owner&&(t.owner=e.owner),e.updatedAt&&(t.updatedAt=e.updatedAt),e.delegation&&(t.delegation={agent:e.delegation.agent,state:e.delegation.state}),[t]}),rev:e.rev}}function i(i={}){return{frameType:n.TASKS_CHANNEL_TYPE,start(n){let a=new Map,o=o=>{if(a.has(o.sessionId))return;let s=i.storeFor?.(o)??new t.TaskStore({cwd:o.cwd,storePath:e.resolveStorePath(o.cwd,process.env,o.sessionId)}),c=s.read(),l=s.onExternalChange(e=>n.publish(o.sessionId,r(e)));a.set(o.sessionId,{store:s,unwatch:l}),c.tasks.length>0&&n.publish(o.sessionId,r(c))},s=e=>{let t=a.get(e);t&&(t.unwatch(),t.store.dispose(),a.delete(e))};for(let e of n.sessions())o(e);return{payloadFor(e){o(e);let t=a.get(e.sessionId)?.store.snapshot;return t===void 0?void 0:r(t)},sessionAdded:o,sessionRemoved:s,close(){for(let e of a.keys())s(e)}}}}}const a=[i()];exports.createTasksChannel=i,exports.webHubChannels=a;
|
|
2
|
+
//# sourceMappingURL=webTasksChannel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webTasksChannel.cjs","names":["TASKS_CHANNEL_TYPE","TaskStore","resolveStorePath"],"sources":["../../src/adapters/webTasksChannel.ts"],"sourcesContent":["import type { HubChannelSource, HubSessionScope, WebHubChannel } from '@agimon-ai/doompi-web-contracts';\nimport { resolveStorePath } from './store/paths.ts';\nimport { TaskStore } from './store/taskStore.ts';\nimport type { TaskDocument } from '../services/store/types.ts';\nimport { TASKS_CHANNEL_TYPE, type WebTask, type WebTasksPayload } from '../types/webTasks.ts';\n\ninterface TaskStoreSource {\n readonly snapshot: TaskDocument;\n read(): TaskDocument;\n onExternalChange(listener: (document: TaskDocument) => void): () => void;\n dispose(): void;\n}\n\nexport interface TasksChannelOptions {\n /** Injectable for tests. The default opens the session tree's durable task store. */\n storeFor?: (scope: HubSessionScope) => TaskStoreSource;\n}\n\nfunction present(document: TaskDocument): WebTasksPayload {\n const tasks: WebTask[] = document.tasks.flatMap((task) => {\n if (task.status === 'deleted') return [];\n const view: WebTask = {\n id: task.id,\n subject: task.subject,\n status: task.status,\n blockedBy: task.blockedBy ?? [],\n };\n if (task.description) view.description = task.description;\n if (task.activeForm) view.activeForm = task.activeForm;\n if (task.owner) view.owner = task.owner;\n if (task.updatedAt) view.updatedAt = task.updatedAt;\n if (task.delegation) {\n view.delegation = { agent: task.delegation.agent, state: task.delegation.state };\n }\n return [view];\n });\n return { tasks, rev: document.rev };\n}\n\n/** Publishes each managed session's durable task graph and follows external subagent writes. */\nexport function createTasksChannel(options: TasksChannelOptions = {}): WebHubChannel {\n return {\n frameType: TASKS_CHANNEL_TYPE,\n start(host) {\n const stores = new Map<string, { store: TaskStoreSource; unwatch: () => void }>();\n const open = (scope: HubSessionScope): void => {\n if (stores.has(scope.sessionId)) return;\n const store =\n options.storeFor?.(scope) ??\n new TaskStore({ cwd: scope.cwd, storePath: resolveStorePath(scope.cwd, process.env, scope.sessionId) });\n const document = store.read();\n const unwatch = store.onExternalChange((changed) => host.publish(scope.sessionId, present(changed)));\n stores.set(scope.sessionId, { store, unwatch });\n if (document.tasks.length > 0) host.publish(scope.sessionId, present(document));\n };\n const close = (sessionId: string): void => {\n const source = stores.get(sessionId);\n if (!source) return;\n source.unwatch();\n source.store.dispose();\n stores.delete(sessionId);\n };\n for (const scope of host.sessions()) open(scope);\n\n const source: HubChannelSource = {\n payloadFor(scope) {\n open(scope);\n const document = stores.get(scope.sessionId)?.store.snapshot;\n return document === undefined ? undefined : present(document);\n },\n sessionAdded: open,\n sessionRemoved: close,\n close() {\n for (const sessionId of stores.keys()) close(sessionId);\n },\n };\n return source;\n },\n };\n}\n\n/** The named export the generated hub registry imports. */\nexport const webHubChannels: readonly WebHubChannel[] = [createTasksChannel()];\n"],"mappings":"2GAkBA,SAAS,EAAQ,EAAyC,CAkBxD,MAAO,CAAE,MAjBgB,EAAS,MAAM,QAAS,GAAS,CACxD,GAAI,EAAK,SAAW,UAAW,MAAO,CAAC,EACvC,IAAM,EAAgB,CACpB,GAAI,EAAK,GACT,QAAS,EAAK,QACd,OAAQ,EAAK,OACb,UAAW,EAAK,WAAa,CAAC,CAChC,EAQA,OAPI,EAAK,cAAa,EAAK,YAAc,EAAK,aAC1C,EAAK,aAAY,EAAK,WAAa,EAAK,YACxC,EAAK,QAAO,EAAK,MAAQ,EAAK,OAC9B,EAAK,YAAW,EAAK,UAAY,EAAK,WACtC,EAAK,aACP,EAAK,WAAa,CAAE,MAAO,EAAK,WAAW,MAAO,MAAO,EAAK,WAAW,KAAM,GAE1E,CAAC,CAAI,CACd,C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@agimon-ai/doompi-web-contracts";
|
|
3
|
+
//#region src/adapters/webTasksChannel.d.ts
|
|
4
|
+
interface TaskStoreSource {
|
|
5
|
+
readonly snapshot: TaskDocument;
|
|
6
|
+
read(): TaskDocument;
|
|
7
|
+
onExternalChange(listener: (document: TaskDocument) => void): () => void;
|
|
8
|
+
dispose(): void;
|
|
9
|
+
}
|
|
10
|
+
interface TasksChannelOptions {
|
|
11
|
+
/** Injectable for tests. The default opens the session tree's durable task store. */
|
|
12
|
+
storeFor?: (scope: HubSessionScope) => TaskStoreSource;
|
|
13
|
+
}
|
|
14
|
+
/** Publishes each managed session's durable task graph and follows external subagent writes. */
|
|
15
|
+
declare function createTasksChannel(options?: TasksChannelOptions): WebHubChannel;
|
|
16
|
+
/** The named export the generated hub registry imports. */
|
|
17
|
+
declare const webHubChannels: readonly WebHubChannel[];
|
|
18
|
+
//#endregion
|
|
19
|
+
export { TasksChannelOptions, createTasksChannel, webHubChannels };
|
|
20
|
+
//# sourceMappingURL=webTasksChannel.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webTasksChannel.d.cts","names":[],"sources":["../../src/adapters/webTasksChannel.ts"],"mappings":";;;UAMU;WACC,UAAU;EACnB,QAAQ;EACR,iBAAiB,WAAW,UAAU;EACtC;;UAGe;;EAEf,YAAY,OAAO,oBAAoB;;;iBAyBzB,mBAAmB,UAAS,sBAA2B;;cA0C1D,yBAAyB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TaskDocument } from "../services/store/types.mjs";
|
|
2
|
+
import { HubSessionScope, WebHubChannel } from "@agimon-ai/doompi-web-contracts";
|
|
3
|
+
//#region src/adapters/webTasksChannel.d.ts
|
|
4
|
+
interface TaskStoreSource {
|
|
5
|
+
readonly snapshot: TaskDocument;
|
|
6
|
+
read(): TaskDocument;
|
|
7
|
+
onExternalChange(listener: (document: TaskDocument) => void): () => void;
|
|
8
|
+
dispose(): void;
|
|
9
|
+
}
|
|
10
|
+
interface TasksChannelOptions {
|
|
11
|
+
/** Injectable for tests. The default opens the session tree's durable task store. */
|
|
12
|
+
storeFor?: (scope: HubSessionScope) => TaskStoreSource;
|
|
13
|
+
}
|
|
14
|
+
/** Publishes each managed session's durable task graph and follows external subagent writes. */
|
|
15
|
+
declare function createTasksChannel(options?: TasksChannelOptions): WebHubChannel;
|
|
16
|
+
/** The named export the generated hub registry imports. */
|
|
17
|
+
declare const webHubChannels: readonly WebHubChannel[];
|
|
18
|
+
//#endregion
|
|
19
|
+
export { TasksChannelOptions, createTasksChannel, webHubChannels };
|
|
20
|
+
//# sourceMappingURL=webTasksChannel.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webTasksChannel.d.mts","names":[],"sources":["../../src/adapters/webTasksChannel.ts"],"mappings":";;;UAMU;WACC,UAAU;EACnB,QAAQ;EACR,iBAAiB,WAAW,UAAU;EACtC;;UAGe;;EAEf,YAAY,OAAO,oBAAoB;;;iBAyBzB,mBAAmB,UAAS,sBAA2B;;cA0C1D,yBAAyB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{resolveStorePath as e}from"./store/paths.mjs";import{TaskStore as t}from"./store/taskStore.mjs";import{TASKS_CHANNEL_TYPE as n}from"../types/webTasks.mjs";function r(e){return{tasks:e.tasks.flatMap(e=>{if(e.status===`deleted`)return[];let t={id:e.id,subject:e.subject,status:e.status,blockedBy:e.blockedBy??[]};return e.description&&(t.description=e.description),e.activeForm&&(t.activeForm=e.activeForm),e.owner&&(t.owner=e.owner),e.updatedAt&&(t.updatedAt=e.updatedAt),e.delegation&&(t.delegation={agent:e.delegation.agent,state:e.delegation.state}),[t]}),rev:e.rev}}function i(i={}){return{frameType:n,start(n){let a=new Map,o=o=>{if(a.has(o.sessionId))return;let s=i.storeFor?.(o)??new t({cwd:o.cwd,storePath:e(o.cwd,process.env,o.sessionId)}),c=s.read(),l=s.onExternalChange(e=>n.publish(o.sessionId,r(e)));a.set(o.sessionId,{store:s,unwatch:l}),c.tasks.length>0&&n.publish(o.sessionId,r(c))},s=e=>{let t=a.get(e);t&&(t.unwatch(),t.store.dispose(),a.delete(e))};for(let e of n.sessions())o(e);return{payloadFor(e){o(e);let t=a.get(e.sessionId)?.store.snapshot;return t===void 0?void 0:r(t)},sessionAdded:o,sessionRemoved:s,close(){for(let e of a.keys())s(e)}}}}}const a=[i()];export{i as createTasksChannel,a as webHubChannels};
|
|
2
|
+
//# sourceMappingURL=webTasksChannel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webTasksChannel.mjs","names":[],"sources":["../../src/adapters/webTasksChannel.ts"],"sourcesContent":["import type { HubChannelSource, HubSessionScope, WebHubChannel } from '@agimon-ai/doompi-web-contracts';\nimport { resolveStorePath } from './store/paths.ts';\nimport { TaskStore } from './store/taskStore.ts';\nimport type { TaskDocument } from '../services/store/types.ts';\nimport { TASKS_CHANNEL_TYPE, type WebTask, type WebTasksPayload } from '../types/webTasks.ts';\n\ninterface TaskStoreSource {\n readonly snapshot: TaskDocument;\n read(): TaskDocument;\n onExternalChange(listener: (document: TaskDocument) => void): () => void;\n dispose(): void;\n}\n\nexport interface TasksChannelOptions {\n /** Injectable for tests. The default opens the session tree's durable task store. */\n storeFor?: (scope: HubSessionScope) => TaskStoreSource;\n}\n\nfunction present(document: TaskDocument): WebTasksPayload {\n const tasks: WebTask[] = document.tasks.flatMap((task) => {\n if (task.status === 'deleted') return [];\n const view: WebTask = {\n id: task.id,\n subject: task.subject,\n status: task.status,\n blockedBy: task.blockedBy ?? [],\n };\n if (task.description) view.description = task.description;\n if (task.activeForm) view.activeForm = task.activeForm;\n if (task.owner) view.owner = task.owner;\n if (task.updatedAt) view.updatedAt = task.updatedAt;\n if (task.delegation) {\n view.delegation = { agent: task.delegation.agent, state: task.delegation.state };\n }\n return [view];\n });\n return { tasks, rev: document.rev };\n}\n\n/** Publishes each managed session's durable task graph and follows external subagent writes. */\nexport function createTasksChannel(options: TasksChannelOptions = {}): WebHubChannel {\n return {\n frameType: TASKS_CHANNEL_TYPE,\n start(host) {\n const stores = new Map<string, { store: TaskStoreSource; unwatch: () => void }>();\n const open = (scope: HubSessionScope): void => {\n if (stores.has(scope.sessionId)) return;\n const store =\n options.storeFor?.(scope) ??\n new TaskStore({ cwd: scope.cwd, storePath: resolveStorePath(scope.cwd, process.env, scope.sessionId) });\n const document = store.read();\n const unwatch = store.onExternalChange((changed) => host.publish(scope.sessionId, present(changed)));\n stores.set(scope.sessionId, { store, unwatch });\n if (document.tasks.length > 0) host.publish(scope.sessionId, present(document));\n };\n const close = (sessionId: string): void => {\n const source = stores.get(sessionId);\n if (!source) return;\n source.unwatch();\n source.store.dispose();\n stores.delete(sessionId);\n };\n for (const scope of host.sessions()) open(scope);\n\n const source: HubChannelSource = {\n payloadFor(scope) {\n open(scope);\n const document = stores.get(scope.sessionId)?.store.snapshot;\n return document === undefined ? undefined : present(document);\n },\n sessionAdded: open,\n sessionRemoved: close,\n close() {\n for (const sessionId of stores.keys()) close(sessionId);\n },\n };\n return source;\n },\n };\n}\n\n/** The named export the generated hub registry imports. */\nexport const webHubChannels: readonly WebHubChannel[] = [createTasksChannel()];\n"],"mappings":"kKAkBA,SAAS,EAAQ,EAAyC,CAkBxD,MAAO,CAAE,MAjBgB,EAAS,MAAM,QAAS,GAAS,CACxD,GAAI,EAAK,SAAW,UAAW,MAAO,CAAC,EACvC,IAAM,EAAgB,CACpB,GAAI,EAAK,GACT,QAAS,EAAK,QACd,OAAQ,EAAK,OACb,UAAW,EAAK,WAAa,CAAC,CAChC,EAQA,OAPI,EAAK,cAAa,EAAK,YAAc,EAAK,aAC1C,EAAK,aAAY,EAAK,WAAa,EAAK,YACxC,EAAK,QAAO,EAAK,MAAQ,EAAK,OAC9B,EAAK,YAAW,EAAK,UAAY,EAAK,WACtC,EAAK,aACP,EAAK,WAAa,CAAE,MAAO,EAAK,WAAW,MAAO,MAAO,EAAK,WAAW,KAAM,GAE1E,CA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ME,{description:`Open Task Space for this session tree`,handler:async(n,a)=>{if(!a.hasUI){a.ui.notify(e.ERR_REQUIRES_INTERACTIVE,`error`);return}await i?.(a),r.read(),await t.openTaskSpace(a,{store:r})}})}exports.registerTasksCommand=n;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["COMMAND_NAME","ERR_REQUIRES_INTERACTIVE","openTaskSpace"],"sources":["../../src/commands/index.ts"],"sourcesContent":["import type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE } from '../schemas/task.ts';\nimport type { TaskStore } from '../adapters/store/taskStore';\nimport { openTaskSpace } from '../tui/taskSpace.ts';\n\n/**\n * `/tasks`, reachable from the leader palette as `SPC t l`.\n *\n * The command opens the Task Space overlay rather than printing a listing: the\n * overlay is the readable surface and it can edit, while a transcript dump could\n * only be read.\n */\nexport function registerTasksCommand(\n pi: ExtensionAPI,\n store: TaskStore,\n waitUntilReady?: (context: ExtensionContext) => Promise<void>,\n): void {\n pi.registerCommand(COMMAND_NAME, {\n description: 'Open Task Space for this session tree',\n handler: async (_args, ctx) => {\n if (!ctx.hasUI) {\n ctx.ui.notify(ERR_REQUIRES_INTERACTIVE, 'error');\n return;\n }\n\n await waitUntilReady?.(ctx);\n store.read();\n await openTaskSpace(ctx, { store });\n },\n });\n}\n"],"mappings":"0EAYA,SAAgB,EACd,EACA,EACA,EACM,CACN,EAAG,gBAAgBA,EAAAA,aAAc,CAC/B,YAAa,wCACb,QAAS,MAAO,EAAO,IAAQ,CAC7B,GAAI,CAAC,EAAI,MAAO,CACd,EAAI,GAAG,OAAOC,EAAAA,yBAA0B,OAAO,EAC/C,MACF,CAEA,MAAM,IAAiB,CAAG,EAC1B,EAAM,KAAK,EACX,MAAMC,EAAAA,cAAc,EAAK,CAAE,OAAM,CAAC,CACpC,CACF,CAAC,CACH"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TaskStore } from "../adapters/store/taskStore.cjs";
|
|
2
|
+
import { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
//#region src/commands/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* `/tasks`, reachable from the leader palette as `SPC t l`.
|
|
6
|
+
*
|
|
7
|
+
* The command opens the Task Space overlay rather than printing a listing: the
|
|
8
|
+
* overlay is the readable surface and it can edit, while a transcript dump could
|
|
9
|
+
* only be read.
|
|
10
|
+
*/
|
|
11
|
+
declare function registerTasksCommand(pi: ExtensionAPI, store: TaskStore, waitUntilReady?: (context: ExtensionContext) => Promise<void>): void;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { registerTasksCommand };
|
|
14
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/commands/index.ts"],"mappings":";;;;;;;;;;iBAYgB,qBACd,IAAI,cACJ,OAAO,WACP,kBAAkB,SAAS,qBAAqB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TaskStore } from "../adapters/store/taskStore.mjs";
|
|
2
|
+
import { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
//#region src/commands/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* `/tasks`, reachable from the leader palette as `SPC t l`.
|
|
6
|
+
*
|
|
7
|
+
* The command opens the Task Space overlay rather than printing a listing: the
|
|
8
|
+
* overlay is the readable surface and it can edit, while a transcript dump could
|
|
9
|
+
* only be read.
|
|
10
|
+
*/
|
|
11
|
+
declare function registerTasksCommand(pi: ExtensionAPI, store: TaskStore, waitUntilReady?: (context: ExtensionContext) => Promise<void>): void;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { registerTasksCommand };
|
|
14
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/commands/index.ts"],"mappings":";;;;;;;;;;iBAYgB,qBACd,IAAI,cACJ,OAAO,WACP,kBAAkB,SAAS,qBAAqB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{COMMAND_NAME as e,ERR_REQUIRES_INTERACTIVE as t}from"../schemas/task.mjs";import{openTaskSpace as n}from"../tui/taskSpace2.mjs";function r(r,i,a){r.registerCommand(e,{description:`Open Task Space for this session tree`,handler:async(e,r)=>{if(!r.hasUI){r.ui.notify(t,`error`);return}await a?.(r),i.read(),await n(r,{store:i})}})}export{r as registerTasksCommand};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/commands/index.ts"],"sourcesContent":["import type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE } from '../schemas/task.ts';\nimport type { TaskStore } from '../adapters/store/taskStore';\nimport { openTaskSpace } from '../tui/taskSpace.ts';\n\n/**\n * `/tasks`, reachable from the leader palette as `SPC t l`.\n *\n * The command opens the Task Space overlay rather than printing a listing: the\n * overlay is the readable surface and it can edit, while a transcript dump could\n * only be read.\n */\nexport function registerTasksCommand(\n pi: ExtensionAPI,\n store: TaskStore,\n waitUntilReady?: (context: ExtensionContext) => Promise<void>,\n): void {\n pi.registerCommand(COMMAND_NAME, {\n description: 'Open Task Space for this session tree',\n handler: async (_args, ctx) => {\n if (!ctx.hasUI) {\n ctx.ui.notify(ERR_REQUIRES_INTERACTIVE, 'error');\n return;\n }\n\n await waitUntilReady?.(ctx);\n store.read();\n await openTaskSpace(ctx, { store });\n },\n });\n}\n"],"mappings":"uIAYA,SAAgB,EACd,EACA,EACA,EACM,CACN,EAAG,gBAAgB,EAAc,CAC/B,YAAa,wCACb,QAAS,MAAO,EAAO,IAAQ,CAC7B,GAAI,CAAC,EAAI,MAAO,CACd,EAAI,GAAG,OAAO,EAA0B,OAAO,EAC/C,MACF,CAEA,MAAM,IAAiB,CAAG,EAC1B,EAAM,KAAK,EACX,MAAM,EAAc,EAAK,CAAE,OAAM,CAAC,CACpC,CACF,CAAC,CACH"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=[`Capture a whole plan in one call: {"action":"upsert","tasks":[{"subject":"Research existing tool"},{"subject":"Write the reducer"},{"subject":"Add tests"}]}. Batch whenever you are writing the plan down — the initial list, a revised plan, or wiring dependencies across several tasks — because one call keeps ids and blockers consistent and shows the user the whole plan at once.`,`Do not batch parent progress. Mark a task in_progress with its own call BEFORE beginning work, and completed with its own call IMMEDIATELY when it is done. upsert accepts many tasks, but a batch of completions sent at the end of a turn is still wrong: upsert batching is for writing a plan down, single calls are for reporting progress, and the user watches the task list to see where you are. Native assignments[] fan-out is separate from progress reporting. Exactly one task should be in_progress for your own work; delegated tasks run in parallel and do not count against that.`,`Never mark a task completed if tests are failing, the implementation is partial, or you hit unresolved errors, use status "failed" or keep it in_progress and add a new task for the blocker in the same upsert.`,`When every non-deleted task is completed, review the full task list once more and call task {"action":"clear"} to close it. Do not leave an all-completed list open.`,`Status is a state machine: pending → in_progress → completed, plus failed (recoverable, can go back to pending or in_progress) and deleted as a tombstone. Pass activeForm (present-continuous, e.g. 'writing tests') when marking in_progress.`,`One call does both: an entry with an id changes that task, an entry without an id creates one. To change status, upsert the task by id, e.g. {"action":"upsert","tasks":[{"id":3,"status":"completed"}]}. Never omit the id when you meant to change an existing task — an entry with no id creates a new one instead. An entry that carries an id and no other field is rejected.`,`Use blockedBy for dependencies (A is blocked by B). On an entry with no id pass blockedBy as the initial set; on an entry with an id use addBlockedBy / removeBlockedBy (additive merge, do not resend the full array). To depend on a task created earlier in the SAME call, give that earlier entry a "ref" and list the ref string in place of an id: [{"ref":"api","subject":"Design the API"},{"subject":"Implement the API","blockedBy":["api"]}]. A ref must be declared before it is used. Cycles are rejected.`,`upsert applies each entry independently: the entries that pass are committed and the failures are reported with their array index. A failed entry changed nothing, so resend only the corrected failures — never resend the whole call, because an already-applied entry with no id would create a duplicate task.`,`Before assigning work, call subagent with {"action":"agents"} and match each task to an exact discovered agent name. Prefer a discovered general-purpose write-capable agent such as delegate or worker when no specialist fits. Use a focused inlineAgent only for read-only work.`,`Apply the session's general delegation criteria before selecting tracked work. Use assignments[] for every assign call, including one task: {"action":"assign","assignments":[{"id":1,"agent":"researcher"}]}. Put every assign-time field, including model, inlineAgent, instructions, relevantFiles, priorFindings, and context, inside its assignments[] entry; assign has no top-level single-task form. For two or more independent ready tasks selected for delegation, use one native batch instead of repeated calls. Do not wrap repeated task assign calls in multi_tool; assignments[] reduces tool overhead and returns one indexed result. Do not use a direct subagent run for work already represented in the shared task list, so ownership and terminal results stay visible.`,`A batched assign applies each entry independently. Successful entries are already running if another entry fails; retry only failed entries after correcting them, and never resend successful entries.`,`Populate relevantFiles only with files you actually read or located, and priorFindings only with verified facts such as symbol names, call sites, the selected approach, and ruled-out alternatives. Send at most a dozen files; a guessed path costs more than an omitted one. Keep priorFindings to a few lines of facts, not directives.`,`When delegated task completion unblocks another tracked task, reconsider that newly eligible task promptly and repeat agent discovery before assigning it if needed.`,`If a child asks for a decision through intercom, or an assignment fails to start for another concrete issue, respond, rescope, or retry explicitly. Do not silently leave the task pending.`,`assign refuses tasks that are blocked, already delegated, or completed. Resolve blockers first. Use {"action":"cancel","id":3} to stop a running delegation; the task returns to pending.`,`Doom Task records delegated lifecycle and results on the shared task. The child does not update task status directly.`,`The task list is scoped to this session tree: delegated subagents share it, while unrelated sessions start empty. It persists for later inspection until retention cleanup.`,`Subject must be short and imperative (e.g. 'Research existing tool'); description is long-form detail written when you plan the task, and the delegated brief is that description plus the assign-time instructions, relevantFiles and priorFindings. Put durable scope in description and what you learned while exploring in the assign-time pack — do not repeat one in the other.`];exports.DEFAULT_PROMPT_GUIDELINES=e;
|
|
2
|
+
//# sourceMappingURL=promptGuidelines.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promptGuidelines.cjs","names":[],"sources":["../../../src/commands/task/promptGuidelines.ts"],"sourcesContent":["export const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Capture a whole plan in one call: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research existing tool\"},{\"subject\":\"Write the reducer\"},{\"subject\":\"Add tests\"}]}. Batch whenever you are writing the plan down — the initial list, a revised plan, or wiring dependencies across several tasks — because one call keeps ids and blockers consistent and shows the user the whole plan at once.',\n 'Do not batch parent progress. Mark a task in_progress with its own call BEFORE beginning work, and completed with its own call IMMEDIATELY when it is done. upsert accepts many tasks, but a batch of completions sent at the end of a turn is still wrong: upsert batching is for writing a plan down, single calls are for reporting progress, and the user watches the task list to see where you are. Native assignments[] fan-out is separate from progress reporting. Exactly one task should be in_progress for your own work; delegated tasks run in parallel and do not count against that.',\n 'Never mark a task completed if tests are failing, the implementation is partial, or you hit unresolved errors, use status \"failed\" or keep it in_progress and add a new task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the full task list once more and call task {\"action\":\"clear\"} to close it. Do not leave an all-completed list open.',\n \"Status is a state machine: pending → in_progress → completed, plus failed (recoverable, can go back to pending or in_progress) and deleted as a tombstone. Pass activeForm (present-continuous, e.g. 'writing tests') when marking in_progress.\",\n 'One call does both: an entry with an id changes that task, an entry without an id creates one. To change status, upsert the task by id, e.g. {\"action\":\"upsert\",\"tasks\":[{\"id\":3,\"status\":\"completed\"}]}. Never omit the id when you meant to change an existing task — an entry with no id creates a new one instead. An entry that carries an id and no other field is rejected.',\n 'Use blockedBy for dependencies (A is blocked by B). On an entry with no id pass blockedBy as the initial set; on an entry with an id use addBlockedBy / removeBlockedBy (additive merge, do not resend the full array). To depend on a task created earlier in the SAME call, give that earlier entry a \"ref\" and list the ref string in place of an id: [{\"ref\":\"api\",\"subject\":\"Design the API\"},{\"subject\":\"Implement the API\",\"blockedBy\":[\"api\"]}]. A ref must be declared before it is used. Cycles are rejected.',\n 'upsert applies each entry independently: the entries that pass are committed and the failures are reported with their array index. A failed entry changed nothing, so resend only the corrected failures — never resend the whole call, because an already-applied entry with no id would create a duplicate task.',\n 'Before assigning work, call subagent with {\"action\":\"agents\"} and match each task to an exact discovered agent name. Prefer a discovered general-purpose write-capable agent such as delegate or worker when no specialist fits. Use a focused inlineAgent only for read-only work.',\n 'Apply the session\\'s general delegation criteria before selecting tracked work. Use assignments[] for every assign call, including one task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put every assign-time field, including model, inlineAgent, instructions, relevantFiles, priorFindings, and context, inside its assignments[] entry; assign has no top-level single-task form. For two or more independent ready tasks selected for delegation, use one native batch instead of repeated calls. Do not wrap repeated task assign calls in multi_tool; assignments[] reduces tool overhead and returns one indexed result. Do not use a direct subagent run for work already represented in the shared task list, so ownership and terminal results stay visible.',\n 'A batched assign applies each entry independently. Successful entries are already running if another entry fails; retry only failed entries after correcting them, and never resend successful entries.',\n 'Populate relevantFiles only with files you actually read or located, and priorFindings only with verified facts such as symbol names, call sites, the selected approach, and ruled-out alternatives. Send at most a dozen files; a guessed path costs more than an omitted one. Keep priorFindings to a few lines of facts, not directives.',\n 'When delegated task completion unblocks another tracked task, reconsider that newly eligible task promptly and repeat agent discovery before assigning it if needed.',\n 'If a child asks for a decision through intercom, or an assignment fails to start for another concrete issue, respond, rescope, or retry explicitly. Do not silently leave the task pending.',\n 'assign refuses tasks that are blocked, already delegated, or completed. Resolve blockers first. Use {\"action\":\"cancel\",\"id\":3} to stop a running delegation; the task returns to pending.',\n 'Doom Task records delegated lifecycle and results on the shared task. The child does not update task status directly.',\n 'The task list is scoped to this session tree: delegated subagents share it, while unrelated sessions start empty. It persists for later inspection until retention cleanup.',\n \"Subject must be short and imperative (e.g. 'Research existing tool'); description is long-form detail written when you plan the task, and the delegated brief is that description plus the assign-time instructions, relevantFiles and priorFindings. Put durable scope in description and what you learned while exploring in the assign-time pack — do not repeat one in the other.\",\n];\n"],"mappings":"AAAA,MAAa,EAAsC,CACjD,6XACA,ukBACA,mNACA,uKACA,kPACA,qXACA,0fACA,qTACA,sRACA,iwBACA,0MACA,8UACA,uKACA,8LACA,4LACA,wHACA,8KACA,uXACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promptGuidelines.d.cts","names":[],"sources":["../../../src/commands/task/promptGuidelines.ts"],"mappings":";cAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promptGuidelines.d.mts","names":[],"sources":["../../../src/commands/task/promptGuidelines.ts"],"mappings":";cAAa"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=[`Capture a whole plan in one call: {"action":"upsert","tasks":[{"subject":"Research existing tool"},{"subject":"Write the reducer"},{"subject":"Add tests"}]}. Batch whenever you are writing the plan down — the initial list, a revised plan, or wiring dependencies across several tasks — because one call keeps ids and blockers consistent and shows the user the whole plan at once.`,`Do not batch parent progress. Mark a task in_progress with its own call BEFORE beginning work, and completed with its own call IMMEDIATELY when it is done. upsert accepts many tasks, but a batch of completions sent at the end of a turn is still wrong: upsert batching is for writing a plan down, single calls are for reporting progress, and the user watches the task list to see where you are. Native assignments[] fan-out is separate from progress reporting. Exactly one task should be in_progress for your own work; delegated tasks run in parallel and do not count against that.`,`Never mark a task completed if tests are failing, the implementation is partial, or you hit unresolved errors, use status "failed" or keep it in_progress and add a new task for the blocker in the same upsert.`,`When every non-deleted task is completed, review the full task list once more and call task {"action":"clear"} to close it. Do not leave an all-completed list open.`,`Status is a state machine: pending → in_progress → completed, plus failed (recoverable, can go back to pending or in_progress) and deleted as a tombstone. Pass activeForm (present-continuous, e.g. 'writing tests') when marking in_progress.`,`One call does both: an entry with an id changes that task, an entry without an id creates one. To change status, upsert the task by id, e.g. {"action":"upsert","tasks":[{"id":3,"status":"completed"}]}. Never omit the id when you meant to change an existing task — an entry with no id creates a new one instead. An entry that carries an id and no other field is rejected.`,`Use blockedBy for dependencies (A is blocked by B). On an entry with no id pass blockedBy as the initial set; on an entry with an id use addBlockedBy / removeBlockedBy (additive merge, do not resend the full array). To depend on a task created earlier in the SAME call, give that earlier entry a "ref" and list the ref string in place of an id: [{"ref":"api","subject":"Design the API"},{"subject":"Implement the API","blockedBy":["api"]}]. A ref must be declared before it is used. Cycles are rejected.`,`upsert applies each entry independently: the entries that pass are committed and the failures are reported with their array index. A failed entry changed nothing, so resend only the corrected failures — never resend the whole call, because an already-applied entry with no id would create a duplicate task.`,`Before assigning work, call subagent with {"action":"agents"} and match each task to an exact discovered agent name. Prefer a discovered general-purpose write-capable agent such as delegate or worker when no specialist fits. Use a focused inlineAgent only for read-only work.`,`Apply the session's general delegation criteria before selecting tracked work. Use assignments[] for every assign call, including one task: {"action":"assign","assignments":[{"id":1,"agent":"researcher"}]}. Put every assign-time field, including model, inlineAgent, instructions, relevantFiles, priorFindings, and context, inside its assignments[] entry; assign has no top-level single-task form. For two or more independent ready tasks selected for delegation, use one native batch instead of repeated calls. Do not wrap repeated task assign calls in multi_tool; assignments[] reduces tool overhead and returns one indexed result. Do not use a direct subagent run for work already represented in the shared task list, so ownership and terminal results stay visible.`,`A batched assign applies each entry independently. Successful entries are already running if another entry fails; retry only failed entries after correcting them, and never resend successful entries.`,`Populate relevantFiles only with files you actually read or located, and priorFindings only with verified facts such as symbol names, call sites, the selected approach, and ruled-out alternatives. Send at most a dozen files; a guessed path costs more than an omitted one. Keep priorFindings to a few lines of facts, not directives.`,`When delegated task completion unblocks another tracked task, reconsider that newly eligible task promptly and repeat agent discovery before assigning it if needed.`,`If a child asks for a decision through intercom, or an assignment fails to start for another concrete issue, respond, rescope, or retry explicitly. Do not silently leave the task pending.`,`assign refuses tasks that are blocked, already delegated, or completed. Resolve blockers first. Use {"action":"cancel","id":3} to stop a running delegation; the task returns to pending.`,`Doom Task records delegated lifecycle and results on the shared task. The child does not update task status directly.`,`The task list is scoped to this session tree: delegated subagents share it, while unrelated sessions start empty. It persists for later inspection until retention cleanup.`,`Subject must be short and imperative (e.g. 'Research existing tool'); description is long-form detail written when you plan the task, and the delegated brief is that description plus the assign-time instructions, relevantFiles and priorFindings. Put durable scope in description and what you learned while exploring in the assign-time pack — do not repeat one in the other.`];export{e as DEFAULT_PROMPT_GUIDELINES};
|
|
2
|
+
//# sourceMappingURL=promptGuidelines.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promptGuidelines.mjs","names":[],"sources":["../../../src/commands/task/promptGuidelines.ts"],"sourcesContent":["export const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Capture a whole plan in one call: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research existing tool\"},{\"subject\":\"Write the reducer\"},{\"subject\":\"Add tests\"}]}. Batch whenever you are writing the plan down — the initial list, a revised plan, or wiring dependencies across several tasks — because one call keeps ids and blockers consistent and shows the user the whole plan at once.',\n 'Do not batch parent progress. Mark a task in_progress with its own call BEFORE beginning work, and completed with its own call IMMEDIATELY when it is done. upsert accepts many tasks, but a batch of completions sent at the end of a turn is still wrong: upsert batching is for writing a plan down, single calls are for reporting progress, and the user watches the task list to see where you are. Native assignments[] fan-out is separate from progress reporting. Exactly one task should be in_progress for your own work; delegated tasks run in parallel and do not count against that.',\n 'Never mark a task completed if tests are failing, the implementation is partial, or you hit unresolved errors, use status \"failed\" or keep it in_progress and add a new task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the full task list once more and call task {\"action\":\"clear\"} to close it. Do not leave an all-completed list open.',\n \"Status is a state machine: pending → in_progress → completed, plus failed (recoverable, can go back to pending or in_progress) and deleted as a tombstone. Pass activeForm (present-continuous, e.g. 'writing tests') when marking in_progress.\",\n 'One call does both: an entry with an id changes that task, an entry without an id creates one. To change status, upsert the task by id, e.g. {\"action\":\"upsert\",\"tasks\":[{\"id\":3,\"status\":\"completed\"}]}. Never omit the id when you meant to change an existing task — an entry with no id creates a new one instead. An entry that carries an id and no other field is rejected.',\n 'Use blockedBy for dependencies (A is blocked by B). On an entry with no id pass blockedBy as the initial set; on an entry with an id use addBlockedBy / removeBlockedBy (additive merge, do not resend the full array). To depend on a task created earlier in the SAME call, give that earlier entry a \"ref\" and list the ref string in place of an id: [{\"ref\":\"api\",\"subject\":\"Design the API\"},{\"subject\":\"Implement the API\",\"blockedBy\":[\"api\"]}]. A ref must be declared before it is used. Cycles are rejected.',\n 'upsert applies each entry independently: the entries that pass are committed and the failures are reported with their array index. A failed entry changed nothing, so resend only the corrected failures — never resend the whole call, because an already-applied entry with no id would create a duplicate task.',\n 'Before assigning work, call subagent with {\"action\":\"agents\"} and match each task to an exact discovered agent name. Prefer a discovered general-purpose write-capable agent such as delegate or worker when no specialist fits. Use a focused inlineAgent only for read-only work.',\n 'Apply the session\\'s general delegation criteria before selecting tracked work. Use assignments[] for every assign call, including one task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put every assign-time field, including model, inlineAgent, instructions, relevantFiles, priorFindings, and context, inside its assignments[] entry; assign has no top-level single-task form. For two or more independent ready tasks selected for delegation, use one native batch instead of repeated calls. Do not wrap repeated task assign calls in multi_tool; assignments[] reduces tool overhead and returns one indexed result. Do not use a direct subagent run for work already represented in the shared task list, so ownership and terminal results stay visible.',\n 'A batched assign applies each entry independently. Successful entries are already running if another entry fails; retry only failed entries after correcting them, and never resend successful entries.',\n 'Populate relevantFiles only with files you actually read or located, and priorFindings only with verified facts such as symbol names, call sites, the selected approach, and ruled-out alternatives. Send at most a dozen files; a guessed path costs more than an omitted one. Keep priorFindings to a few lines of facts, not directives.',\n 'When delegated task completion unblocks another tracked task, reconsider that newly eligible task promptly and repeat agent discovery before assigning it if needed.',\n 'If a child asks for a decision through intercom, or an assignment fails to start for another concrete issue, respond, rescope, or retry explicitly. Do not silently leave the task pending.',\n 'assign refuses tasks that are blocked, already delegated, or completed. Resolve blockers first. Use {\"action\":\"cancel\",\"id\":3} to stop a running delegation; the task returns to pending.',\n 'Doom Task records delegated lifecycle and results on the shared task. The child does not update task status directly.',\n 'The task list is scoped to this session tree: delegated subagents share it, while unrelated sessions start empty. It persists for later inspection until retention cleanup.',\n \"Subject must be short and imperative (e.g. 'Research existing tool'); description is long-form detail written when you plan the task, and the delegated brief is that description plus the assign-time instructions, relevantFiles and priorFindings. Put durable scope in description and what you learned while exploring in the assign-time pack — do not repeat one in the other.\",\n];\n"],"mappings":"AAAA,MAAa,EAAsC,CACjD,6XACA,ukBACA,mNACA,uKACA,kPACA,qXACA,0fACA,qTACA,sRACA,iwBACA,0MACA,8UACA,uKACA,8LACA,4LACA,wHACA,8KACA,uXACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const e=require("../../services/store/taskGraph.cjs"),t=`All tasks are completed. Review the full task list once more, then close it with task {"action":"clear"}.`,n=`The applied entries are committed. Resend only the failed entries, corrected — a failed entry changed nothing, so a corrected retry is safe. Do not resend an entry that already applied: an entry without an id creates a second task.`,r=`No task changed, so the whole call can be resent once corrected.`,i=`Successful assignments are already running. Retry only the failed entries after correcting their task state or arguments; do not resend successful entries.`;function a(e){if(e.length===1)return e[0].message;let t=e.filter(e=>e.ok).length,n=e.length-t,r=[`Assigned ${t}/${e.length} tasks${n>0?`; ${n} failed`:``}.`,...e.map(e=>e.ok?`- [${e.index}] Delegated #${e.id} to ${e.agent}`:`- [${e.index}] Failed #${e.id} → ${e.agent}: ${e.message}`)];return n>0&&t>0&&r.push(``,i),n===0&&r.push(``,`All assignments are running independently in the background. Continue non-overlapping work, or end your turn.`),r.join(`
|
|
2
|
+
`)}function o(e){let t=e.blockedBy?.length?` ⛓ ${e.blockedBy.map(e=>`#${e}`).join(`,`)}`:``,n=e.status===`in_progress`&&e.activeForm?` (${e.activeForm})`:``,r=e.delegation&&e.delegation.state!==`cancelled`?` [${e.delegation.agent}]`:``;return`[${e.status}] #${e.id} ${e.subject}${n}${r}${t}`}function s(e){let t=e.delegation;if(!t)return[];let n=[` delegated to: ${t.agent} (${t.state})`];return t.model&&n.push(` model: ${t.model}`),t.result?.error&&n.push(` error: ${t.result.error}`),t.result?.outputPath&&n.push(` output file: ${t.result.outputPath}`),t.result?.output&&n.push(` output: ${t.result.output}`),n}function c(t,n){let r=e.deriveBlocks(n.tasks).get(t.id)??[],i=[`#${t.id} [${t.status}] ${t.subject}`];return t.description&&i.push(` description: ${t.description}`),t.activeForm&&i.push(` activeForm: ${t.activeForm}`),t.blockedBy?.length&&i.push(` blockedBy: ${t.blockedBy.map(e=>`#${e}`).join(`, `)}`),r.length&&i.push(` blocks: ${r.map(e=>`#${e}`).join(`, `)}`),t.owner&&i.push(` owner: ${t.owner}`),i.push(...s(t)),i.join(`
|
|
3
|
+
`)}function l(e){switch(e.kind){case`created`:{let t=e.ref?` (ref "${e.ref}")`:``,n=e.blockedBy?.length?` — blocked by ${e.blockedBy.map(e=>`#${e}`).join(`, `)}`:``;return`Created #${e.id}${t}: ${e.subject} (${e.status})${n}`}case`updated`:{let t=e.fromStatus===e.toStatus?``:` (${e.fromStatus} -> ${e.toStatus})`;return`Updated #${e.id}${t}`}case`unchanged`:return`No change: #${e.id} already matches the requested values (status: ${e.status})`;case`failed`:return`Failed${e.id===void 0?``:` #${e.id}`}: ${e.message}`}}function u(e){return e.items.length===1?e.items[0].kind===`failed`?e.items[0].message:`no entry was applied`:[`no entry was applied.`,...e.items.map(e=>`- [${e.index}] ${l(e)}`),r].join(`
|
|
4
|
+
`)}function d(r,i){switch(r.kind){case`upsert`:{let a=r.items.length===1?[l(r.items[0])]:[`Upsert applied ${r.applied}/${r.items.length} entries${r.failed>0?`; ${r.failed} failed`:``}.`,...r.items.map(e=>`- [${e.index}] ${l(e)}`),...r.failed>0?[``,n]:[]];return r.applied>0&&e.isTaskListComplete(i.tasks)&&a.push(t),a.join(`
|
|
5
|
+
`)}case`delete`:return`Deleted #${r.id}: ${r.subject}`;case`clear`:return`Closed task list (cleared ${r.count} tasks)`;case`list`:{let e=i.tasks;return r.includeDeleted||(e=e.filter(e=>e.status!==`deleted`)),r.statusFilter&&(e=e.filter(e=>e.status===r.statusFilter)),e.length===0?`No tasks`:e.map(o).join(`
|
|
6
|
+
`)}case`get`:return c(r.task,i);case`error`:return`Error: ${r.message}`}}function f(e,t,n,r){return{content:[{type:`text`,text:d(r,n)}],details:{action:e,params:t,tasks:n.tasks,nextId:n.nextId,rev:n.rev,...r.kind===`error`?{error:r.message}:{},...r.kind===`upsert`?{upsert:{applied:r.items.flatMap(e=>e.kind===`failed`?[]:[e.id]),failed:r.failed}}:{}}}}function p(e,t,n,r){return{content:[{type:`text`,text:n}],details:{action:`assign`,params:e,tasks:t.tasks,nextId:t.nextId,rev:t.rev,assignment:r}}}function m(e,t,n,r,i){return{content:[{type:`text`,text:i?`Error: ${i}`:r}],details:{action:e,params:t,tasks:n.tasks,nextId:n.nextId,rev:n.rev,...i?{error:i}:{}}}}exports.MSG_ALL_COMPLETE_CLEAR=t,exports.MSG_ASSIGN_PARTIAL=i,exports.MSG_UPSERT_NONE_APPLIED=r,exports.MSG_UPSERT_PARTIAL=n,exports.buildAssignmentResult=p,exports.buildTextResult=m,exports.buildToolResult=f,exports.formatAssignmentResults=a,exports.formatContent=d,exports.formatUpsertFailureText=u;
|
|
7
|
+
//# sourceMappingURL=responseEnvelope.cjs.map
|