wicked-crew 0.16.13 → 0.17.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/README.md +27 -9
- package/dist/api/audit-view.d.ts +24 -0
- package/dist/api/audit-view.d.ts.map +1 -0
- package/dist/api/audit-view.js +70 -0
- package/dist/api/audit-view.js.map +1 -0
- package/dist/api/auth.d.ts +42 -2
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +157 -18
- package/dist/api/auth.js.map +1 -1
- package/dist/api/capture.d.ts +12 -59
- package/dist/api/capture.d.ts.map +1 -1
- package/dist/api/capture.js +9 -17
- package/dist/api/capture.js.map +1 -1
- package/dist/api/chat-context.d.ts +6 -62
- package/dist/api/chat-context.d.ts.map +1 -1
- package/dist/api/chat-context.js +6 -12
- package/dist/api/chat-context.js.map +1 -1
- package/dist/api/chat-jobs.d.ts +163 -0
- package/dist/api/chat-jobs.d.ts.map +1 -0
- package/dist/api/chat-jobs.js +767 -0
- package/dist/api/chat-jobs.js.map +1 -0
- package/dist/api/chat-mcp.d.ts +37 -0
- package/dist/api/chat-mcp.d.ts.map +1 -1
- package/dist/api/chat-mcp.js +118 -2
- package/dist/api/chat-mcp.js.map +1 -1
- package/dist/api/chat-proposals.d.ts +170 -152
- package/dist/api/chat-proposals.d.ts.map +1 -1
- package/dist/api/chat-proposals.js +833 -15
- package/dist/api/chat-proposals.js.map +1 -1
- package/dist/api/delivery-assurance.d.ts +3 -1
- package/dist/api/delivery-assurance.d.ts.map +1 -1
- package/dist/api/delivery-assurance.js +20 -0
- package/dist/api/delivery-assurance.js.map +1 -1
- package/dist/api/delivery-freeze.d.ts +2 -8
- package/dist/api/delivery-freeze.d.ts.map +1 -1
- package/dist/api/delivery-freeze.js +2 -4
- package/dist/api/delivery-freeze.js.map +1 -1
- package/dist/api/eval-sample.d.ts +18 -114
- package/dist/api/eval-sample.d.ts.map +1 -1
- package/dist/api/eval-sample.js +7 -13
- package/dist/api/eval-sample.js.map +1 -1
- package/dist/api/governance-steering.d.ts +27 -71
- package/dist/api/governance-steering.d.ts.map +1 -1
- package/dist/api/governance-steering.js +11 -19
- package/dist/api/governance-steering.js.map +1 -1
- package/dist/api/mcp.d.ts +159 -199
- package/dist/api/mcp.d.ts.map +1 -1
- package/dist/api/mcp.js +433 -68
- package/dist/api/mcp.js.map +1 -1
- package/dist/api/needs.d.ts +10 -0
- package/dist/api/needs.d.ts.map +1 -1
- package/dist/api/needs.js +77 -0
- package/dist/api/needs.js.map +1 -1
- package/dist/api/open-path.d.ts +10 -0
- package/dist/api/open-path.d.ts.map +1 -1
- package/dist/api/open-path.js +58 -1
- package/dist/api/open-path.js.map +1 -1
- package/dist/api/plan-schema.d.ts +8 -51
- package/dist/api/plan-schema.d.ts.map +1 -1
- package/dist/api/plan-schema.js +6 -6
- package/dist/api/plan-schema.js.map +1 -1
- package/dist/api/product.d.ts +81 -23
- package/dist/api/product.d.ts.map +1 -1
- package/dist/api/product.js +149 -72
- package/dist/api/product.js.map +1 -1
- package/dist/api/project-aggregates.d.ts +12 -20
- package/dist/api/project-aggregates.d.ts.map +1 -1
- package/dist/api/project-aggregates.js +3 -3
- package/dist/api/project-aggregates.js.map +1 -1
- package/dist/api/recording.d.ts +69 -39
- package/dist/api/recording.d.ts.map +1 -1
- package/dist/api/recording.js +60 -49
- package/dist/api/recording.js.map +1 -1
- package/dist/api/routes.d.ts +229 -1506
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +1226 -169
- package/dist/api/routes.js.map +1 -1
- package/dist/api/run-timing-index.d.ts +12 -1
- package/dist/api/run-timing-index.d.ts.map +1 -1
- package/dist/api/run-timing-index.js +35 -0
- package/dist/api/run-timing-index.js.map +1 -1
- package/dist/api/seat-images.d.ts +10 -0
- package/dist/api/seat-images.d.ts.map +1 -1
- package/dist/api/seat-images.js +16 -3
- package/dist/api/seat-images.js.map +1 -1
- package/dist/api/server-error-body.d.ts +44 -0
- package/dist/api/server-error-body.d.ts.map +1 -0
- package/dist/api/server-error-body.js +206 -0
- package/dist/api/server-error-body.js.map +1 -0
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +179 -4
- package/dist/api/server.js.map +1 -1
- package/dist/api/skills.d.ts +12 -36
- package/dist/api/skills.d.ts.map +1 -1
- package/dist/api/skills.js +12 -15
- package/dist/api/skills.js.map +1 -1
- package/dist/api/system-snapshot.d.ts +1 -5
- package/dist/api/system-snapshot.d.ts.map +1 -1
- package/dist/api/system-snapshot.js +7 -15
- package/dist/api/system-snapshot.js.map +1 -1
- package/dist/api/testing.d.ts +29 -50
- package/dist/api/testing.d.ts.map +1 -1
- package/dist/api/testing.js +7 -13
- package/dist/api/testing.js.map +1 -1
- package/dist/apps/actions/api-action.d.ts +47 -0
- package/dist/apps/actions/api-action.d.ts.map +1 -0
- package/dist/apps/actions/api-action.js +135 -0
- package/dist/apps/actions/api-action.js.map +1 -0
- package/dist/apps/actions/pg-fit.d.ts +27 -0
- package/dist/apps/actions/pg-fit.d.ts.map +1 -0
- package/dist/apps/actions/pg-fit.js +35 -0
- package/dist/apps/actions/pg-fit.js.map +1 -0
- package/dist/apps/actions/pg-write.d.ts +84 -0
- package/dist/apps/actions/pg-write.d.ts.map +1 -0
- package/dist/apps/actions/pg-write.js +161 -0
- package/dist/apps/actions/pg-write.js.map +1 -0
- package/dist/apps/actions/store.d.ts +109 -0
- package/dist/apps/actions/store.d.ts.map +1 -0
- package/dist/apps/actions/store.js +182 -0
- package/dist/apps/actions/store.js.map +1 -0
- package/dist/apps/actions/values.d.ts +59 -0
- package/dist/apps/actions/values.d.ts.map +1 -0
- package/dist/apps/actions/values.js +315 -0
- package/dist/apps/actions/values.js.map +1 -0
- package/dist/apps/actions/write-path.d.ts +103 -0
- package/dist/apps/actions/write-path.d.ts.map +1 -0
- package/dist/apps/actions/write-path.js +576 -0
- package/dist/apps/actions/write-path.js.map +1 -0
- package/dist/apps/check.d.ts +112 -0
- package/dist/apps/check.d.ts.map +1 -0
- package/dist/apps/check.js +358 -0
- package/dist/apps/check.js.map +1 -0
- package/dist/apps/exec/arg-types.d.ts +56 -0
- package/dist/apps/exec/arg-types.d.ts.map +1 -0
- package/dist/apps/exec/arg-types.js +234 -0
- package/dist/apps/exec/arg-types.js.map +1 -0
- package/dist/apps/exec/cache.d.ts +46 -0
- package/dist/apps/exec/cache.d.ts.map +1 -0
- package/dist/apps/exec/cache.js +93 -0
- package/dist/apps/exec/cache.js.map +1 -0
- package/dist/apps/exec/contract.d.ts +83 -0
- package/dist/apps/exec/contract.d.ts.map +1 -0
- package/dist/apps/exec/contract.js +220 -0
- package/dist/apps/exec/contract.js.map +1 -0
- package/dist/apps/exec/executor.d.ts +122 -0
- package/dist/apps/exec/executor.d.ts.map +1 -0
- package/dist/apps/exec/executor.js +455 -0
- package/dist/apps/exec/executor.js.map +1 -0
- package/dist/apps/exec/limits.d.ts +25 -0
- package/dist/apps/exec/limits.d.ts.map +1 -0
- package/dist/apps/exec/limits.js +71 -0
- package/dist/apps/exec/limits.js.map +1 -0
- package/dist/apps/exec/params.d.ts +34 -0
- package/dist/apps/exec/params.d.ts.map +1 -0
- package/dist/apps/exec/params.js +97 -0
- package/dist/apps/exec/params.js.map +1 -0
- package/dist/apps/exec/project.d.ts +67 -0
- package/dist/apps/exec/project.d.ts.map +1 -0
- package/dist/apps/exec/project.js +299 -0
- package/dist/apps/exec/project.js.map +1 -0
- package/dist/apps/exec/recall.d.ts +88 -0
- package/dist/apps/exec/recall.d.ts.map +1 -0
- package/dist/apps/exec/recall.js +301 -0
- package/dist/apps/exec/recall.js.map +1 -0
- package/dist/apps/exec/source-stage.d.ts +61 -0
- package/dist/apps/exec/source-stage.d.ts.map +1 -0
- package/dist/apps/exec/source-stage.js +540 -0
- package/dist/apps/exec/source-stage.js.map +1 -0
- package/dist/apps/exec/sources.d.ts +65 -0
- package/dist/apps/exec/sources.d.ts.map +1 -0
- package/dist/apps/exec/sources.js +77 -0
- package/dist/apps/exec/sources.js.map +1 -0
- package/dist/apps/exec/texts.d.ts +140 -0
- package/dist/apps/exec/texts.d.ts.map +1 -0
- package/dist/apps/exec/texts.js +76 -0
- package/dist/apps/exec/texts.js.map +1 -0
- package/dist/apps/exec/viewer.d.ts +11 -0
- package/dist/apps/exec/viewer.d.ts.map +1 -0
- package/dist/apps/exec/viewer.js +26 -0
- package/dist/apps/exec/viewer.js.map +1 -0
- package/dist/apps/git.d.ts +109 -0
- package/dist/apps/git.d.ts.map +1 -0
- package/dist/apps/git.js +361 -0
- package/dist/apps/git.js.map +1 -0
- package/dist/apps/publish/image.d.ts +25 -0
- package/dist/apps/publish/image.d.ts.map +1 -0
- package/dist/apps/publish/image.js +86 -0
- package/dist/apps/publish/image.js.map +1 -0
- package/dist/apps/publish/layout.d.ts +41 -0
- package/dist/apps/publish/layout.d.ts.map +1 -0
- package/dist/apps/publish/layout.js +31 -0
- package/dist/apps/publish/layout.js.map +1 -0
- package/dist/apps/publish/manifest.d.ts +64 -0
- package/dist/apps/publish/manifest.d.ts.map +1 -0
- package/dist/apps/publish/manifest.js +282 -0
- package/dist/apps/publish/manifest.js.map +1 -0
- package/dist/apps/publish/pack.d.ts +40 -0
- package/dist/apps/publish/pack.d.ts.map +1 -0
- package/dist/apps/publish/pack.js +78 -0
- package/dist/apps/publish/pack.js.map +1 -0
- package/dist/apps/routes.d.ts +103 -0
- package/dist/apps/routes.d.ts.map +1 -0
- package/dist/apps/routes.js +440 -0
- package/dist/apps/routes.js.map +1 -0
- package/dist/apps/spec.d.ts +322 -2640
- package/dist/apps/spec.d.ts.map +1 -1
- package/dist/apps/spec.js +89 -120
- package/dist/apps/spec.js.map +1 -1
- package/dist/apps/store.d.ts +341 -0
- package/dist/apps/store.d.ts.map +1 -0
- package/dist/apps/store.js +905 -0
- package/dist/apps/store.js.map +1 -0
- package/dist/apps/turns.d.ts +169 -0
- package/dist/apps/turns.d.ts.map +1 -0
- package/dist/apps/turns.js +556 -0
- package/dist/apps/turns.js.map +1 -0
- package/dist/apps/views.d.ts +44 -0
- package/dist/apps/views.d.ts.map +1 -0
- package/dist/apps/views.js +53 -0
- package/dist/apps/views.js.map +1 -0
- package/dist/campaigns/routes.d.ts +22 -94
- package/dist/campaigns/routes.d.ts.map +1 -1
- package/dist/campaigns/routes.js +8 -14
- package/dist/campaigns/routes.js.map +1 -1
- package/dist/cli/apps-check.d.ts +43 -0
- package/dist/cli/apps-check.d.ts.map +1 -0
- package/dist/cli/apps-check.js +166 -0
- package/dist/cli/apps-check.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +6 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp.js +2 -2
- package/dist/cli/mcp.js.map +1 -1
- package/dist/core/adapter.d.ts +34 -1
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +78 -2
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/builtin-catalog.d.ts.map +1 -1
- package/dist/core/builtin-catalog.js +2 -0
- package/dist/core/builtin-catalog.js.map +1 -1
- package/dist/core/deliver-text.d.ts +62 -1
- package/dist/core/deliver-text.d.ts.map +1 -1
- package/dist/core/deliver-text.js +244 -22
- package/dist/core/deliver-text.js.map +1 -1
- package/dist/core/deliver.d.ts.map +1 -1
- package/dist/core/deliver.js +30 -3
- package/dist/core/deliver.js.map +1 -1
- package/dist/core/estate-mcp-client.d.ts +9 -0
- package/dist/core/estate-mcp-client.d.ts.map +1 -1
- package/dist/core/estate-mcp-client.js +31 -3
- package/dist/core/estate-mcp-client.js.map +1 -1
- package/dist/core/linked-issues.d.ts +51 -3
- package/dist/core/linked-issues.d.ts.map +1 -1
- package/dist/core/linked-issues.js +59 -14
- package/dist/core/linked-issues.js.map +1 -1
- package/dist/core/qe-acceptance-setting.d.ts.map +1 -1
- package/dist/core/qe-acceptance-setting.js +6 -0
- package/dist/core/qe-acceptance-setting.js.map +1 -1
- package/dist/decisions/chat-recorder.js +1 -1
- package/dist/decisions/chat-recorder.js.map +1 -1
- package/dist/decisions/routes.d.ts.map +1 -1
- package/dist/decisions/routes.js +5 -9
- package/dist/decisions/routes.js.map +1 -1
- package/dist/decisions/rules-brief.d.ts +76 -0
- package/dist/decisions/rules-brief.d.ts.map +1 -0
- package/dist/decisions/rules-brief.js +179 -0
- package/dist/decisions/rules-brief.js.map +1 -0
- package/dist/editors/registry.d.ts +97 -258
- package/dist/editors/registry.d.ts.map +1 -1
- package/dist/editors/registry.js +11 -11
- package/dist/editors/registry.js.map +1 -1
- package/dist/editors/routes.js +3 -3
- package/dist/editors/routes.js.map +1 -1
- package/dist/evals/routes.d.ts.map +1 -1
- package/dist/evals/routes.js +3 -5
- package/dist/evals/routes.js.map +1 -1
- package/dist/insights/routes.js +2 -2
- package/dist/insights/routes.js.map +1 -1
- package/dist/interactive/proxy-routes.d.ts.map +1 -1
- package/dist/interactive/proxy-routes.js +76 -7
- package/dist/interactive/proxy-routes.js.map +1 -1
- package/dist/interactive/ws-relay.d.ts +3 -9
- package/dist/interactive/ws-relay.d.ts.map +1 -1
- package/dist/interactive/ws-relay.js +4 -6
- package/dist/interactive/ws-relay.js.map +1 -1
- package/dist/knowledge/adapters/native.d.ts +44 -0
- package/dist/knowledge/adapters/native.d.ts.map +1 -0
- package/dist/knowledge/adapters/native.js +60 -0
- package/dist/knowledge/adapters/native.js.map +1 -0
- package/dist/knowledge/adapters/toolbox/binary.d.ts +48 -0
- package/dist/knowledge/adapters/toolbox/binary.d.ts.map +1 -0
- package/dist/knowledge/adapters/toolbox/binary.js +145 -0
- package/dist/knowledge/adapters/toolbox/binary.js.map +1 -0
- package/dist/knowledge/adapters/toolbox/catalog.d.ts +22 -0
- package/dist/knowledge/adapters/toolbox/catalog.d.ts.map +1 -0
- package/dist/knowledge/adapters/toolbox/catalog.js +87 -0
- package/dist/knowledge/adapters/toolbox/catalog.js.map +1 -0
- package/dist/knowledge/adapters/toolbox/document.d.ts +71 -0
- package/dist/knowledge/adapters/toolbox/document.d.ts.map +1 -0
- package/dist/knowledge/adapters/toolbox/document.js +165 -0
- package/dist/knowledge/adapters/toolbox/document.js.map +1 -0
- package/dist/knowledge/adapters/toolbox/supervisor.d.ts +142 -0
- package/dist/knowledge/adapters/toolbox/supervisor.d.ts.map +1 -0
- package/dist/knowledge/adapters/toolbox/supervisor.js +438 -0
- package/dist/knowledge/adapters/toolbox/supervisor.js.map +1 -0
- package/dist/knowledge/gate/access.d.ts +36 -0
- package/dist/knowledge/gate/access.d.ts.map +1 -0
- package/dist/knowledge/gate/access.js +46 -0
- package/dist/knowledge/gate/access.js.map +1 -0
- package/dist/knowledge/gate/envelope.d.ts +67 -0
- package/dist/knowledge/gate/envelope.d.ts.map +1 -0
- package/dist/knowledge/gate/envelope.js +96 -0
- package/dist/knowledge/gate/envelope.js.map +1 -0
- package/dist/knowledge/gate/gate.d.ts +238 -0
- package/dist/knowledge/gate/gate.d.ts.map +1 -0
- package/dist/knowledge/gate/gate.js +782 -0
- package/dist/knowledge/gate/gate.js.map +1 -0
- package/dist/knowledge/gate/pg.d.ts +57 -0
- package/dist/knowledge/gate/pg.d.ts.map +1 -0
- package/dist/knowledge/gate/pg.js +94 -0
- package/dist/knowledge/gate/pg.js.map +1 -0
- package/dist/knowledge/gate/record.d.ts +77 -0
- package/dist/knowledge/gate/record.d.ts.map +1 -0
- package/dist/knowledge/gate/record.js +205 -0
- package/dist/knowledge/gate/record.js.map +1 -0
- package/dist/knowledge/gate/routes.d.ts +38 -0
- package/dist/knowledge/gate/routes.d.ts.map +1 -0
- package/dist/knowledge/gate/routes.js +102 -0
- package/dist/knowledge/gate/routes.js.map +1 -0
- package/dist/knowledge/gate/scheduler.d.ts +90 -0
- package/dist/knowledge/gate/scheduler.d.ts.map +1 -0
- package/dist/knowledge/gate/scheduler.js +224 -0
- package/dist/knowledge/gate/scheduler.js.map +1 -0
- package/dist/knowledge/gate/sources.d.ts +69 -0
- package/dist/knowledge/gate/sources.d.ts.map +1 -0
- package/dist/knowledge/gate/sources.js +135 -0
- package/dist/knowledge/gate/sources.js.map +1 -0
- package/dist/knowledge/package.d.ts +136 -0
- package/dist/knowledge/package.d.ts.map +1 -0
- package/dist/knowledge/package.js +148 -0
- package/dist/knowledge/package.js.map +1 -0
- package/dist/knowledge/projector.d.ts +144 -0
- package/dist/knowledge/projector.d.ts.map +1 -0
- package/dist/knowledge/projector.js +287 -0
- package/dist/knowledge/projector.js.map +1 -0
- package/dist/knowledge/registry/entry.d.ts +177 -0
- package/dist/knowledge/registry/entry.d.ts.map +1 -0
- package/dist/knowledge/registry/entry.js +126 -0
- package/dist/knowledge/registry/entry.js.map +1 -0
- package/dist/knowledge/registry/policy.d.ts +79 -0
- package/dist/knowledge/registry/policy.d.ts.map +1 -0
- package/dist/knowledge/registry/policy.js +139 -0
- package/dist/knowledge/registry/policy.js.map +1 -0
- package/dist/knowledge/shapes/code-search.d.ts +55 -0
- package/dist/knowledge/shapes/code-search.d.ts.map +1 -0
- package/dist/knowledge/shapes/code-search.js +88 -0
- package/dist/knowledge/shapes/code-search.js.map +1 -0
- package/dist/knowledge/shapes/map.d.ts +25 -0
- package/dist/knowledge/shapes/map.d.ts.map +1 -0
- package/dist/knowledge/shapes/map.js +187 -0
- package/dist/knowledge/shapes/map.js.map +1 -0
- package/dist/knowledge/shapes/profile.d.ts +117 -0
- package/dist/knowledge/shapes/profile.d.ts.map +1 -0
- package/dist/knowledge/shapes/profile.js +264 -0
- package/dist/knowledge/shapes/profile.js.map +1 -0
- package/dist/knowledge/shapes/routes.d.ts +69 -0
- package/dist/knowledge/shapes/routes.d.ts.map +1 -0
- package/dist/knowledge/shapes/routes.js +270 -0
- package/dist/knowledge/shapes/routes.js.map +1 -0
- package/dist/knowledge/shapes/shapes.d.ts +144 -0
- package/dist/knowledge/shapes/shapes.d.ts.map +1 -0
- package/dist/knowledge/shapes/shapes.js +280 -0
- package/dist/knowledge/shapes/shapes.js.map +1 -0
- package/dist/knowledge/shapes/verified.d.ts +36 -0
- package/dist/knowledge/shapes/verified.d.ts.map +1 -0
- package/dist/knowledge/shapes/verified.js +73 -0
- package/dist/knowledge/shapes/verified.js.map +1 -0
- package/dist/knowledge/summary.d.ts +45 -0
- package/dist/knowledge/summary.d.ts.map +1 -0
- package/dist/knowledge/summary.js +119 -0
- package/dist/knowledge/summary.js.map +1 -0
- package/dist/knowledge/trackers/actions.d.ts +55 -0
- package/dist/knowledge/trackers/actions.d.ts.map +1 -0
- package/dist/knowledge/trackers/actions.js +327 -0
- package/dist/knowledge/trackers/actions.js.map +1 -0
- package/dist/knowledge/trackers/addresses.d.ts +45 -0
- package/dist/knowledge/trackers/addresses.d.ts.map +1 -0
- package/dist/knowledge/trackers/addresses.js +59 -0
- package/dist/knowledge/trackers/addresses.js.map +1 -0
- package/dist/knowledge/trackers/bindings.d.ts +190 -0
- package/dist/knowledge/trackers/bindings.d.ts.map +1 -0
- package/dist/knowledge/trackers/bindings.js +970 -0
- package/dist/knowledge/trackers/bindings.js.map +1 -0
- package/dist/knowledge/trackers/gate-pm.d.ts +160 -0
- package/dist/knowledge/trackers/gate-pm.d.ts.map +1 -0
- package/dist/knowledge/trackers/gate-pm.js +427 -0
- package/dist/knowledge/trackers/gate-pm.js.map +1 -0
- package/dist/knowledge/trackers/issues.d.ts +69 -0
- package/dist/knowledge/trackers/issues.d.ts.map +1 -0
- package/dist/knowledge/trackers/issues.js +193 -0
- package/dist/knowledge/trackers/issues.js.map +1 -0
- package/dist/knowledge/trackers/map.d.ts +23 -0
- package/dist/knowledge/trackers/map.d.ts.map +1 -0
- package/dist/knowledge/trackers/map.js +130 -0
- package/dist/knowledge/trackers/map.js.map +1 -0
- package/dist/knowledge/trackers/projector.d.ts +113 -0
- package/dist/knowledge/trackers/projector.d.ts.map +1 -0
- package/dist/knowledge/trackers/projector.js +274 -0
- package/dist/knowledge/trackers/projector.js.map +1 -0
- package/dist/knowledge/trackers/routes.d.ts +107 -0
- package/dist/knowledge/trackers/routes.d.ts.map +1 -0
- package/dist/knowledge/trackers/routes.js +563 -0
- package/dist/knowledge/trackers/routes.js.map +1 -0
- package/dist/knowledge/trackers/set.d.ts +61 -0
- package/dist/knowledge/trackers/set.d.ts.map +1 -0
- package/dist/knowledge/trackers/set.js +77 -0
- package/dist/knowledge/trackers/set.js.map +1 -0
- package/dist/knowledge/trackers/view.d.ts +22 -0
- package/dist/knowledge/trackers/view.d.ts.map +1 -0
- package/dist/knowledge/trackers/view.js +31 -0
- package/dist/knowledge/trackers/view.js.map +1 -0
- package/dist/knowledge/trackers/visible.d.ts +9 -0
- package/dist/knowledge/trackers/visible.d.ts.map +1 -0
- package/dist/knowledge/trackers/visible.js +10 -0
- package/dist/knowledge/trackers/visible.js.map +1 -0
- package/dist/learn/routes.d.ts +3 -17
- package/dist/learn/routes.d.ts.map +1 -1
- package/dist/learn/routes.js +4 -6
- package/dist/learn/routes.js.map +1 -1
- package/dist/mcp/ask-server.d.ts +6 -0
- package/dist/mcp/ask-server.d.ts.map +1 -1
- package/dist/mcp/ask-server.js +15 -9
- package/dist/mcp/ask-server.js.map +1 -1
- package/dist/mcp/broker.d.ts +16 -0
- package/dist/mcp/broker.d.ts.map +1 -1
- package/dist/mcp/broker.js +137 -3
- package/dist/mcp/broker.js.map +1 -1
- package/dist/mcp/estate-relay.d.ts +50 -2
- package/dist/mcp/estate-relay.d.ts.map +1 -1
- package/dist/mcp/estate-relay.js +126 -4
- package/dist/mcp/estate-relay.js.map +1 -1
- package/dist/mcp/invoke.d.ts +12 -1
- package/dist/mcp/invoke.d.ts.map +1 -1
- package/dist/mcp/invoke.js +5 -2
- package/dist/mcp/invoke.js.map +1 -1
- package/dist/mcp/probe.d.ts +34 -2
- package/dist/mcp/probe.d.ts.map +1 -1
- package/dist/mcp/probe.js +51 -9
- package/dist/mcp/probe.js.map +1 -1
- package/dist/mcp/registry-store.d.ts +91 -0
- package/dist/mcp/registry-store.d.ts.map +1 -1
- package/dist/mcp/registry-store.js +116 -9
- package/dist/mcp/registry-store.js.map +1 -1
- package/dist/mcp/registry.d.ts +249 -6
- package/dist/mcp/registry.d.ts.map +1 -1
- package/dist/mcp/registry.js +735 -35
- package/dist/mcp/registry.js.map +1 -1
- package/dist/mcp/rest.d.ts +36 -10
- package/dist/mcp/rest.d.ts.map +1 -1
- package/dist/mcp/rest.js +71 -73
- package/dist/mcp/rest.js.map +1 -1
- package/dist/mcp/tool-list.d.ts +7 -0
- package/dist/mcp/tool-list.d.ts.map +1 -1
- package/dist/mcp/tool-list.js +32 -4
- package/dist/mcp/tool-list.js.map +1 -1
- package/dist/mcp-inspect/routes.d.ts +3 -0
- package/dist/mcp-inspect/routes.d.ts.map +1 -1
- package/dist/mcp-inspect/routes.js +31 -18
- package/dist/mcp-inspect/routes.js.map +1 -1
- package/dist/persona/routes.d.ts +14 -69
- package/dist/persona/routes.d.ts.map +1 -1
- package/dist/persona/routes.js +2 -2
- package/dist/persona/routes.js.map +1 -1
- package/dist/persona/store.d.ts +13 -40
- package/dist/persona/store.d.ts.map +1 -1
- package/dist/persona/store.js +9 -11
- package/dist/persona/store.js.map +1 -1
- package/dist/presets/routes.d.ts +3 -21
- package/dist/presets/routes.d.ts.map +1 -1
- package/dist/presets/routes.js +5 -7
- package/dist/presets/routes.js.map +1 -1
- package/dist/projects/repo-guard.d.ts +32 -0
- package/dist/projects/repo-guard.d.ts.map +1 -0
- package/dist/projects/repo-guard.js +46 -0
- package/dist/projects/repo-guard.js.map +1 -0
- package/dist/projects/routes.d.ts +16 -44
- package/dist/projects/routes.d.ts.map +1 -1
- package/dist/projects/routes.js +15 -18
- package/dist/projects/routes.js.map +1 -1
- package/dist/schedules/routes.d.ts +4 -18
- package/dist/schedules/routes.d.ts.map +1 -1
- package/dist/schedules/routes.js +4 -6
- package/dist/schedules/routes.js.map +1 -1
- package/dist/skills/plugin-source.d.ts +6 -5
- package/dist/skills/plugin-source.d.ts.map +1 -1
- package/dist/skills/plugin-source.js +6 -5
- package/dist/skills/plugin-source.js.map +1 -1
- package/dist/sources/ask.d.ts +108 -0
- package/dist/sources/ask.d.ts.map +1 -0
- package/dist/sources/ask.js +251 -0
- package/dist/sources/ask.js.map +1 -0
- package/dist/sources/catalog/mysql.d.ts +9 -0
- package/dist/sources/catalog/mysql.d.ts.map +1 -0
- package/dist/sources/catalog/mysql.js +77 -0
- package/dist/sources/catalog/mysql.js.map +1 -0
- package/dist/sources/catalog/postgres.d.ts +68 -0
- package/dist/sources/catalog/postgres.d.ts.map +1 -0
- package/dist/sources/catalog/postgres.js +164 -0
- package/dist/sources/catalog/postgres.js.map +1 -0
- package/dist/sources/catalog/types.d.ts +53 -0
- package/dist/sources/catalog/types.d.ts.map +1 -0
- package/dist/sources/catalog/types.js +30 -0
- package/dist/sources/catalog/types.js.map +1 -0
- package/dist/sources/connection-test.d.ts +37 -0
- package/dist/sources/connection-test.d.ts.map +1 -0
- package/dist/sources/connection-test.js +101 -0
- package/dist/sources/connection-test.js.map +1 -0
- package/dist/sources/crew-source.d.ts +31 -0
- package/dist/sources/crew-source.d.ts.map +1 -0
- package/dist/sources/crew-source.js +48 -0
- package/dist/sources/crew-source.js.map +1 -0
- package/dist/sources/dialer.d.ts +169 -0
- package/dist/sources/dialer.d.ts.map +1 -0
- package/dist/sources/dialer.js +761 -0
- package/dist/sources/dialer.js.map +1 -0
- package/dist/sources/drivers/mysql.d.ts +52 -0
- package/dist/sources/drivers/mysql.d.ts.map +1 -0
- package/dist/sources/drivers/mysql.js +348 -0
- package/dist/sources/drivers/mysql.js.map +1 -0
- package/dist/sources/drivers/postgres.d.ts +84 -0
- package/dist/sources/drivers/postgres.d.ts.map +1 -0
- package/dist/sources/drivers/postgres.js +381 -0
- package/dist/sources/drivers/postgres.js.map +1 -0
- package/dist/sources/drivers/sqlite.d.ts +47 -0
- package/dist/sources/drivers/sqlite.d.ts.map +1 -0
- package/dist/sources/drivers/sqlite.js +156 -0
- package/dist/sources/drivers/sqlite.js.map +1 -0
- package/dist/sources/drivers/types.d.ts +79 -0
- package/dist/sources/drivers/types.d.ts.map +1 -0
- package/dist/sources/drivers/types.js +31 -0
- package/dist/sources/drivers/types.js.map +1 -0
- package/dist/sources/graphql.d.ts +85 -0
- package/dist/sources/graphql.d.ts.map +1 -0
- package/dist/sources/graphql.js +155 -0
- package/dist/sources/graphql.js.map +1 -0
- package/dist/sources/kinds.d.ts +79 -0
- package/dist/sources/kinds.d.ts.map +1 -0
- package/dist/sources/kinds.js +145 -0
- package/dist/sources/kinds.js.map +1 -0
- package/dist/sources/policy/allowlists.d.ts +30 -0
- package/dist/sources/policy/allowlists.d.ts.map +1 -0
- package/dist/sources/policy/allowlists.js +104 -0
- package/dist/sources/policy/allowlists.js.map +1 -0
- package/dist/sources/policy/index.d.ts +20 -0
- package/dist/sources/policy/index.d.ts.map +1 -0
- package/dist/sources/policy/index.js +34 -0
- package/dist/sources/policy/index.js.map +1 -0
- package/dist/sources/policy/mysql.d.ts +21 -0
- package/dist/sources/policy/mysql.d.ts.map +1 -0
- package/dist/sources/policy/mysql.js +834 -0
- package/dist/sources/policy/mysql.js.map +1 -0
- package/dist/sources/policy/pg.d.ts +37 -0
- package/dist/sources/policy/pg.d.ts.map +1 -0
- package/dist/sources/policy/pg.js +572 -0
- package/dist/sources/policy/pg.js.map +1 -0
- package/dist/sources/policy/sqlite.d.ts +37 -0
- package/dist/sources/policy/sqlite.d.ts.map +1 -0
- package/dist/sources/policy/sqlite.js +94 -0
- package/dist/sources/policy/sqlite.js.map +1 -0
- package/dist/sources/policy/types.d.ts +46 -0
- package/dist/sources/policy/types.d.ts.map +1 -0
- package/dist/sources/policy/types.js +13 -0
- package/dist/sources/policy/types.js.map +1 -0
- package/dist/sources/routes.d.ts +154 -0
- package/dist/sources/routes.d.ts.map +1 -0
- package/dist/sources/routes.js +745 -0
- package/dist/sources/routes.js.map +1 -0
- package/dist/sources/safety/postgres.d.ts +87 -0
- package/dist/sources/safety/postgres.d.ts.map +1 -0
- package/dist/sources/safety/postgres.js +349 -0
- package/dist/sources/safety/postgres.js.map +1 -0
- package/dist/sources/sql.d.ts +51 -0
- package/dist/sources/sql.d.ts.map +1 -0
- package/dist/sources/sql.js +89 -0
- package/dist/sources/sql.js.map +1 -0
- package/dist/sources/store.d.ts +25 -0
- package/dist/sources/store.d.ts.map +1 -0
- package/dist/sources/store.js +59 -0
- package/dist/sources/store.js.map +1 -0
- package/dist/sources/uploads.d.ts +70 -0
- package/dist/sources/uploads.d.ts.map +1 -0
- package/dist/sources/uploads.js +636 -0
- package/dist/sources/uploads.js.map +1 -0
- package/dist/standing-orders/parse.d.ts +38 -0
- package/dist/standing-orders/parse.d.ts.map +1 -1
- package/dist/standing-orders/parse.js +104 -43
- package/dist/standing-orders/parse.js.map +1 -1
- package/dist/standing-orders/routes.d.ts +25 -126
- package/dist/standing-orders/routes.d.ts.map +1 -1
- package/dist/standing-orders/routes.js +4 -6
- package/dist/standing-orders/routes.js.map +1 -1
- package/dist/standing-orders/store.d.ts +22 -73
- package/dist/standing-orders/store.d.ts.map +1 -1
- package/dist/standing-orders/store.js +8 -12
- package/dist/standing-orders/store.js.map +1 -1
- package/dist/studio/assets/KnowledgeGraph-Cpm46tEp.js +1 -0
- package/dist/studio/assets/WickedSansA-Regular-CGPJLyb8.woff2 +0 -0
- package/dist/studio/assets/WickedSansA-SemiBold-Bk9KXUaV.woff2 +0 -0
- package/dist/studio/assets/favicon-BJA6hF2f.svg +1 -0
- package/dist/studio/assets/index-BRBwWQMH.css +32 -0
- package/dist/studio/assets/index-CVrWDGRP.js +1097 -0
- package/dist/studio/assets/wicked-studio-lettering-small-CBwSGqop.svg +2 -0
- package/dist/studio/assets/wicked-studio-wordmark-small-gF5xn6IC.svg +2 -0
- package/dist/studio/editors/wicked-apps/editor.json +45 -0
- package/dist/studio/editors/wicked-apps/icon.svg +1 -0
- package/dist/studio/editors/wicked-apps/index.html +151 -0
- package/dist/studio/editors/wicked-deck/editor.json +1 -1
- package/dist/studio/editors/wicked-deck/index.html +12 -8
- package/dist/studio/editors/wicked-doc/editor.json +1 -1
- package/dist/studio/editors/wicked-doc/index.html +12 -8
- package/dist/studio/editors/wicked-insights/editor.json +1 -1
- package/dist/studio/editors/wicked-insights/index.html +1 -1
- package/dist/studio/editors/wicked-page/editor.json +1 -1
- package/dist/studio/editors/wicked-page/index.html +12 -8
- package/dist/studio/editors/wicked-video/editor.json +1 -1
- package/dist/studio/editors/wicked-video/index.html +1 -1
- package/dist/studio/fonts/LICENSE-WickedSans.txt +97 -0
- package/dist/studio/index.html +3 -2
- package/dist/studio/testid-inventory.json +10850 -6700
- package/dist/team/routes.d.ts +31 -172
- package/dist/team/routes.d.ts.map +1 -1
- package/dist/team/routes.js +31 -8
- package/dist/team/routes.js.map +1 -1
- package/dist/voice/dashboard.d.ts +35 -313
- package/dist/voice/dashboard.d.ts.map +1 -1
- package/dist/voice/dashboard.js +10 -10
- package/dist/voice/dashboard.js.map +1 -1
- package/dist/voice/routes.d.ts +2 -6
- package/dist/voice/routes.d.ts.map +1 -1
- package/dist/voice/routes.js +2 -2
- package/dist/voice/routes.js.map +1 -1
- package/dist/watch/checks/check-failed.d.ts +4 -10
- package/dist/watch/checks/check-failed.d.ts.map +1 -1
- package/dist/watch/checks/check-failed.js +6 -8
- package/dist/watch/checks/check-failed.js.map +1 -1
- package/dist/watch/checks/claim-vs-evidence.js +3 -3
- package/dist/watch/checks/claim-vs-evidence.js.map +1 -1
- package/dist/watch/checks/deliver-audit.js +3 -3
- package/dist/watch/checks/deliver-audit.js.map +1 -1
- package/dist/watch/checks/discovery.d.ts.map +1 -1
- package/dist/watch/checks/discovery.js +5 -7
- package/dist/watch/checks/discovery.js.map +1 -1
- package/dist/watch/checks/lag.d.ts +4 -10
- package/dist/watch/checks/lag.d.ts.map +1 -1
- package/dist/watch/checks/lag.js +6 -8
- package/dist/watch/checks/lag.js.map +1 -1
- package/dist/watch/checks/quiet-after-claim.js +3 -3
- package/dist/watch/checks/quiet-after-claim.js.map +1 -1
- package/dist/watch/checks/scope-drift.js +3 -3
- package/dist/watch/checks/scope-drift.js.map +1 -1
- package/dist/watch/checks/team-path.js +2 -2
- package/dist/watch/checks/team-path.js.map +1 -1
- package/dist/watch/checks/ungated.js +3 -3
- package/dist/watch/checks/ungated.js.map +1 -1
- package/dist/watch/checks/warned-rule.js +3 -3
- package/dist/watch/checks/warned-rule.js.map +1 -1
- package/dist/watch/loader.d.ts.map +1 -1
- package/dist/watch/loader.js +12 -16
- package/dist/watch/loader.js.map +1 -1
- package/dist/workflow-catalog/build-v2.d.ts +90 -0
- package/dist/workflow-catalog/build-v2.d.ts.map +1 -0
- package/dist/workflow-catalog/build-v2.js +527 -0
- package/dist/workflow-catalog/build-v2.js.map +1 -0
- package/dist/workflow-catalog/build.d.ts +2 -0
- package/dist/workflow-catalog/build.d.ts.map +1 -1
- package/dist/workflow-catalog/build.js +8 -4
- package/dist/workflow-catalog/build.js.map +1 -1
- package/dist/workflow-catalog/catalog-data-v2.d.ts +12 -0
- package/dist/workflow-catalog/catalog-data-v2.d.ts.map +1 -0
- package/dist/workflow-catalog/catalog-data-v2.js +2582 -0
- package/dist/workflow-catalog/catalog-data-v2.js.map +1 -0
- package/dist/workflow-catalog/catalog-data.d.ts +7 -1
- package/dist/workflow-catalog/catalog-data.d.ts.map +1 -1
- package/dist/workflow-catalog/catalog-data.js +36 -7
- package/dist/workflow-catalog/catalog-data.js.map +1 -1
- package/dist/workflow-catalog/seeds-v2.d.ts +91 -0
- package/dist/workflow-catalog/seeds-v2.d.ts.map +1 -0
- package/dist/workflow-catalog/seeds-v2.js +2 -0
- package/dist/workflow-catalog/seeds-v2.js.map +1 -0
- package/dist/workflow-catalog/shape.d.ts +97 -0
- package/dist/workflow-catalog/shape.d.ts.map +1 -0
- package/dist/workflow-catalog/shape.js +97 -0
- package/dist/workflow-catalog/shape.js.map +1 -0
- package/dist/working-doc/service.d.ts.map +1 -1
- package/dist/working-doc/service.js +2 -1
- package/dist/working-doc/service.js.map +1 -1
- package/dist/zod.d.ts +39 -0
- package/dist/zod.d.ts.map +1 -0
- package/dist/zod.js +197 -0
- package/dist/zod.js.map +1 -0
- package/endpoint-manifest.json +651 -11
- package/package.json +31 -7
- package/runners/sqlite-runner.mjs +110 -0
- package/dist/studio/assets/WickedSans-Regular-fb698rcD.woff2 +0 -0
- package/dist/studio/assets/WickedSans-SemiBold-CD53n1AC.woff2 +0 -0
- package/dist/studio/assets/index-BUZ_-Syk.css +0 -32
- package/dist/studio/assets/index-u4O_7N-b.js +0 -986
package/dist/api/routes.js
CHANGED
|
@@ -2,7 +2,7 @@ import { REVIEW_WORKFLOW } from '../insights/workflow.js';
|
|
|
2
2
|
import { busSeamsOffWarning, busUnavailableWarning } from '../core/bus-notice.js';
|
|
3
3
|
import { vaultBinWarning, vaultDiagnostics } from '../core/vault-bin.js';
|
|
4
4
|
import { PlanSchema, toLaunchPlan } from './plan-schema.js';
|
|
5
|
-
import { z } from 'zod';
|
|
5
|
+
import { record, z } from '../zod.js';
|
|
6
6
|
import { listRequirementsRead, getRequirement, patchRequirement, readRequirementsGraph, REQUIREMENTS_NOT_GENERATED, } from './requirements.js';
|
|
7
7
|
import { randomUUID } from 'node:crypto';
|
|
8
8
|
import { homedir } from 'node:os';
|
|
@@ -11,7 +11,7 @@ import { promises as fsp } from 'node:fs';
|
|
|
11
11
|
import { basename, isAbsolute, join, relative, resolve } from 'node:path';
|
|
12
12
|
import { fileURLToPath } from 'node:url';
|
|
13
13
|
import { videoPalette } from '../appearance/video-palette.js';
|
|
14
|
-
import { CampaignsUnsupportedError, ChatUnsupportedError, CoreAdapter, ElicitationUnsupportedError, GovernanceReplayUnsupportedError, PlanLaunchUnsupportedError, SteeringUnsupportedError, addonSupportsQeOverride, addonSupportsReducedAssurance, humanGatePhaseIds, settingsFilePath } from '../core/adapter.js';
|
|
14
|
+
import { CampaignsUnsupportedError, ChatUnsupportedError, CoreAdapter, ElicitationUnsupportedError, GovernanceReplayUnsupportedError, PlanGateNoteUnsupportedError, PlanLaunchUnsupportedError, SteeringUnsupportedError, addonSupportsQeOverride, addonSupportsReducedAssurance, humanGatePhaseIds, settingsFilePath } from '../core/adapter.js';
|
|
15
15
|
import { codeGraphDb, codeGraphErrorStatus, repoFolderMissing, repoFolderMissingBody } from '../core/repoPaths.js';
|
|
16
16
|
import { resolveCursorUnit } from '../core/cursor.js';
|
|
17
17
|
/** Create `dir` (private) when missing and answer it — a read root must exist when a run launches. */
|
|
@@ -43,6 +43,7 @@ import { attemptUnavailableReason, capturedAttempts, outputUnavailableReason, re
|
|
|
43
43
|
import { execCapped, ExecOutputTooLarge } from '../core/exec.js';
|
|
44
44
|
import { callEstateTool, EstateMcpError, ESTATE_INSTALL_HINT, memoryStoreInfo } from '../core/estate-mcp-client.js';
|
|
45
45
|
import { NO_LEARNINGS_WORKFLOWS } from '../learnings/service.js';
|
|
46
|
+
import { matchRulesForJob, stripRulesBrief, withRulesBrief } from '../decisions/rules-brief.js';
|
|
46
47
|
import { SeatHealthTracker } from './seat-health.js';
|
|
47
48
|
import { applyWorkerConfigRoot, signedInHeuristic } from './seat-signin.js';
|
|
48
49
|
import { applyCouncilSettings, isCouncilSize, isCouncilStaggerMs } from '../core/council-settings.js';
|
|
@@ -58,7 +59,7 @@ import { CHAT_ID, chatMakeDigest, ChatScopeIndex, chatScopeDeps, chatScopeStatem
|
|
|
58
59
|
import { ASK_TURN_BUDGET_SECS, AskPathIndex, isAskTurn } from './ask-paths.js';
|
|
59
60
|
import { chatTurnStep, resolveChatWorkflow, servedChatWorkflows, writeCapableStep } from './chat-workflow.js';
|
|
60
61
|
import { reassignRefusedSeats } from '../core/reassign-refusal.js';
|
|
61
|
-
import { allowedRootsFor, isInsideRoot, openWithSystemDefault } from './open-path.js';
|
|
62
|
+
import { allowedRootsFor, isInsideRoot, mayBeInsideRoot, openWithSystemDefault } from './open-path.js';
|
|
62
63
|
import { InvalidDiffBaseError, MERGE_BASE_LITERAL, NotARegularFileError, UnresolvableDiffBaseError, branchDiff, isGitStopped, isPlainRef, readFileCapped, worktreeDiff, } from './run-files.js';
|
|
63
64
|
import { DocRunIndex } from '../interactive/doc-run-index.js';
|
|
64
65
|
import { listInteractiveDocs } from '../interactive/docs-index.js';
|
|
@@ -67,9 +68,12 @@ import { TestSetIndex } from '../qe/test-sets.js';
|
|
|
67
68
|
import { estateExe, parseEstateTotals, readBlastRadiusPages, resolveProjectGraphBinding } from '../projects/graph.js';
|
|
68
69
|
import { registerProjectRoutes } from '../projects/routes.js';
|
|
69
70
|
import { registerProjectAggregateRoutes } from './project-aggregates.js';
|
|
70
|
-
import { registerProductRoutes } from './product.js';
|
|
71
|
+
import { composeLaunch, composePreflight, registerProductRoutes } from './product.js';
|
|
72
|
+
import { buildWorkflowCatalogV2, parseCommand, resolveOption } from '../workflow-catalog/build-v2.js';
|
|
73
|
+
import { DEFAULT_PROJECT_ID } from '../projects/default-project.js';
|
|
74
|
+
import { checkLaunchShape, LaunchShapeSchema, launchShapeOf, servedFor, withBriefLines } from '../workflow-catalog/shape.js';
|
|
71
75
|
import { registerPresetRoutes } from '../presets/routes.js';
|
|
72
|
-
import { registerTeamRoutes } from '../team/routes.js';
|
|
76
|
+
import { busRows, openPlanGateRev, registerTeamRoutes, workPlanAccepted } from '../team/routes.js';
|
|
73
77
|
import { registerCampaignRoutes } from '../campaigns/routes.js';
|
|
74
78
|
import { registerGovernanceWikiRoutes } from './governance-wiki.js';
|
|
75
79
|
import { DEFAULT_STEERING_TYPE, STEERING_TYPE_VALUES, STEERING_TYPES, registerGovernanceSteeringRoutes, } from './governance-steering.js';
|
|
@@ -81,11 +85,16 @@ import { registerDefaultEvalRoutes, runAndRecord } from '../evals/routes.js';
|
|
|
81
85
|
import { prepareRunEvalsLaunch, RUN_EVALS_WORKFLOW } from '../evals/workflow.js';
|
|
82
86
|
import { defaultReplaySet } from '../evals/replay.js';
|
|
83
87
|
import { gardenRootFor } from '../learn/scheduler.js';
|
|
84
|
-
import { DEMO_PRESET, demoLaunchRoots, registerDemoDocumentRoute, registerDemoRoutes, registerWalkthroughRoutes, walkthroughAcceptance } from './recording.js';
|
|
88
|
+
import { DEMO_PRESET, demoLaunch, demoLaunchRoots, registerDemoDocumentRoute, registerDemoRoutes, registerWalkthroughRoutes, walkthroughAcceptance } from './recording.js';
|
|
85
89
|
import { projectDocsRoot } from '../interactive/project-root.js';
|
|
86
90
|
import { registerSkillsRoutes } from './skills.js';
|
|
91
|
+
import { registerSourceRoutes } from '../sources/routes.js';
|
|
92
|
+
import { seatTurn } from '../standing-orders/parse.js';
|
|
87
93
|
import { registerMcpRoutes } from './mcp.js';
|
|
88
|
-
import { chatMcpToolsFor } from './chat-mcp.js';
|
|
94
|
+
import { chatKnowledgeFor, chatMcpToolsFor } from './chat-mcp.js';
|
|
95
|
+
import { registerGateRoutes } from '../knowledge/gate/routes.js';
|
|
96
|
+
import { registerShapeRoutes } from '../knowledge/shapes/routes.js';
|
|
97
|
+
import { STATEMENT_DEADLINE_MS } from '../sources/drivers/types.js';
|
|
89
98
|
import { McpPolicies } from '../mcp/policies.js';
|
|
90
99
|
import { disabledSkillsHealth } from '../skills/runtime.js';
|
|
91
100
|
import { withPhaseSkillGaps } from '../skills/phase-skill-gaps.js';
|
|
@@ -115,20 +124,27 @@ const BRIEF_COPY_MAX = 512 * 1024;
|
|
|
115
124
|
import { registerInteractiveDocDelete } from '../interactive/doc-delete-routes.js';
|
|
116
125
|
import { registerInteractiveDocChecks } from '../interactive/doc-checks-routes.js';
|
|
117
126
|
import { crewStateHome, stateHomeOfDb } from '../projects/state-home.js';
|
|
118
|
-
import {
|
|
127
|
+
import { demoShowOf, factsOf, inputLines, jobLaunchCommon, personPid, requestDigest, SELF_SEATED } from './chat-jobs.js';
|
|
128
|
+
import { CATALOG_V2_CARDS } from '../workflow-catalog/catalog-data-v2.js';
|
|
129
|
+
import { ChatProposals, LaunchOnceRegistry, proposalRunId, RecordingStubDispatcher, RevisionEditsSchema, runCostFromEvents } from './chat-proposals.js';
|
|
119
130
|
import { CATALOG_SEEDS } from '../workflow-catalog/catalog-data.js';
|
|
120
131
|
import { registerInteractiveDocList } from '../interactive/doc-list-routes.js';
|
|
121
132
|
import { REVIEWS_DIRNAME } from '../interactive/review-ledger.js';
|
|
122
133
|
import { MembershipIndex } from '../projects/membership-index.js';
|
|
123
134
|
import { MEMBERSHIP_ATTACHED, membershipAttachedKey } from '../projects/events.js';
|
|
124
|
-
import { resolveLinkedIssues } from '../core/linked-issues.js';
|
|
135
|
+
import { resolveLinkedIssues, stripLinkedIssues } from '../core/linked-issues.js';
|
|
136
|
+
import { reRegisterRefusal } from '../projects/repo-guard.js';
|
|
137
|
+
import { registerTrackerActionRoutes } from '../knowledge/trackers/actions.js';
|
|
138
|
+
import { pmRegistered, readPmIssues } from '../knowledge/trackers/issues.js';
|
|
139
|
+
import { registerTrackerRoutes } from '../knowledge/trackers/routes.js';
|
|
125
140
|
import { AuditLog } from './audit.js';
|
|
141
|
+
import { auditFor } from './audit-view.js';
|
|
126
142
|
import { AcpFoldCache, EngineVersionCache, FloorCacheCache, eventsDirOf, installedPackageVersion, hostSandboxLauncher, seatRosterFile, listStoreFiles, readStudioBundleVersion, } from './diagnostics.js';
|
|
127
143
|
import { GovernanceDiagnostics } from './governance-health.js';
|
|
128
144
|
import { ATTACHMENT_LIMITS, ATTACHMENT_MAX_MESSAGE_BYTES, AttachmentError, ChatAttachmentStore, attachmentWire, attachmentsBlock, boundaryOf, parseMultipart, stageForSeat } from './chat-attachments.js';
|
|
129
145
|
import { CHAT_HISTORY_MAX_LIMIT, ChatHistoryStore, decodeCursor } from './chat-history.js';
|
|
130
146
|
import { PROBE_TIMEOUT_MS, SYSTEM_BUDGET_MS, SYSTEM_STATS_DAYS, SYSTEM_STATS_TTL_MS, WeekFoldCache, assembleSnapshot, buildNeeds, buildClis, buildGovernance, diskRow, estateReadonlyCall, infraRow, judgeGaps, livenessThresholds, loadRow, probeBroker, probeBus, probeEstate, probeGateway, probeInteractive, probeVault, readBridgeLockAsync, readWeek, resolveContainerRuntime, runLiveness, settleWithin, skillsRow, sortRuns, stateHomeRow, reposRow, unfinished, } from './system-snapshot.js';
|
|
131
|
-
import { parseSeatImageStatus, probeSeatImages, SeatImageRebuilder } from './seat-images.js';
|
|
147
|
+
import { idleClis, parseSeatImageStatus, probeSeatImages, SeatImageRebuilder } from './seat-images.js';
|
|
132
148
|
import { RunCostCache } from './needs.js';
|
|
133
149
|
import { governanceStoreFix, legacyHomeOutboxPath } from '../core/governance-store.js';
|
|
134
150
|
import { UsageError, replayOutboxInto } from '../cli/governance.js';
|
|
@@ -147,7 +163,7 @@ import { GuidanceIndex } from './guidance-index.js';
|
|
|
147
163
|
import { DELIVER_REQUESTED_ACTION, DeliveryIndex, gitRunBranchIsEmpty, gitWorktreeIsClean, isDeliverConflictStranded, deliveryRecordFrom, deliverUnitOf, pushedState, canDeliverResolver, FREE_TEXT_NOTICE, freeTextOutcome, } from './delivery-index.js';
|
|
148
164
|
import { DeliveryDerivationCache } from './delivery-cache.js';
|
|
149
165
|
import { gitReprovisionWorktree, runDeliverScript, } from './post-hoc-deliver.js';
|
|
150
|
-
import { LOCAL_ACTOR, trustAtLeast } from './auth.js';
|
|
166
|
+
import { LOCAL_ACTOR, trustAtLeast, viewOf } from './auth.js';
|
|
151
167
|
// Re-exported so existing `import { API_PREFIX } from './routes.js'` callers keep working; the
|
|
152
168
|
// value lives in the leaf module api-prefix.ts to keep unit-output.ts out of this file's cycle.
|
|
153
169
|
export { API_PREFIX } from './api-prefix.js';
|
|
@@ -162,6 +178,11 @@ import { gardenConformance, gardenPackCheck } from '../editors/pack-install.js';
|
|
|
162
178
|
import { conformanceProvisioner, conformanceRuntimeRoot } from '../editors/conformance-runtime.js';
|
|
163
179
|
import { EditorRegistry } from '../editors/registry.js';
|
|
164
180
|
import { registerEditorRoutes } from '../editors/routes.js';
|
|
181
|
+
import { AppWritePath } from '../apps/actions/write-path.js';
|
|
182
|
+
import { AppExecutor } from '../apps/exec/executor.js';
|
|
183
|
+
import { localViewerOf } from '../apps/exec/viewer.js';
|
|
184
|
+
import { registerAppRoutes } from '../apps/routes.js';
|
|
185
|
+
import { AppStoreError } from '../apps/store.js';
|
|
165
186
|
import { registerMcpInspectRoutes } from '../mcp-inspect/routes.js';
|
|
166
187
|
import { discoverLivePlugin } from '../skills/plugin-source.js';
|
|
167
188
|
import { resolveDecisionsMode } from '../decisions/types.js';
|
|
@@ -205,11 +226,6 @@ function codeGraphDbOr503(repo, reply) {
|
|
|
205
226
|
return null;
|
|
206
227
|
}
|
|
207
228
|
}
|
|
208
|
-
/**
|
|
209
|
-
* `true` after answering **409** when the repo's registered folder is gone, BEFORE anything spawns
|
|
210
|
-
* there: Node reports a missing spawn `cwd` as `spawn <binary> ENOENT`, which named an installed
|
|
211
|
-
* binary as the fault (rig, tiny-math). The words are the finding's, the same everywhere.
|
|
212
|
-
*/
|
|
213
229
|
function refusedMissingFolder(repo, reply) {
|
|
214
230
|
const missing = repoFolderMissing(repo);
|
|
215
231
|
if (missing === null)
|
|
@@ -220,6 +236,22 @@ function refusedMissingFolder(repo, reply) {
|
|
|
220
236
|
function message(err) {
|
|
221
237
|
return err instanceof Error ? err.message : String(err);
|
|
222
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* What the shared launch function answers (DES-CHAT-FIRST-001 C3): the status and body `POST /runs` sends. Shaped like
|
|
241
|
+
* the reply the route body was written against, so the launch policy reads the same in one place for every launcher.
|
|
242
|
+
*/
|
|
243
|
+
export class LaunchReply {
|
|
244
|
+
statusCode = 200;
|
|
245
|
+
payload = undefined;
|
|
246
|
+
code(statusCode) {
|
|
247
|
+
this.statusCode = statusCode;
|
|
248
|
+
return this;
|
|
249
|
+
}
|
|
250
|
+
send(payload) {
|
|
251
|
+
this.payload = payload;
|
|
252
|
+
return this;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
223
255
|
/**
|
|
224
256
|
* Turns a failed parse into a 400 body, naming any field the schema does not know.
|
|
225
257
|
*
|
|
@@ -352,8 +384,7 @@ const RULE_STATUSES = new Set(['active', 'retired', 'all']);
|
|
|
352
384
|
// Repo names become directory components under ~/.wicked/repos/ — reject anything
|
|
353
385
|
// that would allow path traversal (slashes, dots-only segments, control chars).
|
|
354
386
|
const SAFE_REPO_NAME = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
355
|
-
const RegisterRepoSchema = z
|
|
356
|
-
.object({
|
|
387
|
+
export const RegisterRepoSchema = z.strictObject({
|
|
357
388
|
name: z
|
|
358
389
|
.string()
|
|
359
390
|
.min(1)
|
|
@@ -372,25 +403,24 @@ const RegisterRepoSchema = z
|
|
|
372
403
|
actor: z.string().min(1).max(256).optional(),
|
|
373
404
|
/** crew#552: `false` = this onboarding chains no capture-learnings run (a one-off). */
|
|
374
405
|
autoCapture: z.boolean().optional(),
|
|
406
|
+
/** (api-types 0.172.0, DES-APPS-001) A new empty repo under the apps root; no onboarding. */
|
|
407
|
+
create: z.literal(true).optional(),
|
|
375
408
|
})
|
|
376
|
-
.strict()
|
|
377
409
|
.refine((d) => {
|
|
378
410
|
const hasRemote = typeof d.gitUrl === 'string' && d.gitUrl.length > 0;
|
|
379
411
|
const hasLocal = typeof d.rootPath === 'string' && d.rootPath.length > 0;
|
|
380
|
-
// gitUrl alone (clone to default path), gitUrl + rootPath (clone
|
|
381
|
-
// or rootPath alone (register existing local repo) — all valid.
|
|
382
|
-
return hasRemote || hasLocal;
|
|
383
|
-
}, {
|
|
412
|
+
// create alone (a new empty repo), gitUrl alone (clone to default path), gitUrl + rootPath (clone
|
|
413
|
+
// to custom path), or rootPath alone (register existing local repo) — all valid.
|
|
414
|
+
return d.create === true ? !hasRemote && !hasLocal : hasRemote || hasLocal;
|
|
415
|
+
}, { error: 'Provide create (a new empty repo), or gitUrl (remote clone) or rootPath (local registration), or both of those.' });
|
|
384
416
|
/** `POST /repos/:id/onboard`'s optional body (crew#496): where to file the run, and who asked. */
|
|
385
|
-
const OnboardBodySchema = z
|
|
386
|
-
.object({
|
|
417
|
+
const OnboardBodySchema = z.strictObject({
|
|
387
418
|
projectId: z.string().min(1).max(128).optional(),
|
|
388
419
|
channel: z.enum(['studio', 'cli', 'api']).optional(),
|
|
389
420
|
actor: z.string().min(1).max(256).optional(),
|
|
390
421
|
/** crew#552: `false` = this onboarding chains no capture-learnings run (a one-off). */
|
|
391
422
|
autoCapture: z.boolean().optional(),
|
|
392
|
-
})
|
|
393
|
-
.strict();
|
|
423
|
+
});
|
|
394
424
|
/**
|
|
395
425
|
* The launch body. Every field but `problem` is optional, which is what made stripping dangerous:
|
|
396
426
|
* omitting one is a legitimate request that gets an engine default, so a MISSPELLED one was
|
|
@@ -462,7 +492,7 @@ export function primaryRefusal(primary, clisJson) {
|
|
|
462
492
|
}
|
|
463
493
|
return null;
|
|
464
494
|
}
|
|
465
|
-
export const LaunchSchema = z.
|
|
495
|
+
export const LaunchSchema = z.strictObject({
|
|
466
496
|
problem: z.string().min(1),
|
|
467
497
|
sessionId: z.string().min(1).optional(),
|
|
468
498
|
clisJson: z.string().min(1).optional(),
|
|
@@ -514,7 +544,7 @@ export const LaunchSchema = z.object({
|
|
|
514
544
|
* (explicit `"none"` is a 400; a daemon that resolves the omitted field to `none` is a 409).
|
|
515
545
|
* Resolved via `gh pr view` at launch — not OPEN / a fork / gh failure ⇒ 409, nothing launched.
|
|
516
546
|
* Send it only when `GET /health.capabilities.revisesPr === true` (engine ≥ 0.7.27). */
|
|
517
|
-
revisesPr: z.
|
|
547
|
+
revisesPr: z.int().positive().optional(),
|
|
518
548
|
/** crew#619 — the chat this run was promoted from; the daemon retains that chat's transcript
|
|
519
549
|
* on disk until this run reaches a terminal state so the Continue-in-Build prefill is
|
|
520
550
|
* always reproducible. Optional; omit when the launch is not promoted from a chat. */
|
|
@@ -544,32 +574,34 @@ export const LaunchSchema = z.object({
|
|
|
544
574
|
* acceptance, with a reason (labelled on the run, every gate and the delivery), or its explicit
|
|
545
575
|
* force (no score waiver). Forwarded only when sent; crew never decides either for the caller,
|
|
546
576
|
* and the engine refuses either on a run whose workflow does not require QE acceptance. */
|
|
547
|
-
skipQeAcceptance: z.
|
|
577
|
+
skipQeAcceptance: z.strictObject({ reason: z.string().trim().min(1).max(2000) }).optional(),
|
|
548
578
|
forceQeAcceptance: z.boolean().optional(),
|
|
549
|
-
|
|
550
|
-
|
|
579
|
+
/** (api-types 0.192.0, DES-CATALOG-002 §4.4) What this launch is the shape of; judged against the current catalog. */
|
|
580
|
+
shape: LaunchShapeSchema.optional(),
|
|
581
|
+
}).refine((b) => b.skipQeAcceptance === undefined || b.forceQeAcceptance !== true, {
|
|
551
582
|
path: ['forceQeAcceptance'],
|
|
583
|
+
error: 'skipQeAcceptance and forceQeAcceptance are mutually exclusive — skip it with a reason, or force it',
|
|
552
584
|
}).refine((b) => b.plan === undefined || b.workflow === undefined, {
|
|
553
|
-
message: 'plan and workflow are mutually exclusive — a launch carries a plan or names a preset, not both',
|
|
554
585
|
path: ['plan'],
|
|
586
|
+
error: 'plan and workflow are mutually exclusive — a launch carries a plan or names a preset, not both',
|
|
555
587
|
}).refine((b) => b.plan !== undefined || b.deliver !== 'pr' || b.workflow !== undefined, {
|
|
556
|
-
message: 'deliver: "pr" requires a workflow — a free-text run has no def to append the deliver phase to',
|
|
557
588
|
path: ['deliver'],
|
|
589
|
+
error: 'deliver: "pr" requires a workflow — a free-text run has no def to append the deliver phase to',
|
|
558
590
|
}).refine((b) => b.deliverGate === undefined || b.deliver !== 'none', {
|
|
559
591
|
// F-E2E-030: a deliver-gate posture on a launch that declines delivery is a contradiction the
|
|
560
592
|
// caller should hear about, not a silent no-op. (A launch that OMITS `deliver` may still
|
|
561
593
|
// resolve to no deliver unit — repo-less, free-text, read-only def; the field is then inert.)
|
|
562
|
-
message: 'deliverGate has no meaning with deliver: "none" — there is no deliver phase to gate',
|
|
563
594
|
path: ['deliverGate'],
|
|
595
|
+
error: 'deliverGate has no meaning with deliver: "none" — there is no deliver phase to gate',
|
|
564
596
|
}).refine((b) => b.campaignId === undefined || b.groupLabel === undefined, {
|
|
565
|
-
message: 'campaignId and groupLabel are mutually exclusive — a run files onto ONE grouping surface (an existing campaign, or a label group)',
|
|
566
597
|
path: ['groupLabel'],
|
|
598
|
+
error: 'campaignId and groupLabel are mutually exclusive — a run files onto ONE grouping surface (an existing campaign, or a label group)',
|
|
567
599
|
}).refine((b) => b.revisesPr === undefined || (b.repoRef !== undefined && b.workflow !== undefined), {
|
|
568
|
-
message: 'revisesPr needs repoRef and workflow — a revision bases a repo-scoped, def-driven run on the pull request\'s branch',
|
|
569
600
|
path: ['revisesPr'],
|
|
601
|
+
error: 'revisesPr needs repoRef and workflow — a revision bases a repo-scoped, def-driven run on the pull request\'s branch',
|
|
570
602
|
}).refine((b) => b.revisesPr === undefined || b.deliver !== 'none', {
|
|
571
|
-
message: 'revisesPr needs deliver: "pr" — a launch that declines delivery has no phase to push the revision with',
|
|
572
603
|
path: ['revisesPr'],
|
|
604
|
+
error: 'revisesPr needs deliver: "pr" — a launch that declines delivery has no phase to push the revision with',
|
|
573
605
|
});
|
|
574
606
|
/** The escalation arms (wicked-core#469 / #467): approve-shaped, no `amend` / `amendScope`.
|
|
575
607
|
* `extend` | `targeted` | `accept_partial` answer the gate of a repo-checks floor that did not
|
|
@@ -579,7 +611,18 @@ export const LaunchSchema = z.object({
|
|
|
579
611
|
* re-runs the judge of a `judge_unavailable` gate on the same work, the step's seat not run again.
|
|
580
612
|
* The ENGINE refuses each at any other gate (a 409 naming the gate it answers) — and `rejudge`
|
|
581
613
|
* while no judge seat is eligible ({@link GateInfo.rejudge} says beforehand). */
|
|
582
|
-
export const ESCALATION_ACTIONS = ['extend', 'targeted', 'accept_partial', 'accept_suggestion', 'rejudge'];
|
|
614
|
+
export const ESCALATION_ACTIONS = ['extend', 'targeted', 'accept_partial', 'accept_suggestion', 'rejudge', 'retry_rules'];
|
|
615
|
+
/** (DES-RULE-CHECK-001 S2, api-types 0.190.0) At a gate the steering-rule check holds or denies:
|
|
616
|
+
* `retry_rules` (an escalation arm above) re-runs the rule check on the same work, the step's seat
|
|
617
|
+
* not run again; `skip_rules` skips held rules (unchecked, a waiver to confirm, or, rev 2 / api-types
|
|
618
|
+
* 0.193.0, disputed: no council ruling), each with a written reason (`skipRules: [{id, reason}]`,
|
|
619
|
+
* required), then re-runs it. A skip is labelled on the run, the gate and the delivery receipts.
|
|
620
|
+
* Since wicked-core-ts 0.15.30 the engine takes both wherever a rule layer is in the gated unit's
|
|
621
|
+
* denial record (behind a reviewer's FAIL, at `review_adjudication`), refuses them at any other
|
|
622
|
+
* gate, and refuses a skip of a rule that is not held (a broken rule denies, a council's broken
|
|
623
|
+
* ruling too): crew forwards both unfiltered, so the engine is the one check, and its refusal is
|
|
624
|
+
* the 409. Skipping is the human operator's call alone. */
|
|
625
|
+
export const SKIP_RULES_ACTION = 'skip_rules';
|
|
583
626
|
/** (core#820) A consent gate's answer token: `consent:<choice id>` approves that row of the dry-run
|
|
584
627
|
* plan (the engine refuses an id its plan does not offer); `reject` stays the decline. */
|
|
585
628
|
export const CONSENT_CHOICE_ACTION = /^consent:[A-Za-z0-9_-]{1,32}$/u; // core `parse_plan` caps a choice id at 32
|
|
@@ -614,15 +657,19 @@ export const OPERATOR_JUDGMENT_ACTION = 'operator_judgment';
|
|
|
614
657
|
* denied (it counts), or a failed floor's gate with QE behind it (it re-opens on the floor alone).
|
|
615
658
|
* Refused (409, gate left open) everywhere else and on a run that does not require QE. */
|
|
616
659
|
export const SKIP_QE_ACTION = 'skip_qe';
|
|
660
|
+
/** (DES-RULE-CHECK-001 S2) The engine's `skip_rules` amend: `[{"id", "reason"}]`, reasons trimmed. */
|
|
661
|
+
export function skipRulesAmend(skips) {
|
|
662
|
+
return JSON.stringify(skips.map((s) => ({ id: s.id.trim(), reason: s.reason.trim() })));
|
|
663
|
+
}
|
|
617
664
|
/** (studio#923) The label an operator's QE skip carries on the run, every later gate and the
|
|
618
665
|
* delivery — the engine's words ("QE acceptance skipped by operator: <reason>"). */
|
|
619
666
|
export const QE_SKIPPED_BY_OPERATOR_LABEL = 'QE acceptance skipped by operator';
|
|
620
|
-
export const GateSchema = z.
|
|
667
|
+
export const GateSchema = z.strictObject({
|
|
621
668
|
approve: z.boolean(),
|
|
622
669
|
amend: z.string().optional(),
|
|
623
670
|
action: z
|
|
624
671
|
.union([
|
|
625
|
-
z.enum(['approve', 'request_changes', 'reject', 'edit_plan', 'amend_intent', OPERATOR_JUDGMENT_ACTION, SKIP_QE_ACTION, ...ESCALATION_ACTIONS]),
|
|
672
|
+
z.enum(['approve', 'request_changes', 'reject', 'edit_plan', 'amend_intent', OPERATOR_JUDGMENT_ACTION, SKIP_QE_ACTION, SKIP_RULES_ACTION, ...ESCALATION_ACTIONS]),
|
|
626
673
|
z.string().regex(CONSENT_CHOICE_ACTION, 'a consent choice is `consent:<choice id>`'),
|
|
627
674
|
])
|
|
628
675
|
.optional(),
|
|
@@ -631,7 +678,10 @@ export const GateSchema = z.object({
|
|
|
631
678
|
plan: PlanSchema.optional(),
|
|
632
679
|
/** api-types 0.44.0 — the gate this decision answers (its unit `ord`). A mismatch with the run's
|
|
633
680
|
* open gate is a 409 `gate_changed`: the decision was made on a gate that is no longer open. */
|
|
634
|
-
ord: z.
|
|
681
|
+
ord: z.int().nonnegative().optional(),
|
|
682
|
+
/** (api-types 0.192.0, DES-CATALOG-002 §4.6) At a `plan_approval` gate: the plan revision this answer was made on.
|
|
683
|
+
* Passed with `ord` into the engine's own serialized decision, which refuses a stale one (`gate_changed`). */
|
|
684
|
+
planRev: z.int().nonnegative().optional(),
|
|
635
685
|
/** (api-types 0.156.0, DES-VOICE) The person answered by voice and confirmed it on screen: recorded on the
|
|
636
686
|
* `gate.decided` audit line and the decided-gate history ("by voice, confirmed"). It grants nothing. */
|
|
637
687
|
input: z.literal('voice').optional(),
|
|
@@ -640,31 +690,41 @@ export const GateSchema = z.object({
|
|
|
640
690
|
* declined. Absent = every drafted rule lands, as before. 409 `no_draft` unless the run waits at its
|
|
641
691
|
* steering-author propose gate with a readable draft; 400 with anything but a plain approve. */
|
|
642
692
|
keepRules: z.array(z.string().min(1).max(256)).max(500).optional(),
|
|
643
|
-
|
|
644
|
-
|
|
693
|
+
/** (DES-RULE-CHECK-001 S2, api-types 0.190.0) With `action: 'skip_rules'`: the held rules to skip
|
|
694
|
+
* (unchecked, waived or disputed), each with the person's written reason. */
|
|
695
|
+
skipRules: z
|
|
696
|
+
.array(z.strictObject({ id: z.string().trim().min(1).max(256), reason: z.string().trim().min(1).max(2000) }))
|
|
697
|
+
.min(1)
|
|
698
|
+
.max(500)
|
|
699
|
+
.optional(),
|
|
700
|
+
}).refine((b) => (b.action === SKIP_RULES_ACTION) === (b.skipRules !== undefined), { path: ['skipRules'], error: 'skip_rules needs `skipRules`: [{id, reason}] for each rule you skip (unchecked, waived or disputed), each with your written reason; skipRules goes with skip_rules only' }).refine((b) => b.action !== SKIP_RULES_ACTION || (b.approve && b.amend === undefined && b.amendScope === undefined && b.plan === undefined), { path: ['action'], error: 'skip_rules takes approve: true and no amend, amendScope or plan — the reasons ride skipRules' }).refine((b) => b.skipRules === undefined || new Set(b.skipRules.map((r) => r.id)).size === b.skipRules.length, { path: ['skipRules'], error: 'skipRules names a rule twice' }).refine((b) => b.keepRules === undefined || (b.approve && (b.action === undefined || b.action === 'approve') && b.plan === undefined), { path: ['keepRules'], error: 'keepRules goes with a plain approve (no action other than approve, no plan) of a steering-author propose gate' }).refine((b) => b.action === undefined
|
|
701
|
+
|| (b.action === 'approve' || b.action === 'edit_plan' || b.action === 'amend_intent' || b.action === OPERATOR_JUDGMENT_ACTION || b.action === SKIP_QE_ACTION || b.action === SKIP_RULES_ACTION || isEscalationAction(b.action)) === b.approve, { path: ['action'], error: '`action` disagrees with `approve`: request_changes and reject require approve: false; approve, edit_plan, amend_intent, operator_judgment, skip_qe, skip_rules, extend, targeted, accept_partial, accept_suggestion, rejudge, retry_rules and consent:<id> require approve: true' }).refine(
|
|
645
702
|
// (operator ruling 2026-10-21) The override's rationale IS its record: a blank one is a 400 here,
|
|
646
703
|
// before the engine is asked.
|
|
647
|
-
(b) => b.action !== OPERATOR_JUDGMENT_ACTION || (b.amend !== undefined && b.amend.trim() !== ''), {
|
|
704
|
+
(b) => b.action !== OPERATOR_JUDGMENT_ACTION || (b.amend !== undefined && b.amend.trim() !== ''), { path: ['amend'], error: 'operator_judgment needs `amend`: your written rationale — why the failed floor is not the work\'s (an empty one is refused)' }).refine((b) => b.action !== OPERATOR_JUDGMENT_ACTION || (b.amendScope === undefined && b.plan === undefined), { path: ['amendScope'], error: 'operator_judgment takes no amendScope or plan — it answers the failed floor of the gated unit' }).refine(
|
|
648
705
|
// (j4-gates) A QE skip's reason IS its record, as at launch: a blank one is a 400 here.
|
|
649
|
-
(b) => b.action !== SKIP_QE_ACTION || (b.amend !== undefined && b.amend.trim() !== ''), {
|
|
706
|
+
(b) => b.action !== SKIP_QE_ACTION || (b.amend !== undefined && b.amend.trim() !== ''), { path: ['amend'], error: 'skip_qe needs `amend`: your written reason for skipping QE acceptance (an empty one is refused)' }).refine((b) => b.action !== SKIP_QE_ACTION || (b.amendScope === undefined && b.plan === undefined), { path: ['amendScope'], error: 'skip_qe takes no amendScope or plan — it answers the run\'s QE acceptance' }).refine(
|
|
650
707
|
// (wicked-core#555) An intent amendment IS its text: an empty one amends nothing, and the arm's
|
|
651
708
|
// scope is every unit at or after the cursor — which is what makes it reach the evaluator — so
|
|
652
709
|
// `amendScope` cannot narrow it. Both are 400s here rather than a 409 from the engine.
|
|
653
|
-
(b) => b.action !== 'amend_intent' || (b.amend !== undefined && b.amend.trim() !== ''), {
|
|
710
|
+
(b) => b.action !== 'amend_intent' || (b.amend !== undefined && b.amend.trim() !== ''), { path: ['amend'], error: 'amend_intent needs `amend`: what the run\'s acceptance list now says (approve without an action to proceed unamended)' }).refine((b) => b.action !== 'amend_intent' || (b.amendScope === undefined && b.plan === undefined), { path: ['amendScope'], error: 'amend_intent takes no amendScope or plan — an intent amendment reaches every unit at or after the cursor, which is what makes it reach the evaluator' }).refine((b) => !isEscalationAction(b.action) || (b.amend === undefined && b.amendScope === undefined && b.plan === undefined), { path: ['action'], error: 'extend, targeted, accept_partial, accept_suggestion, rejudge, retry_rules and consent:<id> take no amend, amendScope or plan — the engine re-runs the floor, adopts the pinned edit, re-runs the judge or the rule check, or runs the chosen install as it stands' }).refine((b) => (b.action === 'edit_plan') === (b.plan !== undefined) || (b.action === undefined && b.plan !== undefined), { path: ['plan'], error: 'an edited plan answers a plan_approval gate: `plan` needs approve: true with `action` omitted or edit_plan, and edit_plan needs `plan`' }).refine(
|
|
711
|
+
// (crew#1139) `amend` beside a plan is the operator's note to the steps it releases (the engine lands
|
|
712
|
+
// it on the plan's first creator step); a plan gate's note has no scope to choose.
|
|
713
|
+
(b) => b.plan === undefined || (b.approve && b.amendScope === undefined), { path: ['plan'], error: '`plan` is an approve WITH an edited plan: approve: true, and no amendScope (a note in `amend` lands on the plan\'s first creator step)' }).refine((b) => b.amendScope === undefined || b.approve, { path: ['amendScope'], error: '`amendScope` applies to an approve only (approve: true)' });
|
|
654
714
|
/** `PUT /runs/:id/guidance` (DES-UX-002 §7.2, CREW-UX-7) — the durable pre-gate note body.
|
|
655
715
|
* The empty string is a legal body: it CLEARS the note. The byte cap is checked in the route
|
|
656
716
|
* (not zod's char-counting `max`) so the 400 names the actual limit. */
|
|
657
|
-
export const GuidanceSchema = z.
|
|
717
|
+
export const GuidanceSchema = z.strictObject({
|
|
658
718
|
text: z.string(),
|
|
659
|
-
})
|
|
719
|
+
});
|
|
660
720
|
/** ~8KB — a guidance note is operator prose, not a document store. */
|
|
661
721
|
const GUIDANCE_MAX_BYTES = 8192;
|
|
662
722
|
/** `POST /runs/:id/cancel` (api-types `CancelRunRequest`): optional, so a bodiless cancel stays valid. */
|
|
663
|
-
const CancelSchema = z.
|
|
723
|
+
const CancelSchema = z.strictObject({
|
|
664
724
|
reason: z.string().trim().max(2000).optional(),
|
|
665
725
|
input: z.literal('voice').optional(),
|
|
666
|
-
})
|
|
667
|
-
const InjectSchema = z.
|
|
726
|
+
});
|
|
727
|
+
const InjectSchema = z.strictObject({
|
|
668
728
|
message: z.string().min(1),
|
|
669
729
|
/** `"all"` broadcasts to every active worker; any other value is a CLI key. */
|
|
670
730
|
target: z.string().min(1).default('all'),
|
|
@@ -672,56 +732,56 @@ const InjectSchema = z.object({
|
|
|
672
732
|
* any other actor); kept on the `run.injected` audit line and stamped on the note's queued/injected frames so the
|
|
673
733
|
* thread says "You (by voice)". It grants nothing a typed note does not. */
|
|
674
734
|
input: z.literal('voice').optional(),
|
|
675
|
-
})
|
|
735
|
+
});
|
|
676
736
|
// The manual reassign lever (crew#442): `cli` omitted lets the engine's council re-pick, the
|
|
677
737
|
// same shape the automatic stall-watchdog escalation uses for an unknown failover target.
|
|
678
|
-
const ReassignSchema = z.
|
|
738
|
+
const ReassignSchema = z.strictObject({
|
|
679
739
|
cli: z.string().min(1).optional(),
|
|
680
740
|
/** crew#1153: an operator note that rides a GATED reassign as the approve's amendment. Trimmed in
|
|
681
741
|
* the route; blank counts as absent. The byte cap (on the raw note) is checked there too so the 400 names the limit. */
|
|
682
742
|
note: z.string().optional(),
|
|
683
|
-
})
|
|
684
|
-
export const OpenTerminalSchema = z.
|
|
743
|
+
});
|
|
744
|
+
export const OpenTerminalSchema = z.strictObject({
|
|
685
745
|
cwd: z.string().min(1),
|
|
686
746
|
cmd: z.array(z.string().min(1)).min(1).optional(),
|
|
687
|
-
cols: z.
|
|
688
|
-
rows: z.
|
|
747
|
+
cols: z.int().positive(),
|
|
748
|
+
rows: z.int().positive(),
|
|
689
749
|
// Optional so omission is the SAFE governed default (§7 — `false` is never a
|
|
690
750
|
// default; the ungoverned operator shell must opt in explicitly).
|
|
691
751
|
governed: z.boolean().optional(),
|
|
692
|
-
})
|
|
752
|
+
});
|
|
693
753
|
/** `POST /seats/:cli/login|logout` body (crew#615): the PTY size, both optional. */
|
|
694
|
-
export const SeatSessionSchema = z.
|
|
695
|
-
cols: z.
|
|
696
|
-
rows: z.
|
|
697
|
-
})
|
|
698
|
-
const ResizeTerminalSchema = z.
|
|
699
|
-
cols: z.
|
|
700
|
-
rows: z.
|
|
701
|
-
})
|
|
754
|
+
export const SeatSessionSchema = z.strictObject({
|
|
755
|
+
cols: z.int().positive().optional(),
|
|
756
|
+
rows: z.int().positive().optional(),
|
|
757
|
+
});
|
|
758
|
+
const ResizeTerminalSchema = z.strictObject({
|
|
759
|
+
cols: z.int().positive(),
|
|
760
|
+
rows: z.int().positive(),
|
|
761
|
+
});
|
|
702
762
|
/** `POST /open` (crew#273) — the studio Files tab's "open with the OS default app" body. */
|
|
703
|
-
export const OpenPathSchema = z.
|
|
763
|
+
export const OpenPathSchema = z.strictObject({
|
|
704
764
|
path: z.string().min(1),
|
|
705
765
|
runId: z.string().min(1).optional(),
|
|
706
|
-
})
|
|
766
|
+
});
|
|
707
767
|
/** `POST /memory/retire` body (DES-MEM-FACETED-001). `scope_prefix` is REQUIRED and, after trim,
|
|
708
768
|
* non-empty (enforced in the route so the 400 names the total-wipe guard): estate `memory.erase`
|
|
709
769
|
* is subtree-scoped and refuses an empty prefix. `.strict()` for the FINDING-031 posture — an
|
|
710
770
|
* unknown field is a 400, never silently ignored into a broader erase than the caller sent. */
|
|
711
|
-
export const RetireMemorySchema = z.
|
|
771
|
+
export const RetireMemorySchema = z.strictObject({
|
|
712
772
|
scope_prefix: z.string(),
|
|
713
|
-
})
|
|
773
|
+
});
|
|
714
774
|
/** `POST /memory/retire-item` body (studio#206): ONE memory, by its `memory_id` from `GET /memory`.
|
|
715
775
|
* `.strict()`: a stray `scope_prefix` is a 400, never read as a wider erase than one row. */
|
|
716
|
-
export const RetireMemoryItemSchema = z.
|
|
776
|
+
export const RetireMemoryItemSchema = z.strictObject({
|
|
717
777
|
memory_id: z.string().min(1).max(512),
|
|
718
|
-
})
|
|
778
|
+
});
|
|
719
779
|
/** `POST /memory/edit` body (wicked-studio's Memory page): ONE memory's new words. `.strict()`: an
|
|
720
780
|
* unknown field is a 400, never read as something wider than one memory. */
|
|
721
|
-
export const EditMemorySchema = z.
|
|
781
|
+
export const EditMemorySchema = z.strictObject({
|
|
722
782
|
memory_id: z.string().min(1).max(512),
|
|
723
783
|
content: z.string().min(1).max(4000),
|
|
724
|
-
})
|
|
784
|
+
});
|
|
725
785
|
/** estate `memory.capture`'s `kind` for a tier — the kind natural to it, as estate's own proposal
|
|
726
786
|
* approve picks (`kind_for_tier`), so an edited memory keeps the kind its tier implies. */
|
|
727
787
|
const KIND_FOR_TIER = {
|
|
@@ -781,7 +841,7 @@ function withServedSeq(merged) {
|
|
|
781
841
|
* `POST /chats` body (crew#165; `projectId` DES-PROJECT-001 §2.2; `repoRefs` + scope semantics
|
|
782
842
|
* crew#502). Exported for the wire-contract drift guard (`tests/wire-contract.test.ts`).
|
|
783
843
|
*/
|
|
784
|
-
export const ChatOpenSchema = z.
|
|
844
|
+
export const ChatOpenSchema = z.strictObject({
|
|
785
845
|
chatId: z.string().min(1).max(128).regex(/^[A-Za-z0-9._-]+$/).optional(),
|
|
786
846
|
clis: z.array(z.string().min(1)).min(1).max(8).optional(),
|
|
787
847
|
/** One repo in scope — the legacy spelling, merged into `repoRefs` (crew#502). */
|
|
@@ -797,14 +857,29 @@ export const ChatOpenSchema = z.object({
|
|
|
797
857
|
/** (ASK-C1) The seat the operator chose as the primary agent; omitted ⇒ the engine picks at random. */
|
|
798
858
|
primary: z.string().min(1).optional(),
|
|
799
859
|
/** (api-types 0.137.0, DES-SYSTEM-CHAT) The page the chat was started on, for the history list. */
|
|
800
|
-
startedOn: z.
|
|
860
|
+
startedOn: z.strictObject({ route: z.string().min(1).max(512), label: z.string().min(1).max(200) }).optional(),
|
|
801
861
|
/** (api-types 0.141.0, crew#1157) The read-only workflow every turn runs (`analyze`); see
|
|
802
862
|
* `chat-workflow.ts`. Omitted ⇒ a plain chat. */
|
|
803
863
|
workflow: z.string().min(1).max(64).optional(),
|
|
804
864
|
/** (api-types 0.169.0, DES-CHAT-ARTIFACTS-001 §6.3) "Ask about this" on a document no open chat holds: seed the
|
|
805
865
|
* chat's repositories from the document's recorded binding, after an access check. */
|
|
806
866
|
seedFromArtifact: z.string().max(200).optional(),
|
|
807
|
-
|
|
867
|
+
/** (api-types 0.192.0, DES-CATALOG-002 §4.6) A `/` pick or a command with no chat open: the chat opens with this
|
|
868
|
+
* person-made proposal in it; its id and the proposal's derive from (the person, `requestId`). */
|
|
869
|
+
seed: z.strictObject({
|
|
870
|
+
card: z.string().trim().min(1).max(120),
|
|
871
|
+
option: z.string().trim().min(1).max(80).nullable().optional(),
|
|
872
|
+
depth: z.enum(['quick', 'standard', 'deep']).nullable().optional(),
|
|
873
|
+
words: z.string().max(8000).optional(),
|
|
874
|
+
source: z.enum(['pick', 'command']),
|
|
875
|
+
}).optional(),
|
|
876
|
+
requestId: z.string().trim().min(1).max(128).optional(),
|
|
877
|
+
/** (api-types 0.192.0) What the client renders (`['job']`). */
|
|
878
|
+
accepts: z.array(z.literal('job')).max(4).optional(),
|
|
879
|
+
}).refine((b) => b.seed === undefined || (b.requestId !== undefined && b.chatId === undefined), {
|
|
880
|
+
path: ['seed'],
|
|
881
|
+
error: 'seed needs requestId and no chatId: the chat id derives from you and the request',
|
|
882
|
+
});
|
|
808
883
|
/**
|
|
809
884
|
* The `singleSeat` disclosure (crew#641, hole closed in crew#650) — built in ONE place so the 201
|
|
810
885
|
* and the 202 cannot drift.
|
|
@@ -942,6 +1017,8 @@ runtime = {}) {
|
|
|
942
1017
|
? { context: true, proposals: true, create: true, refine: true, theme: true, demo: true, stub: true, stubOps }
|
|
943
1018
|
: { context: true, proposals: true, create: realCreate, refine: false, theme: false, demo: false };
|
|
944
1019
|
const proposalLaunchers = new LaunchOnceRegistry();
|
|
1020
|
+
/** (DES-CATALOG-002 §4.6) Job proposals in a chat: on wherever chat proposals are. */
|
|
1021
|
+
const chatJobProposalsOn = chatArtifactFlags.proposals;
|
|
945
1022
|
if (chatArtifactsStub) {
|
|
946
1023
|
// Under the registered `chats` entry (a new top-level state-home entry would make core refuse every launch), and
|
|
947
1024
|
// not a `.jsonl` there (the boot sweep clears orphaned transcripts by that suffix).
|
|
@@ -1056,6 +1133,55 @@ runtime = {}) {
|
|
|
1056
1133
|
conformance: runtime.editorConformance ?? gardenConformance(discoverLivePlugin()?.path ?? null, () => process.env['WICKED_CREW_URL'] ?? null, { provision: editorConformanceRuntime }),
|
|
1057
1134
|
log: (m) => app.log.warn(m),
|
|
1058
1135
|
});
|
|
1136
|
+
// DES-APPS-001 §7.6 (K2a): the app store's routes, when this daemon has a store.
|
|
1137
|
+
// (K2b) The executor: queries of an accepted version run for real (DES §7.2), crew-source reads in process.
|
|
1138
|
+
// (DES-KNOWLEDGE-DATA-001 §9.1) What an app's knowledge query reads: the gate's registry, the app's project's
|
|
1139
|
+
// visible set, estate (this daemon's stores) and the engine's rules. Absent pieces = no knowledge query runs.
|
|
1140
|
+
const appsKnowledge = runtime.dataGate !== undefined && runtime.appsKnowledgeVisible !== undefined
|
|
1141
|
+
? {
|
|
1142
|
+
sources: () => runtime.dataGate.sources(),
|
|
1143
|
+
visible: runtime.appsKnowledgeVisible,
|
|
1144
|
+
// Each estate call of an app's read is bounded by the read's own deadline (10 s), not the operator client's 30 s.
|
|
1145
|
+
estate: runtime.callEstateTool ?? ((tool, args) => callEstateTool(tool, args, { timeoutMs: STATEMENT_DEADLINE_MS })),
|
|
1146
|
+
rules: () => adapter.listConformanceRules(),
|
|
1147
|
+
}
|
|
1148
|
+
: undefined;
|
|
1149
|
+
const appsExecutor = runtime.apps !== undefined
|
|
1150
|
+
? new AppExecutor({
|
|
1151
|
+
store: runtime.apps,
|
|
1152
|
+
registry: runtime.mcp ?? null,
|
|
1153
|
+
...(appsKnowledge !== undefined ? { knowledge: appsKnowledge } : {}),
|
|
1154
|
+
projectOf: (slug) => runtime.apps.projectOf(slug),
|
|
1155
|
+
crewInject: async (r) => {
|
|
1156
|
+
const res = await app.inject({ method: r.method, url: r.url, headers: r.headers });
|
|
1157
|
+
return { statusCode: res.statusCode, body: res.body };
|
|
1158
|
+
},
|
|
1159
|
+
viewerOf: runtime.appsViewerOf ?? localViewerOf,
|
|
1160
|
+
})
|
|
1161
|
+
: undefined;
|
|
1162
|
+
// (K2b) The write path: grants, records, API actions and Postgres row writes (DES §7.3, §7.4, §9.4).
|
|
1163
|
+
const appsWritePath = runtime.apps !== undefined && runtime.appsActions !== undefined
|
|
1164
|
+
? new AppWritePath({
|
|
1165
|
+
store: runtime.apps,
|
|
1166
|
+
actions: runtime.appsActions,
|
|
1167
|
+
registry: runtime.mcp ?? null,
|
|
1168
|
+
audit,
|
|
1169
|
+
viewerOf: runtime.appsViewerOf ?? localViewerOf,
|
|
1170
|
+
...(appsExecutor !== undefined ? { executor: appsExecutor } : {}),
|
|
1171
|
+
})
|
|
1172
|
+
: undefined;
|
|
1173
|
+
if (runtime.apps !== undefined) {
|
|
1174
|
+
registerAppRoutes(app, {
|
|
1175
|
+
store: runtime.apps,
|
|
1176
|
+
audit,
|
|
1177
|
+
...(appsExecutor !== undefined ? { executor: appsExecutor } : {}),
|
|
1178
|
+
...(appsWritePath !== undefined ? { writePath: appsWritePath } : {}),
|
|
1179
|
+
...(runtime.appsVerifyUnitToken !== undefined ? { verifyUnitToken: runtime.appsVerifyUnitToken } : {}),
|
|
1180
|
+
...(typeof adapter.projectsSupported === 'function' && adapter.projectsSupported()
|
|
1181
|
+
? { projectExists: async (id) => (await adapter.projectGet(id)) !== null }
|
|
1182
|
+
: {}),
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1059
1185
|
const chatRecorder = decisions !== null && chatTranscripts !== undefined && runtime.broadcast !== undefined
|
|
1060
1186
|
? new ChatDecisionRecorder({
|
|
1061
1187
|
service: decisions,
|
|
@@ -1071,8 +1197,21 @@ runtime = {}) {
|
|
|
1071
1197
|
/** DES-L9: PR number → head branch, through `gh pr view` unless the runtime injected an answerer. */
|
|
1072
1198
|
const resolvePullRequest = runtime.resolvePullRequest ?? resolvePullRequestViaGh;
|
|
1073
1199
|
/** crew#627: the intent's linked issues, read under the daemon's identity at launch. */
|
|
1200
|
+
/** (DES-PM-001 §3.2) A project's live `crew.repo` members, for a tracker set. */
|
|
1201
|
+
const repoMembersOf = async (projectId) => (await adapter.projectMembers(projectId)).filter((m) => m.member_kind === 'crew.repo').map((m) => m.member_ref);
|
|
1202
|
+
/** (Q-PM5) With a PM source registered, its system's refs resolve only through the launch's tracker set. */
|
|
1203
|
+
const pmIssueReader = async (projectId, repoRef) => {
|
|
1204
|
+
const gate = runtime.dataGate;
|
|
1205
|
+
if (gate === undefined)
|
|
1206
|
+
return undefined;
|
|
1207
|
+
const entries = await gate.pm.entries();
|
|
1208
|
+
if (entries.length === 0)
|
|
1209
|
+
return undefined;
|
|
1210
|
+
const { systems, jiraKeys } = pmRegistered(entries);
|
|
1211
|
+
return { systems, jiraKeys, read: (refs) => readPmIssues(gate.pm, entries, { projectId, repoId: repoRef }, repoMembersOf, refs, () => gate.pm.entries()) };
|
|
1212
|
+
};
|
|
1074
1213
|
const readLinkedIssues = runtime.resolveLinkedIssues ??
|
|
1075
|
-
((p, root, ref, exclude) => resolveLinkedIssues(p, root, ref, undefined, exclude));
|
|
1214
|
+
(async (p, root, ref, exclude, projectId) => resolveLinkedIssues(p, root, ref, undefined, exclude, await pmIssueReader(projectId ?? null, ref ?? null)));
|
|
1076
1215
|
/** crew#550 P-7: the follow-ups the run's evaluator units flagged, read from their captured output.
|
|
1077
1216
|
* A unit whose output cannot be read contributes nothing (the section then says what WAS read);
|
|
1078
1217
|
* an adapter without transcripts (a directly-driven route set) reads as "not read" — absent. */
|
|
@@ -1266,6 +1405,13 @@ runtime = {}) {
|
|
|
1266
1405
|
const landingFailed = runTimingIndex.landingFailedOf(view.session.id);
|
|
1267
1406
|
if (landingFailed !== undefined)
|
|
1268
1407
|
view.session.landing_failed = landingFailed;
|
|
1408
|
+
// DES-CATALOG-002 §4.4: the shape it was launched as and the chat proposal whose Go launched it — ABSENT otherwise.
|
|
1409
|
+
const launchedShape = runTimingIndex.shapeOf(view.session.id);
|
|
1410
|
+
if (launchedShape !== undefined)
|
|
1411
|
+
view.session.shape = launchedShape;
|
|
1412
|
+
const fromProposal = runTimingIndex.fromProposalOf(view.session.id);
|
|
1413
|
+
if (fromProposal !== undefined)
|
|
1414
|
+
view.session.from_proposal = fromProposal;
|
|
1269
1415
|
// crew#552: the onboarding run a chained capture was launched from — ABSENT otherwise.
|
|
1270
1416
|
const chainedFrom = runTimingIndex.chainedFromOf(view.session.id);
|
|
1271
1417
|
if (chainedFrom !== undefined)
|
|
@@ -1397,6 +1543,8 @@ runtime = {}) {
|
|
|
1397
1543
|
runChatId: true,
|
|
1398
1544
|
// crew#825: `LaunchRunBody.excludeLinkedIssues` + `POST /linked-issues/preview` are served.
|
|
1399
1545
|
linkedIssuesExclude: true,
|
|
1546
|
+
// DES-PM-001 PM-1: PM sources, tracker links, tracker sets in linked issues, tracker actions.
|
|
1547
|
+
trackerLinks: true,
|
|
1400
1548
|
// ASK-C1 (DES-ASK-TEAM-CHAT-001 §5.1): an ask starts a path — the whole contract is the
|
|
1401
1549
|
// pinned core-ts floor the adapter reports; an older studio reads ABSENT as "every helper
|
|
1402
1550
|
// answers", a newer one renders the one PA voice.
|
|
@@ -1434,15 +1582,38 @@ runtime = {}) {
|
|
|
1434
1582
|
workingDoc: app.hasRoute({ method: 'GET', url: `${V}/runs/:id/working-doc` }),
|
|
1435
1583
|
// (api-types 0.149.0) Power mode: the routes are served AND the engine runs it.
|
|
1436
1584
|
powerMode: powerSupported(),
|
|
1585
|
+
// (api-types 0.188.0, crew#1139) A plan approval carries the operator's note (`GateDecision.amend` at a
|
|
1586
|
+
// plan_approval gate, with or without `plan`): the engine lands it on the plan's first creator step.
|
|
1587
|
+
planGateNote: typeof adapter.supportsPlanGateNote === 'function' && adapter.supportsPlanGateNote(),
|
|
1437
1588
|
// (api-types 0.156.0, DES-VOICE) Voice mode's routes are served: local speech to text, the model with
|
|
1438
1589
|
// consent, and the per-person dashboard. Whether transcription can run now is `GET /voice/status`.
|
|
1439
1590
|
voice: app.hasRoute({ method: 'POST', url: `${V}/voice/transcribe` }),
|
|
1440
1591
|
// (api-types 0.168.0, wf-catalog) The categorised workflow catalog with the operator's usage.
|
|
1441
1592
|
workflowCatalog: app.hasRoute({ method: 'GET', url: `${V}/workflows/catalog` }),
|
|
1593
|
+
// DES-CATALOG-002 §4.1: `?v=2` on the same route, and `shape` on every launch route.
|
|
1594
|
+
workflowCatalogV2: app.hasRoute({ method: 'GET', url: `${V}/workflows/catalog` }),
|
|
1595
|
+
launchShape: true,
|
|
1596
|
+
// DES-CATALOG-002 §4.6: person-made and revised job proposals, the revising hold, plan answers bound to planRev.
|
|
1597
|
+
chatJobProposals: chatJobProposalsOn,
|
|
1598
|
+
reshapeRun: chatJobProposalsOn,
|
|
1442
1599
|
// (api-types 0.169.0, DES-CHAT-ARTIFACTS-001 §14) Per operation: A1 serves `context` (the chat sees the open
|
|
1443
1600
|
// artifact and the runs the person names; `seedFromArtifact`); A2 (0.170.0) `proposals`. The operations are later
|
|
1444
1601
|
// slices (all on, with `stub`, in the test configuration).
|
|
1445
1602
|
chatArtifacts: { ...chatArtifactFlags },
|
|
1603
|
+
// (api-types 0.172.0, DES-APPS-001 K2a) The app store is served; each later route says when it serves for real.
|
|
1604
|
+
...(runtime.apps !== undefined
|
|
1605
|
+
? {
|
|
1606
|
+
apps: {
|
|
1607
|
+
// (typed against the contract below: a renamed flag fails the build)
|
|
1608
|
+
query: appsExecutor !== undefined,
|
|
1609
|
+
actions: appsWritePath !== undefined,
|
|
1610
|
+
turns: runtime.apps.turns !== null,
|
|
1611
|
+
publish: false,
|
|
1612
|
+
uploads: app.hasRoute({ method: 'POST', url: `${V}/apps/uploads` }),
|
|
1613
|
+
sourceCheck: runtime.apps.sourceStage !== null,
|
|
1614
|
+
},
|
|
1615
|
+
}
|
|
1616
|
+
: {}),
|
|
1446
1617
|
};
|
|
1447
1618
|
// wicked-core#411 / crew#497: the state-home blocker rides the health probe as a WARNING. The
|
|
1448
1619
|
// daemon still SERVES (status stays ok — studio must load and show the blocker) but refuses to
|
|
@@ -1584,7 +1755,8 @@ runtime = {}) {
|
|
|
1584
1755
|
...(limit !== undefined ? { limit } : {}),
|
|
1585
1756
|
...(since !== undefined ? { since } : {}),
|
|
1586
1757
|
});
|
|
1587
|
-
|
|
1758
|
+
// (crew#1317) A non-human reader gets the MCP and source lines without their connection data.
|
|
1759
|
+
return { entries: auditFor(actorOf(req), entries) };
|
|
1588
1760
|
}
|
|
1589
1761
|
catch (err) {
|
|
1590
1762
|
return reply.code(500).send({ error: message(err) });
|
|
@@ -1761,6 +1933,35 @@ runtime = {}) {
|
|
|
1761
1933
|
}
|
|
1762
1934
|
return { session, target };
|
|
1763
1935
|
};
|
|
1936
|
+
/**
|
|
1937
|
+
* (crew#1324, DES-KNOWLEDGE-DATA-001 §5.2) An app repo's files are a person's to read: its `apps.lock.json`
|
|
1938
|
+
* pins each source's connection descriptor, `queries/` holds SQL that names relations, `apps.json` holds what
|
|
1939
|
+
* its actions write. A non-human actor ({@link viewOf} `agent`) is refused both reads when the run works in an
|
|
1940
|
+
* app's repository, or the path or the run's worktree is inside one (so every file of an app's run, and the run
|
|
1941
|
+
* branch's diff); `GET /apps/:app` answers it the agent-safe view. With no app store (an unreadable one leaves
|
|
1942
|
+
* Apps off) crew cannot tell an app's files from any other, so a non-human reads no run file or diff. Humans
|
|
1943
|
+
* (studio's run pages) are unchanged. Returns `true` after replying.
|
|
1944
|
+
*/
|
|
1945
|
+
const appFilesRefused = async (req, reply, session, target) => {
|
|
1946
|
+
if (viewOf(actorOf(req)) === 'full')
|
|
1947
|
+
return false;
|
|
1948
|
+
const repos = runtime.apps?.appRepos();
|
|
1949
|
+
const appRun = () => {
|
|
1950
|
+
if (repos === undefined)
|
|
1951
|
+
return true;
|
|
1952
|
+
if (session.repo_ref !== null && repos.some((r) => r.repoId !== '' && r.repoId === session.repo_ref))
|
|
1953
|
+
return true;
|
|
1954
|
+
const paths = [target, session.workdir].filter((p) => typeof p === 'string' && p.length > 0);
|
|
1955
|
+
return paths.some((p) => repos.some((r) => mayBeInsideRoot(r.root, p)));
|
|
1956
|
+
};
|
|
1957
|
+
if (!appRun())
|
|
1958
|
+
return false;
|
|
1959
|
+
await reply.code(403).send({
|
|
1960
|
+
code: 'app_files_human_only',
|
|
1961
|
+
error: "an app's files are read by people; GET /apps/:app answers the agent-safe view of the app",
|
|
1962
|
+
});
|
|
1963
|
+
return true;
|
|
1964
|
+
};
|
|
1764
1965
|
// Fastify parses a repeated param as string[] (Copilot, #250/#266). These are FILE-READ
|
|
1765
1966
|
// routes: `?path=a&path=b` is rejected outright (400) rather than silently reading as
|
|
1766
1967
|
// either (Copilot, #305).
|
|
@@ -1781,6 +1982,8 @@ runtime = {}) {
|
|
|
1781
1982
|
const resolved = await resolveRunPath(reply, id, rawPath);
|
|
1782
1983
|
if (resolved === null)
|
|
1783
1984
|
return reply;
|
|
1985
|
+
if (await appFilesRefused(req, reply, resolved.session, resolved.target))
|
|
1986
|
+
return reply;
|
|
1784
1987
|
const target = resolved.target;
|
|
1785
1988
|
try {
|
|
1786
1989
|
const read = await readFileCapped(target);
|
|
@@ -1818,6 +2021,8 @@ runtime = {}) {
|
|
|
1818
2021
|
const resolved = await resolveRunPath(reply, id, rawPath);
|
|
1819
2022
|
if (resolved === null)
|
|
1820
2023
|
return reply;
|
|
2024
|
+
if (await appFilesRefused(req, reply, resolved.session, resolved.target))
|
|
2025
|
+
return reply;
|
|
1821
2026
|
const workdir = resolved.session.workdir;
|
|
1822
2027
|
/** The route's one error mapping, shared by the worktree and the branch reads. */
|
|
1823
2028
|
const diffError = (err) => {
|
|
@@ -2023,15 +2228,38 @@ runtime = {}) {
|
|
|
2023
2228
|
* (core has no unregister). A registered repo returns 201 with `onboardRunId: null` and
|
|
2024
2229
|
* `onboardError` on launch failure, so callers can attach it to their project and retry onboarding.
|
|
2025
2230
|
*/
|
|
2026
|
-
app.post(`${V}/repos`, async (req, reply) => {
|
|
2231
|
+
app.post(`${V}/repos`, { config: { manifest: { requestType: 'RegisterRepoBody', statusCodes: [201, 400, 409, 422, 503] } } }, async (req, reply) => {
|
|
2027
2232
|
const parsed = RegisterRepoSchema.safeParse(req.body);
|
|
2028
2233
|
if (!parsed.success) {
|
|
2029
2234
|
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
2030
2235
|
}
|
|
2236
|
+
if (parsed.data.create === true) {
|
|
2237
|
+
// DES-APPS-001 (K2a): `<apps root>/<name>`, `git init` with one empty commit, registered; an empty
|
|
2238
|
+
// tree has nothing to onboard. A taken (or reserved) name is refused with a suggestion.
|
|
2239
|
+
const store = runtime.apps;
|
|
2240
|
+
if (store === undefined)
|
|
2241
|
+
return reply.code(503).send({ code: 'apps_unavailable', error: 'this daemon has no apps root to make a repo in' });
|
|
2242
|
+
const name = parsed.data.name;
|
|
2243
|
+
try {
|
|
2244
|
+
const { repo } = await store.createRepo(name);
|
|
2245
|
+
audit.record('repo.created', actorOf(req), { detail: { repoId: repo.id, name } });
|
|
2246
|
+
return reply.code(201).send({ repo, onboardRunId: null });
|
|
2247
|
+
}
|
|
2248
|
+
catch (err) {
|
|
2249
|
+
if (err instanceof AppStoreError)
|
|
2250
|
+
return reply.code(err.status).send({ code: err.code, error: err.message, ...err.extra });
|
|
2251
|
+
// A registration the engine refused: the repo was removed again, nothing is left.
|
|
2252
|
+
return reply.code(400).send({ error: message(err) });
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2031
2255
|
const refused = await onboardRefusal();
|
|
2032
2256
|
if (refused !== null)
|
|
2033
2257
|
return reply.code(refused.status).send(refused.body);
|
|
2034
2258
|
const { name, rootPath, gitUrl, projectId, channel, actor, autoCapture } = parsed.data;
|
|
2259
|
+
// (DES-PM-001 Q-PM2) Re-pointing an existing repo id at another checkout keeps its projects and tracker links.
|
|
2260
|
+
const repointed = await reRegisterRefusal(actorOf(req), name, rootPath, Boolean(gitUrl), () => adapter.listRepos());
|
|
2261
|
+
if (repointed !== null)
|
|
2262
|
+
return reply.code(repointed.status).send(repointed.body);
|
|
2035
2263
|
let repo;
|
|
2036
2264
|
let runId;
|
|
2037
2265
|
try {
|
|
@@ -2091,13 +2319,13 @@ runtime = {}) {
|
|
|
2091
2319
|
// crew#825: what a workflow launch WOULD append — the same reading `POST /runs` does, before Send,
|
|
2092
2320
|
// so the composer shows "N linked issues will be appended (≈K chars)" with a way to leave one out
|
|
2093
2321
|
// (`excludeLinkedIssues`). Read-only: nothing launches, nothing is stored.
|
|
2094
|
-
const LinkedIssuesPreviewSchema = z
|
|
2095
|
-
.object({
|
|
2322
|
+
const LinkedIssuesPreviewSchema = z.strictObject({
|
|
2096
2323
|
problem: z.string().min(1),
|
|
2097
2324
|
repoRef: z.string().min(1).optional(),
|
|
2098
2325
|
excludeLinkedIssues: ExcludeLinkedIssuesSchema,
|
|
2099
|
-
|
|
2100
|
-
.
|
|
2326
|
+
// (DES-PM-001 §3.2) The project the launch would be filed in: its tracker set reads the refs.
|
|
2327
|
+
projectId: z.string().min(1).max(128).optional(),
|
|
2328
|
+
});
|
|
2101
2329
|
app.post(`${V}/linked-issues/preview`, { config: { manifest: { requestType: 'LinkedIssuesPreviewBody', responseType: 'LinkedIssuesPreviewResponse', statusCodes: [200, 400] } } }, async (req, reply) => {
|
|
2102
2330
|
const parsed = LinkedIssuesPreviewSchema.safeParse(req.body);
|
|
2103
2331
|
if (!parsed.success)
|
|
@@ -2107,7 +2335,7 @@ runtime = {}) {
|
|
|
2107
2335
|
// intent alone, so the preview answers "nothing appended" and says why — never a 500.
|
|
2108
2336
|
try {
|
|
2109
2337
|
const root = b.repoRef !== undefined ? await repoRootOf(b.repoRef) : undefined;
|
|
2110
|
-
const linked = await readLinkedIssues(b.problem, root, b.repoRef, b.excludeLinkedIssues ?? []);
|
|
2338
|
+
const linked = await readLinkedIssues(b.problem, root, b.repoRef, b.excludeLinkedIssues ?? [], b.projectId ?? null);
|
|
2111
2339
|
return { issues: linked.issues, appendedChars: linked.block === null ? 0 : linked.block.length + 2 };
|
|
2112
2340
|
}
|
|
2113
2341
|
catch (err) {
|
|
@@ -2115,29 +2343,55 @@ runtime = {}) {
|
|
|
2115
2343
|
return { issues: [], appendedChars: 0, error: `linked issues could not be read: ${message(err)} — a launch now runs on the intent alone` };
|
|
2116
2344
|
}
|
|
2117
2345
|
});
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
},
|
|
2134
|
-
},
|
|
2135
|
-
}, async (req, reply) => {
|
|
2346
|
+
/**
|
|
2347
|
+
* (DES-CHAT-FIRST-001 C3, DES-CATALOG-002 §4.6) THE launch: the whole launch policy and provenance path of
|
|
2348
|
+
* `POST /runs`, shared by that route and every other launcher of a run (a chat job proposal's Go, a reshape). The
|
|
2349
|
+
* route parses nothing itself: the body is checked here, by the same schema, so no launcher has a side path.
|
|
2350
|
+
* `internal` carries what only crew may set (never a client field): the proposal a run was launched from.
|
|
2351
|
+
*/
|
|
2352
|
+
/** What a shape is judged against: the engine's served defs, presets and phase catalog (DES-CATALOG-002 §4.4). */
|
|
2353
|
+
const shapeReads = {
|
|
2354
|
+
defs: () => adapter.listWorkflows(),
|
|
2355
|
+
presets: (projectId) => adapter.listPresets(projectId),
|
|
2356
|
+
entries: () => adapter.catalog(),
|
|
2357
|
+
};
|
|
2358
|
+
const launchRun = async (raw, ctx) => {
|
|
2359
|
+
const reply = new LaunchReply();
|
|
2360
|
+
const req = { body: raw, log: ctx.log, actor: ctx.actor };
|
|
2136
2361
|
const parsed = LaunchSchema.safeParse(req.body);
|
|
2137
2362
|
if (!parsed.success) {
|
|
2138
2363
|
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
2139
2364
|
}
|
|
2140
|
-
const b = parsed.data;
|
|
2365
|
+
const b = { ...parsed.data };
|
|
2366
|
+
// DES-CATALOG-002 §4.4: the words as the person gave them, before crew's framing line (the envelope's `words`, which
|
|
2367
|
+
// a reshape relaunches from), with any block an earlier launch appended taken out.
|
|
2368
|
+
const envelopeWords = stripLinkedIssues(stripRulesBrief(b.problem));
|
|
2369
|
+
// The shape as judged, re-judged just before the engine is called (the awaits between can see a preset saved).
|
|
2370
|
+
let shapeChecked = null;
|
|
2371
|
+
// DES-CATALOG-002 §4.4: a shape is judged against the CURRENT catalog and this launch's own target before anything is
|
|
2372
|
+
// read or committed; its framing line (and depth) goes first in the brief, crew's, never the client's.
|
|
2373
|
+
if (b.shape !== undefined) {
|
|
2374
|
+
const target = ctx.target === 'compose'
|
|
2375
|
+
? { kind: 'compose' }
|
|
2376
|
+
: b.workflow === DEMO_PRESET
|
|
2377
|
+
? { kind: 'demo' }
|
|
2378
|
+
: { kind: 'run', workflow: b.workflow };
|
|
2379
|
+
if (ctx.target !== 'compose' && b.plan !== undefined) {
|
|
2380
|
+
return reply.code(400).send({ code: 'shape_mismatch', error: 'a shape names a card, and a launch with its own plan runs no card' });
|
|
2381
|
+
}
|
|
2382
|
+
let served;
|
|
2383
|
+
try {
|
|
2384
|
+
served = await servedFor(shapeReads, b.projectId);
|
|
2385
|
+
}
|
|
2386
|
+
catch (err) {
|
|
2387
|
+
return reply.code(409).send({ code: 'catalog_unavailable', error: message(err) });
|
|
2388
|
+
}
|
|
2389
|
+
const verdict = checkLaunchShape(launchShapeOf(b.shape), target, served);
|
|
2390
|
+
if (!verdict.ok)
|
|
2391
|
+
return reply.code(verdict.code).send(verdict.body);
|
|
2392
|
+
shapeChecked = { shape: launchShapeOf(b.shape), target, resolution: verdict.resolved.resolved.resolution };
|
|
2393
|
+
b.problem = withBriefLines(b.problem, verdict.lines);
|
|
2394
|
+
}
|
|
2141
2395
|
// The demo preset launches only from POST /projects/:id/demo (api/recording.ts), which mints the run's
|
|
2142
2396
|
// demo root and brief first: launched here directly it would have neither.
|
|
2143
2397
|
if (b.workflow === DEMO_PRESET && (b.sessionId === undefined || !demoLaunchRoots.has(b.sessionId))) {
|
|
@@ -2182,7 +2436,9 @@ runtime = {}) {
|
|
|
2182
2436
|
if (b.clisJson === undefined)
|
|
2183
2437
|
await rosterWithStanding.ready?.();
|
|
2184
2438
|
const input = {
|
|
2185
|
-
|
|
2439
|
+
// (xreview r1 on S1) An inherited rules block never rides a relaunch, workflow or free text: the workflow path
|
|
2440
|
+
// below lists the rules afresh; a free-text launch carries none (its planner would turn rule lines into units).
|
|
2441
|
+
problem: stripRulesBrief(b.problem),
|
|
2186
2442
|
sessionId: b.sessionId ?? randomUUID(),
|
|
2187
2443
|
// The default roster carries crew's STANDING (wave 6, the crew half of F-7R2-006): the adapter
|
|
2188
2444
|
// translates `council_eligible: false` into the engine's per-seat bench verdict at launch
|
|
@@ -2417,18 +2673,53 @@ runtime = {}) {
|
|
|
2417
2673
|
// worker cannot read GitHub. The daemon reads each linked issue now and appends its text to the
|
|
2418
2674
|
// problem, inside a marked block the deliver text takes back out. Workflow launches only: the
|
|
2419
2675
|
// free-text planner turns sentences into units, so issue text there would become work units.
|
|
2676
|
+
// E7 (operator ruling 2026-11-05) + DES-RULE-CHECK-001 S1: the project's in-force steering rules ride in the brief,
|
|
2677
|
+
// in a marked block the deliver text takes back out (decisions/rules-brief.ts), so the review and QE seats can judge
|
|
2678
|
+
// the work against them. Every rule is matched against the job and listed as applies / may apply / not applicable
|
|
2679
|
+
// with the fact; none is cut. The steps are not known at launch (a run may be planned into catalog steps whose ids
|
|
2680
|
+
// are the planner's), so step scopes decide nothing here; the def's kinds only order the list. Governed launches
|
|
2681
|
+
// only (a named workflow or an explicit plan); best-effort: an unreadable store launches without it.
|
|
2682
|
+
const briefRules = async (workflow) => {
|
|
2683
|
+
try {
|
|
2684
|
+
const read = await considerations.inForceFor(b.projectId ?? null);
|
|
2685
|
+
const def = workflow === null ? null : adapter.getWorkflow(workflow);
|
|
2686
|
+
const kinds = def === null ? null : def.phases.map((p) => String(p.kind ?? 'build'));
|
|
2687
|
+
const rules = read.source === 'unavailable' ? [] : read.rules;
|
|
2688
|
+
// (coord, E7 rerun) The job's repository: a rule that names it (its statement or its source doc) applies.
|
|
2689
|
+
const job = { workflow, steps: null, kinds, project: b.projectId ?? null, repo: b.repoRef ?? null };
|
|
2690
|
+
const matches = await matchRulesForJob(rules, job, runtime.matchRules ?? CoreAdapter.ruleMatcher(), (m) => req.log.warn(m));
|
|
2691
|
+
const briefed = withRulesBrief(input.problem, rules, matches);
|
|
2692
|
+
input.problem = briefed.problem;
|
|
2693
|
+
if (matches.length > 0) {
|
|
2694
|
+
req.log.info(`[rules] ${input.sessionId}: ${briefed.listed} steering rule(s) to check, ${briefed.notApplicable} not applicable, in the brief`);
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
catch (err) {
|
|
2698
|
+
req.log.warn(`[rules] the rules in force could not be read; launching without them: ${message(err)}`);
|
|
2699
|
+
}
|
|
2700
|
+
};
|
|
2420
2701
|
let linkedIssues;
|
|
2702
|
+
let linkedAddresses;
|
|
2421
2703
|
if (b.workflow !== undefined) {
|
|
2704
|
+
// A retry relaunches with the earlier run's whole problem (studio sends its `problem`), daemon
|
|
2705
|
+
// blocks included. They are dropped before anything is read, whatever the read answers, and
|
|
2706
|
+
// read again below: the intent is the text before the first linked-issues marker, never a
|
|
2707
|
+
// block an earlier launch appended (stripLinkedIssues).
|
|
2708
|
+
// (xreview r1) An inherited rules block goes first, so no rule id is read as a linked issue on a relaunch.
|
|
2709
|
+
const intent = stripLinkedIssues(stripRulesBrief(b.problem));
|
|
2710
|
+
input.problem = intent;
|
|
2422
2711
|
// Best-effort by contract: reading issues never fails the launch it decorates. A resolver
|
|
2423
2712
|
// fault (the repo list unreadable, say) launches the run on its intent alone and is logged.
|
|
2424
2713
|
try {
|
|
2425
2714
|
const root = b.repoRef !== undefined ? await repoRootOf(b.repoRef) : undefined;
|
|
2426
|
-
const linked = await readLinkedIssues(
|
|
2715
|
+
const linked = await readLinkedIssues(intent, root, b.repoRef, b.excludeLinkedIssues ?? [], b.projectId ?? null);
|
|
2427
2716
|
if (linked.block !== null)
|
|
2428
|
-
input.problem = `${
|
|
2717
|
+
input.problem = `${intent.trimEnd()}\n\n${linked.block}`;
|
|
2429
2718
|
// crew#825: an all-excluded intent appends nothing but still answers what it left out.
|
|
2430
2719
|
if (linked.issues.length > 0)
|
|
2431
2720
|
linkedIssues = linked.issues;
|
|
2721
|
+
if (linked.addresses !== undefined && linked.addresses.length > 0)
|
|
2722
|
+
linkedAddresses = linked.addresses;
|
|
2432
2723
|
}
|
|
2433
2724
|
catch (err) {
|
|
2434
2725
|
req.log.warn(`linked-issue resolution failed; launching on the intent alone: ${message(err)}`);
|
|
@@ -2447,6 +2738,13 @@ runtime = {}) {
|
|
|
2447
2738
|
req.log.warn(`[learnings] the memory store could not be read; launching without approved learnings: ${message(err)}`);
|
|
2448
2739
|
}
|
|
2449
2740
|
}
|
|
2741
|
+
if (!NO_LEARNINGS_WORKFLOWS.has(b.workflow))
|
|
2742
|
+
await briefRules(b.workflow);
|
|
2743
|
+
}
|
|
2744
|
+
else if (b.plan !== undefined) {
|
|
2745
|
+
// (xreview r2 on S1) A launch with an explicit plan is governed like a named workflow (its steps are given, so
|
|
2746
|
+
// no prose planner reads the brief): its rules ride along too, an inherited block replaced.
|
|
2747
|
+
await briefRules(null);
|
|
2450
2748
|
}
|
|
2451
2749
|
// DES-RUNS-REVIEW-001 §3: a hand launch of the run review (`/workflow-review-recent-work`) is prepared like a
|
|
2452
2750
|
// scheduled one: its snapshot written, repo-less, one seat, its review directory as the only write root.
|
|
@@ -2478,6 +2776,20 @@ runtime = {}) {
|
|
|
2478
2776
|
if (live !== null)
|
|
2479
2777
|
return reply.code(409).send({ code: 'chat_busy', error: `This chat already has a job running (${live}). Wait, or stop that run.` });
|
|
2480
2778
|
}
|
|
2779
|
+
// DES-CATALOG-002 §4.4 (codex r1): the effective resolution a shape was judged by is read again right before the
|
|
2780
|
+
// engine resolves the preset, so a preset saved during this launch's awaits refuses it rather than running a shape
|
|
2781
|
+
// the person did not see. (The engine has no snapshot binding; every chat-launched job is also held at its plan.)
|
|
2782
|
+
if (shapeChecked !== null) {
|
|
2783
|
+
try {
|
|
2784
|
+
const again = checkLaunchShape(shapeChecked.shape, shapeChecked.target, await servedFor(shapeReads, b.projectId));
|
|
2785
|
+
if (!again.ok || again.resolved.resolved.resolution !== shapeChecked.resolution) {
|
|
2786
|
+
return reply.code(409).send({ code: 'catalog_changed', error: 'the catalog changed while this was starting; check the job again' });
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
catch (err) {
|
|
2790
|
+
return reply.code(409).send({ code: 'catalog_unavailable', error: message(err) });
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2481
2793
|
try {
|
|
2482
2794
|
const runId = await adapter.launchRun(input);
|
|
2483
2795
|
// crew#641/#642 (item 5): when a run is promoted from a chat, record how many seats
|
|
@@ -2546,6 +2858,30 @@ runtime = {}) {
|
|
|
2546
2858
|
...(b.actor !== undefined ? { actor: b.actor } : {}),
|
|
2547
2859
|
// crew#627: which linked issues the daemon read into the problem, and which it could not.
|
|
2548
2860
|
...(linkedIssues !== undefined ? { linkedIssues } : {}),
|
|
2861
|
+
// DES-CATALOG-002 §4.4: the shape it was launched as, what it was launched with, and the proposal behind it.
|
|
2862
|
+
...(b.shape !== undefined ? { shape: launchShapeOf(b.shape) } : {}),
|
|
2863
|
+
...(ctx.fromProposal !== undefined ? { fromProposal: ctx.fromProposal } : {}),
|
|
2864
|
+
envelope: {
|
|
2865
|
+
words: envelopeWords,
|
|
2866
|
+
...(b.repoRef !== undefined ? { repoRef: b.repoRef } : {}),
|
|
2867
|
+
...(b.projectId !== undefined ? { projectId: b.projectId } : {}),
|
|
2868
|
+
...(b.clisJson !== undefined ? { clisJson: b.clisJson } : {}),
|
|
2869
|
+
...(b.primary !== undefined ? { primary: b.primary } : {}),
|
|
2870
|
+
...(input.humanConfirm !== undefined ? { humanConfirm: input.humanConfirm } : {}),
|
|
2871
|
+
deliver,
|
|
2872
|
+
...(b.deliverGate !== undefined ? { deliverGate: b.deliverGate } : {}),
|
|
2873
|
+
...(b.chatId !== undefined ? { chatId: b.chatId } : {}),
|
|
2874
|
+
...(b.skipQeAcceptance !== undefined ? { skipQeAcceptance: b.skipQeAcceptance } : {}),
|
|
2875
|
+
...(b.forceQeAcceptance === true ? { forceQeAcceptance: true } : {}),
|
|
2876
|
+
...(b.reducedAssurance === true ? { reducedAssurance: true } : {}),
|
|
2877
|
+
...(b.power !== undefined ? { power: b.power } : {}),
|
|
2878
|
+
...(b.revisesPr !== undefined ? { revisesPr: b.revisesPr } : {}),
|
|
2879
|
+
...(b.campaignId !== undefined ? { campaignId: b.campaignId } : {}),
|
|
2880
|
+
...(b.groupLabel !== undefined ? { groupLabel: b.groupLabel } : {}),
|
|
2881
|
+
...(revisesPr !== undefined ? { baseRef: revisesPr.headRef } : {}),
|
|
2882
|
+
...(b.shape !== undefined ? { shape: launchShapeOf(b.shape) } : {}),
|
|
2883
|
+
...(ctx.fromProposal !== undefined ? { fromProposal: ctx.fromProposal } : {}),
|
|
2884
|
+
},
|
|
2549
2885
|
});
|
|
2550
2886
|
// Stamp the index live so the field is served without waiting for a daemon restart.
|
|
2551
2887
|
if (chatSeatCount !== undefined && chatGrounded !== undefined) {
|
|
@@ -2555,6 +2891,25 @@ runtime = {}) {
|
|
|
2555
2891
|
retryIndex.set(runId, b.retryOf);
|
|
2556
2892
|
if (revisesPr !== undefined)
|
|
2557
2893
|
retryIndex.setRevisesPr(runId, revisesPr);
|
|
2894
|
+
// (DES-PM-001 §3.2, §4) The issues this run addresses, as its tracker set resolved them: delivery links them
|
|
2895
|
+
// back, the deliver gate's actions are offered for them, and the projection draws the trail.
|
|
2896
|
+
if (linkedAddresses !== undefined && runtime.trackerAddresses !== undefined) {
|
|
2897
|
+
// Retried: a run that addresses issues but has no record of them would deliver and project as if it did not.
|
|
2898
|
+
for (let attempt = 1;; attempt++) {
|
|
2899
|
+
try {
|
|
2900
|
+
await runtime.trackerAddresses.record(runId, linkedAddresses, { projectId: b.projectId ?? null, repoId: b.repoRef ?? null });
|
|
2901
|
+
runtime.trackerProjector?.changed();
|
|
2902
|
+
break;
|
|
2903
|
+
}
|
|
2904
|
+
catch (err) {
|
|
2905
|
+
if (attempt >= 3) {
|
|
2906
|
+
req.log.error(`[trackers] the issues run ${runId} addresses could not be recorded after ${attempt} attempts: ${message(err)}`);
|
|
2907
|
+
break;
|
|
2908
|
+
}
|
|
2909
|
+
await new Promise((r) => setTimeout(r, 200 * attempt));
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2558
2913
|
if (b.campaignId !== undefined)
|
|
2559
2914
|
groupIndex.set(runId, { campaignId: b.campaignId });
|
|
2560
2915
|
else if (b.groupLabel !== undefined)
|
|
@@ -2647,6 +3002,136 @@ runtime = {}) {
|
|
|
2647
3002
|
const busy = /busy|in flight|already/i.test(msg);
|
|
2648
3003
|
return reply.code(busy ? 409 : 400).send({ error: msg });
|
|
2649
3004
|
}
|
|
3005
|
+
};
|
|
3006
|
+
// Launch a run (replaces POST /sessions). `clisJson` defaults to the roster;
|
|
3007
|
+
// `sessionId` is minted if the client omits it.
|
|
3008
|
+
app.post(`${V}/runs`, {
|
|
3009
|
+
config: {
|
|
3010
|
+
manifest: {
|
|
3011
|
+
requestType: 'LaunchRunBody',
|
|
3012
|
+
responseType: 'LaunchRunResponse',
|
|
3013
|
+
// 404/409: unknown project / unknown campaignId (wicked-studio#27) /
|
|
3014
|
+
// archived-or-synthesized project + busy engine + the state-home blocker
|
|
3015
|
+
// (`state_home_unregistered`) + a roster with no eligible seat (`no_eligible_seat`,
|
|
3016
|
+
// wicked-core#461 — see the catch below); 400: zod reject or a retryOf naming no
|
|
3017
|
+
// existing run; 422: the base-skill intake refusal (`base_skill_refused`, crew#554);
|
|
3018
|
+
// 501: campaignId attach on an engine addon without the campaign bindings ("upgrade
|
|
3019
|
+
// the engine").
|
|
3020
|
+
statusCodes: [201, 400, 404, 409, 422, 501],
|
|
3021
|
+
},
|
|
3022
|
+
},
|
|
3023
|
+
}, async (req, reply) => {
|
|
3024
|
+
const out = await launchRun(req.body, { actor: actorOf(req), log: req.log });
|
|
3025
|
+
return reply.code(out.statusCode).send(out.payload);
|
|
3026
|
+
});
|
|
3027
|
+
/**
|
|
3028
|
+
* (DES-CATALOG-002 §4.6) The `job` launcher: a chat job proposal's Go, one launcher per launch kind, each with the
|
|
3029
|
+
* identity derived from the proposal (`sessionId` = its run id, so a retry finds and adopts it), the chat filing, the
|
|
3030
|
+
* shape, and the plan held (a repository job launched from a chat always stops at its first plan, whatever the
|
|
3031
|
+
* person's posture, so power mode is off for it).
|
|
3032
|
+
*/
|
|
3033
|
+
const jobRefusalText = (payload) => {
|
|
3034
|
+
const b = payload;
|
|
3035
|
+
return `${typeof b?.error === 'string' ? b.error : 'the launch was refused'}${typeof b?.code === 'string' ? ` (${b.code})` : ''}`;
|
|
3036
|
+
};
|
|
3037
|
+
proposalLaunchers.register('job', {
|
|
3038
|
+
find: async (identity) => (await adapter.sessions()).includes(identity.runId),
|
|
3039
|
+
live: async (runId) => {
|
|
3040
|
+
const v = (await adapter.sessionsDetail()).find((x) => x.session.id === runId);
|
|
3041
|
+
return v !== undefined && !['completed', 'cancelled', 'failed'].includes(String(v.session.status));
|
|
3042
|
+
},
|
|
3043
|
+
launch: async (d) => {
|
|
3044
|
+
const p = d.resolution;
|
|
3045
|
+
if (p.shape === undefined || p.catalogRev === undefined)
|
|
3046
|
+
throw new Error('this proposal has no shape to launch');
|
|
3047
|
+
const ctx = { actor: d.actor, log: app.log };
|
|
3048
|
+
const projectId = p.filedIn.projectId;
|
|
3049
|
+
const words = (p.brief ?? p.words ?? '').trim();
|
|
3050
|
+
const served = await servedFor(shapeReads, projectId ?? undefined);
|
|
3051
|
+
const resolved = resolveOption(p.shape.card, p.shape.option, served);
|
|
3052
|
+
if (resolved === null)
|
|
3053
|
+
throw new Error(`${p.what.label} is no longer in the catalog`);
|
|
3054
|
+
const selfSeated = resolved.workflow !== null && SELF_SEATED.has(resolved.workflow);
|
|
3055
|
+
// The seats the person saw: the lead, and the roster narrowed to the proposal's keys.
|
|
3056
|
+
const lead = p.seats?.lead ?? undefined;
|
|
3057
|
+
const keys = p.seats?.keys ?? [];
|
|
3058
|
+
// A reshape inherits the held run's roster configuration; its membership is still the proposal's seats (codex r2).
|
|
3059
|
+
let inherited = null;
|
|
3060
|
+
if (p.relaunch?.clisJson !== undefined) {
|
|
3061
|
+
try {
|
|
3062
|
+
const parsedRoster = JSON.parse(p.relaunch.clisJson);
|
|
3063
|
+
if (Array.isArray(parsedRoster))
|
|
3064
|
+
inherited = parsedRoster;
|
|
3065
|
+
}
|
|
3066
|
+
catch {
|
|
3067
|
+
inherited = null;
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
const current = launchRosterNaming(rosterWithStanding(), lead);
|
|
3071
|
+
// Inherited configuration for the seats it names; the current roster's entry for a seat added since (codex r3).
|
|
3072
|
+
const roster = inherited === null ? current : [...inherited, ...current.filter((s) => !inherited.some((i) => i.key === s.key))];
|
|
3073
|
+
const narrowed = keys.length > 0 ? roster.filter((s) => keys.includes(String(s.key))) : roster;
|
|
3074
|
+
const missingSeat = keys.find((k) => !roster.some((s) => String(s.key) === k));
|
|
3075
|
+
if (missingSeat !== undefined)
|
|
3076
|
+
throw new Error(`${missingSeat} is not on this daemon's roster; change who works on it`);
|
|
3077
|
+
const common = jobLaunchCommon(p, { runId: d.identity.runId, chatId: d.chatId }, {
|
|
3078
|
+
...((inherited !== null || narrowed.length !== roster.length) && narrowed.length > 0 ? { clisJson: JSON.stringify(narrowed) } : {}),
|
|
3079
|
+
selfSeated,
|
|
3080
|
+
});
|
|
3081
|
+
if (p.launch === 'run' || p.launch === undefined) {
|
|
3082
|
+
if (resolved.workflow === null)
|
|
3083
|
+
throw new Error(`${p.what.label} has no workflow to run`);
|
|
3084
|
+
const lines = inputLines(p);
|
|
3085
|
+
const out = await launchRun({
|
|
3086
|
+
problem: [words === '' ? p.what.label : words, ...(lines.length > 0 ? [`Inputs:\n${lines.map((l) => `- ${l}`).join('\n')}`] : [])].join('\n\n'),
|
|
3087
|
+
workflow: resolved.workflow,
|
|
3088
|
+
...(p.repoRefs?.[0] !== undefined ? { repoRef: p.repoRefs[0] } : {}),
|
|
3089
|
+
...(projectId !== null && projectId !== DEFAULT_PROJECT_ID ? { projectId } : {}),
|
|
3090
|
+
...common,
|
|
3091
|
+
humanConfirm: 'before:1',
|
|
3092
|
+
power: false,
|
|
3093
|
+
channel: 'studio',
|
|
3094
|
+
// §2.5: a reshape's replacement keeps the held run's delivery and grouping.
|
|
3095
|
+
...(p.relaunch?.deliver !== undefined ? { deliver: p.relaunch.deliver } : {}),
|
|
3096
|
+
...(p.relaunch?.deliverGate !== undefined && p.relaunch.deliver !== 'none' ? { deliverGate: p.relaunch.deliverGate } : {}),
|
|
3097
|
+
...(p.relaunch?.revisesPr !== undefined && p.relaunch.deliver === 'pr' && p.repoRefs?.[0] !== undefined ? { revisesPr: p.relaunch.revisesPr } : {}),
|
|
3098
|
+
}, { ...ctx, fromProposal: d.pid });
|
|
3099
|
+
if (out.statusCode !== 201)
|
|
3100
|
+
throw new Error(jobRefusalText(out.payload));
|
|
3101
|
+
return;
|
|
3102
|
+
}
|
|
3103
|
+
if (p.launch === 'compose') {
|
|
3104
|
+
const req = p.inputs?.['requirements'];
|
|
3105
|
+
if (projectId === null || req === undefined || req.kind !== 'requirements')
|
|
3106
|
+
throw new Error('Backlog needs a project and the requirements you pick');
|
|
3107
|
+
const out = await composeLaunch(adapter, launchRun, projectId, { requirements: req.refs, ...(words !== '' ? { instructions: words } : {}), shape: common['shape'] }, ctx, {
|
|
3108
|
+
fromProposal: d.pid,
|
|
3109
|
+
humanConfirm: 'before:1',
|
|
3110
|
+
common,
|
|
3111
|
+
});
|
|
3112
|
+
if (out.code !== 202)
|
|
3113
|
+
throw new Error(jobRefusalText(out.body));
|
|
3114
|
+
return;
|
|
3115
|
+
}
|
|
3116
|
+
if (p.launch === 'demo') {
|
|
3117
|
+
const v = (id) => {
|
|
3118
|
+
const x = p.inputs?.[id];
|
|
3119
|
+
return x !== undefined && (x.kind === 'text' || x.kind === 'url') ? x.value : undefined;
|
|
3120
|
+
};
|
|
3121
|
+
// What to show is the person's own field, with the corrections carried (§4.6 rule 6).
|
|
3122
|
+
// What to show: the person's first words, their show field and the corrections, together (codex r3); its length
|
|
3123
|
+
// was checked before Start was offered (codex r4), never clipped here.
|
|
3124
|
+
const show = demoShowOf(p);
|
|
3125
|
+
const out = await demoLaunch(launchRun, projectId ?? DEFAULT_PROJECT_ID, { url: v('url') ?? '', audience: v('audience') ?? '', show, shape: common['shape'] }, ctx, {
|
|
3126
|
+
fromProposal: d.pid,
|
|
3127
|
+
common,
|
|
3128
|
+
});
|
|
3129
|
+
if (out.code !== 201)
|
|
3130
|
+
throw new Error(jobRefusalText(out.body));
|
|
3131
|
+
return;
|
|
3132
|
+
}
|
|
3133
|
+
throw new Error(`a ${p.launch} job does not start from a chat`);
|
|
3134
|
+
},
|
|
2650
3135
|
});
|
|
2651
3136
|
// Run list (replaces GET /sessions). Actionable-first; reconciles the gate and elicitation caches
|
|
2652
3137
|
// so that terminal-run entries are pruned even when their terminal CoreEvent was missed.
|
|
@@ -2704,10 +3189,10 @@ runtime = {}) {
|
|
|
2704
3189
|
return { runs: served.map(decorateRun) };
|
|
2705
3190
|
});
|
|
2706
3191
|
// ── Run archival (crew#265) — write-off, not delete ────────────────────────
|
|
2707
|
-
const ArchiveSchema = z.
|
|
3192
|
+
const ArchiveSchema = z.strictObject({
|
|
2708
3193
|
archived: z.boolean(),
|
|
2709
3194
|
note: z.string().max(500).optional(),
|
|
2710
|
-
})
|
|
3195
|
+
});
|
|
2711
3196
|
app.post(`${V}/runs/:id/archive`, async (req, reply) => {
|
|
2712
3197
|
const { id } = req.params;
|
|
2713
3198
|
const parsed = ArchiveSchema.safeParse(req.body ?? {});
|
|
@@ -2736,8 +3221,8 @@ runtime = {}) {
|
|
|
2736
3221
|
// parked at a gate is stopped first (no worker is running), then archived; a run that is
|
|
2737
3222
|
// executing is refused, so a resolve never ends live work. The note keeps the reason.
|
|
2738
3223
|
const ResolveSchema = z.discriminatedUnion('action', [
|
|
2739
|
-
z.
|
|
2740
|
-
z.
|
|
3224
|
+
z.strictObject({ action: z.literal('archive'), reason: z.string().trim().min(1, 'a reason is required to archive').max(480) }),
|
|
3225
|
+
z.strictObject({ action: z.literal('superseded'), by: z.string().min(1), reason: z.string().trim().max(400).optional() }),
|
|
2741
3226
|
]);
|
|
2742
3227
|
app.post(`${V}/runs/:id/resolve`, { config: { manifest: { requestType: 'ResolveRunRequest', responseType: 'ResolveRunResponse', statusCodes: [200, 400, 404, 409, 500] } } }, async (req, reply) => {
|
|
2743
3228
|
const { id } = req.params;
|
|
@@ -2785,10 +3270,10 @@ runtime = {}) {
|
|
|
2785
3270
|
return reply.code(outcome.code).send(outcome.body);
|
|
2786
3271
|
});
|
|
2787
3272
|
// Bulk write-off for campaign backlogs — explicit ids only, never implicit age selection.
|
|
2788
|
-
const BulkArchiveSchema = z.
|
|
3273
|
+
const BulkArchiveSchema = z.strictObject({
|
|
2789
3274
|
ids: z.array(z.string().min(1)).min(1).max(200),
|
|
2790
3275
|
note: z.string().max(500).optional(),
|
|
2791
|
-
})
|
|
3276
|
+
});
|
|
2792
3277
|
app.post(`${V}/runs/archive`, async (req, reply) => {
|
|
2793
3278
|
const parsed = BulkArchiveSchema.safeParse(req.body ?? {});
|
|
2794
3279
|
if (!parsed.success) {
|
|
@@ -2933,8 +3418,11 @@ runtime = {}) {
|
|
|
2933
3418
|
const reports = await seatReports(run);
|
|
2934
3419
|
// crew#1192: the QE check the deliver gate reads, so a required QE that passed says so.
|
|
2935
3420
|
const qeAcceptance = await qeAcceptanceCheckFor(run);
|
|
3421
|
+
// (DES-PM-001 §6 step 3) Each addressed issue links back in its tracker's own form.
|
|
3422
|
+
const trackerRefs = ((await runtime.trackerAddresses?.of(id).catch(() => [])) ?? []).map((a) => ({ system: a.system, ref: a.ref, ...(a.asked !== undefined ? { asked: a.asked } : {}) }));
|
|
2936
3423
|
// The run's preset or workflow NAME, as the engine recorded it (seam X2).
|
|
2937
3424
|
const text = composeDeliverText(factsFromRun(decorateRun(run), runUrlFor(configuredPublicOrigin(), id), {
|
|
3425
|
+
...(trackerRefs.length > 0 ? { trackerRefs } : {}),
|
|
2938
3426
|
workflowId: runIdentityOf(run).name,
|
|
2939
3427
|
revisesPr: retryIndex.revisesPrFor(id) ?? null,
|
|
2940
3428
|
...(followUps !== undefined ? { followUps } : {}),
|
|
@@ -3107,10 +3595,13 @@ runtime = {}) {
|
|
|
3107
3595
|
}
|
|
3108
3596
|
const followUps = await evaluatorFollowUps(run);
|
|
3109
3597
|
const reports = await seatReports(run);
|
|
3598
|
+
// (DES-PM-001 §6 step 3) The post-hoc PR links back in each tracker's own form, as the deliver phase's does.
|
|
3599
|
+
const trackerRefs = ((await runtime.trackerAddresses?.of(id).catch(() => [])) ?? []).map((a) => ({ system: a.system, ref: a.ref, ...(a.asked !== undefined ? { asked: a.asked } : {}) }));
|
|
3110
3600
|
result = await deliverExec(workdir, s.problem ?? undefined, {
|
|
3111
3601
|
runId: id,
|
|
3112
3602
|
apiOrigin: origin,
|
|
3113
3603
|
facts: factsFromRun(run, runUrlFor(configuredPublicOrigin(), id), {
|
|
3604
|
+
...(trackerRefs.length > 0 ? { trackerRefs } : {}),
|
|
3114
3605
|
workflowId: workflowName,
|
|
3115
3606
|
revisesPr: revisesPr === null ? null : { number: revisesPr.number, url: revisesPr.url },
|
|
3116
3607
|
...(followUps !== undefined ? { followUps } : {}),
|
|
@@ -3263,12 +3754,44 @@ runtime = {}) {
|
|
|
3263
3754
|
...(runtime.entityCount !== undefined ? { entityCount: runtime.entityCount } : {}),
|
|
3264
3755
|
...(runtime.freshenCheckout !== undefined ? { freshen: runtime.freshenCheckout } : {}),
|
|
3265
3756
|
});
|
|
3757
|
+
/** (DES-CATALOG-002 §4.6) Chats whose client renders job proposals (`accepts: ['job']`), by its newest declaration. */
|
|
3758
|
+
const chatAccepts = new Map();
|
|
3759
|
+
/** A seed as the person route's body (one spelling, so its request digest is the same on every retry). */
|
|
3760
|
+
const seedBody = (seed, requestId) => ({
|
|
3761
|
+
card: seed.card,
|
|
3762
|
+
...(seed.option !== undefined ? { option: seed.option } : {}),
|
|
3763
|
+
...(seed.depth !== undefined ? { depth: seed.depth } : {}),
|
|
3764
|
+
...(seed.words !== undefined ? { words: seed.words } : {}),
|
|
3765
|
+
source: seed.source,
|
|
3766
|
+
requestId,
|
|
3767
|
+
});
|
|
3768
|
+
/** The seeded chat's person-made proposal (`POST /chats {seed}`), made or found by its request id. */
|
|
3769
|
+
const seedProposal = async (chatId, seed, requestId, actor) => {
|
|
3770
|
+
const instance = chatHistory?.stateOf(chatId)?.instance ?? null;
|
|
3771
|
+
const out = await chatProposals.propose(chatId, seedBody(seed, requestId), actor, instance);
|
|
3772
|
+
if (out.code >= 300) {
|
|
3773
|
+
const b = out.body;
|
|
3774
|
+
app.log.warn(`[proposals] chat ${chatId}: its seed proposal was refused (${String(b.code ?? out.code)})`);
|
|
3775
|
+
return { refused: { code: typeof b.code === 'string' ? b.code : 'seed_refused', error: typeof b.error === 'string' ? b.error : 'the seed proposal was refused' } };
|
|
3776
|
+
}
|
|
3777
|
+
return { view: out.body.view };
|
|
3778
|
+
};
|
|
3779
|
+
/** A seed's card, checked before a chat is opened for it (a hidden card only by its alias). `null` = it resolves. */
|
|
3780
|
+
const seedCardRefusal = (card) => {
|
|
3781
|
+
if (card.startsWith('/'))
|
|
3782
|
+
return parseCommand(card) === null ? `no job has the command ${card.slice(0, 80)}` : null;
|
|
3783
|
+
const c = CATALOG_V2_CARDS.find((x) => x.id === card);
|
|
3784
|
+
if (c === undefined)
|
|
3785
|
+
return `there is no job called “${card.slice(0, 80)}”`;
|
|
3786
|
+
return c.hidden === true ? `${c.title} is reached only by its own command` : null;
|
|
3787
|
+
};
|
|
3266
3788
|
app.post(`${V}/chats`, {
|
|
3267
3789
|
config: {
|
|
3268
3790
|
manifest: {
|
|
3269
3791
|
requestType: 'ChatOpenBody',
|
|
3270
3792
|
responseType: 'ChatOpenResponse',
|
|
3271
|
-
|
|
3793
|
+
// 200: a seeded retry answers the chat its request already opened (api-types 0.192.0).
|
|
3794
|
+
statusCodes: [200, 201, 400, 403, 404, 409, 500, 501],
|
|
3272
3795
|
},
|
|
3273
3796
|
},
|
|
3274
3797
|
}, async (req, reply) => {
|
|
@@ -3277,7 +3800,43 @@ runtime = {}) {
|
|
|
3277
3800
|
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
3278
3801
|
}
|
|
3279
3802
|
const b = parsed.data;
|
|
3280
|
-
|
|
3803
|
+
// DES-CATALOG-002 §4.6: a seeded open is a person's, refused before a chat exists or a seat warms; its chat id
|
|
3804
|
+
// derives from (the person, the request), so a retry after a lost response lands on the same chat and proposal.
|
|
3805
|
+
let seedActor = null;
|
|
3806
|
+
let seedChatId;
|
|
3807
|
+
if (b.seed !== undefined) {
|
|
3808
|
+
if (!chatJobProposalsOn)
|
|
3809
|
+
return reply.code(400).send({ error: 'this daemon does not take job proposals from a chat' });
|
|
3810
|
+
seedActor = actorOf(req);
|
|
3811
|
+
if (!isHumanOperator(seedActor)) {
|
|
3812
|
+
audit.record('chat.proposal.refused', seedActor, { detail: { reason: 'not_a_person', what: 'seed' } });
|
|
3813
|
+
return reply.code(403).send({ code: 'proposal_refused', error: `only a person starts a chat with a job (you are ${seedActor.kind}/${seedActor.trust}). Nothing was opened.` });
|
|
3814
|
+
}
|
|
3815
|
+
const bad = seedCardRefusal(b.seed.card);
|
|
3816
|
+
if (bad !== null)
|
|
3817
|
+
return reply.code(400).send({ code: 'card_unknown', error: bad });
|
|
3818
|
+
seedChatId = proposalRunId(`seed\u0000${seedActor.id}\u0000${b.requestId}`);
|
|
3819
|
+
// A retry: this request's chat exists (open, or kept in history after a close or a restart). Answer it and its
|
|
3820
|
+
// proposal, completing the proposal while the chat is open; never open the id again (codex r1).
|
|
3821
|
+
const open = askPaths.get(seedChatId) !== undefined || chatScopes.get(seedChatId) !== undefined;
|
|
3822
|
+
if (open || chatHistory?.stateOf(seedChatId) !== undefined) {
|
|
3823
|
+
let view = chatProposals.viewOfPid(seedChatId, personPid(seedChatId, seedActor.id, b.requestId));
|
|
3824
|
+
// The same request id with another seed is not a retry (codex r2).
|
|
3825
|
+
if (view !== null && view.proposal.request?.digest !== requestDigest(seedBody(b.seed, b.requestId))) {
|
|
3826
|
+
return reply.code(409).send({ code: 'request_reused', error: 'this requestId already started a chat with another job', chatId: seedChatId });
|
|
3827
|
+
}
|
|
3828
|
+
if (view === null && open) {
|
|
3829
|
+
const seeded = await seedProposal(seedChatId, b.seed, b.requestId, seedActor);
|
|
3830
|
+
if ('refused' in seeded)
|
|
3831
|
+
return reply.code(409).send({ ...seeded.refused, chatId: seedChatId });
|
|
3832
|
+
view = seeded.view;
|
|
3833
|
+
}
|
|
3834
|
+
return reply.code(200).send({ chatId: seedChatId, seats: [], scope: chatScopes.get(seedChatId) ?? null, refused: [], ...(view !== null ? { proposal: view } : {}), adopted: true });
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3837
|
+
const chatId = seedChatId ?? b.chatId ?? randomUUID();
|
|
3838
|
+
if (b.accepts !== undefined)
|
|
3839
|
+
chatAccepts.set(chatId, b.accepts.includes('job'));
|
|
3281
3840
|
const requestedRefs = [...(b.repoRef !== undefined ? [b.repoRef] : []), ...(b.repoRefs ?? [])];
|
|
3282
3841
|
// The scope kind as the open resolves it: the request's, unless an Ask-about-this seed names the repositories.
|
|
3283
3842
|
let scopeKind = b.scopeKind;
|
|
@@ -3629,11 +4188,15 @@ runtime = {}) {
|
|
|
3629
4188
|
// prominently so the caller does not have to reason about the refused[] array.
|
|
3630
4189
|
const warm = seats.filter((s) => s.ok);
|
|
3631
4190
|
const singleSeat = warm.length === 1 ? singleSeatDisclosure(warm[0].cliKey, refused, 'open') : undefined;
|
|
4191
|
+
// DES-CATALOG-002 §4.6: the seeded chat's proposal, made once the chat exists (idempotent by its request id).
|
|
4192
|
+
const seeded = b.seed !== undefined && seedActor !== null ? await seedProposal(chatId, b.seed, b.requestId, seedActor) : null;
|
|
4193
|
+
const seedOut = seeded === null ? {} : 'view' in seeded ? { proposal: seeded.view } : { seedRefused: seeded.refused };
|
|
3632
4194
|
return reply.code(201).send({
|
|
3633
4195
|
chatId,
|
|
3634
4196
|
seats,
|
|
3635
4197
|
scope,
|
|
3636
4198
|
refused,
|
|
4199
|
+
...seedOut,
|
|
3637
4200
|
...(workflow !== undefined ? { workflow: workflow.name } : {}),
|
|
3638
4201
|
...(projectAttachError !== undefined ? { projectAttachError } : {}),
|
|
3639
4202
|
...(singleSeat !== undefined ? { singleSeat } : {}),
|
|
@@ -3667,14 +4230,16 @@ runtime = {}) {
|
|
|
3667
4230
|
chatId,
|
|
3668
4231
|
turn: inFlight,
|
|
3669
4232
|
});
|
|
3670
|
-
const ChatMessageSchema = z.
|
|
4233
|
+
const ChatMessageSchema = z.strictObject({
|
|
3671
4234
|
text: z.string().min(1).max(65536),
|
|
3672
4235
|
targets: z.array(z.string().min(1)).min(1).max(8).optional(),
|
|
3673
4236
|
/** (api-types 0.137.0) Attachment ids from `POST /chats/:id/attachments`. */
|
|
3674
4237
|
attachments: z.array(z.string().min(1).max(64)).optional(),
|
|
3675
4238
|
/** (api-types 0.169.0, DES-CHAT-ARTIFACTS-001 §5.1) What studio shows beside the message. */
|
|
3676
4239
|
context: ChatMessageContextSchema.optional(),
|
|
3677
|
-
|
|
4240
|
+
/** (api-types 0.192.0, DES-CATALOG-002 §4.6) What the client renders (`['job']`): the newest declaration wins. */
|
|
4241
|
+
accepts: z.array(z.literal('job')).max(4).optional(),
|
|
4242
|
+
});
|
|
3678
4243
|
// DES-CHAT-ARTIFACTS-001 §5.1 (A1): what a turn's block reads — the docs roots, the decorated runs (project,
|
|
3679
4244
|
// document and chat ids), unit outputs and the acceptance line. One set of deps, so the block and the run pages
|
|
3680
4245
|
// read the same records.
|
|
@@ -3692,6 +4257,36 @@ runtime = {}) {
|
|
|
3692
4257
|
// records go to the live transcript, or the kept history copy once the chat has ended.
|
|
3693
4258
|
// A dollar figure only from a run whose EVERY dispatched attempt of every agent step reported a price (DES §4.2).
|
|
3694
4259
|
const proposalCosts = async (view) => runCostFromEvents(view, (await adapter.runEvents(view.session.id)));
|
|
4260
|
+
/**
|
|
4261
|
+
* (DES-CATALOG-002 §2.5) A run is reshapeable only while it waits at its first WORK-plan approval (a PA's scope-only
|
|
4262
|
+
* rev 1 may be accepted): the gate's ord and plan revision as read, which the Reject is then bound to.
|
|
4263
|
+
*/
|
|
4264
|
+
const reshapeEligibility = async (runId) => {
|
|
4265
|
+
const after = (why) => ({ refusal: { code: 409, body: { code: 'reshape_after_work', error: `run ${runId} ${why}: change it with the plan's own edit, or start a new job` } } });
|
|
4266
|
+
const run = (await adapter.sessionsDetail()).find((v) => v.session.id === runId);
|
|
4267
|
+
if (run === undefined)
|
|
4268
|
+
return { refusal: { code: 404, body: { error: 'Run not found' } } };
|
|
4269
|
+
if (run.session.status !== 'awaiting_human')
|
|
4270
|
+
return after('is not waiting at its plan');
|
|
4271
|
+
const held = await gateOfRecord(run, undefined);
|
|
4272
|
+
if ('refusal' in held || held.gateKind !== 'plan_approval' || held.gated === undefined)
|
|
4273
|
+
return after('is not waiting at its plan');
|
|
4274
|
+
const rows = await busRows(adapter.busDbPath, runId);
|
|
4275
|
+
if (workPlanAccepted(rows))
|
|
4276
|
+
return after('is past its first plan approval');
|
|
4277
|
+
const planRev = openPlanGateRev(rows);
|
|
4278
|
+
if (planRev === undefined)
|
|
4279
|
+
return after('holds a plan whose version could not be read');
|
|
4280
|
+
return { ord: held.gated.ord, planRev };
|
|
4281
|
+
};
|
|
4282
|
+
/** The held plan answered Reject (`reshaped`) for a reshape, bound to the ord and revision just read. */
|
|
4283
|
+
const reshapeReject = async (runId, actor, pid) => {
|
|
4284
|
+
const elig = await reshapeEligibility(runId);
|
|
4285
|
+
if ('refusal' in elig)
|
|
4286
|
+
return elig.refusal;
|
|
4287
|
+
const out = await decideGate(runId, { approve: false, action: 'reject', amend: 'reshaped', ord: elig.ord, planRev: elig.planRev }, actor, { reshape: pid });
|
|
4288
|
+
return out.code === 200 ? null : { code: out.code, body: (out.body ?? {}) };
|
|
4289
|
+
};
|
|
3695
4290
|
const chatProposals = new ChatProposals({
|
|
3696
4291
|
flags: () => chatArtifactFlags,
|
|
3697
4292
|
catalog: CATALOG_SEEDS,
|
|
@@ -3738,6 +4333,46 @@ runtime = {}) {
|
|
|
3738
4333
|
},
|
|
3739
4334
|
runCostUsd: proposalCosts,
|
|
3740
4335
|
registry: proposalLaunchers,
|
|
4336
|
+
// DES-CATALOG-002 §4.6: job proposals, resolved against the catalog a launch in the chat's project reads.
|
|
4337
|
+
jobs: () => chatJobProposalsOn,
|
|
4338
|
+
reshapeReject,
|
|
4339
|
+
preflight: async (p) => {
|
|
4340
|
+
// The project it files into still takes runs: an archived one refuses every new attachment (codex r6).
|
|
4341
|
+
if (p.filedIn.projectId !== null && p.filedIn.projectId !== DEFAULT_PROJECT_ID) {
|
|
4342
|
+
const project = await adapter.projectGet(p.filedIn.projectId).catch(() => null);
|
|
4343
|
+
if (project === null)
|
|
4344
|
+
return `the project ${p.filedIn.label} is no longer on this daemon`;
|
|
4345
|
+
if (project.status === 'archived')
|
|
4346
|
+
return `the project ${p.filedIn.label} is archived; restore it first`;
|
|
4347
|
+
}
|
|
4348
|
+
// A repository job's repository is still registered and its folder is still there (the launch's own refusal,
|
|
4349
|
+
// checked before a reshape answers its held plan; codex r5).
|
|
4350
|
+
const repoRef = p.repoRefs?.[0];
|
|
4351
|
+
// A compose reads its requirements' own repositories (checked below), not the chat's (pi r6).
|
|
4352
|
+
if (repoRef !== undefined && p.launch !== 'compose') {
|
|
4353
|
+
const entry = (await adapter.listRepos().catch(() => [])).find((r) => r.id === repoRef);
|
|
4354
|
+
if (entry === undefined)
|
|
4355
|
+
return `${p.repos[0] ?? repoRef} is no longer registered on this daemon`;
|
|
4356
|
+
const missing = repoFolderMissing(entry);
|
|
4357
|
+
if (missing !== null)
|
|
4358
|
+
return String(repoFolderMissingBody(missing).error ?? `${entry.name}'s folder is missing`);
|
|
4359
|
+
}
|
|
4360
|
+
if (p.launch !== 'compose')
|
|
4361
|
+
return null;
|
|
4362
|
+
const req = p.inputs?.['requirements'];
|
|
4363
|
+
if (p.filedIn.projectId === null)
|
|
4364
|
+
return 'a backlog needs a project';
|
|
4365
|
+
if (req === undefined || req.kind !== 'requirements')
|
|
4366
|
+
return 'pick the requirements first';
|
|
4367
|
+
const steer = (p.brief ?? p.words ?? '').trim();
|
|
4368
|
+
if (steer.length > 500)
|
|
4369
|
+
return 'A backlog takes a steer of at most 500 characters: say it shorter';
|
|
4370
|
+
return composePreflight(adapter, p.filedIn.projectId, req.refs, steer === '' ? undefined : steer);
|
|
4371
|
+
},
|
|
4372
|
+
qeOff: async () => addonSupportsQeOverride() && (await qeAcceptanceNow()) === 'off',
|
|
4373
|
+
acceptsJobs: (chatId) => chatAccepts.get(chatId) === true,
|
|
4374
|
+
served: (projectId) => servedFor(shapeReads, projectId ?? undefined),
|
|
4375
|
+
turnLive: (chatId, turnId) => chatTurns.turnsOf(chatId).some((t) => t.turnId === turnId),
|
|
3741
4376
|
broadcast: (frame) => runtime.broadcast?.(frame),
|
|
3742
4377
|
audit: (event, actor, detail) => {
|
|
3743
4378
|
audit.record(event, actor, { detail });
|
|
@@ -3757,6 +4392,8 @@ runtime = {}) {
|
|
|
3757
4392
|
if (!parsed.success) {
|
|
3758
4393
|
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
3759
4394
|
}
|
|
4395
|
+
if (parsed.data.accepts !== undefined)
|
|
4396
|
+
chatAccepts.set(id, parsed.data.accepts.includes('job'));
|
|
3760
4397
|
// DES-ASK-TEAM-CHAT-001 §3, §5.1 (ASK-C1): the first message of a chat LAUNCHES one team path
|
|
3761
4398
|
// — a user-composed plan of one `understand` step with its gate raised to the turn gate, one
|
|
3762
4399
|
// reviewer asked for, the eligible roster as `clis`, the operator's choice as `primary`; every
|
|
@@ -3847,6 +4484,10 @@ runtime = {}) {
|
|
|
3847
4484
|
chatTranscripts?.appendUser(id, turnId, text, voice, attached.map(attachmentWire), contextAllowed);
|
|
3848
4485
|
if (turnBinding !== null)
|
|
3849
4486
|
chatTranscripts?.appendContext(id, turnId, turnBinding);
|
|
4487
|
+
// DES-CATALOG-002 §4.6: the person's message holds the chat's open job proposal while its seat turn may revise
|
|
4488
|
+
// it (Go waits: 409 `proposal_revising`), written under the lock Go takes.
|
|
4489
|
+
if (contextAllowed)
|
|
4490
|
+
void chatProposals.holdForMessage(id, turnId).catch((err) => req.log.warn(`[proposals] chat ${id}: the hold for turn ${turnId} could not be written: ${message(err)}`));
|
|
3850
4491
|
// The recorder's audience is the turn's AS THE TURN INDEX HOLDS IT NOW: the eligible roster
|
|
3851
4492
|
// for a random pick, or the PA the relay narrowed it to during the engine awaits above
|
|
3852
4493
|
// (`path.started` / `path.repicked` may land before this record exists — ASK-C2, codex on
|
|
@@ -3867,13 +4508,16 @@ runtime = {}) {
|
|
|
3867
4508
|
// crew#1155: the installed MCP tools and the one command that reaches them (the broker), read
|
|
3868
4509
|
// per turn so a server installed or disabled since the last turn is reflected.
|
|
3869
4510
|
let mcpTools = null;
|
|
4511
|
+
// DES-KNOWLEDGE-DATA-001 §8.1: the live sources the chat's project may use (structure, switches, commands).
|
|
4512
|
+
let knowledgeBlock = null;
|
|
3870
4513
|
const withPreface = (preface) => {
|
|
3871
|
-
const body = mcpTools !== null
|
|
4514
|
+
const body = [mcpTools, knowledgeBlock, seatText].filter((x) => x !== null).join('\n\n');
|
|
3872
4515
|
return preface !== null ? `${preface}\n\n${body}` : body;
|
|
3873
4516
|
};
|
|
3874
4517
|
try {
|
|
3875
4518
|
const rules = (await considerations.inForceFor(scope?.projectId ?? null)).rules;
|
|
3876
4519
|
mcpTools = await chatMcpToolsFor(runtime.mcp);
|
|
4520
|
+
knowledgeBlock = await chatKnowledgeFor(runtime.dataGate, scope?.projectId ?? null, (scope?.repos ?? []).map((r) => r.id));
|
|
3877
4521
|
// crew#1020: a project/everything chat must see repos attached since open. Admission was
|
|
3878
4522
|
// under this scope KIND and the kind stays the same, so do not re-run seat admission.
|
|
3879
4523
|
const scopeRequest = chatScopes.requestOf(id);
|
|
@@ -4149,9 +4793,9 @@ runtime = {}) {
|
|
|
4149
4793
|
// first on every call (a worker or system actor is refused even on an `accepting` proposal); the service then takes
|
|
4150
4794
|
// the proposal's lock and looks for what already happened before any state check.
|
|
4151
4795
|
const ProposalPatchValue = z.union([z.string().max(200), z.number(), z.boolean()]);
|
|
4152
|
-
const ProposalDecisionSchema = z.
|
|
4796
|
+
const ProposalDecisionSchema = z.strictObject({
|
|
4153
4797
|
decision: z.enum(['go', 'not_now']),
|
|
4154
|
-
edits: z.
|
|
4798
|
+
edits: z.strictObject({
|
|
4155
4799
|
title: z.string().max(400).optional(),
|
|
4156
4800
|
brief: z.string().max(16000).optional(),
|
|
4157
4801
|
sources: z.array(z.string().min(1).max(300)).max(32).optional(),
|
|
@@ -4160,13 +4804,67 @@ runtime = {}) {
|
|
|
4160
4804
|
ask: z.string().max(8000).optional(),
|
|
4161
4805
|
allow: z.array(z.string().min(1).max(128)).max(64).optional(),
|
|
4162
4806
|
name: z.string().max(200).optional(),
|
|
4163
|
-
patch:
|
|
4807
|
+
patch: record(z.string().max(40), ProposalPatchValue).optional(),
|
|
4164
4808
|
url: z.string().max(2048).optional(),
|
|
4165
4809
|
audience: z.string().max(800).optional(),
|
|
4166
4810
|
show: z.string().max(4000).optional(),
|
|
4167
4811
|
helpers: z.array(z.string().min(1).max(64)).max(8).optional(),
|
|
4168
|
-
|
|
4169
|
-
|
|
4812
|
+
// (api-types 0.192.0, DES-CATALOG-002 §4.6) a job's edits, merged by the revision rules before Go.
|
|
4813
|
+
option: z.string().trim().min(1).max(80).nullable().optional(),
|
|
4814
|
+
depth: z.enum(['quick', 'standard', 'deep']).nullable().optional(),
|
|
4815
|
+
repoRef: z.string().trim().min(1).max(200).optional(),
|
|
4816
|
+
seats: z.array(z.string().min(1).max(64)).min(1).max(8).optional(),
|
|
4817
|
+
inputs: RevisionEditsSchema.shape.inputs,
|
|
4818
|
+
}).optional(),
|
|
4819
|
+
});
|
|
4820
|
+
/** (api-types 0.192.0) `POST /chats/:id/proposals`: a person-made proposal, or a revision of the open one. */
|
|
4821
|
+
const PersonProposalSchema = z.union([
|
|
4822
|
+
z.strictObject({
|
|
4823
|
+
card: z.string().trim().min(1).max(120),
|
|
4824
|
+
option: z.string().trim().min(1).max(80).nullable().optional(),
|
|
4825
|
+
depth: z.enum(['quick', 'standard', 'deep']).nullable().optional(),
|
|
4826
|
+
words: z.string().max(8000).optional(),
|
|
4827
|
+
source: z.enum(['pick', 'command', 'question', 'suggestion', 'swap']),
|
|
4828
|
+
requestId: z.string().trim().min(1).max(128),
|
|
4829
|
+
}),
|
|
4830
|
+
z.strictObject({
|
|
4831
|
+
revises: z.string().trim().min(1).max(400),
|
|
4832
|
+
edits: RevisionEditsSchema,
|
|
4833
|
+
source: z.enum(['swap', 'suggestion', 'question']),
|
|
4834
|
+
requestId: z.string().trim().min(1).max(128),
|
|
4835
|
+
words: z.string().max(2000).optional(),
|
|
4836
|
+
}),
|
|
4837
|
+
]);
|
|
4838
|
+
/** The checks every person route makes before a proposal is read: the capability, a person, the chat is theirs. */
|
|
4839
|
+
const personChatGate = (req, id, what) => {
|
|
4840
|
+
const actor = actorOf(req);
|
|
4841
|
+
if (!isHumanOperator(actor)) {
|
|
4842
|
+
audit.record('chat.proposal.refused', actor, { detail: { chatId: id, reason: 'not_a_person', what } });
|
|
4843
|
+
return { refusal: { code: 403, body: { code: 'proposal_refused', error: `only a person ${what} (you are ${actor.kind}/${actor.trust}). Nothing was started.` } } };
|
|
4844
|
+
}
|
|
4845
|
+
const viewer = security.authMode === 'required' ? actor.id : null;
|
|
4846
|
+
if (!CHAT_ID.test(id) || chatHistory === null || !chatHistory.visibleTo(id, viewer)) {
|
|
4847
|
+
return { refusal: { code: 404, body: { error: `no chat ${id} on this daemon` } } };
|
|
4848
|
+
}
|
|
4849
|
+
return { actor, instance: chatHistory.stateOf(id)?.instance ?? null };
|
|
4850
|
+
};
|
|
4851
|
+
app.post(`${V}/chats/:id/proposals`, { config: { manifest: { requestType: 'PersonProposalBody | PersonRevisionBody', responseType: 'PersonProposalResponse', statusCodes: [200, 201, 400, 403, 404, 409] } } }, async (req, reply) => {
|
|
4852
|
+
const { id } = req.params;
|
|
4853
|
+
if (!chatArtifactFlags.proposals || !chatJobProposalsOn)
|
|
4854
|
+
return reply.code(404).send({ error: 'this daemon does not take job proposals from a chat' });
|
|
4855
|
+
const gate = personChatGate(req, id, 'proposes a job');
|
|
4856
|
+
if ('refusal' in gate)
|
|
4857
|
+
return reply.code(gate.refusal.code).send(gate.refusal.body);
|
|
4858
|
+
const parsed = PersonProposalSchema.safeParse(req.body);
|
|
4859
|
+
if (!parsed.success)
|
|
4860
|
+
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
4861
|
+
const clean = (o) => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined));
|
|
4862
|
+
const body = 'revises' in parsed.data
|
|
4863
|
+
? clean({ ...parsed.data, edits: clean(parsed.data.edits) })
|
|
4864
|
+
: clean(parsed.data);
|
|
4865
|
+
const out = await chatProposals.propose(id, body, gate.actor, gate.instance);
|
|
4866
|
+
return reply.code(out.code).send(out.body);
|
|
4867
|
+
});
|
|
4170
4868
|
app.post(`${V}/chats/:id/proposals/:pid`, { config: { manifest: { requestType: 'ChatProposalDecisionBody', responseType: 'ChatProposalDecisionResponse', statusCodes: [200, 400, 403, 404, 409, 502] } } }, async (req, reply) => {
|
|
4171
4869
|
const { id, pid } = req.params;
|
|
4172
4870
|
if (!chatArtifactFlags.proposals)
|
|
@@ -4195,9 +4893,9 @@ runtime = {}) {
|
|
|
4195
4893
|
const out = await chatProposals.decide(id, pid, { decision: parsed.data.decision, ...(edits !== undefined ? { edits } : {}) }, actor, instance);
|
|
4196
4894
|
return reply.code(out.code).send(out.body);
|
|
4197
4895
|
});
|
|
4198
|
-
const ChatSeatsSchema = z.
|
|
4896
|
+
const ChatSeatsSchema = z.strictObject({
|
|
4199
4897
|
clis: z.array(z.string().min(1)).min(1).max(8),
|
|
4200
|
-
})
|
|
4898
|
+
});
|
|
4201
4899
|
app.post(`${V}/chats/:id/seats`,
|
|
4202
4900
|
// Typed like every neighbouring chat route (review HIGH-1): the names bind the 0.39.0 api-types
|
|
4203
4901
|
// mirror to this row — `ChatSeatsBody { clis }` in, `ChatSeatsResponse { chatId, seats, refused }`
|
|
@@ -4507,6 +5205,10 @@ runtime = {}) {
|
|
|
4507
5205
|
const chat = chatHistory.visibleTo(id, viewer)
|
|
4508
5206
|
? chatHistory.entry(id, askPaths.get(id)?.pa ?? null, (cid) => askPaths.get(cid) !== undefined || chatScopes.get(cid) !== undefined)
|
|
4509
5207
|
: null;
|
|
5208
|
+
// DES-CATALOG-002 §4.6: a read that finds a job proposal held by a turn that is gone (failed, expired, or forgotten
|
|
5209
|
+
// by a restart) releases it with its note first, so the proposal reads startable again.
|
|
5210
|
+
if (chat !== null)
|
|
5211
|
+
await chatProposals.reopenStale(id).catch(() => false);
|
|
4510
5212
|
const messages = chat === null ? null : chatHistory.messages(id);
|
|
4511
5213
|
if (chat === null || messages === null)
|
|
4512
5214
|
return reply.code(404).send({ error: `no chat ${id} in this daemon's history` });
|
|
@@ -4914,6 +5616,17 @@ runtime = {}) {
|
|
|
4914
5616
|
*/
|
|
4915
5617
|
async function gateForDecision(run, namedOrd, opts = {}) {
|
|
4916
5618
|
const decided = await gateOfRecord(run, namedOrd);
|
|
5619
|
+
// DES-CATALOG-002 §4.6 (codex r1): a plan held for a run launched from a chat proposal is approved only by an
|
|
5620
|
+
// answer bound to its version (`POST /runs/:id/gate` with `planRev`); every other approving path (a gated resume or
|
|
5621
|
+
// reassign, a plan edit at the gate, a standing order) is refused there. Declining stays open.
|
|
5622
|
+
if (!('refusal' in decided) && opts.declining !== true && opts.versioned !== true && decided.gateKind === 'plan_approval'
|
|
5623
|
+
&& runTimingIndex.fromProposalOf(run.session.id) !== undefined) {
|
|
5624
|
+
return { refusal: { code: 409, body: {
|
|
5625
|
+
code: 'gate_changed',
|
|
5626
|
+
error: 'This plan was started from a chat proposal: approve it through its gate with the plan version you read (planRev).',
|
|
5627
|
+
...(await currentPlanOf(run.session.id, false)),
|
|
5628
|
+
} } };
|
|
5629
|
+
}
|
|
4917
5630
|
// crew#1157: every APPROVING path (the gate route, standing orders, a gated resume or reassign, a
|
|
4918
5631
|
// plan edit at the gate, the next message of a chat) is judged here, so no path approves a held
|
|
4919
5632
|
// plan change on an analysis run. Declining stays open.
|
|
@@ -5047,6 +5760,20 @@ runtime = {}) {
|
|
|
5047
5760
|
// (studio#923) Skipping QE acceptance is the human operator's call alone: a seat's token, a
|
|
5048
5761
|
// standing order or any other non-human actor is refused before anything is read, and the
|
|
5049
5762
|
// attempt is audited. The engine records WHO skipped it from the same actor (recordGateActor).
|
|
5763
|
+
// (DES-RULE-CHECK-001 S2) …and so is skipping a steering rule no judge ruled on.
|
|
5764
|
+
if (parsed.data.action === SKIP_RULES_ACTION && !isHumanOperator(actor)) {
|
|
5765
|
+
audit.record('gate.skip_rules_refused', actor, {
|
|
5766
|
+
runId: id,
|
|
5767
|
+
detail: { reason: 'human_operator_only', ...(parsed.data.ord !== undefined ? { ord: parsed.data.ord } : {}) },
|
|
5768
|
+
});
|
|
5769
|
+
return {
|
|
5770
|
+
code: 403,
|
|
5771
|
+
body: {
|
|
5772
|
+
error: `only a human operator can skip a steering rule (you are ${actor.kind}/${actor.trust})`,
|
|
5773
|
+
code: 'human_operator_only',
|
|
5774
|
+
},
|
|
5775
|
+
};
|
|
5776
|
+
}
|
|
5050
5777
|
if (parsed.data.action === SKIP_QE_ACTION && !isHumanOperator(actor)) {
|
|
5051
5778
|
audit.record('gate.skip_qe_refused', actor, {
|
|
5052
5779
|
runId: id,
|
|
@@ -5071,9 +5798,38 @@ runtime = {}) {
|
|
|
5071
5798
|
// Decision integrity (api-types 0.44.0; crew#1083 rounds 3–5): the gate this decision answers
|
|
5072
5799
|
// is the RECORD's — read first thing inside the lock, so the gated unit and its delivery
|
|
5073
5800
|
// checks below are the ones the record confirms ({@link gateForDecision}).
|
|
5074
|
-
const decided = await gateForDecision(run, parsed.data.ord, { declining: !parsed.data.approve });
|
|
5075
|
-
if ('refusal' in decided)
|
|
5076
|
-
|
|
5801
|
+
const decided = await gateForDecision(run, parsed.data.ord, { declining: !parsed.data.approve, versioned: true });
|
|
5802
|
+
if ('refusal' in decided) {
|
|
5803
|
+
const r = decided.refusal.body;
|
|
5804
|
+
return r?.code === 'gate_changed' ? { code: decided.refusal.code, body: { ...(await currentPlanOf(id, false)), ...r } } : decided.refusal;
|
|
5805
|
+
}
|
|
5806
|
+
// DES-CATALOG-002 §4.6: a plan-gate answer is bound to the plan on screen. A run launched from a chat proposal
|
|
5807
|
+
// REQUIRES `planRev` there, whichever client answers; a send-back needs it on any run. The engine compares it
|
|
5808
|
+
// (and `ord`) inside its own serialized decision, so a re-plan landing after this read still loses.
|
|
5809
|
+
if (decided.gateKind === 'plan_approval') {
|
|
5810
|
+
const fromProposal = runTimingIndex.fromProposalOf(id);
|
|
5811
|
+
// A Reject cancels the run whatever revision it holds, so only an approving answer or a send-back needs it.
|
|
5812
|
+
const bindsPlan = parsed.data.approve || parsed.data.action === 'request_changes';
|
|
5813
|
+
if (parsed.data.planRev === undefined && fromProposal !== undefined && bindsPlan) {
|
|
5814
|
+
return { code: 409, body: {
|
|
5815
|
+
code: 'gate_changed',
|
|
5816
|
+
error: 'Gate changed: this run was started from a chat proposal, so a plan answer must name the plan version it was made on (planRev). Read the plan again and answer it.',
|
|
5817
|
+
...(await currentPlanOf(id)),
|
|
5818
|
+
} };
|
|
5819
|
+
}
|
|
5820
|
+
if (parsed.data.planRev !== undefined && !adapterSupportsPlanSendBack()) {
|
|
5821
|
+
return { code: 501, body: { error: 'Answering a plan by its version needs a wicked-core-ts that checks it (Core.supportsPlanSendBack); upgrade the engine' } };
|
|
5822
|
+
}
|
|
5823
|
+
}
|
|
5824
|
+
else if (parsed.data.planRev !== undefined) {
|
|
5825
|
+
return { code: 409, body: { code: 'gate_changed', error: 'Gate changed: this answer names a plan version, but the open gate is not a plan approval. Read the gate again.', ...(await currentPlanOf(id)) } };
|
|
5826
|
+
}
|
|
5827
|
+
// (crew#1139) A note on a plan approval needs an engine that lands it. An older one refuses it with
|
|
5828
|
+
// words that predate notes ("send the edited steps"), so the daemon says what to do instead.
|
|
5829
|
+
if (parsed.data.approve && decided.gateKind === 'plan_approval' && (parsed.data.amend ?? '').trim() !== ''
|
|
5830
|
+
&& !(typeof adapter.supportsPlanGateNote === 'function' && adapter.supportsPlanGateNote())) {
|
|
5831
|
+
return { code: 501, body: { error: message(new PlanGateNoteUnsupportedError()) } };
|
|
5832
|
+
}
|
|
5077
5833
|
const analysis = parsed.data.approve ? analysisPlanRefusal(id, { plan: parsed.data.plan }) : null;
|
|
5078
5834
|
if (analysis !== null)
|
|
5079
5835
|
return analysis;
|
|
@@ -5120,7 +5876,21 @@ runtime = {}) {
|
|
|
5120
5876
|
// confirm, which records it as the judge when this approve answers a `judge_unavailable`
|
|
5121
5877
|
// gate ("judged by operator").
|
|
5122
5878
|
adapter.recordGateActor?.(id, `${actor.id} (${actor.kind})`);
|
|
5123
|
-
|
|
5879
|
+
// The expected ord and plan revision ride as the trailing argument only when sent (an answer without them keeps
|
|
5880
|
+
// the confirm's existing arity; DES-CATALOG-002 §4.6).
|
|
5881
|
+
const expect = parsed.data.planRev !== undefined ? { ...(gated !== undefined ? { ord: gated.ord } : parsed.data.ord !== undefined ? { ord: parsed.data.ord } : {}), planRev: parsed.data.planRev } : undefined;
|
|
5882
|
+
const confirmArgs = [
|
|
5883
|
+
id,
|
|
5884
|
+
parsed.data.approve,
|
|
5885
|
+
// (DES-RULE-CHECK-001 S2) The engine takes a rule skip's reasons in `amend` as JSON.
|
|
5886
|
+
parsed.data.action === SKIP_RULES_ACTION ? skipRulesAmend(parsed.data.skipRules ?? []) : parsed.data.amend,
|
|
5887
|
+
parsed.data.action,
|
|
5888
|
+
parsed.data.amendScope,
|
|
5889
|
+
parsed.data.plan !== undefined ? toLaunchPlan(parsed.data.plan) : undefined,
|
|
5890
|
+
];
|
|
5891
|
+
if (expect !== undefined)
|
|
5892
|
+
confirmArgs.push(expect);
|
|
5893
|
+
const status = await adapter.confirmGate(...confirmArgs);
|
|
5124
5894
|
// WHO approved/rejected — the gate-decision audit (task #88). The engine
|
|
5125
5895
|
// records THAT the gate resolved (interaction_requests / gateDecided);
|
|
5126
5896
|
// only this HTTP layer knows the authenticated principal behind it.
|
|
@@ -5132,6 +5902,13 @@ runtime = {}) {
|
|
|
5132
5902
|
detail: { reason: parsed.data.amend ?? '', ...(gated !== undefined ? { ord: gated.ord } : {}), status },
|
|
5133
5903
|
});
|
|
5134
5904
|
}
|
|
5905
|
+
// (DES-RULE-CHECK-001 S2) Each skipped rule with its reason, on its own audit line.
|
|
5906
|
+
if (parsed.data.action === SKIP_RULES_ACTION) {
|
|
5907
|
+
audit.record('gate.rules_skipped', actor, {
|
|
5908
|
+
runId: id,
|
|
5909
|
+
detail: { skips: parsed.data.skipRules ?? [], ...(gated !== undefined ? { ord: gated.ord } : {}), status },
|
|
5910
|
+
});
|
|
5911
|
+
}
|
|
5135
5912
|
audit.record('gate.decided', actor, {
|
|
5136
5913
|
runId: id,
|
|
5137
5914
|
detail: {
|
|
@@ -5141,6 +5918,7 @@ runtime = {}) {
|
|
|
5141
5918
|
...(parsed.data.amendScope !== undefined ? { amendScope: parsed.data.amendScope } : {}),
|
|
5142
5919
|
...(parsed.data.plan !== undefined ? { planSteps: parsed.data.plan.steps.length } : {}),
|
|
5143
5920
|
...(parsed.data.ord !== undefined ? { ord: parsed.data.ord } : {}),
|
|
5921
|
+
...(parsed.data.planRev !== undefined ? { planRev: parsed.data.planRev } : {}),
|
|
5144
5922
|
...(parsed.data.input !== undefined ? { input: parsed.data.input } : {}),
|
|
5145
5923
|
...extraDetail,
|
|
5146
5924
|
status,
|
|
@@ -5184,13 +5962,34 @@ runtime = {}) {
|
|
|
5184
5962
|
};
|
|
5185
5963
|
}
|
|
5186
5964
|
catch (err) {
|
|
5187
|
-
if (err instanceof PlanLaunchUnsupportedError) {
|
|
5965
|
+
if (err instanceof PlanLaunchUnsupportedError || err instanceof PlanGateNoteUnsupportedError) {
|
|
5188
5966
|
return { code: 501, body: { error: message(err) } };
|
|
5189
5967
|
}
|
|
5968
|
+
// DES-CATALOG-002 §4.6: the engine's own stale-answer refusal (`gate_changed: …`) is the typed 409, with the
|
|
5969
|
+
// plan the gate holds now, so the person reads it again.
|
|
5970
|
+
if (/^gate_changed\b/u.test(message(err))) {
|
|
5971
|
+
return { code: 409, body: { code: 'gate_changed', error: `Gate changed: ${message(err).replace(/^gate_changed:?\s*/u, '')} — read the plan again and answer it.`, ...(await currentPlanOf(id)) } };
|
|
5972
|
+
}
|
|
5190
5973
|
return { code: 409, body: { error: message(err) } };
|
|
5191
5974
|
}
|
|
5192
5975
|
});
|
|
5193
5976
|
}
|
|
5977
|
+
/** (DES-CATALOG-002 §4.6) The plan a gate holds now, for a `gate_changed` answer: its ord and revision, best-effort. */
|
|
5978
|
+
async function currentPlanOf(runId, readGate = true) {
|
|
5979
|
+
try {
|
|
5980
|
+
// The caller that already read the open gate (and names its ord) asks for the plan revision only.
|
|
5981
|
+
const recorded = readGate ? await recordedOpenGate(runId) : null;
|
|
5982
|
+
const rev = openPlanGateRev(await busRows(adapter.busDbPath, runId));
|
|
5983
|
+
return { ...(recorded?.state === 'open' ? { openOrd: recorded.ord } : {}), ...(rev !== undefined ? { planRev: rev } : {}) };
|
|
5984
|
+
}
|
|
5985
|
+
catch {
|
|
5986
|
+
return {};
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5989
|
+
/** Whether the linked engine checks `expectOrd` / `expectPlanRev` (`Core.supportsPlanSendBack`). */
|
|
5990
|
+
function adapterSupportsPlanSendBack() {
|
|
5991
|
+
return typeof adapter.supportsPlanSendBack === 'function' && adapter.supportsPlanSendBack();
|
|
5992
|
+
}
|
|
5194
5993
|
// The steering gate (§11.1). approve+amend = approve-with-steer; approve:false = reject (cancels).
|
|
5195
5994
|
app.post(`${V}/runs/:id/gate`, {
|
|
5196
5995
|
config: {
|
|
@@ -5207,6 +6006,91 @@ runtime = {}) {
|
|
|
5207
6006
|
const out = await decideGate(id, req.body, actorOf(req));
|
|
5208
6007
|
return reply.code(out.code).send(out.body);
|
|
5209
6008
|
});
|
|
6009
|
+
/**
|
|
6010
|
+
* (DES-CATALOG-002 §2.5, api-types 0.192.0) Start a run held at its FIRST work-plan approval again as another card or
|
|
6011
|
+
* option: the crew-made reshape proposal, validated, the held gate answered Reject (`reshaped`) and the replacement
|
|
6012
|
+
* launched from the held run's envelope, all under the chat's lock (`ChatProposals.reshape`).
|
|
6013
|
+
*/
|
|
6014
|
+
const ReshapeSchema = z.strictObject({
|
|
6015
|
+
card: z.string().trim().min(1).max(120),
|
|
6016
|
+
option: z.string().trim().min(1).max(80).nullable().optional(),
|
|
6017
|
+
depth: z.enum(['quick', 'standard', 'deep']).nullable().optional(),
|
|
6018
|
+
inputs: RevisionEditsSchema.shape.inputs,
|
|
6019
|
+
requestId: z.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._-]+$/),
|
|
6020
|
+
/** The person's press on the reshape question: the loss ids it was shown. */
|
|
6021
|
+
confirmLoss: z.array(z.string().min(1).max(40)).min(1).max(12).optional(),
|
|
6022
|
+
});
|
|
6023
|
+
app.post(`${V}/runs/:id/reshape`, { config: { manifest: { requestType: 'ReshapeRunBody', responseType: 'ReshapeRunResponse', statusCodes: [200, 400, 403, 404, 409, 502] } } }, async (req, reply) => {
|
|
6024
|
+
const { id } = req.params;
|
|
6025
|
+
if (!chatJobProposalsOn)
|
|
6026
|
+
return reply.code(404).send({ error: 'this daemon does not start runs again from a chat' });
|
|
6027
|
+
const parsed = ReshapeSchema.safeParse(req.body);
|
|
6028
|
+
if (!parsed.success)
|
|
6029
|
+
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
6030
|
+
const envelope = runTimingIndex.envelopeOf(id);
|
|
6031
|
+
const fromProposal = runTimingIndex.fromProposalOf(id);
|
|
6032
|
+
const chatId = envelope?.chatId ?? runTimingIndex.chatIdFor(id);
|
|
6033
|
+
if (envelope === undefined || fromProposal === undefined || chatId === undefined) {
|
|
6034
|
+
return reply.code(409).send({ code: 'reshape_not_chat', error: `run ${id} was not started from a chat proposal: start the other job in a chat instead` });
|
|
6035
|
+
}
|
|
6036
|
+
const gate = personChatGate(req, chatId, 'starts a run again');
|
|
6037
|
+
if ('refusal' in gate)
|
|
6038
|
+
return reply.code(gate.refusal.code).send(gate.refusal.body);
|
|
6039
|
+
const run = (await adapter.sessionsDetail()).find((v) => v.session.id === id);
|
|
6040
|
+
if (run === undefined)
|
|
6041
|
+
return reply.code(404).send({ error: 'Run not found' });
|
|
6042
|
+
const pid = `${chatId}:reshape:${id}:${parsed.data.requestId}`;
|
|
6043
|
+
// Eligible only while the run waits at its first WORK-plan approval (a PA's scope-only rev 1 may be accepted); a
|
|
6044
|
+
// retry after THIS reshape's own Reject (recorded on its proposal) goes on to its launch (codex r2).
|
|
6045
|
+
if (chatProposals.proposalOfPid(chatId, pid)?.heldRejected !== true) {
|
|
6046
|
+
const elig = await reshapeEligibility(id);
|
|
6047
|
+
if ('refusal' in elig)
|
|
6048
|
+
return reply.code(elig.refusal.code).send(elig.refusal.body);
|
|
6049
|
+
}
|
|
6050
|
+
const old = chatProposals.proposalOfPid(chatId, fromProposal);
|
|
6051
|
+
const base = old !== null && old.shape !== undefined ? factsOf(old) : null;
|
|
6052
|
+
const facts = {
|
|
6053
|
+
card: parsed.data.card,
|
|
6054
|
+
option: parsed.data.option ?? undefined,
|
|
6055
|
+
depth: parsed.data.depth ?? null,
|
|
6056
|
+
words: base?.words ?? envelope.words,
|
|
6057
|
+
details: base?.details ?? [],
|
|
6058
|
+
repoRef: base?.repoRef ?? envelope.repoRef ?? null,
|
|
6059
|
+
projectId: base?.projectId ?? envelope.projectId ?? null,
|
|
6060
|
+
lead: base?.lead ?? envelope.primary ?? null,
|
|
6061
|
+
seats: base?.seats ?? null,
|
|
6062
|
+
inputs: { ...(base?.inputs ?? {}), ...(parsed.data.inputs ?? {}) },
|
|
6063
|
+
// A QE skip given for the held run is not carried: the new shape's checks are its own.
|
|
6064
|
+
skipQe: null,
|
|
6065
|
+
by: 'person',
|
|
6066
|
+
source: 'reshape',
|
|
6067
|
+
};
|
|
6068
|
+
const out = await chatProposals.reshape(chatId, {
|
|
6069
|
+
pid,
|
|
6070
|
+
oldRunId: id,
|
|
6071
|
+
parentPid: fromProposal,
|
|
6072
|
+
facts,
|
|
6073
|
+
edits: {
|
|
6074
|
+
card: parsed.data.card,
|
|
6075
|
+
...(parsed.data.option !== undefined ? { option: parsed.data.option } : {}),
|
|
6076
|
+
...(parsed.data.depth !== undefined ? { depth: parsed.data.depth } : {}),
|
|
6077
|
+
...(parsed.data.inputs !== undefined ? { inputs: parsed.data.inputs } : {}),
|
|
6078
|
+
},
|
|
6079
|
+
reducedAssurance: envelope.reducedAssurance === true,
|
|
6080
|
+
relaunch: {
|
|
6081
|
+
deliver: envelope.deliver,
|
|
6082
|
+
...(envelope.deliverGate !== undefined ? { deliverGate: envelope.deliverGate } : {}),
|
|
6083
|
+
...(envelope.campaignId !== undefined ? { campaignId: envelope.campaignId } : {}),
|
|
6084
|
+
...(envelope.groupLabel !== undefined ? { groupLabel: envelope.groupLabel } : {}),
|
|
6085
|
+
...(envelope.revisesPr !== undefined ? { revisesPr: envelope.revisesPr } : {}),
|
|
6086
|
+
...(envelope.forceQeAcceptance === true ? { forceQeAcceptance: true } : {}),
|
|
6087
|
+
...(envelope.clisJson !== undefined ? { clisJson: envelope.clisJson } : {}),
|
|
6088
|
+
},
|
|
6089
|
+
request: { id: parsed.data.requestId, digest: requestDigest({ card: parsed.data.card, option: parsed.data.option ?? null, depth: parsed.data.depth ?? null, inputs: parsed.data.inputs ?? null }) },
|
|
6090
|
+
confirmLoss: parsed.data.confirmLoss ?? [],
|
|
6091
|
+
}, gate.actor, gate.instance);
|
|
6092
|
+
return reply.code(out.code).send(out.body);
|
|
6093
|
+
});
|
|
5210
6094
|
// Cancel a running or paused run (distinct third action, §11.1).
|
|
5211
6095
|
// (api-types 0.161.0, DES-VOICE) An optional body: the person's `reason` (said or typed) and `input: "voice"`, both
|
|
5212
6096
|
// kept on the `run.cancelled` audit line. A bodiless cancel is unchanged; voice is a person's only (403).
|
|
@@ -5395,11 +6279,9 @@ runtime = {}) {
|
|
|
5395
6279
|
const RIGORS = ['light', 'standard', 'high', 'highest'];
|
|
5396
6280
|
/** A trimmed free-text field: empty is absent (`null`), never `""`. */
|
|
5397
6281
|
const textOrNull = (v) => (v === undefined || v === null || v.trim() === '' ? null : v.trim());
|
|
5398
|
-
const PowerToggleSchema = z.
|
|
5399
|
-
const RigorRaiseSchema = z.
|
|
5400
|
-
const PowerPauseSchema = z
|
|
5401
|
-
.object({ decision: z.enum(['continue_high', 'continue', 'switch_phased', 'stop']), note: z.string().trim().max(8000).nullish() })
|
|
5402
|
-
.strict();
|
|
6282
|
+
const PowerToggleSchema = z.strictObject({ on: z.boolean(), reason: z.string().trim().max(2000).nullish() });
|
|
6283
|
+
const RigorRaiseSchema = z.strictObject({ atLeast: z.enum(RIGORS), reason: z.string().trim().min(1).max(2000) });
|
|
6284
|
+
const PowerPauseSchema = z.strictObject({ decision: z.enum(['continue_high', 'continue', 'switch_phased', 'stop']), note: z.string().trim().max(8000).nullish() });
|
|
5403
6285
|
/** An engine refusal as HTTP: `not_found:` 404, `conflict:` 409, `refused:` / `bad_request:` 409 / 400. */
|
|
5404
6286
|
const powerError = (reply, err) => {
|
|
5405
6287
|
const msg = message(err);
|
|
@@ -5927,23 +6809,21 @@ runtime = {}) {
|
|
|
5927
6809
|
}
|
|
5928
6810
|
return reply.code(404).send({ error: 'No pending elicitation for this run' });
|
|
5929
6811
|
});
|
|
5930
|
-
const ElicitationRespondSchema = z
|
|
5931
|
-
.object({
|
|
6812
|
+
const ElicitationRespondSchema = z.strictObject({
|
|
5932
6813
|
/** Guards against stale-tab submissions: must match the current elicitation's id. */
|
|
5933
6814
|
elicitationId: z.string().min(1),
|
|
5934
6815
|
action: z.enum(['accept', 'decline', 'cancel']),
|
|
5935
6816
|
/** Required when action is "accept"; must be absent for decline/cancel. `response` answers a free-text or
|
|
5936
6817
|
* single-choice question; `values` (api-types 0.158.0) a multi-select one. */
|
|
5937
6818
|
content: z.union([
|
|
5938
|
-
z.
|
|
5939
|
-
z.
|
|
6819
|
+
z.strictObject({ response: z.string().min(1) }),
|
|
6820
|
+
z.strictObject({ values: z.array(z.string().min(1)).min(1).max(100) }),
|
|
5940
6821
|
]).optional(),
|
|
5941
6822
|
})
|
|
5942
|
-
.strict()
|
|
5943
6823
|
.superRefine((val, ctx) => {
|
|
5944
6824
|
if (val.action !== 'accept' && val.content !== undefined) {
|
|
5945
6825
|
ctx.addIssue({
|
|
5946
|
-
code:
|
|
6826
|
+
code: 'custom',
|
|
5947
6827
|
path: ['content'],
|
|
5948
6828
|
message: 'content must only be provided when action is "accept"',
|
|
5949
6829
|
});
|
|
@@ -6230,7 +7110,7 @@ runtime = {}) {
|
|
|
6230
7110
|
},
|
|
6231
7111
|
},
|
|
6232
7112
|
}, async (req, reply) => {
|
|
6233
|
-
const parsed = z.
|
|
7113
|
+
const parsed = z.strictObject({ dryRun: z.boolean().optional() }).safeParse(req.body ?? {});
|
|
6234
7114
|
if (!parsed.success)
|
|
6235
7115
|
return reply.code(400).send({ error: parsed.error.message });
|
|
6236
7116
|
const dryRun = parsed.data.dryRun === true;
|
|
@@ -6295,6 +7175,31 @@ runtime = {}) {
|
|
|
6295
7175
|
// An unknown repo is the CALLER's error (404); a binding/parse failure is OURS (500). Don't collapse
|
|
6296
7176
|
// them (Copilot #227). Core spells the not-found case `no registered repo '<ref>'`.
|
|
6297
7177
|
const repoReadStatus = (msg) => (/no registered repo/i.test(msg) ? 404 : 500);
|
|
7178
|
+
// crew#1359: a registered repo with no code graph yet is "not indexed", a 404 with a code, never a 500. Only a
|
|
7179
|
+
// CONFIRMED missing graph file says so (the engine resolves the path, `code_graph_db`); any other open failure (a
|
|
7180
|
+
// permissions problem, a path that is a directory) stays a server error, its detail in the log (xreview r1/r2).
|
|
7181
|
+
const repoNotIndexed = async (repo) => {
|
|
7182
|
+
try {
|
|
7183
|
+
const entry = (await adapter.listRepos()).find((r) => r.id === repo || r.name === repo);
|
|
7184
|
+
const db = entry?.code_graph_db;
|
|
7185
|
+
if (typeof db !== 'string' || db === '')
|
|
7186
|
+
return false;
|
|
7187
|
+
// (xreview r2) Only ENOENT means "absent": existsSync is also false when a parent cannot be searched (EACCES).
|
|
7188
|
+
await fsp.stat(db);
|
|
7189
|
+
return false;
|
|
7190
|
+
}
|
|
7191
|
+
catch (err) {
|
|
7192
|
+
return err?.code === 'ENOENT';
|
|
7193
|
+
}
|
|
7194
|
+
};
|
|
7195
|
+
const repoReadFailure = async (reply, repo, err) => {
|
|
7196
|
+
const msg = message(err);
|
|
7197
|
+
const status = repoReadStatus(msg);
|
|
7198
|
+
if (status === 500 && (await repoNotIndexed(repo))) {
|
|
7199
|
+
return reply.code(404).send({ error: 'this repository has no code graph yet: index it first', code: 'not_indexed' });
|
|
7200
|
+
}
|
|
7201
|
+
return reply.code(status).send({ error: msg });
|
|
7202
|
+
};
|
|
6298
7203
|
app.get(`${V}/governance/coverage`, async (req, reply) => {
|
|
6299
7204
|
// FINDING-009: with `?repo=<ref>`, report coverage over THAT repo's own code graph. The bare
|
|
6300
7205
|
// endpoint reads the daemon store and reports a vacuous `coverage: 1.0` that names no repo — the
|
|
@@ -6306,8 +7211,7 @@ runtime = {}) {
|
|
|
6306
7211
|
return { report };
|
|
6307
7212
|
}
|
|
6308
7213
|
catch (err) {
|
|
6309
|
-
|
|
6310
|
-
return reply.code(repoReadStatus(msg)).send({ error: msg });
|
|
7214
|
+
return repoReadFailure(reply, repo, err);
|
|
6311
7215
|
}
|
|
6312
7216
|
}
|
|
6313
7217
|
const report = await adapter.getCoverageReport();
|
|
@@ -6327,8 +7231,7 @@ runtime = {}) {
|
|
|
6327
7231
|
return { kinds };
|
|
6328
7232
|
}
|
|
6329
7233
|
catch (err) {
|
|
6330
|
-
|
|
6331
|
-
return reply.code(repoReadStatus(msg)).send({ error: msg });
|
|
7234
|
+
return repoReadFailure(reply, repo, err);
|
|
6332
7235
|
}
|
|
6333
7236
|
});
|
|
6334
7237
|
// ── Governance writes (crew#42; STEERING fold) ─────────────────────────────
|
|
@@ -6491,23 +7394,39 @@ runtime = {}) {
|
|
|
6491
7394
|
// wf-catalog (api-types 0.168.0): the workflows as a categorised catalog with the requesting
|
|
6492
7395
|
// operator's usage. Metadata is the ONE data module (`workflow-catalog/catalog-data.ts`); what a
|
|
6493
7396
|
// workflow is and does stays on its def; usage is derived from the runs and the launch trail.
|
|
6494
|
-
app.get(`${V}/workflows/catalog`, { config: { manifest: { responseType: 'WorkflowCatalogResponse', statusCodes: [200, 400] } } }, async (req, reply) => {
|
|
7397
|
+
app.get(`${V}/workflows/catalog`, { config: { manifest: { responseType: 'WorkflowCatalogResponse | WorkflowCatalogV2Response', statusCodes: [200, 400, 503] } } }, async (req, reply) => {
|
|
6495
7398
|
const raw = req.query?.projectId;
|
|
6496
7399
|
if (raw !== undefined && (typeof raw !== 'string' || raw.length > 200)) {
|
|
6497
7400
|
return reply.code(400).send({ error: '`projectId` must be a string' });
|
|
6498
7401
|
}
|
|
7402
|
+
// DES-CATALOG-002 §4.1: `v=2` answers the catalog by verb; anything else but an absent `v` is a 400, so v1 stays
|
|
7403
|
+
// exactly as it was for every caller that sends none.
|
|
7404
|
+
const version = req.query?.v;
|
|
7405
|
+
if (version !== undefined && version !== '1' && version !== '2') {
|
|
7406
|
+
return reply.code(400).send({ error: '`v` must be 1 or 2' });
|
|
7407
|
+
}
|
|
6499
7408
|
const projectId = typeof raw === 'string' && raw !== '' ? raw : null;
|
|
6500
7409
|
const { workflows } = await adapter.workflowCatalog();
|
|
6501
7410
|
let presets = [];
|
|
7411
|
+
// v2 serves only presets it actually read (an unknown project's global ones included); no read at all is a 503.
|
|
7412
|
+
let presetsRead = true;
|
|
6502
7413
|
try {
|
|
6503
7414
|
presets = await adapter.listPresets(projectId ?? undefined);
|
|
6504
7415
|
}
|
|
6505
7416
|
catch (err) {
|
|
6506
7417
|
// An unknown project: the global presets (built-in attribution and saved ones still hold, agy r1).
|
|
6507
7418
|
// An engine without presets lists the served defs only. Either way, said once in the log.
|
|
6508
|
-
app.log.warn(`workflows/catalog: the presets could not be read${projectId !== null ? ` for project ${projectId}` : ''} (${message(err)});
|
|
6509
|
-
|
|
6510
|
-
|
|
7419
|
+
app.log.warn(`workflows/catalog: the presets could not be read${projectId !== null ? ` for project ${projectId}` : ''} (${message(err)}); v1 lists ${projectId !== null ? 'the global ones' : 'the served workflows only'}, v2 answers 503 if no presets read succeeds`);
|
|
7420
|
+
presetsRead = false;
|
|
7421
|
+
if (projectId !== null) {
|
|
7422
|
+
try {
|
|
7423
|
+
presets = await adapter.listPresets();
|
|
7424
|
+
presetsRead = true;
|
|
7425
|
+
}
|
|
7426
|
+
catch {
|
|
7427
|
+
presets = [];
|
|
7428
|
+
}
|
|
7429
|
+
}
|
|
6511
7430
|
}
|
|
6512
7431
|
const views = await adapter.sessionsDetail();
|
|
6513
7432
|
// codex r1: date terminal runs that have no `run.ended` entry from their event log, as GET /runs
|
|
@@ -6525,7 +7444,31 @@ runtime = {}) {
|
|
|
6525
7444
|
retryOf: retryIndex.retryOfFor(view.session.id),
|
|
6526
7445
|
principal: runTimingIndex.principalFor(view.session.id),
|
|
6527
7446
|
}));
|
|
6528
|
-
|
|
7447
|
+
if (version === '2') {
|
|
7448
|
+
// v2 fails closed (codex r2): a catalog read without the project's presets or the phase catalog would show checks
|
|
7449
|
+
// and a revision a launch could not honour. v1 keeps its fallback below.
|
|
7450
|
+
let entries;
|
|
7451
|
+
try {
|
|
7452
|
+
entries = await adapter.catalog();
|
|
7453
|
+
}
|
|
7454
|
+
catch (err) {
|
|
7455
|
+
return reply.code(503).send({ code: 'catalog_unavailable', error: `the catalog could not be read: ${message(err)}` });
|
|
7456
|
+
}
|
|
7457
|
+
if (!presetsRead)
|
|
7458
|
+
return reply.code(503).send({ code: 'catalog_unavailable', error: 'the presets could not be read' });
|
|
7459
|
+
return buildWorkflowCatalogV2({
|
|
7460
|
+
defs: workflows, presets, entries, actorId: me, projectId,
|
|
7461
|
+
runs: runs.map((r) => {
|
|
7462
|
+
const shape = runTimingIndex.shapeOf(r.id);
|
|
7463
|
+
return shape === undefined ? r : { ...r, shape: { card: shape.card, option: shape.option } };
|
|
7464
|
+
}),
|
|
7465
|
+
});
|
|
7466
|
+
}
|
|
7467
|
+
const body = buildWorkflowCatalog({
|
|
7468
|
+
defs: workflows, presets, runs, actorId: me, projectId,
|
|
7469
|
+
// The same rule as `GET /health.capabilities.apps.turns`.
|
|
7470
|
+
appsByChat: runtime.apps !== undefined && runtime.apps.turns !== null,
|
|
7471
|
+
});
|
|
6529
7472
|
return body;
|
|
6530
7473
|
});
|
|
6531
7474
|
app.get(`${V}/workflows/:id`, async (req, reply) => {
|
|
@@ -6636,8 +7579,8 @@ runtime = {}) {
|
|
|
6636
7579
|
risk: z.enum(['risk', 'no-risk']).optional(),
|
|
6637
7580
|
category: z.enum(['functional', 'config-data']).optional(),
|
|
6638
7581
|
domain: z.string().optional(),
|
|
6639
|
-
offset: z.coerce.number().int().min(0).
|
|
6640
|
-
limit: z.coerce.number().int().min(1).max(200).
|
|
7582
|
+
offset: z.coerce.number().int().min(0).prefault(0),
|
|
7583
|
+
limit: z.coerce.number().int().min(1).max(200).prefault(50),
|
|
6641
7584
|
}).strict();
|
|
6642
7585
|
app.get(`${V}/repos/:id/requirements`, async (req, reply) => {
|
|
6643
7586
|
const { id } = req.params;
|
|
@@ -6705,19 +7648,17 @@ runtime = {}) {
|
|
|
6705
7648
|
return reply.code(404).send({ error: 'Requirement not found' });
|
|
6706
7649
|
return { requirement: detail };
|
|
6707
7650
|
});
|
|
6708
|
-
const ReqPatchSchema = z
|
|
6709
|
-
.object({
|
|
7651
|
+
const ReqPatchSchema = z.strictObject({
|
|
6710
7652
|
title: z.string().min(1).max(500).optional(),
|
|
6711
7653
|
notes: z.string().max(5000).optional(),
|
|
6712
7654
|
status: z.enum(['active', 'deprecated', 'review']).optional(),
|
|
6713
7655
|
risk: z.boolean().optional(),
|
|
6714
7656
|
})
|
|
6715
|
-
.strict()
|
|
6716
7657
|
// `.strict()` BEFORE `.refine()`: the refine runs on the parsed object, so with stripping still
|
|
6717
7658
|
// in effect `{"title":"x","note":"y"}` would pass the non-empty check having silently discarded
|
|
6718
7659
|
// the edit the caller cared about. Every field here is optional, which is exactly the shape
|
|
6719
7660
|
// FINDING-031 makes dangerous.
|
|
6720
|
-
.refine((b) => Object.keys(b).length > 0, {
|
|
7661
|
+
.refine((b) => Object.keys(b).length > 0, { error: 'empty patch' });
|
|
6721
7662
|
app.patch(`${V}/repos/:id/requirements/:key`, async (req, reply) => {
|
|
6722
7663
|
const { id, key } = req.params;
|
|
6723
7664
|
const repos = await adapter.listRepos();
|
|
@@ -6875,7 +7816,7 @@ runtime = {}) {
|
|
|
6875
7816
|
});
|
|
6876
7817
|
// `?limit=` (1..500, default 20): the repo page shows the latest 20; its "Show all" asks for more.
|
|
6877
7818
|
const GitHistoryQuerySchema = z.object({
|
|
6878
|
-
limit: z.coerce.number().int().min(1).max(500).
|
|
7819
|
+
limit: z.coerce.number().int().min(1).max(500).prefault(20),
|
|
6879
7820
|
}).strict();
|
|
6880
7821
|
app.get(`${V}/repos/:id/git-history`, async (req, reply) => {
|
|
6881
7822
|
const { id } = req.params;
|
|
@@ -7599,6 +8540,18 @@ runtime = {}) {
|
|
|
7599
8540
|
}
|
|
7600
8541
|
return reply.code(201).send({ id: submitted.id });
|
|
7601
8542
|
});
|
|
8543
|
+
// A data shape (`knowledge` proposal) is reviewed by a human: an agent-kind actor, whatever its trust, is refused.
|
|
8544
|
+
// Only a non-human's decision costs the extra queue read.
|
|
8545
|
+
const knowledgeReviewRefused = async (req, id) => {
|
|
8546
|
+
if (actorOf(req).kind === 'human')
|
|
8547
|
+
return false;
|
|
8548
|
+
const pending = (await estateTool('proposal.list', { kind_type: 'knowledge', state: 'pending' }));
|
|
8549
|
+
return pending.proposals.some((p) => p.id === id);
|
|
8550
|
+
};
|
|
8551
|
+
const KNOWLEDGE_REVIEW_HUMAN_ONLY = (actor) => ({
|
|
8552
|
+
error: `a data shape is approved or declined by a person; you are ${actor.kind}/${actor.trust}`,
|
|
8553
|
+
code: 'knowledge_review_human_only',
|
|
8554
|
+
});
|
|
7602
8555
|
// POST /proposals/:id/approve → proposal.approve →
|
|
7603
8556
|
// { outcome:'promoted', active_id } — a MEMORY proposal, now an active memory (complete);
|
|
7604
8557
|
// { outcome:'handed_off', payload, landing } — a POLICY proposal, LANDED here as a steering rule.
|
|
@@ -7617,7 +8570,7 @@ runtime = {}) {
|
|
|
7617
8570
|
requestType: 'ApproveProposalBody',
|
|
7618
8571
|
responseType: 'ApproveProposalResponse',
|
|
7619
8572
|
// 404: an accept-with-edit naming no pending proposal; 409: one already in flight for it.
|
|
7620
|
-
statusCodes: [200, 400, 404, 409, 502],
|
|
8573
|
+
statusCodes: [200, 400, 403, 404, 409, 502],
|
|
7621
8574
|
},
|
|
7622
8575
|
},
|
|
7623
8576
|
}, async (req, reply) => {
|
|
@@ -7628,6 +8581,14 @@ runtime = {}) {
|
|
|
7628
8581
|
if (id === '') {
|
|
7629
8582
|
return reply.code(400).send({ error: '`id` is required' });
|
|
7630
8583
|
}
|
|
8584
|
+
// DES-KNOWLEDGE-DATA-001 §10.1: a data shape becomes knowledge only when a PERSON approves it.
|
|
8585
|
+
try {
|
|
8586
|
+
if (await knowledgeReviewRefused(req, id))
|
|
8587
|
+
return reply.code(403).send(KNOWLEDGE_REVIEW_HUMAN_ONLY(actorOf(req)));
|
|
8588
|
+
}
|
|
8589
|
+
catch (err) {
|
|
8590
|
+
return estateUpstreamError(reply, err);
|
|
8591
|
+
}
|
|
7631
8592
|
// An accept WITH an edit (capture review, api-types 0.49.0): the edited copy replaces the
|
|
7632
8593
|
// original in the same queue — see `approveEdited`. No body / `{}` is the plain approve below.
|
|
7633
8594
|
const edit = ApproveEditSchema.safeParse(req.body ?? {});
|
|
@@ -7799,7 +8760,7 @@ runtime = {}) {
|
|
|
7799
8760
|
// POST /proposals/:id/reject → proposal.reject → { ok: true }.
|
|
7800
8761
|
app.post(`${V}/proposals/:id/reject`,
|
|
7801
8762
|
// 409: an accept-with-edit of this proposal is in flight (api/capture.ts).
|
|
7802
|
-
{ config: { manifest: { responseType: 'RejectProposalResponse', statusCodes: [200, 400, 409, 502] } } }, async (req, reply) => {
|
|
8763
|
+
{ config: { manifest: { responseType: 'RejectProposalResponse', statusCodes: [200, 400, 403, 409, 502] } } }, async (req, reply) => {
|
|
7803
8764
|
const { id } = req.params;
|
|
7804
8765
|
if (id.trim() === '') {
|
|
7805
8766
|
return reply.code(400).send({ error: '`id` is required' });
|
|
@@ -7807,6 +8768,14 @@ runtime = {}) {
|
|
|
7807
8768
|
if (editInFlight(id.trim())) {
|
|
7808
8769
|
return reply.code(409).send({ error: `proposal ${id.trim()} is being accepted` });
|
|
7809
8770
|
}
|
|
8771
|
+
// DES-KNOWLEDGE-DATA-001 §10.1: a data shape is declined by a person, as it is approved by one.
|
|
8772
|
+
try {
|
|
8773
|
+
if (await knowledgeReviewRefused(req, id.trim()))
|
|
8774
|
+
return reply.code(403).send(KNOWLEDGE_REVIEW_HUMAN_ONLY(actorOf(req)));
|
|
8775
|
+
}
|
|
8776
|
+
catch (err) {
|
|
8777
|
+
return estateUpstreamError(reply, err);
|
|
8778
|
+
}
|
|
7810
8779
|
// DC-S4a B12: rejecting a decision's proposal dismisses the decision too (one object, two places).
|
|
7811
8780
|
const rejectedDecision = decisions?.deps.ledger.decisionForProposal(id.trim()) ?? null;
|
|
7812
8781
|
if (decisions !== null && rejectedDecision !== null) {
|
|
@@ -8215,12 +9184,12 @@ runtime = {}) {
|
|
|
8215
9184
|
// crew#371: a project's requirements / domain / coverage, folded over its repos' own reads.
|
|
8216
9185
|
registerProjectAggregateRoutes(app, adapter);
|
|
8217
9186
|
// crew#372: draft a product plan from selected requirements, as a governed run via POST /runs.
|
|
8218
|
-
registerProductRoutes(app, adapter);
|
|
9187
|
+
registerProductRoutes(app, adapter, launchRun);
|
|
8219
9188
|
// ── Capture (Studio OS behaviour 8) — notes and photos → a project-filed run whose output is
|
|
8220
9189
|
// proposals in the queue above; the launch is POST /runs itself (api/capture.ts).
|
|
8221
9190
|
registerCaptureRoutes(app);
|
|
8222
9191
|
// The Demo experience (studio#373): the demo preset's launch, view, files and script edit.
|
|
8223
|
-
registerDemoRoutes(app, adapter);
|
|
9192
|
+
registerDemoRoutes(app, adapter, launchRun);
|
|
8224
9193
|
// WT-W3: the storyline PUT checks the open gate through the same resolution the gate routes use.
|
|
8225
9194
|
registerWalkthroughRoutes(app, adapter, { resolveOpenGate, audit });
|
|
8226
9195
|
// ── Presets (DES-TEAMING-002 §8.4, seam C2) — saved phase selections in the engine's store;
|
|
@@ -8338,11 +9307,77 @@ runtime = {}) {
|
|
|
8338
9307
|
...(runtime.askServer !== undefined ? { askServer: runtime.askServer } : {}),
|
|
8339
9308
|
...(runtime.mcp !== undefined ? { registry: runtime.mcp, toolLister: () => CoreAdapter.mcpToolLister() } : {}),
|
|
8340
9309
|
...(runtime.mcpBroker !== undefined ? { broker: runtime.mcpBroker } : {}),
|
|
9310
|
+
...(runtime.dataGate !== undefined ? { gate: runtime.dataGate } : {}),
|
|
8341
9311
|
...(mcpPolicies !== undefined ? { policies: mcpPolicies } : {}),
|
|
8342
9312
|
...(runtime.mcpCalls !== undefined ? { usage: runtime.mcpCalls } : {}),
|
|
8343
9313
|
audit,
|
|
8344
9314
|
actorOf,
|
|
8345
9315
|
});
|
|
9316
|
+
// Apps data sources (DES-APPS-001 §5): the source sheet's routes over the same registry. "Ask a
|
|
9317
|
+
// question of this data" drafts through the standing-order parse's one-shot seat turn (one seat, one
|
|
9318
|
+
// `understand` step, never the warm chat pool).
|
|
9319
|
+
registerSourceRoutes(app, {
|
|
9320
|
+
...(runtime.mcp !== undefined ? { registry: runtime.mcp } : {}),
|
|
9321
|
+
audit,
|
|
9322
|
+
actorOf,
|
|
9323
|
+
// (K2b) Allow writes off withdraws the source's row-write grants.
|
|
9324
|
+
...(appsWritePath !== undefined ? { rowWriteGrants: appsWritePath } : {}),
|
|
9325
|
+
draft: seatTurn({ adapter, roster: rosterWithStanding }),
|
|
9326
|
+
...(runtime.dataGate !== undefined ? { gate: runtime.dataGate } : {}),
|
|
9327
|
+
});
|
|
9328
|
+
// DES-KNOWLEDGE-DATA-001 §7.1, §7.9: the per-source agent switches (human-only) and the read record.
|
|
9329
|
+
registerGateRoutes(app, {
|
|
9330
|
+
...(runtime.mcpRegistryStore !== undefined ? { store: runtime.mcpRegistryStore } : {}),
|
|
9331
|
+
...(runtime.sourceReads !== undefined ? { record: runtime.sourceReads } : {}),
|
|
9332
|
+
audit,
|
|
9333
|
+
actorOf,
|
|
9334
|
+
});
|
|
9335
|
+
// DES-PM-001 §3.3: tracker links (human-only), on the PM source's registry entry, projected into estate.
|
|
9336
|
+
registerTrackerRoutes(app, {
|
|
9337
|
+
...(runtime.mcpRegistryStore !== undefined ? { store: runtime.mcpRegistryStore } : {}),
|
|
9338
|
+
...(runtime.dataGate !== undefined ? { pm: runtime.dataGate.pm } : {}),
|
|
9339
|
+
projects: {
|
|
9340
|
+
get: (id) => adapter.projectGet(id),
|
|
9341
|
+
repos: (id) => repoMembersOf(id),
|
|
9342
|
+
ofRepo: (id) => adapter.memberProjects('crew.repo', id),
|
|
9343
|
+
allRepos: async () => (await adapter.listRepos()).map((r) => r.id),
|
|
9344
|
+
},
|
|
9345
|
+
audit,
|
|
9346
|
+
actorOf,
|
|
9347
|
+
...(runtime.trackerProjector !== undefined ? { projection: runtime.trackerProjector.projection, changed: (_source, trackerId) => runtime.trackerProjector?.changed(trackerId) } : {}),
|
|
9348
|
+
});
|
|
9349
|
+
// DES-PM-001 §5: governed actions on a run's issues (comment, transition), human-only, asked every time in v1.
|
|
9350
|
+
registerTrackerActionRoutes(app, {
|
|
9351
|
+
...(runtime.mcpRegistryStore !== undefined ? { store: runtime.mcpRegistryStore } : {}),
|
|
9352
|
+
...(runtime.dataGate !== undefined ? { pm: runtime.dataGate.pm } : {}),
|
|
9353
|
+
...(runtime.trackerAddresses !== undefined ? { addresses: runtime.trackerAddresses } : {}),
|
|
9354
|
+
runScope: async (runId) => {
|
|
9355
|
+
const run = (await adapter.sessionsDetail()).find((v) => v.session.id === runId);
|
|
9356
|
+
if (run === undefined)
|
|
9357
|
+
return null;
|
|
9358
|
+
const projectId = projects.index.projectOf(runId) ?? (await adapter.memberProjects('crew.run', runId).catch(() => []))[0] ?? null;
|
|
9359
|
+
return { projectId, repoId: run.session.repo_ref ?? null };
|
|
9360
|
+
},
|
|
9361
|
+
members: repoMembersOf,
|
|
9362
|
+
audit,
|
|
9363
|
+
actorOf,
|
|
9364
|
+
});
|
|
9365
|
+
// DES-KNOWLEDGE-DATA-001 §10 (B4): profile a source into data-shape proposals, and the Knowledge map (both human-only).
|
|
9366
|
+
registerShapeRoutes(app, {
|
|
9367
|
+
...(runtime.mcp !== undefined ? { registry: runtime.mcp } : {}),
|
|
9368
|
+
...(runtime.dataGate !== undefined ? { gate: runtime.dataGate } : {}),
|
|
9369
|
+
estate: estateTool,
|
|
9370
|
+
repos: () => adapter.listRepos(),
|
|
9371
|
+
audit,
|
|
9372
|
+
actorOf,
|
|
9373
|
+
...(runtime.dataGate !== undefined
|
|
9374
|
+
? {
|
|
9375
|
+
trackers: async () => (await runtime.dataGate.pm.entries()).flatMap((e) => e.trackers.map((t) => ({ id: t.id, source: e.name, key: t.key, label: t.label }))),
|
|
9376
|
+
projects: async () => (await adapter.projectList()).map((p) => ({ id: p.id, name: p.name })),
|
|
9377
|
+
}
|
|
9378
|
+
: {}),
|
|
9379
|
+
...(appsKnowledge !== undefined ? { knowledge: appsKnowledge } : {}),
|
|
9380
|
+
});
|
|
8346
9381
|
// ── The wicked-interactive bridge, reverse-proxied (DES-MERGE-001 §5.3/§7.2) ──
|
|
8347
9382
|
// Mounted BESIDE the routes above and under the same `${V}` prefix, so it inherits one
|
|
8348
9383
|
// origin, one auth hook, and one CORS posture — the whole point of slice 1.
|
|
@@ -8379,6 +9414,14 @@ runtime = {}) {
|
|
|
8379
9414
|
}
|
|
8380
9415
|
});
|
|
8381
9416
|
// The roster's seats (on the container floor every seat runs in an image); `null` when unreadable.
|
|
9417
|
+
const rosterSeatsNow = () => {
|
|
9418
|
+
try {
|
|
9419
|
+
return rosterWithStanding();
|
|
9420
|
+
}
|
|
9421
|
+
catch {
|
|
9422
|
+
return [];
|
|
9423
|
+
}
|
|
9424
|
+
};
|
|
8382
9425
|
const rosterSeatClis = () => {
|
|
8383
9426
|
try {
|
|
8384
9427
|
return rosterWithStanding().map((r) => String(r.key));
|
|
@@ -8497,13 +9540,16 @@ runtime = {}) {
|
|
|
8497
9540
|
catch {
|
|
8498
9541
|
return null;
|
|
8499
9542
|
} })() : null;
|
|
9543
|
+
// The broker probe refreshes each container seat's sign-in: the seat images row reads which CLIs
|
|
9544
|
+
// are signed in only after it, as the CLI cards do.
|
|
9545
|
+
const brokerP = probeBroker({
|
|
9546
|
+
containerFloor,
|
|
9547
|
+
clis: roster.map((r) => r.key).filter((k) => isContainerLoginCli(k)),
|
|
9548
|
+
status: (cli) => containerStatus.refreshFresh(cli),
|
|
9549
|
+
});
|
|
8500
9550
|
const infraP = Promise.all([
|
|
8501
9551
|
probeGateway({ containerFloor, gatewayDir, runtime: containerFloor ? resolveContainerRuntime() : null, exec: systemExec }),
|
|
8502
|
-
|
|
8503
|
-
containerFloor,
|
|
8504
|
-
clis: roster.map((r) => r.key).filter((k) => isContainerLoginCli(k)),
|
|
8505
|
-
status: (cli) => containerStatus.refreshFresh(cli),
|
|
8506
|
-
}),
|
|
9552
|
+
brokerP,
|
|
8507
9553
|
probeInteractive({
|
|
8508
9554
|
roots: interactiveRoots,
|
|
8509
9555
|
readLock: (root) => readBridgeLockAsync(root),
|
|
@@ -8519,7 +9565,18 @@ runtime = {}) {
|
|
|
8519
9565
|
}),
|
|
8520
9566
|
probeVault({ vault: adapter.vaultBin != null ? vaultDiagnostics(adapter.vaultBin) : null, exec: systemExec }),
|
|
8521
9567
|
diskRow(stateHome),
|
|
8522
|
-
probeSeatImages({
|
|
9568
|
+
probeSeatImages({
|
|
9569
|
+
containerFloor,
|
|
9570
|
+
clis: rosterSeatClis(),
|
|
9571
|
+
// A CLI none of whose seats is signed in needs no image yet, read after the broker's refresh;
|
|
9572
|
+
// a CLI with any signed-in seat (`claude#2`) keeps its image.
|
|
9573
|
+
idle: async () => {
|
|
9574
|
+
await brokerP;
|
|
9575
|
+
return idleClis(rosterSeatsNow());
|
|
9576
|
+
},
|
|
9577
|
+
status: seatImageStatus,
|
|
9578
|
+
rebuild: () => seatImageRebuilder.current(),
|
|
9579
|
+
}),
|
|
8523
9580
|
]);
|
|
8524
9581
|
const [views, settings, openGates, diag, ping, rules, gatesByYou, infraProbed, reposRead] = await Promise.all([
|
|
8525
9582
|
viewsP, settingsP, gatesP, diagP, pingP, rulesP, gatesByYouP, infraP, reposP,
|