@wrongstack/core 0.313.0 → 0.316.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chronicle/index.js +84 -6391
- package/dist/chronicle/legacy-journal-import.d.ts +0 -6
- package/dist/chronicle/metrics-ingest.d.ts +14 -0
- package/dist/chronicle/metrics-schema.d.ts +10 -1
- package/dist/chronicle/metrics-store.d.ts +20 -2
- package/dist/chronicle/project-server.js +98 -4874
- package/dist/chronicle/sink.d.ts +13 -0
- package/dist/chronicle/sqlite-journal.d.ts +20 -2
- package/dist/chunk-25LSLC3G.js +334 -0
- package/dist/chunk-27QIURLN.js +1073 -0
- package/dist/chunk-2FK4WTFF.js +207 -0
- package/dist/chunk-2YU4WVBW.js +134 -0
- package/dist/chunk-3AGWVSS7.js +4608 -0
- package/dist/chunk-3BDV7RL3.js +211 -0
- package/dist/chunk-3ECENVHL.js +325 -0
- package/dist/chunk-3XPVB7BA.js +135 -0
- package/dist/chunk-45WI72ZB.js +16884 -0
- package/dist/chunk-4BMVPOHO.js +3748 -0
- package/dist/chunk-4I7HGVVA.js +363 -0
- package/dist/chunk-4LCZVJVF.js +317 -0
- package/dist/chunk-4SJNS7OB.js +217 -0
- package/dist/chunk-4VWO3ZXL.js +342 -0
- package/dist/chunk-57GEWK5X.js +26 -0
- package/dist/chunk-5BMIE7QG.js +46 -0
- package/dist/chunk-5S437PRC.js +50 -0
- package/dist/chunk-5XDUGTKN.js +511 -0
- package/dist/chunk-5YPSXQXM.js +1443 -0
- package/dist/chunk-6FHWXLPT.js +10 -0
- package/dist/chunk-6H5GEOET.js +2406 -0
- package/dist/chunk-6NWEVFEL.js +151 -0
- package/dist/chunk-AYW5YINX.js +58 -0
- package/dist/chunk-B4AMLZPB.js +9 -0
- package/dist/chunk-B7F4WVP4.js +65 -0
- package/dist/chunk-BJHVULHO.js +55 -0
- package/dist/chunk-BPBKKBUK.js +2085 -0
- package/dist/chunk-BYD345OX.js +589 -0
- package/dist/chunk-C27KDLOX.js +279 -0
- package/dist/chunk-CU546ESW.js +597 -0
- package/dist/chunk-DLHHXUAM.js +172 -0
- package/dist/chunk-DOTHQSJ2.js +429 -0
- package/dist/chunk-DYLPMV4Q.js +711 -0
- package/dist/chunk-EODDVJBM.js +82 -0
- package/dist/chunk-F3JWNST7.js +361 -0
- package/dist/chunk-FC2ZGRF3.js +140 -0
- package/dist/chunk-FCBTO76Z.js +5786 -0
- package/dist/chunk-FHZVFYSL.js +396 -0
- package/dist/chunk-FNXVT7HF.js +52 -0
- package/dist/chunk-FWNLEZYG.js +259 -0
- package/dist/chunk-FXQLIX3K.js +211 -0
- package/dist/chunk-G5S3S5ZN.js +38 -0
- package/dist/chunk-GDQ7CZRQ.js +116 -0
- package/dist/chunk-GJJGJB2R.js +1374 -0
- package/dist/chunk-GTCU6DZ3.js +1 -0
- package/dist/chunk-HA4ZYA6T.js +178 -0
- package/dist/chunk-HI3JGZR2.js +188 -0
- package/dist/chunk-HMLIGAU7.js +395 -0
- package/dist/chunk-HXKZ7OBQ.js +303 -0
- package/dist/chunk-I7DALG7J.js +292 -0
- package/dist/chunk-IRUTEHCE.js +960 -0
- package/dist/chunk-IYFBFX34.js +86 -0
- package/dist/chunk-J2WRWR37.js +1104 -0
- package/dist/chunk-JFPJ6LLQ.js +129 -0
- package/dist/chunk-JMULFFLN.js +9 -0
- package/dist/chunk-JO4MGB6Z.js +1264 -0
- package/dist/chunk-JVKB2TBL.js +48 -0
- package/dist/chunk-JX7VBZDK.js +31 -0
- package/dist/chunk-K6BXGITA.js +931 -0
- package/dist/chunk-KDQJCT2J.js +45 -0
- package/dist/chunk-KJ2ZTQSL.js +47 -0
- package/dist/chunk-KZMSZV32.js +187 -0
- package/dist/chunk-LA7CLDRW.js +129 -0
- package/dist/chunk-LHOA5DWA.js +28 -0
- package/dist/chunk-LSMMOS2Z.js +119 -0
- package/dist/chunk-LX5QWLBL.js +27 -0
- package/dist/chunk-LXWCMQNJ.js +789 -0
- package/dist/chunk-M27LIEKV.js +2829 -0
- package/dist/chunk-MJPHJRAL.js +663 -0
- package/dist/chunk-MTL4O5YR.js +228 -0
- package/dist/chunk-NDBIPFNY.js +102 -0
- package/dist/chunk-NEMIWEXC.js +1199 -0
- package/dist/chunk-NHJ75HXY.js +1 -0
- package/dist/chunk-NIOAGFPB.js +1510 -0
- package/dist/chunk-NS52ISWS.js +355 -0
- package/dist/chunk-NSOFPKGT.js +5352 -0
- package/dist/chunk-NVIZG63R.js +757 -0
- package/dist/chunk-O37BQ65S.js +21 -0
- package/dist/chunk-OOYZPOXM.js +308 -0
- package/dist/chunk-OSGLYW5J.js +28 -0
- package/dist/chunk-PFCMSSUF.js +1640 -0
- package/dist/chunk-PFZO3C6H.js +14 -0
- package/dist/chunk-PGRVXIMY.js +158 -0
- package/dist/chunk-PHH7LD45.js +113 -0
- package/dist/chunk-PISBFBJN.js +109 -0
- package/dist/chunk-POOOIWE5.js +9 -0
- package/dist/chunk-PQNS3U7Z.js +1240 -0
- package/dist/chunk-QSTSJOCK.js +402 -0
- package/dist/chunk-RFQMOKWK.js +282 -0
- package/dist/chunk-RJIZEJ42.js +30 -0
- package/dist/chunk-RTOTNK3P.js +484 -0
- package/dist/chunk-RXKSDUAU.js +1172 -0
- package/dist/chunk-S45JPKQN.js +3317 -0
- package/dist/chunk-SAFHACFA.js +152 -0
- package/dist/chunk-SQJVFEBV.js +41 -0
- package/dist/chunk-SVT4RNTR.js +49 -0
- package/dist/chunk-SWUFN7XM.js +43 -0
- package/dist/chunk-SXMVYC5H.js +174 -0
- package/dist/chunk-SZ6AYUIZ.js +23 -0
- package/dist/chunk-TBRL2RCC.js +9 -0
- package/dist/chunk-TCCHINEF.js +655 -0
- package/dist/chunk-THEGTRAG.js +316 -0
- package/dist/chunk-TR4LQE7L.js +2256 -0
- package/dist/chunk-TRT2HRWZ.js +18 -0
- package/dist/chunk-TWJMGXCI.js +900 -0
- package/dist/chunk-U45AXT5D.js +1023 -0
- package/dist/chunk-U4FWBSO3.js +509 -0
- package/dist/chunk-UBGDX6FI.js +147 -0
- package/dist/chunk-UJILKYES.js +75 -0
- package/dist/chunk-ULMAQV3T.js +234 -0
- package/dist/chunk-VVBP6KGT.js +9 -0
- package/dist/chunk-W5VITDM2.js +168 -0
- package/dist/chunk-WAHQVNWT.js +194 -0
- package/dist/chunk-WBPVKEEE.js +227 -0
- package/dist/chunk-WGGYRBXH.js +5434 -0
- package/dist/chunk-WLYKU45P.js +5770 -0
- package/dist/chunk-WP7BVANJ.js +53 -0
- package/dist/chunk-WQQON3SV.js +473 -0
- package/dist/chunk-WQTOVMGV.js +119 -0
- package/dist/chunk-XBDP4QPW.js +7 -0
- package/dist/chunk-XEBHSJLT.js +103 -0
- package/dist/chunk-XF4VUMKW.js +231 -0
- package/dist/chunk-XQ2ECNK3.js +1 -0
- package/dist/chunk-Y5YXDM7D.js +74 -0
- package/dist/chunk-YOPAUVU4.js +2588 -0
- package/dist/chunk-YPT4A46F.js +362 -0
- package/dist/chunk-YWXT3JNM.js +425 -0
- package/dist/chunk-YY6APYUM.js +49 -0
- package/dist/chunk-Z2IJUO45.js +691 -0
- package/dist/chunk-ZHZ2Y2DH.js +1643 -0
- package/dist/chunk-ZT7JNIGX.js +152 -0
- package/dist/coordination/agent-monitor.d.ts +9 -1
- package/dist/coordination/agent-subagent-runner.d.ts +1 -1
- package/dist/coordination/agents/agent-prompts.d.ts +8 -0
- package/dist/coordination/agents/index.d.ts +33 -1
- package/dist/coordination/agents/index.js +184 -6269
- package/dist/coordination/agents/phase3-wave1-platform.d.ts +1 -3
- package/dist/coordination/agents/phase3-wave2-meta.d.ts +1 -3
- package/dist/coordination/agents/phase8-wave3-products.d.ts +1 -3
- package/dist/coordination/agents/phase9-wave4-platform-meta.d.ts +1 -3
- package/dist/coordination/agents/project-agent-identity.d.ts +11 -11
- package/dist/coordination/agents/types.d.ts +13 -2
- package/dist/coordination/brain-monitor.d.ts +30 -7
- package/dist/coordination/collab-debug.d.ts +1 -1
- package/dist/coordination/collab-pause.d.ts +1 -1
- package/dist/coordination/delegate-tool.d.ts +7 -5
- package/dist/coordination/director-kanban-queue-helpers.d.ts +1 -0
- package/dist/coordination/director-options.d.ts +7 -0
- package/dist/coordination/director-spawn-model.d.ts +17 -0
- package/dist/coordination/director-tools.d.ts +2 -2
- package/dist/coordination/director.d.ts +12 -0
- package/dist/coordination/dispatcher.d.ts +8 -0
- package/dist/coordination/fleet-bus.d.ts +35 -4
- package/dist/coordination/fleet-supervisor.d.ts +10 -2
- package/dist/coordination/fleet.d.ts +16 -7
- package/dist/coordination/index.d.ts +4 -0
- package/dist/coordination/index.js +402 -34324
- package/dist/coordination/kanban-dispatch-port.d.ts +2 -2
- package/dist/coordination/mailbox-http-router.d.ts +4 -3
- package/dist/coordination/mailbox-http-validation.d.ts +1 -1
- package/dist/coordination/mailbox-project-server.js +48 -3276
- package/dist/coordination/mailbox-types.d.ts +24 -6
- package/dist/coordination/model-tier-leader.d.ts +122 -0
- package/dist/coordination/model-tier.d.ts +122 -0
- package/dist/coordination/multi-agent-coordinator.d.ts +24 -0
- package/dist/coordination/origin-session.d.ts +16 -0
- package/dist/coordination/provider-status-tracker.d.ts +41 -5
- package/dist/coordination/session-note-hub.d.ts +44 -0
- package/dist/coordination/session-note-tool.d.ts +10 -0
- package/dist/core/agent.d.ts +15 -2
- package/dist/core/context.d.ts +22 -3
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +239 -12360
- package/dist/core/model-ref.js +5 -23
- package/dist/core/provider-runner.d.ts +36 -1
- package/dist/core/request-conversation-binding.d.ts +37 -0
- package/dist/core/session-notes.d.ts +25 -0
- package/dist/core/system-prompt-builder.d.ts +11 -2
- package/dist/core/system-prompt-variants.d.ts +78 -0
- package/dist/design/index.js +50 -1087
- package/dist/execution/auto-compaction-middleware.d.ts +11 -0
- package/dist/execution/autonomy-brain.d.ts +2 -1
- package/dist/execution/autonomy-prompt-contributor.d.ts +7 -2
- package/dist/execution/compaction-core.d.ts +4 -4
- package/dist/execution/eternal-autonomy.d.ts +1 -1
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/index.js +1615 -21895
- package/dist/execution/model-runtime.d.ts +0 -7
- package/dist/execution/parallel-eternal-engine.d.ts +7 -7
- package/dist/execution/prompt-enhancer.js +16 -535
- package/dist/execution/retry-policy.d.ts +31 -1
- package/dist/extension/index.js +7 -311
- package/dist/goal/index.js +33 -3435
- package/dist/hooks/index.js +14 -1138
- package/dist/hq/index.js +114 -5139
- package/dist/hq/persistence/event-log.d.ts +0 -1
- package/dist/hq/persistence.d.ts +4 -4
- package/dist/hq/protocol.js +21 -668
- package/dist/hq/publisher.d.ts +2 -0
- package/dist/index.d.ts +14 -11
- package/dist/index.js +1502 -92655
- package/dist/infrastructure/index.d.ts +4 -4
- package/dist/infrastructure/index.js +504 -5230
- package/dist/infrastructure/token-counter.d.ts +9 -0
- package/dist/kernel/events/agent-events.d.ts +77 -3
- package/dist/kernel/events/brain-events.d.ts +12 -0
- package/dist/kernel/events/provider-events.d.ts +22 -1
- package/dist/kernel/events/session-events.d.ts +14 -0
- package/dist/kernel/events/tool-events.d.ts +13 -0
- package/dist/kernel/index.js +14 -992
- package/dist/mailbox-attach.d.ts +1 -1
- package/dist/models/index.js +41 -1117
- package/dist/notifications/index.js +3 -108
- package/dist/observability/event-bridge.d.ts +25 -5
- package/dist/observability/index.d.ts +9 -8
- package/dist/observability/index.js +477 -631
- package/dist/observability/tool-usage-source.d.ts +65 -0
- package/dist/plugin/index.d.ts +5 -0
- package/dist/plugin/index.js +600 -14835
- package/dist/plugins/auto-review-plugin.d.ts +3 -2
- package/dist/plugins/review-finding-commands.d.ts +0 -8
- package/dist/plugins/review-finding-store.js +22 -0
- package/dist/plugins/review-finding-types.js +19 -0
- package/dist/plugins/review-report-integration.js +21 -0
- package/dist/plugins/review-report-store.js +20 -0
- package/dist/plugins/review-report-types.js +13 -0
- package/dist/prompts/index.js +14 -948
- package/dist/registry/index.js +9 -822
- package/dist/registry/tool-registry.d.ts +59 -9
- package/dist/registry-7N4O3E7W.js +14 -0
- package/dist/replay/index.js +6 -84
- package/dist/security/capabilities.d.ts +6 -0
- package/dist/security/file-permissions.d.ts +1 -1
- package/dist/security/index.js +161 -2235
- package/dist/security/permission-policy.d.ts +12 -1
- package/dist/security/secret-scrubber.d.ts +15 -0
- package/dist/session-catalog/index.d.ts +1 -0
- package/dist/session-catalog/index.js +41 -2103
- package/dist/session-catalog/project-server.js +59 -1435
- package/dist/session-catalog/protocol.d.ts +32 -1
- package/dist/session-catalog/registry.d.ts +17 -1
- package/dist/session-catalog/session-agents.d.ts +56 -0
- package/dist/session-catalog/store-rebuild.d.ts +14 -0
- package/dist/session-catalog/store-schema.d.ts +26 -0
- package/dist/session-catalog/store.d.ts +27 -1
- package/dist/session-note-attach.d.ts +9 -0
- package/dist/skills/index.js +35 -1578
- package/dist/statusline/index.d.ts +43 -0
- package/dist/statusline/index.js +102 -0
- package/dist/storage/board-store-port.d.ts +2 -2
- package/dist/storage/config-loader/in-project-policy.d.ts +29 -0
- package/dist/storage/config-loader.d.ts +3 -2
- package/dist/storage/file-session-writer.d.ts +4 -2
- package/dist/storage/goal-coordination.d.ts +6 -1
- package/dist/storage/goal-kanban.d.ts +4 -1
- package/dist/storage/index.d.ts +12 -4
- package/dist/storage/index.js +198 -15601
- package/dist/storage/input-history-store.d.ts +2 -4
- package/dist/storage/memory-curator.d.ts +133 -0
- package/dist/storage/session-agent-attribution.d.ts +39 -0
- package/dist/storage/session-doctor.d.ts +109 -0
- package/dist/storage/session-event-bridge.d.ts +5 -7
- package/dist/storage/session-outcome.d.ts +42 -0
- package/dist/storage/session-recovery.d.ts +55 -0
- package/dist/storage/session-store/load-session-data.d.ts +11 -0
- package/dist/storage/session-store/prune-helpers.d.ts +1 -1
- package/dist/storage/session-store/resume-session.d.ts +0 -2
- package/dist/storage/session-store/types.d.ts +8 -0
- package/dist/storage/session-store.d.ts +3 -3
- package/dist/storage/session-summary-tracker.d.ts +8 -1
- package/dist/storage/session-write-buffer.d.ts +18 -0
- package/dist/storage/session-writer-truncate.d.ts +2 -0
- package/dist/tasking/index.js +10 -676
- package/dist/tools/fallback-manage-tools.d.ts +6 -4
- package/dist/tools/index.js +52 -9590
- package/dist/tools/model-tier-set-tool.d.ts +66 -0
- package/dist/types/agent-bridge.d.ts +2 -1
- package/dist/types/config/autonomy.d.ts +5 -0
- package/dist/types/config/mcp-features.d.ts +7 -0
- package/dist/types/config/model-tiers.d.ts +148 -0
- package/dist/types/config/root.d.ts +9 -0
- package/dist/types/config/tools.d.ts +73 -0
- package/dist/types/config/ui.d.ts +1 -1
- package/dist/types/config.d.ts +1 -0
- package/dist/types/context.d.ts +2 -0
- package/dist/types/default-config.d.ts +6 -0
- package/dist/types/errors.d.ts +20 -1
- package/dist/types/index.d.ts +11 -9
- package/dist/types/index.js +131 -1342
- package/dist/types/multi-agent.d.ts +43 -0
- package/dist/types/plugin.d.ts +1 -1
- package/dist/types/provider-runner.d.ts +8 -0
- package/dist/types/provider.d.ts +15 -0
- package/dist/types/runtime-capability-manifest.d.ts +1 -1
- package/dist/types/secret-scrubber.d.ts +15 -0
- package/dist/types/session-markers.d.ts +37 -10
- package/dist/types/session-markers.js +8 -144
- package/dist/types/session-timeline.d.ts +197 -0
- package/dist/types/session-timeline.js +12 -0
- package/dist/types/session.d.ts +172 -11
- package/dist/types/system-prompt.d.ts +27 -0
- package/dist/utils/config-backup.d.ts +9 -1
- package/dist/utils/error.js +3 -4
- package/dist/utils/expect-defined.js +3 -9
- package/dist/utils/heap-watchdog.js +6 -706
- package/dist/utils/index.js +271 -5685
- package/dist/utils/message-invariants.d.ts +4 -1
- package/dist/utils/regex-guard.d.ts +1 -1
- package/dist/utils/sage-output-block.js +5 -42
- package/dist/utils/socket-path.d.ts +1 -1
- package/dist/utils/token-estimate.d.ts +6 -2
- package/dist/utils/wstack-paths.d.ts +2 -0
- package/dist/wiring/proxy-rewrite.d.ts +46 -0
- package/dist/wiring/proxy-rewrite.js +24 -121
- package/dist/worktree/index.js +6 -887
- package/instructions/agents/explore-companion.md +45 -18
- package/instructions/agents/memory-curator.md +34 -22
- package/instructions/coordination/director-preamble.md +12 -7
- package/instructions/coordination/subagent-baseline.md +26 -5
- package/instructions/leader-after-task.md +4 -1
- package/instructions/llm/chimera-review.md +30 -9
- package/instructions/llm/memory-curator.md +31 -0
- package/instructions/sections/tool/delegation-compact.md +2 -0
- package/instructions/sections/tool/delegation-full.md +5 -1
- package/instructions/sections/tool/mailbox-compact.md +5 -1
- package/instructions/sections/tool/mailbox-full.md +3 -0
- package/instructions/sections/tool/session-note-compact.md +3 -0
- package/instructions/sections/tool/session-note-full.md +15 -0
- package/instructions/system-lite.md +9 -4
- package/instructions/system-pro.md +66 -143
- package/instructions/system.md +73 -175
- package/package.json +32 -4
- package/dist/coordination/agents.d.ts +0 -8
- package/dist/coordination/transport.d.ts +0 -2
- package/dist/storage/session-writer/session-writer-summary-tracker.d.ts +0 -28
package/dist/tasking/index.js
CHANGED
|
@@ -1,679 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
async listGraphs() {
|
|
12
|
-
return Array.from(this.graphs.values()).map((graph) => ({
|
|
13
|
-
id: graph.id,
|
|
14
|
-
title: graph.title,
|
|
15
|
-
updatedAt: graph.updatedAt
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
async deleteGraph(id) {
|
|
19
|
-
this.graphs.delete(id);
|
|
20
|
-
}
|
|
21
|
-
cloneGraph(graph) {
|
|
22
|
-
return {
|
|
23
|
-
...graph,
|
|
24
|
-
nodes: new Map(graph.nodes),
|
|
25
|
-
edges: [...graph.edges],
|
|
26
|
-
rootNodes: [...graph.rootNodes]
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// src/utils/error.ts
|
|
32
|
-
function toErrorMessage(err) {
|
|
33
|
-
return err instanceof Error ? err.message : String(err);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// src/types/errors.ts
|
|
37
|
-
var ERROR_CODES = {
|
|
38
|
-
// Provider
|
|
39
|
-
PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED",
|
|
40
|
-
PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
|
|
41
|
-
PROVIDER_OVERLOADED: "PROVIDER_OVERLOADED",
|
|
42
|
-
PROVIDER_INVALID_REQUEST: "PROVIDER_INVALID_REQUEST",
|
|
43
|
-
PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR",
|
|
44
|
-
PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR",
|
|
45
|
-
PROVIDER_CONTEXT_OVERFLOW: "PROVIDER_CONTEXT_OVERFLOW",
|
|
46
|
-
// Tool
|
|
47
|
-
TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
|
|
48
|
-
TOOL_PERMISSION_DENIED: "TOOL_PERMISSION_DENIED",
|
|
49
|
-
TOOL_EXECUTION_FAILED: "TOOL_EXECUTION_FAILED",
|
|
50
|
-
TOOL_TIMEOUT: "TOOL_TIMEOUT",
|
|
51
|
-
TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID",
|
|
52
|
-
// Config
|
|
53
|
-
CONFIG_INVALID: "CONFIG_INVALID",
|
|
54
|
-
CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
|
|
55
|
-
CONFIG_PARSE_FAILED: "CONFIG_PARSE_FAILED",
|
|
56
|
-
CONFIG_MIGRATION_NEEDED: "CONFIG_MIGRATION_NEEDED",
|
|
57
|
-
// Plugin
|
|
58
|
-
PLUGIN_LOAD_FAILED: "PLUGIN_LOAD_FAILED",
|
|
59
|
-
PLUGIN_API_MISMATCH: "PLUGIN_API_MISMATCH",
|
|
60
|
-
PLUGIN_MISSING_DEPENDENCY: "PLUGIN_MISSING_DEPENDENCY",
|
|
61
|
-
// Agent
|
|
62
|
-
AGENT_ITERATION_LIMIT: "AGENT_ITERATION_LIMIT",
|
|
63
|
-
AGENT_CONTEXT_OVERFLOW: "AGENT_CONTEXT_OVERFLOW",
|
|
64
|
-
AGENT_ABORTED: "AGENT_ABORTED",
|
|
65
|
-
AGENT_RUN_FAILED: "AGENT_RUN_FAILED",
|
|
66
|
-
// Session
|
|
67
|
-
SESSION_NOT_FOUND: "SESSION_NOT_FOUND",
|
|
68
|
-
SESSION_CORRUPTED: "SESSION_CORRUPTED",
|
|
69
|
-
SESSION_WRITE_FAILED: "SESSION_WRITE_FAILED",
|
|
70
|
-
// Container / Registry
|
|
71
|
-
CONTAINER_TOKEN_ALREADY_BOUND: "CONTAINER_TOKEN_ALREADY_BOUND",
|
|
72
|
-
CONTAINER_TOKEN_NOT_BOUND: "CONTAINER_TOKEN_NOT_BOUND",
|
|
73
|
-
CONTAINER_CIRCULAR_DEPENDENCY: "CONTAINER_CIRCULAR_DEPENDENCY",
|
|
74
|
-
REGISTRY_DUPLICATE: "REGISTRY_DUPLICATE",
|
|
75
|
-
REGISTRY_NOT_FOUND: "REGISTRY_NOT_FOUND",
|
|
76
|
-
REGISTRY_INVALID: "REGISTRY_INVALID",
|
|
77
|
-
// File system
|
|
78
|
-
FS_READ_FAILED: "FS_READ_FAILED",
|
|
79
|
-
FS_WRITE_FAILED: "FS_WRITE_FAILED",
|
|
80
|
-
FS_MKDIR_FAILED: "FS_MKDIR_FAILED",
|
|
81
|
-
FS_DELETE_FAILED: "FS_DELETE_FAILED",
|
|
82
|
-
FS_ATOMIC_WRITE_FAILED: "FS_ATOMIC_WRITE_FAILED",
|
|
83
|
-
// SDD (Spec-Driven Development)
|
|
84
|
-
SDD_VALIDATION_FAILED: "SDD_VALIDATION_FAILED",
|
|
85
|
-
SDD_PARSE_FAILED: "SDD_PARSE_FAILED",
|
|
86
|
-
SDD_INVALID_STATE: "SDD_INVALID_STATE",
|
|
87
|
-
SDD_NOT_READY: "SDD_NOT_READY",
|
|
88
|
-
// General
|
|
89
|
-
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
90
|
-
PARSE_FAILED: "PARSE_FAILED",
|
|
91
|
-
UNKNOWN: "UNKNOWN"
|
|
92
|
-
};
|
|
93
|
-
var WrongStackError = class extends Error {
|
|
94
|
-
code;
|
|
95
|
-
subsystem;
|
|
96
|
-
severity;
|
|
97
|
-
recoverable;
|
|
98
|
-
context;
|
|
99
|
-
constructor(opts) {
|
|
100
|
-
super(opts.message, { cause: opts.cause });
|
|
101
|
-
this.name = "WrongStackError";
|
|
102
|
-
this.code = opts.code;
|
|
103
|
-
this.subsystem = opts.subsystem;
|
|
104
|
-
this.severity = opts.severity ?? "error";
|
|
105
|
-
this.recoverable = opts.recoverable ?? false;
|
|
106
|
-
this.context = opts.context;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Render a one-line user-facing description.
|
|
110
|
-
* Subclasses should override for domain-specific formatting.
|
|
111
|
-
*/
|
|
112
|
-
describe() {
|
|
113
|
-
const ctx = this.context ? ` ${formatContext(this.context)}` : "";
|
|
114
|
-
return `${this.code}: ${this.message}${ctx}`;
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
function formatContext(ctx) {
|
|
118
|
-
const parts = Object.entries(ctx).filter(([, v]) => v !== void 0).slice(0, 3).map(([k, v]) => `${k}=${String(v)}`);
|
|
119
|
-
return parts.length > 0 ? `[${parts.join(" ")}]` : "";
|
|
120
|
-
}
|
|
121
|
-
var SddError = class extends WrongStackError {
|
|
122
|
-
constructor(opts) {
|
|
123
|
-
super({
|
|
124
|
-
message: opts.message,
|
|
125
|
-
code: opts.code,
|
|
126
|
-
subsystem: "sdd",
|
|
127
|
-
severity: opts.code === ERROR_CODES.SDD_PARSE_FAILED ? "warning" : "error",
|
|
128
|
-
recoverable: opts.code === ERROR_CODES.SDD_NOT_READY,
|
|
129
|
-
context: opts.context,
|
|
130
|
-
cause: opts.cause
|
|
131
|
-
});
|
|
132
|
-
this.name = "SddError";
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// src/types/task-graph.ts
|
|
137
|
-
function computeTaskProgress(graph) {
|
|
138
|
-
let completed = 0;
|
|
139
|
-
let pending = 0;
|
|
140
|
-
let inProgress = 0;
|
|
141
|
-
let blocked = 0;
|
|
142
|
-
let failed = 0;
|
|
143
|
-
let review = 0;
|
|
144
|
-
let estimatedHours = 0;
|
|
145
|
-
let actualHours = 0;
|
|
146
|
-
for (const n of graph.nodes.values()) {
|
|
147
|
-
switch (n.status) {
|
|
148
|
-
case "completed":
|
|
149
|
-
completed++;
|
|
150
|
-
break;
|
|
151
|
-
case "pending":
|
|
152
|
-
pending++;
|
|
153
|
-
break;
|
|
154
|
-
case "in_progress":
|
|
155
|
-
inProgress++;
|
|
156
|
-
break;
|
|
157
|
-
case "blocked":
|
|
158
|
-
blocked++;
|
|
159
|
-
break;
|
|
160
|
-
case "failed":
|
|
161
|
-
failed++;
|
|
162
|
-
break;
|
|
163
|
-
case "review":
|
|
164
|
-
review++;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
estimatedHours += n.estimateHours ?? 0;
|
|
168
|
-
actualHours += n.actualHours ?? 0;
|
|
169
|
-
}
|
|
170
|
-
const total = graph.nodes.size;
|
|
171
|
-
return {
|
|
172
|
-
total,
|
|
173
|
-
pending,
|
|
174
|
-
inProgress,
|
|
175
|
-
blocked,
|
|
176
|
-
failed,
|
|
177
|
-
review,
|
|
178
|
-
completed,
|
|
179
|
-
percentComplete: total > 0 ? Math.round(completed / total * 100) : 0,
|
|
180
|
-
estimatedHours,
|
|
181
|
-
actualHours
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function topologicalSort(graph) {
|
|
185
|
-
const visited = /* @__PURE__ */ new Set();
|
|
186
|
-
const inStack = /* @__PURE__ */ new Set();
|
|
187
|
-
const result = [];
|
|
188
|
-
function visit(id) {
|
|
189
|
-
if (inStack.has(id)) return;
|
|
190
|
-
if (visited.has(id)) return;
|
|
191
|
-
if (!graph.nodes.has(id)) return;
|
|
192
|
-
visited.add(id);
|
|
193
|
-
inStack.add(id);
|
|
194
|
-
for (const edge of graph.edges) {
|
|
195
|
-
if (edge.from === id) visit(edge.to);
|
|
196
|
-
}
|
|
197
|
-
inStack.delete(id);
|
|
198
|
-
result.push(id);
|
|
199
|
-
}
|
|
200
|
-
for (const rootId of graph.rootNodes) {
|
|
201
|
-
visit(rootId);
|
|
202
|
-
}
|
|
203
|
-
return result;
|
|
204
|
-
}
|
|
205
|
-
function serializeTaskGraph(graph) {
|
|
206
|
-
return {
|
|
207
|
-
...graph,
|
|
208
|
-
nodes: Array.from(graph.nodes.values())
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
function deserializeTaskGraph(input) {
|
|
212
|
-
const nodes = /* @__PURE__ */ new Map();
|
|
213
|
-
if (Array.isArray(input.nodes)) {
|
|
214
|
-
for (const entry of input.nodes) {
|
|
215
|
-
if (Array.isArray(entry)) nodes.set(entry[0], { ...entry[1], id: entry[1].id || entry[0] });
|
|
216
|
-
else nodes.set(entry.id, entry);
|
|
217
|
-
}
|
|
218
|
-
} else {
|
|
219
|
-
for (const [id, node] of Object.entries(input.nodes)) {
|
|
220
|
-
nodes.set(id, { ...node, id: node.id || id });
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return { ...input, nodes };
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// src/tasking/task-tracker.ts
|
|
227
|
-
var TaskTracker = class _TaskTracker {
|
|
228
|
-
constructor(opts) {
|
|
229
|
-
this.opts = opts;
|
|
230
|
-
}
|
|
231
|
-
opts;
|
|
232
|
-
graph = null;
|
|
233
|
-
transitions = [];
|
|
234
|
-
listeners = [];
|
|
235
|
-
/**
|
|
236
|
-
* Re-entrancy guard for status cascades: true while an auto-block /
|
|
237
|
-
* auto-unblock cascade is running. Listener-driven mutations during a
|
|
238
|
-
* cascade still record their own primary transition — only their
|
|
239
|
-
* cascading is skipped (prevents unbounded recursion).
|
|
240
|
-
*/
|
|
241
|
-
cascading = false;
|
|
242
|
-
static MAX_TRANSITIONS = 1e4;
|
|
243
|
-
/**
|
|
244
|
-
* Subscribe to live task mutations (add / update / status change). Returns an
|
|
245
|
-
* unsubscribe fn. This is the hook the board projector uses to stream a live
|
|
246
|
-
* snapshot — the tracker was previously fire-and-forget with no observability.
|
|
247
|
-
*/
|
|
248
|
-
subscribe(listener) {
|
|
249
|
-
this.listeners.push(listener);
|
|
250
|
-
return () => {
|
|
251
|
-
const i = this.listeners.indexOf(listener);
|
|
252
|
-
if (i >= 0) this.listeners.splice(i, 1);
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
notifyChange(change) {
|
|
256
|
-
for (const l of this.listeners) {
|
|
257
|
-
try {
|
|
258
|
-
l(change);
|
|
259
|
-
} catch {
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Attach an existing graph (used by PhaseOrchestrator to associate a tracker
|
|
265
|
-
* with a phase's pre-built task graph without re-creating it).
|
|
266
|
-
*/
|
|
267
|
-
setGraph(graph) {
|
|
268
|
-
this.graph = graph;
|
|
269
|
-
}
|
|
270
|
-
async createGraph(specId, title) {
|
|
271
|
-
this.graph = {
|
|
272
|
-
id: crypto.randomUUID(),
|
|
273
|
-
specId,
|
|
274
|
-
title,
|
|
275
|
-
nodes: /* @__PURE__ */ new Map(),
|
|
276
|
-
edges: [],
|
|
277
|
-
rootNodes: [],
|
|
278
|
-
createdAt: Date.now(),
|
|
279
|
-
updatedAt: Date.now()
|
|
280
|
-
};
|
|
281
|
-
await this.opts.store.saveGraph(this.graph);
|
|
282
|
-
return this.graph;
|
|
283
|
-
}
|
|
284
|
-
async loadGraph(id) {
|
|
285
|
-
this.graph = await this.opts.store.loadGraph(id);
|
|
286
|
-
return this.graph;
|
|
287
|
-
}
|
|
288
|
-
addNode(node) {
|
|
289
|
-
if (!this.graph)
|
|
290
|
-
throw new SddError({
|
|
291
|
-
message: "No graph loaded",
|
|
292
|
-
code: ERROR_CODES.SDD_INVALID_STATE
|
|
293
|
-
});
|
|
294
|
-
const now = Date.now();
|
|
295
|
-
const newNode = {
|
|
296
|
-
...node,
|
|
297
|
-
id: crypto.randomUUID(),
|
|
298
|
-
status: node.status ?? "pending",
|
|
299
|
-
createdAt: now,
|
|
300
|
-
updatedAt: now
|
|
301
|
-
};
|
|
302
|
-
this.graph.nodes.set(newNode.id, newNode);
|
|
303
|
-
if (!node.parentId) {
|
|
304
|
-
this.graph.rootNodes.push(newNode.id);
|
|
305
|
-
}
|
|
306
|
-
this.graph.updatedAt = now;
|
|
307
|
-
this.persist();
|
|
308
|
-
this.notifyChange({ type: "node_added", nodeId: newNode.id, node: newNode });
|
|
309
|
-
return newNode;
|
|
310
|
-
}
|
|
311
|
-
addEdge(from, to, type = "depends_on") {
|
|
312
|
-
if (!this.graph)
|
|
313
|
-
throw new SddError({
|
|
314
|
-
message: "No graph loaded",
|
|
315
|
-
code: ERROR_CODES.SDD_INVALID_STATE
|
|
316
|
-
});
|
|
317
|
-
if (!this.graph.nodes.has(from) || !this.graph.nodes.has(to)) {
|
|
318
|
-
throw new SddError({
|
|
319
|
-
message: `Cannot add ${type} edge ${from} -> ${to}: endpoint task is not in the graph`,
|
|
320
|
-
code: ERROR_CODES.SDD_NOT_READY,
|
|
321
|
-
context: { from, to, type }
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
if (from === to) {
|
|
325
|
-
throw new SddError({
|
|
326
|
-
message: `Cannot add ${type} edge: self-loop on task ${from}`,
|
|
327
|
-
code: ERROR_CODES.SDD_INVALID_STATE,
|
|
328
|
-
context: { nodeId: from, type }
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
if (this.graph.edges.some((e) => e.from === from && e.to === to && e.type === type)) return;
|
|
332
|
-
if (type === "depends_on" && this.dependsOnTransitively(from, to, /* @__PURE__ */ new Set())) {
|
|
333
|
-
throw new SddError({
|
|
334
|
-
message: `Cannot add depends_on edge ${from} -> ${to}: it would create a dependency cycle`,
|
|
335
|
-
code: ERROR_CODES.SDD_INVALID_STATE,
|
|
336
|
-
context: { from, to }
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
this.graph.edges.push({
|
|
340
|
-
id: crypto.randomUUID(),
|
|
341
|
-
from,
|
|
342
|
-
to,
|
|
343
|
-
type
|
|
344
|
-
});
|
|
345
|
-
this.graph.updatedAt = Date.now();
|
|
346
|
-
this.persist();
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Declare that `taskId` depends on `depId` (a `depends_on` edge `depId → taskId`),
|
|
350
|
-
* guarding against self-loops, duplicates, missing nodes, and cycles. Returns
|
|
351
|
-
* true if the dependency now holds (added or already present), false if it was
|
|
352
|
-
* rejected (would create a cycle / unknown node). This is the safe entry point
|
|
353
|
-
* for wiring agent-declared `dependsOn` references into the graph.
|
|
354
|
-
*/
|
|
355
|
-
addDependency(depId, taskId) {
|
|
356
|
-
if (!this.graph) return false;
|
|
357
|
-
if (depId === taskId) return false;
|
|
358
|
-
if (!this.graph.nodes.has(depId) || !this.graph.nodes.has(taskId)) return false;
|
|
359
|
-
if (this.getBlockers(taskId).includes(depId)) return true;
|
|
360
|
-
if (this.dependsOnTransitively(depId, taskId, /* @__PURE__ */ new Set())) return false;
|
|
361
|
-
this.addEdge(depId, taskId, "depends_on");
|
|
362
|
-
return true;
|
|
363
|
-
}
|
|
364
|
-
/** True when `taskId` transitively depends on `targetId` (follows depends_on blockers). */
|
|
365
|
-
dependsOnTransitively(taskId, targetId, seen) {
|
|
366
|
-
if (taskId === targetId) return true;
|
|
367
|
-
if (seen.has(taskId)) return false;
|
|
368
|
-
seen.add(taskId);
|
|
369
|
-
for (const blocker of this.getBlockers(taskId)) {
|
|
370
|
-
if (this.dependsOnTransitively(blocker, targetId, seen)) return true;
|
|
371
|
-
}
|
|
372
|
-
return false;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Merge `patch` into a node's `metadata` (used for per-task model/provider/
|
|
376
|
-
* fallback assignment and the cancel marker). Persists + notifies as a node
|
|
377
|
-
* update. No-op if the node is missing.
|
|
378
|
-
*/
|
|
379
|
-
patchMetadata(id, patch) {
|
|
380
|
-
if (!this.graph) return;
|
|
381
|
-
const node = this.graph.nodes.get(id);
|
|
382
|
-
if (!node) return;
|
|
383
|
-
node.metadata = { ...node.metadata, ...patch };
|
|
384
|
-
node.updatedAt = Date.now();
|
|
385
|
-
this.graph.updatedAt = node.updatedAt;
|
|
386
|
-
this.persist();
|
|
387
|
-
this.notifyChange({ type: "node_updated", nodeId: id, node });
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Remove a node and every edge touching it. Intended for deleting a task that
|
|
391
|
-
* has not started yet — callers must gate on status (do not remove a running
|
|
392
|
-
* task). Dependents simply lose this blocker (re-evaluated by `canStart`).
|
|
393
|
-
* Returns true if a node was removed.
|
|
394
|
-
*/
|
|
395
|
-
removeNode(id) {
|
|
396
|
-
if (!this.graph) return false;
|
|
397
|
-
const node = this.graph.nodes.get(id);
|
|
398
|
-
if (!node) return false;
|
|
399
|
-
if (node.specRequirementId && this.graph.requiredRequirementIds?.includes(node.specRequirementId) && !Array.from(this.graph.nodes.values()).some(
|
|
400
|
-
(candidate) => candidate.id !== id && candidate.specRequirementId === node.specRequirementId
|
|
401
|
-
)) {
|
|
402
|
-
return false;
|
|
403
|
-
}
|
|
404
|
-
this.graph.nodes.delete(id);
|
|
405
|
-
this.graph.edges = this.graph.edges.filter((e) => e.from !== id && e.to !== id);
|
|
406
|
-
this.graph.rootNodes = this.graph.rootNodes.filter((r) => r !== id);
|
|
407
|
-
for (const n of this.graph.nodes.values()) {
|
|
408
|
-
if (n.children?.includes(id)) n.children = n.children.filter((c) => c !== id);
|
|
409
|
-
}
|
|
410
|
-
this.graph.updatedAt = Date.now();
|
|
411
|
-
this.persist();
|
|
412
|
-
this.notifyChange({ type: "node_removed", nodeId: id, node });
|
|
413
|
-
return true;
|
|
414
|
-
}
|
|
415
|
-
updateNodeStatus(id, status, reason) {
|
|
416
|
-
if (!this.graph)
|
|
417
|
-
throw new SddError({
|
|
418
|
-
message: "No graph loaded",
|
|
419
|
-
code: ERROR_CODES.SDD_INVALID_STATE
|
|
420
|
-
});
|
|
421
|
-
const node = this.graph.nodes.get(id);
|
|
422
|
-
if (!node)
|
|
423
|
-
throw new SddError({
|
|
424
|
-
message: `Node ${id} not found`,
|
|
425
|
-
code: ERROR_CODES.SDD_NOT_READY,
|
|
426
|
-
context: { nodeId: id }
|
|
427
|
-
});
|
|
428
|
-
const from = node.status;
|
|
429
|
-
const now = Date.now();
|
|
430
|
-
node.status = status;
|
|
431
|
-
node.updatedAt = now;
|
|
432
|
-
if (status === "completed") {
|
|
433
|
-
node.completedAt = now;
|
|
434
|
-
node.startedAt = node.startedAt ?? now;
|
|
435
|
-
}
|
|
436
|
-
if (status === "in_progress") {
|
|
437
|
-
node.startedAt = now;
|
|
438
|
-
}
|
|
439
|
-
this.transitions.push({ nodeId: id, from, to: status, timestamp: now, reason });
|
|
440
|
-
if (this.transitions.length > _TaskTracker.MAX_TRANSITIONS) {
|
|
441
|
-
this.transitions.splice(0, this.transitions.length - _TaskTracker.MAX_TRANSITIONS);
|
|
442
|
-
}
|
|
443
|
-
if (status === "completed") {
|
|
444
|
-
this.unblockDependents(id);
|
|
445
|
-
}
|
|
446
|
-
if (status === "in_progress") {
|
|
447
|
-
this.checkAndBlockIfNeeded(id);
|
|
448
|
-
}
|
|
449
|
-
this.graph.updatedAt = now;
|
|
450
|
-
this.persist();
|
|
451
|
-
this.notifyChange({
|
|
452
|
-
type: "status_changed",
|
|
453
|
-
nodeId: id,
|
|
454
|
-
node,
|
|
455
|
-
transition: { nodeId: id, from, to: status, timestamp: now, reason }
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
updateNode(id, patch) {
|
|
459
|
-
if (!this.graph)
|
|
460
|
-
throw new SddError({
|
|
461
|
-
message: "No graph loaded",
|
|
462
|
-
code: ERROR_CODES.SDD_INVALID_STATE
|
|
463
|
-
});
|
|
464
|
-
const node = this.graph.nodes.get(id);
|
|
465
|
-
if (!node)
|
|
466
|
-
throw new SddError({
|
|
467
|
-
message: `Node ${id} not found`,
|
|
468
|
-
code: ERROR_CODES.SDD_NOT_READY,
|
|
469
|
-
context: { nodeId: id }
|
|
470
|
-
});
|
|
471
|
-
if (patch.title !== void 0) node.title = patch.title;
|
|
472
|
-
if (patch.description !== void 0) node.description = patch.description;
|
|
473
|
-
if (patch.priority !== void 0) node.priority = patch.priority;
|
|
474
|
-
if (patch.estimateHours !== void 0) node.estimateHours = patch.estimateHours;
|
|
475
|
-
if (patch.tags !== void 0) node.tags = patch.tags;
|
|
476
|
-
if (patch.assignee !== void 0) node.assignee = patch.assignee;
|
|
477
|
-
node.updatedAt = Date.now();
|
|
478
|
-
this.graph.updatedAt = node.updatedAt;
|
|
479
|
-
this.persist();
|
|
480
|
-
this.notifyChange({ type: "node_updated", nodeId: id, node });
|
|
481
|
-
}
|
|
482
|
-
getNode(id) {
|
|
483
|
-
return this.graph?.nodes.get(id);
|
|
484
|
-
}
|
|
485
|
-
getAllNodes(filter, sort) {
|
|
486
|
-
if (!this.graph) return [];
|
|
487
|
-
let nodes = Array.from(this.graph.nodes.values());
|
|
488
|
-
if (filter) {
|
|
489
|
-
nodes = nodes.filter((n) => {
|
|
490
|
-
if (filter.status?.length && !filter.status.includes(n.status)) return false;
|
|
491
|
-
if (filter.priority?.length && !filter.priority.includes(n.priority)) return false;
|
|
492
|
-
if (filter.type?.length && !filter.type.includes(n.type)) return false;
|
|
493
|
-
if (filter.assignee?.length && n.assignee && !filter.assignee.includes(n.assignee))
|
|
494
|
-
return false;
|
|
495
|
-
if (filter.tags?.length && n.tags && !n.tags.some((t) => filter.tags?.includes(t)))
|
|
496
|
-
return false;
|
|
497
|
-
if (filter.specRequirementId && n.specRequirementId !== filter.specRequirementId)
|
|
498
|
-
return false;
|
|
499
|
-
return true;
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
if (sort) {
|
|
503
|
-
nodes.sort((a, b) => {
|
|
504
|
-
const cmp = compareByField(a, b, sort.field);
|
|
505
|
-
return sort.direction === "asc" ? cmp : -cmp;
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
return nodes;
|
|
509
|
-
}
|
|
510
|
-
getChildren(parentId) {
|
|
511
|
-
if (!this.graph) return [];
|
|
512
|
-
return Array.from(this.graph.nodes.values()).filter((n) => n.parentId === parentId);
|
|
513
|
-
}
|
|
514
|
-
getDependents(taskId) {
|
|
515
|
-
if (!this.graph) return [];
|
|
516
|
-
return this.graph.edges.filter((e) => e.from === taskId && e.type === "depends_on").map((e) => e.to);
|
|
517
|
-
}
|
|
518
|
-
getBlockers(taskId) {
|
|
519
|
-
if (!this.graph) return [];
|
|
520
|
-
return this.graph.edges.filter((e) => e.to === taskId && e.type === "depends_on").map((e) => e.from);
|
|
521
|
-
}
|
|
522
|
-
canStart(taskId) {
|
|
523
|
-
const blockers = this.getBlockers(taskId);
|
|
524
|
-
return blockers.every((id) => {
|
|
525
|
-
const node = this.graph?.nodes.get(id);
|
|
526
|
-
return node?.status === "completed" || node?.status === "failed";
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
getProgress() {
|
|
530
|
-
if (!this.graph) {
|
|
531
|
-
return {
|
|
532
|
-
total: 0,
|
|
533
|
-
pending: 0,
|
|
534
|
-
inProgress: 0,
|
|
535
|
-
blocked: 0,
|
|
536
|
-
failed: 0,
|
|
537
|
-
review: 0,
|
|
538
|
-
completed: 0,
|
|
539
|
-
percentComplete: 0,
|
|
540
|
-
estimatedHours: 0,
|
|
541
|
-
actualHours: 0
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
return computeTaskProgress(this.graph);
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Recorded transitions in insertion order (oldest first — the array is
|
|
548
|
-
* trimmed from the front). With `taskId`, only that task's transitions are
|
|
549
|
-
* returned, still oldest-first; a consumer wanting newest-first reverses
|
|
550
|
-
* the result. Per-task filtering is possible because every TaskTransition
|
|
551
|
-
* carries `nodeId` (BIZ-005).
|
|
552
|
-
*/
|
|
553
|
-
getTransitions(taskId) {
|
|
554
|
-
return taskId === void 0 ? [...this.transitions] : this.transitions.filter((t) => t.nodeId === taskId);
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* Record a cascade-driven status change (BIZ-003): mutate the node, push a
|
|
558
|
-
* TaskTransition, persist, and notify subscribers — the same effects an
|
|
559
|
-
* explicit updateNodeStatus produces — so the board projector's live
|
|
560
|
-
* snapshot and the transition log observe auto-block/auto-unblock.
|
|
561
|
-
*/
|
|
562
|
-
recordCascadeStatusChange(nodeId, node, to, reason) {
|
|
563
|
-
const from = node.status;
|
|
564
|
-
if (from === to) return;
|
|
565
|
-
const now = Date.now();
|
|
566
|
-
node.status = to;
|
|
567
|
-
node.updatedAt = now;
|
|
568
|
-
if (this.graph) this.graph.updatedAt = now;
|
|
569
|
-
this.transitions.push({ nodeId, from, to, timestamp: now, reason });
|
|
570
|
-
if (this.transitions.length > _TaskTracker.MAX_TRANSITIONS) {
|
|
571
|
-
this.transitions.splice(0, this.transitions.length - _TaskTracker.MAX_TRANSITIONS);
|
|
572
|
-
}
|
|
573
|
-
this.persist();
|
|
574
|
-
this.notifyChange({
|
|
575
|
-
type: "status_changed",
|
|
576
|
-
nodeId,
|
|
577
|
-
node,
|
|
578
|
-
transition: { nodeId, from, to, timestamp: now, reason }
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
unblockDependents(completedId) {
|
|
582
|
-
if (!this.graph || this.cascading) return;
|
|
583
|
-
this.cascading = true;
|
|
584
|
-
try {
|
|
585
|
-
const dependents = this.getDependents(completedId);
|
|
586
|
-
for (const depId of dependents) {
|
|
587
|
-
const dep = this.graph.nodes.get(depId);
|
|
588
|
-
if (dep?.status !== "blocked") continue;
|
|
589
|
-
const remainingBlockers = this.getBlockers(depId);
|
|
590
|
-
const allUnblocked = remainingBlockers.every((id) => {
|
|
591
|
-
const blocker = this.graph?.nodes.get(id);
|
|
592
|
-
return blocker?.status === "completed" || blocker?.status === "failed";
|
|
593
|
-
});
|
|
594
|
-
if (allUnblocked) {
|
|
595
|
-
this.recordCascadeStatusChange(
|
|
596
|
-
depId,
|
|
597
|
-
dep,
|
|
598
|
-
"pending",
|
|
599
|
-
`auto-unblocked: blocker ${completedId} reached a terminal state`
|
|
600
|
-
);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
} finally {
|
|
604
|
-
this.cascading = false;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
checkAndBlockIfNeeded(taskId) {
|
|
608
|
-
if (!this.graph || this.cascading) return;
|
|
609
|
-
this.cascading = true;
|
|
610
|
-
try {
|
|
611
|
-
const blockers = this.getBlockers(taskId);
|
|
612
|
-
const incomplete = blockers.filter((id) => {
|
|
613
|
-
const blocker = this.graph?.nodes.get(id);
|
|
614
|
-
return blocker?.status !== "completed" && blocker?.status !== "failed";
|
|
615
|
-
});
|
|
616
|
-
if (incomplete.length > 0) {
|
|
617
|
-
const node = this.graph.nodes.get(taskId);
|
|
618
|
-
if (node) {
|
|
619
|
-
this.recordCascadeStatusChange(
|
|
620
|
-
taskId,
|
|
621
|
-
node,
|
|
622
|
-
"blocked",
|
|
623
|
-
`auto-blocked: incomplete blocker(s) ${incomplete.join(", ")}`
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
} finally {
|
|
628
|
-
this.cascading = false;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
/**
|
|
632
|
-
* Fire-and-forget persistence with attached error handler.
|
|
633
|
-
* Synchronous mutators (addNode/addEdge/updateNodeStatus) use this to
|
|
634
|
-
* avoid forcing an async cascade through every caller; if the store
|
|
635
|
-
* is missing or throwing, the error is surfaced via onPersistError.
|
|
636
|
-
*/
|
|
637
|
-
persist() {
|
|
638
|
-
if (!this.graph) return;
|
|
639
|
-
this.opts.store.saveGraph(this.graph).catch((err) => {
|
|
640
|
-
this.opts.onPersistError ? this.opts.onPersistError(err) : console.warn(
|
|
641
|
-
JSON.stringify({
|
|
642
|
-
level: "warn",
|
|
643
|
-
event: "task_tracker.save_graph_failed",
|
|
644
|
-
message: toErrorMessage(err),
|
|
645
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
646
|
-
})
|
|
647
|
-
);
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
var PRIORITY_RANK = {
|
|
652
|
-
critical: 0,
|
|
653
|
-
high: 1,
|
|
654
|
-
medium: 2,
|
|
655
|
-
low: 3
|
|
656
|
-
};
|
|
657
|
-
var STATUS_RANK = {
|
|
658
|
-
in_progress: 0,
|
|
659
|
-
pending: 1,
|
|
660
|
-
review: 2,
|
|
661
|
-
blocked: 3,
|
|
662
|
-
failed: 4,
|
|
663
|
-
completed: 5
|
|
664
|
-
};
|
|
665
|
-
function compareByField(a, b, field) {
|
|
666
|
-
switch (field) {
|
|
667
|
-
case "priority":
|
|
668
|
-
return PRIORITY_RANK[a.priority] - PRIORITY_RANK[b.priority];
|
|
669
|
-
case "status":
|
|
670
|
-
return STATUS_RANK[a.status] - STATUS_RANK[b.status];
|
|
671
|
-
case "createdAt":
|
|
672
|
-
return a.createdAt - b.createdAt;
|
|
673
|
-
case "updatedAt":
|
|
674
|
-
return a.updatedAt - b.updatedAt;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
DefaultTaskStore,
|
|
3
|
+
TaskTracker,
|
|
4
|
+
computeTaskProgress,
|
|
5
|
+
deserializeTaskGraph,
|
|
6
|
+
serializeTaskGraph,
|
|
7
|
+
topologicalSort
|
|
8
|
+
} from "../chunk-BYD345OX.js";
|
|
9
|
+
import "../chunk-25LSLC3G.js";
|
|
10
|
+
import "../chunk-TBRL2RCC.js";
|
|
677
11
|
export {
|
|
678
12
|
DefaultTaskStore,
|
|
679
13
|
TaskTracker,
|