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,898 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var SchedulesService_1;
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
15
|
+
import { resolve } from "node:path";
|
|
16
|
+
import { Inject, Injectable, Logger, Optional, } from "@nestjs/common";
|
|
17
|
+
import { AccessLevelSchema, AUTO_START_ACCESS_LEVEL, LIVE_WORKFLOW_STATUSES, } from "@prismalens/contracts";
|
|
18
|
+
import { HarnessService } from "../../core/harness/harness.service.js";
|
|
19
|
+
import { RuntimeLifecycleService } from "../../core/lifecycle/runtime-lifecycle.service.js";
|
|
20
|
+
import { PrismaService } from "../../core/prisma/prisma.service.js";
|
|
21
|
+
import { DispatchService } from "../../infrastructure/dispatch/dispatch.service.js";
|
|
22
|
+
import { CanonicalBusy, canonical, sameAsDisk, } from "../../infrastructure/dispatch/folder-lock.js";
|
|
23
|
+
import { serviceNotes } from "../../infrastructure/dispatch/investigation-run.js";
|
|
24
|
+
import { PrismaJobStore, SCHEDULED_KIND, } from "../../infrastructure/dispatch/job-store.js";
|
|
25
|
+
import { shownFullName } from "../repositories/serialize-repository.js";
|
|
26
|
+
import { SessionLifecycleService } from "../wakes/session-lifecycle.service.js";
|
|
27
|
+
import { allowedAsks } from "./allowed-asks.js";
|
|
28
|
+
import { decide } from "./decide.js";
|
|
29
|
+
import { cronShape, nextSlots, recurrenceError, } from "./recurrence.js";
|
|
30
|
+
import { describeRecurrence, dstNote } from "./schedule-text.js";
|
|
31
|
+
export const LOOP_MS = 30_000;
|
|
32
|
+
export const SCHEDULED_PRIORITY = 5;
|
|
33
|
+
export const FAILURES_BEFORE_PAUSE = 3;
|
|
34
|
+
const MAX_SCHEDULES = 50;
|
|
35
|
+
export class ScheduleError extends Error {
|
|
36
|
+
code;
|
|
37
|
+
constructor(code, message) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.code = code;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const STARTING = new Set(["started", "late_started", "run_now"]);
|
|
43
|
+
export const FOLDER_REFUSED = "A Folder project can't run on a schedule. Start git here first.";
|
|
44
|
+
function subjectOf(s) {
|
|
45
|
+
return s.repositoryId ? "project" : s.serviceId ? "service" : "none";
|
|
46
|
+
}
|
|
47
|
+
export const FOLDER_MOVED = "The project's folder is not where it was saved. Review it and resume.";
|
|
48
|
+
function bindingsChanged(subject, fix) {
|
|
49
|
+
return subject === "project"
|
|
50
|
+
? `The project's code location changed since this schedule was saved. ${fix}`
|
|
51
|
+
: `The service's repositories or notes changed since this schedule was saved. ${fix}`;
|
|
52
|
+
}
|
|
53
|
+
export function parseRecurrence(json) {
|
|
54
|
+
const r = JSON.parse(json);
|
|
55
|
+
return r.type === "interval"
|
|
56
|
+
? { ...r, anchorAt: new Date(r.anchorAt) }
|
|
57
|
+
: r;
|
|
58
|
+
}
|
|
59
|
+
function toRecurrence(input) {
|
|
60
|
+
return input.type === "interval"
|
|
61
|
+
? { ...input, anchorAt: new Date(input.anchorAt) }
|
|
62
|
+
: input;
|
|
63
|
+
}
|
|
64
|
+
let SchedulesService = SchedulesService_1 = class SchedulesService {
|
|
65
|
+
prisma;
|
|
66
|
+
dispatch;
|
|
67
|
+
harness;
|
|
68
|
+
gaps;
|
|
69
|
+
sessions;
|
|
70
|
+
logger = new Logger(SchedulesService_1.name);
|
|
71
|
+
timer = null;
|
|
72
|
+
chain = Promise.resolve();
|
|
73
|
+
constructor(prisma, dispatch, harness, gaps, sessions) {
|
|
74
|
+
this.prisma = prisma;
|
|
75
|
+
this.dispatch = dispatch;
|
|
76
|
+
this.harness = harness;
|
|
77
|
+
this.gaps = gaps;
|
|
78
|
+
this.sessions = sessions;
|
|
79
|
+
}
|
|
80
|
+
onApplicationBootstrap() {
|
|
81
|
+
this.timer = setInterval(() => void this.kick(), LOOP_MS);
|
|
82
|
+
this.timer.unref();
|
|
83
|
+
void this.kick();
|
|
84
|
+
}
|
|
85
|
+
onModuleDestroy() {
|
|
86
|
+
if (this.timer)
|
|
87
|
+
clearInterval(this.timer);
|
|
88
|
+
}
|
|
89
|
+
kick(now) {
|
|
90
|
+
const run = this.chain.then(() => this.evaluate(now ?? new Date()));
|
|
91
|
+
this.chain = run.catch((error) => this.logger.error("Schedule evaluation failed", error));
|
|
92
|
+
return this.chain.then(() => undefined);
|
|
93
|
+
}
|
|
94
|
+
serial(work) {
|
|
95
|
+
const run = this.chain.then(work);
|
|
96
|
+
this.chain = run.catch(() => undefined);
|
|
97
|
+
return run;
|
|
98
|
+
}
|
|
99
|
+
async evaluate(now) {
|
|
100
|
+
await this.sessions
|
|
101
|
+
?.process(now)
|
|
102
|
+
.catch((error) => this.logger.error("Wakes were not processed", error));
|
|
103
|
+
await this.expire(now);
|
|
104
|
+
await this.pauseFailing();
|
|
105
|
+
const due = await this.prisma.schedule.findMany({
|
|
106
|
+
where: { enabled: true, nextRunAt: { lte: now } },
|
|
107
|
+
});
|
|
108
|
+
for (const s of due) {
|
|
109
|
+
try {
|
|
110
|
+
await this.evaluateOne(s, now);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
this.logger.error(`Schedule ${s.id} was not evaluated`, error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async evaluateOne(s, now) {
|
|
118
|
+
if (!s.nextRunAt)
|
|
119
|
+
return;
|
|
120
|
+
let observed = false;
|
|
121
|
+
const decision = decide({
|
|
122
|
+
recurrence: parseRecurrence(s.recurrence),
|
|
123
|
+
nextRunAt: s.nextRunAt,
|
|
124
|
+
missedPolicy: s.missedPolicy,
|
|
125
|
+
catchUpMinutes: s.catchUpMinutes,
|
|
126
|
+
}, now, (at) => {
|
|
127
|
+
if (!observed)
|
|
128
|
+
this.gaps?.observe(now);
|
|
129
|
+
observed = true;
|
|
130
|
+
return this.gaps?.gapCovering(at) ?? null;
|
|
131
|
+
});
|
|
132
|
+
if (!decision)
|
|
133
|
+
return;
|
|
134
|
+
let outcome = decision.outcome;
|
|
135
|
+
let reason = decision.gap;
|
|
136
|
+
if (STARTING.has(outcome)) {
|
|
137
|
+
const ready = await this.harness.ensureReady(s.harness);
|
|
138
|
+
if (!ready.ready) {
|
|
139
|
+
outcome = "skipped_agent_not_ready";
|
|
140
|
+
reason = ready.reason;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
await this.admit(s, now, { ...decision, outcome, reason }, "tick");
|
|
144
|
+
}
|
|
145
|
+
async admit(s, now, d, mode) {
|
|
146
|
+
const moved = STARTING.has(d.outcome) && (await this.folderMoved(s));
|
|
147
|
+
const admitted = await this.prisma.$transaction(async (tx) => {
|
|
148
|
+
if (mode === "tick") {
|
|
149
|
+
const { count } = await tx.schedule.updateMany({
|
|
150
|
+
where: {
|
|
151
|
+
id: s.id,
|
|
152
|
+
revision: s.revision,
|
|
153
|
+
enabled: true,
|
|
154
|
+
nextRunAt: s.nextRunAt,
|
|
155
|
+
},
|
|
156
|
+
data: { nextRunAt: d.next ?? null, lastEvaluatedAt: now },
|
|
157
|
+
});
|
|
158
|
+
if (count === 0)
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
const { count } = await tx.schedule.updateMany({
|
|
163
|
+
where: { id: s.id, revision: s.revision },
|
|
164
|
+
data: { lastEvaluatedAt: now },
|
|
165
|
+
});
|
|
166
|
+
if (count === 0)
|
|
167
|
+
throw new ScheduleError("CONFLICT", "This schedule changed. Reload it and try again.");
|
|
168
|
+
}
|
|
169
|
+
let outcome = d.outcome;
|
|
170
|
+
const reason = d.reason;
|
|
171
|
+
let frozen = null;
|
|
172
|
+
if (STARTING.has(outcome)) {
|
|
173
|
+
const live = await tx.investigation.findFirst({
|
|
174
|
+
where: {
|
|
175
|
+
scheduleId: s.id,
|
|
176
|
+
status: { in: [...LIVE_WORKFLOW_STATUSES] },
|
|
177
|
+
},
|
|
178
|
+
select: { id: true },
|
|
179
|
+
});
|
|
180
|
+
if (live) {
|
|
181
|
+
if (mode === "run_now")
|
|
182
|
+
throw new ScheduleError("CONFLICT", "A run of this schedule is still going.");
|
|
183
|
+
outcome = "skipped_overlap";
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
frozen = await this.freeze(tx, s);
|
|
187
|
+
const subject = subjectOf(s);
|
|
188
|
+
if (frozen.hash !== s.bindingsHash || frozen.folder || moved) {
|
|
189
|
+
if (mode === "run_now")
|
|
190
|
+
throw new ScheduleError("CONFLICT", frozen.folder
|
|
191
|
+
? FOLDER_REFUSED
|
|
192
|
+
: moved
|
|
193
|
+
? FOLDER_MOVED
|
|
194
|
+
: bindingsChanged(subject, "Save it again to confirm."));
|
|
195
|
+
outcome = "skipped_bindings_changed";
|
|
196
|
+
frozen = null;
|
|
197
|
+
await tx.schedule.updateMany({
|
|
198
|
+
where: { id: s.id, revision: s.revision },
|
|
199
|
+
data: {
|
|
200
|
+
enabled: false,
|
|
201
|
+
pausedReason: moved
|
|
202
|
+
? FOLDER_MOVED
|
|
203
|
+
: bindingsChanged(subject, "Review it and resume."),
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
await tx.scheduleEvent.create({
|
|
207
|
+
data: {
|
|
208
|
+
scheduleId: s.id,
|
|
209
|
+
action: "paused_by_prismalens",
|
|
210
|
+
after: JSON.stringify({ reason: "bindings_changed" }),
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const tick = await tx.scheduleTick.create({
|
|
217
|
+
data: {
|
|
218
|
+
scheduleId: s.id,
|
|
219
|
+
scheduledFor: d.slot,
|
|
220
|
+
outcome,
|
|
221
|
+
reason,
|
|
222
|
+
missedCount: d.missedCount,
|
|
223
|
+
missedOverflow: d.missedOverflow,
|
|
224
|
+
revision: s.revision,
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
if (!frozen)
|
|
228
|
+
return { tickId: tick.id, investigationId: null };
|
|
229
|
+
const investigationId = await this.createRun(tx, s, frozen.run, outcome, d.startBy);
|
|
230
|
+
await tx.scheduleTick.update({
|
|
231
|
+
where: { id: tick.id },
|
|
232
|
+
data: { investigationId },
|
|
233
|
+
});
|
|
234
|
+
return { tickId: tick.id, investigationId };
|
|
235
|
+
});
|
|
236
|
+
if (!admitted)
|
|
237
|
+
return null;
|
|
238
|
+
if (admitted.investigationId)
|
|
239
|
+
this.dispatch.startAdmitted(admitted.investigationId);
|
|
240
|
+
return this.tickDto(admitted.tickId);
|
|
241
|
+
}
|
|
242
|
+
async createRun(tx, s, scheduled, outcome, startBy) {
|
|
243
|
+
const accessLevel = AccessLevelSchema.safeParse(s.accessLevel).data ??
|
|
244
|
+
AUTO_START_ACCESS_LEVEL;
|
|
245
|
+
const chat = !s.report;
|
|
246
|
+
const run = await tx.investigation.create({
|
|
247
|
+
data: {
|
|
248
|
+
incidentId: null,
|
|
249
|
+
serviceId: s.serviceId,
|
|
250
|
+
repositoryId: s.repositoryId,
|
|
251
|
+
scheduleId: s.id,
|
|
252
|
+
scheduleRevision: s.revision,
|
|
253
|
+
configSnapshot: JSON.stringify({
|
|
254
|
+
...scheduled,
|
|
255
|
+
brief: s.brief,
|
|
256
|
+
harness: s.harness,
|
|
257
|
+
model: s.model,
|
|
258
|
+
effort: s.effort,
|
|
259
|
+
}),
|
|
260
|
+
status: "pending",
|
|
261
|
+
kind: chat ? "chat" : "investigation",
|
|
262
|
+
title: s.name,
|
|
263
|
+
triggerType: "scheduled",
|
|
264
|
+
triggerReason: outcome === "run_now" ? "Run now" : `Schedule: ${s.name}`,
|
|
265
|
+
harness: s.harness,
|
|
266
|
+
model: s.model,
|
|
267
|
+
effort: s.effort,
|
|
268
|
+
accessLevel,
|
|
269
|
+
},
|
|
270
|
+
select: { id: true },
|
|
271
|
+
});
|
|
272
|
+
const data = {
|
|
273
|
+
incidentId: null,
|
|
274
|
+
investigationId: run.id,
|
|
275
|
+
scheduled,
|
|
276
|
+
...(chat
|
|
277
|
+
? { kind: "chat", chat: { text: s.brief } }
|
|
278
|
+
: { brief: s.brief }),
|
|
279
|
+
unattended: s.whenAsks !== "wait",
|
|
280
|
+
...(s.whenAsks === "wait" ? { waitForAsks: true } : {}),
|
|
281
|
+
startedBy: "schedule",
|
|
282
|
+
accessLevel,
|
|
283
|
+
harness: s.harness,
|
|
284
|
+
...(s.model ? { model: s.model } : {}),
|
|
285
|
+
...(s.effort ? { effort: s.effort } : {}),
|
|
286
|
+
};
|
|
287
|
+
await new PrismaJobStore(tx.job).enqueue({
|
|
288
|
+
investigationId: run.id,
|
|
289
|
+
incidentId: null,
|
|
290
|
+
payload: JSON.stringify(data),
|
|
291
|
+
priority: SCHEDULED_PRIORITY,
|
|
292
|
+
kind: SCHEDULED_KIND,
|
|
293
|
+
startBy: outcome === "run_now" ? null : startBy,
|
|
294
|
+
});
|
|
295
|
+
return run.id;
|
|
296
|
+
}
|
|
297
|
+
async freeze(db, s) {
|
|
298
|
+
const remembered = allowedAsks(s.alwaysAllow);
|
|
299
|
+
const common = {
|
|
300
|
+
scheduleId: s.id,
|
|
301
|
+
revision: s.revision,
|
|
302
|
+
runbook: s.runbook,
|
|
303
|
+
...(remembered.length ? { alwaysAllow: remembered } : {}),
|
|
304
|
+
};
|
|
305
|
+
if (s.repositoryId) {
|
|
306
|
+
const repo = await db.repository.findUnique({
|
|
307
|
+
where: { id: s.repositoryId },
|
|
308
|
+
select: {
|
|
309
|
+
sourceKind: true,
|
|
310
|
+
url: true,
|
|
311
|
+
fullName: true,
|
|
312
|
+
defaultBranch: true,
|
|
313
|
+
connectionId: true,
|
|
314
|
+
subPath: true,
|
|
315
|
+
plain: true,
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
if (!repo)
|
|
319
|
+
throw new ScheduleError("NOT_FOUND", "That project no longer exists.");
|
|
320
|
+
const name = shownFullName(repo);
|
|
321
|
+
const ref = {
|
|
322
|
+
sourceKind: repo.sourceKind === "folder" ? "folder" : "url",
|
|
323
|
+
url: repo.url,
|
|
324
|
+
defaultBranch: repo.defaultBranch ?? null,
|
|
325
|
+
subPath: repo.subPath ?? null,
|
|
326
|
+
connectionId: repo.connectionId ?? null,
|
|
327
|
+
serviceName: name,
|
|
328
|
+
...(repo.plain ? { plain: true } : {}),
|
|
329
|
+
};
|
|
330
|
+
return {
|
|
331
|
+
hash: createHash("sha256")
|
|
332
|
+
.update(JSON.stringify({ subject: "project", repos: [ref] }))
|
|
333
|
+
.digest("hex"),
|
|
334
|
+
folder: repo.plain,
|
|
335
|
+
run: {
|
|
336
|
+
...common,
|
|
337
|
+
subject: "project",
|
|
338
|
+
serviceId: null,
|
|
339
|
+
serviceName: "",
|
|
340
|
+
repositoryId: s.repositoryId,
|
|
341
|
+
projectName: name,
|
|
342
|
+
serviceNotes: null,
|
|
343
|
+
repos: [ref],
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
if (!s.serviceId)
|
|
348
|
+
return {
|
|
349
|
+
hash: createHash("sha256")
|
|
350
|
+
.update(JSON.stringify({ subject: "none" }))
|
|
351
|
+
.digest("hex"),
|
|
352
|
+
folder: false,
|
|
353
|
+
run: {
|
|
354
|
+
...common,
|
|
355
|
+
subject: "none",
|
|
356
|
+
serviceId: null,
|
|
357
|
+
serviceName: "",
|
|
358
|
+
serviceNotes: null,
|
|
359
|
+
repos: [],
|
|
360
|
+
},
|
|
361
|
+
};
|
|
362
|
+
const service = await db.service.findUnique({
|
|
363
|
+
where: { id: s.serviceId },
|
|
364
|
+
select: {
|
|
365
|
+
id: true,
|
|
366
|
+
name: true,
|
|
367
|
+
metadata: true,
|
|
368
|
+
repositories: {
|
|
369
|
+
orderBy: [{ isPrimary: "desc" }, { createdAt: "asc" }],
|
|
370
|
+
select: {
|
|
371
|
+
subPath: true,
|
|
372
|
+
isPrimary: true,
|
|
373
|
+
repository: {
|
|
374
|
+
select: {
|
|
375
|
+
sourceKind: true,
|
|
376
|
+
url: true,
|
|
377
|
+
defaultBranch: true,
|
|
378
|
+
connectionId: true,
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
if (!service)
|
|
386
|
+
throw new ScheduleError("NOT_FOUND", "That service no longer exists.");
|
|
387
|
+
const repos = service.repositories.map((r) => ({
|
|
388
|
+
sourceKind: r.repository.sourceKind === "folder"
|
|
389
|
+
? "folder"
|
|
390
|
+
: "url",
|
|
391
|
+
url: r.repository.url,
|
|
392
|
+
defaultBranch: r.repository.defaultBranch ?? null,
|
|
393
|
+
subPath: r.subPath ?? null,
|
|
394
|
+
connectionId: r.repository.connectionId ?? null,
|
|
395
|
+
serviceName: service.name,
|
|
396
|
+
}));
|
|
397
|
+
const notes = serviceNotes(service.metadata);
|
|
398
|
+
const hash = createHash("sha256")
|
|
399
|
+
.update(JSON.stringify({
|
|
400
|
+
repos,
|
|
401
|
+
primary: service.repositories.map((r) => r.isPrimary),
|
|
402
|
+
notes,
|
|
403
|
+
}))
|
|
404
|
+
.digest("hex");
|
|
405
|
+
const run = {
|
|
406
|
+
...common,
|
|
407
|
+
subject: "service",
|
|
408
|
+
serviceId: service.id,
|
|
409
|
+
serviceName: service.name,
|
|
410
|
+
serviceNotes: notes,
|
|
411
|
+
repos,
|
|
412
|
+
};
|
|
413
|
+
return { hash, run, folder: false };
|
|
414
|
+
}
|
|
415
|
+
async expire(now) {
|
|
416
|
+
const due = await new PrismaJobStore(this.prisma.job).scheduledPastDeadline(now);
|
|
417
|
+
for (const job of due) {
|
|
418
|
+
await this.prisma.$transaction(async (tx) => {
|
|
419
|
+
const store = new PrismaJobStore(tx.job);
|
|
420
|
+
if (!(await store.expireScheduledJob(job.id, now)))
|
|
421
|
+
return;
|
|
422
|
+
await tx.investigation.updateMany({
|
|
423
|
+
where: { id: job.investigationId, status: "pending" },
|
|
424
|
+
data: {
|
|
425
|
+
status: "cancelled",
|
|
426
|
+
completedAt: now,
|
|
427
|
+
error: "Not started: PrismaLens was busy with other runs until this run's deadline.",
|
|
428
|
+
},
|
|
429
|
+
});
|
|
430
|
+
await tx.scheduleTick.updateMany({
|
|
431
|
+
where: { investigationId: job.investigationId },
|
|
432
|
+
data: { outcome: "expired_host_busy" },
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
async pauseFailing() {
|
|
438
|
+
const enabled = await this.prisma.schedule.findMany({
|
|
439
|
+
where: { enabled: true },
|
|
440
|
+
});
|
|
441
|
+
for (const s of enabled) {
|
|
442
|
+
const ticks = await this.prisma.scheduleTick.findMany({
|
|
443
|
+
where: {
|
|
444
|
+
scheduleId: s.id,
|
|
445
|
+
revision: s.revision,
|
|
446
|
+
investigationId: { not: null },
|
|
447
|
+
},
|
|
448
|
+
orderBy: { scheduledFor: "desc" },
|
|
449
|
+
take: FAILURES_BEFORE_PAUSE + 1,
|
|
450
|
+
select: { investigationId: true },
|
|
451
|
+
});
|
|
452
|
+
const runs = await this.prisma.investigation.findMany({
|
|
453
|
+
where: { id: { in: ticks.map((t) => t.investigationId) } },
|
|
454
|
+
select: { id: true, status: true },
|
|
455
|
+
});
|
|
456
|
+
const status = new Map(runs.map((r) => [r.id, r.status]));
|
|
457
|
+
let trailing = 0;
|
|
458
|
+
for (const t of ticks) {
|
|
459
|
+
const st = status.get(t.investigationId);
|
|
460
|
+
if (st === "pending" || st === "running")
|
|
461
|
+
continue;
|
|
462
|
+
if (st !== "failed")
|
|
463
|
+
break;
|
|
464
|
+
trailing++;
|
|
465
|
+
}
|
|
466
|
+
if (trailing === s.consecutiveFailures &&
|
|
467
|
+
trailing < FAILURES_BEFORE_PAUSE)
|
|
468
|
+
continue;
|
|
469
|
+
const pause = trailing >= FAILURES_BEFORE_PAUSE;
|
|
470
|
+
const { count } = await this.prisma.schedule.updateMany({
|
|
471
|
+
where: { id: s.id, revision: s.revision, enabled: true },
|
|
472
|
+
data: {
|
|
473
|
+
consecutiveFailures: trailing,
|
|
474
|
+
...(pause
|
|
475
|
+
? {
|
|
476
|
+
enabled: false,
|
|
477
|
+
pausedReason: "Paused after three failed runs in a row.",
|
|
478
|
+
}
|
|
479
|
+
: {}),
|
|
480
|
+
},
|
|
481
|
+
});
|
|
482
|
+
if (pause && count === 1)
|
|
483
|
+
await this.prisma.scheduleEvent.create({
|
|
484
|
+
data: {
|
|
485
|
+
scheduleId: s.id,
|
|
486
|
+
action: "paused_by_prismalens",
|
|
487
|
+
after: JSON.stringify({ reason: "failures" }),
|
|
488
|
+
},
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
async list() {
|
|
493
|
+
const rows = await this.prisma.schedule.findMany({
|
|
494
|
+
orderBy: { createdAt: "asc" },
|
|
495
|
+
});
|
|
496
|
+
return {
|
|
497
|
+
schedules: await Promise.all(rows.map((r) => this.toDto(r))),
|
|
498
|
+
builtIns: await this.builtIns(),
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
async get(id, cursor, limit) {
|
|
502
|
+
const row = await this.prisma.schedule.findUnique({ where: { id } });
|
|
503
|
+
if (!row)
|
|
504
|
+
throw new ScheduleError("NOT_FOUND", "No such schedule.");
|
|
505
|
+
const ticks = await this.prisma.scheduleTick.findMany({
|
|
506
|
+
where: { scheduleId: id },
|
|
507
|
+
orderBy: [{ scheduledFor: "desc" }, { id: "desc" }],
|
|
508
|
+
take: limit + 1,
|
|
509
|
+
...(cursor ? { cursor: { id: cursor }, skip: 1 } : {}),
|
|
510
|
+
});
|
|
511
|
+
const page = ticks.slice(0, limit);
|
|
512
|
+
return {
|
|
513
|
+
schedule: await this.toDto(row),
|
|
514
|
+
ticks: await Promise.all(page.map((t) => this.tickDto(t.id))).then((all) => all.filter((t) => t !== null)),
|
|
515
|
+
nextCursor: ticks.length > limit ? (page.at(-1)?.id ?? null) : null,
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
preview(recurrence, now = new Date()) {
|
|
519
|
+
const r = toRecurrence(recurrence);
|
|
520
|
+
const error = recurrenceError(r);
|
|
521
|
+
if (error)
|
|
522
|
+
return { description: null, shape: null, next: [], dstNote: null, error };
|
|
523
|
+
return {
|
|
524
|
+
description: describeRecurrence(r),
|
|
525
|
+
shape: r.type === "interval" ? "interval" : cronShape(r.expr),
|
|
526
|
+
next: nextSlots(r, now, 3).map((d) => d.toISOString()),
|
|
527
|
+
dstNote: dstNote(r, now),
|
|
528
|
+
error: null,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
create(input, deviceId, now = new Date()) {
|
|
532
|
+
return this.serial(async () => {
|
|
533
|
+
const r = this.validRecurrence(input);
|
|
534
|
+
if ((await this.prisma.schedule.count()) >= MAX_SCHEDULES)
|
|
535
|
+
throw new ScheduleError("BAD_REQUEST", `PrismaLens keeps at most ${MAX_SCHEDULES} schedules.`);
|
|
536
|
+
const frozen = await this.saveable(input, "", 1, null);
|
|
537
|
+
const row = await this.prisma.$transaction(async (tx) => {
|
|
538
|
+
const created = await tx.schedule.create({
|
|
539
|
+
data: {
|
|
540
|
+
...this.columns(input),
|
|
541
|
+
bindingsHash: frozen.hash,
|
|
542
|
+
nextRunAt: nextSlots(r, now, 1)[0] ?? null,
|
|
543
|
+
},
|
|
544
|
+
});
|
|
545
|
+
await tx.scheduleEvent.create({
|
|
546
|
+
data: {
|
|
547
|
+
scheduleId: created.id,
|
|
548
|
+
action: "created",
|
|
549
|
+
deviceId,
|
|
550
|
+
after: JSON.stringify(input),
|
|
551
|
+
},
|
|
552
|
+
});
|
|
553
|
+
return created;
|
|
554
|
+
});
|
|
555
|
+
return this.toDto(row);
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
update(id, revision, input, deviceId, now = new Date()) {
|
|
559
|
+
return this.serial(async () => {
|
|
560
|
+
const r = this.validRecurrence(input);
|
|
561
|
+
const before = await this.prisma.schedule.findUnique({ where: { id } });
|
|
562
|
+
if (!before)
|
|
563
|
+
throw new ScheduleError("NOT_FOUND", "No such schedule.");
|
|
564
|
+
const frozen = await this.saveable(input, id, before.revision + 1, before.alwaysAllow);
|
|
565
|
+
const row = await this.prisma.$transaction(async (tx) => {
|
|
566
|
+
const { count } = await tx.schedule.updateMany({
|
|
567
|
+
where: { id, revision },
|
|
568
|
+
data: {
|
|
569
|
+
...this.columns(input),
|
|
570
|
+
bindingsHash: frozen.hash,
|
|
571
|
+
nextRunAt: nextSlots(r, now, 1)[0] ?? null,
|
|
572
|
+
revision: { increment: 1 },
|
|
573
|
+
consecutiveFailures: 0,
|
|
574
|
+
pausedReason: null,
|
|
575
|
+
},
|
|
576
|
+
});
|
|
577
|
+
if (count === 0)
|
|
578
|
+
throw new ScheduleError("CONFLICT", "This schedule changed since you opened it. Reload it to see the latest.");
|
|
579
|
+
await tx.scheduleEvent.create({
|
|
580
|
+
data: {
|
|
581
|
+
scheduleId: id,
|
|
582
|
+
action: "edited",
|
|
583
|
+
deviceId,
|
|
584
|
+
before: JSON.stringify(this.inputOf(before)),
|
|
585
|
+
after: JSON.stringify(input),
|
|
586
|
+
},
|
|
587
|
+
});
|
|
588
|
+
return tx.schedule.findUniqueOrThrow({ where: { id } });
|
|
589
|
+
});
|
|
590
|
+
return this.toDto(row);
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
setEnabled(id, enabled, deviceId, now = new Date()) {
|
|
594
|
+
return this.serial(async () => {
|
|
595
|
+
const s = await this.prisma.schedule.findUnique({ where: { id } });
|
|
596
|
+
if (!s)
|
|
597
|
+
throw new ScheduleError("NOT_FOUND", "No such schedule.");
|
|
598
|
+
const frozen = enabled ? await this.freeze(this.prisma, s) : null;
|
|
599
|
+
if (frozen?.folder)
|
|
600
|
+
throw new ScheduleError("BAD_REQUEST", FOLDER_REFUSED);
|
|
601
|
+
if (enabled && (await this.folderMoved(s)))
|
|
602
|
+
throw new ScheduleError("BAD_REQUEST", FOLDER_MOVED);
|
|
603
|
+
const row = await this.prisma.$transaction(async (tx) => {
|
|
604
|
+
await tx.schedule.update({
|
|
605
|
+
where: { id },
|
|
606
|
+
data: {
|
|
607
|
+
enabled,
|
|
608
|
+
revision: { increment: 1 },
|
|
609
|
+
consecutiveFailures: 0,
|
|
610
|
+
pausedReason: null,
|
|
611
|
+
...(frozen
|
|
612
|
+
? {
|
|
613
|
+
bindingsHash: frozen.hash,
|
|
614
|
+
nextRunAt: nextSlots(parseRecurrence(s.recurrence), now, 1)[0] ?? null,
|
|
615
|
+
}
|
|
616
|
+
: {}),
|
|
617
|
+
},
|
|
618
|
+
});
|
|
619
|
+
await tx.scheduleEvent.create({
|
|
620
|
+
data: {
|
|
621
|
+
scheduleId: id,
|
|
622
|
+
action: enabled ? "resumed" : "paused",
|
|
623
|
+
deviceId,
|
|
624
|
+
},
|
|
625
|
+
});
|
|
626
|
+
return tx.schedule.findUniqueOrThrow({ where: { id } });
|
|
627
|
+
});
|
|
628
|
+
return this.toDto(row);
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
runNow(id, deviceId, now = new Date()) {
|
|
632
|
+
return this.serial(async () => {
|
|
633
|
+
const s = await this.prisma.schedule.findUnique({ where: { id } });
|
|
634
|
+
if (!s)
|
|
635
|
+
throw new ScheduleError("NOT_FOUND", "No such schedule.");
|
|
636
|
+
const ready = await this.harness.ensureReady(s.harness);
|
|
637
|
+
if (!ready.ready)
|
|
638
|
+
throw new ScheduleError("PRECONDITION_FAILED", ready.reason);
|
|
639
|
+
const slot = now;
|
|
640
|
+
const tick = await this.oneRunPerInstant(() => this.admit(s, now, {
|
|
641
|
+
slot,
|
|
642
|
+
outcome: "run_now",
|
|
643
|
+
reason: null,
|
|
644
|
+
missedCount: 0,
|
|
645
|
+
missedOverflow: false,
|
|
646
|
+
startBy: null,
|
|
647
|
+
}, "run_now"));
|
|
648
|
+
await this.prisma.scheduleEvent.create({
|
|
649
|
+
data: { scheduleId: id, action: "run_now", deviceId },
|
|
650
|
+
});
|
|
651
|
+
if (!tick)
|
|
652
|
+
throw new ScheduleError("CONFLICT", "This schedule changed. Reload it and try again.");
|
|
653
|
+
return tick;
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
remove(id, deviceId) {
|
|
657
|
+
return this.serial(async () => {
|
|
658
|
+
const before = await this.prisma.schedule.findUnique({ where: { id } });
|
|
659
|
+
if (!before)
|
|
660
|
+
throw new ScheduleError("NOT_FOUND", "No such schedule.");
|
|
661
|
+
await this.prisma.$transaction([
|
|
662
|
+
this.prisma.schedule.delete({ where: { id } }),
|
|
663
|
+
this.prisma.scheduleEvent.create({
|
|
664
|
+
data: {
|
|
665
|
+
scheduleId: id,
|
|
666
|
+
action: "deleted",
|
|
667
|
+
deviceId,
|
|
668
|
+
before: JSON.stringify(this.inputOf(before)),
|
|
669
|
+
},
|
|
670
|
+
}),
|
|
671
|
+
]);
|
|
672
|
+
return { ok: true };
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
async folderMoved(s) {
|
|
676
|
+
if (!s.repositoryId)
|
|
677
|
+
return false;
|
|
678
|
+
const repo = await this.prisma.repository.findUnique({
|
|
679
|
+
where: { id: s.repositoryId },
|
|
680
|
+
select: { sourceKind: true, url: true },
|
|
681
|
+
});
|
|
682
|
+
if (repo?.sourceKind !== "folder")
|
|
683
|
+
return false;
|
|
684
|
+
try {
|
|
685
|
+
const real = await canonical(repo.url);
|
|
686
|
+
return real === null || !sameAsDisk(resolve(repo.url), real);
|
|
687
|
+
}
|
|
688
|
+
catch (e) {
|
|
689
|
+
if (e instanceof CanonicalBusy)
|
|
690
|
+
return false;
|
|
691
|
+
throw e;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
async saveable(input, id, revision, alwaysAllow) {
|
|
695
|
+
if (input.serviceId && input.repositoryId)
|
|
696
|
+
throw new ScheduleError("BAD_REQUEST", "Pick a project or a service, not both.");
|
|
697
|
+
const frozen = await this.freeze(this.prisma, {
|
|
698
|
+
id,
|
|
699
|
+
serviceId: input.serviceId,
|
|
700
|
+
repositoryId: input.repositoryId,
|
|
701
|
+
runbook: input.runbook,
|
|
702
|
+
revision,
|
|
703
|
+
alwaysAllow,
|
|
704
|
+
});
|
|
705
|
+
if (frozen.folder)
|
|
706
|
+
throw new ScheduleError("BAD_REQUEST", FOLDER_REFUSED);
|
|
707
|
+
return frozen;
|
|
708
|
+
}
|
|
709
|
+
async oneRunPerInstant(work) {
|
|
710
|
+
try {
|
|
711
|
+
return await work();
|
|
712
|
+
}
|
|
713
|
+
catch (error) {
|
|
714
|
+
if (error.code === "P2002")
|
|
715
|
+
throw new ScheduleError("CONFLICT", "This schedule just ran. Try again in a moment.");
|
|
716
|
+
throw error;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
validRecurrence(input) {
|
|
720
|
+
const r = toRecurrence(input.recurrence);
|
|
721
|
+
const error = recurrenceError(r);
|
|
722
|
+
if (error)
|
|
723
|
+
throw new ScheduleError("BAD_REQUEST", error);
|
|
724
|
+
return r;
|
|
725
|
+
}
|
|
726
|
+
columns(input) {
|
|
727
|
+
return {
|
|
728
|
+
name: input.name,
|
|
729
|
+
serviceId: input.serviceId,
|
|
730
|
+
repositoryId: input.repositoryId,
|
|
731
|
+
runbook: input.runbook,
|
|
732
|
+
brief: input.brief,
|
|
733
|
+
recurrence: JSON.stringify(input.recurrence),
|
|
734
|
+
harness: input.harness,
|
|
735
|
+
model: input.model,
|
|
736
|
+
effort: input.effort,
|
|
737
|
+
accessLevel: input.accessLevel,
|
|
738
|
+
report: input.report,
|
|
739
|
+
whenAsks: input.whenAsks,
|
|
740
|
+
missedPolicy: input.missedPolicy,
|
|
741
|
+
catchUpMinutes: input.catchUpMinutes,
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
inputOf(row) {
|
|
745
|
+
return {
|
|
746
|
+
name: row.name,
|
|
747
|
+
serviceId: row.serviceId,
|
|
748
|
+
repositoryId: row.repositoryId,
|
|
749
|
+
runbook: row.runbook,
|
|
750
|
+
brief: row.brief,
|
|
751
|
+
recurrence: JSON.parse(row.recurrence),
|
|
752
|
+
harness: row.harness,
|
|
753
|
+
model: row.model,
|
|
754
|
+
effort: row.effort,
|
|
755
|
+
accessLevel: AccessLevelSchema.safeParse(row.accessLevel).data ?? null,
|
|
756
|
+
report: row.report,
|
|
757
|
+
whenAsks: row.whenAsks === "wait" ? "wait" : "decide",
|
|
758
|
+
missedPolicy: row.missedPolicy,
|
|
759
|
+
catchUpMinutes: row.catchUpMinutes,
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
async toDto(row) {
|
|
763
|
+
const r = parseRecurrence(row.recurrence);
|
|
764
|
+
const [service, repository, last, live] = await Promise.all([
|
|
765
|
+
row.serviceId
|
|
766
|
+
? this.prisma.service.findUnique({
|
|
767
|
+
where: { id: row.serviceId },
|
|
768
|
+
select: { name: true },
|
|
769
|
+
})
|
|
770
|
+
: null,
|
|
771
|
+
row.repositoryId
|
|
772
|
+
? this.prisma.repository.findUnique({
|
|
773
|
+
where: { id: row.repositoryId },
|
|
774
|
+
select: { sourceKind: true, url: true, fullName: true },
|
|
775
|
+
})
|
|
776
|
+
: null,
|
|
777
|
+
this.prisma.scheduleTick.findFirst({
|
|
778
|
+
where: { scheduleId: row.id },
|
|
779
|
+
orderBy: [{ decidedAt: "desc" }, { id: "desc" }],
|
|
780
|
+
select: { id: true },
|
|
781
|
+
}),
|
|
782
|
+
this.prisma.investigation.findFirst({
|
|
783
|
+
where: {
|
|
784
|
+
scheduleId: row.id,
|
|
785
|
+
status: { in: [...LIVE_WORKFLOW_STATUSES] },
|
|
786
|
+
},
|
|
787
|
+
select: { id: true },
|
|
788
|
+
}),
|
|
789
|
+
]);
|
|
790
|
+
return {
|
|
791
|
+
...this.inputOf(row),
|
|
792
|
+
id: row.id,
|
|
793
|
+
subject: subjectOf(row),
|
|
794
|
+
serviceName: service?.name ?? "",
|
|
795
|
+
repositoryName: repository ? shownFullName(repository) : null,
|
|
796
|
+
alwaysAllow: allowedAsks(row.alwaysAllow),
|
|
797
|
+
description: describeRecurrence(r),
|
|
798
|
+
shape: r.type === "interval" ? "interval" : cronShape(r.expr),
|
|
799
|
+
enabled: row.enabled,
|
|
800
|
+
pausedReason: row.pausedReason,
|
|
801
|
+
nextRunAt: row.enabled ? (row.nextRunAt?.toISOString() ?? null) : null,
|
|
802
|
+
lastTick: last ? await this.tickDto(last.id) : null,
|
|
803
|
+
liveRunId: live?.id ?? null,
|
|
804
|
+
revision: row.revision,
|
|
805
|
+
createdAt: row.createdAt.toISOString(),
|
|
806
|
+
updatedAt: row.updatedAt.toISOString(),
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
async tickDto(id) {
|
|
810
|
+
const t = await this.prisma.scheduleTick.findUnique({ where: { id } });
|
|
811
|
+
if (!t)
|
|
812
|
+
return null;
|
|
813
|
+
const run = t.investigationId
|
|
814
|
+
? await this.prisma.investigation.findUnique({
|
|
815
|
+
where: { id: t.investigationId },
|
|
816
|
+
select: {
|
|
817
|
+
id: true,
|
|
818
|
+
status: true,
|
|
819
|
+
summary: true,
|
|
820
|
+
error: true,
|
|
821
|
+
startedAt: true,
|
|
822
|
+
completedAt: true,
|
|
823
|
+
incidentId: true,
|
|
824
|
+
incident: { select: { number: true } },
|
|
825
|
+
},
|
|
826
|
+
})
|
|
827
|
+
: null;
|
|
828
|
+
return {
|
|
829
|
+
id: t.id,
|
|
830
|
+
scheduledFor: t.scheduledFor.toISOString(),
|
|
831
|
+
decidedAt: t.decidedAt.toISOString(),
|
|
832
|
+
outcome: t.outcome,
|
|
833
|
+
reason: t.reason,
|
|
834
|
+
missedCount: t.missedCount,
|
|
835
|
+
missedOverflow: t.missedOverflow,
|
|
836
|
+
run: run
|
|
837
|
+
? {
|
|
838
|
+
id: run.id,
|
|
839
|
+
status: run.status,
|
|
840
|
+
summary: run.summary,
|
|
841
|
+
error: run.error,
|
|
842
|
+
startedAt: run.startedAt?.toISOString() ?? null,
|
|
843
|
+
completedAt: run.completedAt?.toISOString() ?? null,
|
|
844
|
+
incidentId: run.incidentId,
|
|
845
|
+
incidentNumber: run.incident?.number ?? null,
|
|
846
|
+
}
|
|
847
|
+
: null,
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
async builtIns() {
|
|
851
|
+
const pull = await this.prisma.setting.findUnique({
|
|
852
|
+
where: { key: "ALERT_PULL" },
|
|
853
|
+
});
|
|
854
|
+
let lastPulledAt = null;
|
|
855
|
+
try {
|
|
856
|
+
lastPulledAt = pull
|
|
857
|
+
? (JSON.parse(pull.value).lastPulledAt ??
|
|
858
|
+
null)
|
|
859
|
+
: null;
|
|
860
|
+
}
|
|
861
|
+
catch {
|
|
862
|
+
lastPulledAt = null;
|
|
863
|
+
}
|
|
864
|
+
return [
|
|
865
|
+
{
|
|
866
|
+
id: "workspace-sweep",
|
|
867
|
+
name: "Remove finished run workspaces",
|
|
868
|
+
description: "Your workspace settings decide what is kept",
|
|
869
|
+
cadence: "When PrismaLens starts",
|
|
870
|
+
lastRunAt: null,
|
|
871
|
+
lastResult: null,
|
|
872
|
+
ok: null,
|
|
873
|
+
nextRunAt: null,
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
id: "alert-pull",
|
|
877
|
+
name: "Pull alerts from Alertmanager",
|
|
878
|
+
description: "Catches alerts sent while PrismaLens was off",
|
|
879
|
+
cadence: "When PrismaLens starts",
|
|
880
|
+
lastRunAt: lastPulledAt,
|
|
881
|
+
lastResult: null,
|
|
882
|
+
ok: null,
|
|
883
|
+
nextRunAt: null,
|
|
884
|
+
},
|
|
885
|
+
];
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
SchedulesService = SchedulesService_1 = __decorate([
|
|
889
|
+
Injectable(),
|
|
890
|
+
__param(3, Optional()),
|
|
891
|
+
__param(3, Inject(RuntimeLifecycleService)),
|
|
892
|
+
__param(4, Optional()),
|
|
893
|
+
__metadata("design:paramtypes", [PrismaService,
|
|
894
|
+
DispatchService,
|
|
895
|
+
HarnessService, Object, SessionLifecycleService])
|
|
896
|
+
], SchedulesService);
|
|
897
|
+
export { SchedulesService };
|
|
898
|
+
//# sourceMappingURL=schedules.service.js.map
|