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
|
@@ -0,0 +1,970 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource bindings with response projectors (DES-PM-001 §3.1): what keeps every agent call to a PM system's own MCP
|
|
3
|
+
* server inside the unit's linked set L(u, S), whatever the credential can reach.
|
|
4
|
+
*
|
|
5
|
+
* One credential usually reads every project on a Jira site, and often several sites; a GitHub token reads every repo
|
|
6
|
+
* its owner can. So a source-level switch is not enough. For each PM tool crew knows, a binding says:
|
|
7
|
+
*
|
|
8
|
+
* - `bindArgs`: which arguments name the tenant and the project or repo. The gate SETS the tenant itself (Jira's
|
|
9
|
+
* `cloudId`; GitHub's host is the server's), and REWRITES or REFUSES the project argument so it stays inside L:
|
|
10
|
+
* a key must be a linked key, a repo a linked repo; a JQL query gets `project in (<linked keys>) AND (<jql>)`; a
|
|
11
|
+
* GitHub issue search gets the linked `repo:` qualifiers when it names none, and is refused when it names another.
|
|
12
|
+
* Arguments a binding does not name are dropped, never sent (an allowlist). JQL functions such as
|
|
13
|
+
* `projectsLeadByUser()` cannot be judged without a full parser, so the rewrite is defence in depth only.
|
|
14
|
+
* - `project`: the RESPONSE PROJECTOR, which is the boundary. The answer is rebuilt from admitted items only: an item
|
|
15
|
+
* whose identity (the Jira issue key's project on the tenant crew set; a GitHub `html_url`'s owner/repo) is outside
|
|
16
|
+
* L is dropped; totals are recomputed from what was admitted, pagination is kept only when nothing was dropped,
|
|
17
|
+
* every other field is left out unless the binding keeps it, and an answer whose shape the projector does not know
|
|
18
|
+
* is refused. Text and structured copies are never passed through: the one answer is built from the items.
|
|
19
|
+
*
|
|
20
|
+
* A tool with no binding here (Rovo `search`, `executeRead`, Confluence, Teamwork Graph, every write, `get_me`, …) is
|
|
21
|
+
* unavailable to agents. Jira's account metadata (`atlassianUserInfo`, `getAccessibleAtlassianResources`) is bound as
|
|
22
|
+
* `structure`: the account id, and the sites of the linked trackers only.
|
|
23
|
+
* Vendor text (titles, bodies, comments, labels) is untrusted: it rides inside the gate's envelope as data.
|
|
24
|
+
*/
|
|
25
|
+
/** Bumped when a binding's rules change: stored bindings of an older version are no longer in force. */
|
|
26
|
+
export const BINDING_POLICY_VERSION = 1;
|
|
27
|
+
/** A unit asks for at most this many issues per call. */
|
|
28
|
+
export const PM_PAGE_MAX = 50;
|
|
29
|
+
/** An issue body, a description or a comment is cut to this many characters. */
|
|
30
|
+
export const PM_TEXT_MAX = 6_000;
|
|
31
|
+
/** At most this many comments per issue are kept. */
|
|
32
|
+
export const PM_COMMENTS_MAX = 20;
|
|
33
|
+
/** Whether an item without an address may be admitted on the tenant crew bound (both conditions of {@link ProjectOpts}). */
|
|
34
|
+
const tenantProves = (opts, tenant) => opts?.vendorBindsTenant === true && typeof opts.soleSite === 'string' && opts.soleSite === tenant;
|
|
35
|
+
/** The Atlassian vendor server's origin: the only one whose answers may prove a site by the `cloudId` crew bound. */
|
|
36
|
+
export const ATLASSIAN_MCP_ORIGIN = 'https://mcp.atlassian.com';
|
|
37
|
+
/** Whether an entry's server is Atlassian's own remote MCP server (an https `mcp-http` entry on its origin). */
|
|
38
|
+
export function vendorBindsTenant(config, system) {
|
|
39
|
+
if (system !== 'jira' || config.kind !== 'mcp-http' || typeof config.url !== 'string')
|
|
40
|
+
return false;
|
|
41
|
+
try {
|
|
42
|
+
const u = new URL(config.url);
|
|
43
|
+
return u.origin === ATLASSIAN_MCP_ORIGIN && u.username === '' && u.password === '';
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
50
|
+
const str = (v) => (typeof v === 'string' && v !== '' ? v : null);
|
|
51
|
+
const refuse = (code, reason) => ({ ok: false, code, reason });
|
|
52
|
+
/** Vendor text as kept: control characters out (newlines stay), cut to `max`. */
|
|
53
|
+
export function vendorText(v, max = PM_TEXT_MAX) {
|
|
54
|
+
if (typeof v !== 'string')
|
|
55
|
+
return null;
|
|
56
|
+
const t = v.replace(/\r\n?/g, '\n').replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g, ' ');
|
|
57
|
+
return t.length <= max ? t : `${t.slice(0, max)}… (cut at ${max} characters)`;
|
|
58
|
+
}
|
|
59
|
+
/** The text of an Atlassian document (ADF): its `text` nodes in order, paragraphs on their own lines. No attrs, no URLs. */
|
|
60
|
+
export function adfText(doc, max = PM_TEXT_MAX) {
|
|
61
|
+
if (typeof doc === 'string')
|
|
62
|
+
return vendorText(doc, max);
|
|
63
|
+
if (!isObj(doc))
|
|
64
|
+
return null;
|
|
65
|
+
const out = [];
|
|
66
|
+
let len = 0;
|
|
67
|
+
const walk = (n, depth) => {
|
|
68
|
+
if (len > max || depth > 64 || !isObj(n))
|
|
69
|
+
return;
|
|
70
|
+
if (n['type'] === 'text' && typeof n['text'] === 'string') {
|
|
71
|
+
out.push(n['text']);
|
|
72
|
+
len += n['text'].length;
|
|
73
|
+
}
|
|
74
|
+
if (n['type'] === 'hardBreak')
|
|
75
|
+
out.push('\n');
|
|
76
|
+
if (Array.isArray(n['content'])) {
|
|
77
|
+
for (const c of n['content']) {
|
|
78
|
+
if (len > max)
|
|
79
|
+
break;
|
|
80
|
+
walk(c, depth + 1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (n['type'] === 'paragraph' || n['type'] === 'heading' || n['type'] === 'listItem')
|
|
84
|
+
out.push('\n');
|
|
85
|
+
};
|
|
86
|
+
walk(doc, 0);
|
|
87
|
+
return vendorText(out.join('').replace(/\n{3,}/g, '\n\n').trim(), max);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The Atlassian v2 server wraps an answer as `{data: …}`, sometimes with metadata beside it (`appliedContentFormat`,
|
|
91
|
+
* `context`): the payload is what `data` holds. Anything else is its own payload. Siblings are dropped, never read:
|
|
92
|
+
* every projector rebuilds its answer from the items it admits.
|
|
93
|
+
*/
|
|
94
|
+
export function unwrapData(p) {
|
|
95
|
+
if (!isObj(p) || !('data' in p) || isErrorEnvelope(p))
|
|
96
|
+
return p;
|
|
97
|
+
return isObj(p['data']) || Array.isArray(p['data']) ? p['data'] : p;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The field names an outline may print: the schema of the answers crew reads (MCP, Atlassian v2 and REST, GitHub). Any
|
|
101
|
+
* other key may be vendor data (a custom field's label, a customer's name, an issue key), so it is only counted.
|
|
102
|
+
*/
|
|
103
|
+
const KNOWN_KEYS = new Set([
|
|
104
|
+
'content', 'type', 'text', 'isError', 'structuredContent', 'data', 'error', 'message', 'statusCode', 'status', 'errorMessages', 'errors', 'context', 'appliedContentFormat',
|
|
105
|
+
'resources', 'sites', 'accessibleResources', 'cloudId', 'id', 'url', 'name', 'products', 'access', 'scopes', 'avatarUrl', 'accountId', 'account_id',
|
|
106
|
+
'issues', 'nodes', 'totalCount', 'total', 'remainingCount', 'pageInfo', 'hasNextPage', 'endCursor', 'isLast', 'nextPageToken', 'startAt', 'maxResults', 'values', 'projects',
|
|
107
|
+
'key', 'self', 'webUrl', 'fields', 'summary', 'description', 'issuetype', 'priority', 'assignee', 'reporter', 'labels', 'created', 'updated', 'project', 'statusCategory', 'customFields', 'attachment', 'comment',
|
|
108
|
+
'comments', 'author', 'body', 'displayName', 'visibility', 'jsdPublic', 'parentId', 'issueKey', 'issueId', 'transitions', 'to',
|
|
109
|
+
'items', 'total_count', 'incomplete_results', 'number', 'title', 'state', 'html_url', 'user', 'login', 'full_name', 'result', 'results', 'warnings',
|
|
110
|
+
]);
|
|
111
|
+
const BLOCK_TYPES = new Set(['text', 'image', 'audio', 'resource', 'resource_link']);
|
|
112
|
+
const OUTLINE_MAX = 700;
|
|
113
|
+
const cap = (s) => (s.length <= OUTLINE_MAX ? s : `${s.slice(0, OUTLINE_MAX)}…`);
|
|
114
|
+
/**
|
|
115
|
+
* The value-free outline of a JSON value, for a diagnosis: its type, its plain field names and array lengths, a few
|
|
116
|
+
* levels deep. Never a value: a string is `string`, a number `number`, and a key that is not a plain field name is
|
|
117
|
+
* only counted.
|
|
118
|
+
*/
|
|
119
|
+
export function outlineOf(v, depth = 3) {
|
|
120
|
+
return cap(outline(v, depth));
|
|
121
|
+
}
|
|
122
|
+
function outline(v, depth) {
|
|
123
|
+
if (v === null)
|
|
124
|
+
return 'null';
|
|
125
|
+
if (Array.isArray(v))
|
|
126
|
+
return `array(${v.length})${v.length > 0 && depth > 0 ? `[${outline(v[0], depth - 1)}]` : ''}`;
|
|
127
|
+
if (typeof v !== 'object')
|
|
128
|
+
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' ? typeof v : 'other';
|
|
129
|
+
const keys = Object.keys(v);
|
|
130
|
+
const shown = keys.filter((k) => KNOWN_KEYS.has(k)).slice(0, 12);
|
|
131
|
+
const more = keys.length - shown.length;
|
|
132
|
+
const parts = shown.map((k) => (depth > 0 ? `${k}:${outline(v[k], depth - 1)}` : k));
|
|
133
|
+
if (more > 0)
|
|
134
|
+
parts.push(`+${more} other key${more === 1 ? '' : 's'}`);
|
|
135
|
+
// Bounded as it is built: a wide tree stops growing once the outline is longer than any reason shows.
|
|
136
|
+
const out = `object{${parts.join(',')}}`;
|
|
137
|
+
return out.length <= OUTLINE_MAX * 2 ? out : `${out.slice(0, OUTLINE_MAX * 2)}…}`;
|
|
138
|
+
}
|
|
139
|
+
/** The value-free outline of a whole tool result: its error flag, its content blocks (type; JSON outline or text length). */
|
|
140
|
+
export function resultOutline(result) {
|
|
141
|
+
if (!isObj(result))
|
|
142
|
+
return `result: ${outlineOf(result, 0)}`;
|
|
143
|
+
const parts = [];
|
|
144
|
+
if (result['isError'] !== undefined)
|
|
145
|
+
parts.push(`isError ${result['isError'] === true ? 'true' : 'false'}`);
|
|
146
|
+
const content = result['content'];
|
|
147
|
+
if (!Array.isArray(content))
|
|
148
|
+
parts.push(`content ${content === undefined ? 'absent' : outlineOf(content, 0)}`);
|
|
149
|
+
else {
|
|
150
|
+
const blocks = content.slice(0, 4).map((c) => {
|
|
151
|
+
if (!isObj(c))
|
|
152
|
+
return outlineOf(c, 0);
|
|
153
|
+
const type = typeof c['type'] === 'string' && BLOCK_TYPES.has(c['type']) ? c['type'] : 'other';
|
|
154
|
+
if (type !== 'text')
|
|
155
|
+
return type;
|
|
156
|
+
const text = typeof c['text'] === 'string' ? c['text'] : null;
|
|
157
|
+
if (text === null)
|
|
158
|
+
return 'text without text';
|
|
159
|
+
try {
|
|
160
|
+
return `text JSON ${outlineOf(JSON.parse(text))}`;
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return `text, not JSON (${text.length} chars)`;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
parts.push(`content ${content.length} block${content.length === 1 ? '' : 's'}: [${blocks.join('; ')}${content.length > 4 ? '; …' : ''}]`);
|
|
167
|
+
}
|
|
168
|
+
parts.push(`structuredContent ${result['structuredContent'] === undefined ? 'absent' : 'present (not read)'}`);
|
|
169
|
+
return cap(parts.join(', '));
|
|
170
|
+
}
|
|
171
|
+
/** `{"error": true, "message", "statusCode"}` (the Atlassian server, often without `isError`) or Jira's `{errorMessages}`. */
|
|
172
|
+
function isErrorEnvelope(p) {
|
|
173
|
+
if (!isObj(p))
|
|
174
|
+
return false;
|
|
175
|
+
// An error beside data is an error: a contradictory answer is not read as a success.
|
|
176
|
+
if (p['error'] === true || isObj(p['error']))
|
|
177
|
+
return true;
|
|
178
|
+
// Jira's own error shape dominates whatever else the answer carries.
|
|
179
|
+
return Array.isArray(p['errorMessages']) && p['errorMessages'].length > 0;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The Atlassian scopes crew may repeat from an error (a fixed, vetted set): any other word of the vendor's sentence,
|
|
183
|
+
* scope-shaped or not, is not repeated.
|
|
184
|
+
*/
|
|
185
|
+
const SCOPES = new Set([
|
|
186
|
+
'read:me', 'read:account', 'offline_access', 'read:jira-work', 'write:jira-work', 'read:jira-user', 'manage:jira-project', 'manage:jira-configuration',
|
|
187
|
+
'read:jira:agent-interface', 'search:jira:agent-interface', 'write:jira:agent-interface', 'read:servicedesk-request', 'write:servicedesk-request',
|
|
188
|
+
'read:page:confluence', 'write:page:confluence', 'read:space:confluence', 'search:confluence', 'read:confluence-user', 'read:comment:confluence', 'write:comment:confluence',
|
|
189
|
+
]);
|
|
190
|
+
/**
|
|
191
|
+
* What an error answer may say: its HTTP status, and the scopes the vendor says are missing (each checked to be a
|
|
192
|
+
* scope name). The vendor's other words are not shown: they can echo a request.
|
|
193
|
+
*/
|
|
194
|
+
function vendorErrorReason(who, p) {
|
|
195
|
+
const env = isObj(p) ? p : {};
|
|
196
|
+
const raw = env['statusCode'] ?? env['status'] ?? (isObj(env['error']) ? env['error']['status'] : undefined);
|
|
197
|
+
const status = typeof raw === 'number' && Number.isInteger(raw) && raw >= 100 && raw <= 599 ? raw : null;
|
|
198
|
+
const msg = typeof env['message'] === 'string' ? env['message'] : '';
|
|
199
|
+
const m = /Insufficient scopes?\.?\s*Required:\s*([^\n]{1,300})$/i.exec(msg.trim());
|
|
200
|
+
const scopes = m === null ? [] : m[1].replace(/\.$/, '').split(/[\s,]+/).filter((x) => x !== '');
|
|
201
|
+
const named = scopes.length > 0 && scopes.length <= 10 && scopes.every((x) => SCOPES.has(x)) ? scopes : [];
|
|
202
|
+
const hint = named.length > 0
|
|
203
|
+
? `: it says the token needs the scope${named.length === 1 ? '' : 's'} ${named.join(', ')}`
|
|
204
|
+
: status === 401
|
|
205
|
+
? ': the credential was refused (check the account email and the API token, and that your organization allows API-token sign-in to its MCP server)'
|
|
206
|
+
: status === 403
|
|
207
|
+
? ': the credential is not allowed this (a scoped API token may lack a scope, or your organization has not allowed the tool)'
|
|
208
|
+
: status === 404
|
|
209
|
+
? ': not found'
|
|
210
|
+
: '';
|
|
211
|
+
return `${who} answered an error${status !== null ? ` (HTTP ${status})` : ''}${hint}; its other words are not shown`;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* The ONE payload of a tool answer: the single text block holding JSON (other blocks, and text that is not JSON, are
|
|
215
|
+
* left out, never passed on), `{data}` unwrapped. `structuredContent` is never read or passed on. An error, flagged by
|
|
216
|
+
* `isError` or answered as an error envelope, is `vendor_error` with its HTTP status; a shape no reader knows is
|
|
217
|
+
* `unknown_shape` with the answer's outline (block types, field names, array lengths; never a value).
|
|
218
|
+
*/
|
|
219
|
+
export function readPayload(result, who = 'the tracker') {
|
|
220
|
+
const content = result['content'];
|
|
221
|
+
const jsons = [];
|
|
222
|
+
if (Array.isArray(content)) {
|
|
223
|
+
for (const c of content) {
|
|
224
|
+
if (!isObj(c) || c['type'] !== 'text' || typeof c['text'] !== 'string')
|
|
225
|
+
continue;
|
|
226
|
+
try {
|
|
227
|
+
jsons.push(JSON.parse(c['text']));
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
// not JSON: left out
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (result['isError'] === true) {
|
|
235
|
+
const j = jsons.length === 1 ? jsons[0] : null;
|
|
236
|
+
const inner = unwrapData(j);
|
|
237
|
+
return refuse('vendor_error', vendorErrorReason(who, isErrorEnvelope(j) ? j : isErrorEnvelope(inner) ? inner : j));
|
|
238
|
+
}
|
|
239
|
+
if (!Array.isArray(content) || jsons.length !== 1)
|
|
240
|
+
return refuse('unknown_shape', `${who} answered a shape crew does not know (${resultOutline(result)})`);
|
|
241
|
+
const p = jsons[0];
|
|
242
|
+
if (isErrorEnvelope(p))
|
|
243
|
+
return refuse('vendor_error', vendorErrorReason(who, p));
|
|
244
|
+
const inner = unwrapData(p);
|
|
245
|
+
// An error wrapped in `data` is an error too.
|
|
246
|
+
if (inner !== p && isErrorEnvelope(inner))
|
|
247
|
+
return refuse('vendor_error', vendorErrorReason(who, inner));
|
|
248
|
+
return { ok: true, payload: inner };
|
|
249
|
+
}
|
|
250
|
+
/** {@link readPayload} for the projectors. */
|
|
251
|
+
export function payloadOf(result) {
|
|
252
|
+
return readPayload(result);
|
|
253
|
+
}
|
|
254
|
+
/** A refusal for a payload that parsed, but not as the shape `what` needs: names its outline, never a value. */
|
|
255
|
+
export function unknownShape(who, what, payload) {
|
|
256
|
+
return refuse('unknown_shape', `${who} answered ${what} in a shape crew does not know (got ${outlineOf(payload)})`);
|
|
257
|
+
}
|
|
258
|
+
// ── Jira (the Atlassian remote MCP server; tenant = the site's cloudId) ─────────────────────────────────
|
|
259
|
+
/** A Jira issue key: project key (letters, digits, `_`; Jira keys have no hyphen) and a number. */
|
|
260
|
+
export const JIRA_ISSUE_KEY = /^([A-Z][A-Z0-9_]{0,19})-([1-9][0-9]{0,9})$/;
|
|
261
|
+
/** The tenant a Jira call goes to: the `cloudId` asked for when it is a linked tenant, else the one linked tenant. */
|
|
262
|
+
function jiraTenant(args, linked, keyFilter) {
|
|
263
|
+
const pool = keyFilter === undefined ? linked : linked.filter((t) => t.key === keyFilter);
|
|
264
|
+
const tenants = [...new Set(pool.map((t) => t.tenant))];
|
|
265
|
+
const asked = str(args['cloudId']);
|
|
266
|
+
if (asked !== null) {
|
|
267
|
+
if (!tenants.includes(asked))
|
|
268
|
+
return refuse('outside_linked_set', keyFilter === undefined ? 'that Jira site is not linked to this step' : `${keyFilter} is not linked on that Jira site`);
|
|
269
|
+
return { ok: true, tenant: asked };
|
|
270
|
+
}
|
|
271
|
+
if (tenants.length === 1)
|
|
272
|
+
return { ok: true, tenant: tenants[0] };
|
|
273
|
+
if (tenants.length === 0)
|
|
274
|
+
return refuse('outside_linked_set', keyFilter === undefined ? 'no Jira project is linked to this step' : `${keyFilter} is not a Jira project linked to this step`);
|
|
275
|
+
return refuse('tenant_required', `${keyFilter ?? 'the linked projects'} are on ${tenants.length} Jira sites: pass cloudId, one of ${tenants.join(', ')}`);
|
|
276
|
+
}
|
|
277
|
+
/** The kept fields of one Jira issue (no URLs, no `self`, no site detail). A node with no `fields` keeps its own. */
|
|
278
|
+
function jiraIssueValue(issue, tenant, siteHost) {
|
|
279
|
+
const f = isObj(issue['fields']) ? issue['fields'] : issue;
|
|
280
|
+
const name = (v) => (isObj(v) ? str(v['name']) ?? str(v['displayName']) : null);
|
|
281
|
+
const status = isObj(f['status']) ? f['status'] : null;
|
|
282
|
+
const category = status !== null ? jiraCategory(status['statusCategory']) : null;
|
|
283
|
+
const commentsRaw = isObj(f['comment']) && Array.isArray(f['comment']['comments']) ? f['comment']['comments'] : [];
|
|
284
|
+
// An embedded comment is kept only when nothing it says contradicts the issue: an address on another site, or a
|
|
285
|
+
// parent issue other than this one.
|
|
286
|
+
const issueId = str(issue['id']) ?? (typeof issue['id'] === 'number' ? String(issue['id']) : null);
|
|
287
|
+
const comments = commentsRaw
|
|
288
|
+
.filter(isObj)
|
|
289
|
+
.filter((c) => jiraProof(c, tenant, siteHost) !== 'contradicted' && commentParents(c).every((x) => x === issueId || x === issue['key']))
|
|
290
|
+
.filter((c) => !jiraCommentRestricted(c))
|
|
291
|
+
.slice(-PM_COMMENTS_MAX)
|
|
292
|
+
.map((c) => ({ author: name(c['author']), created: str(c['created']), body: adfText(c['body'], 1_500) }));
|
|
293
|
+
return {
|
|
294
|
+
key: String(issue['key']),
|
|
295
|
+
summary: vendorText(f['summary'], 400),
|
|
296
|
+
status: name(f['status']),
|
|
297
|
+
statusCategory: category,
|
|
298
|
+
issuetype: name(f['issuetype']),
|
|
299
|
+
priority: name(f['priority']),
|
|
300
|
+
assignee: name(f['assignee']),
|
|
301
|
+
reporter: name(f['reporter']),
|
|
302
|
+
labels: Array.isArray(f['labels']) ? f['labels'].filter((l) => typeof l === 'string').slice(0, 20) : [],
|
|
303
|
+
created: str(f['created']),
|
|
304
|
+
updated: str(f['updated']),
|
|
305
|
+
description: adfText(f['description']),
|
|
306
|
+
...(comments.length > 0 ? { comments } : {}),
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/** A Jira status category (`{key: 'new'}`, or the key alone) as todo/doing/done. */
|
|
310
|
+
export function jiraCategory(v) {
|
|
311
|
+
const k = String(isObj(v) ? (v['key'] ?? '') : (v ?? '')).toLowerCase();
|
|
312
|
+
return k === 'new' || k === 'todo' || k === 'to_do' ? 'todo' : k === 'indeterminate' || k === 'in_progress' ? 'doing' : k === 'done' ? 'done' : null;
|
|
313
|
+
}
|
|
314
|
+
/** A comment Jira limits to a role or group, or a JSM internal note: withheld (the token's owner sees it; a project's agents may not). */
|
|
315
|
+
function jiraCommentRestricted(c) {
|
|
316
|
+
return (isObj(c['visibility']) && Object.keys(c['visibility']).length > 0) || c['jsdPublic'] === false;
|
|
317
|
+
}
|
|
318
|
+
/** The issue an address names: `/browse/<KEY>`, or `/issue/<id or key>` (a REST URL), from the parsed path. */
|
|
319
|
+
function addressIssue(a) {
|
|
320
|
+
try {
|
|
321
|
+
const path = new URL(a).pathname;
|
|
322
|
+
return /\/browse\/([A-Z][A-Z0-9_]{0,19}-[1-9][0-9]{0,9})\/?$/.exec(path)?.[1] ?? /\/issue\/([A-Za-z0-9_-]{1,40})(?:\/|$)/.exec(path)?.[1] ?? null;
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/** Every parent issue a comment names (its `self` path, `issueId`, `issueKey`): all must be the issue asked for. */
|
|
329
|
+
function commentParents(c) {
|
|
330
|
+
const out = [];
|
|
331
|
+
if (typeof c['self'] === 'string') {
|
|
332
|
+
const m = addressIssue(c['self']);
|
|
333
|
+
if (m !== null)
|
|
334
|
+
out.push(m);
|
|
335
|
+
}
|
|
336
|
+
for (const k of ['issueId', 'issueKey'])
|
|
337
|
+
if (typeof c[k] === 'string' || typeof c[k] === 'number')
|
|
338
|
+
out.push(String(c[k]));
|
|
339
|
+
return out;
|
|
340
|
+
}
|
|
341
|
+
/** An address on a Jira answer: `self` (a REST URL) and `webUrl` (a browse URL), when the answer carries them. */
|
|
342
|
+
function jiraAddresses(x) {
|
|
343
|
+
return [x['self'], x['webUrl']].filter((v) => v !== undefined && v !== null).map((v) => (typeof v === 'string' ? v : ''));
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Whether an answer's own addresses PROVE it is on the site crew called: the gateway form names the cloudId
|
|
347
|
+
* (`https://api.atlassian.com/ex/jira/<cloudId>/…`), the site form the site's host confirmed at link time
|
|
348
|
+
* (`https://acme.atlassian.net/…`). `absent`: it carries none; `contradicted`: one names another site or cannot be judged.
|
|
349
|
+
*/
|
|
350
|
+
export function jiraProof(x, tenant, siteHost) {
|
|
351
|
+
const addrs = jiraAddresses(x);
|
|
352
|
+
if (addrs.length === 0)
|
|
353
|
+
return 'absent';
|
|
354
|
+
for (const a of addrs) {
|
|
355
|
+
// Judged on the parsed URL; a path with dot segments or encoded separators cannot be judged.
|
|
356
|
+
if (/%2e|%2f|%5c|\\|\/\.\.?(?:\/|$)/i.test(a))
|
|
357
|
+
return 'contradicted';
|
|
358
|
+
let u;
|
|
359
|
+
try {
|
|
360
|
+
u = new URL(a);
|
|
361
|
+
}
|
|
362
|
+
catch {
|
|
363
|
+
return 'contradicted';
|
|
364
|
+
}
|
|
365
|
+
if (u.protocol !== 'https:' || u.username !== '' || u.password !== '')
|
|
366
|
+
return 'contradicted';
|
|
367
|
+
const host = u.host.toLowerCase();
|
|
368
|
+
if (host === 'api.atlassian.com') {
|
|
369
|
+
const gw = /^\/ex\/jira\/([A-Za-z0-9-]{1,64})\//.exec(u.pathname);
|
|
370
|
+
if (gw === null || gw[1] !== tenant)
|
|
371
|
+
return 'contradicted';
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
if (siteHost == null || host !== siteHost.toLowerCase())
|
|
375
|
+
return 'contradicted';
|
|
376
|
+
}
|
|
377
|
+
return 'proved';
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Whether a Jira issue answered for `tenant` is inside the linked set; its tracker when it is. The key's project must be
|
|
381
|
+
* a linked key on `tenant` (and the issue's own `fields.project`, when named, the same project). Then its SITE must be
|
|
382
|
+
* proved, one of two ways (DES-PM-001 §3.1, revised for the Atlassian v2 server, which answers no `self`):
|
|
383
|
+
*
|
|
384
|
+
* - its own address (`self`, `webUrl`) names the site, as {@link jiraProof} reads it; an address that names another
|
|
385
|
+
* site, or that cannot be judged, is never admitted, whatever else holds;
|
|
386
|
+
* - it carries NO address, and `bound` holds: the call went to Atlassian's own server with the `cloudId` crew set from
|
|
387
|
+
* the linked tracker, the credential reaches that ONE site and no other (read from the vendor just now: so a server
|
|
388
|
+
* that ran the call on another site has no other site to have read), and the whole answer carries no address either
|
|
389
|
+
* (a server that addresses some items and not others is not trusted for the rest).
|
|
390
|
+
*
|
|
391
|
+
* A credential that reaches several sites gets no tenant proof: an address-free answer from it is `site_unproven`.
|
|
392
|
+
* On any other server (a proxy, a fake) an issue without an address proves nothing and is not admitted.
|
|
393
|
+
*/
|
|
394
|
+
function jiraAdmit(issue, tenant, linked, bound) {
|
|
395
|
+
if (!isObj(issue))
|
|
396
|
+
return null;
|
|
397
|
+
const key = str(issue['key']);
|
|
398
|
+
const m = key === null ? null : JIRA_ISSUE_KEY.exec(key);
|
|
399
|
+
if (m === null || key === null)
|
|
400
|
+
return null;
|
|
401
|
+
const f = isObj(issue['fields']) ? issue['fields'] : issue;
|
|
402
|
+
// When the answer names the issue's project, it must be the key's own project.
|
|
403
|
+
const pk = isObj(f['project']) ? str(f['project']['key']) : null;
|
|
404
|
+
if (pk !== null && pk !== m[1])
|
|
405
|
+
return null;
|
|
406
|
+
const tracker = linked.find((t) => t.tenant === tenant && t.key === m[1]);
|
|
407
|
+
if (tracker === undefined)
|
|
408
|
+
return null;
|
|
409
|
+
const proof = jiraProof(issue, tenant, tracker.siteHost);
|
|
410
|
+
// An address that names an issue must name THIS one: a key must be its key; an id, its own id (when it says one).
|
|
411
|
+
const id = str(issue['id']) ?? (typeof issue['id'] === 'number' ? String(issue['id']) : null);
|
|
412
|
+
for (const a of jiraAddresses(issue)) {
|
|
413
|
+
const named = addressIssue(a);
|
|
414
|
+
if (named === null || named === key)
|
|
415
|
+
continue;
|
|
416
|
+
if (JIRA_ISSUE_KEY.test(named) || (id !== null && named !== id))
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
if (proof === 'proved' || (proof === 'absent' && bound))
|
|
420
|
+
return { tracker, key };
|
|
421
|
+
return proof === 'absent' ? { unproven: true } : null;
|
|
422
|
+
}
|
|
423
|
+
/** Why an address-free answer is not shown. */
|
|
424
|
+
const UNPROVEN = (what) => `Jira answered ${what} without an address, so crew cannot prove the site; it trusts the site it named only on Atlassian's own server and when the credential reaches that one site (use a token or account that reaches only the linked site); nothing is shown`;
|
|
425
|
+
const admitted = (a) => a !== null && 'tracker' in a;
|
|
426
|
+
/** A Jira issue key asked for: one key of a linked project, and the tenant it is linked on. */
|
|
427
|
+
function jiraKeyArgs(args, linked) {
|
|
428
|
+
const key = str(args['issueIdOrKey']);
|
|
429
|
+
const m = key === null ? null : JIRA_ISSUE_KEY.exec(key);
|
|
430
|
+
if (m === null || key === null)
|
|
431
|
+
return refuse('bad_request', 'issueIdOrKey is a Jira issue key such as PROJA-12 (a numeric id or a URL cannot be checked against the linked projects)');
|
|
432
|
+
const t = jiraTenant(args, linked, m[1]);
|
|
433
|
+
if (!t.ok)
|
|
434
|
+
return t;
|
|
435
|
+
return { ok: true, key, project: m[1], tenant: t.tenant };
|
|
436
|
+
}
|
|
437
|
+
const jiraGetIssue = {
|
|
438
|
+
system: 'jira',
|
|
439
|
+
tool: 'getJiraIssue',
|
|
440
|
+
disclosure: 'rows',
|
|
441
|
+
bindArgs(args, linked) {
|
|
442
|
+
const k = jiraKeyArgs(args, linked);
|
|
443
|
+
if (!k.ok)
|
|
444
|
+
return k;
|
|
445
|
+
const out = { cloudId: k.tenant, issueIdOrKey: k.key };
|
|
446
|
+
if (Array.isArray(args['fields']) && args['fields'].every((x) => typeof x === 'string'))
|
|
447
|
+
out['fields'] = args['fields'].slice(0, 50);
|
|
448
|
+
return { ok: true, args: out, tenant: k.tenant, trackers: linked.filter((x) => x.tenant === k.tenant && x.key === k.project) };
|
|
449
|
+
},
|
|
450
|
+
project(result, prepared, opts) {
|
|
451
|
+
const p = payloadOf(result);
|
|
452
|
+
if (!p.ok)
|
|
453
|
+
return p;
|
|
454
|
+
if (!isObj(p.payload) || str(p.payload['key']) === null)
|
|
455
|
+
return unknownShape('the tracker', 'the issue', p.payload);
|
|
456
|
+
const a = jiraAdmit(p.payload, prepared.tenant, prepared.trackers, tenantProves(opts, prepared.tenant));
|
|
457
|
+
// Said apart, so a server that answers no address at all is seen at once: nothing can prove its site.
|
|
458
|
+
if (a !== null && 'unproven' in a)
|
|
459
|
+
return refuse('site_unproven', UNPROVEN('the issue'));
|
|
460
|
+
// The issue asked for is not the one answered, or not a linked one: nothing of it is shown.
|
|
461
|
+
if (!admitted(a) || a.key !== prepared.args['issueIdOrKey'])
|
|
462
|
+
return refuse('outside_linked_set', 'the tracker answered an issue outside the projects linked to this step, so nothing is shown');
|
|
463
|
+
return { ok: true, items: [{ trackerId: a.tracker.trackerId, ref: a.key, value: jiraIssueValue(p.payload, prepared.tenant, a.tracker.siteHost) }], next: null };
|
|
464
|
+
},
|
|
465
|
+
};
|
|
466
|
+
/** The JQL a unit may run: `project in (<linked keys>) AND (<its JQL>)`, its ORDER BY kept last. */
|
|
467
|
+
export function boundJql(jql, keys) {
|
|
468
|
+
// Found on a copy with quoted strings blanked (same length), so `"order by milk"` is text, not the clause.
|
|
469
|
+
const blanked = jql.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g, (m) => ' '.repeat(m.length));
|
|
470
|
+
const at = blanked.search(/\border\s+by\b(?![\s\S]*\border\s+by\b)/i);
|
|
471
|
+
const where = (at === -1 ? jql : jql.slice(0, at)).trim();
|
|
472
|
+
const order = at === -1 ? '' : ` ${jql.slice(at).trim()}`;
|
|
473
|
+
const inList = `project in (${keys.map((k) => `"${k}"`).join(', ')})`;
|
|
474
|
+
return `${where === '' ? inList : `${inList} AND (${where})`}${order}`;
|
|
475
|
+
}
|
|
476
|
+
/** The issue list of a Jira search answer: `issues: [...]` (REST, the v2 text) or `issues: {nodes: [...]}` (the v2 envelope). */
|
|
477
|
+
function jiraIssueList(p) {
|
|
478
|
+
if (!isObj(p))
|
|
479
|
+
return null;
|
|
480
|
+
const i = p['issues'];
|
|
481
|
+
if (Array.isArray(i))
|
|
482
|
+
return i;
|
|
483
|
+
if (isObj(i) && Array.isArray(i['nodes']))
|
|
484
|
+
return i['nodes'];
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
const jiraSearch = {
|
|
488
|
+
system: 'jira',
|
|
489
|
+
tool: 'searchJiraIssuesUsingJql',
|
|
490
|
+
disclosure: 'rows',
|
|
491
|
+
bindArgs(args, linked) {
|
|
492
|
+
const jql = typeof args['jql'] === 'string' ? args['jql'] : '';
|
|
493
|
+
if (jql.length > 4_000)
|
|
494
|
+
return refuse('bad_request', 'jql is at most 4000 characters');
|
|
495
|
+
const t = jiraTenant(args, linked);
|
|
496
|
+
if (!t.ok)
|
|
497
|
+
return t;
|
|
498
|
+
const trackers = linked.filter((x) => x.tenant === t.tenant);
|
|
499
|
+
const keys = [...new Set(trackers.map((x) => x.key))].sort();
|
|
500
|
+
const max = typeof args['maxResults'] === 'number' && Number.isInteger(args['maxResults']) && args['maxResults'] > 0 ? Math.min(args['maxResults'], PM_PAGE_MAX) : 20;
|
|
501
|
+
const out = { cloudId: t.tenant, jql: boundJql(jql, keys), maxResults: max };
|
|
502
|
+
if (Array.isArray(args['fields']) && args['fields'].every((x) => typeof x === 'string'))
|
|
503
|
+
out['fields'] = args['fields'].slice(0, 50);
|
|
504
|
+
return { ok: true, args: out, tenant: t.tenant, trackers };
|
|
505
|
+
},
|
|
506
|
+
project(result, prepared, opts) {
|
|
507
|
+
const p = payloadOf(result);
|
|
508
|
+
if (!p.ok)
|
|
509
|
+
return p;
|
|
510
|
+
const list = jiraIssueList(p.payload);
|
|
511
|
+
if (list === null)
|
|
512
|
+
return unknownShape('the tracker', 'its search', p.payload);
|
|
513
|
+
// The tenant proof holds only for an answer with no address anywhere: one that addresses some items proves each.
|
|
514
|
+
const bound = tenantProves(opts, prepared.tenant) && !list.some((i) => isObj(i) && jiraAddresses(i).length > 0);
|
|
515
|
+
const items = [];
|
|
516
|
+
let unproven = 0;
|
|
517
|
+
for (const issue of list) {
|
|
518
|
+
const a = jiraAdmit(issue, prepared.tenant, prepared.trackers, bound);
|
|
519
|
+
if (!admitted(a)) {
|
|
520
|
+
if (a !== null)
|
|
521
|
+
unproven++;
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
items.push({ trackerId: a.tracker.trackerId, ref: a.key, value: jiraIssueValue(issue, prepared.tenant, a.tracker.siteHost) });
|
|
525
|
+
}
|
|
526
|
+
// Nothing admitted, and the linked items were answered without an address: say so, rather than an empty page that
|
|
527
|
+
// reads as "no issues".
|
|
528
|
+
if (items.length === 0 && unproven > 0)
|
|
529
|
+
return refuse('site_unproven', UNPROVEN('its issues'));
|
|
530
|
+
// Vendor cursors are not passed on: a cursor is the vendor's text, which nothing here can judge (narrow the JQL).
|
|
531
|
+
return { ok: true, items: items.slice(0, PM_PAGE_MAX), next: null };
|
|
532
|
+
},
|
|
533
|
+
};
|
|
534
|
+
/**
|
|
535
|
+
* An issue's comments (`listJiraIssueComments`): bound like `getJiraIssue` (the key's project linked, crew sets the
|
|
536
|
+
* site), one item per call (the issue) carrying its comments. A comment's own address, when it has one, must name the
|
|
537
|
+
* site; one Jira limits to a role or group, or a JSM internal note, is withheld and counted.
|
|
538
|
+
*/
|
|
539
|
+
const jiraComments = {
|
|
540
|
+
system: 'jira',
|
|
541
|
+
tool: 'listJiraIssueComments',
|
|
542
|
+
disclosure: 'rows',
|
|
543
|
+
bindArgs(args, linked) {
|
|
544
|
+
const k = jiraKeyArgs(args, linked);
|
|
545
|
+
if (!k.ok)
|
|
546
|
+
return k;
|
|
547
|
+
const out = { cloudId: k.tenant, issueIdOrKey: k.key };
|
|
548
|
+
out['maxResults'] = typeof args['maxResults'] === 'number' && Number.isInteger(args['maxResults']) && args['maxResults'] > 0 ? Math.min(args['maxResults'], PM_COMMENTS_MAX) : PM_COMMENTS_MAX;
|
|
549
|
+
if (typeof args['startAt'] === 'number' && Number.isInteger(args['startAt']) && args['startAt'] >= 0 && args['startAt'] <= 100_000)
|
|
550
|
+
out['startAt'] = args['startAt'];
|
|
551
|
+
if (args['orderBy'] === 'created' || args['orderBy'] === '-created' || args['orderBy'] === '+created')
|
|
552
|
+
out['orderBy'] = args['orderBy'];
|
|
553
|
+
return { ok: true, args: out, tenant: k.tenant, trackers: linked.filter((x) => x.tenant === k.tenant && x.key === k.project) };
|
|
554
|
+
},
|
|
555
|
+
project(result, prepared, opts) {
|
|
556
|
+
const p = payloadOf(result);
|
|
557
|
+
if (!p.ok)
|
|
558
|
+
return p;
|
|
559
|
+
const list = Array.isArray(p.payload) ? p.payload : isObj(p.payload) && Array.isArray(p.payload['comments']) ? p.payload['comments'] : null;
|
|
560
|
+
if (list === null)
|
|
561
|
+
return unknownShape('the tracker', 'the comments', p.payload);
|
|
562
|
+
const tracker = prepared.trackers[0];
|
|
563
|
+
const key = String(prepared.args['issueIdOrKey']);
|
|
564
|
+
if (tracker === undefined)
|
|
565
|
+
return refuse('outside_linked_set', `${key} is not a Jira project linked to this step`);
|
|
566
|
+
// Every place the answer names its issue must name the one asked for.
|
|
567
|
+
for (const k of ['issueKey', 'key']) {
|
|
568
|
+
const named = isObj(p.payload) ? p.payload[k] : undefined;
|
|
569
|
+
if (named !== undefined && named !== key)
|
|
570
|
+
return refuse('outside_linked_set', 'the tracker answered the comments of another issue, so nothing is shown');
|
|
571
|
+
}
|
|
572
|
+
// crew asks for at most 20: an answer this long is not the page asked for, and is not read in part.
|
|
573
|
+
if (list.length > 200)
|
|
574
|
+
return refuse('unknown_shape', `the tracker answered ${list.length} comments for a page of ${String(prepared.args['maxResults'])}, so nothing is shown`);
|
|
575
|
+
const bound = tenantProves(opts, prepared.tenant) && !list.some((c) => isObj(c) && jiraAddresses(c).length > 0);
|
|
576
|
+
// Every comment that names its issue (`.../issue/<id>/comment/<id>`, an `issueId`) must name the same one: an answer
|
|
577
|
+
// that mixes issues is not the one issue crew asked for.
|
|
578
|
+
const parents = new Set();
|
|
579
|
+
const comments = [];
|
|
580
|
+
let withheld = 0;
|
|
581
|
+
let cut = 0;
|
|
582
|
+
for (const c of list) {
|
|
583
|
+
if (!isObj(c))
|
|
584
|
+
continue;
|
|
585
|
+
const proof = jiraProof(c, prepared.tenant, tracker.siteHost);
|
|
586
|
+
if (proof === 'contradicted')
|
|
587
|
+
return refuse('outside_linked_set', 'the tracker answered a comment from another site, so nothing is shown');
|
|
588
|
+
if (proof === 'absent' && !bound)
|
|
589
|
+
return refuse('site_unproven', UNPROVEN('the comments'));
|
|
590
|
+
// Every parent a comment names, by id or key: one issue across the answer, and a key named must be the one asked.
|
|
591
|
+
for (const x of commentParents(c)) {
|
|
592
|
+
if (JIRA_ISSUE_KEY.test(x) ? x !== key : false)
|
|
593
|
+
return refuse('outside_linked_set', 'the tracker answered comments of another issue, so nothing is shown');
|
|
594
|
+
if (!JIRA_ISSUE_KEY.test(x))
|
|
595
|
+
parents.add(x);
|
|
596
|
+
}
|
|
597
|
+
if (parents.size > 1)
|
|
598
|
+
return refuse('outside_linked_set', 'the tracker answered comments of more than one issue, so nothing is shown');
|
|
599
|
+
if (jiraCommentRestricted(c)) {
|
|
600
|
+
withheld++;
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
if (comments.length >= PM_COMMENTS_MAX) {
|
|
604
|
+
cut++;
|
|
605
|
+
continue;
|
|
606
|
+
}
|
|
607
|
+
const author = isObj(c['author']) ? str(c['author']['displayName']) ?? str(c['author']['name']) : null;
|
|
608
|
+
comments.push({ author, created: str(c['created']), updated: str(c['updated']), body: adfText(c['body'], 1_500), ...(str(c['parentId']) !== null || typeof c['parentId'] === 'number' ? { reply: true } : {}) });
|
|
609
|
+
}
|
|
610
|
+
const pl = isObj(p.payload) ? p.payload : {};
|
|
611
|
+
const total = typeof pl['total'] === 'number' && Number.isInteger(pl['total']) ? pl['total'] : null;
|
|
612
|
+
// A page crew cut is not the last one, whatever the vendor said.
|
|
613
|
+
const isLast = cut > 0 ? false : typeof pl['isLast'] === 'boolean' ? pl['isLast'] : null;
|
|
614
|
+
return { ok: true, items: [{ trackerId: tracker.trackerId, ref: key, value: { key, comments, total, isLast, ...(withheld > 0 ? { withheld } : {}), ...(cut > 0 ? { cut } : {}) } }], next: null };
|
|
615
|
+
},
|
|
616
|
+
};
|
|
617
|
+
/** The account a Jira credential belongs to (`atlassianUserInfo`): its `accountId` alone, no issue rows. */
|
|
618
|
+
const jiraAccount = {
|
|
619
|
+
system: 'jira',
|
|
620
|
+
tool: 'atlassianUserInfo',
|
|
621
|
+
disclosure: 'structure',
|
|
622
|
+
bindArgs(_args, linked) {
|
|
623
|
+
const tenants = [...new Set(linked.map((t) => t.tenant))];
|
|
624
|
+
if (tenants.length === 0)
|
|
625
|
+
return refuse('outside_linked_set', 'no Jira project is linked to this step');
|
|
626
|
+
return { ok: true, args: {}, tenant: tenants[0], trackers: [...linked] };
|
|
627
|
+
},
|
|
628
|
+
project(result, prepared) {
|
|
629
|
+
const p = payloadOf(result);
|
|
630
|
+
if (!p.ok)
|
|
631
|
+
return p;
|
|
632
|
+
const id = isObj(p.payload) ? str(p.payload['accountId']) ?? str(p.payload['account_id']) : null;
|
|
633
|
+
if (id === null || id.length > 128)
|
|
634
|
+
return unknownShape('the tracker', 'its account', p.payload);
|
|
635
|
+
return { ok: true, items: [{ trackerId: prepared.trackers[0].trackerId, ref: 'account', value: { accountId: id } }], next: null };
|
|
636
|
+
},
|
|
637
|
+
};
|
|
638
|
+
/** The Jira sites of an answer to `getAccessibleAtlassianResources` (v2 `{resources}`, REST array); `null`: not that shape. */
|
|
639
|
+
export function jiraSitesOf(p) {
|
|
640
|
+
const list = siteListOf(p);
|
|
641
|
+
if (list === null)
|
|
642
|
+
return null;
|
|
643
|
+
const host = (u) => {
|
|
644
|
+
try {
|
|
645
|
+
const x = new URL(String(u));
|
|
646
|
+
return x.protocol === 'https:' && x.username === '' && x.password === '' ? x.host.toLowerCase() : null;
|
|
647
|
+
}
|
|
648
|
+
catch {
|
|
649
|
+
return null;
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
const out = new Map();
|
|
653
|
+
// Every host each site id is named at, across ALL entries (whatever their products): two hosts confirm none.
|
|
654
|
+
const hosts = new Map();
|
|
655
|
+
for (const s of list) {
|
|
656
|
+
const id = isObj(s) ? siteIdOf(s) : null;
|
|
657
|
+
if (id !== null && id !== false)
|
|
658
|
+
hosts.set(id, (hosts.get(id) ?? new Set()).add(host(s['url'])));
|
|
659
|
+
}
|
|
660
|
+
let readable = 0;
|
|
661
|
+
for (const s of list) {
|
|
662
|
+
if (!isObj(s))
|
|
663
|
+
continue;
|
|
664
|
+
const id = siteIdOf(s);
|
|
665
|
+
if (id === false)
|
|
666
|
+
return null;
|
|
667
|
+
if (id === null)
|
|
668
|
+
continue;
|
|
669
|
+
readable++;
|
|
670
|
+
// A site the answer says has no Jira (a Confluence-only site, an empty product list; the REST shape's entry whose
|
|
671
|
+
// scopes are all another product's) is no tracker's site.
|
|
672
|
+
const products = Array.isArray(s['products']) ? s['products'] : null;
|
|
673
|
+
if (products !== null && !products.some((x) => /^jira/i.test(String(isObj(x) ? x['id'] ?? x['key'] ?? x['name'] ?? '' : x))))
|
|
674
|
+
continue;
|
|
675
|
+
const scopes = products === null && Array.isArray(s['scopes']) ? s['scopes'] : null;
|
|
676
|
+
if (scopes !== null && scopes.length > 0 && !scopes.some((x) => typeof x === 'string' && /jira/i.test(x)))
|
|
677
|
+
continue;
|
|
678
|
+
const named = [...(hosts.get(id) ?? [])];
|
|
679
|
+
// One site named at two hosts (or once without one): no host is confirmed; a site-form address then proves nothing.
|
|
680
|
+
const h = named.length === 1 ? named[0] : null;
|
|
681
|
+
const was = out.get(id);
|
|
682
|
+
const name = typeof s['name'] === 'string' && s['name'].trim() !== '' ? vendorText(s['name'], 100) : null;
|
|
683
|
+
out.set(id, { id, label: name ?? was?.label ?? h ?? named.find((x) => x !== null) ?? id, host: h });
|
|
684
|
+
}
|
|
685
|
+
// Entries, none of them readable as a site: not a shape crew knows.
|
|
686
|
+
if (list.length > 0 && readable === 0)
|
|
687
|
+
return null;
|
|
688
|
+
return [...out.values()];
|
|
689
|
+
}
|
|
690
|
+
/** Every distinct site id an answer to `getAccessibleAtlassianResources` names, whatever its products; `null`: not that shape. */
|
|
691
|
+
export function atlassianSiteIdsOf(p) {
|
|
692
|
+
const list = siteListOf(p);
|
|
693
|
+
if (list === null)
|
|
694
|
+
return null;
|
|
695
|
+
const ids = new Set();
|
|
696
|
+
for (const s of list) {
|
|
697
|
+
const id = isObj(s) ? siteIdOf(s) : null;
|
|
698
|
+
if (id === null || id === false)
|
|
699
|
+
return null;
|
|
700
|
+
ids.add(id);
|
|
701
|
+
}
|
|
702
|
+
return [...ids];
|
|
703
|
+
}
|
|
704
|
+
/** The ONE site list of an answer (an array, or `resources` / `sites` / `accessibleResources`); two lists = `null`. */
|
|
705
|
+
function siteListOf(p) {
|
|
706
|
+
if (Array.isArray(p))
|
|
707
|
+
return p;
|
|
708
|
+
if (!isObj(p))
|
|
709
|
+
return null;
|
|
710
|
+
const lists = [p['resources'], p['sites'], p['accessibleResources']].filter(Array.isArray);
|
|
711
|
+
return lists.length === 1 ? lists[0] : null;
|
|
712
|
+
}
|
|
713
|
+
/** A site entry's id (`cloudId`, or `id`); `false` when both are named and disagree, `null` when neither is one. */
|
|
714
|
+
function siteIdOf(s) {
|
|
715
|
+
const a = str(s['cloudId']);
|
|
716
|
+
const b = str(s['id']);
|
|
717
|
+
if (a !== null && b !== null && a !== b)
|
|
718
|
+
return false;
|
|
719
|
+
const id = a ?? b;
|
|
720
|
+
return id !== null && /^[A-Za-z0-9-]{1,64}$/.test(id) ? id : null;
|
|
721
|
+
}
|
|
722
|
+
/** The sites of `getAccessibleAtlassianResources`, cut to the tenants linked to this step: `{cloudId, url}` each. */
|
|
723
|
+
const jiraSites = {
|
|
724
|
+
system: 'jira',
|
|
725
|
+
tool: 'getAccessibleAtlassianResources',
|
|
726
|
+
disclosure: 'structure',
|
|
727
|
+
bindArgs(_args, linked) {
|
|
728
|
+
const tenants = [...new Set(linked.map((t) => t.tenant))];
|
|
729
|
+
if (tenants.length === 0)
|
|
730
|
+
return refuse('outside_linked_set', 'no Jira project is linked to this step');
|
|
731
|
+
return { ok: true, args: {}, tenant: tenants[0], trackers: [...linked] };
|
|
732
|
+
},
|
|
733
|
+
project(result, prepared) {
|
|
734
|
+
const p = payloadOf(result);
|
|
735
|
+
if (!p.ok)
|
|
736
|
+
return p;
|
|
737
|
+
const sites = jiraSitesOf(p.payload);
|
|
738
|
+
if (sites === null)
|
|
739
|
+
return unknownShape('the tracker', 'its sites', p.payload);
|
|
740
|
+
const items = [];
|
|
741
|
+
for (const s of sites) {
|
|
742
|
+
const t = prepared.trackers.find((x) => x.tenant === s.id);
|
|
743
|
+
// A site no tracker of this step is linked on is not shown (the credential may reach many).
|
|
744
|
+
if (t === undefined)
|
|
745
|
+
continue;
|
|
746
|
+
// The site's address must be the host confirmed at link time, when one was.
|
|
747
|
+
const host = t.siteHost != null ? (s.host === t.siteHost.toLowerCase() ? t.siteHost : null) : s.host;
|
|
748
|
+
if (t.siteHost != null && host === null)
|
|
749
|
+
continue;
|
|
750
|
+
items.push({ trackerId: t.trackerId, ref: `site:${s.id}`, value: { cloudId: s.id, ...(host !== null ? { url: `https://${host}` } : {}) } });
|
|
751
|
+
}
|
|
752
|
+
return { ok: true, items, next: null };
|
|
753
|
+
},
|
|
754
|
+
};
|
|
755
|
+
// ── GitHub (github/github-mcp-server; tenant = the host) ────────────────────────────────────────────────
|
|
756
|
+
export const GITHUB_TENANT = 'github.com';
|
|
757
|
+
const REPO_PART = /^[A-Za-z0-9_.-]{1,100}$/;
|
|
758
|
+
/** `owner/repo` lower-cased, or `null` when it is not one. */
|
|
759
|
+
export function repoKey(owner, repo) {
|
|
760
|
+
if (typeof owner !== 'string' || typeof repo !== 'string' || !REPO_PART.test(owner) || !REPO_PART.test(repo))
|
|
761
|
+
return null;
|
|
762
|
+
return `${owner}/${repo}`.toLowerCase();
|
|
763
|
+
}
|
|
764
|
+
/** The owner/repo and issue number an `html_url` names (`https://github.com/o/r/issues/7`, `…#issuecomment-1`). */
|
|
765
|
+
export function githubUrlIdentity(url) {
|
|
766
|
+
if (typeof url !== 'string')
|
|
767
|
+
return null;
|
|
768
|
+
const m = /^https:\/\/github\.com\/([A-Za-z0-9_.-]{1,100})\/([A-Za-z0-9_.-]{1,100})\/(?:issues|pull)\/([1-9][0-9]{0,9})(?:[#?].*)?$/.exec(url);
|
|
769
|
+
return m === null ? null : { repo: `${m[1]}/${m[2]}`.toLowerCase(), number: Number(m[3]) };
|
|
770
|
+
}
|
|
771
|
+
function githubTracker(repo, linked) {
|
|
772
|
+
if (repo === null)
|
|
773
|
+
return null;
|
|
774
|
+
return linked.find((t) => t.tenant === GITHUB_TENANT && t.key.toLowerCase() === repo) ?? null;
|
|
775
|
+
}
|
|
776
|
+
function githubIssueValue(i, number) {
|
|
777
|
+
const login = (v) => (isObj(v) ? str(v['login']) : str(v));
|
|
778
|
+
const labels = Array.isArray(i['labels']) ? i['labels'].map((l) => (isObj(l) ? str(l['name']) : str(l))).filter((l) => l !== null).slice(0, 20) : [];
|
|
779
|
+
return {
|
|
780
|
+
number,
|
|
781
|
+
title: vendorText(i['title'], 400),
|
|
782
|
+
state: str(i['state']),
|
|
783
|
+
...(str(i['state_reason']) !== null ? { stateReason: str(i['state_reason']) } : {}),
|
|
784
|
+
author: login(i['user']),
|
|
785
|
+
labels,
|
|
786
|
+
assignees: Array.isArray(i['assignees']) ? i['assignees'].map(login).filter((x) => x !== null).slice(0, 20) : [],
|
|
787
|
+
created: str(i['created_at']),
|
|
788
|
+
updated: str(i['updated_at']),
|
|
789
|
+
closed: str(i['closed_at']),
|
|
790
|
+
comments: typeof i['comments'] === 'number' ? i['comments'] : null,
|
|
791
|
+
body: vendorText(i['body']),
|
|
792
|
+
url: String(i['html_url']),
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
/** One GitHub issue admitted by its own `html_url`; a pull request in an issue list is not an issue of the tracker. */
|
|
796
|
+
function githubAdmit(i, linked, want) {
|
|
797
|
+
if (!isObj(i))
|
|
798
|
+
return null;
|
|
799
|
+
const id = githubUrlIdentity(i['html_url']);
|
|
800
|
+
if (id === null || !/\/issues\//.test(String(i['html_url'])))
|
|
801
|
+
return null;
|
|
802
|
+
if (i['number'] !== undefined && i['number'] !== id.number)
|
|
803
|
+
return null;
|
|
804
|
+
if (want !== undefined && (want.repo !== id.repo || (want.number !== undefined && want.number !== id.number)))
|
|
805
|
+
return null;
|
|
806
|
+
const t = githubTracker(id.repo, linked);
|
|
807
|
+
if (t === null)
|
|
808
|
+
return null;
|
|
809
|
+
return { trackerId: t.trackerId, ref: `${t.key}#${id.number}`, value: githubIssueValue(i, id.number) };
|
|
810
|
+
}
|
|
811
|
+
function githubRepoArgs(args, linked) {
|
|
812
|
+
const repo = repoKey(args['owner'], args['repo']);
|
|
813
|
+
if (repo === null)
|
|
814
|
+
return refuse('bad_request', 'owner and repo name a GitHub repository');
|
|
815
|
+
const t = githubTracker(repo, linked);
|
|
816
|
+
if (t === null)
|
|
817
|
+
return refuse('outside_linked_set', `${repo} is not a GitHub tracker linked to this step`);
|
|
818
|
+
return { ok: true, repo, tracker: t };
|
|
819
|
+
}
|
|
820
|
+
const githubIssueRead = {
|
|
821
|
+
system: 'github',
|
|
822
|
+
tool: 'issue_read',
|
|
823
|
+
disclosure: 'rows',
|
|
824
|
+
bindArgs(args, linked) {
|
|
825
|
+
const method = args['method'];
|
|
826
|
+
if (method !== 'get' && method !== 'get_comments')
|
|
827
|
+
return refuse('method_unbound', 'issue_read is bound for method get and get_comments only');
|
|
828
|
+
const r = githubRepoArgs(args, linked);
|
|
829
|
+
if (!r.ok)
|
|
830
|
+
return r;
|
|
831
|
+
const n = args['issue_number'];
|
|
832
|
+
if (typeof n !== 'number' || !Number.isInteger(n) || n < 1)
|
|
833
|
+
return refuse('bad_request', 'issue_number is a positive integer');
|
|
834
|
+
const [owner, repo] = r.tracker.key.split('/');
|
|
835
|
+
const out = { method, owner, repo, issue_number: n };
|
|
836
|
+
if (method === 'get_comments')
|
|
837
|
+
out['perPage'] = typeof args['perPage'] === 'number' && args['perPage'] > 0 ? Math.min(Math.trunc(args['perPage']), PM_COMMENTS_MAX) : PM_COMMENTS_MAX;
|
|
838
|
+
if (method === 'get_comments' && typeof args['page'] === 'number' && Number.isInteger(args['page']) && args['page'] > 0)
|
|
839
|
+
out['page'] = args['page'];
|
|
840
|
+
return { ok: true, args: out, tenant: GITHUB_TENANT, trackers: [r.tracker] };
|
|
841
|
+
},
|
|
842
|
+
project(result, prepared) {
|
|
843
|
+
const p = payloadOf(result);
|
|
844
|
+
if (!p.ok)
|
|
845
|
+
return p;
|
|
846
|
+
const repo = prepared.trackers[0].key.toLowerCase();
|
|
847
|
+
const number = prepared.args['issue_number'];
|
|
848
|
+
if (prepared.args['method'] === 'get') {
|
|
849
|
+
if (!isObj(p.payload))
|
|
850
|
+
return unknownShape('the tracker', 'the issue', p.payload);
|
|
851
|
+
const item = githubAdmit(p.payload, prepared.trackers, { repo, number });
|
|
852
|
+
if (item === null)
|
|
853
|
+
return refuse('outside_linked_set', 'the tracker answered an issue outside the repositories linked to this step, so nothing is shown');
|
|
854
|
+
return { ok: true, items: [item], next: null };
|
|
855
|
+
}
|
|
856
|
+
const list = Array.isArray(p.payload) ? p.payload : isObj(p.payload) && Array.isArray(p.payload['comments']) ? p.payload['comments'] : null;
|
|
857
|
+
if (list === null)
|
|
858
|
+
return unknownShape('the tracker', 'the comments', p.payload);
|
|
859
|
+
const comments = [];
|
|
860
|
+
let dropped = 0;
|
|
861
|
+
for (const c of list.slice(0, 200)) {
|
|
862
|
+
if (comments.length >= PM_COMMENTS_MAX)
|
|
863
|
+
break;
|
|
864
|
+
const id = isObj(c) ? githubUrlIdentity(c['html_url']) : null;
|
|
865
|
+
if (!isObj(c) || id === null || id.repo !== repo || id.number !== number) {
|
|
866
|
+
dropped++;
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
869
|
+
comments.push({ author: isObj(c['user']) ? str(c['user']['login']) : null, created: str(c['created_at']), body: vendorText(c['body'], 1_500), url: String(c['html_url']) });
|
|
870
|
+
}
|
|
871
|
+
void dropped;
|
|
872
|
+
return { ok: true, items: [{ trackerId: prepared.trackers[0].trackerId, ref: `${prepared.trackers[0].key}#${number}`, value: { number, comments } }], next: null };
|
|
873
|
+
},
|
|
874
|
+
};
|
|
875
|
+
/**
|
|
876
|
+
* The scope qualifiers of a GitHub search query (`repo:`, `org:`, `user:`, `owner:`), anywhere: quoted values and
|
|
877
|
+
* negations included (`-repo:x`, `repo:"x"`), so the caller can refuse what it cannot bound. A qualifier inside a
|
|
878
|
+
* quoted phrase is text, not a qualifier, but GitHub's parser is not ours to guess: it is reported too.
|
|
879
|
+
*/
|
|
880
|
+
export function searchQualifiers(q) {
|
|
881
|
+
const out = [];
|
|
882
|
+
for (const m of q.matchAll(/(-)?\b(repo|org|user|owner)\s*:\s*("?)([^\s"]*)/gi))
|
|
883
|
+
out.push({ kind: m[2].toLowerCase(), value: m[4].toLowerCase(), negated: m[1] === '-', quoted: m[3] === '"' });
|
|
884
|
+
return out;
|
|
885
|
+
}
|
|
886
|
+
const githubSearchIssues = {
|
|
887
|
+
system: 'github',
|
|
888
|
+
tool: 'search_issues',
|
|
889
|
+
disclosure: 'rows',
|
|
890
|
+
bindArgs(args, linked) {
|
|
891
|
+
const q = typeof args['query'] === 'string' ? args['query'].trim() : '';
|
|
892
|
+
if (q === '' || q.length > 1_000)
|
|
893
|
+
return refuse('bad_request', 'query is a GitHub issue search of at most 1000 characters');
|
|
894
|
+
const repos = linked.filter((t) => t.tenant === GITHUB_TENANT);
|
|
895
|
+
const keys = repos.map((t) => t.key.toLowerCase());
|
|
896
|
+
if (keys.length === 0)
|
|
897
|
+
return refuse('outside_linked_set', 'no GitHub repository is linked to this step');
|
|
898
|
+
const quals = searchQualifiers(q);
|
|
899
|
+
if (quals.some((x) => x.kind !== 'repo'))
|
|
900
|
+
return refuse('outside_linked_set', 'a search here names repositories with repo: only (org:, user: and owner: reach past the linked set)');
|
|
901
|
+
if (quals.some((x) => x.negated || x.quoted || x.value === ''))
|
|
902
|
+
return refuse('outside_linked_set', 'a search here names its repositories as plain repo:owner/name qualifiers (no negation, no quotes)');
|
|
903
|
+
if (quals.some((x) => !keys.includes(x.value)))
|
|
904
|
+
return refuse('outside_linked_set', 'the query names a repository that is not linked to this step');
|
|
905
|
+
// `owner`/`repo` arguments become a qualifier on the server: judged the same way, then folded into the query.
|
|
906
|
+
const add = new Set();
|
|
907
|
+
if (args['owner'] !== undefined || args['repo'] !== undefined) {
|
|
908
|
+
const r = githubRepoArgs(args, linked);
|
|
909
|
+
if (!r.ok)
|
|
910
|
+
return r;
|
|
911
|
+
if (!quals.some((x) => x.value === r.repo))
|
|
912
|
+
add.add(r.tracker.key.toLowerCase());
|
|
913
|
+
}
|
|
914
|
+
// A query that names no repository gets every linked one (GitHub ORs repo: qualifiers, ANDs the rest).
|
|
915
|
+
if (quals.length === 0 && add.size === 0)
|
|
916
|
+
for (const k of keys)
|
|
917
|
+
add.add(k);
|
|
918
|
+
const query = [q, ...[...add].map((k) => `repo:${k}`)].join(' ');
|
|
919
|
+
const out = { query, perPage: typeof args['perPage'] === 'number' && args['perPage'] > 0 ? Math.min(Math.trunc(args['perPage']), PM_PAGE_MAX) : 20 };
|
|
920
|
+
for (const k of ['sort', 'order'])
|
|
921
|
+
if (typeof args[k] === 'string' && args[k].length <= 40)
|
|
922
|
+
out[k] = args[k];
|
|
923
|
+
if (typeof args['page'] === 'number' && Number.isInteger(args['page']) && args['page'] > 0)
|
|
924
|
+
out['page'] = args['page'];
|
|
925
|
+
return { ok: true, args: out, tenant: GITHUB_TENANT, trackers: repos };
|
|
926
|
+
},
|
|
927
|
+
project(result, prepared) {
|
|
928
|
+
const p = payloadOf(result);
|
|
929
|
+
if (!p.ok)
|
|
930
|
+
return p;
|
|
931
|
+
if (!isObj(p.payload) || !Array.isArray(p.payload['items']))
|
|
932
|
+
return unknownShape('the tracker', 'its search', p.payload);
|
|
933
|
+
const items = [];
|
|
934
|
+
for (const i of p.payload['items']) {
|
|
935
|
+
const item = githubAdmit(i, prepared.trackers);
|
|
936
|
+
if (item !== null)
|
|
937
|
+
items.push(item);
|
|
938
|
+
}
|
|
939
|
+
return { ok: true, items: items.slice(0, PM_PAGE_MAX), next: null };
|
|
940
|
+
},
|
|
941
|
+
};
|
|
942
|
+
// `list_issues` is NOT bound: the server's GraphQL path answers issues without `html_url` (its MinimalIssue leaves it
|
|
943
|
+
// empty), so no item could prove its repository; `search_issues` (repo: qualifiers, `html_url`) serves listing.
|
|
944
|
+
const BINDINGS = [jiraGetIssue, jiraSearch, jiraComments, jiraAccount, jiraSites, githubIssueRead, githubSearchIssues];
|
|
945
|
+
/** Crew's binding for a PM tool, or `null`: such a tool is unavailable to agents. */
|
|
946
|
+
export function bindingFor(system, tool) {
|
|
947
|
+
return BINDINGS.find((b) => b.system === system && b.tool === tool) ?? null;
|
|
948
|
+
}
|
|
949
|
+
/** The policy string a binding is stored under (`jira/getJiraIssue@1`). */
|
|
950
|
+
export function bindingPolicy(b) {
|
|
951
|
+
return `${b.system}/${b.tool}@${BINDING_POLICY_VERSION}`;
|
|
952
|
+
}
|
|
953
|
+
/** The binding a save stores for a tool of a PM entry: crew's current one, bound to the saved schema; `null` = none. */
|
|
954
|
+
export function bindingOnSave(system, tool) {
|
|
955
|
+
const b = bindingFor(system, tool.name);
|
|
956
|
+
return b === null ? null : { policy: bindingPolicy(b), schemaHash: tool.schemaHash };
|
|
957
|
+
}
|
|
958
|
+
/** The binding in force for a stored tool: crew's binding, when the stored one is its current policy on the saved schema. */
|
|
959
|
+
export function bindingInForce(system, t) {
|
|
960
|
+
const b = bindingFor(system, t.name);
|
|
961
|
+
const stored = t.binding ?? null;
|
|
962
|
+
if (b === null || stored === null || t.schemaHash === null)
|
|
963
|
+
return null;
|
|
964
|
+
return stored.policy === bindingPolicy(b) && stored.schemaHash === t.schemaHash ? b : null;
|
|
965
|
+
}
|
|
966
|
+
/** Every tool name crew binds for `system` (the sheet and the tests). */
|
|
967
|
+
export function boundToolNames(system) {
|
|
968
|
+
return BINDINGS.filter((b) => b.system === system).map((b) => b.tool);
|
|
969
|
+
}
|
|
970
|
+
//# sourceMappingURL=bindings.js.map
|