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
|
@@ -0,0 +1,972 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { execFile } from "node:child_process";
|
|
11
|
+
import { promisify } from "node:util";
|
|
12
|
+
import { Injectable, } from "@nestjs/common";
|
|
13
|
+
import { ACCESS_LEVELS } from "@prismalens/config/harness";
|
|
14
|
+
import { isWorkflowTerminal, LIVE_WORKFLOW_STATUSES, RunWorkspaceSchema, THREAD_MESSAGE_CHARS, } from "@prismalens/contracts";
|
|
15
|
+
import { fail, } from "@prismalens/integrations/harness";
|
|
16
|
+
import { Logger } from "@prismalens/logger";
|
|
17
|
+
import { PrismaService } from "../../core/prisma/prisma.service.js";
|
|
18
|
+
import { DispatchService } from "../../infrastructure/dispatch/dispatch.service.js";
|
|
19
|
+
import { InvestigationsService } from "../investigations/investigations.service.js";
|
|
20
|
+
import { actionReason, ThreadsService } from "../threads/threads.service.js";
|
|
21
|
+
import { PendingActionsService } from "./pending-actions.service.js";
|
|
22
|
+
import { PutOff } from "./put-off.js";
|
|
23
|
+
import { isDuplicate, TreeIo } from "./tree-io.service.js";
|
|
24
|
+
import { TreeSettings } from "./tree-settings.service.js";
|
|
25
|
+
const git = promisify(execFile);
|
|
26
|
+
const logger = new Logger({ context: "ThreadTree" });
|
|
27
|
+
const TICK_MS = 2_000;
|
|
28
|
+
const REOPEN_TRIES = 30;
|
|
29
|
+
const MESSAGE_BATCH = 100;
|
|
30
|
+
const ROSTER_LINES = 20;
|
|
31
|
+
const ROW = {
|
|
32
|
+
id: true,
|
|
33
|
+
title: true,
|
|
34
|
+
role: true,
|
|
35
|
+
parentId: true,
|
|
36
|
+
rootId: true,
|
|
37
|
+
depth: true,
|
|
38
|
+
status: true,
|
|
39
|
+
incidentId: true,
|
|
40
|
+
scheduleId: true,
|
|
41
|
+
createdAt: true,
|
|
42
|
+
endReason: true,
|
|
43
|
+
};
|
|
44
|
+
const LIVE = [...LIVE_WORKFLOW_STATUSES];
|
|
45
|
+
export function threadLink(row) {
|
|
46
|
+
if (row.incidentId)
|
|
47
|
+
return `/incidents/${row.incidentId}/conversation?investigation=${row.id}`;
|
|
48
|
+
if (row.scheduleId)
|
|
49
|
+
return `/schedules/${row.scheduleId}/runs/${row.id}`;
|
|
50
|
+
return `/threads/${row.id}`;
|
|
51
|
+
}
|
|
52
|
+
export function nodeState(row) {
|
|
53
|
+
switch (row.status) {
|
|
54
|
+
case "pending":
|
|
55
|
+
return "queued";
|
|
56
|
+
case "completed":
|
|
57
|
+
return "answered";
|
|
58
|
+
case "failed":
|
|
59
|
+
return "failed";
|
|
60
|
+
case "cancelled":
|
|
61
|
+
return "stopped";
|
|
62
|
+
default:
|
|
63
|
+
return "running";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function outcomeOf(row) {
|
|
67
|
+
if (row.status === "completed")
|
|
68
|
+
return "answered";
|
|
69
|
+
if (row.status === "cancelled")
|
|
70
|
+
return "stopped";
|
|
71
|
+
return row.endReason === "limited"
|
|
72
|
+
? "limited"
|
|
73
|
+
: "failed";
|
|
74
|
+
}
|
|
75
|
+
const NO_TREE = () => fail("invalid_input", "This thread is not in a tree yet: it has started no threads and none started it.", "Start a child with thread_start first, or do the work here.");
|
|
76
|
+
const cap = (text, n = THREAD_MESSAGE_CHARS) => text.length > n ? `${text.slice(0, n - 1)}…` : text;
|
|
77
|
+
const rank = (level) => ACCESS_LEVELS.indexOf(level);
|
|
78
|
+
export const TREE_MESSAGE_CAP = 500;
|
|
79
|
+
let ThreadTreeService = class ThreadTreeService {
|
|
80
|
+
prisma;
|
|
81
|
+
threads;
|
|
82
|
+
dispatch;
|
|
83
|
+
investigations;
|
|
84
|
+
settings;
|
|
85
|
+
actions;
|
|
86
|
+
io;
|
|
87
|
+
timer;
|
|
88
|
+
ticking = null;
|
|
89
|
+
reopenTries = new Map();
|
|
90
|
+
putOff = new PutOff();
|
|
91
|
+
draining = Promise.resolve();
|
|
92
|
+
sweptTo = new Date(0);
|
|
93
|
+
constructor(prisma, threads, dispatch, investigations, settings, actions, io) {
|
|
94
|
+
this.prisma = prisma;
|
|
95
|
+
this.threads = threads;
|
|
96
|
+
this.dispatch = dispatch;
|
|
97
|
+
this.investigations = investigations;
|
|
98
|
+
this.settings = settings;
|
|
99
|
+
this.actions = actions;
|
|
100
|
+
this.io = io;
|
|
101
|
+
actions.register("thread_start", {
|
|
102
|
+
check: (caller, args) => this.startRefusal(caller, args),
|
|
103
|
+
run: (caller, args, actionId) => this.startChild(caller, args, actionId),
|
|
104
|
+
already: async (_caller, _args, actionId) => !!(await this.prisma.investigation.findFirst({
|
|
105
|
+
where: { triggerReason: actionReason(actionId) },
|
|
106
|
+
select: { id: true },
|
|
107
|
+
})),
|
|
108
|
+
describe: (args) => {
|
|
109
|
+
const a = args;
|
|
110
|
+
return {
|
|
111
|
+
title: `Start a thread: ${a.title} (${a.role})`,
|
|
112
|
+
detail: cap(a.brief, 1_000),
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
done: (_args, value) => {
|
|
116
|
+
const v = value;
|
|
117
|
+
return `started ${v.role} #${v.number}, ${v.link}. Its result arrives as a message when it finishes.`;
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
actions.register("thread_cancel", {
|
|
121
|
+
check: (caller, args) => this.cancelRefusal(caller, args.id),
|
|
122
|
+
run: (caller, args) => this.cancelMember(caller, args),
|
|
123
|
+
already: async (caller, args) => {
|
|
124
|
+
const target = await this.resolveMember(caller, args.id);
|
|
125
|
+
return !!target && isWorkflowTerminal(target.status);
|
|
126
|
+
},
|
|
127
|
+
describe: (args) => {
|
|
128
|
+
const a = args;
|
|
129
|
+
return { title: "Stop a thread in this tree", detail: a.reason };
|
|
130
|
+
},
|
|
131
|
+
done: (_args, value) => `${value.link} was asked to stop.`,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
onApplicationBootstrap() {
|
|
135
|
+
void this.actions
|
|
136
|
+
.resume()
|
|
137
|
+
.catch((e) => logger.warn(`Resuming pending actions failed: ${e}`));
|
|
138
|
+
this.timer = setInterval(() => void this.tick(), TICK_MS);
|
|
139
|
+
this.timer.unref?.();
|
|
140
|
+
}
|
|
141
|
+
onModuleDestroy() {
|
|
142
|
+
clearInterval(this.timer);
|
|
143
|
+
this.actions.stop();
|
|
144
|
+
}
|
|
145
|
+
tick() {
|
|
146
|
+
this.ticking ??= (async () => {
|
|
147
|
+
try {
|
|
148
|
+
await this.sweepFinished();
|
|
149
|
+
await this.sweepCancelled();
|
|
150
|
+
await this.drain();
|
|
151
|
+
await this.actions.deliverOutcomes();
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
logger.warn(`Thread tree tick failed: ${e.message}`);
|
|
155
|
+
}
|
|
156
|
+
})().finally(() => {
|
|
157
|
+
this.ticking = null;
|
|
158
|
+
});
|
|
159
|
+
return this.ticking;
|
|
160
|
+
}
|
|
161
|
+
row(id) {
|
|
162
|
+
return this.prisma.investigation.findUnique({ where: { id }, select: ROW });
|
|
163
|
+
}
|
|
164
|
+
async members(rootId) {
|
|
165
|
+
return this.prisma.investigation.findMany({
|
|
166
|
+
where: { OR: [{ id: rootId }, { rootId }] },
|
|
167
|
+
orderBy: { createdAt: "asc" },
|
|
168
|
+
select: ROW,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
rootOf(row) {
|
|
172
|
+
return row.rootId ?? row.id;
|
|
173
|
+
}
|
|
174
|
+
async sameTree(a, b) {
|
|
175
|
+
const [x, y] = await Promise.all([this.row(a), this.row(b)]);
|
|
176
|
+
if (!x || !y)
|
|
177
|
+
return false;
|
|
178
|
+
if (!x.rootId && !y.rootId)
|
|
179
|
+
return false;
|
|
180
|
+
return this.rootOf(x) === this.rootOf(y);
|
|
181
|
+
}
|
|
182
|
+
async tree(id) {
|
|
183
|
+
const row = await this.row(id);
|
|
184
|
+
if (!row)
|
|
185
|
+
return null;
|
|
186
|
+
const rootId = this.rootOf(row);
|
|
187
|
+
const members = await this.members(rootId);
|
|
188
|
+
const unread = await this.prisma.threadMessage.groupBy({
|
|
189
|
+
by: ["toId"],
|
|
190
|
+
where: { rootId, state: "queued" },
|
|
191
|
+
_count: { _all: true },
|
|
192
|
+
});
|
|
193
|
+
const count = new Map(unread.map((u) => [u.toId, u._count._all]));
|
|
194
|
+
const allowance = await this.prisma.treeAllowance.findUnique({
|
|
195
|
+
where: { rootId },
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
rootId,
|
|
199
|
+
nodes: members.map((m, i) => ({
|
|
200
|
+
id: m.id,
|
|
201
|
+
number: i + 1,
|
|
202
|
+
title: m.title,
|
|
203
|
+
role: m.id === rootId ? null : m.role,
|
|
204
|
+
parentId: m.parentId,
|
|
205
|
+
depth: m.depth,
|
|
206
|
+
state: nodeState(m),
|
|
207
|
+
unread: count.get(m.id) ?? 0,
|
|
208
|
+
link: threadLink(m),
|
|
209
|
+
})),
|
|
210
|
+
allowance: allowance
|
|
211
|
+
? { grantedAt: allowance.grantedAt.toISOString() }
|
|
212
|
+
: null,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
nameOf(m, rootId) {
|
|
216
|
+
return m.id === rootId ? "root" : (m.role ?? "thread");
|
|
217
|
+
}
|
|
218
|
+
async roster(selfId) {
|
|
219
|
+
const self = await this.row(selfId);
|
|
220
|
+
if (!self)
|
|
221
|
+
return null;
|
|
222
|
+
const rootId = this.rootOf(self);
|
|
223
|
+
const members = await this.members(rootId);
|
|
224
|
+
return {
|
|
225
|
+
self: { number: members.findIndex((m) => m.id === selfId) + 1 },
|
|
226
|
+
members: members.map((m, i) => ({
|
|
227
|
+
number: i + 1,
|
|
228
|
+
role: this.nameOf(m, rootId),
|
|
229
|
+
relation: m.id === selfId
|
|
230
|
+
? "you"
|
|
231
|
+
: m.id === self.parentId
|
|
232
|
+
? "parent"
|
|
233
|
+
: m.parentId === selfId
|
|
234
|
+
? "child"
|
|
235
|
+
: m.parentId && m.parentId === self.parentId
|
|
236
|
+
? "sibling"
|
|
237
|
+
: m.id === rootId
|
|
238
|
+
? "root"
|
|
239
|
+
: "member",
|
|
240
|
+
title: m.title,
|
|
241
|
+
state: nodeState(m),
|
|
242
|
+
link: threadLink(m),
|
|
243
|
+
})),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
async resolveMember(selfId, to) {
|
|
247
|
+
const self = await this.row(selfId);
|
|
248
|
+
if (!self)
|
|
249
|
+
return null;
|
|
250
|
+
const rootId = this.rootOf(self);
|
|
251
|
+
const members = await this.members(rootId);
|
|
252
|
+
const key = to.trim();
|
|
253
|
+
const byId = key.match(/[0-9a-f]{8}-[0-9a-f-]{27}/i)?.[0];
|
|
254
|
+
if (byId)
|
|
255
|
+
return members.find((m) => m.id === byId) ?? null;
|
|
256
|
+
const lower = key.toLowerCase();
|
|
257
|
+
if (lower === "parent")
|
|
258
|
+
return members.find((m) => m.id === self.parentId) ?? null;
|
|
259
|
+
if (lower === "root")
|
|
260
|
+
return members.find((m) => m.id === rootId) ?? null;
|
|
261
|
+
const numbered = lower.match(/^#?(\d+)$/);
|
|
262
|
+
if (numbered)
|
|
263
|
+
return members[Number(numbered[1]) - 1] ?? null;
|
|
264
|
+
const rank = (m) => [
|
|
265
|
+
isWorkflowTerminal(m.status) ? 1 : 0,
|
|
266
|
+
m.parentId === selfId ? 0 : m.parentId === self.parentId ? 1 : 2,
|
|
267
|
+
-m.createdAt.getTime(),
|
|
268
|
+
];
|
|
269
|
+
const [best] = members
|
|
270
|
+
.filter((m) => m.id !== selfId && m.role?.toLowerCase() === lower)
|
|
271
|
+
.sort((a, b) => {
|
|
272
|
+
const [x, y] = [rank(a), rank(b)];
|
|
273
|
+
return ((x[0] ?? 0) - (y[0] ?? 0) ||
|
|
274
|
+
(x[1] ?? 0) - (y[1] ?? 0) ||
|
|
275
|
+
(x[2] ?? 0) - (y[2] ?? 0));
|
|
276
|
+
});
|
|
277
|
+
return best ?? null;
|
|
278
|
+
}
|
|
279
|
+
async startRefusal(callerId, args) {
|
|
280
|
+
const s = await this.settings.get();
|
|
281
|
+
if (s.agentsStartThreads === "never")
|
|
282
|
+
return fail("disabled", "The user turned off starting threads.", "Do the work yourself in this thread.");
|
|
283
|
+
const caller = await this.row(callerId);
|
|
284
|
+
if (!caller)
|
|
285
|
+
return fail("run_ended", "This thread is gone.", "Stop starting threads.");
|
|
286
|
+
const project = await this.prisma.investigation.findUnique({
|
|
287
|
+
where: { id: callerId },
|
|
288
|
+
select: { repository: { select: { plain: true } } },
|
|
289
|
+
});
|
|
290
|
+
if (project?.repository?.plain)
|
|
291
|
+
return fail("invalid_input", "This project is a plain folder with no git, so a child thread would work in the same folder as this one.", "Do the work in this thread, or tell the user that Start git on the project gives children their own worktrees.");
|
|
292
|
+
if (caller.depth + 1 > s.depth)
|
|
293
|
+
return fail("limit_reached", `A thread ${caller.depth} levels down may not start threads: the depth cap is ${s.depth}.`, "Do the work in this thread, or tell the user the cap is Settings → Agent → Advanced → Thread depth.");
|
|
294
|
+
const children = await this.prisma.investigation.count({
|
|
295
|
+
where: { parentId: callerId, status: { in: LIVE } },
|
|
296
|
+
});
|
|
297
|
+
if (children >= s.children)
|
|
298
|
+
return fail("limit_reached", `This thread already has ${children} running children, the cap.`, "Wait for one to finish (thread_wait), or cancel one; the cap is Settings → Agent → Advanced → Children per thread.");
|
|
299
|
+
const rootId = this.rootOf(caller);
|
|
300
|
+
const live = await this.prisma.investigation.count({
|
|
301
|
+
where: { OR: [{ id: rootId }, { rootId }], status: { in: LIVE } },
|
|
302
|
+
});
|
|
303
|
+
if (live >= s.perTree)
|
|
304
|
+
return fail("limit_reached", `This tree already has ${live} running threads, the cap.`, "Wait for one to finish (thread_wait); the cap is Settings → Agent → Advanced → Threads per tree.");
|
|
305
|
+
const taken = await this.prisma.investigation.findFirst({
|
|
306
|
+
where: {
|
|
307
|
+
parentId: callerId,
|
|
308
|
+
role: args.role,
|
|
309
|
+
status: { in: LIVE },
|
|
310
|
+
},
|
|
311
|
+
select: { id: true },
|
|
312
|
+
});
|
|
313
|
+
if (taken)
|
|
314
|
+
return fail("invalid_input", `A running child already has the role "${args.role}".`, "Pick a role no running child has, or message that child with thread_send.");
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
async subjectFor(callerId) {
|
|
318
|
+
const row = await this.prisma.investigation.findUniqueOrThrow({
|
|
319
|
+
where: { id: callerId },
|
|
320
|
+
select: {
|
|
321
|
+
repositoryId: true,
|
|
322
|
+
serviceId: true,
|
|
323
|
+
accessLevel: true,
|
|
324
|
+
harness: true,
|
|
325
|
+
model: true,
|
|
326
|
+
effort: true,
|
|
327
|
+
workspace: true,
|
|
328
|
+
incident: { select: { serviceId: true } },
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
const serviceId = row.incident ? row.incident.serviceId : row.serviceId;
|
|
332
|
+
const subject = row.repositoryId
|
|
333
|
+
? { kind: "project", repositoryId: row.repositoryId }
|
|
334
|
+
: serviceId
|
|
335
|
+
? { kind: "service", serviceId }
|
|
336
|
+
: { kind: "none" };
|
|
337
|
+
return { row, subject };
|
|
338
|
+
}
|
|
339
|
+
async pinsFor(workspace, kind, ref) {
|
|
340
|
+
if (kind === "same_project_fresh")
|
|
341
|
+
return undefined;
|
|
342
|
+
if (kind === "new_from_ref")
|
|
343
|
+
return ref;
|
|
344
|
+
const ws = workspace
|
|
345
|
+
? RunWorkspaceSchema.safeParse(JSON.parse(workspace))
|
|
346
|
+
: null;
|
|
347
|
+
if (!ws?.success)
|
|
348
|
+
return undefined;
|
|
349
|
+
const pins = new Map();
|
|
350
|
+
for (const repo of ws.data.repos) {
|
|
351
|
+
let head = repo.head;
|
|
352
|
+
if (repo.sourceKind === "folder")
|
|
353
|
+
head =
|
|
354
|
+
(await git("git", ["-C", repo.dir, "rev-parse", "HEAD"], {
|
|
355
|
+
timeout: 5_000,
|
|
356
|
+
}).catch(() => ({ stdout: head }))).stdout.trim() || head;
|
|
357
|
+
pins.set(repo.url, head);
|
|
358
|
+
}
|
|
359
|
+
return pins;
|
|
360
|
+
}
|
|
361
|
+
async startChild(callerId, args, actionId) {
|
|
362
|
+
const caller = await this.row(callerId);
|
|
363
|
+
if (!caller)
|
|
364
|
+
return fail("run_ended", "This thread is gone.", "Stop starting threads.");
|
|
365
|
+
const rootId = this.rootOf(caller);
|
|
366
|
+
const existing = await this.prisma.investigation.findFirst({
|
|
367
|
+
where: { triggerReason: actionReason(actionId) },
|
|
368
|
+
select: ROW,
|
|
369
|
+
});
|
|
370
|
+
let childId = existing?.id;
|
|
371
|
+
let queued = false;
|
|
372
|
+
const { row: parent, subject } = await this.subjectFor(callerId);
|
|
373
|
+
const parentLevel = parent.accessLevel ?? "supervised";
|
|
374
|
+
const asked = args.access ?? parentLevel;
|
|
375
|
+
const access = rank(asked) > rank(parentLevel) ? parentLevel : asked;
|
|
376
|
+
if (!childId) {
|
|
377
|
+
if (!caller.rootId)
|
|
378
|
+
await this.prisma.investigation.update({
|
|
379
|
+
where: { id: callerId },
|
|
380
|
+
data: { rootId: callerId },
|
|
381
|
+
});
|
|
382
|
+
const pins = await this.pinsFor(parent.workspace, args.workspace.kind, args.workspace.ref);
|
|
383
|
+
const brief = await this.firstPrompt(callerId, rootId, args);
|
|
384
|
+
const started = await this.threads.start({
|
|
385
|
+
subject,
|
|
386
|
+
text: brief,
|
|
387
|
+
accessLevel: access,
|
|
388
|
+
...((args.agent ?? parent.harness)
|
|
389
|
+
? { harness: (args.agent ?? parent.harness) }
|
|
390
|
+
: {}),
|
|
391
|
+
...((args.model ?? parent.model)
|
|
392
|
+
? { model: args.model ?? parent.model }
|
|
393
|
+
: {}),
|
|
394
|
+
...((args.effort ?? parent.effort)
|
|
395
|
+
? { effort: args.effort ?? parent.effort }
|
|
396
|
+
: {}),
|
|
397
|
+
}, {
|
|
398
|
+
parentId: callerId,
|
|
399
|
+
rootId,
|
|
400
|
+
role: args.role,
|
|
401
|
+
depth: caller.depth + 1,
|
|
402
|
+
title: args.title,
|
|
403
|
+
actionId,
|
|
404
|
+
...(pins
|
|
405
|
+
? {
|
|
406
|
+
at: (r) => (typeof pins === "string" ? pins : pins.get(r.url)),
|
|
407
|
+
}
|
|
408
|
+
: {}),
|
|
409
|
+
});
|
|
410
|
+
childId = started.investigationId;
|
|
411
|
+
queued = started.queued;
|
|
412
|
+
await this.joined(callerId, rootId, childId);
|
|
413
|
+
}
|
|
414
|
+
const child = (await this.row(childId));
|
|
415
|
+
const members = await this.members(rootId);
|
|
416
|
+
const number = members.findIndex((m) => m.id === childId) + 1;
|
|
417
|
+
const link = threadLink(child);
|
|
418
|
+
const waits = await this.prisma.threadWait.findMany({
|
|
419
|
+
where: { targetId: actionId },
|
|
420
|
+
});
|
|
421
|
+
for (const w of waits) {
|
|
422
|
+
await this.prisma.threadWait
|
|
423
|
+
.create({
|
|
424
|
+
data: { waiterId: w.waiterId, targetId: childId, mode: w.mode },
|
|
425
|
+
})
|
|
426
|
+
.catch((e) => {
|
|
427
|
+
if (!isDuplicate(e))
|
|
428
|
+
throw e;
|
|
429
|
+
});
|
|
430
|
+
await this.prisma.threadWait.delete({
|
|
431
|
+
where: {
|
|
432
|
+
waiterId_targetId: { waiterId: w.waiterId, targetId: actionId },
|
|
433
|
+
},
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
value: {
|
|
438
|
+
status: "started",
|
|
439
|
+
childId,
|
|
440
|
+
number,
|
|
441
|
+
role: args.role,
|
|
442
|
+
link,
|
|
443
|
+
state: nodeState(child),
|
|
444
|
+
access,
|
|
445
|
+
...(access !== asked
|
|
446
|
+
? {
|
|
447
|
+
note: `Access was clamped to ${access}: a child never gets more than its parent.`,
|
|
448
|
+
}
|
|
449
|
+
: {}),
|
|
450
|
+
...(args.workspace.kind === "new_from_parent"
|
|
451
|
+
? {
|
|
452
|
+
workspace: "A new worktree at your current commit; your uncommitted changes are not in it.",
|
|
453
|
+
}
|
|
454
|
+
: {}),
|
|
455
|
+
...(queued ? { queued: true } : {}),
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
async joined(parentId, rootId, childId) {
|
|
460
|
+
const child = (await this.row(childId));
|
|
461
|
+
const link = threadLink(child);
|
|
462
|
+
await this.io.record(parentId, {
|
|
463
|
+
kind: "thread_started",
|
|
464
|
+
childId,
|
|
465
|
+
role: child.role ?? "thread",
|
|
466
|
+
title: child.title ?? "",
|
|
467
|
+
link,
|
|
468
|
+
});
|
|
469
|
+
const members = await this.members(rootId);
|
|
470
|
+
const number = members.findIndex((m) => m.id === childId) + 1;
|
|
471
|
+
for (const sib of members) {
|
|
472
|
+
if (sib.parentId !== parentId || sib.id === childId)
|
|
473
|
+
continue;
|
|
474
|
+
if (!LIVE.includes(sib.status))
|
|
475
|
+
continue;
|
|
476
|
+
await this.prisma.threadMessage
|
|
477
|
+
.create({
|
|
478
|
+
data: {
|
|
479
|
+
rootId,
|
|
480
|
+
fromId: parentId,
|
|
481
|
+
toId: sib.id,
|
|
482
|
+
type: "fact",
|
|
483
|
+
text: `${child.role} #${number} joined the tree: ${child.title ?? ""} (${link}).`,
|
|
484
|
+
requestId: `joined:${childId}`,
|
|
485
|
+
},
|
|
486
|
+
})
|
|
487
|
+
.catch((e) => {
|
|
488
|
+
if (!isDuplicate(e))
|
|
489
|
+
throw e;
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
async firstPrompt(callerId, rootId, args) {
|
|
494
|
+
const members = await this.members(rootId);
|
|
495
|
+
const parentNo = members.findIndex((m) => m.id === callerId) + 1;
|
|
496
|
+
const lines = members.slice(0, ROSTER_LINES).map((m, i) => {
|
|
497
|
+
const relation = m.id === callerId
|
|
498
|
+
? "your parent"
|
|
499
|
+
: m.parentId === callerId
|
|
500
|
+
? "sibling"
|
|
501
|
+
: m.id === rootId
|
|
502
|
+
? "root"
|
|
503
|
+
: "member";
|
|
504
|
+
return `- ${this.nameOf(m, rootId)} #${i + 1} (${relation}): ${m.title ?? "untitled"} — ${nodeState(m)} — ${threadLink(m)}`;
|
|
505
|
+
});
|
|
506
|
+
if (members.length > ROSTER_LINES)
|
|
507
|
+
lines.push(`- and ${members.length - ROSTER_LINES} more; thread_roster lists them.`);
|
|
508
|
+
return [
|
|
509
|
+
`You are "${args.role}", #${members.length + 1} in a tree of threads PrismaLens runs for the user. Your parent is #${parentNo}.`,
|
|
510
|
+
"Members:",
|
|
511
|
+
...lines,
|
|
512
|
+
"Messaging: thread_send to a member's role, `parent` or `root`. Send only what changes the receiver's work (handoff, blocker, fact, question, reply); never acknowledge; reply only to a question. Your final answer goes to your parent when you finish. Show the user links, not ids.",
|
|
513
|
+
"",
|
|
514
|
+
args.brief,
|
|
515
|
+
].join("\n");
|
|
516
|
+
}
|
|
517
|
+
async send(callerId, args) {
|
|
518
|
+
const self = await this.row(callerId);
|
|
519
|
+
if (!self)
|
|
520
|
+
return fail("run_ended", "This thread is gone.", "Stop messaging.");
|
|
521
|
+
if (!self.rootId)
|
|
522
|
+
return NO_TREE();
|
|
523
|
+
const rootId = this.rootOf(self);
|
|
524
|
+
const to = await this.resolveMember(callerId, args.to);
|
|
525
|
+
if (!to || to.id === callerId)
|
|
526
|
+
return fail("not_found", `No member "${args.to}" in this thread's tree.`, "Call thread_roster and pass a role, `parent` or `root` exactly as it lists them.");
|
|
527
|
+
if (args.mode === "steer" &&
|
|
528
|
+
!(args.type === "blocker" && to.parentId === callerId))
|
|
529
|
+
return fail("invalid_input", "Only a parent's blocker to its own child may steer.", "Send it again with mode `queue`.");
|
|
530
|
+
const sent = await this.prisma.threadMessage.count({ where: { rootId } });
|
|
531
|
+
const retried = sent >= TREE_MESSAGE_CAP &&
|
|
532
|
+
(await this.prisma.threadMessage.findUnique({
|
|
533
|
+
where: {
|
|
534
|
+
fromId_requestId: { fromId: callerId, requestId: args.requestId },
|
|
535
|
+
},
|
|
536
|
+
}));
|
|
537
|
+
if (retried)
|
|
538
|
+
return {
|
|
539
|
+
value: {
|
|
540
|
+
status: retried.state,
|
|
541
|
+
messageId: retried.id,
|
|
542
|
+
link: threadLink((await this.row(retried.toId)) ?? to),
|
|
543
|
+
},
|
|
544
|
+
};
|
|
545
|
+
if (sent >= TREE_MESSAGE_CAP)
|
|
546
|
+
return fail("limit_reached", `This thread tree has sent ${TREE_MESSAGE_CAP} messages, its limit.`, "Finish with what you have, and put anything left in your result.");
|
|
547
|
+
let message;
|
|
548
|
+
try {
|
|
549
|
+
message = await this.prisma.threadMessage.create({
|
|
550
|
+
data: {
|
|
551
|
+
rootId,
|
|
552
|
+
fromId: callerId,
|
|
553
|
+
toId: to.id,
|
|
554
|
+
type: args.type,
|
|
555
|
+
text: args.text,
|
|
556
|
+
mode: args.mode,
|
|
557
|
+
requestId: args.requestId,
|
|
558
|
+
},
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
catch (e) {
|
|
562
|
+
if (!isDuplicate(e))
|
|
563
|
+
throw e;
|
|
564
|
+
const seen = await this.prisma.threadMessage.findUniqueOrThrow({
|
|
565
|
+
where: {
|
|
566
|
+
fromId_requestId: { fromId: callerId, requestId: args.requestId },
|
|
567
|
+
},
|
|
568
|
+
});
|
|
569
|
+
return {
|
|
570
|
+
value: {
|
|
571
|
+
status: seen.state,
|
|
572
|
+
messageId: seen.id,
|
|
573
|
+
link: threadLink((await this.row(seen.toId)) ?? to),
|
|
574
|
+
},
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
await this.io.record(callerId, {
|
|
578
|
+
kind: "thread_message",
|
|
579
|
+
direction: "sent",
|
|
580
|
+
peerId: to.id,
|
|
581
|
+
peerRole: this.nameOf(to, rootId),
|
|
582
|
+
peerLink: threadLink(to),
|
|
583
|
+
type: args.type,
|
|
584
|
+
text: args.text,
|
|
585
|
+
mode: args.mode,
|
|
586
|
+
});
|
|
587
|
+
await this.drain();
|
|
588
|
+
const now = await this.prisma.threadMessage.findUniqueOrThrow({
|
|
589
|
+
where: { id: message.id },
|
|
590
|
+
});
|
|
591
|
+
return {
|
|
592
|
+
value: {
|
|
593
|
+
status: now.state,
|
|
594
|
+
messageId: now.id,
|
|
595
|
+
link: threadLink(to),
|
|
596
|
+
...(now.state === "queued" && isWorkflowTerminal(to.status)
|
|
597
|
+
? {
|
|
598
|
+
note: `${this.nameOf(to, rootId)} has ended; it gets this when it next runs.`,
|
|
599
|
+
}
|
|
600
|
+
: {}),
|
|
601
|
+
},
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
async formatted(m) {
|
|
605
|
+
const members = await this.members(m.rootId);
|
|
606
|
+
const i = members.findIndex((x) => x.id === m.fromId);
|
|
607
|
+
const from = members[i];
|
|
608
|
+
const name = from ? this.nameOf(from, m.rootId) : "thread";
|
|
609
|
+
return `[FROM ${name} #${i + 1}] ${m.type}: ${m.text}`;
|
|
610
|
+
}
|
|
611
|
+
drain() {
|
|
612
|
+
const pass = this.draining.then(() => this.drainOnce(), () => this.drainOnce());
|
|
613
|
+
this.draining = pass.catch(() => { });
|
|
614
|
+
return pass;
|
|
615
|
+
}
|
|
616
|
+
async drainOnce() {
|
|
617
|
+
const receivers = (await this.prisma.threadMessage.findMany({
|
|
618
|
+
where: { state: "queued" },
|
|
619
|
+
distinct: ["toId"],
|
|
620
|
+
select: { toId: true },
|
|
621
|
+
})).map((r) => r.toId);
|
|
622
|
+
if (!receivers.length)
|
|
623
|
+
return;
|
|
624
|
+
const [running, waiting] = await Promise.all([
|
|
625
|
+
this.prisma.investigation.findMany({
|
|
626
|
+
where: { id: { in: receivers }, status: { in: LIVE } },
|
|
627
|
+
select: { id: true },
|
|
628
|
+
}),
|
|
629
|
+
this.prisma.threadWait.findMany({
|
|
630
|
+
where: { waiterId: { in: receivers } },
|
|
631
|
+
distinct: ["waiterId"],
|
|
632
|
+
select: { waiterId: true },
|
|
633
|
+
}),
|
|
634
|
+
]);
|
|
635
|
+
const queued = await this.prisma.threadMessage.findMany({
|
|
636
|
+
where: {
|
|
637
|
+
state: "queued",
|
|
638
|
+
id: { notIn: this.putOff.skip() },
|
|
639
|
+
OR: [
|
|
640
|
+
{ toId: { in: running.map((r) => r.id) } },
|
|
641
|
+
{ toId: { in: waiting.map((w) => w.waiterId) }, type: "result" },
|
|
642
|
+
],
|
|
643
|
+
},
|
|
644
|
+
orderBy: { createdAt: "asc" },
|
|
645
|
+
take: MESSAGE_BATCH,
|
|
646
|
+
});
|
|
647
|
+
try {
|
|
648
|
+
await this.deliverEach(queued);
|
|
649
|
+
}
|
|
650
|
+
finally {
|
|
651
|
+
this.putOff.settle(queued.length, MESSAGE_BATCH);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
async deliverEach(queued) {
|
|
655
|
+
for (const m of queued) {
|
|
656
|
+
try {
|
|
657
|
+
await this.deliverMessage(m);
|
|
658
|
+
}
|
|
659
|
+
catch (e) {
|
|
660
|
+
logger.warn(`Could not deliver tree message ${m.id} to ${m.toId}: ${e.message}`);
|
|
661
|
+
this.putOff.defer(m.id);
|
|
662
|
+
if (m.type === "result")
|
|
663
|
+
await this.refusedReopen(m).catch(() => { });
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
async deliverMessage(m) {
|
|
668
|
+
const reopen = m.type === "result" && (await this.wakes(m.toId, m.fromId));
|
|
669
|
+
const got = await this.io.deliver(m.toId, await this.formatted(m), {
|
|
670
|
+
steer: m.mode === "steer",
|
|
671
|
+
reopen,
|
|
672
|
+
});
|
|
673
|
+
if (reopen && got.state === "later")
|
|
674
|
+
await this.refusedReopen(m);
|
|
675
|
+
if (got.state !== "delivered") {
|
|
676
|
+
this.putOff.defer(m.id);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
this.reopenTries.delete(m.id);
|
|
680
|
+
await this.prisma.threadMessage.update({
|
|
681
|
+
where: { id: m.id },
|
|
682
|
+
data: { state: "delivered", deliveredAt: new Date() },
|
|
683
|
+
});
|
|
684
|
+
if (reopen)
|
|
685
|
+
await this.prisma.threadWait.deleteMany({
|
|
686
|
+
where: { waiterId: m.toId },
|
|
687
|
+
});
|
|
688
|
+
if (m.type === "result")
|
|
689
|
+
return;
|
|
690
|
+
const from = await this.row(m.fromId);
|
|
691
|
+
if (!from)
|
|
692
|
+
return;
|
|
693
|
+
await this.io.record(m.toId, {
|
|
694
|
+
kind: "thread_message",
|
|
695
|
+
direction: "received",
|
|
696
|
+
peerId: from.id,
|
|
697
|
+
peerRole: this.nameOf(from, m.rootId),
|
|
698
|
+
peerLink: threadLink(from),
|
|
699
|
+
type: m.type,
|
|
700
|
+
text: m.text,
|
|
701
|
+
mode: m.mode,
|
|
702
|
+
messageId: got.messageId,
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
async refusedReopen(m) {
|
|
706
|
+
const tries = (this.reopenTries.get(m.id) ?? 0) + 1;
|
|
707
|
+
this.reopenTries.set(m.id, tries);
|
|
708
|
+
if (tries < REOPEN_TRIES)
|
|
709
|
+
return;
|
|
710
|
+
this.reopenTries.delete(m.id);
|
|
711
|
+
logger.info(`Gave up reopening ${m.toId} for a child's result after ${tries} tries`);
|
|
712
|
+
await this.prisma.threadWait.deleteMany({
|
|
713
|
+
where: { waiterId: m.toId, targetId: m.fromId },
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
async wakes(parentId, childId) {
|
|
717
|
+
const waits = await this.prisma.threadWait.findMany({
|
|
718
|
+
where: { waiterId: parentId },
|
|
719
|
+
});
|
|
720
|
+
if (!waits.some((w) => w.targetId === childId))
|
|
721
|
+
return false;
|
|
722
|
+
if (!waits.some((w) => w.mode === "all"))
|
|
723
|
+
return true;
|
|
724
|
+
const ids = waits.map((w) => w.targetId);
|
|
725
|
+
const [threads, starts] = await Promise.all([
|
|
726
|
+
this.prisma.investigation.findMany({
|
|
727
|
+
where: { id: { in: ids } },
|
|
728
|
+
select: { id: true, status: true },
|
|
729
|
+
}),
|
|
730
|
+
this.prisma.pendingAction.findMany({
|
|
731
|
+
where: { id: { in: ids } },
|
|
732
|
+
select: { id: true, state: true },
|
|
733
|
+
}),
|
|
734
|
+
]);
|
|
735
|
+
return ids.every((id) => {
|
|
736
|
+
const thread = threads.find((t) => t.id === id);
|
|
737
|
+
if (thread)
|
|
738
|
+
return isWorkflowTerminal(thread.status);
|
|
739
|
+
const start = starts.find((s) => s.id === id);
|
|
740
|
+
return (!!start &&
|
|
741
|
+
["denied", "expired", "cancelled", "failed"].includes(start.state));
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
async sweepFinished() {
|
|
745
|
+
const since = this.sweptTo;
|
|
746
|
+
const now = new Date();
|
|
747
|
+
const ended = await this.prisma.investigation.findMany({
|
|
748
|
+
where: {
|
|
749
|
+
parentId: { not: null },
|
|
750
|
+
status: { in: ["completed", "failed", "cancelled"] },
|
|
751
|
+
completedAt: { gte: new Date(since.getTime() - 60_000) },
|
|
752
|
+
},
|
|
753
|
+
select: { ...ROW, completedAt: true, summary: true },
|
|
754
|
+
});
|
|
755
|
+
for (const child of ended) {
|
|
756
|
+
const parentId = child.parentId;
|
|
757
|
+
const rootId = this.rootOf(child);
|
|
758
|
+
const outcome = outcomeOf(child);
|
|
759
|
+
const excerpt = cap((await this.finalText(child.id)) ?? child.summary ?? "");
|
|
760
|
+
const link = threadLink(child);
|
|
761
|
+
try {
|
|
762
|
+
await this.prisma.threadMessage.create({
|
|
763
|
+
data: {
|
|
764
|
+
rootId,
|
|
765
|
+
fromId: child.id,
|
|
766
|
+
toId: parentId,
|
|
767
|
+
type: "result",
|
|
768
|
+
text: `${link} finished: ${outcome}.${excerpt ? `\n${excerpt}` : ""}`,
|
|
769
|
+
requestId: `result:${child.completedAt?.toISOString()}`,
|
|
770
|
+
},
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
catch (e) {
|
|
774
|
+
if (isDuplicate(e))
|
|
775
|
+
continue;
|
|
776
|
+
throw e;
|
|
777
|
+
}
|
|
778
|
+
await this.io.record(parentId, {
|
|
779
|
+
kind: "child_finished",
|
|
780
|
+
childId: child.id,
|
|
781
|
+
link,
|
|
782
|
+
role: child.role ?? "thread",
|
|
783
|
+
outcome,
|
|
784
|
+
excerpt,
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
this.sweptTo = now;
|
|
788
|
+
await this.settleAllowances();
|
|
789
|
+
}
|
|
790
|
+
async finalText(id) {
|
|
791
|
+
const rows = await this.prisma.investigationEvent.findMany({
|
|
792
|
+
where: {
|
|
793
|
+
investigationId: id,
|
|
794
|
+
event: { contains: '"kind":"agent_step"' },
|
|
795
|
+
},
|
|
796
|
+
orderBy: { seq: "desc" },
|
|
797
|
+
take: 5,
|
|
798
|
+
select: { event: true },
|
|
799
|
+
});
|
|
800
|
+
for (const r of rows) {
|
|
801
|
+
try {
|
|
802
|
+
const e = JSON.parse(r.event);
|
|
803
|
+
if (e.text?.trim())
|
|
804
|
+
return e.text.trim();
|
|
805
|
+
}
|
|
806
|
+
catch { }
|
|
807
|
+
}
|
|
808
|
+
return null;
|
|
809
|
+
}
|
|
810
|
+
async settleAllowances() {
|
|
811
|
+
const all = await this.prisma.treeAllowance.findMany();
|
|
812
|
+
for (const a of all) {
|
|
813
|
+
const live = await this.prisma.investigation.count({
|
|
814
|
+
where: {
|
|
815
|
+
OR: [{ id: a.rootId }, { rootId: a.rootId }],
|
|
816
|
+
status: { in: LIVE },
|
|
817
|
+
},
|
|
818
|
+
});
|
|
819
|
+
if (!live)
|
|
820
|
+
await this.prisma.treeAllowance.deleteMany({
|
|
821
|
+
where: { rootId: a.rootId },
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
async sweepCancelled() {
|
|
826
|
+
const open = await this.prisma.pendingAction.findMany({
|
|
827
|
+
where: { state: "pending" },
|
|
828
|
+
select: { callerId: true },
|
|
829
|
+
distinct: ["callerId"],
|
|
830
|
+
});
|
|
831
|
+
if (!open.length)
|
|
832
|
+
return;
|
|
833
|
+
const cancelled = await this.prisma.investigation.findMany({
|
|
834
|
+
where: { id: { in: open.map((o) => o.callerId) }, status: "cancelled" },
|
|
835
|
+
select: { id: true },
|
|
836
|
+
});
|
|
837
|
+
for (const c of cancelled)
|
|
838
|
+
await this.actions.cancelFor(c.id);
|
|
839
|
+
}
|
|
840
|
+
async wait(callerId, ids, mode) {
|
|
841
|
+
const self = await this.row(callerId);
|
|
842
|
+
if (!self)
|
|
843
|
+
return fail("run_ended", "This thread is gone.", "Stop waiting.");
|
|
844
|
+
if (!self.rootId &&
|
|
845
|
+
!(await this.prisma.pendingAction.count({
|
|
846
|
+
where: {
|
|
847
|
+
callerId,
|
|
848
|
+
tool: "thread_start",
|
|
849
|
+
state: { in: ["pending", "approved", "executing"] },
|
|
850
|
+
},
|
|
851
|
+
})))
|
|
852
|
+
return NO_TREE();
|
|
853
|
+
const targets = [];
|
|
854
|
+
for (const key of ids) {
|
|
855
|
+
const action = await this.prisma.pendingAction.findFirst({
|
|
856
|
+
where: {
|
|
857
|
+
callerId,
|
|
858
|
+
tool: "thread_start",
|
|
859
|
+
OR: [{ requestId: key }, { id: key }],
|
|
860
|
+
},
|
|
861
|
+
});
|
|
862
|
+
if (action) {
|
|
863
|
+
const childId = action.result
|
|
864
|
+
? JSON.parse(action.result).childId
|
|
865
|
+
: undefined;
|
|
866
|
+
if (childId) {
|
|
867
|
+
const child = await this.row(childId);
|
|
868
|
+
if (child) {
|
|
869
|
+
targets.push({
|
|
870
|
+
key,
|
|
871
|
+
targetId: child.id,
|
|
872
|
+
state: nodeState(child),
|
|
873
|
+
link: threadLink(child),
|
|
874
|
+
});
|
|
875
|
+
continue;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
if (action.state === "pending" ||
|
|
879
|
+
action.state === "approved" ||
|
|
880
|
+
action.state === "executing") {
|
|
881
|
+
targets.push({ key, targetId: action.id, state: "pending_approval" });
|
|
882
|
+
continue;
|
|
883
|
+
}
|
|
884
|
+
return fail("not_found", `The start "${key}" ended without a thread (${action.state}).`, "Drop it from `ids` and call thread_wait again.");
|
|
885
|
+
}
|
|
886
|
+
const member = await this.resolveMember(callerId, key);
|
|
887
|
+
if (!member || member.parentId !== callerId)
|
|
888
|
+
return fail("not_found", `"${key}" is not a child of this thread.`, "Pass a child's role or link from thread_roster, or a thread_start requestId.");
|
|
889
|
+
targets.push({
|
|
890
|
+
key,
|
|
891
|
+
targetId: member.id,
|
|
892
|
+
state: nodeState(member),
|
|
893
|
+
link: threadLink(member),
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
for (const t of targets)
|
|
897
|
+
await this.prisma.threadWait.upsert({
|
|
898
|
+
where: {
|
|
899
|
+
waiterId_targetId: { waiterId: callerId, targetId: t.targetId },
|
|
900
|
+
},
|
|
901
|
+
create: { waiterId: callerId, targetId: t.targetId, mode },
|
|
902
|
+
update: { mode },
|
|
903
|
+
});
|
|
904
|
+
return {
|
|
905
|
+
value: {
|
|
906
|
+
waiting: targets.map(({ key, state, link }) => ({
|
|
907
|
+
id: key,
|
|
908
|
+
state,
|
|
909
|
+
...(link ? { link } : {}),
|
|
910
|
+
})),
|
|
911
|
+
mode,
|
|
912
|
+
next: "Registered. Do not poll: each result arrives as a message at your next pause, and if you have ended, your thread reopens for it.",
|
|
913
|
+
},
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
async revokeAllowance(rootId) {
|
|
917
|
+
await this.prisma.treeAllowance.deleteMany({ where: { rootId } });
|
|
918
|
+
}
|
|
919
|
+
async cancelRefusal(callerId, id) {
|
|
920
|
+
if (!(await this.row(callerId))?.rootId)
|
|
921
|
+
return NO_TREE();
|
|
922
|
+
const target = await this.resolveMember(callerId, id);
|
|
923
|
+
if (!target || !(await this.isDescendant(target, callerId)))
|
|
924
|
+
return fail("not_found", `"${id}" is not a thread this one started.`, "Pass the role or link of a child from thread_roster.");
|
|
925
|
+
if (isWorkflowTerminal(target.status))
|
|
926
|
+
return fail("invalid_input", `${threadLink(target)} has already ended.`, "Nothing to cancel; continue.");
|
|
927
|
+
return null;
|
|
928
|
+
}
|
|
929
|
+
async isDescendant(row, ancestorId) {
|
|
930
|
+
let cur = row;
|
|
931
|
+
for (let i = 0; cur && i < 10; i++) {
|
|
932
|
+
if (cur.parentId === ancestorId)
|
|
933
|
+
return true;
|
|
934
|
+
cur = cur.parentId ? await this.row(cur.parentId) : null;
|
|
935
|
+
}
|
|
936
|
+
return false;
|
|
937
|
+
}
|
|
938
|
+
async cancelMember(callerId, args) {
|
|
939
|
+
const target = (await this.resolveMember(callerId, args.id));
|
|
940
|
+
await this.stop(target.id, args.reason);
|
|
941
|
+
await this.actions.cancelFor(target.id);
|
|
942
|
+
return { value: { status: "stopping", link: threadLink(target) } };
|
|
943
|
+
}
|
|
944
|
+
async stop(id, reason) {
|
|
945
|
+
const row = await this.row(id);
|
|
946
|
+
if (!row || isWorkflowTerminal(row.status))
|
|
947
|
+
return;
|
|
948
|
+
const why = `Stopped by its parent: ${cap(reason, 200)}`;
|
|
949
|
+
if (row.status === "pending" &&
|
|
950
|
+
(await this.dispatch.cancelPendingJob(id))) {
|
|
951
|
+
await this.investigations.cancelPending(id, row.incidentId, why);
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
await this.investigations.markStopRequested(id);
|
|
955
|
+
if ((await this.dispatch.requestCancel(id)) === 0) {
|
|
956
|
+
await this.dispatch.cancelOrphanedRun(id);
|
|
957
|
+
await this.investigations.cancelPending(id, row.incidentId, why);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
ThreadTreeService = __decorate([
|
|
962
|
+
Injectable(),
|
|
963
|
+
__metadata("design:paramtypes", [PrismaService,
|
|
964
|
+
ThreadsService,
|
|
965
|
+
DispatchService,
|
|
966
|
+
InvestigationsService,
|
|
967
|
+
TreeSettings,
|
|
968
|
+
PendingActionsService,
|
|
969
|
+
TreeIo])
|
|
970
|
+
], ThreadTreeService);
|
|
971
|
+
export { ThreadTreeService };
|
|
972
|
+
//# sourceMappingURL=thread-tree.service.js.map
|