@leitwerk-dev/server 0.3.1 → 0.4.1
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-BuJCdkvy.d.ts → app-CtlotzYm.d.ts} +312 -121
- package/dist/app-KR3N2JAE.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-QCHS3X33.js → chunk-OUA5EZS2.js} +3127 -689
- package/dist/chunk-OUA5EZS2.js.map +1 -0
- package/dist/{chunk-HK6BLLHA.js → chunk-YLWY4UTT.js} +2424 -1580
- package/dist/chunk-YLWY4UTT.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 +16 -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/dashboard-model-issues.d.ts +10 -0
- package/dist/dashboard-model-issues.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/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 +21 -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 +4 -0
- 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/repositories.d.ts +12 -0
- package/dist/db/repositories.d.ts.map +1 -1
- package/dist/db/schema.d.ts +693 -2
- 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 +10 -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/domain-logic/worker-lease-lifecycle.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.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.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 +1 -6
- package/dist/process-action-presenter.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/process-engine/ops/automatic-retry-startup.d.ts +8 -0
- package/dist/process-engine/ops/automatic-retry-startup.d.ts.map +1 -0
- 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 +2 -0
- 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 +13 -2
- 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-turn-outcome-writes.d.ts +2 -0
- package/dist/process-engine/writes/build-turn-outcome-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/writes.d.ts +28 -60
- 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-availability-recovery.d.ts +1 -1
- package/dist/process-model-availability-recovery.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-trace.d.ts.map +1 -1
- package/dist/process-ui-snapshot-presenter.d.ts +14 -3
- package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
- package/dist/routes/dashboard.d.ts +17 -0
- package/dist/routes/dashboard.d.ts.map +1 -0
- 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-model-config.d.ts +4 -0
- package/dist/routes/process-model-config.d.ts.map +1 -0
- package/dist/routes/process-route-helpers.d.ts +8 -9
- 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 +98 -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 +7 -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 +4 -3
- package/dist/startup-evidence.d.ts.map +1 -1
- package/dist/startup-retry-policy.d.ts +8 -0
- package/dist/startup-retry-policy.d.ts.map +1 -0
- 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.map +1 -1
- package/dist/supervisor/worker-supervisor.d.ts +2 -0
- package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
- 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.js +2 -1
- 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 +177 -25
- package/src/auth/fastify-auth.ts +13 -0
- package/src/config/config-loader.ts +42 -2
- package/src/config/config-types.ts +16 -1
- package/src/config/kubernetes-docker-isolation.ts +21 -0
- package/src/dashboard-model-issues.ts +199 -0
- package/src/db/database.ts +131 -40
- package/src/db/execution-inspection-repo.ts +163 -0
- package/src/db/history-window.ts +18 -0
- package/src/db/process-event-repo.ts +88 -10
- package/src/db/process-instance-repo.ts +33 -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 +45 -12
- package/src/db/publication-repo.ts +63 -0
- package/src/db/repositories.ts +17 -0
- package/src/db/schema.ts +103 -1
- 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 +36 -4
- package/src/db/worker-lease-repo.ts +8 -2
- package/src/domain-logic/outcome-tools.ts +18 -216
- package/src/domain-logic/worker-lease-lifecycle.ts +2 -1
- 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 +7 -8
- package/src/integration-tool-registry.ts +59 -26
- 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 +22 -57
- package/src/process-action-registry.ts +31 -39
- package/src/process-engine/decision.ts +10 -0
- package/src/process-engine/engine.ts +25 -2
- package/src/process-engine/mapped-turns.ts +5 -7
- package/src/process-engine/ops/automatic-retry-startup.ts +93 -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 +20 -16
- package/src/process-engine/ops/start-process.ts +34 -2
- package/src/process-engine/ops/turn-outcome.ts +61 -60
- 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 +34 -5
- 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 +21 -0
- package/src/process-engine/writes/build-process-abort-writes.ts +30 -20
- package/src/process-engine/writes/build-turn-outcome-writes.ts +39 -2
- package/src/process-engine/writes/commit-writes.ts +16 -4
- package/src/process-engine/writes/writes.ts +59 -74
- 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-availability-recovery.ts +6 -4
- 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-trace.ts +12 -24
- package/src/process-ui-snapshot-presenter.ts +210 -295
- package/src/routes/dashboard.ts +106 -0
- 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-model-config.ts +70 -0
- package/src/routes/process-route-helpers.ts +153 -162
- 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 +797 -0
- package/src/server-bootstrap/build-host-capabilities.ts +42 -0
- package/src/server-bootstrap/register-http.ts +12 -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 +94 -0
- package/src/skills/launch-skills.ts +19 -0
- package/src/skills/skill-frontmatter.ts +19 -6
- package/src/skills/source-importer.ts +7 -13
- package/src/startup-evidence.ts +29 -8
- package/src/startup-retry-policy.ts +106 -0
- package/src/supervisor/execution-inspection-ingestor.ts +55 -0
- package/src/supervisor/ipc-handler.ts +2 -0
- package/src/supervisor/worker-event-ingestor.ts +30 -14
- package/src/supervisor/worker-start-payload-builder.ts +17 -0
- package/src/supervisor/worker-supervisor.ts +26 -1
- 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/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-MSJXFK33.js +0 -8
- package/dist/chunk-HK6BLLHA.js.map +0 -1
- package/dist/chunk-QCHS3X33.js.map +0 -1
- /package/dist/{app-MSJXFK33.js.map → app-KR3N2JAE.js.map} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ExecutionInspectionCapture } from "@leitwerk-dev/domain";
|
|
2
|
+
import type { RepositoryBundle } from "../db/repositories.js";
|
|
3
|
+
|
|
4
|
+
/** Accepted execution ownership is checked before retaining any expanded evidence. */
|
|
5
|
+
export function ingestExecutionInspection(
|
|
6
|
+
deps: Pick<RepositoryBundle, "executionInspections" | "turnRecords" | "leases">,
|
|
7
|
+
input: { instanceId: string; workerId: string; turnRecordId: string; capture: unknown },
|
|
8
|
+
): boolean {
|
|
9
|
+
const record = deps.turnRecords.getById(input.turnRecordId);
|
|
10
|
+
const lease = deps.leases.getByInstance(input.instanceId);
|
|
11
|
+
if (
|
|
12
|
+
!record ||
|
|
13
|
+
record.instanceId !== input.instanceId ||
|
|
14
|
+
record.status !== "running" ||
|
|
15
|
+
!record.turnStartRecordId ||
|
|
16
|
+
!lease ||
|
|
17
|
+
lease.workerId !== input.workerId ||
|
|
18
|
+
lease.turnStartRecordId !== record.turnStartRecordId ||
|
|
19
|
+
lease.exitedAt !== null
|
|
20
|
+
)
|
|
21
|
+
return false;
|
|
22
|
+
const capture = input.capture as ExecutionInspectionCapture | null;
|
|
23
|
+
if (
|
|
24
|
+
!capture ||
|
|
25
|
+
capture.version !== 1 ||
|
|
26
|
+
typeof capture.id !== "string" ||
|
|
27
|
+
!capture.id ||
|
|
28
|
+
typeof capture.timestamp !== "string" ||
|
|
29
|
+
!capture.fact ||
|
|
30
|
+
!["model_input", "supplied_context", "product_consumed", "entry_link"].includes(
|
|
31
|
+
capture.fact.kind,
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
return false;
|
|
35
|
+
if (capture.fact.kind === "supplied_context") {
|
|
36
|
+
for (const product of capture.fact.products) {
|
|
37
|
+
const producer = deps.turnRecords.getById(product.producerTurnRecordId);
|
|
38
|
+
if (
|
|
39
|
+
!producer ||
|
|
40
|
+
producer.instanceId !== input.instanceId ||
|
|
41
|
+
producer.resultPiEntryId !== product.entryId
|
|
42
|
+
)
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
deps.executionInspections.append({
|
|
47
|
+
...capture,
|
|
48
|
+
id: `${input.turnRecordId}:${capture.id}`,
|
|
49
|
+
instanceId: input.instanceId,
|
|
50
|
+
turnRecordId: record.id,
|
|
51
|
+
startRecordId: record.turnStartRecordId,
|
|
52
|
+
workerLeaseId: lease.id,
|
|
53
|
+
});
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
@@ -48,6 +48,8 @@ export interface IpcHandlerDeps
|
|
|
48
48
|
/** @internal */
|
|
49
49
|
startupObservations?: RepositoryBundle["startupObservations"];
|
|
50
50
|
/** @internal */
|
|
51
|
+
executionInspections?: RepositoryBundle["executionInspections"];
|
|
52
|
+
/** @internal */
|
|
51
53
|
getLaunchCoordinator?: () => LaunchCoordinator | undefined;
|
|
52
54
|
/** @internal */
|
|
53
55
|
processQuestions?: ProcessQuestionService;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
applyPiEventToLiveTurnProjection,
|
|
3
2
|
asWsEventPayloadRecord,
|
|
4
|
-
buildLiveTurnProjectionFromEvents,
|
|
5
3
|
createDurableWsFrame,
|
|
6
4
|
createEphemeralWsFrame,
|
|
7
|
-
|
|
5
|
+
createLiveTurnProjection,
|
|
8
6
|
isStreamableEvent,
|
|
9
|
-
type
|
|
7
|
+
type LiveTurnProjection,
|
|
10
8
|
mapWorkerEventToWsType,
|
|
11
9
|
readWsEventNonEmptyString,
|
|
12
10
|
readWsEventPiTurnId,
|
|
@@ -21,6 +19,7 @@ import type { RepositoryBundle } from "../db/repositories.js";
|
|
|
21
19
|
import { recordTurnPreparation } from "../turn-preparation.js";
|
|
22
20
|
import { recordTurnProgress } from "../turn-progress.js";
|
|
23
21
|
import type { Broadcaster } from "../ws/broadcast.js";
|
|
22
|
+
import { ingestExecutionInspection } from "./execution-inspection-ingestor.js";
|
|
24
23
|
import { recordInitialTurnObservation } from "./startup-observer.js";
|
|
25
24
|
|
|
26
25
|
/** @internal */
|
|
@@ -48,6 +47,7 @@ export interface WorkerEventLogEntry {
|
|
|
48
47
|
export interface WorkerEventIngestorDeps
|
|
49
48
|
extends Pick<RepositoryBundle, "processes" | "events" | "turnRecords"> {
|
|
50
49
|
leases?: RepositoryBundle["leases"];
|
|
50
|
+
executionInspections?: RepositoryBundle["executionInspections"];
|
|
51
51
|
startupObservations?: RepositoryBundle["startupObservations"];
|
|
52
52
|
broadcaster: Broadcaster;
|
|
53
53
|
workerEventLogger?: (entry: WorkerEventLogEntry) => void;
|
|
@@ -70,28 +70,28 @@ function hydrateLiveTurnProjection(
|
|
|
70
70
|
deps: Pick<WorkerEventIngestorDeps, "events" | "turnRecords">,
|
|
71
71
|
instanceId: string,
|
|
72
72
|
turnRecordId: string | null,
|
|
73
|
-
):
|
|
73
|
+
): LiveTurnProjection {
|
|
74
74
|
if (!turnRecordId) {
|
|
75
|
-
return
|
|
75
|
+
return createLiveTurnProjection();
|
|
76
76
|
}
|
|
77
77
|
const turnRecord = deps.turnRecords.getById(turnRecordId);
|
|
78
78
|
if (!turnRecord) {
|
|
79
|
-
return
|
|
79
|
+
return createLiveTurnProjection();
|
|
80
80
|
}
|
|
81
|
-
return
|
|
81
|
+
return createLiveTurnProjection(deps.events.listByTurnRecord(instanceId, turnRecordId));
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
export function createWorkerEventIngestor(deps: WorkerEventIngestorDeps) {
|
|
85
85
|
const liveTurnRecordIds = new Map<string, string>();
|
|
86
86
|
const liveTurnProjections = new Map<
|
|
87
87
|
string,
|
|
88
|
-
{ turnRecordId: string | null; projection:
|
|
88
|
+
{ turnRecordId: string | null; projection: LiveTurnProjection }
|
|
89
89
|
>();
|
|
90
90
|
|
|
91
91
|
function getLiveTurnProjection(
|
|
92
92
|
instanceId: string,
|
|
93
93
|
turnRecordId: string | null,
|
|
94
|
-
):
|
|
94
|
+
): LiveTurnProjection {
|
|
95
95
|
const existing = liveTurnProjections.get(instanceId);
|
|
96
96
|
if (existing && existing.turnRecordId === turnRecordId) {
|
|
97
97
|
return existing.projection;
|
|
@@ -104,7 +104,7 @@ export function createWorkerEventIngestor(deps: WorkerEventIngestorDeps) {
|
|
|
104
104
|
function setLiveTurnProjection(instanceId: string, turnRecordId: string | null) {
|
|
105
105
|
liveTurnProjections.set(instanceId, {
|
|
106
106
|
turnRecordId,
|
|
107
|
-
projection:
|
|
107
|
+
projection: createLiveTurnProjection(),
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -171,6 +171,18 @@ export function createWorkerEventIngestor(deps: WorkerEventIngestorDeps) {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
if (suppliedTurnRecordId && suppliedTurnRecordId !== currentTurnRecordId) return;
|
|
174
|
+
if (payload.eventType === "execution.inspection") {
|
|
175
|
+
if (suppliedTurnRecordId && deps.executionInspections && deps.leases)
|
|
176
|
+
ingestExecutionInspection(
|
|
177
|
+
{
|
|
178
|
+
executionInspections: deps.executionInspections,
|
|
179
|
+
turnRecords: deps.turnRecords,
|
|
180
|
+
leases: deps.leases,
|
|
181
|
+
},
|
|
182
|
+
{ instanceId, workerId, turnRecordId: suppliedTurnRecordId, capture: data.capture },
|
|
183
|
+
);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
174
186
|
if (payload.eventType === "turn.progress") {
|
|
175
187
|
const reportedTurnRecordId = readWsEventNonEmptyString(data.turnRecordId);
|
|
176
188
|
if (!reportedTurnRecordId || reportedTurnRecordId !== currentTurnRecordId) return;
|
|
@@ -192,7 +204,7 @@ export function createWorkerEventIngestor(deps: WorkerEventIngestorDeps) {
|
|
|
192
204
|
return;
|
|
193
205
|
}
|
|
194
206
|
const projection = getLiveTurnProjection(instanceId, currentTurnRecordId);
|
|
195
|
-
const appliedProjectionEvent =
|
|
207
|
+
const appliedProjectionEvent = projection.apply({
|
|
196
208
|
eventType: payload.eventType,
|
|
197
209
|
data,
|
|
198
210
|
fallbackTimestamp: new Date().toISOString(),
|
|
@@ -200,7 +212,11 @@ export function createWorkerEventIngestor(deps: WorkerEventIngestorDeps) {
|
|
|
200
212
|
const projectionData = appliedProjectionEvent.canonicalData;
|
|
201
213
|
const enrichedData: Record<string, unknown> =
|
|
202
214
|
currentTurnRecordId && !readWsEventNonEmptyString(projectionData.turnRecordId)
|
|
203
|
-
? {
|
|
215
|
+
? {
|
|
216
|
+
...projectionData,
|
|
217
|
+
turnRecordId: currentTurnRecordId,
|
|
218
|
+
workerLeaseId: deps.leases?.getByInstance(instanceId)?.id ?? null,
|
|
219
|
+
}
|
|
204
220
|
: projectionData;
|
|
205
221
|
const currentSelectedTurnId = payload.selectedTurnId ?? process.selectedTurnId ?? null;
|
|
206
222
|
const normalizedTimestamp = eventTimestamp(enrichedData);
|
|
@@ -263,7 +279,7 @@ export function createWorkerEventIngestor(deps: WorkerEventIngestorDeps) {
|
|
|
263
279
|
);
|
|
264
280
|
}
|
|
265
281
|
} else if (payload.eventType === "pi.usage") {
|
|
266
|
-
const usage =
|
|
282
|
+
const usage = appliedProjectionEvent.usage;
|
|
267
283
|
if (usage) {
|
|
268
284
|
deps.broadcaster.broadcast(
|
|
269
285
|
createEphemeralWsFrame({
|
|
@@ -285,6 +285,22 @@ export function createWorkerStartPayloadBuilder(deps: WorkerStartPayloadBuilderD
|
|
|
285
285
|
function buildWorkerRuntimeContextSnapshot(process: ProcessInstance, start: TurnStartRecord) {
|
|
286
286
|
const turnResultMarkdownBySemanticRef = buildTurnResultMarkdownBySemanticRef(process, deps);
|
|
287
287
|
const turnResultMarkdownByProduct = buildTurnResultMarkdownByProduct(process, deps);
|
|
288
|
+
const productRefs = parseProductRefsFromStateJsonLenient(process.stateJson);
|
|
289
|
+
const inspectionProducts = Object.entries(turnResultMarkdownByProduct ?? {}).flatMap(
|
|
290
|
+
([name, content]) => {
|
|
291
|
+
const ref = productRefs[name];
|
|
292
|
+
return ref?.turnRecordId
|
|
293
|
+
? [
|
|
294
|
+
{
|
|
295
|
+
name,
|
|
296
|
+
producerTurnRecordId: ref.turnRecordId,
|
|
297
|
+
entryId: ref.entryId,
|
|
298
|
+
content: { state: "recorded" as const, value: content },
|
|
299
|
+
},
|
|
300
|
+
]
|
|
301
|
+
: [];
|
|
302
|
+
},
|
|
303
|
+
);
|
|
288
304
|
const prepared =
|
|
289
305
|
start.state.kind === "starting" ||
|
|
290
306
|
start.state.kind === "accepted" ||
|
|
@@ -302,6 +318,7 @@ export function createWorkerStartPayloadBuilder(deps: WorkerStartPayloadBuilderD
|
|
|
302
318
|
projectSnapshots: buildProjectSnapshots(process.id),
|
|
303
319
|
...(turnResultMarkdownBySemanticRef ? { turnResultMarkdownBySemanticRef } : {}),
|
|
304
320
|
...(turnResultMarkdownByProduct ? { turnResultMarkdownByProduct } : {}),
|
|
321
|
+
inspectionProducts,
|
|
305
322
|
};
|
|
306
323
|
}
|
|
307
324
|
|
|
@@ -82,6 +82,8 @@ export interface SupervisorDeps
|
|
|
82
82
|
/** @internal */
|
|
83
83
|
startupObservations?: RepositoryBundle["startupObservations"];
|
|
84
84
|
/** @internal */
|
|
85
|
+
executionInspections?: RepositoryBundle["executionInspections"];
|
|
86
|
+
/** @internal */
|
|
85
87
|
mappedRuns?: RepositoryBundle["mappedRuns"];
|
|
86
88
|
/** @internal */
|
|
87
89
|
config: LeitwerkConfig;
|
|
@@ -639,7 +641,29 @@ export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
|
639
641
|
pendingCleanup.delete(instanceId);
|
|
640
642
|
const leaseBeforeExit = safeGetLeaseByInstance(instanceId);
|
|
641
643
|
const startupTimedOut = startupTimedOutWorkers.delete(timedOutWorkerKey(instanceId, workerId));
|
|
642
|
-
|
|
644
|
+
// Graceful runtime termination may report cleanup before the exit arrives.
|
|
645
|
+
// Cleanup alone does not complete an accepted turn's durable outcome.
|
|
646
|
+
const processBeforeExit = safeGetProcessById(instanceId);
|
|
647
|
+
const startBeforeExit =
|
|
648
|
+
processBeforeExit?.currentExecution?.kind === "worker_start"
|
|
649
|
+
? deps.turnStarts.getById(processBeforeExit.currentExecution.id)
|
|
650
|
+
: null;
|
|
651
|
+
const acceptedTurnBeforeExit =
|
|
652
|
+
startBeforeExit?.state.kind === "accepted"
|
|
653
|
+
? deps.turnRecords.getById(startBeforeExit.state.turnRecordId)
|
|
654
|
+
: null;
|
|
655
|
+
const unfinishedOwningTurn =
|
|
656
|
+
leaseBeforeExit?.workerId === workerId &&
|
|
657
|
+
["draining", "cleanup"].includes(leaseBeforeExit.state) &&
|
|
658
|
+
processBeforeExit?.lifecycleStatus === "active" &&
|
|
659
|
+
startBeforeExit?.state.kind === "accepted" &&
|
|
660
|
+
startBeforeExit.state.acceptedWorkerLeaseId === leaseBeforeExit.id &&
|
|
661
|
+
startBeforeExit.instanceId === instanceId &&
|
|
662
|
+
acceptedTurnBeforeExit?.instanceId === instanceId &&
|
|
663
|
+
acceptedTurnBeforeExit.turnStartRecordId === startBeforeExit.id &&
|
|
664
|
+
acceptedTurnBeforeExit.acceptedWorkerLeaseId === leaseBeforeExit.id &&
|
|
665
|
+
acceptedTurnBeforeExit.status === "running";
|
|
666
|
+
if (isLiveWorkerLease(leaseBeforeExit, workerId) || unfinishedOwningTurn) {
|
|
643
667
|
const diagnostics = formatWorkerExitDiagnostics(info);
|
|
644
668
|
emitServerObservedWorkerFailure(instanceId, workerId, {
|
|
645
669
|
errorCode: startupTimedOut
|
|
@@ -717,6 +741,7 @@ export function createWorkerSupervisor(deps: SupervisorDeps): WorkerSupervisor {
|
|
|
717
741
|
config: deps.config,
|
|
718
742
|
processId: process.processId,
|
|
719
743
|
componentKeys: deps.projects.listByInstance(process.id).map((project) => project.key),
|
|
744
|
+
docker: deps.processGraphs.get(process.processId)?.runtime?.docker === true,
|
|
720
745
|
}),
|
|
721
746
|
);
|
|
722
747
|
if (!selection.ok) {
|
|
@@ -46,6 +46,7 @@ export async function prepareAcceptedFixtureStart(
|
|
|
46
46
|
const result = await prepareCreatedTurnStarts(
|
|
47
47
|
{
|
|
48
48
|
config: ctx.config,
|
|
49
|
+
processModelPolicy: ctx.deps.processModelPolicy,
|
|
49
50
|
registry: ctx.modelProviderRegistry,
|
|
50
51
|
modelStatusCache: ctx.modelStatusCache,
|
|
51
52
|
piContributions: contributions,
|
|
@@ -114,6 +114,7 @@ export function createModelAvailabilitySnapshot(
|
|
|
114
114
|
|
|
115
115
|
export function createTestModelPolicy(
|
|
116
116
|
input: {
|
|
117
|
+
defaultProfileId?: string;
|
|
117
118
|
profiles?: readonly {
|
|
118
119
|
id: string;
|
|
119
120
|
model_id?: string;
|
|
@@ -132,6 +133,7 @@ export function createTestModelPolicy(
|
|
|
132
133
|
processActionRegistry: { getTurnDefinition: () => ReturnType<typeof createTestLlmTurn> };
|
|
133
134
|
} {
|
|
134
135
|
const config = getDefaultConfig();
|
|
136
|
+
config.pi.default_model_profile = input.defaultProfileId ?? "first";
|
|
135
137
|
config.pi.model_profiles = (
|
|
136
138
|
input.profiles ?? [
|
|
137
139
|
{ id: "first", model_id: "one" },
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { ExtensionCatalog } from "@leitwerk-dev/extension-runtime";
|
|
2
|
+
import { buildExtensionCatalogFromModules } from "@leitwerk-dev/extension-runtime/testing";
|
|
3
|
+
import type { LeitwerkExtensionModule, SettingDefinition } from "@leitwerk-dev/process-sdk";
|
|
4
|
+
import { getDefaultConfig } from "../config/config-loader.js";
|
|
5
|
+
import { createAllRepos } from "../db/repositories.js";
|
|
6
|
+
import { buildProcessActionRegistry } from "../process-action-registry.js";
|
|
7
|
+
import { createServerProcessModelPolicy } from "../process-model-policy/index.js";
|
|
8
|
+
import { createScopedSettingsService } from "../scoped-settings-service.js";
|
|
9
|
+
import { createOwnedInMemoryDatabase } from "./owned-test-deps.js";
|
|
10
|
+
import {
|
|
11
|
+
createFixtureHumanTurn,
|
|
12
|
+
createFixtureLlmTurn,
|
|
13
|
+
createFixtureProcess,
|
|
14
|
+
} from "./process-fixtures.js";
|
|
15
|
+
|
|
16
|
+
export const reportLabel: SettingDefinition<string> = {
|
|
17
|
+
key: "settings-test.report_label",
|
|
18
|
+
schemaVersion: 1,
|
|
19
|
+
defaultValue: "Default report",
|
|
20
|
+
scopes: [
|
|
21
|
+
"instance",
|
|
22
|
+
"settings-test.issue-type",
|
|
23
|
+
"settings-test.project",
|
|
24
|
+
"settings-test.project-issue-type",
|
|
25
|
+
],
|
|
26
|
+
merge: "replace",
|
|
27
|
+
schema: {
|
|
28
|
+
parse(value) {
|
|
29
|
+
if (typeof value !== "string") throw new Error("Expected text");
|
|
30
|
+
return value;
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
form: { label: "Report label", control: "textarea", group: "Planning" },
|
|
34
|
+
};
|
|
35
|
+
export const repositoryLabel: SettingDefinition<string> = {
|
|
36
|
+
...reportLabel,
|
|
37
|
+
key: "settings-test.repository_label",
|
|
38
|
+
scopes: ["instance", "repository"],
|
|
39
|
+
};
|
|
40
|
+
export const model: SettingDefinition<string | null> = {
|
|
41
|
+
key: "settings-test.model",
|
|
42
|
+
schemaVersion: 1,
|
|
43
|
+
defaultValue: null,
|
|
44
|
+
scopes: ["instance", "repository"],
|
|
45
|
+
merge: "replace",
|
|
46
|
+
schema: {
|
|
47
|
+
parse(value) {
|
|
48
|
+
if (value === null || typeof value === "string") return value;
|
|
49
|
+
throw new Error("Expected a model profile");
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
form: { label: "Planning model", control: "model", group: "Planning" },
|
|
53
|
+
};
|
|
54
|
+
const process = createFixtureProcess({
|
|
55
|
+
id: "settings_process",
|
|
56
|
+
entry: "run",
|
|
57
|
+
turns: {
|
|
58
|
+
run: createFixtureLlmTurn("Plan", { executionPurpose: "settings-test.planning" }),
|
|
59
|
+
review: createFixtureHumanTurn({
|
|
60
|
+
actions: { proceed: { label: "Proceed", acceptanceState: "accepted", to: "run" } },
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
export const settingsExtension: LeitwerkExtensionModule = {
|
|
65
|
+
manifest: { id: "settings-test", version: "1" },
|
|
66
|
+
scopedSettings: {
|
|
67
|
+
scopes: [
|
|
68
|
+
{ id: "settings-test.issue-type", label: "Issue type" },
|
|
69
|
+
{ id: "settings-test.project", label: "Project" },
|
|
70
|
+
{ id: "settings-test.project-issue-type", label: "Project + issue type" },
|
|
71
|
+
],
|
|
72
|
+
settings: [reportLabel, repositoryLabel, model],
|
|
73
|
+
purposes: [
|
|
74
|
+
{
|
|
75
|
+
id: "settings-test.planning",
|
|
76
|
+
label: "Planning",
|
|
77
|
+
modelSettingKey: model.key,
|
|
78
|
+
settingKeys: [reportLabel.key, repositoryLabel.key],
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
setupCatalog(api) {
|
|
83
|
+
api.registerProcess(process);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export function createSettingsProcess(repos: ReturnType<typeof createAllRepos>, keys: string[]) {
|
|
88
|
+
const process = repos.processes.create({ processId: "settings_process", selectedTurnId: "run" });
|
|
89
|
+
for (const key of keys)
|
|
90
|
+
repos.projects.create({
|
|
91
|
+
instanceId: process.id,
|
|
92
|
+
key,
|
|
93
|
+
repoLocator: `/workspace/${key}`,
|
|
94
|
+
baseBranch: "main",
|
|
95
|
+
});
|
|
96
|
+
return process;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export async function createSettingsFixture(
|
|
100
|
+
repos = createAllRepos(createOwnedInMemoryDatabase()),
|
|
101
|
+
modules = [settingsExtension],
|
|
102
|
+
) {
|
|
103
|
+
const catalog: ExtensionCatalog = await buildExtensionCatalogFromModules(modules);
|
|
104
|
+
const config = getDefaultConfig();
|
|
105
|
+
config.pi.default_model_profile = "first";
|
|
106
|
+
config.pi.model_profiles = [
|
|
107
|
+
{ id: "first", provider: "test", model_id: "one" },
|
|
108
|
+
{ id: "second", provider: "test", model_id: "two" },
|
|
109
|
+
];
|
|
110
|
+
config.process_configs = modules.length
|
|
111
|
+
? {
|
|
112
|
+
settings_process: {
|
|
113
|
+
default_model_profile: "first",
|
|
114
|
+
turn_configs: { run: { model_profile: "first" } },
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
: {};
|
|
118
|
+
const settings = createScopedSettingsService({ repos, catalog, config });
|
|
119
|
+
const policy = createServerProcessModelPolicy({
|
|
120
|
+
config,
|
|
121
|
+
processGraphs: catalog.processes,
|
|
122
|
+
processActionRegistry: buildProcessActionRegistry(catalog),
|
|
123
|
+
scopedSettings: settings,
|
|
124
|
+
});
|
|
125
|
+
return { repos, catalog, config, settings, policy };
|
|
126
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createCanonicalPiResourceBundle } from "@leitwerk-dev/worker-protocol";
|
|
2
|
+
import type { RepositoryBundle } from "../db/repositories.js";
|
|
3
|
+
|
|
4
|
+
/** Installs a synthetic catalog skill using the operator registration path. @internal */
|
|
5
|
+
export function installTestSkill(
|
|
6
|
+
repos: Pick<RepositoryBundle, "skills">,
|
|
7
|
+
id: string,
|
|
8
|
+
content = "Synthetic skill instructions.",
|
|
9
|
+
) {
|
|
10
|
+
const repositoryId = `test-${id}`;
|
|
11
|
+
repos.skills.mergeCatalog(repositoryId, [
|
|
12
|
+
{
|
|
13
|
+
skillId: id,
|
|
14
|
+
label: id,
|
|
15
|
+
description: "Synthetic skill",
|
|
16
|
+
sourcePath: `skills/${id}`,
|
|
17
|
+
sourceRevision: null,
|
|
18
|
+
bundle: createCanonicalPiResourceBundle([
|
|
19
|
+
{
|
|
20
|
+
path: `skills/${id}/SKILL.md`,
|
|
21
|
+
content: Buffer.from(`---\nname: ${id}\ndescription: Synthetic skill\n---\n${content}\n`),
|
|
22
|
+
},
|
|
23
|
+
]),
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
26
|
+
repos.skills.registerCatalogEntry(repositoryId, id);
|
|
27
|
+
return repos.skills.resolveActive([id]);
|
|
28
|
+
}
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
} from "@leitwerk-dev/domain";
|
|
6
6
|
import type { RepositoryBundle } from "./db/repositories.js";
|
|
7
7
|
import type { ProcessOperationCoordinator } from "./process-operation-coordinator.js";
|
|
8
|
+
import type { Broadcaster } from "./ws/broadcast.js";
|
|
8
9
|
|
|
9
10
|
/** @internal */
|
|
10
11
|
export type ToolApprovalDecision =
|
|
@@ -62,8 +63,20 @@ export function createToolApprovalGate(input: {
|
|
|
62
63
|
repos: ToolApprovalRepos;
|
|
63
64
|
/** @internal */
|
|
64
65
|
processOperations: ProcessOperationCoordinator;
|
|
66
|
+
/** @internal */
|
|
67
|
+
broadcaster: Pick<Broadcaster, "sendDurable">;
|
|
65
68
|
}) {
|
|
66
69
|
const waiters = new Map<string, Set<(decision: ToolApprovalDecision) => void>>();
|
|
70
|
+
const notify = (instanceId: string) =>
|
|
71
|
+
input.broadcaster.sendDurable(
|
|
72
|
+
"process.event",
|
|
73
|
+
{
|
|
74
|
+
eventType: "tool_approval_updated",
|
|
75
|
+
level: "info",
|
|
76
|
+
message: "Issue approval updated",
|
|
77
|
+
},
|
|
78
|
+
instanceId,
|
|
79
|
+
);
|
|
67
80
|
/** @internal */
|
|
68
81
|
function reconcile(instanceId: string): void {
|
|
69
82
|
for (const request of input.repos.toolApprovalRequests.listByInstance(instanceId)) {
|
|
@@ -95,6 +108,7 @@ export function createToolApprovalGate(input: {
|
|
|
95
108
|
const result = input.repos.toolApprovalRequests.createIdempotent(requestInput);
|
|
96
109
|
const decision = resolvedDecision(result.request);
|
|
97
110
|
if (decision) return decision;
|
|
111
|
+
if (result.kind === "created") notify(requestInput.instanceId);
|
|
98
112
|
return await new Promise<ToolApprovalDecision>((resolve) => {
|
|
99
113
|
const pending = waiters.get(result.request.id) ?? new Set();
|
|
100
114
|
pending.add(resolve);
|
|
@@ -130,12 +144,14 @@ export function createToolApprovalGate(input: {
|
|
|
130
144
|
});
|
|
131
145
|
}),
|
|
132
146
|
);
|
|
147
|
+
if (resolved) notify(instanceId);
|
|
133
148
|
reconcile(instanceId);
|
|
134
149
|
return resolved;
|
|
135
150
|
},
|
|
136
151
|
/** @internal */
|
|
137
152
|
cancelTurn(instanceId: string, turnRecordId: string): number {
|
|
138
153
|
const changed = input.repos.toolApprovalRequests.cancelOpenByTurn(instanceId, turnRecordId);
|
|
154
|
+
if (changed) notify(instanceId);
|
|
139
155
|
reconcile(instanceId);
|
|
140
156
|
return changed;
|
|
141
157
|
},
|
package/src/turn-progress.ts
CHANGED
|
@@ -60,6 +60,7 @@ export function normalizeTurnProgressReport(value: unknown): TurnProgressReport
|
|
|
60
60
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
61
61
|
const raw = value as Record<string, unknown>;
|
|
62
62
|
const title = text(raw.title, 160);
|
|
63
|
+
const summary = text(raw.summary, 2000);
|
|
63
64
|
if (!title || !Array.isArray(raw.steps) || raw.steps.length > 50) return null;
|
|
64
65
|
const ids = new Set<string>();
|
|
65
66
|
const steps = raw.steps.flatMap((value) => {
|
|
@@ -81,13 +82,13 @@ export function normalizeTurnProgressReport(value: unknown): TurnProgressReport
|
|
|
81
82
|
},
|
|
82
83
|
];
|
|
83
84
|
});
|
|
84
|
-
if (steps.length !== raw.steps.length || steps.length === 0) return null;
|
|
85
|
+
if (steps.length !== raw.steps.length || (steps.length === 0 && !summary)) return null;
|
|
85
86
|
const links = normalizeTurnProgressLinks(raw.links);
|
|
86
87
|
if (!links) return null;
|
|
87
88
|
return {
|
|
88
89
|
title,
|
|
89
90
|
steps,
|
|
90
|
-
...(
|
|
91
|
+
...(summary ? { summary } : {}),
|
|
91
92
|
...(links.length > 0 ? { links } : {}),
|
|
92
93
|
};
|
|
93
94
|
}
|