prismalens 0.5.3 → 0.5.4
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 +7 -5
- package/THIRD_PARTY_NOTICES.txt +381 -3
- package/dist/{chunk-2BLEMVIB.js → chunk-7JTFOLGT.js} +9 -4
- package/dist/{chunk-32MOXOOZ.js → chunk-IEPD6EMA.js} +15 -7
- package/dist/{chunk-2SF6M3PV.js → chunk-IJ2EB73U.js} +10 -0
- package/dist/{chunk-B34NMVBM.js → chunk-JK7AMZSE.js} +34 -1
- package/dist/{chunk-7JF4AL64.js → chunk-NXTEM2HN.js} +3 -2
- package/dist/src/cli/doctor.js +53 -184
- package/dist/src/cli/pair.js +8 -3
- package/dist/src/cli/service-unit.js +1 -1
- package/dist/src/cli/service.js +4 -4
- package/dist/src/cli/tailscale.js +3 -1
- package/dist/src/cli/up-console.js +7 -3
- package/dist/src/cli/up.js +23 -4
- package/dist/src/cli/upgrade-trial.js +1 -1
- package/dist/src/cli/upgrade.js +4 -4
- package/node_modules/@prismalens/agent-adapters/THIRD_PARTY_LICENSES/@agentclientprotocol/sdk/2.1.0/LICENSE +191 -0
- package/node_modules/@prismalens/agent-adapters/THIRD_PARTY_LICENSES/@anthropic-ai/claude-agent-sdk/README.md +2 -2
- package/node_modules/@prismalens/agent-adapters/dist/adapters/bundled.json +6 -6
- package/node_modules/@prismalens/agent-adapters/dist/adapters/claude-agent-acp.mjs +3840 -1504
- package/node_modules/@prismalens/agent-adapters/dist/adapters/codex-acp.mjs +3247 -1158
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/README.md +2 -2
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/bridge.mjs +81 -86
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.js +76 -83
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/core-07pvccxf.mjs +43 -0
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/core-0rjxgk9e.mjs +18 -0
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/core-fpeb751h.mjs +33 -0
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/core-jf0rbr11.mjs +17 -0
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/core.d.ts +1 -0
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/core.mjs +12 -21
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/manifest.json +19 -24
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/manifest.zst.json +23 -28
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/package.json +7 -7
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/sdk-tools.d.ts +11 -0
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/sdk.d.ts +139 -36
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +68 -73
- package/node_modules/@prismalens/agent-adapters/package.json +1 -1
- package/node_modules/@prismalens/agent-host/dist/launch.js +81 -12
- package/node_modules/@prismalens/agent-host/dist/probe.js +76 -24
- package/node_modules/@prismalens/agent-host/dist/registry/agents.js +17 -1
- package/node_modules/@prismalens/agent-host/dist/workspace/git.js +20 -5
- package/node_modules/@prismalens/agent-host/dist/workspace/index.js +26 -4
- package/node_modules/@prismalens/api/dist/src/app.module.js +14 -0
- package/node_modules/@prismalens/api/dist/src/core/auth/auth.guard.js +7 -3
- package/node_modules/@prismalens/api/dist/src/core/auth/instance-identity.js +12 -0
- package/node_modules/@prismalens/api/dist/src/core/auth/operator.controller.js +1 -1
- package/node_modules/@prismalens/api/dist/src/core/auth/owner.js +18 -0
- package/node_modules/@prismalens/api/dist/src/core/auth/pairing.controller.js +11 -7
- package/node_modules/@prismalens/api/dist/src/core/harness/git-credential.js +18 -0
- package/node_modules/@prismalens/api/dist/src/core/harness/git-env.js +3 -20
- package/node_modules/@prismalens/api/dist/src/core/harness/git-spawn.js +22 -4
- package/node_modules/@prismalens/api/dist/src/core/harness/harness.service.js +81 -1
- package/node_modules/@prismalens/api/dist/src/core/harness/ready-harness.js +26 -0
- package/node_modules/@prismalens/api/dist/src/core/harness/repo-source.service.js +46 -9
- package/node_modules/@prismalens/api/dist/src/core/harness/run-worktree.js +22 -5
- package/node_modules/@prismalens/api/dist/src/core/lifecycle/admission.service.js +35 -0
- package/node_modules/@prismalens/api/dist/src/core/lifecycle/restart-exit.js +8 -0
- package/node_modules/@prismalens/api/dist/src/core/lifecycle/runtime-lifecycle.module.js +28 -0
- package/node_modules/@prismalens/api/dist/src/core/lifecycle/runtime-lifecycle.service.js +186 -0
- package/node_modules/@prismalens/api/dist/src/core/lifecycle/workspace-lock-shutdown.service.js +4 -0
- package/node_modules/@prismalens/api/dist/src/core/live/live-changes.js +25 -12
- package/node_modules/@prismalens/api/dist/src/core/prisma/prisma.service.js +54 -0
- package/node_modules/@prismalens/api/dist/src/core/settings/about.service.js +17 -3
- package/node_modules/@prismalens/api/dist/src/core/settings/diagnostics.service.js +61 -0
- package/node_modules/@prismalens/api/dist/src/core/settings/settings.controller.js +52 -15
- package/node_modules/@prismalens/api/dist/src/core/settings/settings.module.js +3 -1
- package/node_modules/@prismalens/api/dist/src/core/settings/settings.service.js +0 -4
- package/node_modules/@prismalens/api/dist/src/core/settings/update-handoff.js +201 -0
- package/node_modules/@prismalens/api/dist/src/core/settings/update.service.js +373 -0
- package/node_modules/@prismalens/api/dist/src/core/telemetry/telemetry.service.js +16 -7
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/checkout-lease.js +203 -0
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/checkout-status.js +125 -0
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/dispatch.service.js +962 -81
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/dispatcher.js +66 -22
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/event-bus.js +6 -0
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/folder-lock.js +140 -0
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/harness-receipt.js +312 -0
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/in-process-runner.js +27 -5
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/investigation-run.js +683 -60
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/job-store.js +72 -9
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/pre-run-context.js +7 -1
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/restart-recovery.js +112 -0
- package/node_modules/@prismalens/api/dist/src/infrastructure/dispatch/run-abort.js +2 -0
- package/node_modules/@prismalens/api/dist/src/main.js +16 -3
- package/node_modules/@prismalens/api/dist/src/middlewares/cross-site.middleware.js +79 -0
- package/node_modules/@prismalens/api/dist/src/middlewares/host-allowlist.middleware.js +18 -3
- package/node_modules/@prismalens/api/dist/src/modules/alerts/alert-pull.service.js +20 -8
- package/node_modules/@prismalens/api/dist/src/modules/alerts/alerts.service.js +12 -3
- package/node_modules/@prismalens/api/dist/src/modules/asks/asks.contract.js +6 -0
- package/node_modules/@prismalens/api/dist/src/modules/asks/asks.service.js +303 -0
- package/node_modules/@prismalens/api/dist/src/modules/composer/composer.controller.js +64 -0
- package/node_modules/@prismalens/api/dist/src/modules/composer/composer.module.js +54 -0
- package/node_modules/@prismalens/api/dist/src/modules/composer/drafts.service.js +169 -0
- package/node_modules/@prismalens/api/dist/src/modules/delivery/report-delivery.controller.js +5 -1
- package/node_modules/@prismalens/api/dist/src/modules/events/events.service.js +27 -1
- package/node_modules/@prismalens/api/dist/src/modules/fixes/fixes.service.js +12 -4
- package/node_modules/@prismalens/api/dist/src/modules/gateway/gateway.service.js +1034 -80
- package/node_modules/@prismalens/api/dist/src/modules/gateway/runbooks.js +2 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/artifacts.js +30 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/asks.js +94 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/attachments.js +128 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/history.js +42 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/incident.js +74 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/index.js +32 -4
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/knowledge.js +18 -10
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/propose.js +36 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/record.js +80 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/report.js +41 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/rules.js +3 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/run.js +24 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/runbooks.js +18 -12
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/serves.js +11 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/services.js +24 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/thread-tree.js +99 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/threads.js +85 -0
- package/node_modules/@prismalens/api/dist/src/modules/gateway/tools/watches.js +75 -0
- package/node_modules/@prismalens/api/dist/src/modules/images/image-fetch.js +100 -0
- package/node_modules/@prismalens/api/dist/src/modules/images/images.controller.js +50 -0
- package/node_modules/@prismalens/api/dist/src/modules/images/images.module.js +22 -0
- package/node_modules/@prismalens/api/dist/src/modules/images/images.service.js +211 -0
- package/node_modules/@prismalens/api/dist/src/modules/incidents/incidents.controller.js +75 -34
- package/node_modules/@prismalens/api/dist/src/modules/incidents/incidents.module.js +2 -0
- package/node_modules/@prismalens/api/dist/src/modules/incidents/incidents.service.js +89 -46
- package/node_modules/@prismalens/api/dist/src/modules/integrations/host-repositories.service.js +76 -0
- package/node_modules/@prismalens/api/dist/src/modules/integrations/integrations.controller.js +67 -7
- package/node_modules/@prismalens/api/dist/src/modules/integrations/integrations.module.js +4 -1
- package/node_modules/@prismalens/api/dist/src/modules/integrations/telemetry-snapshot.service.js +11 -1
- package/node_modules/@prismalens/api/dist/src/modules/investigations/attachments.service.js +157 -49
- package/node_modules/@prismalens/api/dist/src/modules/investigations/context-pack.service.js +39 -7
- package/node_modules/@prismalens/api/dist/src/modules/investigations/dto/investigation-result.dto.js +3 -3
- package/node_modules/@prismalens/api/dist/src/modules/investigations/investigation-trigger.service.js +4 -1
- package/node_modules/@prismalens/api/dist/src/modules/investigations/investigations.controller.js +301 -21
- package/node_modules/@prismalens/api/dist/src/modules/investigations/investigations.module.js +17 -0
- package/node_modules/@prismalens/api/dist/src/modules/investigations/investigations.service.js +165 -30
- package/node_modules/@prismalens/api/dist/src/modules/investigations/promotion.js +5 -0
- package/node_modules/@prismalens/api/dist/src/modules/investigations/run-scope.js +31 -0
- package/node_modules/@prismalens/api/dist/src/modules/investigations/run-views.js +333 -0
- package/node_modules/@prismalens/api/dist/src/modules/investigations/subagent-sessions.js +28 -0
- package/node_modules/@prismalens/api/dist/src/modules/investigations/tool-asks.service.js +193 -0
- package/node_modules/@prismalens/api/dist/src/modules/investigations/worktree-changes.js +324 -0
- package/node_modules/@prismalens/api/dist/src/modules/openapi/build-spec.js +42 -0
- package/node_modules/@prismalens/api/dist/src/modules/openapi/openapi.controller.js +8 -87
- package/node_modules/@prismalens/api/dist/src/modules/overlay/overlay.service.js +36 -24
- package/node_modules/@prismalens/api/dist/src/modules/push/ask-state.js +6 -3
- package/node_modules/@prismalens/api/dist/src/modules/push/push-outbox.js +4 -1
- package/node_modules/@prismalens/api/dist/src/modules/push/push.service.js +13 -3
- package/node_modules/@prismalens/api/dist/src/modules/references/file-list.js +135 -0
- package/node_modules/@prismalens/api/dist/src/modules/references/monitoring.provider.js +200 -0
- package/node_modules/@prismalens/api/dist/src/modules/references/ranking.js +42 -0
- package/node_modules/@prismalens/api/dist/src/modules/references/records.provider.js +463 -0
- package/node_modules/@prismalens/api/dist/src/modules/references/reference-provider.js +9 -0
- package/node_modules/@prismalens/api/dist/src/modules/references/references.service.js +341 -0
- package/node_modules/@prismalens/api/dist/src/modules/references/work-items.provider.js +83 -0
- package/node_modules/@prismalens/api/dist/src/modules/repositories/folder-browser.js +150 -0
- package/node_modules/@prismalens/api/dist/src/modules/repositories/project-scripts.js +100 -0
- package/node_modules/@prismalens/api/dist/src/modules/repositories/repo-icon-scan.js +180 -0
- package/node_modules/@prismalens/api/dist/src/modules/repositories/repositories.controller.js +51 -4
- package/node_modules/@prismalens/api/dist/src/modules/repositories/repositories.module.js +5 -3
- package/node_modules/@prismalens/api/dist/src/modules/repositories/repositories.service.js +91 -15
- package/node_modules/@prismalens/api/dist/src/modules/repositories/repository-icon.service.js +271 -0
- package/node_modules/@prismalens/api/dist/src/modules/repositories/serialize-repository.js +5 -3
- package/node_modules/@prismalens/api/dist/src/modules/repositories/start-git.js +204 -0
- package/node_modules/@prismalens/api/dist/src/modules/run-workspaces/editors.js +122 -0
- package/node_modules/@prismalens/api/dist/src/modules/run-workspaces/run-workspaces.controller.js +15 -16
- package/node_modules/@prismalens/api/dist/src/modules/run-workspaces/run-workspaces.service.js +29 -1
- package/node_modules/@prismalens/api/dist/src/modules/schedules/allowed-asks.js +17 -0
- package/node_modules/@prismalens/api/dist/src/modules/schedules/decide.js +54 -0
- package/node_modules/@prismalens/api/dist/src/modules/schedules/recurrence.js +85 -0
- package/node_modules/@prismalens/api/dist/src/modules/schedules/schedule-text.js +111 -0
- package/node_modules/@prismalens/api/dist/src/modules/schedules/schedules.controller.js +83 -0
- package/node_modules/@prismalens/api/dist/src/modules/schedules/schedules.module.js +23 -0
- package/node_modules/@prismalens/api/dist/src/modules/schedules/schedules.service.js +898 -0
- package/node_modules/@prismalens/api/dist/src/modules/services/services.controller.js +24 -5
- package/node_modules/@prismalens/api/dist/src/modules/services/services.module.js +2 -1
- package/node_modules/@prismalens/api/dist/src/modules/services/services.service.js +11 -6
- package/node_modules/@prismalens/api/dist/src/modules/terminal/local-request.js +61 -0
- package/node_modules/@prismalens/api/dist/src/modules/terminal/pty.js +75 -0
- package/node_modules/@prismalens/api/dist/src/modules/terminal/terminal-gate.js +57 -0
- package/node_modules/@prismalens/api/dist/src/modules/terminal/terminal-key-issue.js +22 -0
- package/node_modules/@prismalens/api/dist/src/modules/terminal/terminal-socket.js +162 -0
- package/node_modules/@prismalens/api/dist/src/modules/terminal/terminal.controller.js +94 -0
- package/node_modules/@prismalens/api/dist/src/modules/terminal/terminal.module.js +20 -0
- package/node_modules/@prismalens/api/dist/src/modules/terminal/terminal.service.js +54 -0
- package/node_modules/@prismalens/api/dist/src/modules/thread-tree/pending-actions.service.js +465 -0
- package/node_modules/@prismalens/api/dist/src/modules/thread-tree/proposals.service.js +234 -0
- package/node_modules/@prismalens/api/dist/src/modules/thread-tree/put-off.js +19 -0
- package/node_modules/@prismalens/api/dist/src/modules/thread-tree/thread-tree.controller.js +68 -0
- package/node_modules/@prismalens/api/dist/src/modules/thread-tree/thread-tree.module.js +46 -0
- package/node_modules/@prismalens/api/dist/src/modules/thread-tree/thread-tree.service.js +972 -0
- package/node_modules/@prismalens/api/dist/src/modules/thread-tree/tree-gateway.service.js +85 -0
- package/node_modules/@prismalens/api/dist/src/modules/thread-tree/tree-io.service.js +98 -0
- package/node_modules/@prismalens/api/dist/src/modules/thread-tree/tree-settings.service.js +49 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/links.service.js +258 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/pr-hosts.js +359 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/pr-url.js +74 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/pull-requests.service.js +471 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/thread-context-settings.controller.js +58 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/thread-context-settings.js +28 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/thread-context.service.js +250 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/thread-sections.js +82 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/thread-titles.js +56 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/thread-watches.service.js +329 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/threads.controller.js +81 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/threads.module.js +53 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/threads.service.js +623 -0
- package/node_modules/@prismalens/api/dist/src/modules/threads/work-items.js +171 -0
- package/node_modules/@prismalens/api/dist/src/modules/timeline/timeline.service.js +2 -0
- package/node_modules/@prismalens/api/dist/src/modules/wakes/agent-wakes.js +17 -0
- package/node_modules/@prismalens/api/dist/src/modules/wakes/session-lifecycle.service.js +376 -0
- package/node_modules/@prismalens/api/dist/src/modules/wakes/session.js +124 -0
- package/node_modules/@prismalens/api/dist/src/modules/wakes/wakes.module.js +28 -0
- package/node_modules/@prismalens/api/dist/src/modules/wakes/wakes.service.js +129 -0
- package/node_modules/@prismalens/api/dist/src/modules/webhooks/dto/generic-webhook.dto.js +12 -0
- package/node_modules/@prismalens/api/dist/src/modules/webhooks/webhooks.controller.js +7 -1
- package/node_modules/@prismalens/api/dist/src/modules/webhooks/webhooks.module.js +2 -0
- package/node_modules/@prismalens/api/dist/src/modules/webhooks/webhooks.service.js +103 -41
- package/node_modules/@prismalens/api/dist/src/shared/utils/literal-like.js +5 -0
- package/node_modules/@prismalens/api/public/THIRD_PARTY_NOTICES.txt +381 -3
- package/node_modules/@prismalens/api/public/assets/AddProjectDialog-BEBKziDJ.js +1 -0
- package/node_modules/@prismalens/api/public/assets/AgentDetail-DNNZ2RSQ.js +6 -0
- package/node_modules/@prismalens/api/public/assets/AlertsBlank-M7HkWlgo.js +1 -0
- package/node_modules/@prismalens/api/public/assets/Composer-MAXlRLhF.js +1 -0
- package/node_modules/@prismalens/api/public/assets/CopyButton-DKP5JHET.js +1 -0
- package/node_modules/@prismalens/api/public/assets/HelperThread-BmGnmkL5.js +1 -0
- package/node_modules/@prismalens/api/public/assets/Hint-BCpVhAvV.js +1 -0
- package/node_modules/@prismalens/api/public/assets/HomeComposer-BI6Vhge8.js +1 -0
- package/node_modules/@prismalens/api/public/assets/HypothesesCard-HKxfxVbG.js +1 -0
- package/node_modules/@prismalens/api/public/assets/IncidentHeader-BIYafwD0.js +2 -0
- package/node_modules/@prismalens/api/public/assets/KeptWorkspaces-ozJb7lRG.js +1 -0
- package/node_modules/@prismalens/api/public/assets/MergeDialog-DRjChRQQ.js +1 -0
- package/node_modules/@prismalens/api/public/assets/NewThread-HisGwIRc.js +2 -0
- package/node_modules/@prismalens/api/public/assets/PageHeader-CL1AN9BA.js +1 -0
- package/node_modules/@prismalens/api/public/assets/PanelShell-BHpdPx3P.js +1 -0
- package/node_modules/@prismalens/api/public/assets/ProjectList-lAMigyat.js +1 -0
- package/node_modules/@prismalens/api/public/assets/ResolveDialog-DbMNHrwo.js +1 -0
- package/node_modules/@prismalens/api/public/assets/RingTick-DkMvLoUV.js +1 -0
- package/node_modules/@prismalens/api/public/assets/Row-B3HLhwlw.js +1 -0
- package/node_modules/@prismalens/api/public/assets/RunStrip-CLaYEj2D.js +1 -0
- package/node_modules/@prismalens/api/public/assets/RunsMenu-CD4Yy4jT.js +1 -0
- package/node_modules/@prismalens/api/public/assets/ScheduleDialog-DPYtmK0g.js +2 -0
- package/node_modules/@prismalens/api/public/assets/ServiceFormDialog-9-qDnObk.js +1 -0
- package/node_modules/@prismalens/api/public/assets/SettingsFrame-D4eE2n4w.js +1 -0
- package/node_modules/@prismalens/api/public/assets/State-CCKzehkH.js +1 -0
- package/node_modules/@prismalens/api/public/assets/SubagentPane-exGNOprU.js +1574 -0
- package/node_modules/@prismalens/api/public/assets/TickDot-m_aEzdkj.js +1 -0
- package/node_modules/@prismalens/api/public/assets/Transcript-2ke3pjya.js +159 -0
- package/node_modules/@prismalens/api/public/assets/TriggerCard-BIAznpA9.js +1 -0
- package/node_modules/@prismalens/api/public/assets/WebhookCopy-C8w9xwD6.js +1 -0
- package/node_modules/@prismalens/api/public/assets/{WorkspaceFields-CiyyjkGf.js → WorkspaceFields-DCSJCThm.js} +6 -6
- package/node_modules/@prismalens/api/public/assets/___design-8brlEBqd.js +1 -0
- package/node_modules/@prismalens/api/public/assets/_authenticated-BETuqAeS.js +22 -0
- package/node_modules/@prismalens/api/public/assets/_authenticated-BVT266zx.js +1 -0
- package/node_modules/@prismalens/api/public/assets/_authenticated-BrP-ENHg.css +1 -0
- package/node_modules/@prismalens/api/public/assets/_id-B8v8uWe_.js +1 -0
- package/node_modules/@prismalens/api/public/assets/_id-BeO8QWfB.js +1 -0
- package/node_modules/@prismalens/api/public/assets/_id-Cnh_sXTf.js +1 -0
- package/node_modules/@prismalens/api/public/assets/_id-Crvjv3cl.js +1 -0
- package/node_modules/@prismalens/api/public/assets/_id-DiQnst4D.js +1 -0
- package/node_modules/@prismalens/api/public/assets/_id-VgE-Xeq5.js +1 -0
- package/node_modules/@prismalens/api/public/assets/_id-y5y3CxjT.js +1 -0
- package/node_modules/@prismalens/api/public/assets/_id_.runs._runId-U4P5LH-M.js +1 -0
- package/node_modules/@prismalens/api/public/assets/alerts-BI1l8Cxn.js +1 -0
- package/node_modules/@prismalens/api/public/assets/app-DmCziBS9.css +2 -0
- package/node_modules/@prismalens/api/public/assets/automation-FhFtuS5_.js +1 -0
- package/node_modules/@prismalens/api/public/assets/boxes-Dh2QZfJa.js +1 -0
- package/node_modules/@prismalens/api/public/assets/button-DmIfWVZ8.js +1 -0
- package/node_modules/@prismalens/api/public/assets/check-DfKru7HJ.js +1 -0
- package/node_modules/@prismalens/api/public/assets/chevron-left-DWLaEwl8.js +1 -0
- package/node_modules/@prismalens/api/public/assets/chevron-right-tPbGnTHi.js +1 -0
- package/node_modules/@prismalens/api/public/assets/circle-BqIhGHXt.js +1 -0
- package/node_modules/@prismalens/api/public/assets/command-chip-5Lf0FARB.js +1 -0
- package/node_modules/@prismalens/api/public/assets/conversation-CXkaesO_.js +1 -0
- package/node_modules/@prismalens/api/public/assets/copy-BUnkkIK-.js +1 -0
- package/node_modules/@prismalens/api/public/assets/desktop-Bqso9PNq.js +9 -0
- package/node_modules/@prismalens/api/public/assets/{device-name-uZQ3wSgk.js → device-name-CZPntaj6.js} +1 -1
- package/node_modules/@prismalens/api/public/assets/dist-CQz4Osl1.js +1 -0
- package/node_modules/@prismalens/api/public/assets/dist-CYLssYEL.js +1 -0
- package/node_modules/@prismalens/api/public/assets/dropdown-menu-Db9u3UIb.js +1 -0
- package/node_modules/@prismalens/api/public/assets/ellipsis-d1vABf4v.js +1 -0
- package/node_modules/@prismalens/api/public/assets/evidence-files-C9UcJR1J.js +1 -0
- package/node_modules/@prismalens/api/public/assets/fixes-CgjsPkfr.js +1 -0
- package/node_modules/@prismalens/api/public/assets/folder-git-2-DRsiaeAx.js +1 -0
- package/node_modules/@prismalens/api/public/assets/globe-D2S-zGel.js +1 -0
- package/node_modules/@prismalens/api/public/assets/harness-CokJrRXZ.js +55 -0
- package/node_modules/@prismalens/api/public/assets/highlighted-body-JLMTFACH-B_v9yJZa.js +1 -0
- package/node_modules/@prismalens/api/public/assets/incidents-B0KnIveX.js +1 -0
- package/node_modules/@prismalens/api/public/assets/index-DZMj9YK4.js +23 -0
- package/node_modules/@prismalens/api/public/assets/input-CXxt1dAV.js +1 -0
- package/node_modules/@prismalens/api/public/assets/key-CjFGD02m.js +1 -0
- package/node_modules/@prismalens/api/public/assets/lazyRouteComponent-DkcTE9Kh.js +1 -0
- package/node_modules/@prismalens/api/public/assets/live-refresh-C5Jfxdxb.js +1 -0
- package/node_modules/@prismalens/api/public/assets/mermaid-WFAXDIZX-CqliGVff.js +1 -0
- package/node_modules/@prismalens/api/public/assets/needs-find-DPugLWCN.js +1 -0
- package/node_modules/@prismalens/api/public/assets/new-Ci475pgf.js +1 -0
- package/node_modules/@prismalens/api/public/assets/pair-CobM73_c.js +1 -0
- package/node_modules/@prismalens/api/public/assets/pencil-BwNhunJy.js +1 -0
- package/node_modules/@prismalens/api/public/assets/plus-DWSahnrj.js +1 -0
- package/node_modules/@prismalens/api/public/assets/preload-helper-BLdHbfdN.js +1 -0
- package/node_modules/@prismalens/api/public/assets/projects-CIckRlw8.js +1 -0
- package/node_modules/@prismalens/api/public/assets/record-context-CoIOStXx.js +1 -0
- package/node_modules/@prismalens/api/public/assets/restart-40l7XMmi.js +1 -0
- package/node_modules/@prismalens/api/public/assets/route-Bg17GbpR.js +1 -0
- package/node_modules/@prismalens/api/public/assets/route-DX3TI7JD.js +1 -0
- package/node_modules/@prismalens/api/public/assets/route-Dvao2bBW.js +1 -0
- package/node_modules/@prismalens/api/public/assets/{route-CCkTDfa6.js → route-ah1SnYbH.js} +1 -1
- package/node_modules/@prismalens/api/public/assets/run-details-DTzMO1X0.js +1 -0
- package/node_modules/@prismalens/api/public/assets/run-labels-ubQZmnqd.js +2 -0
- package/node_modules/@prismalens/api/public/assets/select-98_n4DVz.js +1 -0
- package/node_modules/@prismalens/api/public/assets/service-detail.utils-ulWHS1Ao.js +1 -0
- package/node_modules/@prismalens/api/public/assets/service-lanes-BfHIrySn.js +1 -0
- package/node_modules/@prismalens/api/public/assets/services-CZQMzqYj.js +1 -0
- package/node_modules/@prismalens/api/public/assets/settings-QPxeIS82.js +1 -0
- package/node_modules/@prismalens/api/public/assets/source-words-B5oOdiQU.js +4 -0
- package/node_modules/@prismalens/api/public/assets/state-tone-DEsvSFn6.js +1 -0
- package/node_modules/@prismalens/api/public/assets/strip-inline-markdown-d6Movgzo.js +1 -0
- package/node_modules/@prismalens/api/public/assets/switch-DpPkkZxw.js +1 -0
- package/node_modules/@prismalens/api/public/assets/theme-provider-C9jvt7JX.js +1 -0
- package/node_modules/@prismalens/api/public/assets/threads-BqAHgCGd.js +1 -0
- package/node_modules/@prismalens/api/public/assets/tick-copy-B7dbIrfQ.js +1 -0
- package/node_modules/@prismalens/api/public/assets/trigger-DVo1oKMX.js +1 -0
- package/node_modules/@prismalens/api/public/assets/{use-back-VWIQYM2j.js → use-back-R0oWqfab.js} +1 -1
- package/node_modules/@prismalens/api/public/assets/use-operator-BH6GxjAY.js +1 -0
- package/node_modules/@prismalens/api/public/assets/use-repositories-orpc-c6hPOKjE.js +41 -0
- package/node_modules/@prismalens/api/public/assets/use-threads-orpc-rBrvQXJf.js +1 -0
- package/node_modules/@prismalens/api/public/assets/useInvestigationRun-xdB0R08B.js +1 -0
- package/node_modules/@prismalens/api/public/assets/useLocation-CXMqJKgu.js +1 -0
- package/node_modules/@prismalens/api/public/assets/{useSearch-Bq5sxYI3.js → useMatch-B0f9tdXB.js} +1 -1
- package/node_modules/@prismalens/api/public/assets/useQueries-CGpidxif.js +1 -0
- package/node_modules/@prismalens/api/public/assets/useSearch-BBl0vmEJ.js +1 -0
- package/node_modules/@prismalens/api/public/index.html +5 -3
- package/node_modules/@prismalens/auth/dist/index.js +2 -1
- package/node_modules/@prismalens/auth/dist/pairing.js +31 -6
- package/node_modules/@prismalens/auth/dist/terminal-key.js +25 -0
- package/node_modules/@prismalens/config/dist/acp-registry.json +151 -103
- package/node_modules/@prismalens/config/dist/index.js +3 -0
- package/node_modules/@prismalens/config/dist/providers/harness.js +61 -6
- package/node_modules/@prismalens/config/dist/utils/app-data.js +14 -13
- package/node_modules/@prismalens/config/dist/utils/background-service.js +9 -4
- package/node_modules/@prismalens/config/dist/utils/diagnostics.js +247 -0
- package/node_modules/@prismalens/config/dist/utils/node-version.js +29 -0
- package/node_modules/@prismalens/config/dist/utils/update-install.js +160 -0
- package/node_modules/@prismalens/contracts/dist/contracts/composer.js +70 -0
- package/node_modules/@prismalens/contracts/dist/contracts/incidents.js +3 -2
- package/node_modules/@prismalens/contracts/dist/contracts/index.js +16 -0
- package/node_modules/@prismalens/contracts/dist/contracts/investigations.js +184 -2
- package/node_modules/@prismalens/contracts/dist/contracts/live.js +8 -1
- package/node_modules/@prismalens/contracts/dist/contracts/pairing.js +6 -0
- package/node_modules/@prismalens/contracts/dist/contracts/push.js +1 -1
- package/node_modules/@prismalens/contracts/dist/contracts/repositories.js +41 -1
- package/node_modules/@prismalens/contracts/dist/contracts/run-workspaces.js +11 -0
- package/node_modules/@prismalens/contracts/dist/contracts/schedules.js +84 -0
- package/node_modules/@prismalens/contracts/dist/contracts/settings.js +99 -1
- package/node_modules/@prismalens/contracts/dist/contracts/sources.js +19 -19
- package/node_modules/@prismalens/contracts/dist/contracts/terminal.js +43 -0
- package/node_modules/@prismalens/contracts/dist/contracts/thread-tree.js +87 -0
- package/node_modules/@prismalens/contracts/dist/contracts/threads.js +239 -0
- package/node_modules/@prismalens/contracts/dist/schemas/ask-projection.js +107 -0
- package/node_modules/@prismalens/contracts/dist/schemas/asks.js +211 -0
- package/node_modules/@prismalens/contracts/dist/schemas/composer.js +139 -0
- package/node_modules/@prismalens/contracts/dist/schemas/context-pack.js +6 -2
- package/node_modules/@prismalens/contracts/dist/schemas/impact.js +2 -0
- package/node_modules/@prismalens/contracts/dist/schemas/incident.js +29 -2
- package/node_modules/@prismalens/contracts/dist/schemas/index.js +12 -0
- package/node_modules/@prismalens/contracts/dist/schemas/investigation.js +642 -39
- package/node_modules/@prismalens/contracts/dist/schemas/pull-request.js +176 -0
- package/node_modules/@prismalens/contracts/dist/schemas/recommendation.js +2 -1
- package/node_modules/@prismalens/contracts/dist/schemas/references.js +104 -0
- package/node_modules/@prismalens/contracts/dist/schemas/repository.js +69 -2
- package/node_modules/@prismalens/contracts/dist/schemas/run-views.js +168 -0
- package/node_modules/@prismalens/contracts/dist/schemas/schedule.js +172 -0
- package/node_modules/@prismalens/contracts/dist/schemas/service.js +4 -1
- package/node_modules/@prismalens/contracts/dist/schemas/settings.js +101 -1
- package/node_modules/@prismalens/contracts/dist/schemas/source-type.js +25 -1
- package/node_modules/@prismalens/contracts/dist/schemas/subagents.js +31 -0
- package/node_modules/@prismalens/contracts/dist/schemas/terminal.js +78 -0
- package/node_modules/@prismalens/contracts/dist/schemas/thread-context.js +222 -0
- package/node_modules/@prismalens/contracts/dist/schemas/thread-tree.js +172 -0
- package/node_modules/@prismalens/contracts/dist/schemas/thread.js +159 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/internal/class.js +4 -4
- package/node_modules/@prismalens/database/dist/prisma/generated/internal/prismaNamespace.js +231 -1
- package/node_modules/@prismalens/database/dist/prisma/generated/models/CheckoutLease.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/ComposerDraft.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/PendingAction.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/PrWatch.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/Proposal.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/PullRequest.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/ReferenceUse.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/Schedule.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/ScheduleEvent.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/ScheduleTick.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/SecretRequested.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/SubagentSession.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/ThreadMessage.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/ThreadWait.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/ThreadWake.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/ToolAsk.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/generated/models/TreeAllowance.js +2 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261028083515_scheduled_tasks/migration.sql +148 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261102044114_investigation_service_set_null/migration.sql +57 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261102202000_thread_subjects/migration.sql +78 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261103010000_thread_list/migration.sql +3 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261103090000_thread_titles/migration.sql +2 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261103200000_helper_place/migration.sql +2 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261104010000_project_kinds/migration.sql +3 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261104200000_schedule_subjects/migration.sql +41 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261107100000_composer/migration.sql +40 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261107110000_session_wake/migration.sql +26 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261107120000_thread_context/migration.sql +32 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261107130000_app_sources/migration.sql +4 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261107140000_thread_tree/migration.sql +166 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261108100000_subagents/migration.sql +51 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/20261108110000_in_place/migration.sql +15 -0
- package/node_modules/@prismalens/database/dist/prisma/sqlite/schema/app.prisma +391 -7
- package/node_modules/@prismalens/engine/dist/adapter/acp-adapter.js +380 -31
- package/node_modules/@prismalens/engine/dist/index.js +2 -0
- package/node_modules/@prismalens/engine/dist/launch/policy.js +29 -9
- package/node_modules/@prismalens/engine/dist/run/conductor.js +5 -1
- package/node_modules/@prismalens/engine/dist/run/elicitation.js +244 -0
- package/node_modules/@prismalens/engine/dist/run/fence.js +23 -5
- package/node_modules/@prismalens/engine/dist/run/findings.js +203 -0
- package/node_modules/@prismalens/engine/dist/run/handoff.js +86 -2
- package/node_modules/@prismalens/engine/dist/run/harness-doctor.js +46 -6
- package/node_modules/@prismalens/engine/dist/run/investigate.js +403 -57
- package/node_modules/@prismalens/engine/dist/run/local-default.js +13 -4
- package/node_modules/@prismalens/engine/dist/run/permission.js +192 -14
- package/node_modules/@prismalens/engine/dist/run/prompt.js +126 -12
- package/node_modules/@prismalens/engine/dist/run/redact.js +52 -0
- package/node_modules/@prismalens/engine/dist/run/usage-limit.js +91 -9
- package/node_modules/@prismalens/engine/dist/runner/acp-client.js +238 -16
- package/node_modules/@prismalens/integrations/dist/engine/oauth2-flow.js +12 -0
- package/node_modules/@prismalens/integrations/dist/harness/index.js +8 -0
- package/node_modules/@prismalens/integrations/dist/harness/mcp-server.js +60 -0
- package/node_modules/@prismalens/integrations/dist/harness/registry.js +127 -0
- package/node_modules/@prismalens/integrations/dist/harness/replay.js +67 -0
- package/node_modules/@prismalens/integrations/dist/harness/search.js +113 -0
- package/node_modules/@prismalens/integrations/dist/harness/tool.js +64 -0
- package/node_modules/@prismalens/integrations/dist/index.js +2 -0
- package/node_modules/@prismalens/integrations/dist/providers/host-repositories.js +193 -0
- package/node_modules/@prismalens/integrations/package.json +4 -0
- package/package.json +12 -5
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/core-4pv47a2z.mjs +0 -27
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/core-bz5kkzv0.mjs +0 -40
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/core-c86d180z.mjs +0 -52
- package/node_modules/@prismalens/agent-adapters/node_modules/@anthropic-ai/claude-agent-sdk/core-pzfwbvz7.mjs +0 -26
- package/node_modules/@prismalens/api/dist/src/modules/gateway/mcp-delivery.js +0 -39
- package/node_modules/@prismalens/api/public/assets/Field-BQic-QnX.js +0 -1
- package/node_modules/@prismalens/api/public/assets/Hint-B9ocVmjH.js +0 -41
- package/node_modules/@prismalens/api/public/assets/KeptWorkspaces-mrbq8M-h.js +0 -1
- package/node_modules/@prismalens/api/public/assets/MergeDialog-BO_TSjSe.js +0 -1
- package/node_modules/@prismalens/api/public/assets/NewIncident-DWw1jRp3.js +0 -1
- package/node_modules/@prismalens/api/public/assets/PageHeader-DmwtlO5o.js +0 -1
- package/node_modules/@prismalens/api/public/assets/ResolveDialog-nVfxRJOp.js +0 -1
- package/node_modules/@prismalens/api/public/assets/RunsMenu-DrVYxtD6.js +0 -3
- package/node_modules/@prismalens/api/public/assets/ServiceFormDialog-CM8ibEPP.js +0 -1
- package/node_modules/@prismalens/api/public/assets/_authenticated-BIX9FmcY.js +0 -1
- package/node_modules/@prismalens/api/public/assets/_authenticated-g2XLlfqP.js +0 -1
- package/node_modules/@prismalens/api/public/assets/_id-Bs75xuEI.js +0 -1
- package/node_modules/@prismalens/api/public/assets/_id-CbGZLynL.js +0 -1
- package/node_modules/@prismalens/api/public/assets/_id-D7TdCttn.js +0 -1
- package/node_modules/@prismalens/api/public/assets/_id-asM5UbQq.js +0 -1
- package/node_modules/@prismalens/api/public/assets/alerts-C2Ii6YGg.js +0 -1
- package/node_modules/@prismalens/api/public/assets/app-DpX-DlR8.css +0 -2
- package/node_modules/@prismalens/api/public/assets/button-BX6aOWvu.js +0 -1
- package/node_modules/@prismalens/api/public/assets/conversation-MWIw1Mcu.js +0 -461
- package/node_modules/@prismalens/api/public/assets/desktop-CcO1sAJv.js +0 -63
- package/node_modules/@prismalens/api/public/assets/dist-NPKXzqzH.js +0 -1
- package/node_modules/@prismalens/api/public/assets/dropdown-menu-C2eZATbR.js +0 -1
- package/node_modules/@prismalens/api/public/assets/fixes-qbD9HTI7.js +0 -1
- package/node_modules/@prismalens/api/public/assets/format-time-CGRUxfR2.js +0 -1
- package/node_modules/@prismalens/api/public/assets/get-error-message-XWlcOfOx.js +0 -1
- package/node_modules/@prismalens/api/public/assets/highlighted-body-JLMTFACH-DrFHe1nT.js +0 -1
- package/node_modules/@prismalens/api/public/assets/incident-attention-DvrvH6ZE.js +0 -1
- package/node_modules/@prismalens/api/public/assets/incidents-tNIOIUJ9.js +0 -1
- package/node_modules/@prismalens/api/public/assets/index-Bkua5FuI.js +0 -26
- package/node_modules/@prismalens/api/public/assets/loader-circle-BxgKP4dD.js +0 -1
- package/node_modules/@prismalens/api/public/assets/mermaid-WFAXDIZX-BJN6kGuM.js +0 -1
- package/node_modules/@prismalens/api/public/assets/pair-CyzQzNhd.js +0 -1
- package/node_modules/@prismalens/api/public/assets/plus-C-sWiVlr.js +0 -1
- package/node_modules/@prismalens/api/public/assets/route-9A2eeVtZ.js +0 -1
- package/node_modules/@prismalens/api/public/assets/route-BpObCIuc.js +0 -1
- package/node_modules/@prismalens/api/public/assets/route-CAqkvl37.js +0 -1
- package/node_modules/@prismalens/api/public/assets/services-B9GdE4hP.js +0 -1
- package/node_modules/@prismalens/api/public/assets/settings-DsCNpTCk.js +0 -1
- package/node_modules/@prismalens/api/public/assets/state-tone-B3RGc3XM.js +0 -1
- package/node_modules/@prismalens/api/public/assets/switch-UJRRev_z.js +0 -3
- package/node_modules/@prismalens/api/public/assets/use-first-open-rsFZV7FY.js +0 -1
- package/node_modules/@prismalens/api/public/assets/useInvestigationRun-7torOSoz.js +0 -1
- package/node_modules/@prismalens/api/public/assets/useLocation-D-akr70j.js +0 -1
|
@@ -10,64 +10,179 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
|
+
import { readFile, realpath, stat } from "node:fs/promises";
|
|
14
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
13
15
|
import { createMcpHandler } from "@modelcontextprotocol/server";
|
|
14
16
|
import { Injectable, Optional } from "@nestjs/common";
|
|
15
|
-
import { HttpAdapterHost } from "@nestjs/core";
|
|
16
|
-
import {
|
|
17
|
+
import { HttpAdapterHost, ModuleRef } from "@nestjs/core";
|
|
18
|
+
import { HARNESS_REGISTRY } from "@prismalens/config/harness";
|
|
19
|
+
import { INVESTIGATION_DEFAULTS } from "@prismalens/config/investigation";
|
|
20
|
+
import { FixVerdictSchema, InvestigationReportSchema, isWorkflowLive, RunUsageSchema, RunWorkspaceSchema, } from "@prismalens/contracts/schemas";
|
|
21
|
+
import { FindingsLedger, quoteLine, } from "@prismalens/engine";
|
|
22
|
+
import { autoAllowed, fail, harnessMcpServer, harnessPromptLine, runView, servedTo, } from "@prismalens/integrations/harness";
|
|
17
23
|
import { Logger } from "@prismalens/logger";
|
|
18
24
|
import { PrismaService } from "../../core/prisma/prisma.service.js";
|
|
19
25
|
import { safeParseJsonObject } from "../../shared/utils/json-utils.js";
|
|
20
|
-
import {
|
|
26
|
+
import { resolveServiceVersion } from "../../shared/utils/service-version.js";
|
|
27
|
+
import { attachmentsDir } from "../investigations/attachments.service.js";
|
|
28
|
+
import { setAgentTitle } from "../threads/thread-titles.js";
|
|
21
29
|
import { bearerOf, RunTokens } from "./run-tokens.js";
|
|
22
30
|
import { listRunbooks, readRunbook, } from "./runbooks.js";
|
|
23
|
-
import {
|
|
31
|
+
import { gatewayTools, THREAD_WATCHES, TOOL_ASKS, } from "./tools/index.js";
|
|
24
32
|
export const GATEWAY_ROUTE = "mcp/runs/:runId";
|
|
25
33
|
const RUNBOOKS_SETTING = "sources.runbooks.enabled";
|
|
26
34
|
const CHANGES_BEFORE_MS = 24 * 3_600_000;
|
|
27
35
|
const CHANGES_TAKE = 20;
|
|
28
36
|
const INDEX_REPOS = 5;
|
|
29
37
|
const INDEX_ENTRIES = 50;
|
|
38
|
+
const THREAD_STEPS = 20;
|
|
39
|
+
const THREAD_STEP_ROWS = 60;
|
|
40
|
+
const STEP_CHARS = 1_000;
|
|
41
|
+
const TIMELINE_TEXT_CHARS = 500;
|
|
42
|
+
const SERVICE_LINKS = 50;
|
|
43
|
+
const ATTACHMENTS_LISTED = 100;
|
|
44
|
+
const FIX_CHECK_ROWS = 500;
|
|
45
|
+
function parseWith(schema, raw) {
|
|
46
|
+
if (!raw)
|
|
47
|
+
return null;
|
|
48
|
+
try {
|
|
49
|
+
const r = schema.safeParse(JSON.parse(raw));
|
|
50
|
+
return r.success ? r.data : null;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function changeFacts(metadata) {
|
|
57
|
+
const meta = safeParseJsonObject(metadata) ?? {};
|
|
58
|
+
const env = meta.environment ?? meta.env;
|
|
59
|
+
return {
|
|
60
|
+
environment: typeof env === "string" ? env : null,
|
|
61
|
+
version: typeof meta.version === "string" ? meta.version : null,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function ownedBy(scope) {
|
|
65
|
+
const ids = scope.serviceIds;
|
|
66
|
+
return [
|
|
67
|
+
...(scope.repositoryId ? [{ repositoryId: scope.repositoryId }] : []),
|
|
68
|
+
...(ids.length
|
|
69
|
+
? [{ serviceId: { in: ids } }, { incident: { serviceId: { in: ids } } }]
|
|
70
|
+
: []),
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
function inScope(scope, row) {
|
|
74
|
+
const ids = scope.serviceIds;
|
|
75
|
+
return ((!!scope.repositoryId && row.repositoryId === scope.repositoryId) ||
|
|
76
|
+
(!!row.serviceId && ids.includes(row.serviceId)) ||
|
|
77
|
+
(!!row.incident?.serviceId && ids.includes(row.incident.serviceId)));
|
|
78
|
+
}
|
|
79
|
+
const filesOf = (runId, incident) => incident ? { incidentId: incident.id } : { investigationId: runId };
|
|
30
80
|
const logger = new Logger({ context: "Gateway" });
|
|
81
|
+
const NO_TOOLS = { direct: [], deferred: [] };
|
|
82
|
+
const TREE_TOOLS = new Set([
|
|
83
|
+
"thread_start",
|
|
84
|
+
"thread_send",
|
|
85
|
+
"thread_wait",
|
|
86
|
+
"thread_cancel",
|
|
87
|
+
"thread_roster",
|
|
88
|
+
]);
|
|
89
|
+
const NO_TREE = () => fail("disabled", "Thread trees are not running in this PrismaLens.", "Do the work in this thread.");
|
|
90
|
+
const QUOTE_FILE_BYTES = 2_000_000;
|
|
91
|
+
const ARTIFACTS_PER_RUN = 20;
|
|
92
|
+
const NOT_LIVE = "This run is not live, so nothing can be recorded on it";
|
|
93
|
+
const NO_HISTORY = "PrismaLens could not read what this run recorded earlier, so nothing was recorded; retry this call";
|
|
94
|
+
const LISTEN_WAIT_MS = 60_000;
|
|
31
95
|
let GatewayService = class GatewayService {
|
|
32
96
|
prisma;
|
|
33
97
|
http;
|
|
98
|
+
moduleRef;
|
|
34
99
|
tokens = new RunTokens();
|
|
100
|
+
treePort;
|
|
35
101
|
runs = new Map();
|
|
36
|
-
|
|
37
|
-
|
|
102
|
+
toolSearch = (harness) => !!harness &&
|
|
103
|
+
HARNESS_REGISTRY[harness]
|
|
104
|
+
?.harnessToolSearch === true;
|
|
105
|
+
tools;
|
|
106
|
+
version = resolveServiceVersion();
|
|
107
|
+
handler = createMcpHandler(({ authInfo }) => {
|
|
108
|
+
const runId = authInfo?.clientId ?? "";
|
|
109
|
+
return harnessMcpServer({
|
|
110
|
+
runId,
|
|
111
|
+
view: this.runs.get(runId)?.view ?? NO_TOOLS,
|
|
112
|
+
version: this.version,
|
|
113
|
+
onCall: (call) => this.called(runId, call),
|
|
114
|
+
});
|
|
115
|
+
}, {
|
|
38
116
|
responseMode: "json",
|
|
39
117
|
onerror: (e) => logger.warn(`gateway: ${e.message}`),
|
|
40
118
|
});
|
|
41
|
-
constructor(prisma, http) {
|
|
119
|
+
constructor(prisma, http, moduleRef) {
|
|
42
120
|
this.prisma = prisma;
|
|
43
121
|
this.http = http;
|
|
44
|
-
this.
|
|
122
|
+
this.moduleRef = moduleRef;
|
|
123
|
+
this.tools = gatewayTools(this.data);
|
|
124
|
+
}
|
|
125
|
+
bindTree(port) {
|
|
126
|
+
this.treePort = port;
|
|
45
127
|
}
|
|
46
|
-
async lease(runId, serverName) {
|
|
47
|
-
const base = this.
|
|
128
|
+
async lease(runId, serverName, harness, turnStartedAt, scope = {}) {
|
|
129
|
+
const base = await this.listeningBaseUrl();
|
|
48
130
|
if (!base)
|
|
49
131
|
return null;
|
|
132
|
+
const tree = await this.treeView(runId);
|
|
50
133
|
const token = this.tokens.mint(runId);
|
|
51
134
|
const state = {
|
|
52
135
|
connected: false,
|
|
53
136
|
waiters: new Set(),
|
|
54
137
|
calls: new Map(),
|
|
55
138
|
listeners: new Set(),
|
|
139
|
+
log: [],
|
|
140
|
+
ledger: new FindingsLedger(),
|
|
141
|
+
found: new Set(),
|
|
142
|
+
artifacts: [],
|
|
143
|
+
published: new Set(),
|
|
144
|
+
recording: true,
|
|
145
|
+
view: runView(servedTo(this.tools, { ...scope, tree: tree.member }).filter((t) => !(tree.actsOff &&
|
|
146
|
+
(t.effect === "act" || t.name === "thread_send")) && !(tree.actsOff && !tree.member && TREE_TOOLS.has(t.name))), { search: this.toolSearch(harness) }),
|
|
147
|
+
turnStartedAt,
|
|
56
148
|
};
|
|
57
149
|
this.runs.set(runId, state);
|
|
58
|
-
const tools =
|
|
150
|
+
const tools = [...state.view.direct, ...state.view.deferred].map((t) => t.name);
|
|
59
151
|
return {
|
|
60
152
|
url: `${base}/api/mcp/runs/${runId}`,
|
|
61
153
|
token,
|
|
62
154
|
serverName,
|
|
63
|
-
promptLine:
|
|
155
|
+
promptLine: harnessPromptLine(state.view, serverName),
|
|
64
156
|
tools,
|
|
157
|
+
autoAllow: autoAllowed(state.view),
|
|
65
158
|
connected: () => state.connected,
|
|
66
159
|
onCall: (listener) => {
|
|
67
160
|
state.listeners.add(listener);
|
|
68
161
|
return () => state.listeners.delete(listener);
|
|
69
162
|
},
|
|
70
163
|
calls: () => [...state.calls.values()].map((c) => ({ ...c })),
|
|
164
|
+
sawOutput: (toolCallId, text) => {
|
|
165
|
+
for (const e of state.ledger.sawOutput(toolCallId, text))
|
|
166
|
+
this.recorded(state, { type: "evidence", ...e });
|
|
167
|
+
},
|
|
168
|
+
restore: async (load) => {
|
|
169
|
+
state.history = load;
|
|
170
|
+
await this.loadHistory(state);
|
|
171
|
+
},
|
|
172
|
+
onFinding: (listener) => {
|
|
173
|
+
state.found.add(listener);
|
|
174
|
+
return () => state.found.delete(listener);
|
|
175
|
+
},
|
|
176
|
+
findings: () => state.ledger.snapshot(),
|
|
177
|
+
closeRecording: () => {
|
|
178
|
+
state.recording = false;
|
|
179
|
+
},
|
|
180
|
+
artifacts: () => [...state.artifacts],
|
|
181
|
+
callLog: () => [...state.log],
|
|
182
|
+
onArtifact: (listener) => {
|
|
183
|
+
state.published.add(listener);
|
|
184
|
+
return () => state.published.delete(listener);
|
|
185
|
+
},
|
|
71
186
|
waitConnected: (ms) => state.connected
|
|
72
187
|
? Promise.resolve(true)
|
|
73
188
|
: new Promise((resolve) => {
|
|
@@ -81,6 +196,16 @@ let GatewayService = class GatewayService {
|
|
|
81
196
|
}),
|
|
82
197
|
};
|
|
83
198
|
}
|
|
199
|
+
async treeView(runId) {
|
|
200
|
+
const row = await this.prisma.investigation.findUnique({
|
|
201
|
+
where: { id: runId },
|
|
202
|
+
select: { rootId: true },
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
member: !!row?.rootId,
|
|
206
|
+
actsOff: this.treePort ? await this.treePort.actsOff() : true,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
84
209
|
revoke(runId) {
|
|
85
210
|
this.tokens.revoke(runId);
|
|
86
211
|
const state = this.runs.get(runId);
|
|
@@ -88,18 +213,68 @@ let GatewayService = class GatewayService {
|
|
|
88
213
|
for (const done of state?.waiters ?? [])
|
|
89
214
|
done(false);
|
|
90
215
|
state?.listeners.clear();
|
|
216
|
+
state?.found.clear();
|
|
217
|
+
state?.published.clear();
|
|
218
|
+
}
|
|
219
|
+
async loadHistory(state) {
|
|
220
|
+
const load = state.history;
|
|
221
|
+
if (!load)
|
|
222
|
+
return true;
|
|
223
|
+
state.loading ??= load()
|
|
224
|
+
.then((found) => {
|
|
225
|
+
state.ledger.restore(found);
|
|
226
|
+
state.history = undefined;
|
|
227
|
+
})
|
|
228
|
+
.finally(() => {
|
|
229
|
+
state.loading = undefined;
|
|
230
|
+
});
|
|
231
|
+
return state.loading.then(() => true, (e) => {
|
|
232
|
+
logger.warn(`gateway: could not read the run's recorded findings: ${e}`);
|
|
233
|
+
return false;
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
recorded(state, finding) {
|
|
237
|
+
for (const listener of [...state.found])
|
|
238
|
+
listener(finding);
|
|
239
|
+
}
|
|
240
|
+
async fileAnchor(runId, path, quote) {
|
|
241
|
+
const ws = await this.workspaceOf(runId);
|
|
242
|
+
if (!ws)
|
|
243
|
+
return null;
|
|
244
|
+
const file = isAbsolute(path) ? path : resolve(ws.cwd, path);
|
|
245
|
+
try {
|
|
246
|
+
const real = await realpath(file);
|
|
247
|
+
const roots = await Promise.all([ws.cwd, ...ws.repos.map((r) => r.dir)].map((d) => realpath(d).catch(() => null)));
|
|
248
|
+
const inside = roots.some((root) => {
|
|
249
|
+
if (!root)
|
|
250
|
+
return false;
|
|
251
|
+
const rel = relative(root, real);
|
|
252
|
+
return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel);
|
|
253
|
+
});
|
|
254
|
+
if (!inside)
|
|
255
|
+
return null;
|
|
256
|
+
const info = await stat(real);
|
|
257
|
+
if (!info.isFile() || info.size > QUOTE_FILE_BYTES)
|
|
258
|
+
return null;
|
|
259
|
+
const line = quoteLine(await readFile(real, "utf8"), quote);
|
|
260
|
+
return line ? { in: "file", path: file, line } : null;
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
91
265
|
}
|
|
92
|
-
called(runId,
|
|
266
|
+
called(runId, call) {
|
|
93
267
|
const state = this.runs.get(runId);
|
|
94
268
|
if (!state)
|
|
95
269
|
return;
|
|
96
|
-
const at =
|
|
270
|
+
const { name, at } = call;
|
|
271
|
+
state.log.push(call);
|
|
97
272
|
const seen = state.calls.get(name);
|
|
98
273
|
state.calls.set(name, seen
|
|
99
274
|
? { ...seen, count: seen.count + 1 }
|
|
100
275
|
: { name, firstCalledAt: at, count: 1 });
|
|
101
276
|
for (const listener of [...state.listeners])
|
|
102
|
-
listener(
|
|
277
|
+
listener(call);
|
|
103
278
|
}
|
|
104
279
|
async serve(runId, request) {
|
|
105
280
|
const token = bearerOf(request.headers.get("authorization"));
|
|
@@ -117,6 +292,25 @@ let GatewayService = class GatewayService {
|
|
|
117
292
|
authInfo: { token: token, clientId: runId, scopes: [] },
|
|
118
293
|
});
|
|
119
294
|
}
|
|
295
|
+
async listeningBaseUrl(waitMs = LISTEN_WAIT_MS) {
|
|
296
|
+
const now = this.baseUrl();
|
|
297
|
+
if (now)
|
|
298
|
+
return now;
|
|
299
|
+
const server = this.http?.httpAdapter?.getHttpServer?.();
|
|
300
|
+
if (!server?.once)
|
|
301
|
+
return null;
|
|
302
|
+
await new Promise((resolve) => {
|
|
303
|
+
const done = () => {
|
|
304
|
+
clearTimeout(timer);
|
|
305
|
+
server.off?.("listening", done);
|
|
306
|
+
resolve();
|
|
307
|
+
};
|
|
308
|
+
const timer = setTimeout(done, waitMs);
|
|
309
|
+
timer.unref?.();
|
|
310
|
+
server.once?.("listening", done);
|
|
311
|
+
});
|
|
312
|
+
return this.baseUrl();
|
|
313
|
+
}
|
|
120
314
|
baseUrl() {
|
|
121
315
|
const server = this.http?.httpAdapter?.getHttpServer?.();
|
|
122
316
|
const address = server?.address?.();
|
|
@@ -131,7 +325,44 @@ let GatewayService = class GatewayService {
|
|
|
131
325
|
: address.address;
|
|
132
326
|
return `${protocol}://${host}:${address.port}`;
|
|
133
327
|
}
|
|
328
|
+
toolAsks() {
|
|
329
|
+
try {
|
|
330
|
+
return (this.moduleRef?.get(TOOL_ASKS, { strict: false }) ?? null);
|
|
331
|
+
}
|
|
332
|
+
catch {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
watches() {
|
|
337
|
+
try {
|
|
338
|
+
return (this.moduleRef?.get(THREAD_WATCHES, { strict: false }) ??
|
|
339
|
+
null);
|
|
340
|
+
}
|
|
341
|
+
catch {
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
134
345
|
data = {
|
|
346
|
+
watches: {
|
|
347
|
+
wakeup: async (runId, delay, reason) => (await this.watches()?.wakeup(runId, delay, reason)) ?? {
|
|
348
|
+
error: "PrismaLens cannot schedule a wake here.",
|
|
349
|
+
},
|
|
350
|
+
link: async (runId, url) => (await this.watches()?.link(runId, url)) ?? {
|
|
351
|
+
error: "PrismaLens cannot link a pull request here.",
|
|
352
|
+
},
|
|
353
|
+
watch: async (runId, prId, until) => (await this.watches()?.watch(runId, prId, until)) ?? {
|
|
354
|
+
error: "PrismaLens cannot watch a pull request here.",
|
|
355
|
+
},
|
|
356
|
+
unwatch: async (runId, prId) => (await this.watches()?.unwatch(runId, prId)) ?? { stopped: false },
|
|
357
|
+
},
|
|
358
|
+
asks: {
|
|
359
|
+
question: async (runId, questions) => (await this.toolAsks()?.question(runId, questions)) ?? {
|
|
360
|
+
error: "PrismaLens cannot ask the user here.",
|
|
361
|
+
},
|
|
362
|
+
secret: async (runId, input) => (await this.toolAsks()?.secret(runId, input)) ?? {
|
|
363
|
+
error: "PrismaLens cannot ask the user here.",
|
|
364
|
+
},
|
|
365
|
+
},
|
|
135
366
|
runbooks: {
|
|
136
367
|
list: async (runId, service) => (await this.runbooksEnabled())
|
|
137
368
|
? listRunbooks(await this.runbookRepos(runId), { service })
|
|
@@ -141,10 +372,96 @@ let GatewayService = class GatewayService {
|
|
|
141
372
|
: {
|
|
142
373
|
ok: false,
|
|
143
374
|
error: "Runbook discovery is turned off in PrismaLens.",
|
|
375
|
+
disabled: true,
|
|
144
376
|
},
|
|
145
377
|
},
|
|
146
378
|
searchInvestigations: (q) => this.searchInvestigations(q),
|
|
147
379
|
incident: (q) => this.incident(q),
|
|
380
|
+
threads: {
|
|
381
|
+
list: (q) => this.listThreads(q),
|
|
382
|
+
read: (runId, threadId, page) => this.readThread(runId, threadId, page),
|
|
383
|
+
title: (runId, title) => setAgentTitle(this.prisma, runId, title),
|
|
384
|
+
},
|
|
385
|
+
incidentRecord: {
|
|
386
|
+
timeline: (runId, limit) => this.timeline(runId, limit),
|
|
387
|
+
scope: (runId) => this.changeScope(runId),
|
|
388
|
+
changes: (q) => this.changesIn(q),
|
|
389
|
+
},
|
|
390
|
+
service: (name) => this.serviceView(name),
|
|
391
|
+
runStatus: (runId) => this.runStatus(runId),
|
|
392
|
+
attachments: {
|
|
393
|
+
list: (runId) => this.attachmentsOf(runId),
|
|
394
|
+
read: (runId, id) => this.attachmentOf(runId, id),
|
|
395
|
+
},
|
|
396
|
+
tree: {
|
|
397
|
+
start: async (runId, input) => this.treePort ? this.treePort.tree.start(runId, input) : NO_TREE(),
|
|
398
|
+
send: async (runId, input) => this.treePort ? this.treePort.tree.send(runId, input) : NO_TREE(),
|
|
399
|
+
wait: async (runId, ids, mode) => this.treePort ? this.treePort.tree.wait(runId, ids, mode) : NO_TREE(),
|
|
400
|
+
cancel: async (runId, id, reason, requestId) => this.treePort
|
|
401
|
+
? this.treePort.tree.cancel(runId, id, reason, requestId)
|
|
402
|
+
: NO_TREE(),
|
|
403
|
+
roster: async (runId) => this.treePort ? this.treePort.tree.roster(runId) : NO_TREE(),
|
|
404
|
+
},
|
|
405
|
+
proposals: {
|
|
406
|
+
propose: async (runId, change, why) => this.treePort
|
|
407
|
+
? this.treePort.proposals.propose(runId, change, why)
|
|
408
|
+
: { error: "Proposals are not running in this PrismaLens." },
|
|
409
|
+
},
|
|
410
|
+
history: {
|
|
411
|
+
similar: (runId, limit) => this.similarTo(runId, limit),
|
|
412
|
+
fixes: (runId, limit) => this.pastFixes(runId, limit),
|
|
413
|
+
},
|
|
414
|
+
artifacts: {
|
|
415
|
+
publish: async (runId, page) => {
|
|
416
|
+
const state = this.runs.get(runId);
|
|
417
|
+
if (!state?.recording)
|
|
418
|
+
return { error: NOT_LIVE, ended: true };
|
|
419
|
+
if (state.artifacts.length >= ARTIFACTS_PER_RUN)
|
|
420
|
+
return {
|
|
421
|
+
error: `This run already holds ${ARTIFACTS_PER_RUN} pages`,
|
|
422
|
+
};
|
|
423
|
+
const artifact = {
|
|
424
|
+
id: `a${state.artifacts.length + 1}`,
|
|
425
|
+
...page,
|
|
426
|
+
at: new Date().toISOString(),
|
|
427
|
+
};
|
|
428
|
+
state.artifacts.push(artifact);
|
|
429
|
+
for (const listener of [...state.published])
|
|
430
|
+
listener(artifact);
|
|
431
|
+
return { id: artifact.id };
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
findings: {
|
|
435
|
+
recordEvidence: async (runId, input) => {
|
|
436
|
+
const state = this.runs.get(runId);
|
|
437
|
+
if (!state?.recording)
|
|
438
|
+
return { error: NOT_LIVE };
|
|
439
|
+
if (!(await this.loadHistory(state)))
|
|
440
|
+
return { error: NO_HISTORY };
|
|
441
|
+
const file = input.path
|
|
442
|
+
? await this.fileAnchor(runId, input.path, input.quote)
|
|
443
|
+
: null;
|
|
444
|
+
if (this.runs.get(runId) !== state || !state.recording)
|
|
445
|
+
return { error: NOT_LIVE };
|
|
446
|
+
const r = state.ledger.addEvidence(input, file, new Date().toISOString());
|
|
447
|
+
if (!("error" in r))
|
|
448
|
+
this.recorded(state, { type: "evidence", ...r });
|
|
449
|
+
return r;
|
|
450
|
+
},
|
|
451
|
+
recordHypothesis: async (runId, input) => {
|
|
452
|
+
const state = this.runs.get(runId);
|
|
453
|
+
if (!state?.recording)
|
|
454
|
+
return { error: NOT_LIVE };
|
|
455
|
+
if (!(await this.loadHistory(state)))
|
|
456
|
+
return { error: NO_HISTORY };
|
|
457
|
+
if (this.runs.get(runId) !== state || !state.recording)
|
|
458
|
+
return { error: NOT_LIVE };
|
|
459
|
+
const r = state.ledger.addHypothesis(input, new Date().toISOString());
|
|
460
|
+
if (!("error" in r))
|
|
461
|
+
this.recorded(state, { type: "hypothesis", ...r });
|
|
462
|
+
return r;
|
|
463
|
+
},
|
|
464
|
+
},
|
|
148
465
|
};
|
|
149
466
|
async runbookIndex(runId, signal) {
|
|
150
467
|
signal?.throwIfAborted();
|
|
@@ -167,29 +484,665 @@ let GatewayService = class GatewayService {
|
|
|
167
484
|
return row?.value !== "false";
|
|
168
485
|
}
|
|
169
486
|
async runbookRepos(runId) {
|
|
487
|
+
const ws = await this.workspaceOf(runId);
|
|
488
|
+
const project = !!(await this.scopeOf(runId))?.repositoryId;
|
|
489
|
+
return (ws?.repos ?? []).flatMap((r) => {
|
|
490
|
+
const services = r.services.length ? r.services : project ? [r.name] : [];
|
|
491
|
+
return services.length
|
|
492
|
+
? [
|
|
493
|
+
{
|
|
494
|
+
name: r.name,
|
|
495
|
+
dir: r.dir,
|
|
496
|
+
head: r.head,
|
|
497
|
+
subPath: r.subPath,
|
|
498
|
+
services,
|
|
499
|
+
},
|
|
500
|
+
]
|
|
501
|
+
: [];
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
async workspaceOf(runId) {
|
|
170
505
|
const row = await this.prisma.investigation.findUnique({
|
|
171
506
|
where: { id: runId },
|
|
172
507
|
select: { workspace: true },
|
|
173
508
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
509
|
+
return parseWith(RunWorkspaceSchema, row?.workspace);
|
|
510
|
+
}
|
|
511
|
+
async runIncident(runId) {
|
|
512
|
+
const row = await this.prisma.investigation.findUnique({
|
|
513
|
+
where: { id: runId },
|
|
514
|
+
select: {
|
|
515
|
+
incident: {
|
|
516
|
+
select: {
|
|
517
|
+
id: true,
|
|
518
|
+
number: true,
|
|
519
|
+
triggeredAt: true,
|
|
520
|
+
serviceId: true,
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
});
|
|
525
|
+
return row?.incident ?? null;
|
|
526
|
+
}
|
|
527
|
+
async serviceIdsOf(incidentId, serviceId) {
|
|
528
|
+
const alertServices = await this.prisma.alert.findMany({
|
|
529
|
+
where: { incidentId, serviceId: { not: null } },
|
|
530
|
+
select: { serviceId: true },
|
|
531
|
+
distinct: ["serviceId"],
|
|
532
|
+
});
|
|
533
|
+
return [
|
|
534
|
+
...new Set([serviceId, ...alertServices.map((a) => a.serviceId)].filter((id) => !!id)),
|
|
535
|
+
];
|
|
536
|
+
}
|
|
537
|
+
async scopeOf(runId) {
|
|
538
|
+
const row = await this.prisma.investigation.findUnique({
|
|
539
|
+
where: { id: runId },
|
|
540
|
+
select: {
|
|
541
|
+
serviceId: true,
|
|
542
|
+
repositoryId: true,
|
|
543
|
+
incident: {
|
|
544
|
+
select: {
|
|
545
|
+
id: true,
|
|
546
|
+
number: true,
|
|
547
|
+
triggeredAt: true,
|
|
548
|
+
serviceId: true,
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
});
|
|
553
|
+
if (!row)
|
|
554
|
+
return null;
|
|
555
|
+
if (row.incident)
|
|
556
|
+
return {
|
|
557
|
+
incident: row.incident,
|
|
558
|
+
repositoryId: null,
|
|
559
|
+
serviceIds: await this.serviceIdsOf(row.incident.id, row.incident.serviceId),
|
|
560
|
+
};
|
|
561
|
+
if (row.serviceId)
|
|
562
|
+
return {
|
|
563
|
+
incident: null,
|
|
564
|
+
repositoryId: null,
|
|
565
|
+
serviceIds: [row.serviceId],
|
|
566
|
+
};
|
|
567
|
+
if (!row.repositoryId)
|
|
568
|
+
return null;
|
|
569
|
+
const linked = await this.prisma.serviceRepository.findMany({
|
|
570
|
+
where: { repositoryId: row.repositoryId },
|
|
571
|
+
select: { serviceId: true },
|
|
572
|
+
});
|
|
573
|
+
return {
|
|
574
|
+
incident: null,
|
|
575
|
+
repositoryId: row.repositoryId,
|
|
576
|
+
serviceIds: [...new Set(linked.map((l) => l.serviceId))],
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
async listThreads(q) {
|
|
580
|
+
const scope = await this.scopeOf(q.runId);
|
|
581
|
+
if (!scope)
|
|
582
|
+
return { error: "This thread has no records to list threads from." };
|
|
583
|
+
const { incident } = scope;
|
|
584
|
+
let where = incident
|
|
585
|
+
? { id: { not: q.runId }, incidentId: incident.id }
|
|
586
|
+
: { id: { not: q.runId }, OR: ownedBy(scope) };
|
|
587
|
+
if (q.service) {
|
|
588
|
+
const service = await this.prisma.service.findUnique({
|
|
589
|
+
where: { name: q.service },
|
|
590
|
+
select: { id: true },
|
|
591
|
+
});
|
|
592
|
+
if (!service)
|
|
593
|
+
return { error: `PrismaLens has no service named "${q.service}".` };
|
|
594
|
+
if (!scope.serviceIds.includes(service.id))
|
|
595
|
+
return { error: `"${q.service}" is not a service of this thread.` };
|
|
596
|
+
where = incident
|
|
597
|
+
? { id: { not: q.runId }, incident: { serviceId: service.id } }
|
|
598
|
+
: {
|
|
599
|
+
id: { not: q.runId },
|
|
600
|
+
OR: [
|
|
601
|
+
{ serviceId: service.id },
|
|
602
|
+
{ incident: { serviceId: service.id } },
|
|
603
|
+
],
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
const rows = await this.prisma.investigation.findMany({
|
|
607
|
+
where,
|
|
608
|
+
orderBy: { createdAt: "desc" },
|
|
609
|
+
take: q.limit,
|
|
610
|
+
select: {
|
|
611
|
+
id: true,
|
|
612
|
+
kind: true,
|
|
613
|
+
status: true,
|
|
614
|
+
startedAt: true,
|
|
615
|
+
completedAt: true,
|
|
616
|
+
harness: true,
|
|
617
|
+
model: true,
|
|
618
|
+
summary: true,
|
|
619
|
+
},
|
|
620
|
+
});
|
|
621
|
+
return {
|
|
622
|
+
threads: rows.map((r) => ({
|
|
623
|
+
id: r.id,
|
|
624
|
+
kind: r.kind,
|
|
625
|
+
status: r.status,
|
|
626
|
+
startedAt: r.startedAt?.toISOString() ?? null,
|
|
627
|
+
finishedAt: r.completedAt?.toISOString() ?? null,
|
|
628
|
+
agent: r.harness,
|
|
629
|
+
model: r.model,
|
|
630
|
+
...(r.status === "completed" && r.summary
|
|
631
|
+
? { summary: r.summary }
|
|
632
|
+
: {}),
|
|
633
|
+
})),
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
async sameTree(a, b) {
|
|
637
|
+
const rows = await this.prisma.investigation.findMany({
|
|
638
|
+
where: { id: { in: [a, b] } },
|
|
639
|
+
select: { id: true, rootId: true },
|
|
640
|
+
});
|
|
641
|
+
const root = (id) => {
|
|
642
|
+
const r = rows.find((x) => x.id === id);
|
|
643
|
+
return r ? (r.rootId ?? r.id) : null;
|
|
644
|
+
};
|
|
645
|
+
return (rows.length === 2 && rows.some((r) => r.rootId) && root(a) === root(b));
|
|
646
|
+
}
|
|
647
|
+
async stepsPage(id, page) {
|
|
648
|
+
const rows = await this.prisma.investigationEvent.findMany({
|
|
649
|
+
where: {
|
|
650
|
+
investigationId: id,
|
|
651
|
+
seq: { gt: page.afterSeq ?? -1 },
|
|
652
|
+
event: { contains: '"kind":"agent_step"' },
|
|
653
|
+
},
|
|
654
|
+
orderBy: { seq: "asc" },
|
|
655
|
+
take: page.limit + 1,
|
|
656
|
+
select: { seq: true, event: true },
|
|
657
|
+
});
|
|
658
|
+
const steps = rows.slice(0, page.limit).flatMap((r) => {
|
|
659
|
+
const ev = safeParseJsonObject(r.event);
|
|
660
|
+
return typeof ev?.text === "string" && ev.text.trim()
|
|
661
|
+
? [{ seq: r.seq, text: ev.text.slice(0, STEP_CHARS) }]
|
|
662
|
+
: [];
|
|
663
|
+
});
|
|
664
|
+
const last = rows[Math.min(rows.length, page.limit) - 1];
|
|
665
|
+
return {
|
|
666
|
+
steps,
|
|
667
|
+
nextSeq: rows.length > page.limit && last ? last.seq : null,
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
async readThread(runId, threadId, page) {
|
|
671
|
+
const member = await this.sameTree(runId, threadId);
|
|
672
|
+
const view = await this.threadBody(runId, threadId, member);
|
|
673
|
+
if (!view)
|
|
674
|
+
return null;
|
|
675
|
+
return page && member
|
|
676
|
+
? { ...view, page: await this.stepsPage(view.id, page) }
|
|
677
|
+
: view;
|
|
678
|
+
}
|
|
679
|
+
async threadBody(runId, threadId, member) {
|
|
680
|
+
const scope = member ? null : await this.scopeOf(runId);
|
|
681
|
+
if (!scope && !member)
|
|
682
|
+
return null;
|
|
683
|
+
const row = await this.prisma.investigation.findUnique({
|
|
684
|
+
where: { id: threadId },
|
|
685
|
+
select: {
|
|
686
|
+
id: true,
|
|
687
|
+
kind: true,
|
|
688
|
+
status: true,
|
|
689
|
+
summary: true,
|
|
690
|
+
rootCause: true,
|
|
691
|
+
report: true,
|
|
692
|
+
error: true,
|
|
693
|
+
serviceId: true,
|
|
694
|
+
repositoryId: true,
|
|
695
|
+
incident: { select: { id: true, serviceId: true } },
|
|
696
|
+
},
|
|
697
|
+
});
|
|
698
|
+
if (!row)
|
|
699
|
+
return null;
|
|
700
|
+
const own = scope?.incident;
|
|
701
|
+
if (!scope) {
|
|
702
|
+
}
|
|
703
|
+
else if (own) {
|
|
704
|
+
if (!row.incident)
|
|
705
|
+
return null;
|
|
706
|
+
if (row.incident.id !== own.id &&
|
|
707
|
+
(!row.incident.serviceId ||
|
|
708
|
+
!scope.serviceIds.includes(row.incident.serviceId)))
|
|
709
|
+
return null;
|
|
710
|
+
}
|
|
711
|
+
else if (!inScope(scope, row))
|
|
712
|
+
return null;
|
|
713
|
+
const head = { id: row.id, kind: row.kind, status: row.status };
|
|
714
|
+
if (row.status === "completed") {
|
|
715
|
+
const report = parseWith(InvestigationReportSchema, row.report);
|
|
716
|
+
return {
|
|
717
|
+
...head,
|
|
718
|
+
report: {
|
|
719
|
+
summary: report?.summary ?? row.summary,
|
|
720
|
+
rootCause: report?.rootCause ?? row.rootCause,
|
|
721
|
+
hypotheses: (report?.hypotheses ?? []).map((h) => ({
|
|
722
|
+
statement: h.statement,
|
|
723
|
+
status: h.status,
|
|
724
|
+
})),
|
|
725
|
+
nextSteps: (report?.nextSteps ?? []).map((n) => ({
|
|
726
|
+
title: n.title,
|
|
727
|
+
detail: n.detail,
|
|
728
|
+
})),
|
|
729
|
+
culprit: report?.culprit ?? null,
|
|
730
|
+
},
|
|
731
|
+
steps: [],
|
|
732
|
+
error: null,
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
if (isWorkflowLive(row.status))
|
|
736
|
+
return { ...head, report: null, steps: [], error: null };
|
|
737
|
+
const events = await this.prisma.investigationEvent.findMany({
|
|
738
|
+
where: {
|
|
739
|
+
investigationId: row.id,
|
|
740
|
+
event: { contains: '"kind":"agent_step"' },
|
|
741
|
+
},
|
|
742
|
+
orderBy: { seq: "desc" },
|
|
743
|
+
take: THREAD_STEP_ROWS,
|
|
744
|
+
select: { event: true },
|
|
745
|
+
});
|
|
746
|
+
const steps = events
|
|
747
|
+
.flatMap((e) => {
|
|
748
|
+
const ev = safeParseJsonObject(e.event);
|
|
749
|
+
return ev?.kind === "agent_step" &&
|
|
750
|
+
typeof ev.text === "string" &&
|
|
751
|
+
ev.text.trim()
|
|
752
|
+
? [ev.text.slice(0, STEP_CHARS)]
|
|
188
753
|
: [];
|
|
754
|
+
})
|
|
755
|
+
.slice(0, THREAD_STEPS)
|
|
756
|
+
.reverse();
|
|
757
|
+
return { ...head, report: null, steps, error: row.error };
|
|
758
|
+
}
|
|
759
|
+
async timeline(runId, limit) {
|
|
760
|
+
const incident = await this.runIncident(runId);
|
|
761
|
+
if (!incident)
|
|
762
|
+
return null;
|
|
763
|
+
const where = { incidentId: incident.id };
|
|
764
|
+
const [rows, total] = await Promise.all([
|
|
765
|
+
this.prisma.timelineEntry.findMany({
|
|
766
|
+
where,
|
|
767
|
+
orderBy: { occurredAt: "desc" },
|
|
768
|
+
take: limit,
|
|
769
|
+
select: {
|
|
770
|
+
type: true,
|
|
771
|
+
title: true,
|
|
772
|
+
description: true,
|
|
773
|
+
source: true,
|
|
774
|
+
occurredAt: true,
|
|
775
|
+
},
|
|
776
|
+
}),
|
|
777
|
+
this.prisma.timelineEntry.count({ where }),
|
|
778
|
+
]);
|
|
779
|
+
return {
|
|
780
|
+
incident: incident.number,
|
|
781
|
+
total,
|
|
782
|
+
entries: [...rows].reverse().map((r) => ({
|
|
783
|
+
type: r.type,
|
|
784
|
+
source: r.source === "user"
|
|
785
|
+
? "operator"
|
|
786
|
+
: r.source === "ai_worker"
|
|
787
|
+
? "agent"
|
|
788
|
+
: "system",
|
|
789
|
+
text: (r.description ? `${r.title}: ${r.description}` : r.title).slice(0, TIMELINE_TEXT_CHARS),
|
|
790
|
+
at: r.occurredAt.toISOString(),
|
|
791
|
+
})),
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
async changeScope(runId) {
|
|
795
|
+
const scope = await this.scopeOf(runId);
|
|
796
|
+
if (!scope)
|
|
797
|
+
return null;
|
|
798
|
+
const { incident, serviceIds: ids } = scope;
|
|
799
|
+
const services = ids.length
|
|
800
|
+
? await this.prisma.service.findMany({
|
|
801
|
+
where: { id: { in: ids } },
|
|
802
|
+
select: { name: true },
|
|
803
|
+
orderBy: { name: "asc" },
|
|
804
|
+
})
|
|
805
|
+
: [];
|
|
806
|
+
const names = services.map((s) => s.name);
|
|
807
|
+
return incident
|
|
808
|
+
? {
|
|
809
|
+
number: incident.number,
|
|
810
|
+
triggeredAt: incident.triggeredAt.toISOString(),
|
|
811
|
+
services: names,
|
|
812
|
+
}
|
|
813
|
+
: { services: names };
|
|
814
|
+
}
|
|
815
|
+
async changesIn(q) {
|
|
816
|
+
const found = await this.prisma.service.findMany({
|
|
817
|
+
where: { name: { in: q.services } },
|
|
818
|
+
select: { id: true, name: true },
|
|
819
|
+
});
|
|
820
|
+
const unknown = q.services.filter((n) => !found.some((s) => s.name === n));
|
|
821
|
+
if (unknown.length)
|
|
822
|
+
return { unknown, changes: [] };
|
|
823
|
+
const rows = await this.prisma.changeEvent.findMany({
|
|
824
|
+
where: {
|
|
825
|
+
serviceId: { in: found.map((s) => s.id) },
|
|
826
|
+
timestamp: { gte: new Date(q.from), lte: new Date(q.to) },
|
|
827
|
+
},
|
|
828
|
+
orderBy: { timestamp: "desc" },
|
|
829
|
+
take: q.limit,
|
|
830
|
+
select: {
|
|
831
|
+
type: true,
|
|
832
|
+
source: true,
|
|
833
|
+
timestamp: true,
|
|
834
|
+
description: true,
|
|
835
|
+
metadata: true,
|
|
836
|
+
service: { select: { name: true } },
|
|
837
|
+
},
|
|
838
|
+
});
|
|
839
|
+
return {
|
|
840
|
+
unknown: [],
|
|
841
|
+
changes: rows.map((c) => ({
|
|
842
|
+
type: c.type,
|
|
843
|
+
source: c.source,
|
|
844
|
+
at: c.timestamp.toISOString(),
|
|
845
|
+
service: c.service?.name ?? null,
|
|
846
|
+
description: c.description,
|
|
847
|
+
...changeFacts(c.metadata),
|
|
848
|
+
})),
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
async serviceView(name) {
|
|
852
|
+
const s = await this.prisma.service.findUnique({
|
|
853
|
+
where: { name },
|
|
854
|
+
select: {
|
|
855
|
+
name: true,
|
|
856
|
+
displayName: true,
|
|
857
|
+
type: true,
|
|
858
|
+
tier: true,
|
|
859
|
+
team: true,
|
|
860
|
+
slackChannel: true,
|
|
861
|
+
tags: true,
|
|
862
|
+
repositories: {
|
|
863
|
+
select: {
|
|
864
|
+
subPath: true,
|
|
865
|
+
repository: { select: { fullName: true, defaultBranch: true } },
|
|
866
|
+
},
|
|
867
|
+
take: SERVICE_LINKS,
|
|
868
|
+
},
|
|
869
|
+
dependencies: {
|
|
870
|
+
select: {
|
|
871
|
+
criticality: true,
|
|
872
|
+
dependency: { select: { name: true } },
|
|
873
|
+
},
|
|
874
|
+
take: SERVICE_LINKS,
|
|
875
|
+
},
|
|
876
|
+
dependents: {
|
|
877
|
+
select: {
|
|
878
|
+
criticality: true,
|
|
879
|
+
dependent: { select: { name: true } },
|
|
880
|
+
},
|
|
881
|
+
take: SERVICE_LINKS,
|
|
882
|
+
},
|
|
883
|
+
},
|
|
884
|
+
});
|
|
885
|
+
if (!s)
|
|
886
|
+
return null;
|
|
887
|
+
let tags = [];
|
|
888
|
+
try {
|
|
889
|
+
const parsed = s.tags ? JSON.parse(s.tags) : [];
|
|
890
|
+
if (Array.isArray(parsed))
|
|
891
|
+
tags = parsed.filter((t) => typeof t === "string");
|
|
189
892
|
}
|
|
190
893
|
catch {
|
|
191
|
-
return [];
|
|
192
894
|
}
|
|
895
|
+
return {
|
|
896
|
+
name: s.name,
|
|
897
|
+
displayName: s.displayName,
|
|
898
|
+
type: s.type,
|
|
899
|
+
tier: s.tier,
|
|
900
|
+
team: s.team,
|
|
901
|
+
slackChannel: s.slackChannel,
|
|
902
|
+
tags,
|
|
903
|
+
repos: s.repositories.map((r) => ({
|
|
904
|
+
name: r.repository.fullName,
|
|
905
|
+
subPath: r.subPath,
|
|
906
|
+
branch: r.repository.defaultBranch,
|
|
907
|
+
})),
|
|
908
|
+
dependsOn: s.dependencies.map((d) => ({
|
|
909
|
+
name: d.dependency.name,
|
|
910
|
+
criticality: d.criticality,
|
|
911
|
+
})),
|
|
912
|
+
dependedOnBy: s.dependents.map((d) => ({
|
|
913
|
+
name: d.dependent.name,
|
|
914
|
+
criticality: d.criticality,
|
|
915
|
+
})),
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
async fileOwner(runId) {
|
|
919
|
+
const scope = await this.scopeOf(runId);
|
|
920
|
+
if (scope)
|
|
921
|
+
return scope.incident;
|
|
922
|
+
const run = await this.prisma.investigation.findUnique({
|
|
923
|
+
where: { id: runId },
|
|
924
|
+
select: { id: true },
|
|
925
|
+
});
|
|
926
|
+
return run ? null : undefined;
|
|
927
|
+
}
|
|
928
|
+
async attachmentsOf(runId) {
|
|
929
|
+
const incident = await this.fileOwner(runId);
|
|
930
|
+
if (incident === undefined)
|
|
931
|
+
return null;
|
|
932
|
+
const rows = await this.prisma.attachment.findMany({
|
|
933
|
+
where: filesOf(runId, incident),
|
|
934
|
+
orderBy: { createdAt: "desc" },
|
|
935
|
+
take: ATTACHMENTS_LISTED,
|
|
936
|
+
select: {
|
|
937
|
+
id: true,
|
|
938
|
+
name: true,
|
|
939
|
+
mimeType: true,
|
|
940
|
+
size: true,
|
|
941
|
+
createdAt: true,
|
|
942
|
+
},
|
|
943
|
+
});
|
|
944
|
+
return {
|
|
945
|
+
...(incident ? { incident: incident.number } : {}),
|
|
946
|
+
attachments: rows.map((r) => ({
|
|
947
|
+
id: r.id,
|
|
948
|
+
name: r.name,
|
|
949
|
+
mimeType: r.mimeType,
|
|
950
|
+
size: r.size,
|
|
951
|
+
at: r.createdAt.toISOString(),
|
|
952
|
+
})),
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
async attachmentOf(runId, id) {
|
|
956
|
+
const incident = await this.fileOwner(runId);
|
|
957
|
+
if (incident === undefined)
|
|
958
|
+
return null;
|
|
959
|
+
const row = await this.prisma.attachment.findFirst({
|
|
960
|
+
where: { id, ...filesOf(runId, incident) },
|
|
961
|
+
select: { id: true, name: true, mimeType: true, size: true },
|
|
962
|
+
});
|
|
963
|
+
if (!row)
|
|
964
|
+
return null;
|
|
965
|
+
return {
|
|
966
|
+
name: row.name,
|
|
967
|
+
mimeType: row.mimeType,
|
|
968
|
+
size: row.size,
|
|
969
|
+
text: () => readFile(join(attachmentsDir(), row.id), "utf8").catch(() => null),
|
|
970
|
+
bytes: () => readFile(join(attachmentsDir(), row.id)).catch(() => null),
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
async similarTo(runId, limit) {
|
|
974
|
+
const incident = await this.runIncident(runId);
|
|
975
|
+
if (!incident)
|
|
976
|
+
return null;
|
|
977
|
+
const scored = await this.prisma.incidentSimilarity.findMany({
|
|
978
|
+
where: { incidentId: incident.id },
|
|
979
|
+
orderBy: [{ similarityScore: "desc" }, { calculatedAt: "desc" }],
|
|
980
|
+
take: limit,
|
|
981
|
+
select: {
|
|
982
|
+
similarIncidentId: true,
|
|
983
|
+
similarityScore: true,
|
|
984
|
+
matchFactors: true,
|
|
985
|
+
},
|
|
986
|
+
});
|
|
987
|
+
const rows = scored.length
|
|
988
|
+
? await this.prisma.incident.findMany({
|
|
989
|
+
where: { id: { in: scored.map((s) => s.similarIncidentId) } },
|
|
990
|
+
select: {
|
|
991
|
+
id: true,
|
|
992
|
+
number: true,
|
|
993
|
+
title: true,
|
|
994
|
+
status: true,
|
|
995
|
+
resolvedAt: true,
|
|
996
|
+
actualCause: true,
|
|
997
|
+
actualCauseCategory: true,
|
|
998
|
+
service: { select: { name: true } },
|
|
999
|
+
},
|
|
1000
|
+
})
|
|
1001
|
+
: [];
|
|
1002
|
+
const byId = new Map(rows.map((r) => [r.id, r]));
|
|
1003
|
+
return {
|
|
1004
|
+
incident: incident.number,
|
|
1005
|
+
similar: scored.flatMap((s) => {
|
|
1006
|
+
const r = byId.get(s.similarIncidentId);
|
|
1007
|
+
if (!r)
|
|
1008
|
+
return [];
|
|
1009
|
+
const matched = safeParseJsonObject(s.matchFactors)?.matchedOn;
|
|
1010
|
+
return [
|
|
1011
|
+
{
|
|
1012
|
+
number: r.number,
|
|
1013
|
+
title: r.title,
|
|
1014
|
+
service: r.service?.name ?? null,
|
|
1015
|
+
status: r.status,
|
|
1016
|
+
resolvedAt: r.resolvedAt?.toISOString() ?? null,
|
|
1017
|
+
actualCause: r.actualCause
|
|
1018
|
+
? { cause: r.actualCause, category: r.actualCauseCategory }
|
|
1019
|
+
: null,
|
|
1020
|
+
similarityScore: s.similarityScore,
|
|
1021
|
+
matchedOn: Array.isArray(matched)
|
|
1022
|
+
? matched.filter((m) => typeof m === "string")
|
|
1023
|
+
: [],
|
|
1024
|
+
},
|
|
1025
|
+
];
|
|
1026
|
+
}),
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
async pastFixes(runId, limit) {
|
|
1030
|
+
const scope = await this.scopeOf(runId);
|
|
1031
|
+
if (!scope)
|
|
1032
|
+
return null;
|
|
1033
|
+
const { incident, serviceIds } = scope;
|
|
1034
|
+
const owned = incident
|
|
1035
|
+
? serviceIds.length
|
|
1036
|
+
? { incident: { serviceId: { in: serviceIds } } }
|
|
1037
|
+
: null
|
|
1038
|
+
: ownedBy(scope).length
|
|
1039
|
+
? { OR: ownedBy(scope) }
|
|
1040
|
+
: null;
|
|
1041
|
+
const rows = owned
|
|
1042
|
+
? await this.prisma.recommendation.findMany({
|
|
1043
|
+
where: { investigation: { id: { not: runId }, ...owned } },
|
|
1044
|
+
orderBy: { createdAt: "desc" },
|
|
1045
|
+
take: limit,
|
|
1046
|
+
select: {
|
|
1047
|
+
id: true,
|
|
1048
|
+
investigationId: true,
|
|
1049
|
+
title: true,
|
|
1050
|
+
description: true,
|
|
1051
|
+
priority: true,
|
|
1052
|
+
category: true,
|
|
1053
|
+
status: true,
|
|
1054
|
+
implementedAt: true,
|
|
1055
|
+
investigation: {
|
|
1056
|
+
select: { incident: { select: { id: true, number: true } } },
|
|
1057
|
+
},
|
|
1058
|
+
},
|
|
1059
|
+
})
|
|
1060
|
+
: [];
|
|
1061
|
+
const recs = rows.flatMap(({ investigation: { incident: cited }, ...r }) => cited || !incident ? [{ ...r, incident: cited }] : []);
|
|
1062
|
+
const checks = recs.length
|
|
1063
|
+
? await this.prisma.timelineEntry.findMany({
|
|
1064
|
+
where: {
|
|
1065
|
+
incidentId: {
|
|
1066
|
+
in: [
|
|
1067
|
+
...new Set(recs.flatMap((r) => (r.incident ? [r.incident.id] : []))),
|
|
1068
|
+
],
|
|
1069
|
+
},
|
|
1070
|
+
type: "custom",
|
|
1071
|
+
metadata: { contains: '"event":"fix_check"' },
|
|
1072
|
+
},
|
|
1073
|
+
orderBy: { occurredAt: "desc" },
|
|
1074
|
+
take: FIX_CHECK_ROWS,
|
|
1075
|
+
select: { metadata: true, occurredAt: true },
|
|
1076
|
+
})
|
|
1077
|
+
: [];
|
|
1078
|
+
const checked = checks.flatMap((c) => {
|
|
1079
|
+
const m = safeParseJsonObject(c.metadata);
|
|
1080
|
+
const verdict = FixVerdictSchema.safeParse(m?.verdict);
|
|
1081
|
+
return typeof m?.stepId === "string" && verdict.success
|
|
1082
|
+
? [{ stepId: m.stepId, verdict: verdict.data, at: c.occurredAt }]
|
|
1083
|
+
: [];
|
|
1084
|
+
});
|
|
1085
|
+
return {
|
|
1086
|
+
...(incident ? { incident: incident.number } : {}),
|
|
1087
|
+
fixes: recs.map((r) => {
|
|
1088
|
+
const last = checked.find((c) => c.stepId === r.id && (!r.implementedAt || c.at >= r.implementedAt));
|
|
1089
|
+
return {
|
|
1090
|
+
id: r.id,
|
|
1091
|
+
title: r.title,
|
|
1092
|
+
detail: r.description,
|
|
1093
|
+
incident: r.incident?.number ?? null,
|
|
1094
|
+
investigationId: r.investigationId,
|
|
1095
|
+
status: r.status === "completed" ? "applied" : r.status,
|
|
1096
|
+
priority: r.priority,
|
|
1097
|
+
category: r.category,
|
|
1098
|
+
appliedAt: r.implementedAt?.toISOString() ?? null,
|
|
1099
|
+
lastCheck: last
|
|
1100
|
+
? { verdict: last.verdict, at: last.at.toISOString() }
|
|
1101
|
+
: null,
|
|
1102
|
+
};
|
|
1103
|
+
}),
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
async runStatus(runId) {
|
|
1107
|
+
const row = await this.prisma.investigation.findUnique({
|
|
1108
|
+
where: { id: runId },
|
|
1109
|
+
select: {
|
|
1110
|
+
status: true,
|
|
1111
|
+
startedAt: true,
|
|
1112
|
+
usage: true,
|
|
1113
|
+
accessLevel: true,
|
|
1114
|
+
workspace: true,
|
|
1115
|
+
},
|
|
1116
|
+
});
|
|
1117
|
+
if (!row)
|
|
1118
|
+
return null;
|
|
1119
|
+
const usage = parseWith(RunUsageSchema, row.usage);
|
|
1120
|
+
const ws = parseWith(RunWorkspaceSchema, row.workspace);
|
|
1121
|
+
const clockStart = this.runs.get(runId)?.turnStartedAt ?? row.startedAt;
|
|
1122
|
+
return {
|
|
1123
|
+
status: row.status,
|
|
1124
|
+
usage: usage
|
|
1125
|
+
? {
|
|
1126
|
+
used: usage.used,
|
|
1127
|
+
size: usage.size,
|
|
1128
|
+
...(usage.cost ? { cost: usage.cost } : {}),
|
|
1129
|
+
}
|
|
1130
|
+
: null,
|
|
1131
|
+
secondsLeft: clockStart
|
|
1132
|
+
? Math.max(0, Math.round((clockStart.getTime() +
|
|
1133
|
+
INVESTIGATION_DEFAULTS.harnessWallClockMs -
|
|
1134
|
+
Date.now()) /
|
|
1135
|
+
1000))
|
|
1136
|
+
: null,
|
|
1137
|
+
accessLevel: row.accessLevel,
|
|
1138
|
+
repos: (ws?.repos ?? []).map((r) => ({
|
|
1139
|
+
name: r.name,
|
|
1140
|
+
subPath: r.subPath,
|
|
1141
|
+
branch: r.branch,
|
|
1142
|
+
commit: r.head,
|
|
1143
|
+
services: r.services,
|
|
1144
|
+
})),
|
|
1145
|
+
};
|
|
193
1146
|
}
|
|
194
1147
|
async incident(q) {
|
|
195
1148
|
const select = {
|
|
@@ -225,14 +1178,7 @@ let GatewayService = class GatewayService {
|
|
|
225
1178
|
}))?.incident;
|
|
226
1179
|
if (!row)
|
|
227
1180
|
return null;
|
|
228
|
-
const
|
|
229
|
-
where: { incidentId: row.id, serviceId: { not: null } },
|
|
230
|
-
select: { serviceId: true },
|
|
231
|
-
distinct: ["serviceId"],
|
|
232
|
-
});
|
|
233
|
-
const serviceIds = [
|
|
234
|
-
...new Set([row.serviceId, ...alertServices.map((a) => a.serviceId)].filter((id) => !!id)),
|
|
235
|
-
];
|
|
1181
|
+
const serviceIds = await this.serviceIdsOf(row.id, row.serviceId);
|
|
236
1182
|
const changes = serviceIds.length
|
|
237
1183
|
? await this.prisma.changeEvent.findMany({
|
|
238
1184
|
where: {
|
|
@@ -268,19 +1214,14 @@ let GatewayService = class GatewayService {
|
|
|
268
1214
|
labels: safeParseJsonObject(a.labels) ?? null,
|
|
269
1215
|
triggeredAt: a.triggeredAt.toISOString(),
|
|
270
1216
|
})),
|
|
271
|
-
changes: changes.map((c) => {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
description: c.description,
|
|
280
|
-
environment: typeof env === "string" ? env : null,
|
|
281
|
-
version: typeof meta.version === "string" ? meta.version : null,
|
|
282
|
-
};
|
|
283
|
-
}),
|
|
1217
|
+
changes: changes.map((c) => ({
|
|
1218
|
+
type: c.type,
|
|
1219
|
+
source: c.source,
|
|
1220
|
+
timestamp: c.timestamp.toISOString(),
|
|
1221
|
+
service: c.service?.name ?? null,
|
|
1222
|
+
description: c.description,
|
|
1223
|
+
...changeFacts(c.metadata),
|
|
1224
|
+
})),
|
|
284
1225
|
};
|
|
285
1226
|
}
|
|
286
1227
|
async searchInvestigations(q) {
|
|
@@ -289,23 +1230,38 @@ let GatewayService = class GatewayService {
|
|
|
289
1230
|
where: {
|
|
290
1231
|
id: { not: q.excludeRunId },
|
|
291
1232
|
status: "completed",
|
|
292
|
-
|
|
293
|
-
{
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
1233
|
+
AND: [
|
|
1234
|
+
{
|
|
1235
|
+
OR: [
|
|
1236
|
+
{ summary: text },
|
|
1237
|
+
{ rootCause: text },
|
|
1238
|
+
{ title: text },
|
|
1239
|
+
{ incident: { title: text } },
|
|
1240
|
+
{ incident: { description: text } },
|
|
1241
|
+
{ incident: { actualCause: text } },
|
|
1242
|
+
],
|
|
1243
|
+
},
|
|
1244
|
+
...(q.service
|
|
1245
|
+
? [
|
|
1246
|
+
{
|
|
1247
|
+
OR: [
|
|
1248
|
+
{
|
|
1249
|
+
incident: {
|
|
1250
|
+
service: {
|
|
1251
|
+
OR: [{ name: q.service }, { displayName: q.service }],
|
|
1252
|
+
},
|
|
1253
|
+
},
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
service: {
|
|
1257
|
+
OR: [{ name: q.service }, { displayName: q.service }],
|
|
1258
|
+
},
|
|
1259
|
+
},
|
|
1260
|
+
],
|
|
305
1261
|
},
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
1262
|
+
]
|
|
1263
|
+
: []),
|
|
1264
|
+
],
|
|
309
1265
|
},
|
|
310
1266
|
orderBy: { completedAt: "desc" },
|
|
311
1267
|
take: q.limit,
|
|
@@ -328,18 +1284,20 @@ let GatewayService = class GatewayService {
|
|
|
328
1284
|
});
|
|
329
1285
|
return rows.map((r) => ({
|
|
330
1286
|
investigationId: r.id,
|
|
331
|
-
incident:
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
1287
|
+
incident: r.incident
|
|
1288
|
+
? {
|
|
1289
|
+
number: r.incident.number,
|
|
1290
|
+
title: r.incident.title,
|
|
1291
|
+
service: r.incident.service?.name ?? null,
|
|
1292
|
+
}
|
|
1293
|
+
: null,
|
|
336
1294
|
completedAt: r.completedAt?.toISOString() ?? null,
|
|
337
1295
|
agentFinding: {
|
|
338
1296
|
summary: r.summary,
|
|
339
1297
|
rootCause: r.rootCause,
|
|
340
1298
|
category: r.rootCauseCategory,
|
|
341
1299
|
},
|
|
342
|
-
operatorRecordedCause: r.incident
|
|
1300
|
+
operatorRecordedCause: r.incident?.actualCause
|
|
343
1301
|
? {
|
|
344
1302
|
cause: r.incident.actualCause,
|
|
345
1303
|
category: r.incident.actualCauseCategory,
|
|
@@ -351,14 +1309,10 @@ let GatewayService = class GatewayService {
|
|
|
351
1309
|
GatewayService = __decorate([
|
|
352
1310
|
Injectable(),
|
|
353
1311
|
__param(1, Optional()),
|
|
1312
|
+
__param(2, Optional()),
|
|
354
1313
|
__metadata("design:paramtypes", [PrismaService,
|
|
355
|
-
HttpAdapterHost
|
|
1314
|
+
HttpAdapterHost,
|
|
1315
|
+
ModuleRef])
|
|
356
1316
|
], GatewayService);
|
|
357
1317
|
export { GatewayService };
|
|
358
|
-
export function gatewayPromptLine(tools, serverName) {
|
|
359
|
-
return [
|
|
360
|
-
`PrismaLens tools (MCP server \`${serverName}\`, read-only): ${tools.map((t) => `\`${t}\``).join(", ")}.`,
|
|
361
|
-
"For metrics, logs and other live data, use the tools your own setup gives you.",
|
|
362
|
-
].join("\n");
|
|
363
|
-
}
|
|
364
1318
|
//# sourceMappingURL=gateway.service.js.map
|