@leitwerk-dev/server 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-WfwKzrVk.d.ts → app-CsuxFZT5.d.ts} +332 -111
- package/dist/app-JM4CBTND.js +8 -0
- package/dist/app.d.ts +9 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/auth/fastify-auth.d.ts +9 -0
- package/dist/auth/fastify-auth.d.ts.map +1 -1
- package/dist/{chunk-LK3RO6C7.js → chunk-FPMDWQF7.js} +3050 -645
- package/dist/chunk-FPMDWQF7.js.map +1 -0
- package/dist/{chunk-KIOQNNG6.js → chunk-MBHRCQFE.js} +2781 -1822
- package/dist/chunk-MBHRCQFE.js.map +1 -0
- package/dist/config/config-loader.d.ts +1 -1
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/config/config-types.d.ts +14 -1
- package/dist/config/config-types.d.ts.map +1 -1
- package/dist/config/kubernetes-docker-isolation.d.ts +7 -0
- package/dist/config/kubernetes-docker-isolation.d.ts.map +1 -0
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/execution-inspection-repo.d.ts +15 -0
- package/dist/db/execution-inspection-repo.d.ts.map +1 -0
- package/dist/db/history-window.d.ts +11 -0
- package/dist/db/history-window.d.ts.map +1 -0
- package/dist/db/mapped-llm-run-repo.d.ts +56 -0
- package/dist/db/mapped-llm-run-repo.d.ts.map +1 -0
- package/dist/db/process-event-repo.d.ts +2 -0
- package/dist/db/process-event-repo.d.ts.map +1 -1
- package/dist/db/process-instance-repo.d.ts +4 -1
- package/dist/db/process-instance-repo.d.ts.map +1 -1
- package/dist/db/process-leaf-outcome-snapshot-repo.d.ts +2 -1
- package/dist/db/process-leaf-outcome-snapshot-repo.d.ts.map +1 -1
- package/dist/db/process-project-repo.d.ts +2 -0
- package/dist/db/process-project-repo.d.ts.map +1 -1
- package/dist/db/process-skill-repo.d.ts.map +1 -1
- package/dist/db/process-turn-annotation-repo.d.ts +4 -1
- package/dist/db/process-turn-annotation-repo.d.ts.map +1 -1
- package/dist/db/process-turn-record-repo.d.ts +7 -1
- package/dist/db/process-turn-record-repo.d.ts.map +1 -1
- package/dist/db/publication-repo.d.ts +5 -0
- package/dist/db/publication-repo.d.ts.map +1 -0
- package/dist/db/repo-helpers.d.ts +6 -0
- package/dist/db/repo-helpers.d.ts.map +1 -1
- package/dist/db/repositories.d.ts +16 -0
- package/dist/db/repositories.d.ts.map +1 -1
- package/dist/db/schema.d.ts +1177 -71
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/scoped-settings-repo.d.ts +37 -0
- package/dist/db/scoped-settings-repo.d.ts.map +1 -0
- package/dist/db/skill-repo.d.ts +3 -0
- package/dist/db/skill-repo.d.ts.map +1 -1
- package/dist/db/turn-start-record-repo.d.ts +2 -1
- package/dist/db/turn-start-record-repo.d.ts.map +1 -1
- package/dist/db/turn-summary-repo.d.ts +1 -1
- package/dist/db/turn-summary-repo.d.ts.map +1 -1
- package/dist/db/worker-lease-repo.d.ts +2 -1
- package/dist/db/worker-lease-repo.d.ts.map +1 -1
- package/dist/domain-logic/outcome-tools.d.ts.map +1 -1
- package/dist/external-source-service.d.ts.map +1 -1
- package/dist/future-execution/execution.d.ts +4 -1
- package/dist/future-execution/execution.d.ts.map +1 -1
- package/dist/future-execution/launch-lifecycle.d.ts +9 -25
- package/dist/future-execution/launch-lifecycle.d.ts.map +1 -1
- package/dist/future-execution/lifecycle.d.ts +3 -28
- package/dist/future-execution/lifecycle.d.ts.map +1 -1
- package/dist/future-execution/model-projection.d.ts.map +1 -1
- package/dist/future-execution/reconciliation.d.ts +1 -0
- package/dist/future-execution/reconciliation.d.ts.map +1 -1
- package/dist/future-execution-presenter.d.ts +4 -14
- package/dist/future-execution-presenter.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/integration-tool-registry.d.ts +11 -2
- package/dist/integration-tool-registry.d.ts.map +1 -1
- package/dist/launch-coordinator-test-harness.d.ts.map +1 -1
- package/dist/launch-coordinator.d.ts.map +1 -1
- package/dist/launcher-model-config-service.d.ts +7 -1
- package/dist/launcher-model-config-service.d.ts.map +1 -1
- package/dist/leaf-outcome-snapshot-capture.d.ts +1 -0
- package/dist/leaf-outcome-snapshot-capture.d.ts.map +1 -1
- package/dist/main.js +3 -3
- package/dist/primary-path-snapshot.d.ts.map +1 -1
- package/dist/process-action-presenter.d.ts +11 -0
- package/dist/process-action-presenter.d.ts.map +1 -0
- package/dist/process-action-registry.d.ts.map +1 -1
- package/dist/process-engine/decision.d.ts +2 -0
- package/dist/process-engine/decision.d.ts.map +1 -1
- package/dist/process-engine/engine.d.ts.map +1 -1
- package/dist/process-engine/mapped-turns.d.ts +45 -0
- package/dist/process-engine/mapped-turns.d.ts.map +1 -0
- package/dist/process-engine/operation.d.ts +1 -1
- package/dist/process-engine/operation.d.ts.map +1 -1
- package/dist/process-engine/ops/accept-worker-turn-start.d.ts +2 -0
- package/dist/process-engine/ops/accept-worker-turn-start.d.ts.map +1 -1
- package/dist/process-engine/ops/continue-failed-turn.d.ts.map +1 -1
- package/dist/process-engine/ops/process-observation.d.ts +6 -0
- package/dist/process-engine/ops/process-observation.d.ts.map +1 -0
- package/dist/process-engine/ops/retry-failed-turn.d.ts.map +1 -1
- package/dist/process-engine/ops/retry-startup.d.ts.map +1 -1
- package/dist/process-engine/ops/start-process.d.ts +2 -0
- package/dist/process-engine/ops/start-process.d.ts.map +1 -1
- package/dist/process-engine/ops/turn-outcome.d.ts.map +1 -1
- package/dist/process-engine/ops/turn-wait.d.ts +30 -0
- package/dist/process-engine/ops/turn-wait.d.ts.map +1 -0
- package/dist/process-engine/ops/update-model-config.d.ts +9 -0
- package/dist/process-engine/ops/update-model-config.d.ts.map +1 -0
- package/dist/process-engine/recorder.d.ts.map +1 -1
- package/dist/process-engine/turn-start-preflight.d.ts +6 -0
- package/dist/process-engine/turn-start-preflight.d.ts.map +1 -1
- package/dist/process-engine/turn-wait-state.d.ts +24 -0
- package/dist/process-engine/turn-wait-state.d.ts.map +1 -0
- package/dist/process-engine/turn-worker-requirement.d.ts +2 -0
- package/dist/process-engine/turn-worker-requirement.d.ts.map +1 -1
- package/dist/process-engine/types.d.ts +10 -1
- package/dist/process-engine/types.d.ts.map +1 -1
- package/dist/process-engine/writes/build-process-abort-writes.d.ts +3 -1
- package/dist/process-engine/writes/build-process-abort-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-recovery-start-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts +10 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-selection-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/commit-writes.d.ts +2 -0
- package/dist/process-engine/writes/commit-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/reserve-selected-turn-start.d.ts +5 -0
- package/dist/process-engine/writes/reserve-selected-turn-start.d.ts.map +1 -0
- package/dist/process-engine/writes/writes.d.ts +35 -49
- package/dist/process-engine/writes/writes.d.ts.map +1 -1
- package/dist/process-graph.d.ts +1 -1
- package/dist/process-graph.d.ts.map +1 -1
- package/dist/process-inspection-reader.d.ts +21 -0
- package/dist/process-inspection-reader.d.ts.map +1 -0
- package/dist/process-inspection-trace.d.ts +13 -0
- package/dist/process-inspection-trace.d.ts.map +1 -0
- package/dist/process-inspection.d.ts +22 -0
- package/dist/process-inspection.d.ts.map +1 -0
- package/dist/process-instance-tree-presenter.d.ts +4 -3
- package/dist/process-instance-tree-presenter.d.ts.map +1 -1
- package/dist/process-launch-executor.d.ts +2 -0
- package/dist/process-launch-executor.d.ts.map +1 -1
- package/dist/process-launch-plan.d.ts +1 -0
- package/dist/process-launch-plan.d.ts.map +1 -1
- package/dist/process-launcher-registry.d.ts.map +1 -1
- package/dist/process-model-config.d.ts +19 -0
- package/dist/process-model-config.d.ts.map +1 -0
- package/dist/process-model-policy/construct.d.ts.map +1 -1
- package/dist/process-model-policy/evaluate.d.ts.map +1 -1
- package/dist/process-model-policy/index.d.ts +4 -1
- package/dist/process-model-policy/index.d.ts.map +1 -1
- package/dist/process-model-policy/project.d.ts.map +1 -1
- package/dist/process-model-policy/types.d.ts +18 -0
- package/dist/process-model-policy/types.d.ts.map +1 -1
- package/dist/process-model-policy-presenter.d.ts.map +1 -1
- package/dist/process-runtime-availability.d.ts +2 -1
- package/dist/process-runtime-availability.d.ts.map +1 -1
- package/dist/process-turn-navigation.d.ts +12 -2
- package/dist/process-turn-navigation.d.ts.map +1 -1
- package/dist/process-turn-trace.d.ts.map +1 -1
- package/dist/process-ui-snapshot-presenter.d.ts +15 -3
- package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
- package/dist/routes/future-executions.d.ts.map +1 -1
- package/dist/routes/launchers.d.ts.map +1 -1
- package/dist/routes/process-actions.d.ts.map +1 -1
- package/dist/routes/process-detail.d.ts.map +1 -1
- package/dist/routes/process-diagnostics-assembler.d.ts +3 -1
- package/dist/routes/process-diagnostics-assembler.d.ts.map +1 -1
- package/dist/routes/process-model-config.d.ts +4 -0
- package/dist/routes/process-model-config.d.ts.map +1 -0
- package/dist/routes/process-primary-path-assembler.d.ts +4 -12
- package/dist/routes/process-primary-path-assembler.d.ts.map +1 -1
- package/dist/routes/process-route-helpers.d.ts +15 -41
- package/dist/routes/process-route-helpers.d.ts.map +1 -1
- package/dist/routes/processes.d.ts.map +1 -1
- package/dist/routes/settings.d.ts +11 -0
- package/dist/routes/settings.d.ts.map +1 -0
- package/dist/routes/ticket-creation.d.ts.map +1 -1
- package/dist/scoped-settings-service.d.ts +83 -0
- package/dist/scoped-settings-service.d.ts.map +1 -0
- package/dist/server-bootstrap/build-host-capabilities.d.ts +2 -0
- package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
- package/dist/server-bootstrap/register-http.d.ts.map +1 -1
- package/dist/session-summary-projection.d.ts.map +1 -1
- package/dist/skills/bundled-skills.d.ts +5 -0
- package/dist/skills/bundled-skills.d.ts.map +1 -0
- package/dist/skills/catalog-service.d.ts +1 -0
- package/dist/skills/catalog-service.d.ts.map +1 -1
- package/dist/skills/extension-importer.d.ts +11 -0
- package/dist/skills/extension-importer.d.ts.map +1 -0
- package/dist/skills/launch-skills.d.ts +11 -0
- package/dist/skills/launch-skills.d.ts.map +1 -0
- package/dist/skills/skill-frontmatter.d.ts +5 -0
- package/dist/skills/skill-frontmatter.d.ts.map +1 -1
- package/dist/skills/source-importer.d.ts +3 -0
- package/dist/skills/source-importer.d.ts.map +1 -1
- package/dist/startup-evidence.d.ts +3 -0
- package/dist/startup-evidence.d.ts.map +1 -1
- package/dist/supervisor/execution-inspection-ingestor.d.ts +9 -0
- package/dist/supervisor/execution-inspection-ingestor.d.ts.map +1 -0
- package/dist/supervisor/ipc-handler.d.ts +2 -0
- package/dist/supervisor/ipc-handler.d.ts.map +1 -1
- package/dist/supervisor/worker-event-ingestor.d.ts +1 -0
- package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.d.ts +2 -0
- package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
- package/dist/supervisor/worker-supervisor.d.ts +4 -0
- package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts +2 -2
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts.map +1 -1
- package/dist/test-helpers/accepted-turn-start.d.ts +18 -4
- package/dist/test-helpers/accepted-turn-start.d.ts.map +1 -1
- package/dist/test-helpers/owned-test-deps.d.ts +18 -0
- package/dist/test-helpers/owned-test-deps.d.ts.map +1 -0
- package/dist/test-helpers/prepared-fixture-start.d.ts.map +1 -1
- package/dist/test-helpers/process-model-fixtures.d.ts +1 -0
- package/dist/test-helpers/process-model-fixtures.d.ts.map +1 -1
- package/dist/test-helpers/scoped-settings-fixtures.d.ts +16 -0
- package/dist/test-helpers/scoped-settings-fixtures.d.ts.map +1 -0
- package/dist/test-helpers/skill-fixtures.d.ts +4 -0
- package/dist/test-helpers/skill-fixtures.d.ts.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +14 -10
- package/dist/testing.js.map +1 -1
- package/dist/tool-approval-gate.d.ts +3 -0
- package/dist/tool-approval-gate.d.ts.map +1 -1
- package/dist/turn-progress.d.ts.map +1 -1
- package/dist/turn-wait-service.d.ts +28 -0
- package/dist/turn-wait-service.d.ts.map +1 -0
- package/dist/worker-runtime-profile-selection.d.ts +2 -0
- package/dist/worker-runtime-profile-selection.d.ts.map +1 -1
- package/package.json +20 -19
- package/src/app.ts +117 -5
- package/src/auth/fastify-auth.ts +13 -0
- package/src/config/config-loader.ts +40 -2
- package/src/config/config-types.ts +14 -1
- package/src/config/kubernetes-docker-isolation.ts +21 -0
- package/src/db/database.ts +159 -40
- package/src/db/execution-inspection-repo.ts +163 -0
- package/src/db/history-window.ts +18 -0
- package/src/db/mapped-llm-run-repo.ts +177 -0
- package/src/db/process-event-repo.ts +88 -10
- package/src/db/process-instance-repo.ts +9 -2
- package/src/db/process-leaf-outcome-snapshot-repo.ts +8 -2
- package/src/db/process-project-repo.ts +4 -0
- package/src/db/process-skill-repo.ts +9 -2
- package/src/db/process-turn-annotation-repo.ts +27 -9
- package/src/db/process-turn-record-repo.ts +53 -13
- package/src/db/publication-repo.ts +63 -0
- package/src/db/repo-helpers.ts +11 -1
- package/src/db/repositories.ts +22 -0
- package/src/db/schema.ts +173 -2
- package/src/db/scoped-settings-repo.ts +234 -0
- package/src/db/skill-repo.ts +89 -27
- package/src/db/turn-start-record-repo.ts +13 -3
- package/src/db/turn-summary-repo.ts +12 -3
- package/src/db/worker-lease-repo.ts +8 -2
- package/src/domain-logic/outcome-tools.ts +4 -149
- package/src/external-source-service.ts +33 -7
- package/src/future-execution/execution.ts +9 -2
- package/src/future-execution/launch-lifecycle.ts +87 -78
- package/src/future-execution/lifecycle.ts +5 -34
- package/src/future-execution/model-projection.ts +2 -0
- package/src/future-execution/reconciliation.ts +7 -0
- package/src/future-execution-presenter.ts +14 -22
- package/src/integration-tool-registry.ts +59 -26
- package/src/launch-coordinator-test-harness.ts +8 -4
- package/src/launch-coordinator.ts +10 -1
- package/src/launcher-model-config-service.ts +24 -3
- package/src/leaf-outcome-snapshot-capture.ts +2 -0
- package/src/primary-path-snapshot.ts +3 -4
- package/src/process-action-presenter.ts +98 -0
- package/src/process-action-registry.ts +31 -39
- package/src/process-engine/decision.ts +10 -0
- package/src/process-engine/engine.ts +13 -4
- package/src/process-engine/mapped-turns.ts +328 -0
- package/src/process-engine/operation.ts +1 -1
- package/src/process-engine/ops/accept-worker-turn-start.ts +6 -0
- package/src/process-engine/ops/continue-failed-turn.ts +2 -13
- package/src/process-engine/ops/process-observation.ts +119 -0
- package/src/process-engine/ops/retry-failed-turn.ts +2 -12
- package/src/process-engine/ops/retry-startup.ts +10 -13
- package/src/process-engine/ops/start-process.ts +34 -2
- package/src/process-engine/ops/turn-outcome.ts +65 -62
- package/src/process-engine/ops/turn-wait.ts +225 -0
- package/src/process-engine/ops/update-model-config.ts +66 -0
- package/src/process-engine/recorder.ts +33 -5
- package/src/process-engine/runner.ts +8 -8
- package/src/process-engine/turn-start-preflight.ts +168 -105
- package/src/process-engine/turn-wait-state.ts +126 -0
- package/src/process-engine/turn-worker-requirement.ts +4 -0
- package/src/process-engine/types.ts +15 -0
- package/src/process-engine/writes/build-process-abort-writes.ts +30 -19
- package/src/process-engine/writes/build-recovery-start-writes.ts +1 -0
- package/src/process-engine/writes/build-turn-outcome-writes.ts +118 -21
- package/src/process-engine/writes/build-turn-selection-writes.ts +2 -31
- package/src/process-engine/writes/commit-writes.ts +20 -2
- package/src/process-engine/writes/reserve-selected-turn-start.ts +44 -0
- package/src/process-engine/writes/writes.ts +73 -61
- package/src/process-graph.ts +0 -1
- package/src/process-inspection-reader.ts +305 -0
- package/src/process-inspection-trace.ts +176 -0
- package/src/process-inspection.ts +169 -0
- package/src/process-instance-tree-presenter.ts +56 -216
- package/src/process-launch-executor.ts +5 -2
- package/src/process-launch-plan.ts +17 -2
- package/src/process-launcher-registry.ts +28 -16
- package/src/process-model-config.ts +100 -0
- package/src/process-model-policy/construct.ts +1 -0
- package/src/process-model-policy/evaluate.ts +34 -32
- package/src/process-model-policy/index.ts +45 -3
- package/src/process-model-policy/project.ts +62 -76
- package/src/process-model-policy/types.ts +26 -0
- package/src/process-model-policy-presenter.ts +7 -3
- package/src/process-runtime-availability.ts +9 -4
- package/src/process-turn-navigation.ts +86 -8
- package/src/process-turn-trace.ts +12 -24
- package/src/process-ui-snapshot-presenter.ts +249 -298
- package/src/routes/future-executions.ts +5 -5
- package/src/routes/launchers.ts +51 -1
- package/src/routes/process-actions.ts +10 -10
- package/src/routes/process-detail.ts +25 -2
- package/src/routes/process-diagnostics-assembler.ts +32 -6
- package/src/routes/process-model-config.ts +70 -0
- package/src/routes/process-primary-path-assembler.ts +17 -33
- package/src/routes/process-route-helpers.ts +161 -327
- package/src/routes/processes.ts +2 -0
- package/src/routes/settings.ts +173 -0
- package/src/routes/ticket-creation.ts +28 -5
- package/src/scoped-settings-service.ts +736 -0
- package/src/server-bootstrap/build-host-capabilities.ts +42 -0
- package/src/server-bootstrap/register-http.ts +7 -1
- package/src/session-summary-projection.ts +1 -2
- package/src/skills/bundled-skills.ts +64 -0
- package/src/skills/catalog-service.ts +35 -6
- package/src/skills/extension-importer.ts +97 -0
- package/src/skills/launch-skills.ts +19 -0
- package/src/skills/skill-frontmatter.ts +13 -0
- package/src/skills/source-importer.ts +3 -0
- package/src/startup-evidence.ts +20 -0
- package/src/supervisor/execution-inspection-ingestor.ts +55 -0
- package/src/supervisor/ipc-handler.ts +29 -18
- package/src/supervisor/worker-event-ingestor.ts +30 -14
- package/src/supervisor/worker-start-payload-builder.ts +42 -0
- package/src/supervisor/worker-supervisor.ts +5 -0
- package/src/supervisor/worker-turn-ipc-recorder.ts +13 -1
- package/src/test-helpers/accepted-turn-start.ts +51 -27
- package/src/test-helpers/owned-test-deps.ts +45 -0
- package/src/test-helpers/prepared-fixture-start.ts +1 -0
- package/src/test-helpers/process-model-fixtures.ts +2 -0
- package/src/test-helpers/scoped-settings-fixtures.ts +126 -0
- package/src/test-helpers/skill-fixtures.ts +28 -0
- package/src/testing.ts +4 -1
- package/src/tool-approval-gate.ts +16 -0
- package/src/turn-progress.ts +3 -2
- package/src/turn-wait-service.ts +228 -0
- package/src/worker-runtime-profile-selection.ts +8 -1
- package/dist/app-4QSV4FUQ.js +0 -8
- package/dist/chunk-KIOQNNG6.js.map +0 -1
- package/dist/chunk-LK3RO6C7.js.map +0 -1
- /package/dist/{app-4QSV4FUQ.js.map → app-JM4CBTND.js.map} +0 -0
|
@@ -20,12 +20,12 @@ import {
|
|
|
20
20
|
import { parseStructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
21
21
|
import {
|
|
22
22
|
buildActiveTimelineTurnSummary,
|
|
23
|
-
buildLiveTurnProjectionFromEvents,
|
|
24
23
|
buildUsageSnapshotsByTurnRecordId,
|
|
25
24
|
type CompactActiveTurnSnapshot,
|
|
26
25
|
type CompactTurnSummary,
|
|
27
26
|
type CurrentProcessErrorSummary,
|
|
28
27
|
type CurrentTurnRecoverySummary,
|
|
28
|
+
createLiveTurnProjection,
|
|
29
29
|
emptyCompactTurnSummary,
|
|
30
30
|
extractFirstUserPromptOnBranch,
|
|
31
31
|
extractInitialPromptFromParamsJson,
|
|
@@ -47,7 +47,6 @@ import {
|
|
|
47
47
|
type ReadonlyEntryTree,
|
|
48
48
|
reasoningPreviewTail,
|
|
49
49
|
resolveTurnContinuationUserPrompt,
|
|
50
|
-
snapshotTurnTrace,
|
|
51
50
|
type TurnReasoningDetailResponseBody,
|
|
52
51
|
type TurnTracePreview,
|
|
53
52
|
type TurnTraceSnapshot,
|
|
@@ -55,8 +54,11 @@ import {
|
|
|
55
54
|
} from "@leitwerk-dev/protocol";
|
|
56
55
|
import type { SessionSummary } from "./db/turn-summary-repo.js";
|
|
57
56
|
import { normalizeExternalObservation } from "./external-source-reporting.js";
|
|
57
|
+
import { getScheduledActionDetailForProcess } from "./future-execution-presenter.js";
|
|
58
58
|
import { physicalWorkerStarts } from "./physical-worker-starts.js";
|
|
59
59
|
import type { ReadonlyPiSessionTree } from "./pi-session-tree.js";
|
|
60
|
+
import { listVisibleActionsForProcess } from "./process-action-presenter.js";
|
|
61
|
+
import { pendingTurnWait } from "./process-engine/turn-wait-state.js";
|
|
60
62
|
import { resolveCurrentExecutionTurnRecordId } from "./process-execution.js";
|
|
61
63
|
import { buildProcessFlowViewForProcess, getProcessGraph } from "./process-graph.js";
|
|
62
64
|
import { presentProcessInstanceTree } from "./process-instance-tree-presenter.js";
|
|
@@ -70,9 +72,7 @@ import {
|
|
|
70
72
|
import {
|
|
71
73
|
buildProcessLaunchConfigurationView,
|
|
72
74
|
buildProcessRunDetailsView,
|
|
73
|
-
getScheduledActionDetailForProcess,
|
|
74
75
|
getSelectedTurnSummaryForProcess,
|
|
75
|
-
listVisibleActionsForProcess,
|
|
76
76
|
processDefinesLeafOutcome,
|
|
77
77
|
type RouteDeps,
|
|
78
78
|
} from "./routes/process-route-helpers.js";
|
|
@@ -80,40 +80,6 @@ import { presentSessionTransferOperation } from "./session-transfer-service.js";
|
|
|
80
80
|
import { buildStartupEvidence, presentProcessStartupSummary } from "./startup-evidence.js";
|
|
81
81
|
import { normalizeTurnProgressLinks, normalizeTurnProgressReport } from "./turn-progress.js";
|
|
82
82
|
|
|
83
|
-
const COMPACT_DETAIL_EVENT_TYPES = [
|
|
84
|
-
"worker_capacity_queued",
|
|
85
|
-
"turn_outcome_recorded",
|
|
86
|
-
"lifecycle_parked",
|
|
87
|
-
"worker_failed",
|
|
88
|
-
"external_trigger_listener_armed",
|
|
89
|
-
"external_source_armed",
|
|
90
|
-
"external_trigger_failed",
|
|
91
|
-
"external_source_failed",
|
|
92
|
-
"external_trigger_consumed",
|
|
93
|
-
"external_source_consumed",
|
|
94
|
-
] as const;
|
|
95
|
-
|
|
96
|
-
function sortEventsAscending(events: readonly ProcessEvent[]): ProcessEvent[] {
|
|
97
|
-
return [...events].sort((left, right) => {
|
|
98
|
-
const createdAtComparison = left.createdAt.localeCompare(right.createdAt);
|
|
99
|
-
return createdAtComparison !== 0 ? createdAtComparison : left.id.localeCompare(right.id);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function compactDetailEvents(
|
|
104
|
-
deps: RouteDeps,
|
|
105
|
-
instanceId: string,
|
|
106
|
-
turnRecords: readonly ProcessTurnRecord[],
|
|
107
|
-
): ProcessEvent[] {
|
|
108
|
-
return sortEventsAscending([
|
|
109
|
-
...deps.events.listByInstanceEventTypes(instanceId, COMPACT_DETAIL_EVENT_TYPES, 1_000),
|
|
110
|
-
...turnRecords.flatMap((turn) => {
|
|
111
|
-
const event = deps.events.latestByTurnRecordEventType(instanceId, turn.id, "turn.progress");
|
|
112
|
-
return event ? [event] : [];
|
|
113
|
-
}),
|
|
114
|
-
]);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
83
|
function compactPrimaryPathSnapshot(
|
|
118
84
|
snapshot: PrimaryPathSnapshot | PrimaryPathUiSnapshot,
|
|
119
85
|
): PrimaryPathUiSnapshot {
|
|
@@ -191,52 +157,23 @@ function paramsRecord(value: unknown): Record<string, unknown> {
|
|
|
191
157
|
return asRecord(value) ?? {};
|
|
192
158
|
}
|
|
193
159
|
|
|
194
|
-
function
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
for (const event of events) {
|
|
205
|
-
if (event.eventType !== "turn_outcome_recorded") {
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
const turnRecordId = turnRecordIdFromEvent(event);
|
|
209
|
-
if (turnRecordId) {
|
|
210
|
-
map.set(turnRecordId, event);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return map;
|
|
160
|
+
function indexByTurnRecordId<T>(
|
|
161
|
+
records: readonly T[],
|
|
162
|
+
key: (record: T) => string | null,
|
|
163
|
+
): Map<string, T> {
|
|
164
|
+
return new Map(
|
|
165
|
+
records.flatMap((record) => {
|
|
166
|
+
const id = key(record);
|
|
167
|
+
return id ? [[id, record] as const] : [];
|
|
168
|
+
}),
|
|
169
|
+
);
|
|
214
170
|
}
|
|
215
171
|
|
|
216
172
|
function turnRecordIdFromAnnotation(annotation: ProcessTurnAnnotation): string | null {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function createTurnAnnotationMap(
|
|
226
|
-
turnAnnotations: readonly ProcessTurnAnnotation[],
|
|
227
|
-
annotationType: string,
|
|
228
|
-
): Map<string, ProcessTurnAnnotation> {
|
|
229
|
-
const map = new Map<string, ProcessTurnAnnotation>();
|
|
230
|
-
for (const annotation of turnAnnotations) {
|
|
231
|
-
if (annotation.annotationType !== annotationType) {
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
const turnRecordId = turnRecordIdFromAnnotation(annotation);
|
|
235
|
-
if (turnRecordId) {
|
|
236
|
-
map.set(turnRecordId, annotation);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return map;
|
|
173
|
+
return (
|
|
174
|
+
annotation.references.find((reference) => reference.kind === "turn_record")?.turnRecordId ??
|
|
175
|
+
null
|
|
176
|
+
);
|
|
240
177
|
}
|
|
241
178
|
|
|
242
179
|
function outputFromTurnParams(
|
|
@@ -263,16 +200,9 @@ function summarizeTurnOutcome(
|
|
|
263
200
|
}
|
|
264
201
|
|
|
265
202
|
function fallbackOutcomeFromTurnRecord(turnRecord: ProcessTurnRecord): string {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
case "superseded":
|
|
270
|
-
return "superseded";
|
|
271
|
-
case "succeeded":
|
|
272
|
-
return "succeeded";
|
|
273
|
-
default:
|
|
274
|
-
return "completed";
|
|
275
|
-
}
|
|
203
|
+
return ["failed", "superseded", "succeeded"].includes(turnRecord.status)
|
|
204
|
+
? turnRecord.status
|
|
205
|
+
: "completed";
|
|
276
206
|
}
|
|
277
207
|
|
|
278
208
|
function fallbackSummaryFromTurnRecord(turnRecord: ProcessTurnRecord): string {
|
|
@@ -403,47 +333,6 @@ function effectiveTurnRecordForDisplay(
|
|
|
403
333
|
};
|
|
404
334
|
}
|
|
405
335
|
|
|
406
|
-
function durableTurnLineage(turnRecord: ProcessTurnRecord) {
|
|
407
|
-
return {
|
|
408
|
-
attemptNumber: turnRecord.attemptNumber,
|
|
409
|
-
parentTurnRecordId: turnRecord.parentTurnRecordId,
|
|
410
|
-
startedAt: turnRecord.startedAt,
|
|
411
|
-
endedAt: turnRecord.endedAt,
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
function createCompletedTurnRecord(args: {
|
|
416
|
-
turnRecord: ProcessTurnRecord;
|
|
417
|
-
turnId: string;
|
|
418
|
-
displayTurn?: string;
|
|
419
|
-
outcome: string;
|
|
420
|
-
summary: string;
|
|
421
|
-
output: string;
|
|
422
|
-
turnResultMarkdown: string;
|
|
423
|
-
createdAt: string;
|
|
424
|
-
actionSource: TimelineActionSource;
|
|
425
|
-
progress: ProcessTimelineTurnSummary["progress"];
|
|
426
|
-
}): ProcessTimelineTurnSummary {
|
|
427
|
-
return {
|
|
428
|
-
id: args.turnRecord.id,
|
|
429
|
-
turnId: args.turnId,
|
|
430
|
-
turnType: args.turnRecord.turnType,
|
|
431
|
-
displayTurn: args.displayTurn ?? args.turnId,
|
|
432
|
-
outcome: args.outcome,
|
|
433
|
-
summary: args.summary,
|
|
434
|
-
output: normalizeOutput(args.output) || (args.turnResultMarkdown ? "" : args.summary),
|
|
435
|
-
turnResultMarkdown: args.turnResultMarkdown,
|
|
436
|
-
pathType: args.turnRecord.pathType,
|
|
437
|
-
createdAt: args.createdAt,
|
|
438
|
-
presentation: timelinePresentationForTurnType(args.turnRecord.turnType),
|
|
439
|
-
status: "completed",
|
|
440
|
-
modelProfileId: args.turnRecord.modelProfileId ?? null,
|
|
441
|
-
actionSource: args.actionSource,
|
|
442
|
-
progress: args.progress,
|
|
443
|
-
...durableTurnLineage(args.turnRecord),
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
|
|
447
336
|
/** @internal */
|
|
448
337
|
export function presentProcessTimelineTurns(input: {
|
|
449
338
|
/** @internal */
|
|
@@ -463,20 +352,19 @@ export function presentProcessTimelineTurns(input: {
|
|
|
463
352
|
/** @internal */
|
|
464
353
|
activeModelProfileId?: string | null;
|
|
465
354
|
}): ProcessTimelineTurnSummary[] {
|
|
466
|
-
const outcomeEventsByTurnRecordId =
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
input.turnAnnotations,
|
|
470
|
-
"turn_milestone",
|
|
471
|
-
);
|
|
472
|
-
const acceptanceAnnotationsByTurnRecordId = createTurnAnnotationMap(
|
|
473
|
-
input.turnAnnotations,
|
|
474
|
-
"acceptance_state",
|
|
475
|
-
);
|
|
476
|
-
const externalTriggerAnnotationsByTurnRecordId = createTurnAnnotationMap(
|
|
477
|
-
input.turnAnnotations,
|
|
478
|
-
"external_trigger",
|
|
355
|
+
const outcomeEventsByTurnRecordId = indexByTurnRecordId(
|
|
356
|
+
input.events.filter((event) => event.eventType === "turn_outcome_recorded"),
|
|
357
|
+
(event) => stringValue(paramsRecord(event.data).turnRecordId),
|
|
479
358
|
);
|
|
359
|
+
const progressByTurnRecordId = buildTurnProgressIndex(input.events);
|
|
360
|
+
const annotationMap = (annotationType: string) =>
|
|
361
|
+
indexByTurnRecordId(
|
|
362
|
+
input.turnAnnotations.filter((annotation) => annotation.annotationType === annotationType),
|
|
363
|
+
turnRecordIdFromAnnotation,
|
|
364
|
+
);
|
|
365
|
+
const milestoneAnnotationsByTurnRecordId = annotationMap("turn_milestone");
|
|
366
|
+
const acceptanceAnnotationsByTurnRecordId = annotationMap("acceptance_state");
|
|
367
|
+
const externalTriggerAnnotationsByTurnRecordId = annotationMap("external_trigger");
|
|
480
368
|
const actionSourceByTurnRecordId = buildActionSourceIndex(
|
|
481
369
|
input.turnAnnotations,
|
|
482
370
|
input.turnRecords,
|
|
@@ -504,11 +392,23 @@ export function presentProcessTimelineTurns(input: {
|
|
|
504
392
|
continue;
|
|
505
393
|
}
|
|
506
394
|
const turnRecord = effectiveTurnRecordForDisplay(durableTurnRecord, input.process);
|
|
395
|
+
const common = {
|
|
396
|
+
id: turnRecord.id,
|
|
397
|
+
turnType: turnRecord.turnType,
|
|
398
|
+
pathType: turnRecord.pathType,
|
|
399
|
+
presentation: timelinePresentationForTurnType(turnRecord.turnType),
|
|
400
|
+
modelProfileId: turnRecord.modelProfileId ?? null,
|
|
401
|
+
actionSource: actionSourceByTurnRecordId.get(turnRecord.id) ?? null,
|
|
402
|
+
attemptNumber: turnRecord.attemptNumber,
|
|
403
|
+
parentTurnRecordId: turnRecord.parentTurnRecordId,
|
|
404
|
+
startedAt: turnRecord.startedAt,
|
|
405
|
+
endedAt: turnRecord.endedAt,
|
|
406
|
+
...progressByTurnRecordId.get(turnRecord.id),
|
|
407
|
+
};
|
|
507
408
|
if (turnRecord.status === "running") {
|
|
508
409
|
turns.push({
|
|
509
|
-
|
|
410
|
+
...common,
|
|
510
411
|
turnId: turnRecord.turnId,
|
|
511
|
-
turnType: turnRecord.turnType,
|
|
512
412
|
displayTurn: turnRecord.turnId,
|
|
513
413
|
outcome: "in_progress",
|
|
514
414
|
summary: `Current step: ${formatDefinition(turnRecord.turnId)}`,
|
|
@@ -517,14 +417,8 @@ export function presentProcessTimelineTurns(input: {
|
|
|
517
417
|
? input.activeTurn.assistant.text.trim()
|
|
518
418
|
: "",
|
|
519
419
|
turnResultMarkdown: "",
|
|
520
|
-
pathType: turnRecord.pathType,
|
|
521
420
|
createdAt: turnRecord.startedAt,
|
|
522
|
-
presentation: timelinePresentationForTurnType(turnRecord.turnType),
|
|
523
421
|
status: "in_progress",
|
|
524
|
-
modelProfileId: turnRecord.modelProfileId ?? null,
|
|
525
|
-
actionSource: actionSourceByTurnRecordId.get(turnRecord.id) ?? null,
|
|
526
|
-
...progressByTurnRecordId.get(turnRecord.id),
|
|
527
|
-
...durableTurnLineage(turnRecord),
|
|
528
422
|
});
|
|
529
423
|
continue;
|
|
530
424
|
}
|
|
@@ -535,24 +429,26 @@ export function presentProcessTimelineTurns(input: {
|
|
|
535
429
|
const actionAnnotation =
|
|
536
430
|
acceptanceAnnotationsByTurnRecordId.get(turnRecord.id) ??
|
|
537
431
|
externalTriggerAnnotationsByTurnRecordId.get(turnRecord.id);
|
|
538
|
-
let presentation:
|
|
539
|
-
|
|
540
|
-
"
|
|
541
|
-
|
|
432
|
+
let presentation: Pick<
|
|
433
|
+
ProcessTimelineTurnSummary,
|
|
434
|
+
"turnId" | "outcome" | "summary" | "output" | "createdAt"
|
|
435
|
+
> & { displayTurn?: string };
|
|
542
436
|
|
|
543
|
-
|
|
544
|
-
|
|
437
|
+
const recordedOutcome = outcomeEvent ?? (!actionAnnotation ? milestoneAnnotation : null);
|
|
438
|
+
if (recordedOutcome) {
|
|
439
|
+
const data = "data" in recordedOutcome ? recordedOutcome.data : recordedOutcome.payload;
|
|
440
|
+
const turnId = stringValue(data.turnId) || turnRecord.turnId || "turn";
|
|
545
441
|
const outcome =
|
|
546
|
-
stringValue(
|
|
442
|
+
stringValue(data.outcome) ||
|
|
547
443
|
stringValue(milestoneAnnotation?.payload.outcome) ||
|
|
548
444
|
fallbackOutcomeFromTurnRecord(turnRecord);
|
|
549
|
-
const params = paramsRecord(outcomeEvent
|
|
445
|
+
const params = paramsRecord(outcomeEvent?.data.params);
|
|
550
446
|
presentation = {
|
|
551
447
|
turnId,
|
|
552
448
|
outcome,
|
|
553
449
|
summary: summarizeTurnOutcome(turnId, outcome, params),
|
|
554
450
|
output: outputFromTurnParams(params, { includeMarkdownFields: !turnResultMarkdown }),
|
|
555
|
-
createdAt: turnRecord.endedAt ??
|
|
451
|
+
createdAt: turnRecord.endedAt ?? recordedOutcome.createdAt ?? turnRecord.startedAt,
|
|
556
452
|
};
|
|
557
453
|
} else if (actionAnnotation) {
|
|
558
454
|
const label = annotationLabel(actionAnnotation);
|
|
@@ -568,18 +464,6 @@ export function presentProcessTimelineTurns(input: {
|
|
|
568
464
|
output: annotationOutput(actionAnnotation),
|
|
569
465
|
createdAt: actionAnnotation.createdAt ?? turnRecord.endedAt ?? turnRecord.startedAt,
|
|
570
466
|
};
|
|
571
|
-
} else if (milestoneAnnotation) {
|
|
572
|
-
const turnId = stringValue(milestoneAnnotation.payload.turnId) || turnRecord.turnId || "turn";
|
|
573
|
-
const outcome =
|
|
574
|
-
stringValue(milestoneAnnotation.payload.outcome) ||
|
|
575
|
-
fallbackOutcomeFromTurnRecord(turnRecord);
|
|
576
|
-
presentation = {
|
|
577
|
-
turnId,
|
|
578
|
-
outcome,
|
|
579
|
-
summary: summarizeTurnOutcome(turnId, outcome, {}),
|
|
580
|
-
output: "",
|
|
581
|
-
createdAt: turnRecord.endedAt ?? milestoneAnnotation.createdAt ?? turnRecord.startedAt,
|
|
582
|
-
};
|
|
583
467
|
} else {
|
|
584
468
|
const summary = fallbackSummaryFromTurnRecord(turnRecord);
|
|
585
469
|
presentation = {
|
|
@@ -590,7 +474,12 @@ export function presentProcessTimelineTurns(input: {
|
|
|
590
474
|
createdAt: turnRecord.endedAt ?? turnRecord.startedAt,
|
|
591
475
|
};
|
|
592
476
|
}
|
|
477
|
+
const payload = actionAnnotation?.payload ?? milestoneAnnotation?.payload;
|
|
478
|
+
const selectedTurnId =
|
|
479
|
+
stringValue(payload?.selectedTurnIdAfter) || stringValue(payload?.causedSelectedTurnId);
|
|
480
|
+
const targetTurnRecordId = stringValue(payload?.targetTurnRecordId);
|
|
593
481
|
turns.push({
|
|
482
|
+
...common,
|
|
594
483
|
resources:
|
|
595
484
|
normalizeTurnProgressLinks(
|
|
596
485
|
paramsRecord(actionAnnotation?.payload.eventDescription).links,
|
|
@@ -598,32 +487,24 @@ export function presentProcessTimelineTurns(input: {
|
|
|
598
487
|
...(stringValue(actionAnnotation?.payload.sourceTurnRecordId)
|
|
599
488
|
? { reviewedTurnRecordId: stringValue(actionAnnotation?.payload.sourceTurnRecordId) }
|
|
600
489
|
: {}),
|
|
601
|
-
...(
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
...createCompletedTurnRecord({
|
|
620
|
-
...presentation,
|
|
621
|
-
turnRecord,
|
|
622
|
-
turnResultMarkdown,
|
|
623
|
-
actionSource: actionSourceByTurnRecordId.get(turnRecord.id) ?? null,
|
|
624
|
-
progress: progressByTurnRecordId.get(turnRecord.id)?.progress ?? null,
|
|
625
|
-
}),
|
|
626
|
-
...progressByTurnRecordId.get(turnRecord.id),
|
|
490
|
+
...(selectedTurnId
|
|
491
|
+
? {
|
|
492
|
+
transition: {
|
|
493
|
+
selectedTurnId,
|
|
494
|
+
...(targetTurnRecordId ? { targetTurnRecordId } : {}),
|
|
495
|
+
accepted: Boolean(
|
|
496
|
+
targetTurnRecordId &&
|
|
497
|
+
input.turnRecords.some((record) => record.id === targetTurnRecordId),
|
|
498
|
+
),
|
|
499
|
+
},
|
|
500
|
+
}
|
|
501
|
+
: {}),
|
|
502
|
+
...presentation,
|
|
503
|
+
displayTurn: presentation.displayTurn ?? presentation.turnId,
|
|
504
|
+
output: presentation.output.trim() || (turnResultMarkdown ? "" : presentation.summary),
|
|
505
|
+
turnResultMarkdown,
|
|
506
|
+
status: "completed",
|
|
507
|
+
progress: common.progress ?? null,
|
|
627
508
|
...(stringValue(milestoneAnnotation?.payload.resultSummary)
|
|
628
509
|
? { resultSummary: stringValue(milestoneAnnotation?.payload.resultSummary) }
|
|
629
510
|
: {}),
|
|
@@ -648,28 +529,21 @@ export function presentProcessTimelineTurns(input: {
|
|
|
648
529
|
) {
|
|
649
530
|
const turnId = input.process.selectedTurnId ?? "unknown";
|
|
650
531
|
turns.push({
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
status: "in_progress",
|
|
532
|
+
...buildActiveTimelineTurnSummary(
|
|
533
|
+
{
|
|
534
|
+
turnRecordId: input.currentExecutionTurnRecordId ?? `current:${turnId}`,
|
|
535
|
+
turnId,
|
|
536
|
+
turnType: input.selectedTurnType ?? "llm",
|
|
537
|
+
pathType: "primary",
|
|
538
|
+
startedAt: input.process.updatedAt,
|
|
539
|
+
assistant: { text: "", thinking: "", lastUpdatedAt: null },
|
|
540
|
+
},
|
|
541
|
+
{ summary: `Current step: ${formatDefinition(turnId)}`, output: "" },
|
|
542
|
+
),
|
|
663
543
|
modelProfileId:
|
|
664
544
|
input.activeModelProfileId === undefined
|
|
665
545
|
? (input.process.selectedTurnModelProfileId ?? null)
|
|
666
546
|
: input.activeModelProfileId,
|
|
667
|
-
attemptNumber: 1,
|
|
668
|
-
parentTurnRecordId: null,
|
|
669
|
-
startedAt: input.process.updatedAt,
|
|
670
|
-
endedAt: null,
|
|
671
|
-
actionSource: null,
|
|
672
|
-
progress: null,
|
|
673
547
|
});
|
|
674
548
|
}
|
|
675
549
|
|
|
@@ -739,46 +613,28 @@ export function buildExternalTriggerSignals(args: {
|
|
|
739
613
|
) ?? null;
|
|
740
614
|
const latestConfiguredEvent = latestArmedEvent ?? latestEvent;
|
|
741
615
|
const configuredDetail = setupDetail(latestConfiguredEvent);
|
|
742
|
-
|
|
616
|
+
let state: ProcessExternalTriggerSignal["state"] = "waiting";
|
|
617
|
+
let occurredAt: string | null = null;
|
|
618
|
+
let secondaryDetail = configuredDetail;
|
|
743
619
|
if (
|
|
744
620
|
latestEvent?.eventType === "external_trigger_failed" ||
|
|
745
621
|
latestEvent?.eventType === "external_source_failed"
|
|
746
622
|
) {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
if (args.isWaitingForSelectedTurn) {
|
|
756
|
-
return {
|
|
757
|
-
triggerId: trigger.id,
|
|
758
|
-
state: "armed",
|
|
759
|
-
occurredAt: latestArmedEvent?.createdAt ?? null,
|
|
760
|
-
secondaryDetail: configuredDetail ?? "No trigger attempts recorded yet.",
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
if (
|
|
623
|
+
state = "error";
|
|
624
|
+
occurredAt = latestEvent.createdAt;
|
|
625
|
+
secondaryDetail = joinDetails(stringValueOrNull(latestEvent.data.message), configuredDetail);
|
|
626
|
+
} else if (args.isWaitingForSelectedTurn) {
|
|
627
|
+
state = "armed";
|
|
628
|
+
occurredAt = latestArmedEvent?.createdAt ?? null;
|
|
629
|
+
secondaryDetail = configuredDetail ?? "No trigger attempts recorded yet.";
|
|
630
|
+
} else if (
|
|
765
631
|
latestEvent?.eventType === "external_trigger_consumed" ||
|
|
766
632
|
latestEvent?.eventType === "external_source_consumed"
|
|
767
633
|
) {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
state: "triggered",
|
|
771
|
-
occurredAt: latestEvent.createdAt,
|
|
772
|
-
secondaryDetail: configuredDetail,
|
|
773
|
-
};
|
|
634
|
+
state = "triggered";
|
|
635
|
+
occurredAt = latestEvent.createdAt;
|
|
774
636
|
}
|
|
775
|
-
|
|
776
|
-
return {
|
|
777
|
-
triggerId: trigger.id,
|
|
778
|
-
state: "waiting",
|
|
779
|
-
occurredAt: null,
|
|
780
|
-
secondaryDetail: configuredDetail,
|
|
781
|
-
};
|
|
637
|
+
return { triggerId: trigger.id, state, occurredAt, secondaryDetail };
|
|
782
638
|
});
|
|
783
639
|
}
|
|
784
640
|
|
|
@@ -845,6 +701,20 @@ export function formatProcessErrorPresentation(
|
|
|
845
701
|
};
|
|
846
702
|
}
|
|
847
703
|
const withoutPrefix = raw.replace(/^Turn\s+'[^']*'\s+.*?failed:\s*/i, "").trim() || raw;
|
|
704
|
+
if (
|
|
705
|
+
(!errorClass || errorClass === "llm_error") &&
|
|
706
|
+
withoutPrefix.startsWith("Turn aborted by LLM:")
|
|
707
|
+
) {
|
|
708
|
+
const reason = withoutPrefix.slice("Turn aborted by LLM:".length).trim();
|
|
709
|
+
return {
|
|
710
|
+
summary: reason
|
|
711
|
+
? `The agent stopped this turn — ${lowerFirst(reason)}`
|
|
712
|
+
: "The agent stopped this turn",
|
|
713
|
+
guidance:
|
|
714
|
+
"Review the reported reason and resolve any blocker before continuing or retrying the turn.",
|
|
715
|
+
technicalDetail: raw,
|
|
716
|
+
};
|
|
717
|
+
}
|
|
848
718
|
const detail = extractProviderMessage(withoutPrefix) ?? withoutPrefix;
|
|
849
719
|
const summary =
|
|
850
720
|
category && detail.toLowerCase() !== category.toLowerCase()
|
|
@@ -949,6 +819,16 @@ export function buildCurrentProcessError(input: {
|
|
|
949
819
|
if (input.process.lifecycleStatus !== "error" || input.currentTurnRecovery) {
|
|
950
820
|
return null;
|
|
951
821
|
}
|
|
822
|
+
const wait = pendingTurnWait(input.process);
|
|
823
|
+
if (wait?.status === "error")
|
|
824
|
+
return {
|
|
825
|
+
title: input.selectedTurnDescription ?? "Waiting condition",
|
|
826
|
+
summary: wait.message ?? "The waiting condition failed",
|
|
827
|
+
canRetry: true,
|
|
828
|
+
guidance:
|
|
829
|
+
"Fix the condition or its configuration, then retry. Readiness is checked before starting a worker.",
|
|
830
|
+
technicalDetail: null,
|
|
831
|
+
};
|
|
952
832
|
const latestErrorEvent = input.events.findLast(
|
|
953
833
|
(event) => event.eventType === "lifecycle_parked" || event.eventType === "worker_failed",
|
|
954
834
|
);
|
|
@@ -998,14 +878,10 @@ export function buildUsageEstimate(input: {
|
|
|
998
878
|
totalLlmTurnCount += 1;
|
|
999
879
|
const isActiveTurn = turnRecord.id === input.currentTurnRecordId;
|
|
1000
880
|
const turnUsage =
|
|
1001
|
-
isActiveTurn && input.activeTurn?.turnType === "llm"
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
null)
|
|
1006
|
-
: (input.tracePreviewsByTurnRecordId[turnRecord.id]?.usage ??
|
|
1007
|
-
input.usageByTurnRecordId[turnRecord.id] ??
|
|
1008
|
-
null);
|
|
881
|
+
(isActiveTurn && input.activeTurn?.turnType === "llm" ? input.activeTurn.usage : null) ??
|
|
882
|
+
input.tracePreviewsByTurnRecordId[turnRecord.id]?.usage ??
|
|
883
|
+
input.usageByTurnRecordId[turnRecord.id] ??
|
|
884
|
+
null;
|
|
1009
885
|
if (!turnUsage) {
|
|
1010
886
|
missingUsageTurnCount += 1;
|
|
1011
887
|
continue;
|
|
@@ -1203,10 +1079,54 @@ export function buildProcessUiSnapshotProjections(input: {
|
|
|
1203
1079
|
};
|
|
1204
1080
|
}
|
|
1205
1081
|
|
|
1082
|
+
type ProcessUiSnapshotDeps = Pick<
|
|
1083
|
+
RouteDeps,
|
|
1084
|
+
| "executionInspections"
|
|
1085
|
+
| "processes"
|
|
1086
|
+
| "projects"
|
|
1087
|
+
| "inputs"
|
|
1088
|
+
| "events"
|
|
1089
|
+
| "turnRecords"
|
|
1090
|
+
| "mappedRuns"
|
|
1091
|
+
| "turnStarts"
|
|
1092
|
+
| "turnAnnotations"
|
|
1093
|
+
| "turnSummaries"
|
|
1094
|
+
| "leafOutcomeSnapshots"
|
|
1095
|
+
| "questionRequests"
|
|
1096
|
+
| "toolApprovalRequests"
|
|
1097
|
+
| "leases"
|
|
1098
|
+
| "startupObservations"
|
|
1099
|
+
| "futureExecutions"
|
|
1100
|
+
| "processGraphs"
|
|
1101
|
+
| "processActionRegistry"
|
|
1102
|
+
| "processUiRegistry"
|
|
1103
|
+
| "processModelPolicy"
|
|
1104
|
+
| "modelStatusCache"
|
|
1105
|
+
| "launcherService"
|
|
1106
|
+
| "sessionReader"
|
|
1107
|
+
| "sessionTransferService"
|
|
1108
|
+
| "externalSourceService"
|
|
1109
|
+
| "toolRenderers"
|
|
1110
|
+
| "config"
|
|
1111
|
+
>;
|
|
1112
|
+
|
|
1113
|
+
function includeRecord<T extends { id: string }>(
|
|
1114
|
+
records: T[],
|
|
1115
|
+
id: string | null | undefined,
|
|
1116
|
+
repo: { getById(id: string): T | null },
|
|
1117
|
+
): void {
|
|
1118
|
+
if (!id || records.some((record) => record.id === id)) return;
|
|
1119
|
+
const record = repo.getById(id);
|
|
1120
|
+
if (record) records.push(record);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1206
1123
|
export class ProcessUiSnapshotAssembler {
|
|
1207
|
-
constructor(private readonly deps:
|
|
1124
|
+
constructor(private readonly deps: ProcessUiSnapshotDeps) {}
|
|
1208
1125
|
|
|
1209
|
-
async assemble(
|
|
1126
|
+
async assemble(
|
|
1127
|
+
instanceId: string,
|
|
1128
|
+
beforeTurnRecordId?: string,
|
|
1129
|
+
): Promise<ProcessDetailUiSnapshotResponseBody | null> {
|
|
1210
1130
|
const process = this.deps.processes.getById(instanceId);
|
|
1211
1131
|
if (!process) {
|
|
1212
1132
|
return null;
|
|
@@ -1214,19 +1134,41 @@ export class ProcessUiSnapshotAssembler {
|
|
|
1214
1134
|
// Capture every synchronous durable read before yielding so one response cannot
|
|
1215
1135
|
// combine process/turn state from opposite sides of a concurrent mutation.
|
|
1216
1136
|
const projects = this.deps.projects.listByInstance(instanceId);
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
const
|
|
1137
|
+
const before = beforeTurnRecordId ? this.deps.turnRecords.getById(beforeTurnRecordId) : null;
|
|
1138
|
+
if (beforeTurnRecordId && before?.instanceId !== instanceId) return null;
|
|
1139
|
+
const page = this.deps.turnRecords.listPage(instanceId, before ?? undefined, 41);
|
|
1140
|
+
const hasMore = page.length > 40;
|
|
1141
|
+
const turnRecords = hasMore ? page.slice(1) : page;
|
|
1142
|
+
const turnRecordIds = turnRecords.map((turn) => turn.id);
|
|
1143
|
+
const window = {
|
|
1144
|
+
since: hasMore ? turnRecords[0]?.startedAt : undefined,
|
|
1145
|
+
until: before?.startedAt,
|
|
1146
|
+
};
|
|
1147
|
+
const mapped = {
|
|
1148
|
+
runs: this.deps.mappedRuns?.listByInstance(instanceId) ?? [],
|
|
1149
|
+
items: this.deps.mappedRuns?.listItemsByInstance(instanceId) ?? [],
|
|
1150
|
+
};
|
|
1151
|
+
const events = this.deps.events.listUiSnapshotEvents(instanceId, turnRecordIds);
|
|
1152
|
+
const turnAnnotations = this.deps.turnAnnotations.listForTimeline(instanceId, window);
|
|
1220
1153
|
const inputs = this.deps.inputs.listByInstance(instanceId);
|
|
1221
|
-
const leafOutcomeSnapshots = this.deps.leafOutcomeSnapshots.listByInstance(instanceId);
|
|
1154
|
+
const leafOutcomeSnapshots = this.deps.leafOutcomeSnapshots.listByInstance(instanceId, window);
|
|
1222
1155
|
const questionRequests = this.deps.questionRequests.listByInstance(instanceId);
|
|
1223
1156
|
const toolApprovalRequests = this.deps.toolApprovalRequests.listByInstance(instanceId);
|
|
1224
|
-
const workerLeases = this.deps.leases.listByInstance(instanceId);
|
|
1225
|
-
const workerLease =
|
|
1226
|
-
|
|
1157
|
+
const workerLeases = this.deps.leases.listByInstance(instanceId, window);
|
|
1158
|
+
const workerLease = this.deps.leases.getByInstance(instanceId);
|
|
1159
|
+
if (workerLease && !workerLeases.some((lease) => lease.id === workerLease.id)) {
|
|
1160
|
+
workerLeases.push(workerLease);
|
|
1161
|
+
}
|
|
1162
|
+
const startupTurnStarts = this.deps.turnStarts.listByInstance(instanceId, window);
|
|
1163
|
+
// A worker starts before its accepted turn. Keep boundary records even when
|
|
1164
|
+
// their timestamps precede the oldest turn on this page.
|
|
1165
|
+
for (const turn of turnRecords) {
|
|
1166
|
+
includeRecord(startupTurnStarts, turn.turnStartRecordId, this.deps.turnStarts);
|
|
1167
|
+
includeRecord(workerLeases, turn.acceptedWorkerLeaseId, this.deps.leases);
|
|
1168
|
+
}
|
|
1227
1169
|
const selectedTurn = getSelectedTurnSummaryForProcess(this.deps, process);
|
|
1228
1170
|
const session = this.deps.turnSummaries.getSession(instanceId);
|
|
1229
|
-
const summaries = this.deps.turnSummaries.listByInstance(instanceId);
|
|
1171
|
+
const summaries = this.deps.turnSummaries.listByInstance(instanceId, turnRecordIds);
|
|
1230
1172
|
const currentTurnRecordId = resolveCurrentExecutionTurnRecordId(process, this.deps.turnStarts);
|
|
1231
1173
|
const activeRecord = turnRecords.find(
|
|
1232
1174
|
(turn) => turn.id === currentTurnRecordId && turn.status === "running",
|
|
@@ -1311,22 +1253,33 @@ export class ProcessUiSnapshotAssembler {
|
|
|
1311
1253
|
refreshedAt: annotation.payload.refreshedAt,
|
|
1312
1254
|
});
|
|
1313
1255
|
}
|
|
1256
|
+
if (hasMore && projections.usageEstimate) {
|
|
1257
|
+
projections.usageEstimate.isPartial = true;
|
|
1258
|
+
projections.usageEstimate.historyLimited = true;
|
|
1259
|
+
}
|
|
1314
1260
|
const runDetails = buildProcessRunDetailsView(this.deps, process, projects);
|
|
1315
1261
|
const navigation = presentProcessTurnNavigation({
|
|
1316
1262
|
graph: getProcessGraph(this.deps.processGraphs, process.processId),
|
|
1317
1263
|
turns: projections.timeline.turns,
|
|
1318
1264
|
selectedTurnId: process.selectedTurnId,
|
|
1319
1265
|
lifecycleStatus: process.lifecycleStatus,
|
|
1266
|
+
turnRecords,
|
|
1267
|
+
mapped,
|
|
1320
1268
|
});
|
|
1321
1269
|
|
|
1322
1270
|
return {
|
|
1323
1271
|
...projections,
|
|
1324
|
-
timeline: {
|
|
1272
|
+
timeline: {
|
|
1273
|
+
...projections.timeline,
|
|
1274
|
+
turns: navigation.turns,
|
|
1275
|
+
history: { beforeTurnRecordId: hasMore ? turnRecords[0].id : null },
|
|
1276
|
+
},
|
|
1325
1277
|
plannedNextTurn: navigation.plannedNextTurn,
|
|
1326
1278
|
instanceTree: presentProcessInstanceTree({
|
|
1327
1279
|
process,
|
|
1328
1280
|
turnRecords,
|
|
1329
|
-
|
|
1281
|
+
leases: workerLeases,
|
|
1282
|
+
observations: this.deps.executionInspections.listContextFacts(instanceId, turnRecordIds),
|
|
1330
1283
|
turnDetails: runDetails.turns,
|
|
1331
1284
|
currentPiEntryId: session?.leafId ?? null,
|
|
1332
1285
|
}),
|
|
@@ -1355,41 +1308,39 @@ export class ProcessUiSnapshotAssembler {
|
|
|
1355
1308
|
instanceId: string;
|
|
1356
1309
|
turnRecordId: string;
|
|
1357
1310
|
}): Promise<TurnReasoningDetailResponseBody | null> {
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1311
|
+
return (await this.readReasoningEvidence(input))?.detail ?? null;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
/** Capture durable facts before loading the session, once for all detail projections. @internal */
|
|
1315
|
+
async readReasoningEvidence(input: {
|
|
1316
|
+
instanceId: string;
|
|
1317
|
+
turnRecordId: string;
|
|
1318
|
+
includeSession?: boolean;
|
|
1319
|
+
}) {
|
|
1320
|
+
if (!this.deps.processes.getById(input.instanceId)) return null;
|
|
1362
1321
|
const turnRecord = this.deps.turnRecords.getById(input.turnRecordId);
|
|
1363
|
-
if (!turnRecord || turnRecord.instanceId !== input.instanceId)
|
|
1364
|
-
return null;
|
|
1365
|
-
}
|
|
1322
|
+
if (!turnRecord || turnRecord.instanceId !== input.instanceId) return null;
|
|
1366
1323
|
const throughEventSequence = this.deps.events.latestSequence(input.instanceId);
|
|
1367
1324
|
const events = this.deps.events.listByTurnRecord(input.instanceId, input.turnRecordId);
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
const
|
|
1380
|
-
const trace = buildCommittedTurnTrace({
|
|
1381
|
-
tree: session.piTree,
|
|
1382
|
-
turnRecord,
|
|
1383
|
-
events,
|
|
1384
|
-
});
|
|
1385
|
-
trace.usage ??= buildUsageSnapshotsByTurnRecordId(events)[turnRecord.id] ?? null;
|
|
1386
|
-
return {
|
|
1325
|
+
const live = turnRecord.status === "running";
|
|
1326
|
+
const liveSignature = this.deps.turnSummaries.getSession(input.instanceId)?.signature ?? null;
|
|
1327
|
+
const session =
|
|
1328
|
+
!live || input.includeSession
|
|
1329
|
+
? await this.deps.sessionReader.readSessionTree(input.instanceId)
|
|
1330
|
+
: null;
|
|
1331
|
+
const trace =
|
|
1332
|
+
!live && session
|
|
1333
|
+
? buildCommittedTurnTrace({ tree: session.piTree, turnRecord, events })
|
|
1334
|
+
: createLiveTurnProjection(events).snapshot();
|
|
1335
|
+
if (!live) trace.usage ??= buildUsageSnapshotsByTurnRecordId(events)[turnRecord.id] ?? null;
|
|
1336
|
+
const detail: TurnReasoningDetailResponseBody = {
|
|
1387
1337
|
instanceId: input.instanceId,
|
|
1388
1338
|
turnRecordId: input.turnRecordId,
|
|
1389
|
-
sessionSignature: session
|
|
1390
|
-
state: "committed",
|
|
1339
|
+
sessionSignature: live ? liveSignature : (session?.signature ?? null),
|
|
1340
|
+
state: live ? "live" : "committed",
|
|
1391
1341
|
throughEventSequence,
|
|
1392
1342
|
reasoning: trace,
|
|
1393
1343
|
};
|
|
1344
|
+
return { detail, turnRecord, events, session };
|
|
1394
1345
|
}
|
|
1395
1346
|
}
|