wicked-crew 0.16.12 → 0.17.0
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 +3 -2
- 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-history.d.ts +6 -0
- package/dist/api/chat-history.d.ts.map +1 -1
- package/dist/api/chat-history.js +21 -0
- package/dist/api/chat-history.js.map +1 -1
- 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 +82 -155
- package/dist/api/chat-proposals.d.ts.map +1 -1
- package/dist/api/chat-proposals.js +254 -28
- 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 +17 -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 +3 -22
- package/dist/api/product.d.ts.map +1 -1
- package/dist/api/product.js +4 -6
- 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 +10 -37
- package/dist/api/recording.d.ts.map +1 -1
- package/dist/api/recording.js +9 -11
- package/dist/api/recording.js.map +1 -1
- package/dist/api/routes.d.ts +173 -1507
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +660 -139
- package/dist/api/routes.js.map +1 -1
- package/dist/api/run-timing-index.d.ts +18 -0
- package/dist/api/run-timing-index.d.ts.map +1 -1
- package/dist/api/run-timing-index.js +34 -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 +276 -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 +691 -0
- package/dist/apps/spec.d.ts.map +1 -0
- package/dist/apps/spec.js +839 -0
- package/dist/apps/spec.js.map +1 -0
- 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 +9 -4
- 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 +23 -0
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +49 -1
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/deliver-text.d.ts +25 -0
- package/dist/core/deliver-text.d.ts.map +1 -1
- package/dist/core/deliver-text.js +50 -5
- package/dist/core/deliver-text.js.map +1 -1
- package/dist/core/deliver.d.ts.map +1 -1
- package/dist/core/deliver.js +6 -0
- 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/run-boot-resume.d.ts +4 -1
- package/dist/core/run-boot-resume.d.ts.map +1 -1
- package/dist/core/run-boot-resume.js +6 -1
- package/dist/core/run-boot-resume.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/csp.d.ts +24 -4
- package/dist/editors/csp.d.ts.map +1 -1
- package/dist/editors/csp.js +35 -8
- package/dist/editors/csp.js.map +1 -1
- 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.d.ts +4 -1
- package/dist/editors/routes.d.ts.map +1 -1
- package/dist/editors/routes.js +33 -6
- package/dist/editors/routes.js.map +1 -1
- package/dist/editors/webrtc-guard.d.ts +94 -0
- package/dist/editors/webrtc-guard.d.ts.map +1 -0
- package/dist/editors/webrtc-guard.js +506 -0
- package/dist/editors/webrtc-guard.js.map +1 -0
- 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/bridge-pool.d.ts +11 -2
- package/dist/interactive/bridge-pool.d.ts.map +1 -1
- package/dist/interactive/bridge-pool.js +10 -1
- package/dist/interactive/bridge-pool.js.map +1 -1
- package/dist/interactive/doc-binding.d.ts +156 -0
- package/dist/interactive/doc-binding.d.ts.map +1 -0
- package/dist/interactive/doc-binding.js +277 -0
- package/dist/interactive/doc-binding.js.map +1 -0
- package/dist/interactive/doc-delete-routes.d.ts +3 -0
- package/dist/interactive/doc-delete-routes.d.ts.map +1 -1
- package/dist/interactive/doc-delete-routes.js +4 -0
- package/dist/interactive/doc-delete-routes.js.map +1 -1
- package/dist/interactive/draft-events.d.ts +89 -3
- package/dist/interactive/draft-events.d.ts.map +1 -1
- package/dist/interactive/draft-events.js +438 -27
- package/dist/interactive/draft-events.js.map +1 -1
- package/dist/interactive/edit-events.d.ts +2 -0
- package/dist/interactive/edit-events.d.ts.map +1 -1
- package/dist/interactive/edit-events.js +11 -0
- package/dist/interactive/edit-events.js.map +1 -1
- package/dist/interactive/proposal-create.d.ts +143 -0
- package/dist/interactive/proposal-create.d.ts.map +1 -0
- package/dist/interactive/proposal-create.js +318 -0
- package/dist/interactive/proposal-create.js.map +1 -0
- package/dist/interactive/proxy-routes.d.ts +60 -3
- package/dist/interactive/proxy-routes.d.ts.map +1 -1
- package/dist/interactive/proxy-routes.js +285 -10
- package/dist/interactive/proxy-routes.js.map +1 -1
- package/dist/interactive/source-packet.d.ts +126 -0
- package/dist/interactive/source-packet.d.ts.map +1 -0
- package/dist/interactive/source-packet.js +482 -0
- package/dist/interactive/source-packet.js.map +1 -0
- 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 +21 -172
- package/dist/team/routes.d.ts.map +1 -1
- package/dist/team/routes.js +4 -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.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.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/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 +617 -7
- package/package.json +11 -5
- 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-C_UIgTiy.js +0 -986
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracker links (DES-PM-001 §3.3): which trackers (one project inside one tenant of a registered PM system) are
|
|
3
|
+
* linked to which studio projects and repos. Every route is a HUMAN's only: any other actor, whatever its trust, gets
|
|
4
|
+
* 403 `tracker_links_human_only` (the rule of `knowledge/gate/routes.ts`): a link says "this work is tracked there",
|
|
5
|
+
* and it widens what a project's agents may read.
|
|
6
|
+
*
|
|
7
|
+
* GET /tracker-links?project=&repo= the links of a project and/or a repo (with both: a run's tracker set)
|
|
8
|
+
* POST /tracker-links link a tracker (a direct live lookup first); 201, or 200 when it exists
|
|
9
|
+
* DELETE /tracker-links/:id unlink; the tracker's last link retires it (its estate documents go)
|
|
10
|
+
* GET /sources/:name/trackers one page of the projects the source lists NOW (a person's live read)
|
|
11
|
+
*
|
|
12
|
+
* The links live on the PM source's registry entry (`trackers[]`), written in one registry mutation (a generation,
|
|
13
|
+
* an atomic rename), audited `knowledge.source.tracker_linked` / `tracker_unlinked`, then projected into estate.
|
|
14
|
+
* Access follows the registry at once (the gate reads it on every call); Understand follows the projection.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from '../../zod.js';
|
|
17
|
+
import { API_PREFIX } from '../../api/api-prefix.js';
|
|
18
|
+
import { trustAtLeast } from '../../api/auth.js';
|
|
19
|
+
import { MCP_SERVER_NAME_RE } from '../../mcp/classify.js';
|
|
20
|
+
import { configOf, normalizeRegistryFile, pmDescriptorHash } from '../../mcp/registry.js';
|
|
21
|
+
import { McpRegistryCorruptError } from '../../mcp/registry-store.js';
|
|
22
|
+
import { DEFAULT_PROJECT_ID } from '../../projects/default-project.js';
|
|
23
|
+
import { agentMay } from '../gate/access.js';
|
|
24
|
+
import { trackerIdOf, trackerLabel, trackerLinkIdOf, trackersOf } from '../registry/entry.js';
|
|
25
|
+
import { bindingInForce, GITHUB_TENANT, jiraSitesOf, outlineOf, readPayload } from './bindings.js';
|
|
26
|
+
import { projectOptsVia } from './gate-pm.js';
|
|
27
|
+
import { pmEntriesOf } from './set.js';
|
|
28
|
+
import { PROJECTION_UNKNOWN, trackerLinkView } from './view.js';
|
|
29
|
+
const V = API_PREFIX;
|
|
30
|
+
const isHuman = (a) => a.kind === 'human';
|
|
31
|
+
const isHumanOperator = (a) => a.kind === 'human' && trustAtLeast(a, 'operator');
|
|
32
|
+
function humanOnly(reply, actor) {
|
|
33
|
+
return reply.code(403).send({ error: `only a person links trackers to projects and repos, or reads a tracker source's projects; you are ${actor.kind}/${actor.trust}`, code: 'tracker_links_human_only' });
|
|
34
|
+
}
|
|
35
|
+
const TargetSchema = z.discriminatedUnion('kind', [
|
|
36
|
+
z.strictObject({ kind: z.literal('project'), id: z.string().min(1).max(128).regex(/^[A-Za-z0-9_.:-]+$/) }),
|
|
37
|
+
z.strictObject({ kind: z.literal('repo'), id: z.string().min(1).max(128).regex(/^[A-Za-z0-9_.:-]+$/) }),
|
|
38
|
+
]);
|
|
39
|
+
export const CreateTrackerLinkSchema = z.strictObject({
|
|
40
|
+
source: z.string().min(1).max(63),
|
|
41
|
+
tenant: z.string().min(1).max(256),
|
|
42
|
+
key: z.string().min(1).max(201),
|
|
43
|
+
target: TargetSchema,
|
|
44
|
+
});
|
|
45
|
+
const ListQuery = z.strictObject({ project: z.string().min(1).max(128).optional(), repo: z.string().min(1).max(128).optional() });
|
|
46
|
+
const IssuesQuery = z.strictObject({ project: z.string().min(1).max(128).optional(), repo: z.string().min(1).max(128).optional(), q: z.string().max(200).optional() });
|
|
47
|
+
const SourceTrackersQuery = z.strictObject({ q: z.string().max(200).optional(), cursor: z.string().max(400).optional(), tenant: z.string().max(256).optional() });
|
|
48
|
+
/** A Jira project key, or a GitHub `owner/repo`: one key names one project (no wildcard, JQL or whole site). */
|
|
49
|
+
export function validTrackerKey(system, key) {
|
|
50
|
+
if (system === 'jira')
|
|
51
|
+
return /^[A-Z][A-Z0-9_]{0,19}$/.test(key);
|
|
52
|
+
if (system === 'github')
|
|
53
|
+
return /^[A-Za-z0-9_.-]{1,100}\/[A-Za-z0-9_.-]{1,100}$/.test(key);
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
const PAGE = 50;
|
|
57
|
+
/** At most this many links per tracker (estate's per-document link bound). */
|
|
58
|
+
export const TRACKER_LINKS_MAX = 200;
|
|
59
|
+
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
60
|
+
/** The single JSON payload of a person read (the same rule the projectors use), or `null`. */
|
|
61
|
+
function payload(result) {
|
|
62
|
+
const r = readPayload(result);
|
|
63
|
+
return r.ok ? r.payload : null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A person read's payload, or why there is none, said so the next attempt is diagnosable: the vendor's error with its
|
|
67
|
+
* HTTP status, or the outline of a shape crew does not know (block types, field names, array lengths; never a value).
|
|
68
|
+
*/
|
|
69
|
+
function read(e, tool, result) {
|
|
70
|
+
return readPayload(result, `${e.name} (${tool})`);
|
|
71
|
+
}
|
|
72
|
+
/** Jira sites the credential reaches (`getAccessibleAtlassianResources`): v2 `{resources: [{cloudId, url, products}]}`. */
|
|
73
|
+
async function jiraSites(pm, e) {
|
|
74
|
+
const r = await pm.personCall(e, 'getAccessibleAtlassianResources', {});
|
|
75
|
+
if (!r.ok)
|
|
76
|
+
return r;
|
|
77
|
+
const p = read(e, 'getAccessibleAtlassianResources', r.result);
|
|
78
|
+
if (!p.ok)
|
|
79
|
+
return p;
|
|
80
|
+
const sites = jiraSitesOf(p.payload);
|
|
81
|
+
if (sites === null)
|
|
82
|
+
return { ok: false, code: 'unknown_shape', reason: `${e.name} answered its sites in a shape crew does not know (got ${outlineOf(p.payload)})` };
|
|
83
|
+
return { ok: true, sites: sites.map((s) => ({ ...s, label: trackerLabel(s.label, s.id) })) };
|
|
84
|
+
}
|
|
85
|
+
/** One page of a Jira site's projects (`listJiraProjects`). */
|
|
86
|
+
async function jiraProjects(pm, e, cloudId, q, startAt) {
|
|
87
|
+
// A non-primary operation on the Atlassian v2 server: by name, or through its executeRead meta-tool.
|
|
88
|
+
const r = await pm.personOp(e, 'listJiraProjects', cloudId, { ...(q !== '' ? { searchString: q } : {}), startAt, maxResults: PAGE });
|
|
89
|
+
if (!r.ok)
|
|
90
|
+
return r;
|
|
91
|
+
const pr = read(e, 'listJiraProjects', r.result);
|
|
92
|
+
if (!pr.ok)
|
|
93
|
+
return pr;
|
|
94
|
+
const p = pr.payload;
|
|
95
|
+
const list = Array.isArray(p) ? p : isObj(p) && Array.isArray(p['values']) ? p['values'] : isObj(p) && Array.isArray(p['projects']) ? p['projects'] : null;
|
|
96
|
+
if (list === null)
|
|
97
|
+
return { ok: false, code: 'unknown_shape', reason: `${e.name} answered its projects in a shape crew does not know (got ${outlineOf(p)})` };
|
|
98
|
+
const rows = list.filter(isObj).filter((x) => typeof x['key'] === 'string' && validTrackerKey('jira', x['key'])).map((x) => ({ key: x['key'], label: trackerLabel(x['name'], x['key']) }));
|
|
99
|
+
const more = isObj(p) && p['isLast'] === false ? true : isObj(p) && typeof p['total'] === 'number' ? startAt + list.length < p['total'] : list.length >= PAGE;
|
|
100
|
+
return { ok: true, rows, more };
|
|
101
|
+
}
|
|
102
|
+
/** One page of GitHub repositories (`search_repositories`). */
|
|
103
|
+
async function githubRepos(pm, e, query, page) {
|
|
104
|
+
const r = await pm.personCall(e, 'search_repositories', { query, page, perPage: PAGE });
|
|
105
|
+
if (!r.ok)
|
|
106
|
+
return r;
|
|
107
|
+
const pr = read(e, 'search_repositories', r.result);
|
|
108
|
+
if (!pr.ok)
|
|
109
|
+
return pr;
|
|
110
|
+
const p = pr.payload;
|
|
111
|
+
if (!isObj(p) || !Array.isArray(p['items']))
|
|
112
|
+
return { ok: false, code: 'unknown_shape', reason: `${e.name} answered its repositories in a shape crew does not know (got ${outlineOf(p)})` };
|
|
113
|
+
const rows = p['items'].filter(isObj).filter((x) => typeof x['full_name'] === 'string' && validTrackerKey('github', x['full_name'])).map((x) => ({ key: x['full_name'], label: trackerLabel(x['full_name'], x['full_name']) }));
|
|
114
|
+
const total = typeof p['total_count'] === 'number' ? p['total_count'] : 0;
|
|
115
|
+
return { ok: true, rows, more: page * PAGE < Math.min(total, 1000) };
|
|
116
|
+
}
|
|
117
|
+
const enc = (v) => Buffer.from(JSON.stringify(v), 'utf8').toString('base64url');
|
|
118
|
+
function dec(c) {
|
|
119
|
+
if (c === undefined || c === '')
|
|
120
|
+
return {};
|
|
121
|
+
try {
|
|
122
|
+
const v = JSON.parse(Buffer.from(c, 'base64url').toString('utf8'));
|
|
123
|
+
if (!isObj(v))
|
|
124
|
+
return null;
|
|
125
|
+
// Only this route's own shapes: whole, non-negative offsets (`t`, `s`) or a page from 1 (`p`).
|
|
126
|
+
const keys = Object.keys(v);
|
|
127
|
+
const nat = (x, min) => typeof x === 'number' && Number.isInteger(x) && x >= min && x <= 1_000_000;
|
|
128
|
+
if (keys.every((k) => k === 't' || k === 's') && (v['t'] === undefined || nat(v['t'], 0)) && (v['s'] === undefined || nat(v['s'], 0)))
|
|
129
|
+
return v;
|
|
130
|
+
if (keys.length === 1 && keys[0] === 'p' && nat(v['p'], 1))
|
|
131
|
+
return v;
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** One page of the projects a PM source lists now. */
|
|
139
|
+
export async function listSourceTrackers(pm, e, q, cursor, onlyTenant) {
|
|
140
|
+
if (e.system === 'github') {
|
|
141
|
+
const page = typeof cursor['p'] === 'number' && cursor['p'] >= 1 ? Math.trunc(cursor['p']) : 1;
|
|
142
|
+
let query = q.trim();
|
|
143
|
+
if (query === '') {
|
|
144
|
+
const me = await pm.personCall(e, 'get_me', {});
|
|
145
|
+
if (!me.ok)
|
|
146
|
+
return me;
|
|
147
|
+
const pr = read(e, 'get_me', me.result);
|
|
148
|
+
if (!pr.ok)
|
|
149
|
+
return pr;
|
|
150
|
+
const p = pr.payload;
|
|
151
|
+
const login = isObj(p) && typeof p['login'] === 'string' ? p['login'] : null;
|
|
152
|
+
if (login === null)
|
|
153
|
+
return { ok: false, code: 'unknown_shape', reason: `${e.name} did not say whose credential it holds (get_me answered ${outlineOf(p)})` };
|
|
154
|
+
query = `user:${login}`;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
query = `${query.replace(/[^\w./ -]/g, ' ')} in:name`;
|
|
158
|
+
}
|
|
159
|
+
const r = await githubRepos(pm, e, `${query} fork:true`, page);
|
|
160
|
+
if (!r.ok)
|
|
161
|
+
return r;
|
|
162
|
+
return { ok: true, rows: r.rows.map((x) => ({ tenant: GITHUB_TENANT, key: x.key, label: x.label })), next: r.more ? enc({ p: page + 1 }) : null };
|
|
163
|
+
}
|
|
164
|
+
const sites = await jiraSites(pm, e);
|
|
165
|
+
if (!sites.ok)
|
|
166
|
+
return sites;
|
|
167
|
+
const pool = onlyTenant === null ? sites.sites : sites.sites.filter((s) => s.id === onlyTenant);
|
|
168
|
+
let t = typeof cursor['t'] === 'number' ? Math.trunc(cursor['t']) : 0;
|
|
169
|
+
let s = typeof cursor['s'] === 'number' ? Math.trunc(cursor['s']) : 0;
|
|
170
|
+
const rows = [];
|
|
171
|
+
while (t < pool.length && rows.length === 0) {
|
|
172
|
+
const site = pool[t];
|
|
173
|
+
const r = await jiraProjects(pm, e, site.id, q.trim(), s);
|
|
174
|
+
if (!r.ok)
|
|
175
|
+
return r;
|
|
176
|
+
rows.push(...r.rows.map((x) => ({ tenant: site.id, tenantLabel: site.label, key: x.key, label: x.label })));
|
|
177
|
+
if (r.more) {
|
|
178
|
+
s += PAGE;
|
|
179
|
+
return { ok: true, rows, next: enc({ t, s }) };
|
|
180
|
+
}
|
|
181
|
+
t += 1;
|
|
182
|
+
s = 0;
|
|
183
|
+
}
|
|
184
|
+
return { ok: true, rows, next: t < pool.length ? enc({ t, s: 0 }) : null };
|
|
185
|
+
}
|
|
186
|
+
/** The direct live lookup a link needs (§3.3): the tracker's label, or why it cannot be linked. */
|
|
187
|
+
export async function lookupTracker(pm, e, tenant, key) {
|
|
188
|
+
if (!validTrackerKey(e.system, key))
|
|
189
|
+
return { ok: false, status: 422, code: 'tracker_unknown', reason: e.system === 'jira' ? 'a Jira tracker is one project key, such as PROJA' : 'a GitHub tracker is one owner/repo' };
|
|
190
|
+
if (e.system === 'github') {
|
|
191
|
+
if (tenant !== GITHUB_TENANT)
|
|
192
|
+
return { ok: false, status: 422, code: 'tracker_unknown', reason: `a GitHub source's tenant is ${GITHUB_TENANT}` };
|
|
193
|
+
const r = await githubRepos(pm, e, `repo:${key}`, 1);
|
|
194
|
+
if (!r.ok)
|
|
195
|
+
return { ...r, status: 503, code: 'source_unavailable', cause: r.code };
|
|
196
|
+
const hit = r.rows.find((x) => x.key.toLowerCase() === key.toLowerCase());
|
|
197
|
+
if (hit === undefined)
|
|
198
|
+
return { ok: false, status: 422, code: 'tracker_unknown', reason: `${e.name} finds no repository ${key}` };
|
|
199
|
+
return { ok: true, key: hit.key, label: hit.label, tenantLabel: null };
|
|
200
|
+
}
|
|
201
|
+
const sites = await jiraSites(pm, e);
|
|
202
|
+
if (!sites.ok)
|
|
203
|
+
return { ...sites, status: 503, code: 'source_unavailable', cause: sites.code };
|
|
204
|
+
const site = sites.sites.find((s) => s.id === tenant);
|
|
205
|
+
if (site === undefined)
|
|
206
|
+
return { ok: false, status: 422, code: 'tracker_unknown', reason: `${e.name}'s credential reaches no Jira site ${tenant}` };
|
|
207
|
+
// Every page of the key's search, until the exact key is found or the site says it was the last page.
|
|
208
|
+
for (let page = 0; page < 20; page++) {
|
|
209
|
+
const r = await jiraProjects(pm, e, tenant, key, page * PAGE);
|
|
210
|
+
if (!r.ok)
|
|
211
|
+
return { ...r, status: 503, code: 'source_unavailable', cause: r.code };
|
|
212
|
+
const hit = r.rows.find((x) => x.key === key);
|
|
213
|
+
if (hit !== undefined)
|
|
214
|
+
return { ok: true, key: hit.key, label: hit.label, tenantLabel: site.label, siteHost: site.host };
|
|
215
|
+
if (!r.more)
|
|
216
|
+
return { ok: false, status: 422, code: 'tracker_unknown', reason: `${site.label} has no project ${key}` };
|
|
217
|
+
}
|
|
218
|
+
// Pages left that were not read: not a "no such project", which this could not tell.
|
|
219
|
+
return { ok: false, status: 503, code: 'source_unavailable', reason: `${site.label} answered more projects matching ${key} than crew reads at once; try again with the exact key` };
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* A tracker's value-free structure (§3.4): its issue types and workflow states, mapped to todo/doing/done. Read at
|
|
223
|
+
* link time, best-effort: a tool the server lacks, or an answer this cannot read, leaves that part empty.
|
|
224
|
+
*/
|
|
225
|
+
export async function readStructure(pm, e, tenant, key) {
|
|
226
|
+
const names = (p, ...lists) => {
|
|
227
|
+
const l = Array.isArray(p) ? p : isObj(p) ? lists.map((k) => p[k]).find(Array.isArray) : null;
|
|
228
|
+
return Array.isArray(l) ? l.filter(isObj).slice(0, 50) : [];
|
|
229
|
+
};
|
|
230
|
+
const cat = (v) => {
|
|
231
|
+
const k = String(isObj(v) ? (v['key'] ?? '') : (v ?? '')).toLowerCase();
|
|
232
|
+
return k === 'new' || k === 'todo' || k === 'to_do' ? 'todo' : k === 'indeterminate' || k === 'in_progress' ? 'doing' : k === 'done' ? 'done' : null;
|
|
233
|
+
};
|
|
234
|
+
if (e.system === 'github') {
|
|
235
|
+
const [owner] = key.split('/');
|
|
236
|
+
const r = await pm.personCall(e, 'list_issue_types', { owner }).catch(() => null);
|
|
237
|
+
const types = r !== null && r.ok ? names(payload(r.result), 'issue_types', 'types').map((x) => trackerLabel(x['name'], '?')) : [];
|
|
238
|
+
return { issueTypes: types, states: [{ name: 'open', category: 'todo' }, { name: 'closed', category: 'done' }], fields: [] };
|
|
239
|
+
}
|
|
240
|
+
const t = await pm.personOp(e, 'listJiraProjectIssueTypesMetadata', tenant, { projectIdOrKey: key }).catch(() => null);
|
|
241
|
+
const st = await pm.personOp(e, 'listJiraStatuses', tenant, { projectIdOrKey: key }).catch(() => null);
|
|
242
|
+
const types = t !== null && t.ok ? names(payload(t.result), 'issueTypes', 'values') : [];
|
|
243
|
+
// The fields of the first issue type: identifiers, names and value types only (never a value or a default).
|
|
244
|
+
const first = types.find((x) => typeof x['id'] === 'string');
|
|
245
|
+
const f = first === undefined ? null : await pm.personOp(e, 'getJiraIssueTypeMetaWithFields', tenant, { projectIdOrKey: key, issueTypeId: first['id'] }).catch(() => null);
|
|
246
|
+
return {
|
|
247
|
+
issueTypes: types.map((x) => trackerLabel(x['name'], '?')),
|
|
248
|
+
states: st !== null && st.ok ? names(payload(st.result), 'values', 'statuses').map((x) => ({ name: trackerLabel(x['name'], '?'), category: cat(x['statusCategory']) })) : [],
|
|
249
|
+
fields: f !== null && f.ok
|
|
250
|
+
? names(payload(f.result), 'fields', 'values').map((x) => ({ id: trackerLabel(x['fieldId'] ?? x['key'] ?? x['id'], '?'), name: trackerLabel(x['name'], '?'), type: isObj(x['schema']) ? trackerLabel(x['schema']['type'], '?') : null }))
|
|
251
|
+
: [],
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/** Every link of every PM entry, as stored, with its entry and tracker. */
|
|
255
|
+
function allLinks(entries) {
|
|
256
|
+
const out = [];
|
|
257
|
+
for (const e of entries)
|
|
258
|
+
for (const t of e.trackers)
|
|
259
|
+
for (const l of t.links)
|
|
260
|
+
out.push({ e, t, l });
|
|
261
|
+
return out;
|
|
262
|
+
}
|
|
263
|
+
export function registerTrackerRoutes(app, deps) {
|
|
264
|
+
const projection = deps.projection ?? PROJECTION_UNKNOWN;
|
|
265
|
+
const view = (x) => trackerLinkView({ id: x.e.id, name: x.e.name, system: x.e.system }, x.t, x.l, projection);
|
|
266
|
+
const entries = async () => pmEntriesOf(await deps.store.read());
|
|
267
|
+
app.get(`${V}/tracker-links`, { config: { manifest: { responseType: 'TrackerLinksResponse', statusCodes: [200, 400, 403, 503] } } }, async (req, reply) => {
|
|
268
|
+
const actor = deps.actorOf(req);
|
|
269
|
+
if (!isHuman(actor))
|
|
270
|
+
return humanOnly(reply, actor);
|
|
271
|
+
const q = ListQuery.safeParse(req.query ?? {});
|
|
272
|
+
if (!q.success || (q.data.project === undefined && q.data.repo === undefined))
|
|
273
|
+
return reply.code(400).send({ error: 'name ?project=<id>, ?repo=<id>, or both', code: 'bad_request' });
|
|
274
|
+
if (deps.store === undefined)
|
|
275
|
+
return reply.code(503).send({ error: 'the connector registry is not available on this daemon', code: 'registry_unavailable' });
|
|
276
|
+
let es;
|
|
277
|
+
try {
|
|
278
|
+
es = await entries();
|
|
279
|
+
}
|
|
280
|
+
catch (err) {
|
|
281
|
+
if (err instanceof McpRegistryCorruptError)
|
|
282
|
+
return reply.code(503).send({ error: err.message, code: 'registry_corrupt' });
|
|
283
|
+
throw err;
|
|
284
|
+
}
|
|
285
|
+
const { project, repo } = q.data;
|
|
286
|
+
const all = allLinks(es);
|
|
287
|
+
const own = (t) => (project !== undefined ? t.kind === 'project' && t.id === project : t.kind === 'repo' && t.id === repo);
|
|
288
|
+
const links = all.filter((x) => own(x.l.target)).map(view);
|
|
289
|
+
const viaRepos = [];
|
|
290
|
+
const projects = [];
|
|
291
|
+
const agents = [];
|
|
292
|
+
if (project !== undefined) {
|
|
293
|
+
const repos = new Set();
|
|
294
|
+
try {
|
|
295
|
+
for (const r of await deps.projects.repos(project))
|
|
296
|
+
repos.add(r);
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
// a membership read that fails shows the project's own links only
|
|
300
|
+
}
|
|
301
|
+
if (repo !== undefined)
|
|
302
|
+
repos.add(repo);
|
|
303
|
+
for (const x of all)
|
|
304
|
+
if (x.l.target.kind === 'repo' && repos.has(x.l.target.id))
|
|
305
|
+
viaRepos.push({ ...view(x), viaRepo: x.l.target.id });
|
|
306
|
+
const named = new Set([...links, ...viaRepos].map((l) => l.source));
|
|
307
|
+
for (const e of es.filter((x) => named.has(x.name))) {
|
|
308
|
+
const src = { enabled: e.enabled, queryable: true };
|
|
309
|
+
agents.push({ source: e.name, see: agentMay(e.access, src, project, 'see'), query: agentMay(e.access, src, project, 'query') });
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else if (repo !== undefined) {
|
|
313
|
+
try {
|
|
314
|
+
for (const id of await deps.projects.ofRepo(repo)) {
|
|
315
|
+
const p = await deps.projects.get(id).catch(() => null);
|
|
316
|
+
if (p !== null)
|
|
317
|
+
projects.push({ id: p.id, name: p.name });
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
// the reverse read is unavailable: the card says nothing about reach
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const body = { target: { ...(project !== undefined ? { project } : {}), ...(repo !== undefined ? { repo } : {}) }, links, viaRepos, projects, agents };
|
|
325
|
+
return body;
|
|
326
|
+
});
|
|
327
|
+
// §6 step 1: the issues of a launch's tracker set, for "Start a job from an issue" (a person's live read, bound).
|
|
328
|
+
app.get(`${V}/tracker-links/issues`, { config: { manifest: { responseType: 'TrackerIssuesResponse', statusCodes: [200, 400, 403, 503] } } }, async (req, reply) => {
|
|
329
|
+
const actor = deps.actorOf(req);
|
|
330
|
+
// A live read with the source's credential, like the picker and the link lookup: a human operator's.
|
|
331
|
+
if (!isHumanOperator(actor))
|
|
332
|
+
return humanOnly(reply, actor);
|
|
333
|
+
const q = IssuesQuery.safeParse(req.query ?? {});
|
|
334
|
+
if (!q.success || (q.data.project === undefined && q.data.repo === undefined))
|
|
335
|
+
return reply.code(400).send({ error: 'name ?project=<id>, ?repo=<id>, or both', code: 'bad_request' });
|
|
336
|
+
if (deps.store === undefined || deps.pm === undefined)
|
|
337
|
+
return reply.code(503).send({ error: 'the connector registry is not available on this daemon', code: 'registry_unavailable' });
|
|
338
|
+
const pm = deps.pm;
|
|
339
|
+
const es = await entries();
|
|
340
|
+
const set = await pm.trackerSet({ projectId: q.data.project ?? null, repoId: q.data.repo ?? null }, es);
|
|
341
|
+
const text = (q.data.q ?? '').replace(/[^\w\s.#-]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
342
|
+
const out = [];
|
|
343
|
+
for (const t of set.slice(0, 10)) {
|
|
344
|
+
const e = es.find((x) => x.id === t.sourceId);
|
|
345
|
+
const row = {
|
|
346
|
+
trackerId: t.trackerId,
|
|
347
|
+
source: t.source,
|
|
348
|
+
system: t.system,
|
|
349
|
+
tenant: t.tenant,
|
|
350
|
+
key: t.key,
|
|
351
|
+
label: t.label,
|
|
352
|
+
...(t.tenantLabel !== null ? { tenantLabel: t.tenantLabel } : {}),
|
|
353
|
+
via: t.via.find((v) => v.kind === 'project') ?? t.via[0],
|
|
354
|
+
issues: [],
|
|
355
|
+
};
|
|
356
|
+
out.push(row);
|
|
357
|
+
if (!agentMay(e.access, { enabled: e.enabled, queryable: true }, q.data.project ?? null, 'query')) {
|
|
358
|
+
row.error = 'query_off';
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
const tool = e.system === 'jira' ? 'searchJiraIssuesUsingJql' : 'search_issues';
|
|
362
|
+
const stored = e.record.tools.find((x) => x.name === tool && x.present);
|
|
363
|
+
const binding = stored === undefined ? null : bindingInForce(e.system, stored);
|
|
364
|
+
if (binding === null) {
|
|
365
|
+
row.error = 'tool_unbound';
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
const [owner, repo] = t.key.split('/');
|
|
369
|
+
const args = e.system === 'jira'
|
|
370
|
+
? { cloudId: t.tenant, jql: `${text !== '' ? `text ~ "${text}" ` : ''}ORDER BY updated DESC`, maxResults: 20 }
|
|
371
|
+
: { query: `${text} is:issue is:open`.trim(), owner, repo, perPage: 20 };
|
|
372
|
+
const prepared = binding.bindArgs(args, [{ trackerId: t.trackerId, tenant: t.tenant, key: t.key, siteHost: t.siteHost }]);
|
|
373
|
+
if (!prepared.ok) {
|
|
374
|
+
row.error = prepared.code;
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
const r = await pm.vendorRead(e, tool, prepared.args, 'person');
|
|
378
|
+
const p = r.ok ? binding.project(r.result, prepared, await projectOptsVia(pm, e, r.credential)) : null;
|
|
379
|
+
if (p === null || !p.ok) {
|
|
380
|
+
row.error = 'unavailable';
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
// A key two trackers of this set share is qualified, so the reference a launch takes is never ambiguous.
|
|
384
|
+
const shared = e.system === 'jira' && set.filter((x) => x.system === 'jira' && x.key === t.key).length > 1;
|
|
385
|
+
row.issues = p.items.map((i) => ({
|
|
386
|
+
key: i.ref,
|
|
387
|
+
ref: shared ? `${t.source}@${t.tenant}:${i.ref}` : i.ref,
|
|
388
|
+
title: String((e.system === 'jira' ? i.value['summary'] : i.value['title']) ?? ''),
|
|
389
|
+
state: typeof (e.system === 'jira' ? i.value['status'] : i.value['state']) === 'string' ? String(e.system === 'jira' ? i.value['status'] : i.value['state']) : null,
|
|
390
|
+
}));
|
|
391
|
+
}
|
|
392
|
+
const body = { trackers: out };
|
|
393
|
+
return body;
|
|
394
|
+
});
|
|
395
|
+
app.post(`${V}/tracker-links`, { config: { manifest: { requestType: 'CreateTrackerLinkBody', responseType: 'TrackerLink', statusCodes: [200, 201, 400, 403, 404, 409, 422, 503] } } }, async (req, reply) => {
|
|
396
|
+
const actor = deps.actorOf(req);
|
|
397
|
+
if (!isHumanOperator(actor))
|
|
398
|
+
return humanOnly(reply, actor);
|
|
399
|
+
const parsed = CreateTrackerLinkSchema.safeParse(req.body);
|
|
400
|
+
if (!parsed.success)
|
|
401
|
+
return reply.code(400).send({ error: parsed.error.issues.map((i) => `${i.path.join('.') || 'body'}: ${i.message}`).join('; '), code: 'bad_request' });
|
|
402
|
+
if (deps.store === undefined || deps.pm === undefined)
|
|
403
|
+
return reply.code(503).send({ error: 'the connector registry is not available on this daemon', code: 'registry_unavailable' });
|
|
404
|
+
const b = parsed.data;
|
|
405
|
+
if (!MCP_SERVER_NAME_RE.test(b.source))
|
|
406
|
+
return reply.code(404).send({ error: `no source named ${b.source}`, code: 'source_not_found' });
|
|
407
|
+
const file = normalizeRegistryFile(await deps.store.read());
|
|
408
|
+
const rec = file.servers.find((s) => s.name === b.source);
|
|
409
|
+
if (rec === undefined)
|
|
410
|
+
return reply.code(404).send({ error: `no source named ${b.source}`, code: 'source_not_found' });
|
|
411
|
+
const e = pmEntriesOf(file).find((x) => x.name === b.source);
|
|
412
|
+
if (e === undefined)
|
|
413
|
+
return reply.code(409).send({ error: `${b.source} is not a project-management source`, code: 'not_a_tracker' });
|
|
414
|
+
if (b.target.kind === 'project') {
|
|
415
|
+
if (b.target.id === DEFAULT_PROJECT_ID)
|
|
416
|
+
return reply.code(409).send({ error: 'trackers link to a real project, not the synthesised Unfiled one', code: 'default_project' });
|
|
417
|
+
const p = await deps.projects.get(b.target.id).catch(() => null);
|
|
418
|
+
if (p === null)
|
|
419
|
+
return reply.code(404).send({ error: `no project ${b.target.id}`, code: 'project_not_found' });
|
|
420
|
+
if (p.status === 'archived')
|
|
421
|
+
return reply.code(409).send({ error: `${p.name} is archived`, code: 'project_archived' });
|
|
422
|
+
}
|
|
423
|
+
else if (!(await deps.projects.allRepos()).includes(b.target.id)) {
|
|
424
|
+
return reply.code(404).send({ error: `no repo ${b.target.id}`, code: 'repo_not_found' });
|
|
425
|
+
}
|
|
426
|
+
const found = await lookupTracker(deps.pm, e, b.tenant, b.key);
|
|
427
|
+
if (!found.ok)
|
|
428
|
+
return reply.code(found.status).send({ error: found.reason, code: found.code, ...(found.cause !== undefined ? { cause: found.cause } : {}) });
|
|
429
|
+
const structure = await readStructure(deps.pm, e, b.tenant, found.key);
|
|
430
|
+
const trackerId = trackerIdOf(e.id, b.tenant, found.key);
|
|
431
|
+
const target = b.target.kind === 'project' ? { kind: 'project', id: b.target.id } : { kind: 'repo', id: b.target.id };
|
|
432
|
+
const linkId = trackerLinkIdOf(trackerId, target);
|
|
433
|
+
const stamp = new Date().toISOString();
|
|
434
|
+
let out;
|
|
435
|
+
try {
|
|
436
|
+
out = await deps.store.mutate((f) => {
|
|
437
|
+
const s = f.servers.find((x) => x.name === b.source);
|
|
438
|
+
// Saved again as another entry (a new id), or re-pointed at another server, since the lookup: nothing is linked.
|
|
439
|
+
if (s === undefined || s.id !== e.id || pmDescriptorHash(configOf(s)) !== pmDescriptorHash(configOf(e.record)))
|
|
440
|
+
return { gone: true };
|
|
441
|
+
const trackers = trackersOf(s);
|
|
442
|
+
let t = trackers.find((x) => x.id === trackerId);
|
|
443
|
+
if (t === undefined) {
|
|
444
|
+
t = { id: trackerId, tenant: b.tenant, tenantLabel: found.tenantLabel, siteHost: found.siteHost ?? null, key: found.key, label: found.label, links: [], structure };
|
|
445
|
+
trackers.push(t);
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
t.structure = structure;
|
|
449
|
+
t.label = found.label;
|
|
450
|
+
if (found.tenantLabel !== null)
|
|
451
|
+
t.tenantLabel = found.tenantLabel;
|
|
452
|
+
if (found.siteHost != null)
|
|
453
|
+
t.siteHost = found.siteHost;
|
|
454
|
+
}
|
|
455
|
+
// estate bounds a document's links (200): one tracker holds at most TRACKER_LINKS_MAX.
|
|
456
|
+
if (!t.links.some((l) => l.id === linkId) && t.links.length >= TRACKER_LINKS_MAX)
|
|
457
|
+
return { full: true };
|
|
458
|
+
let link = t.links.find((l) => l.id === linkId);
|
|
459
|
+
const created = link === undefined;
|
|
460
|
+
if (link === undefined) {
|
|
461
|
+
link = { id: linkId, target, linkedAt: stamp, linkedBy: actor.id };
|
|
462
|
+
t.links.push(link);
|
|
463
|
+
}
|
|
464
|
+
s.trackers = trackers;
|
|
465
|
+
if (s.retired !== undefined)
|
|
466
|
+
s.retired = s.retired.filter((r) => r.id !== trackerId);
|
|
467
|
+
s.updatedAt = stamp;
|
|
468
|
+
return { created, tracker: structuredClone(t), link: structuredClone(link) };
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
catch (err) {
|
|
472
|
+
if (err instanceof McpRegistryCorruptError)
|
|
473
|
+
return reply.code(503).send({ error: err.message, code: 'registry_corrupt' });
|
|
474
|
+
throw err;
|
|
475
|
+
}
|
|
476
|
+
if ('gone' in out)
|
|
477
|
+
return reply.code(409).send({ error: `${b.source} was removed or saved again while linking; nothing was linked: try again`, code: 'source_changed' });
|
|
478
|
+
if ('full' in out)
|
|
479
|
+
return reply.code(409).send({ error: `${found.key} already has ${TRACKER_LINKS_MAX} links`, code: 'too_many_links' });
|
|
480
|
+
if (out.created)
|
|
481
|
+
deps.audit.record('knowledge.source.tracker_linked', actor, { detail: { source: b.source, tenant: b.tenant, key: found.key, target } });
|
|
482
|
+
// Projected either way: a link made again may carry a new label.
|
|
483
|
+
deps.changed?.(b.source, trackerId);
|
|
484
|
+
return reply.code(out.created ? 201 : 200).send(view({ e, t: out.tracker, l: out.link }));
|
|
485
|
+
});
|
|
486
|
+
app.delete(`${V}/tracker-links/:id`, { config: { manifest: { statusCodes: [204, 403, 404, 503] } } }, async (req, reply) => {
|
|
487
|
+
const actor = deps.actorOf(req);
|
|
488
|
+
if (!isHumanOperator(actor))
|
|
489
|
+
return humanOnly(reply, actor);
|
|
490
|
+
if (deps.store === undefined)
|
|
491
|
+
return reply.code(503).send({ error: 'the connector registry is not available on this daemon', code: 'registry_unavailable' });
|
|
492
|
+
const id = req.params.id;
|
|
493
|
+
if (!/^tl_[0-9a-f]{16}$/.test(id))
|
|
494
|
+
return reply.code(404).send({ error: `no tracker link ${id}`, code: 'not_found' });
|
|
495
|
+
const stamp = new Date().toISOString();
|
|
496
|
+
let out;
|
|
497
|
+
try {
|
|
498
|
+
out = await deps.store.mutate((f) => {
|
|
499
|
+
for (const s of normalizeRegistryFile(f).servers) {
|
|
500
|
+
const trackers = trackersOf(s);
|
|
501
|
+
for (const t of trackers) {
|
|
502
|
+
const l = t.links.find((x) => x.id === id);
|
|
503
|
+
if (l === undefined)
|
|
504
|
+
continue;
|
|
505
|
+
t.links = t.links.filter((x) => x.id !== id);
|
|
506
|
+
const kept = trackers.filter((x) => x.links.length > 0);
|
|
507
|
+
s.trackers = kept;
|
|
508
|
+
// The tracker's last link: it is retired until estate takes its empty generation (its documents go).
|
|
509
|
+
if (t.links.length === 0)
|
|
510
|
+
s.retired = [...(s.retired ?? []).filter((r) => r.id !== t.id), { id: t.id, since: stamp }];
|
|
511
|
+
s.updatedAt = stamp;
|
|
512
|
+
return { source: s.name, tenant: t.tenant, key: t.key, target: l.target, trackerId: t.id };
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return null;
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
catch (err) {
|
|
519
|
+
if (err instanceof McpRegistryCorruptError)
|
|
520
|
+
return reply.code(503).send({ error: err.message, code: 'registry_corrupt' });
|
|
521
|
+
throw err;
|
|
522
|
+
}
|
|
523
|
+
if (out === null)
|
|
524
|
+
return reply.code(404).send({ error: `no tracker link ${id}`, code: 'not_found' });
|
|
525
|
+
deps.audit.record('knowledge.source.tracker_unlinked', actor, { detail: { source: out.source, tenant: out.tenant, key: out.key, target: out.target } });
|
|
526
|
+
deps.changed?.(out.source, out.trackerId);
|
|
527
|
+
return reply.code(204).send();
|
|
528
|
+
});
|
|
529
|
+
app.get(`${V}/sources/:name/trackers`, { config: { manifest: { responseType: 'SourceTrackersResponse', statusCodes: [200, 400, 403, 404, 409, 503] } } }, async (req, reply) => {
|
|
530
|
+
const actor = deps.actorOf(req);
|
|
531
|
+
if (!isHumanOperator(actor))
|
|
532
|
+
return humanOnly(reply, actor);
|
|
533
|
+
const q = SourceTrackersQuery.safeParse(req.query ?? {});
|
|
534
|
+
const cursor = q.success ? dec(q.data.cursor) : null;
|
|
535
|
+
if (!q.success || cursor === null)
|
|
536
|
+
return reply.code(400).send({ error: 'q is at most 200 characters; cursor is a cursor this route answered', code: 'bad_request' });
|
|
537
|
+
if (deps.store === undefined || deps.pm === undefined)
|
|
538
|
+
return reply.code(503).send({ error: 'the connector registry is not available on this daemon', code: 'registry_unavailable' });
|
|
539
|
+
if (!MCP_SERVER_NAME_RE.test(req.params.name))
|
|
540
|
+
return reply.code(404).send({ error: `no source named ${req.params.name}`, code: 'source_not_found' });
|
|
541
|
+
const file = normalizeRegistryFile(await deps.store.read());
|
|
542
|
+
if (!file.servers.some((s) => s.name === req.params.name))
|
|
543
|
+
return reply.code(404).send({ error: `no source named ${req.params.name}`, code: 'source_not_found' });
|
|
544
|
+
const e = pmEntriesOf(file).find((x) => x.name === req.params.name);
|
|
545
|
+
if (e === undefined)
|
|
546
|
+
return reply.code(409).send({ error: `${req.params.name} is not a project-management source`, code: 'not_a_tracker' });
|
|
547
|
+
const page = await listSourceTrackers(deps.pm, e, q.data.q ?? '', cursor, q.data.tenant ?? null);
|
|
548
|
+
// `cause` is the lister's own class (vendor_error, unknown_shape, unavailable, secret_missing, …): the reason names it.
|
|
549
|
+
if (!page.ok)
|
|
550
|
+
return reply.code(503).send({ error: page.reason, code: 'source_unavailable', cause: page.code });
|
|
551
|
+
const links = allLinks([e]);
|
|
552
|
+
const body = {
|
|
553
|
+
name: e.name,
|
|
554
|
+
trackers: page.rows.map((r) => ({
|
|
555
|
+
...r,
|
|
556
|
+
links: links.filter((x) => x.t.tenant === r.tenant && x.t.key.toLowerCase() === r.key.toLowerCase()).map(view),
|
|
557
|
+
})),
|
|
558
|
+
next: page.next,
|
|
559
|
+
};
|
|
560
|
+
return body;
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
//# sourceMappingURL=routes.js.map
|