@leitwerk-dev/server 0.3.1 → 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-BuJCdkvy.d.ts → app-CsuxFZT5.d.ts} +262 -121
- 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-QCHS3X33.js → chunk-FPMDWQF7.js} +2617 -562
- package/dist/chunk-FPMDWQF7.js.map +1 -0
- package/dist/{chunk-HK6BLLHA.js → chunk-MBHRCQFE.js} +2303 -1576
- 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/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 +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 +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.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/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 +5 -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-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-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/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 +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.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 +115 -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 +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 +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 +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 +8 -2
- 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 -193
- 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 +11 -2
- package/src/process-engine/mapped-turns.ts +5 -7
- 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 +9 -13
- 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 +21 -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 +9 -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 +15 -2
- 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-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/future-executions.ts +5 -5
- package/src/routes/launchers.ts +51 -1
- package/src/routes/process-actions.ts +9 -9
- 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 +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 +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 +3 -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/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-JM4CBTND.js.map} +0 -0
|
@@ -131,6 +131,7 @@ export async function projectFutureExecutionModelState(
|
|
|
131
131
|
policy: deps.policy,
|
|
132
132
|
availability: deps.availability,
|
|
133
133
|
detectedAt: now().toISOString(),
|
|
134
|
+
existingBlockedReason: execution.blockedReason,
|
|
134
135
|
});
|
|
135
136
|
}
|
|
136
137
|
if (!execution.instanceId || !execution.actionId) return null;
|
|
@@ -159,6 +160,7 @@ export async function projectFutureExecutionModelState(
|
|
|
159
160
|
overrideModelProfileId: parsed.value.nextTurnModelProfileId,
|
|
160
161
|
overrideProvided: parsed.value.nextTurnModelProfileId !== null,
|
|
161
162
|
detectedAt: now().toISOString(),
|
|
163
|
+
existingBlockedReason: execution.blockedReason,
|
|
162
164
|
});
|
|
163
165
|
}
|
|
164
166
|
|
|
@@ -6,6 +6,7 @@ import type { ProcessActionRegistry } from "../process-action-registry.js";
|
|
|
6
6
|
import type { ProcessGraphRegistry } from "../process-graph.js";
|
|
7
7
|
import {
|
|
8
8
|
evaluateAtStableAvailabilityRevision,
|
|
9
|
+
isPinnedModelSelection,
|
|
9
10
|
type ServerProcessModelPolicy,
|
|
10
11
|
} from "../process-model-policy/index.js";
|
|
11
12
|
import type { ProcessOperationCoordinator } from "../process-operation-coordinator.js";
|
|
@@ -35,6 +36,7 @@ export async function reconcileFutureExecutionModelBlocks(input: {
|
|
|
35
36
|
availability: ModelStatusCacheSnapshot;
|
|
36
37
|
getModelAvailabilitySnapshot: () => ModelStatusCacheSnapshot;
|
|
37
38
|
profileIds?: ReadonlySet<string>;
|
|
39
|
+
instanceId?: string;
|
|
38
40
|
broadcaster: Broadcaster;
|
|
39
41
|
processTitles?: ProcessTitleGenerator;
|
|
40
42
|
asOf: string;
|
|
@@ -42,6 +44,7 @@ export async function reconcileFutureExecutionModelBlocks(input: {
|
|
|
42
44
|
let changed = 0;
|
|
43
45
|
const effects: PostCommitEffect[] = [];
|
|
44
46
|
for (const candidate of input.futureExecutions.listAll()) {
|
|
47
|
+
if (input.instanceId && candidate.instanceId !== input.instanceId) continue;
|
|
45
48
|
if (
|
|
46
49
|
candidate.modelSelection &&
|
|
47
50
|
input.profileIds &&
|
|
@@ -98,6 +101,10 @@ export async function reconcileFutureExecutionModelBlocks(input: {
|
|
|
98
101
|
if (projected && !sameModelPolicyState(current, projected)) updateCurrent(projected);
|
|
99
102
|
};
|
|
100
103
|
|
|
104
|
+
if (!isPinnedModelSelection(current.modelSelection)) {
|
|
105
|
+
await projectCurrent();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
101
108
|
if (!current.modelSelection) {
|
|
102
109
|
await projectCurrent();
|
|
103
110
|
if (!current.modelSelection) return;
|
|
@@ -144,13 +144,12 @@ export function getScheduledActionDetailForProcess(
|
|
|
144
144
|
actionLabel,
|
|
145
145
|
input: payload.input,
|
|
146
146
|
nextTurnModelProfileId: payload.nextTurnModelProfileId,
|
|
147
|
-
action: buildActionSummaryForProcess(
|
|
148
|
-
deps,
|
|
149
|
-
|
|
150
|
-
action,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
),
|
|
147
|
+
action: buildActionSummaryForProcess(deps, process, {
|
|
148
|
+
...listCurrentVisibleActions(deps, process).find((candidate) => candidate.id === action.id),
|
|
149
|
+
id: action.id,
|
|
150
|
+
form: action.form,
|
|
151
|
+
label: actionLabel.trim() ? actionLabel : action.label,
|
|
152
|
+
supportsScheduling: true,
|
|
153
|
+
}),
|
|
155
154
|
};
|
|
156
155
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Actor, resolveJsonPointer, type TurnProgressReport } from "@leitwerk-dev/domain";
|
|
2
2
|
import {
|
|
3
3
|
bindExternalWrites,
|
|
4
4
|
type ExternalWriteLogRepoLike,
|
|
@@ -34,8 +34,8 @@ type RegisteredIntegrationTool = IntegrationToolDefinition<unknown>;
|
|
|
34
34
|
type TicketCreationTool = RegisteredIntegrationTool & { capability: TicketCreationCapability };
|
|
35
35
|
type IntegrationToolExecutionInput = Omit<
|
|
36
36
|
IntegrationToolExecutionContext,
|
|
37
|
-
"signal" | "externalWrites"
|
|
38
|
-
|
|
37
|
+
"signal" | "externalWrites" | "reportProgress"
|
|
38
|
+
> & { reportProgress?: IntegrationToolExecutionContext["reportProgress"] };
|
|
39
39
|
|
|
40
40
|
interface PendingIntegrationToolExecution {
|
|
41
41
|
readonly controller: AbortController;
|
|
@@ -104,6 +104,7 @@ const ticketCapabilitySchema = v.object({
|
|
|
104
104
|
startTurnId: nonEmptyString,
|
|
105
105
|
titlePath: v.optional(v.string()),
|
|
106
106
|
descriptionPath: v.optional(v.string()),
|
|
107
|
+
descriptionFormat: v.optional(v.picklist(["plain", "markdown"])),
|
|
107
108
|
destinations: v.optional(v.unknown()),
|
|
108
109
|
});
|
|
109
110
|
const destinationSummarySchema = v.pipe(
|
|
@@ -192,18 +193,6 @@ export function validateTicketCreationReceipt(value: unknown): TicketCreationRec
|
|
|
192
193
|
};
|
|
193
194
|
}
|
|
194
195
|
|
|
195
|
-
function resolveJsonPointer(value: unknown, pointer: string): unknown {
|
|
196
|
-
if (pointer === "") return value;
|
|
197
|
-
return pointer
|
|
198
|
-
.slice(1)
|
|
199
|
-
.split("/")
|
|
200
|
-
.reduce<unknown>((current, token) => {
|
|
201
|
-
if (!current || typeof current !== "object") return undefined;
|
|
202
|
-
const key = token.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
203
|
-
return (current as Record<string, unknown>)[key];
|
|
204
|
-
}, value);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
196
|
const parseToolArgs = (value: unknown) =>
|
|
208
197
|
objectArg(value, "Integration tool arguments must be an object");
|
|
209
198
|
|
|
@@ -357,6 +346,7 @@ export class IntegrationToolRegistry {
|
|
|
357
346
|
if (!definition) throw new Error(`Unknown integration tool '${name}'`);
|
|
358
347
|
return {
|
|
359
348
|
name: definition.name,
|
|
349
|
+
...(definition.modelVisible === false ? { modelVisible: false } : {}),
|
|
360
350
|
description: definition.description,
|
|
361
351
|
parameters:
|
|
362
352
|
definition.capability?.kind === "ticket_creation" && definition.capability.destinations
|
|
@@ -380,6 +370,9 @@ export class IntegrationToolRegistry {
|
|
|
380
370
|
return definition.execute(
|
|
381
371
|
{
|
|
382
372
|
...ctx,
|
|
373
|
+
reportProgress: (report) => {
|
|
374
|
+
if (!controller.signal.aborted) ctx.reportProgress?.(report);
|
|
375
|
+
},
|
|
383
376
|
signal: controller.signal,
|
|
384
377
|
externalWrites: bindExternalWrites(this.writes, ctx.process.id),
|
|
385
378
|
},
|
|
@@ -391,6 +384,30 @@ export class IntegrationToolRegistry {
|
|
|
391
384
|
return promise;
|
|
392
385
|
}
|
|
393
386
|
|
|
387
|
+
/** Only trusted server extensions use this path; approval-gated ticket tools require worker IPC. */
|
|
388
|
+
executeServer(
|
|
389
|
+
name: string,
|
|
390
|
+
args: unknown,
|
|
391
|
+
ctx: IntegrationToolExecutionInput,
|
|
392
|
+
signal: AbortSignal,
|
|
393
|
+
): Promise<unknown> {
|
|
394
|
+
const definition = this.tools.get(name);
|
|
395
|
+
if (!definition || definition.capability)
|
|
396
|
+
throw new Error(`Tool '${name}' is unavailable to server maintenance`);
|
|
397
|
+
signal.throwIfAborted();
|
|
398
|
+
return definition.execute(
|
|
399
|
+
{
|
|
400
|
+
...ctx,
|
|
401
|
+
signal,
|
|
402
|
+
reportProgress: (report) => {
|
|
403
|
+
if (!signal.aborted) ctx.reportProgress?.(report);
|
|
404
|
+
},
|
|
405
|
+
externalWrites: bindExternalWrites(this.writes, ctx.process.id),
|
|
406
|
+
},
|
|
407
|
+
definition.parse?.(args) ?? parseToolArgs(args),
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
|
|
394
411
|
cancel(idempotencyKey: string): boolean {
|
|
395
412
|
const execution = this.executions.get(idempotencyKey);
|
|
396
413
|
if (!execution) return false;
|
|
@@ -413,6 +430,11 @@ export function createIntegrationToolRequestService(input: {
|
|
|
413
430
|
repos: Pick<RepositoryBundle, "processes" | "projects" | "turnRecords" | "turnStarts">;
|
|
414
431
|
processActionRegistry: Pick<ProcessActionRegistry, "getTurnDefinition" | "resolveContextData">;
|
|
415
432
|
toolApprovalGate?: ToolApprovalGate;
|
|
433
|
+
reportProgress?: (input: {
|
|
434
|
+
instanceId: string;
|
|
435
|
+
turnRecordId: string;
|
|
436
|
+
report: TurnProgressReport;
|
|
437
|
+
}) => void;
|
|
416
438
|
}) {
|
|
417
439
|
const pending = new Map<
|
|
418
440
|
string,
|
|
@@ -453,22 +475,26 @@ export function createIntegrationToolRequestService(input: {
|
|
|
453
475
|
if (process.selectedTurnId !== turn.turnId) {
|
|
454
476
|
return fail("Integration tool call targets a stale turn");
|
|
455
477
|
}
|
|
456
|
-
const
|
|
457
|
-
if (signal.aborted)
|
|
478
|
+
const isActive = () => {
|
|
479
|
+
if (signal.aborted) return false;
|
|
458
480
|
const current = input.repos.processes.getById(instanceId);
|
|
459
481
|
const currentTurn = input.repos.turnRecords.getById(payload.turnRecordId);
|
|
460
482
|
const start =
|
|
461
483
|
current?.currentExecution?.kind === "worker_start"
|
|
462
484
|
? input.repos.turnStarts.getById(current.currentExecution.id)
|
|
463
485
|
: null;
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
486
|
+
return Boolean(
|
|
487
|
+
current &&
|
|
488
|
+
currentTurn?.status === "running" &&
|
|
489
|
+
currentTurn.instanceId === instanceId &&
|
|
490
|
+
current.selectedTurnId === turn.turnId &&
|
|
491
|
+
start?.state.kind === "accepted" &&
|
|
492
|
+
start.state.turnRecordId === payload.turnRecordId,
|
|
493
|
+
);
|
|
494
|
+
};
|
|
495
|
+
const assertActive = () => {
|
|
496
|
+
if (signal.aborted) throw new Error("Integration tool execution cancelled");
|
|
497
|
+
if (!isActive()) throw new Error("Integration tool call targets a stale turn record");
|
|
472
498
|
};
|
|
473
499
|
const authorizedTools = resolveTurnIntegrationToolNames(
|
|
474
500
|
input.processActionRegistry,
|
|
@@ -484,7 +510,10 @@ export function createIntegrationToolRequestService(input: {
|
|
|
484
510
|
const project = projectKey
|
|
485
511
|
? (projects.find((candidate) => candidate.key === projectKey) ?? null)
|
|
486
512
|
: null;
|
|
487
|
-
if (projectKey && !project)
|
|
513
|
+
if (projectKey && !project)
|
|
514
|
+
return fail(
|
|
515
|
+
`Unknown process project '${projectKey}'. Available project keys: ${projects.map((candidate) => candidate.key).join(", ") || "(none)"}`,
|
|
516
|
+
);
|
|
488
517
|
try {
|
|
489
518
|
let ticketDestination: TicketCreationDestinationSnapshot | undefined;
|
|
490
519
|
let executionArgs = payload.args;
|
|
@@ -545,6 +574,10 @@ export function createIntegrationToolRequestService(input: {
|
|
|
545
574
|
projects,
|
|
546
575
|
turn,
|
|
547
576
|
project,
|
|
577
|
+
reportProgress: (report) => {
|
|
578
|
+
if (isActive())
|
|
579
|
+
input.reportProgress?.({ instanceId, turnRecordId: payload.turnRecordId, report });
|
|
580
|
+
},
|
|
548
581
|
...(ticketDestination ? { ticketDestination } : {}),
|
|
549
582
|
idempotencyKey: integrationToolIdempotencyKey({
|
|
550
583
|
instanceId,
|
|
@@ -629,9 +629,18 @@ export function createLaunchCoordinator(deps: LaunchCoordinatorDeps): LaunchCoor
|
|
|
629
629
|
return bindLaunchPreparationChecks(attempt.preparationChecks, attempt.launchConfig);
|
|
630
630
|
},
|
|
631
631
|
async prepare(attempt) {
|
|
632
|
+
const eventProfile = attempt.launchConfig.defaultModelProfileId;
|
|
632
633
|
const prepared = await deps.launchPlans.prepare(
|
|
633
634
|
withWatcherHandoffDedupKey(attempt.launchPlan, admissionKey),
|
|
634
|
-
{
|
|
635
|
+
{
|
|
636
|
+
modelConfig: {
|
|
637
|
+
...watcher.launchModelConfig,
|
|
638
|
+
defaultModelProfileId:
|
|
639
|
+
eventProfile ?? watcher.launchModelConfig.defaultModelProfileId,
|
|
640
|
+
},
|
|
641
|
+
// Event selections express ticket/user intent. Never silently drop them.
|
|
642
|
+
invalidModelConfig: eventProfile ? "reject" : "omit",
|
|
643
|
+
},
|
|
635
644
|
);
|
|
636
645
|
return prepared.ok
|
|
637
646
|
? { ok: true as const, value: prepared.launchPlan }
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from "./process-model-policy-presenter.js";
|
|
15
15
|
|
|
16
16
|
type LauncherModelConfigDeps = {
|
|
17
|
+
scopedSettingsService?: import("./scoped-settings-service.js").ScopedSettingsService;
|
|
17
18
|
launcherService: ProcessLauncherService;
|
|
18
19
|
launchPlans: ProcessLaunchPlanServiceLike;
|
|
19
20
|
/** Server construction always supplies the authoritative model policy and availability view. */
|
|
@@ -39,15 +40,27 @@ function projectLauncherPreview(
|
|
|
39
40
|
input: LauncherModelConfigDeps,
|
|
40
41
|
processId: string,
|
|
41
42
|
modelConfig: LaunchModelConfigInputLike,
|
|
43
|
+
plan?: import("@leitwerk-dev/process-sdk").ProcessLaunchPlan,
|
|
42
44
|
) {
|
|
43
|
-
|
|
45
|
+
const preview = presentLauncherModelConfigPreview(
|
|
44
46
|
input.processModelPolicy.project({
|
|
45
47
|
kind: "launcher_preview",
|
|
48
|
+
plan,
|
|
46
49
|
processId,
|
|
47
50
|
modelConfig: modelConfig,
|
|
48
51
|
availability: input.modelStatusCache.snapshot(),
|
|
49
52
|
}),
|
|
50
53
|
);
|
|
54
|
+
const context = plan ? input.scopedSettingsService?.forLaunch(plan) : undefined;
|
|
55
|
+
return {
|
|
56
|
+
...preview,
|
|
57
|
+
...(context
|
|
58
|
+
? {
|
|
59
|
+
settingsSubjectId: context.context.repository ?? "instance",
|
|
60
|
+
settingsExplanations: context.explanations,
|
|
61
|
+
}
|
|
62
|
+
: {}),
|
|
63
|
+
};
|
|
51
64
|
}
|
|
52
65
|
|
|
53
66
|
export type LauncherModelConfigPreviewResult =
|
|
@@ -76,7 +89,10 @@ export async function buildLauncherModelConfigPreviewForLauncher(
|
|
|
76
89
|
let modelConfig = input.modelConfig;
|
|
77
90
|
let resolved: Awaited<ReturnType<ProcessLauncherService["resolveUiLauncher"]>> | null = null;
|
|
78
91
|
try {
|
|
79
|
-
resolved = await input.launcherService.
|
|
92
|
+
resolved = await input.launcherService.resolveUiLauncherPreview(
|
|
93
|
+
input.launcherId,
|
|
94
|
+
input.launcherInput,
|
|
95
|
+
);
|
|
80
96
|
} catch (error) {
|
|
81
97
|
if (!input.ignoreResolveErrors) throw error;
|
|
82
98
|
}
|
|
@@ -97,7 +113,12 @@ export async function buildLauncherModelConfigPreviewForLauncher(
|
|
|
97
113
|
return {
|
|
98
114
|
ok: true,
|
|
99
115
|
launcher,
|
|
100
|
-
preview: projectLauncherPreview(
|
|
116
|
+
preview: projectLauncherPreview(
|
|
117
|
+
input,
|
|
118
|
+
launcher.processId,
|
|
119
|
+
modelConfig,
|
|
120
|
+
resolved?.ok ? resolved.launcher.launchPlan : undefined,
|
|
121
|
+
),
|
|
101
122
|
};
|
|
102
123
|
}
|
|
103
124
|
|
|
@@ -55,6 +55,7 @@ export interface CaptureLeafOutcomeSnapshotOptions {
|
|
|
55
55
|
turnRecordId: string | null;
|
|
56
56
|
};
|
|
57
57
|
turnRecord: ProcessTurnRecord | null;
|
|
58
|
+
mappedResult?: unknown;
|
|
58
59
|
anchoredAt: string;
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -88,6 +89,7 @@ export async function captureLeafOutcomeSnapshot(
|
|
|
88
89
|
turnRecordId: options.leaf.turnRecordId,
|
|
89
90
|
},
|
|
90
91
|
turnRecord: options.turnRecord,
|
|
92
|
+
mappedResult: options.mappedResult,
|
|
91
93
|
readTreeEntry,
|
|
92
94
|
readLeafEntry,
|
|
93
95
|
readTurnRecord(turnRecordId: string) {
|
|
@@ -12,12 +12,11 @@ import { parseProcessStateJsonLenient } from "@leitwerk-dev/domain";
|
|
|
12
12
|
import { parseStructuralProcessState } from "@leitwerk-dev/process-sdk";
|
|
13
13
|
import {
|
|
14
14
|
asWsEventPayloadRecord,
|
|
15
|
-
|
|
15
|
+
createLiveTurnProjection,
|
|
16
16
|
type PrimaryPathActiveTurnSnapshot,
|
|
17
17
|
type PrimaryPathEntrySnapshot,
|
|
18
18
|
type PrimaryPathSnapshot,
|
|
19
19
|
readWsEventTurnRecordId,
|
|
20
|
-
snapshotLiveTurnProjection,
|
|
21
20
|
} from "@leitwerk-dev/protocol";
|
|
22
21
|
import type { ParsedInstanceTree } from "./instance-tree.js";
|
|
23
22
|
|
|
@@ -239,8 +238,8 @@ function buildActiveTurnSnapshot(input: {
|
|
|
239
238
|
}
|
|
240
239
|
return event.createdAt >= currentTurnRecord.startedAt;
|
|
241
240
|
});
|
|
242
|
-
const
|
|
243
|
-
|
|
241
|
+
const { assistant, toolCalls, traceItems, usage } =
|
|
242
|
+
createLiveTurnProjection(activeTurnEvents).rawSnapshot();
|
|
244
243
|
|
|
245
244
|
return {
|
|
246
245
|
turnRecordId: currentTurnRecord.id,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProcessInstance } from "@leitwerk-dev/domain";
|
|
2
|
-
import { type
|
|
2
|
+
import { isLlmTurnDefinition, type TurnDefinition } from "@leitwerk-dev/process-sdk";
|
|
3
3
|
import type {
|
|
4
4
|
ProcessActionPreviewSummary,
|
|
5
5
|
ProcessActionSummary,
|
|
@@ -10,52 +10,41 @@ import {
|
|
|
10
10
|
type ProcessOperatorAttentionDeps,
|
|
11
11
|
} from "./process-operator-attention.js";
|
|
12
12
|
|
|
13
|
-
function actionHasPurePlan(
|
|
14
|
-
deps: Pick<ProcessOperatorAttentionDeps, "processActionRegistry">,
|
|
15
|
-
process: ProcessInstance,
|
|
16
|
-
actionId: string,
|
|
17
|
-
): boolean {
|
|
18
|
-
const action = deps.processActionRegistry?.getAction(process.processId, actionId);
|
|
19
|
-
return typeof action?.plan === "function";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
13
|
/** @internal */
|
|
23
14
|
export function buildActionSummaryForProcess(
|
|
24
15
|
deps: Pick<ProcessOperatorAttentionDeps, "processActionRegistry">,
|
|
25
16
|
process: ProcessInstance,
|
|
26
|
-
action:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
visibleAction?: VisibleProcessActionSummary,
|
|
32
|
-
labelOverride?: string | null,
|
|
33
|
-
overrides: { supportsScheduling?: boolean } = {},
|
|
17
|
+
action: Pick<VisibleProcessActionSummary, "id" | "label" | "form"> &
|
|
18
|
+
Partial<Pick<VisibleProcessActionSummary, "description" | "preview">> & {
|
|
19
|
+
supportsScheduling?: boolean;
|
|
20
|
+
},
|
|
34
21
|
): ProcessActionSummary {
|
|
35
22
|
const actionId = action.id;
|
|
36
23
|
const preview =
|
|
37
|
-
|
|
24
|
+
action.preview ??
|
|
38
25
|
deps.processActionRegistry?.resolveActionPreview(process.processId, process, actionId) ??
|
|
39
26
|
null;
|
|
27
|
+
const hasPurePlan =
|
|
28
|
+
typeof deps.processActionRegistry?.getAction(process.processId, actionId)?.plan === "function";
|
|
29
|
+
const turnDef = preview?.candidateSelectedTurnId
|
|
30
|
+
? deps.processActionRegistry?.getTurnDefinition(
|
|
31
|
+
process.processId,
|
|
32
|
+
preview.candidateSelectedTurnId,
|
|
33
|
+
)
|
|
34
|
+
: undefined;
|
|
40
35
|
const supportsScheduling =
|
|
41
|
-
|
|
36
|
+
action.supportsScheduling ??
|
|
42
37
|
Boolean(
|
|
43
|
-
|
|
38
|
+
hasPurePlan &&
|
|
44
39
|
deps.processActionRegistry?.resolveActionScheduling(process.processId, process, actionId),
|
|
45
40
|
);
|
|
46
|
-
const label = labelOverride ?? visibleAction?.label ?? action.label;
|
|
47
41
|
return {
|
|
48
42
|
id: action.id,
|
|
49
|
-
label:
|
|
50
|
-
description:
|
|
51
|
-
preview: buildProcessActionPreviewSummary(
|
|
43
|
+
label: action.label,
|
|
44
|
+
description: action.description ?? null,
|
|
45
|
+
preview: buildProcessActionPreviewSummary(preview, turnDef),
|
|
52
46
|
supportsScheduling,
|
|
53
|
-
supportsNextTurnModelOverride:
|
|
54
|
-
deps,
|
|
55
|
-
process,
|
|
56
|
-
actionId,
|
|
57
|
-
preview,
|
|
58
|
-
),
|
|
47
|
+
supportsNextTurnModelOverride: Boolean(hasPurePlan && turnDef && isLlmTurnDefinition(turnDef)),
|
|
59
48
|
...(action.form
|
|
60
49
|
? {
|
|
61
50
|
form: {
|
|
@@ -75,17 +64,16 @@ export function listVisibleActionsForProcess(
|
|
|
75
64
|
process: ProcessInstance,
|
|
76
65
|
) {
|
|
77
66
|
return listVisibleAttentionActionsForProcess(deps, process).map((action) =>
|
|
78
|
-
buildActionSummaryForProcess(deps, process, action
|
|
67
|
+
buildActionSummaryForProcess(deps, process, action),
|
|
79
68
|
);
|
|
80
69
|
}
|
|
81
70
|
|
|
82
71
|
function buildProcessActionPreviewSummary(
|
|
83
|
-
deps: Pick<ProcessOperatorAttentionDeps, "processActionRegistry">,
|
|
84
72
|
preview: {
|
|
85
73
|
candidateSelectedTurnId: string | null;
|
|
86
74
|
lifecycleStatus?: string | null;
|
|
87
75
|
} | null,
|
|
88
|
-
|
|
76
|
+
turnDef: TurnDefinition | undefined,
|
|
89
77
|
): ProcessActionPreviewSummary | null {
|
|
90
78
|
if (!preview) {
|
|
91
79
|
return null;
|
|
@@ -98,10 +86,6 @@ function buildProcessActionPreviewSummary(
|
|
|
98
86
|
description: preview.lifecycleStatus === "aborted" ? "Abort process" : "Complete process",
|
|
99
87
|
};
|
|
100
88
|
}
|
|
101
|
-
const turnDef = deps.processActionRegistry?.getTurnDefinition(
|
|
102
|
-
process.processId,
|
|
103
|
-
preview.candidateSelectedTurnId,
|
|
104
|
-
);
|
|
105
89
|
if (!turnDef) {
|
|
106
90
|
return null;
|
|
107
91
|
}
|
|
@@ -112,22 +96,3 @@ function buildProcessActionPreviewSummary(
|
|
|
112
96
|
description: turnDef.description,
|
|
113
97
|
};
|
|
114
98
|
}
|
|
115
|
-
|
|
116
|
-
function previewSupportsNextTurnModelOverride(
|
|
117
|
-
deps: Pick<ProcessOperatorAttentionDeps, "processActionRegistry">,
|
|
118
|
-
process: ProcessInstance,
|
|
119
|
-
actionId: string,
|
|
120
|
-
preview: { candidateSelectedTurnId: string | null } | null,
|
|
121
|
-
): boolean {
|
|
122
|
-
if (!preview?.candidateSelectedTurnId) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
if (!actionHasPurePlan(deps, process, actionId)) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
const turnDef = deps.processActionRegistry?.getTurnDefinition(
|
|
129
|
-
process.processId,
|
|
130
|
-
preview.candidateSelectedTurnId,
|
|
131
|
-
);
|
|
132
|
-
return Boolean(turnDef && isLlmTurnDefinition(turnDef));
|
|
133
|
-
}
|
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
ProcessExternalSourceSummary,
|
|
31
31
|
ProcessSelectedTurnSummary,
|
|
32
32
|
} from "@leitwerk-dev/protocol/http-contracts";
|
|
33
|
+
import { pendingTurnWait } from "./process-engine/turn-wait-state.js";
|
|
33
34
|
|
|
34
35
|
/** @internal */
|
|
35
36
|
export interface ProcessContextData {
|
|
@@ -223,30 +224,6 @@ function listExternalTriggers(
|
|
|
223
224
|
state: unknown;
|
|
224
225
|
},
|
|
225
226
|
): ProcessExternalSourceSummary[] {
|
|
226
|
-
if (isHumanTurnDefinition(turnDef)) {
|
|
227
|
-
const view = resolveHumanTurnView({ turnId, turn: turnDef });
|
|
228
|
-
return [
|
|
229
|
-
...view.externalTriggers.map((trigger) => ({
|
|
230
|
-
id: trigger.id,
|
|
231
|
-
kind: "human_action_external_trigger",
|
|
232
|
-
label: trigger.label,
|
|
233
|
-
description: trigger.description,
|
|
234
|
-
})),
|
|
235
|
-
...view.externalActions
|
|
236
|
-
.filter((action) => {
|
|
237
|
-
const definition = turnDef.externalActions?.[action.externalActionId];
|
|
238
|
-
return !definition?.when || definition.when(ctx);
|
|
239
|
-
})
|
|
240
|
-
.map((action) => ({
|
|
241
|
-
id: action.id,
|
|
242
|
-
externalActionId: action.externalActionId,
|
|
243
|
-
kind: action.sourceKind,
|
|
244
|
-
sourceKind: action.sourceKind,
|
|
245
|
-
label: action.label,
|
|
246
|
-
description: action.description,
|
|
247
|
-
})),
|
|
248
|
-
];
|
|
249
|
-
}
|
|
250
227
|
if (isExternalTurnDefinition(turnDef)) {
|
|
251
228
|
return turnDef.transitions.map((transition, index) => ({
|
|
252
229
|
id: getExternalSourceTransitionId({ turnId, source: transition.source, index }),
|
|
@@ -255,8 +232,23 @@ function listExternalTriggers(
|
|
|
255
232
|
description: transition.source.description ?? null,
|
|
256
233
|
}));
|
|
257
234
|
}
|
|
258
|
-
if (
|
|
259
|
-
|
|
235
|
+
if (
|
|
236
|
+
!isHumanTurnDefinition(turnDef) &&
|
|
237
|
+
(!(isAutomaticTurnDefinition(turnDef) || turnDef.kind === "llm") ||
|
|
238
|
+
ctx.process.lifecycleStatus !== "waiting")
|
|
239
|
+
)
|
|
240
|
+
return [];
|
|
241
|
+
const triggers = isHumanTurnDefinition(turnDef)
|
|
242
|
+
? resolveHumanTurnView({ turnId, turn: turnDef }).externalTriggers.map((trigger) => ({
|
|
243
|
+
id: trigger.id,
|
|
244
|
+
kind: "human_action_external_trigger",
|
|
245
|
+
label: trigger.label,
|
|
246
|
+
description: trigger.description,
|
|
247
|
+
}))
|
|
248
|
+
: [];
|
|
249
|
+
return [
|
|
250
|
+
...triggers,
|
|
251
|
+
...Object.entries(turnDef.externalActions ?? {})
|
|
260
252
|
.filter(([, action]) => !action.when || action.when(ctx))
|
|
261
253
|
.map(([externalActionId, action]) => ({
|
|
262
254
|
id: getExternalActionArmingId({ turnId, externalActionId }),
|
|
@@ -265,9 +257,8 @@ function listExternalTriggers(
|
|
|
265
257
|
sourceKind: action.source.kind,
|
|
266
258
|
label: action.label ?? action.source.label ?? null,
|
|
267
259
|
description: action.description ?? action.source.description ?? null,
|
|
268
|
-
}))
|
|
269
|
-
|
|
270
|
-
return [];
|
|
260
|
+
})),
|
|
261
|
+
];
|
|
271
262
|
}
|
|
272
263
|
|
|
273
264
|
function resolveCurrentVisibleActionForProcess(
|
|
@@ -290,16 +281,8 @@ function isTurnScopedActionForProcess(
|
|
|
290
281
|
if (!processDef) {
|
|
291
282
|
return false;
|
|
292
283
|
}
|
|
293
|
-
for (const
|
|
294
|
-
if (isHumanTurnDefinition(turnDef))
|
|
295
|
-
const view = resolveHumanTurnView({ turnId, turn: turnDef });
|
|
296
|
-
if (
|
|
297
|
-
view.actions.some((action) => action.actionId === actionId) ||
|
|
298
|
-
view.externalTriggers.some((trigger) => trigger.actionId === actionId)
|
|
299
|
-
) {
|
|
300
|
-
return true;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
284
|
+
for (const { definition: turnDef } of processDef.turns.values()) {
|
|
285
|
+
if (isHumanTurnDefinition(turnDef) && Object.hasOwn(turnDef.actions, actionId)) return true;
|
|
303
286
|
}
|
|
304
287
|
return false;
|
|
305
288
|
}
|
|
@@ -314,6 +297,7 @@ function buildSelectedTurnSummaryForProcess(
|
|
|
314
297
|
return null;
|
|
315
298
|
}
|
|
316
299
|
const { params, state } = resolveProcessContextData(processDef, process);
|
|
300
|
+
const wait = pendingTurnWait(process);
|
|
317
301
|
return {
|
|
318
302
|
turnId: currentTurn.turnId,
|
|
319
303
|
kind: currentTurn.turnDef.kind,
|
|
@@ -327,6 +311,14 @@ function buildSelectedTurnSummaryForProcess(
|
|
|
327
311
|
params,
|
|
328
312
|
state,
|
|
329
313
|
}),
|
|
314
|
+
...(wait?.status === "waiting" && process.lifecycleStatus === "waiting"
|
|
315
|
+
? {
|
|
316
|
+
readiness: {
|
|
317
|
+
message: wait.message,
|
|
318
|
+
nextCheckAt: wait.nextCheckAt > 0 ? new Date(wait.nextCheckAt).toISOString() : null,
|
|
319
|
+
},
|
|
320
|
+
}
|
|
321
|
+
: {}),
|
|
330
322
|
};
|
|
331
323
|
}
|
|
332
324
|
|
|
@@ -9,6 +9,16 @@ import type { EngineErrorCode } from "./types.js";
|
|
|
9
9
|
|
|
10
10
|
export type Reaction = PostCommitEffect;
|
|
11
11
|
|
|
12
|
+
/** @internal */
|
|
13
|
+
export function modelOverrideMetadata(input: DecisionMetadata = {}): DecisionMetadata | undefined {
|
|
14
|
+
const { nextTurnModelProfileId, providerOptions } = input;
|
|
15
|
+
if (nextTurnModelProfileId === undefined && providerOptions === undefined) return undefined;
|
|
16
|
+
return {
|
|
17
|
+
...(nextTurnModelProfileId !== undefined ? { nextTurnModelProfileId } : {}),
|
|
18
|
+
...(providerOptions !== undefined ? { providerOptions } : {}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
/** @internal */
|
|
13
23
|
export interface Decision<TData = void> {
|
|
14
24
|
/** @internal */
|
|
@@ -22,7 +22,10 @@ import {
|
|
|
22
22
|
UpdateSemanticRefs,
|
|
23
23
|
WorkerFailure,
|
|
24
24
|
} from "./ops/index.js";
|
|
25
|
+
import { ApplyProcessObservation } from "./ops/process-observation.js";
|
|
26
|
+
import { RetryTurnWait } from "./ops/turn-wait.js";
|
|
25
27
|
import { createEngineRunner } from "./runner.js";
|
|
28
|
+
import { pendingTurnWait } from "./turn-wait-state.js";
|
|
26
29
|
import type {
|
|
27
30
|
ActionExecutionResult,
|
|
28
31
|
EngineResult,
|
|
@@ -92,6 +95,9 @@ export function createProcessEngine(deps: ProcessEngineDeps): ProcessEngine {
|
|
|
92
95
|
|
|
93
96
|
engine = {
|
|
94
97
|
run,
|
|
98
|
+
applyProcessObservation(instanceId, input) {
|
|
99
|
+
return run(ApplyProcessObservation, { instanceId, ...input });
|
|
100
|
+
},
|
|
95
101
|
|
|
96
102
|
getDeferredProcessActivationSnapshots({ instanceId, processId, projectKey }) {
|
|
97
103
|
const processes = instanceId
|
|
@@ -134,7 +140,7 @@ export function createProcessEngine(deps: ProcessEngineDeps): ProcessEngine {
|
|
|
134
140
|
},
|
|
135
141
|
|
|
136
142
|
startProcess(instanceId, startTurnId, opts) {
|
|
137
|
-
return run(StartProcess, { instanceId, startTurnId,
|
|
143
|
+
return run(StartProcess, { instanceId, startTurnId, ...opts });
|
|
138
144
|
},
|
|
139
145
|
|
|
140
146
|
abortProcess(instanceId, opts) {
|
|
@@ -150,7 +156,10 @@ export function createProcessEngine(deps: ProcessEngineDeps): ProcessEngine {
|
|
|
150
156
|
},
|
|
151
157
|
|
|
152
158
|
async retryProcess(instanceId, opts) {
|
|
153
|
-
const
|
|
159
|
+
const process = deps.processes.getById(instanceId);
|
|
160
|
+
if (process && pendingTurnWait(process)?.status === "error")
|
|
161
|
+
return run(RetryTurnWait, { instanceId, ...opts });
|
|
162
|
+
const current = process?.currentExecution;
|
|
154
163
|
const start = current?.kind === "worker_start" ? deps.turnStarts.getById(current.id) : null;
|
|
155
164
|
if (start?.state.kind === "preparation_failed" || start?.state.kind === "bootstrap_failed") {
|
|
156
165
|
// RetryStartup fences this ID and lifecycle state under the process lock.
|