@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ProcessEvent } from "@leitwerk-dev/domain";
|
|
2
2
|
import { applyEventToCompactTurnSummary, emptyCompactTurnSummary } from "@leitwerk-dev/protocol";
|
|
3
|
-
import {
|
|
3
|
+
import type { SQL } from "drizzle-orm";
|
|
4
|
+
import { and, asc, desc, eq, getTableColumns, gte, inArray, like, sql } from "drizzle-orm";
|
|
4
5
|
import type { LeitwerkDb } from "./database.js";
|
|
5
6
|
import { generateId, now } from "./repo-helpers.js";
|
|
6
7
|
import * as s from "./schema.js";
|
|
@@ -40,6 +41,87 @@ export function createProcessEventRepo(db: LeitwerkDb) {
|
|
|
40
41
|
.all()
|
|
41
42
|
.map(rowToProcessEvent);
|
|
42
43
|
return {
|
|
44
|
+
/** Timeline facts without embedded process state or provider responses. @internal */
|
|
45
|
+
listUiSnapshotEvents(instanceId: string, turnRecordIds: readonly string[]): ProcessEvent[] {
|
|
46
|
+
const newestIds = (where: SQL | undefined, limit: number) =>
|
|
47
|
+
db
|
|
48
|
+
.select({ id: s.processEvents.id, sequence: s.processEvents.eventSequence })
|
|
49
|
+
.from(s.processEvents)
|
|
50
|
+
.where(where)
|
|
51
|
+
.orderBy(desc(s.processEvents.eventSequence))
|
|
52
|
+
.limit(limit)
|
|
53
|
+
.all();
|
|
54
|
+
// Select identities before loading payloads. Most candidates are discarded
|
|
55
|
+
// by the combined limit, and one provider response can be megabytes.
|
|
56
|
+
const candidates = [
|
|
57
|
+
"worker_capacity_queued",
|
|
58
|
+
"lifecycle_parked",
|
|
59
|
+
"worker_failed",
|
|
60
|
+
"external_trigger_listener_armed",
|
|
61
|
+
"external_source_armed",
|
|
62
|
+
"external_trigger_failed",
|
|
63
|
+
"external_source_failed",
|
|
64
|
+
"external_trigger_consumed",
|
|
65
|
+
"external_source_consumed",
|
|
66
|
+
].flatMap((eventType) =>
|
|
67
|
+
newestIds(
|
|
68
|
+
and(eq(s.processEvents.instanceId, instanceId), eq(s.processEvents.eventType, eventType)),
|
|
69
|
+
40,
|
|
70
|
+
),
|
|
71
|
+
);
|
|
72
|
+
candidates.sort((left, right) => right.sequence - left.sequence);
|
|
73
|
+
const selected = candidates.slice(0, 40);
|
|
74
|
+
for (const turnRecordId of turnRecordIds) {
|
|
75
|
+
for (const eventType of ["turn.progress", "turn_outcome_recorded"]) {
|
|
76
|
+
selected.push(
|
|
77
|
+
...newestIds(
|
|
78
|
+
and(
|
|
79
|
+
eq(s.processEvents.instanceId, instanceId),
|
|
80
|
+
eq(s.processEvents.turnRecordId, turnRecordId),
|
|
81
|
+
eq(s.processEvents.eventType, eventType),
|
|
82
|
+
),
|
|
83
|
+
1,
|
|
84
|
+
),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const ids = [...new Set(selected.map((event) => event.id))];
|
|
89
|
+
if (ids.length === 0) return [];
|
|
90
|
+
const data = s.processEvents.data;
|
|
91
|
+
return db
|
|
92
|
+
.select({
|
|
93
|
+
...getTableColumns(s.processEvents),
|
|
94
|
+
data: sql<string>`json_object(
|
|
95
|
+
'turnRecordId', json_extract(${data}, '$.turnRecordId'),
|
|
96
|
+
'turnId', json_extract(${data}, '$.turnId'),
|
|
97
|
+
'outcome', json_extract(${data}, '$.outcome'),
|
|
98
|
+
'params', json_object(
|
|
99
|
+
'summary', json_extract(${data}, '$.params.summary'),
|
|
100
|
+
'planMarkdown', json_extract(${data}, '$.params.planMarkdown'),
|
|
101
|
+
'reviewMarkdown', json_extract(${data}, '$.params.reviewMarkdown'),
|
|
102
|
+
'feedback', json_extract(${data}, '$.params.feedback')),
|
|
103
|
+
'report', json_extract(${data}, '$.report'),
|
|
104
|
+
'revision', json_extract(${data}, '$.revision'),
|
|
105
|
+
'startRecordId', json_extract(${data}, '$.startRecordId'),
|
|
106
|
+
'reason', json_extract(${data}, '$.reason'),
|
|
107
|
+
'message', json_extract(${data}, '$.message'),
|
|
108
|
+
'errorCode', json_extract(${data}, '$.errorCode'),
|
|
109
|
+
'errorClass', json_extract(${data}, '$.errorClass'),
|
|
110
|
+
'armingId', json_extract(${data}, '$.armingId'),
|
|
111
|
+
'trigger', json_extract(${data}, '$.trigger'),
|
|
112
|
+
'path', json_extract(${data}, '$.path'),
|
|
113
|
+
'pollInterval', json_extract(${data}, '$.pollInterval'),
|
|
114
|
+
'provider', json_object(
|
|
115
|
+
'path', json_extract(${data}, '$.provider.path'),
|
|
116
|
+
'pollInterval', json_extract(${data}, '$.provider.pollInterval'))
|
|
117
|
+
)`,
|
|
118
|
+
})
|
|
119
|
+
.from(s.processEvents)
|
|
120
|
+
.where(inArray(s.processEvents.id, ids))
|
|
121
|
+
.orderBy(asc(s.processEvents.createdAt), asc(s.processEvents.id))
|
|
122
|
+
.all()
|
|
123
|
+
.map(rowToProcessEvent);
|
|
124
|
+
},
|
|
43
125
|
/** @internal */
|
|
44
126
|
create(input: CreateProcessEventInput): ProcessEvent {
|
|
45
127
|
const id = generateId("evt");
|
|
@@ -111,20 +193,16 @@ export function createProcessEventRepo(db: LeitwerkDb) {
|
|
|
111
193
|
turnRecordId: string,
|
|
112
194
|
eventType: string,
|
|
113
195
|
): ProcessEvent | null {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
.from(s.processEvents)
|
|
117
|
-
.where(
|
|
196
|
+
return (
|
|
197
|
+
listNewest(
|
|
118
198
|
and(
|
|
119
199
|
eq(s.processEvents.instanceId, instanceId),
|
|
120
200
|
eq(s.processEvents.turnRecordId, turnRecordId),
|
|
121
201
|
eq(s.processEvents.eventType, eventType),
|
|
122
202
|
),
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
.get();
|
|
127
|
-
return row ? rowToProcessEvent(row) : null;
|
|
203
|
+
1,
|
|
204
|
+
)[0] ?? null
|
|
205
|
+
);
|
|
128
206
|
},
|
|
129
207
|
/** @internal */
|
|
130
208
|
summary(turnRecordId: string) {
|
|
@@ -362,10 +362,17 @@ export function createProcessInstanceRepo(db: LeitwerkDb) {
|
|
|
362
362
|
},
|
|
363
363
|
|
|
364
364
|
/** @public */
|
|
365
|
-
update(
|
|
365
|
+
update(
|
|
366
|
+
id: string,
|
|
367
|
+
input: UpdateProcessInstanceInput,
|
|
368
|
+
options: {
|
|
369
|
+
/** Scheduling-only writes retain process activity time; never part of a process patch. @internal */
|
|
370
|
+
preserveUpdatedAt?: boolean;
|
|
371
|
+
} = {},
|
|
372
|
+
): ProcessInstance | null {
|
|
366
373
|
const ts = now();
|
|
367
374
|
const setValues: SQLiteUpdateSetSource<typeof s.processInstances> = {
|
|
368
|
-
updatedAt: ts,
|
|
375
|
+
...(options.preserveUpdatedAt ? {} : { updatedAt: ts }),
|
|
369
376
|
defaultModelProfileId: input.defaultModelProfileId,
|
|
370
377
|
initialDefaultModelProfileId: input.initialDefaultModelProfileId,
|
|
371
378
|
selectedTurnId: input.selectedTurnId,
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
} from "@leitwerk-dev/domain";
|
|
5
5
|
import { and, asc, desc, eq, sql } from "drizzle-orm";
|
|
6
6
|
import type { LeitwerkDb } from "./database.js";
|
|
7
|
+
import { type HistoryWindow, historyWindow } from "./history-window.js";
|
|
7
8
|
import { generateId, now, parseJsonRecord } from "./repo-helpers.js";
|
|
8
9
|
import * as s from "./schema.js";
|
|
9
10
|
|
|
@@ -82,11 +83,16 @@ export function createProcessLeafOutcomeSnapshotRepo(db: LeitwerkDb) {
|
|
|
82
83
|
},
|
|
83
84
|
|
|
84
85
|
/** @internal */
|
|
85
|
-
listByInstance(instanceId: string): ProcessLeafOutcomeSnapshot[] {
|
|
86
|
+
listByInstance(instanceId: string, window?: HistoryWindow): ProcessLeafOutcomeSnapshot[] {
|
|
86
87
|
return db
|
|
87
88
|
.select()
|
|
88
89
|
.from(s.processLeafOutcomeSnapshots)
|
|
89
|
-
.where(
|
|
90
|
+
.where(
|
|
91
|
+
and(
|
|
92
|
+
eq(s.processLeafOutcomeSnapshots.instanceId, instanceId),
|
|
93
|
+
historyWindow(s.processLeafOutcomeSnapshots.anchoredAt, window),
|
|
94
|
+
),
|
|
95
|
+
)
|
|
90
96
|
.orderBy(
|
|
91
97
|
asc(s.processLeafOutcomeSnapshots.anchoredAt),
|
|
92
98
|
asc(s.processLeafOutcomeSnapshots.createdAt),
|
|
@@ -60,6 +60,10 @@ function rowToProcessProject(row: typeof s.processProjects.$inferSelect): Proces
|
|
|
60
60
|
/** @public */
|
|
61
61
|
export function createProcessProjectRepo(db: LeitwerkDb) {
|
|
62
62
|
return {
|
|
63
|
+
/** @internal */
|
|
64
|
+
listAll(): ProcessProject[] {
|
|
65
|
+
return db.select().from(s.processProjects).all().map(rowToProcessProject);
|
|
66
|
+
},
|
|
63
67
|
/** @internal */
|
|
64
68
|
create(input: CreateProcessProjectInput): ProcessProject {
|
|
65
69
|
const id = generateId("prj");
|
|
@@ -49,15 +49,22 @@ export function createProcessSkillRepo(db: LeitwerkDb) {
|
|
|
49
49
|
.select({
|
|
50
50
|
digest: skillRevisions.bundleDigest,
|
|
51
51
|
bytes: skillRevisions.bundleBytes,
|
|
52
|
+
provenance: skillRevisions.provenance,
|
|
52
53
|
})
|
|
53
54
|
.from(processSkills)
|
|
54
55
|
.innerJoin(skillRevisions, eq(processSkills.skillRevisionId, skillRevisions.id))
|
|
55
56
|
.where(eq(processSkills.instanceId, instanceId))
|
|
56
57
|
.orderBy(asc(processSkills.position))
|
|
57
58
|
.all()
|
|
58
|
-
.map(({ digest, bytes }) => ({
|
|
59
|
+
.map(({ digest, bytes, provenance }) => ({
|
|
59
60
|
bundle: { digest, bytes },
|
|
60
|
-
owner:
|
|
61
|
+
owner: provenance
|
|
62
|
+
? {
|
|
63
|
+
kind: "skill" as const,
|
|
64
|
+
ownerExtensionId: provenance.extensionId,
|
|
65
|
+
packageName: provenance.packageName,
|
|
66
|
+
}
|
|
67
|
+
: SKILL_RESOURCE_OWNER,
|
|
61
68
|
}));
|
|
62
69
|
},
|
|
63
70
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ProcessTurnAnnotation, TurnAnnotationReference } from "@leitwerk-dev/domain";
|
|
2
2
|
import { parseTurnAnnotationReferences } from "@leitwerk-dev/domain";
|
|
3
|
-
import { and, asc, eq } from "drizzle-orm";
|
|
3
|
+
import { and, asc, eq, getTableColumns, sql } from "drizzle-orm";
|
|
4
4
|
import type { SQLiteUpdateSetSource } from "drizzle-orm/sqlite-core";
|
|
5
5
|
import type { LeitwerkDb } from "./database.js";
|
|
6
|
+
import { type HistoryWindow, historyWindow } from "./history-window.js";
|
|
6
7
|
import { generateId, now, parseJsonRecord } from "./repo-helpers.js";
|
|
7
8
|
import * as s from "./schema.js";
|
|
8
9
|
|
|
@@ -65,6 +66,24 @@ function rowToProcessTurnAnnotation(
|
|
|
65
66
|
|
|
66
67
|
/** @internal */
|
|
67
68
|
export function createProcessTurnAnnotationRepo(db: LeitwerkDb) {
|
|
69
|
+
const list = (instanceId: string, window: HistoryWindow | undefined, compact: boolean) =>
|
|
70
|
+
db
|
|
71
|
+
.select({
|
|
72
|
+
...getTableColumns(s.turnAnnotations),
|
|
73
|
+
payloadJson: compact
|
|
74
|
+
? sql<string>`json_remove(${s.turnAnnotations.payloadJson}, '$.event')`
|
|
75
|
+
: s.turnAnnotations.payloadJson,
|
|
76
|
+
})
|
|
77
|
+
.from(s.turnAnnotations)
|
|
78
|
+
.where(
|
|
79
|
+
and(
|
|
80
|
+
eq(s.turnAnnotations.instanceId, instanceId),
|
|
81
|
+
historyWindow(s.turnAnnotations.createdAt, window),
|
|
82
|
+
),
|
|
83
|
+
)
|
|
84
|
+
.orderBy(asc(s.turnAnnotations.createdAt))
|
|
85
|
+
.all()
|
|
86
|
+
.map(rowToProcessTurnAnnotation);
|
|
68
87
|
return {
|
|
69
88
|
/** @internal */
|
|
70
89
|
create(input: CreateProcessTurnAnnotationInput): ProcessTurnAnnotation {
|
|
@@ -111,14 +130,13 @@ export function createProcessTurnAnnotationRepo(db: LeitwerkDb) {
|
|
|
111
130
|
},
|
|
112
131
|
|
|
113
132
|
/** @internal */
|
|
114
|
-
listByInstance(instanceId: string): ProcessTurnAnnotation[] {
|
|
115
|
-
return
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.map(rowToProcessTurnAnnotation);
|
|
133
|
+
listByInstance(instanceId: string, window?: HistoryWindow): ProcessTurnAnnotation[] {
|
|
134
|
+
return list(instanceId, window, false);
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
/** Keep presentation and observation fields without the raw source event. @internal */
|
|
138
|
+
listForTimeline(instanceId: string, window?: HistoryWindow): ProcessTurnAnnotation[] {
|
|
139
|
+
return list(instanceId, window, true);
|
|
122
140
|
},
|
|
123
141
|
|
|
124
142
|
/** @internal */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
MappedTurnItemRef,
|
|
2
3
|
ModelSelectionProvenance,
|
|
3
4
|
ProcessTurnRecord,
|
|
4
5
|
ProcessTurnRecordPathType,
|
|
@@ -7,10 +8,10 @@ import type {
|
|
|
7
8
|
TurnId,
|
|
8
9
|
WorkerErrorClass,
|
|
9
10
|
} from "@leitwerk-dev/domain";
|
|
10
|
-
import { asc, desc, eq } from "drizzle-orm";
|
|
11
|
+
import { and, asc, desc, eq, getTableColumns, isNull, ne, sql } from "drizzle-orm";
|
|
11
12
|
import type { SQLiteUpdateSetSource } from "drizzle-orm/sqlite-core";
|
|
12
13
|
import type { LeitwerkDb } from "./database.js";
|
|
13
|
-
import { generateId, now } from "./repo-helpers.js";
|
|
14
|
+
import { generateId, mappedItemRef, now } from "./repo-helpers.js";
|
|
14
15
|
import * as s from "./schema.js";
|
|
15
16
|
|
|
16
17
|
/** @internal */
|
|
@@ -50,6 +51,8 @@ export interface UpdateProcessTurnRecordInput {
|
|
|
50
51
|
/** @internal */
|
|
51
52
|
modelSelectionProvenance?: ModelSelectionProvenance | null;
|
|
52
53
|
/** @internal */
|
|
54
|
+
iteration?: MappedTurnItemRef | null;
|
|
55
|
+
/** @internal */
|
|
53
56
|
turnResultMarkdown?: string | null;
|
|
54
57
|
/** @internal */
|
|
55
58
|
errorSummary?: string | null;
|
|
@@ -81,6 +84,7 @@ function rowToProcessTurnRecord(row: typeof s.turnRecords.$inferSelect): Process
|
|
|
81
84
|
source: row.modelSelectionSource as ModelSelectionProvenance["source"],
|
|
82
85
|
}
|
|
83
86
|
: null,
|
|
87
|
+
iteration: mappedItemRef(row),
|
|
84
88
|
turnResultMarkdown: row.turnResultMarkdown ?? null,
|
|
85
89
|
errorSummary: row.errorSummary ?? null,
|
|
86
90
|
errorClass: (row.errorClass as WorkerErrorClass | null | undefined) ?? null,
|
|
@@ -116,6 +120,9 @@ export function createProcessTurnRecordRepo(db: LeitwerkDb) {
|
|
|
116
120
|
errorClass: input.errorClass ?? null,
|
|
117
121
|
startedAt: input.startedAt ?? now(),
|
|
118
122
|
endedAt: input.endedAt ?? null,
|
|
123
|
+
mappedRunId: input.iteration?.runId ?? null,
|
|
124
|
+
mappedItemKey: input.iteration?.itemKey ?? null,
|
|
125
|
+
mappedItemIndex: input.iteration?.itemIndex ?? null,
|
|
119
126
|
};
|
|
120
127
|
db.insert(s.turnRecords).values(values).run();
|
|
121
128
|
return rowToProcessTurnRecord(values);
|
|
@@ -138,23 +145,56 @@ export function createProcessTurnRecordRepo(db: LeitwerkDb) {
|
|
|
138
145
|
.map(rowToProcessTurnRecord);
|
|
139
146
|
},
|
|
140
147
|
|
|
148
|
+
/** Only absent summaries need repair; don't read every retained turn at startup. @internal */
|
|
149
|
+
listMissingSummaries(instanceId: string): ProcessTurnRecord[] {
|
|
150
|
+
return db
|
|
151
|
+
.select(getTableColumns(s.turnRecords))
|
|
152
|
+
.from(s.turnRecords)
|
|
153
|
+
.leftJoin(s.turnSummaries, eq(s.turnSummaries.turnRecordId, s.turnRecords.id))
|
|
154
|
+
.where(and(eq(s.turnRecords.instanceId, instanceId), isNull(s.turnSummaries.turnRecordId)))
|
|
155
|
+
.all()
|
|
156
|
+
.map(rowToProcessTurnRecord);
|
|
157
|
+
},
|
|
158
|
+
/** A stable page, even when new turns arrive or timestamps tie. @internal */
|
|
159
|
+
listPage(
|
|
160
|
+
instanceId: string,
|
|
161
|
+
before?: Pick<ProcessTurnRecord, "startedAt" | "id">,
|
|
162
|
+
limit = 40,
|
|
163
|
+
): ProcessTurnRecord[] {
|
|
164
|
+
return db
|
|
165
|
+
.select()
|
|
166
|
+
.from(s.turnRecords)
|
|
167
|
+
.where(
|
|
168
|
+
and(
|
|
169
|
+
eq(s.turnRecords.instanceId, instanceId),
|
|
170
|
+
before
|
|
171
|
+
? sql`(${s.turnRecords.startedAt}, ${s.turnRecords.id}) < (${before.startedAt}, ${before.id})`
|
|
172
|
+
: undefined,
|
|
173
|
+
),
|
|
174
|
+
)
|
|
175
|
+
.orderBy(desc(s.turnRecords.startedAt), desc(s.turnRecords.id))
|
|
176
|
+
.limit(limit)
|
|
177
|
+
.all()
|
|
178
|
+
.map(rowToProcessTurnRecord)
|
|
179
|
+
.reverse();
|
|
180
|
+
},
|
|
181
|
+
|
|
141
182
|
/** @internal */
|
|
142
183
|
getLatestSucceededPrimaryByInstance(instanceId: string): ProcessTurnRecord | null {
|
|
143
184
|
const row = db
|
|
144
185
|
.select()
|
|
145
186
|
.from(s.turnRecords)
|
|
146
|
-
.where(
|
|
187
|
+
.where(
|
|
188
|
+
and(
|
|
189
|
+
eq(s.turnRecords.instanceId, instanceId),
|
|
190
|
+
eq(s.turnRecords.status, "succeeded"),
|
|
191
|
+
eq(s.turnRecords.pathType, "primary"),
|
|
192
|
+
ne(s.turnRecords.resultPiEntryId, ""),
|
|
193
|
+
),
|
|
194
|
+
)
|
|
147
195
|
.orderBy(desc(s.turnRecords.startedAt))
|
|
148
|
-
.
|
|
149
|
-
|
|
150
|
-
.find(
|
|
151
|
-
(run) =>
|
|
152
|
-
run.status === "succeeded" &&
|
|
153
|
-
run.pathType === "primary" &&
|
|
154
|
-
typeof run.resultPiEntryId === "string" &&
|
|
155
|
-
run.resultPiEntryId.length > 0,
|
|
156
|
-
);
|
|
157
|
-
return row ?? null;
|
|
196
|
+
.get();
|
|
197
|
+
return row ? rowToProcessTurnRecord(row) : null;
|
|
158
198
|
},
|
|
159
199
|
|
|
160
200
|
/** @internal */
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { PublicationReceipt, PublicationStore } from "@leitwerk-dev/external-writes";
|
|
2
|
+
import { eq } from "drizzle-orm";
|
|
3
|
+
import type { LeitwerkDb } from "./database.js";
|
|
4
|
+
import { topicPublications } from "./schema.js";
|
|
5
|
+
|
|
6
|
+
/** @internal */
|
|
7
|
+
export function createPublicationRepo(db: LeitwerkDb): PublicationStore {
|
|
8
|
+
const store: PublicationStore = {
|
|
9
|
+
publication(key) {
|
|
10
|
+
const row = db.select().from(topicPublications).where(eq(topicPublications.key, key)).get();
|
|
11
|
+
return row ? JSON.parse(row.data) : null;
|
|
12
|
+
},
|
|
13
|
+
publicationByExternalId(externalId) {
|
|
14
|
+
const row = db
|
|
15
|
+
.select()
|
|
16
|
+
.from(topicPublications)
|
|
17
|
+
.where(eq(topicPublications.externalId, externalId))
|
|
18
|
+
.get();
|
|
19
|
+
return row ? JSON.parse(row.data) : null;
|
|
20
|
+
},
|
|
21
|
+
reservePublication(input) {
|
|
22
|
+
return (
|
|
23
|
+
Number(
|
|
24
|
+
db
|
|
25
|
+
.insert(topicPublications)
|
|
26
|
+
.values({
|
|
27
|
+
key: input.key,
|
|
28
|
+
topicId: input.topicId,
|
|
29
|
+
externalId: null,
|
|
30
|
+
data: JSON.stringify(input),
|
|
31
|
+
})
|
|
32
|
+
.onConflictDoNothing()
|
|
33
|
+
.run().changes,
|
|
34
|
+
) === 1
|
|
35
|
+
);
|
|
36
|
+
},
|
|
37
|
+
finishPublication(key, externalId, url) {
|
|
38
|
+
const current = store.publication(key);
|
|
39
|
+
if (!current || (current.externalId && current.externalId !== externalId))
|
|
40
|
+
throw new Error("Publication receipt conflict");
|
|
41
|
+
const receipt: PublicationReceipt = { ...current, externalId, url };
|
|
42
|
+
db.update(topicPublications)
|
|
43
|
+
.set({ externalId, data: JSON.stringify(receipt) })
|
|
44
|
+
.where(eq(topicPublications.key, key))
|
|
45
|
+
.run();
|
|
46
|
+
},
|
|
47
|
+
releaseRejectedPublication(key) {
|
|
48
|
+
const current = store.publication(key);
|
|
49
|
+
if (current?.externalId) throw new Error("Cannot release a published ticket");
|
|
50
|
+
db.delete(topicPublications).where(eq(topicPublications.key, key)).run();
|
|
51
|
+
},
|
|
52
|
+
markPublicationTriggered(key) {
|
|
53
|
+
const current = store.publication(key);
|
|
54
|
+
if (!current?.externalId)
|
|
55
|
+
throw new Error("Ticket receipt is required before triggering changes");
|
|
56
|
+
db.update(topicPublications)
|
|
57
|
+
.set({ data: JSON.stringify({ ...current, triggered: true }) })
|
|
58
|
+
.where(eq(topicPublications.key, key))
|
|
59
|
+
.run();
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
return store;
|
|
63
|
+
}
|
package/src/db/repo-helpers.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import { asUnknownRecord } from "@leitwerk-dev/domain";
|
|
1
|
+
import { asUnknownRecord, type MappedTurnItemRef } from "@leitwerk-dev/domain";
|
|
2
|
+
|
|
3
|
+
export function mappedItemRef(row: {
|
|
4
|
+
mappedRunId: string | null;
|
|
5
|
+
mappedItemKey: string | null;
|
|
6
|
+
mappedItemIndex: number | null;
|
|
7
|
+
}): MappedTurnItemRef | null {
|
|
8
|
+
return row.mappedRunId !== null && row.mappedItemKey !== null && row.mappedItemIndex !== null
|
|
9
|
+
? { runId: row.mappedRunId, itemKey: row.mappedItemKey, itemIndex: row.mappedItemIndex }
|
|
10
|
+
: null;
|
|
11
|
+
}
|
|
2
12
|
|
|
3
13
|
export function parsePersistedJson<T>(value: string, label: string): T {
|
|
4
14
|
try {
|
package/src/db/repositories.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { createTopicWikiRepo } from "@leitwerk-dev/wiki/server";
|
|
1
2
|
import { createApiTokenRepo } from "./api-token-repo.js";
|
|
3
|
+
import { createExecutionInspectionRepo } from "./execution-inspection-repo.js";
|
|
4
|
+
import { createPublicationRepo } from "./publication-repo.js";
|
|
5
|
+
import { createScopedSettingsRepo } from "./scoped-settings-repo.js";
|
|
2
6
|
import { createStartupObservationRepo } from "./startup-observation-repo.js";
|
|
3
7
|
import { createTurnSummaryRepo } from "./turn-summary-repo.js";
|
|
4
8
|
|
|
@@ -15,6 +19,7 @@ export * from "./external-write-log-repo.js";
|
|
|
15
19
|
export * from "./future-execution-repo.js";
|
|
16
20
|
export * from "./launch-run-repo.js";
|
|
17
21
|
export * from "./launcher-recent-value-repo.js";
|
|
22
|
+
export * from "./mapped-llm-run-repo.js";
|
|
18
23
|
export * from "./pending-external-source-fire-repo.js";
|
|
19
24
|
export * from "./process-event-repo.js";
|
|
20
25
|
export * from "./process-handoff-dedup-key-repo.js";
|
|
@@ -39,6 +44,7 @@ export * from "./worker-lease-repo.js";
|
|
|
39
44
|
import { createFutureExecutionRepo } from "./future-execution-repo.js";
|
|
40
45
|
import { createLaunchRunRepo } from "./launch-run-repo.js";
|
|
41
46
|
import { createLauncherRecentValueRepo } from "./launcher-recent-value-repo.js";
|
|
47
|
+
import { createMappedLlmRunRepo } from "./mapped-llm-run-repo.js";
|
|
42
48
|
import { createPendingExternalSourceFireRepo } from "./pending-external-source-fire-repo.js";
|
|
43
49
|
import { createProcessEventRepo } from "./process-event-repo.js";
|
|
44
50
|
import { createProcessHandoffDedupKeyRepo } from "./process-handoff-dedup-key-repo.js";
|
|
@@ -64,6 +70,14 @@ import { createWorkerLeaseRepo } from "./worker-lease-repo.js";
|
|
|
64
70
|
|
|
65
71
|
/** @public */
|
|
66
72
|
export interface RepositoryBundle {
|
|
73
|
+
/** @internal */
|
|
74
|
+
topicWiki: ReturnType<typeof createTopicWikiRepo>;
|
|
75
|
+
/** @internal */
|
|
76
|
+
publications: ReturnType<typeof createPublicationRepo>;
|
|
77
|
+
/** @internal */
|
|
78
|
+
executionInspections: ReturnType<typeof createExecutionInspectionRepo>;
|
|
79
|
+
/** @internal */
|
|
80
|
+
scopedSettings: ReturnType<typeof createScopedSettingsRepo>;
|
|
67
81
|
/** @internal */
|
|
68
82
|
startupObservations: ReturnType<typeof createStartupObservationRepo>;
|
|
69
83
|
/** @internal */
|
|
@@ -105,6 +119,8 @@ export interface RepositoryBundle {
|
|
|
105
119
|
/** @internal */
|
|
106
120
|
turnAnnotations: ReturnType<typeof createProcessTurnAnnotationRepo>;
|
|
107
121
|
/** @internal */
|
|
122
|
+
mappedRuns: ReturnType<typeof createMappedLlmRunRepo>;
|
|
123
|
+
/** @internal */
|
|
108
124
|
leases: ReturnType<typeof createWorkerLeaseRepo>;
|
|
109
125
|
/** @internal */
|
|
110
126
|
providerCredentials: ReturnType<typeof createProviderCredentialRepo>;
|
|
@@ -136,6 +152,11 @@ export function createAllRepos(
|
|
|
136
152
|
): RepositoryBundle {
|
|
137
153
|
const credentialCipher = options.credentialCipher ?? createUnavailableCredentialCipher();
|
|
138
154
|
const bundle: RepositoryBundle = {
|
|
155
|
+
topicWiki: createTopicWikiRepo(db),
|
|
156
|
+
publications: createPublicationRepo(db),
|
|
157
|
+
executionInspections: createExecutionInspectionRepo(db),
|
|
158
|
+
|
|
159
|
+
scopedSettings: createScopedSettingsRepo(db),
|
|
139
160
|
startupObservations: createStartupObservationRepo(db),
|
|
140
161
|
turnSummaries: createTurnSummaryRepo(db),
|
|
141
162
|
processes: createProcessInstanceRepo(db),
|
|
@@ -156,6 +177,7 @@ export function createAllRepos(
|
|
|
156
177
|
turnRecords: createProcessTurnRecordRepo(db),
|
|
157
178
|
turnStarts: createTurnStartRecordRepo(db),
|
|
158
179
|
turnAnnotations: createProcessTurnAnnotationRepo(db),
|
|
180
|
+
mappedRuns: createMappedLlmRunRepo(db),
|
|
159
181
|
leases: createWorkerLeaseRepo(db),
|
|
160
182
|
providerCredentials: createProviderCredentialRepo(db, credentialCipher),
|
|
161
183
|
externalWrites: createExternalWriteLogRepo(db),
|