@leitwerk-dev/worker 0.1.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/LICENSE +13 -0
- package/dist/automatic-turn-executor.d.ts +28 -0
- package/dist/automatic-turn-executor.d.ts.map +1 -0
- package/dist/automatic-turn-executor.js +58 -0
- package/dist/automatic-turn-executor.js.map +1 -0
- package/dist/chunk-N5HLJDWA.js +8124 -0
- package/dist/chunk-N5HLJDWA.js.map +1 -0
- package/dist/diagnostics.d.ts +23 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +51 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/entry-runtime.d.ts +24 -0
- package/dist/entry-runtime.d.ts.map +1 -0
- package/dist/entry-runtime.js +160 -0
- package/dist/entry-runtime.js.map +1 -0
- package/dist/event-translator.d.ts +8 -0
- package/dist/event-translator.d.ts.map +1 -0
- package/dist/event-translator.js +12 -0
- package/dist/event-translator.js.map +1 -0
- package/dist/extension-entry-roots.d.ts +7 -0
- package/dist/extension-entry-roots.d.ts.map +1 -0
- package/dist/extension-entry-roots.js +41 -0
- package/dist/extension-entry-roots.js.map +1 -0
- package/dist/identified-pi-entry.d.ts +56 -0
- package/dist/identified-pi-entry.d.ts.map +1 -0
- package/dist/identified-pi-entry.js +125 -0
- package/dist/identified-pi-entry.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/input-consumer.d.ts +24 -0
- package/dist/input-consumer.d.ts.map +1 -0
- package/dist/input-consumer.js +34 -0
- package/dist/input-consumer.js.map +1 -0
- package/dist/ipc.d.ts +22 -0
- package/dist/ipc.d.ts.map +1 -0
- package/dist/ipc.js +192 -0
- package/dist/ipc.js.map +1 -0
- package/dist/logical-prompt-runner.d.ts +49 -0
- package/dist/logical-prompt-runner.d.ts.map +1 -0
- package/dist/logical-prompt-runner.js +225 -0
- package/dist/logical-prompt-runner.js.map +1 -0
- package/dist/managed-pi-agent-dir.d.ts +13 -0
- package/dist/managed-pi-agent-dir.d.ts.map +1 -0
- package/dist/managed-pi-agent-dir.js +66 -0
- package/dist/managed-pi-agent-dir.js.map +1 -0
- package/dist/managed-pi-bootstrap.d.ts +24 -0
- package/dist/managed-pi-bootstrap.d.ts.map +1 -0
- package/dist/managed-pi-bootstrap.js +135 -0
- package/dist/managed-pi-bootstrap.js.map +1 -0
- package/dist/missing-tool-recovery-runner.d.ts +23 -0
- package/dist/missing-tool-recovery-runner.d.ts.map +1 -0
- package/dist/missing-tool-recovery-runner.js +73 -0
- package/dist/missing-tool-recovery-runner.js.map +1 -0
- package/dist/pi-adapter.d.ts +134 -0
- package/dist/pi-adapter.d.ts.map +1 -0
- package/dist/pi-adapter.js +1648 -0
- package/dist/pi-adapter.js.map +1 -0
- package/dist/pi-branch-guard.d.ts +39 -0
- package/dist/pi-branch-guard.d.ts.map +1 -0
- package/dist/pi-branch-guard.js +75 -0
- package/dist/pi-branch-guard.js.map +1 -0
- package/dist/pi-event-reporter.d.ts +15 -0
- package/dist/pi-event-reporter.d.ts.map +1 -0
- package/dist/pi-event-reporter.js +136 -0
- package/dist/pi-event-reporter.js.map +1 -0
- package/dist/pi-resource-bundle.d.ts +12 -0
- package/dist/pi-resource-bundle.d.ts.map +1 -0
- package/dist/pi-resource-bundle.js +58 -0
- package/dist/pi-resource-bundle.js.map +1 -0
- package/dist/pre-turn-targeted-inputs.d.ts +44 -0
- package/dist/pre-turn-targeted-inputs.d.ts.map +1 -0
- package/dist/pre-turn-targeted-inputs.js +101 -0
- package/dist/pre-turn-targeted-inputs.js.map +1 -0
- package/dist/prompt-guards.d.ts +52 -0
- package/dist/prompt-guards.d.ts.map +1 -0
- package/dist/prompt-guards.js +318 -0
- package/dist/prompt-guards.js.map +1 -0
- package/dist/question-bridge.d.ts +16 -0
- package/dist/question-bridge.d.ts.map +1 -0
- package/dist/question-bridge.js +55 -0
- package/dist/question-bridge.js.map +1 -0
- package/dist/question-tool.d.ts +14 -0
- package/dist/question-tool.d.ts.map +1 -0
- package/dist/question-tool.js +54 -0
- package/dist/question-tool.js.map +1 -0
- package/dist/resource-loader-factory.d.ts +11 -0
- package/dist/resource-loader-factory.d.ts.map +1 -0
- package/dist/resource-loader-factory.js +87 -0
- package/dist/resource-loader-factory.js.map +1 -0
- package/dist/result-image-upload.d.ts +14 -0
- package/dist/result-image-upload.d.ts.map +1 -0
- package/dist/result-image-upload.js +183 -0
- package/dist/result-image-upload.js.map +1 -0
- package/dist/runtime/adapters.d.ts +48 -0
- package/dist/runtime/adapters.d.ts.map +1 -0
- package/dist/runtime/adapters.js +15 -0
- package/dist/runtime/adapters.js.map +1 -0
- package/dist/runtime/bootstrap-session.d.ts +95 -0
- package/dist/runtime/bootstrap-session.d.ts.map +1 -0
- package/dist/runtime/bootstrap-session.js +198 -0
- package/dist/runtime/bootstrap-session.js.map +1 -0
- package/dist/runtime/bootstrap.d.ts +81 -0
- package/dist/runtime/bootstrap.d.ts.map +1 -0
- package/dist/runtime/bootstrap.js +440 -0
- package/dist/runtime/bootstrap.js.map +1 -0
- package/dist/runtime/failure-policy.d.ts +79 -0
- package/dist/runtime/failure-policy.d.ts.map +1 -0
- package/dist/runtime/failure-policy.js +182 -0
- package/dist/runtime/failure-policy.js.map +1 -0
- package/dist/runtime/index.d.ts +9 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +326 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/lifecycle-reducer.d.ts +328 -0
- package/dist/runtime/lifecycle-reducer.d.ts.map +1 -0
- package/dist/runtime/lifecycle-reducer.js +1100 -0
- package/dist/runtime/lifecycle-reducer.js.map +1 -0
- package/dist/runtime/llm-turn-execution.d.ts +42 -0
- package/dist/runtime/llm-turn-execution.d.ts.map +1 -0
- package/dist/runtime/llm-turn-execution.js +472 -0
- package/dist/runtime/llm-turn-execution.js.map +1 -0
- package/dist/runtime/settings.d.ts +11 -0
- package/dist/runtime/settings.d.ts.map +1 -0
- package/dist/runtime/settings.js +23 -0
- package/dist/runtime/settings.js.map +1 -0
- package/dist/runtime/snapshot-policy.d.ts +11 -0
- package/dist/runtime/snapshot-policy.d.ts.map +1 -0
- package/dist/runtime/snapshot-policy.js +16 -0
- package/dist/runtime/snapshot-policy.js.map +1 -0
- package/dist/runtime/turn-execution.d.ts +49 -0
- package/dist/runtime/turn-execution.d.ts.map +1 -0
- package/dist/runtime/turn-execution.js +120 -0
- package/dist/runtime/turn-execution.js.map +1 -0
- package/dist/session-snapshot-exchange.d.ts +39 -0
- package/dist/session-snapshot-exchange.d.ts.map +1 -0
- package/dist/session-snapshot-exchange.js +102 -0
- package/dist/session-snapshot-exchange.js.map +1 -0
- package/dist/test-helpers/fake-websocket.d.ts +16 -0
- package/dist/test-helpers/fake-websocket.d.ts.map +1 -0
- package/dist/test-helpers/fake-websocket.js +40 -0
- package/dist/test-helpers/fake-websocket.js.map +1 -0
- package/dist/test-helpers/ipc-harness.d.ts +11 -0
- package/dist/test-helpers/ipc-harness.d.ts.map +1 -0
- package/dist/test-helpers/ipc-harness.js +17 -0
- package/dist/test-helpers/ipc-harness.js.map +1 -0
- package/dist/test-helpers/worker-message-builders.d.ts +21 -0
- package/dist/test-helpers/worker-message-builders.d.ts.map +1 -0
- package/dist/test-helpers/worker-message-builders.js +62 -0
- package/dist/test-helpers/worker-message-builders.js.map +1 -0
- package/dist/turn-continuation.d.ts +28 -0
- package/dist/turn-continuation.d.ts.map +1 -0
- package/dist/turn-continuation.js +80 -0
- package/dist/turn-continuation.js.map +1 -0
- package/dist/turn-execution-error.d.ts +39 -0
- package/dist/turn-execution-error.d.ts.map +1 -0
- package/dist/turn-execution-error.js +64 -0
- package/dist/turn-execution-error.js.map +1 -0
- package/dist/turn-execution-result.d.ts +35 -0
- package/dist/turn-execution-result.d.ts.map +1 -0
- package/dist/turn-execution-result.js +21 -0
- package/dist/turn-execution-result.js.map +1 -0
- package/dist/turn-outcome-tool-session.d.ts +50 -0
- package/dist/turn-outcome-tool-session.d.ts.map +1 -0
- package/dist/turn-outcome-tool-session.js +209 -0
- package/dist/turn-outcome-tool-session.js.map +1 -0
- package/dist/turn-record-id.d.ts +3 -0
- package/dist/turn-record-id.d.ts.map +1 -0
- package/dist/turn-record-id.js +10 -0
- package/dist/turn-record-id.js.map +1 -0
- package/dist/turn-result-markdown.d.ts +74 -0
- package/dist/turn-result-markdown.d.ts.map +1 -0
- package/dist/turn-result-markdown.js +263 -0
- package/dist/turn-result-markdown.js.map +1 -0
- package/dist/turn-tree-strategy.d.ts +29 -0
- package/dist/turn-tree-strategy.d.ts.map +1 -0
- package/dist/turn-tree-strategy.js +80 -0
- package/dist/turn-tree-strategy.js.map +1 -0
- package/dist/worker-entry.d.ts +2 -0
- package/dist/worker-entry.d.ts.map +1 -0
- package/dist/worker-entry.js +7 -0
- package/dist/worker-entry.js.map +1 -0
- package/dist/worker-http.d.ts +2 -0
- package/dist/worker-http.d.ts.map +1 -0
- package/dist/worker-http.js +9 -0
- package/dist/worker-http.js.map +1 -0
- package/dist/worker-ipc-reporter.d.ts +29 -0
- package/dist/worker-ipc-reporter.d.ts.map +1 -0
- package/dist/worker-ipc-reporter.js +58 -0
- package/dist/worker-ipc-reporter.js.map +1 -0
- package/dist/worker-payloads.d.ts +10 -0
- package/dist/worker-payloads.d.ts.map +1 -0
- package/dist/worker-payloads.js +66 -0
- package/dist/worker-payloads.js.map +1 -0
- package/dist/worker-start-payload.d.ts +7 -0
- package/dist/worker-start-payload.d.ts.map +1 -0
- package/dist/worker-start-payload.js +5 -0
- package/dist/worker-start-payload.js.map +1 -0
- package/dist/workspace/manifest.d.ts +35 -0
- package/dist/workspace/manifest.d.ts.map +1 -0
- package/dist/workspace/manifest.js +79 -0
- package/dist/workspace/manifest.js.map +1 -0
- package/dist/workspace/node-run-root-git-ops.d.ts +17 -0
- package/dist/workspace/node-run-root-git-ops.d.ts.map +1 -0
- package/dist/workspace/node-run-root-git-ops.js +96 -0
- package/dist/workspace/node-run-root-git-ops.js.map +1 -0
- package/dist/workspace/resource-aggregator.d.ts +15 -0
- package/dist/workspace/resource-aggregator.d.ts.map +1 -0
- package/dist/workspace/resource-aggregator.js +39 -0
- package/dist/workspace/resource-aggregator.js.map +1 -0
- package/dist/workspace/run-root.d.ts +52 -0
- package/dist/workspace/run-root.d.ts.map +1 -0
- package/dist/workspace/run-root.js +209 -0
- package/dist/workspace/run-root.js.map +1 -0
- package/package.json +55 -0
- package/src/automatic-turn-executor.ts +106 -0
- package/src/diagnostics.ts +82 -0
- package/src/entry-runtime.ts +235 -0
- package/src/event-translator.ts +22 -0
- package/src/extension-entry-roots.ts +43 -0
- package/src/identified-pi-entry.ts +188 -0
- package/src/index.ts +54 -0
- package/src/input-consumer.ts +71 -0
- package/src/ipc.ts +250 -0
- package/src/logical-prompt-runner.ts +320 -0
- package/src/managed-pi-agent-dir.ts +86 -0
- package/src/managed-pi-bootstrap.ts +208 -0
- package/src/missing-tool-recovery-runner.ts +112 -0
- package/src/pi-adapter.ts +2197 -0
- package/src/pi-branch-guard.ts +104 -0
- package/src/pi-event-reporter.ts +164 -0
- package/src/pi-resource-bundle.ts +90 -0
- package/src/pre-turn-targeted-inputs.ts +167 -0
- package/src/prompt-guards.ts +385 -0
- package/src/question-bridge.ts +69 -0
- package/src/question-tool.ts +65 -0
- package/src/resource-loader-factory.ts +115 -0
- package/src/result-image-upload.ts +256 -0
- package/src/runtime/adapters.ts +67 -0
- package/src/runtime/bootstrap-session.ts +294 -0
- package/src/runtime/bootstrap.ts +621 -0
- package/src/runtime/failure-policy.ts +274 -0
- package/src/runtime/index.ts +362 -0
- package/src/runtime/lifecycle-reducer.ts +1537 -0
- package/src/runtime/llm-turn-execution.ts +696 -0
- package/src/runtime/settings.ts +41 -0
- package/src/runtime/snapshot-policy.ts +28 -0
- package/src/runtime/turn-execution.ts +203 -0
- package/src/session-snapshot-exchange.ts +155 -0
- package/src/test-helpers/fake-websocket.ts +46 -0
- package/src/test-helpers/ipc-harness.ts +19 -0
- package/src/test-helpers/worker-message-builders.ts +92 -0
- package/src/turn-continuation.ts +147 -0
- package/src/turn-execution-error.ts +102 -0
- package/src/turn-execution-result.ts +48 -0
- package/src/turn-outcome-tool-session.ts +311 -0
- package/src/turn-record-id.ts +17 -0
- package/src/turn-result-markdown.ts +355 -0
- package/src/turn-tree-strategy.ts +141 -0
- package/src/worker-entry.ts +8 -0
- package/src/worker-http.ts +6 -0
- package/src/worker-ipc-reporter.ts +100 -0
- package/src/worker-payloads.ts +94 -0
- package/src/worker-start-payload.ts +10 -0
- package/src/workspace/manifest.ts +126 -0
- package/src/workspace/node-run-root-git-ops.ts +137 -0
- package/src/workspace/resource-aggregator.ts +43 -0
- package/src/workspace/run-root.ts +361 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { parseDurationMs } from "@leitwerk-dev/watcher-utils";
|
|
2
|
+
import type { WorkerStartPayload } from "@leitwerk-dev/worker-protocol";
|
|
3
|
+
import { isLlmWorkerStartPayload } from "../worker-start-payload.js";
|
|
4
|
+
import type { WorkerRuntimeConfig } from "./adapters.js";
|
|
5
|
+
|
|
6
|
+
const DEFAULT_HEARTBEAT_MS = 30_000;
|
|
7
|
+
const DEFAULT_TURN_MAX_DURATION_MS = 30 * 60_000;
|
|
8
|
+
const DEFAULT_TURN_INACTIVITY_TIMEOUT_MS = 5 * 60_000;
|
|
9
|
+
const DEFAULT_TURN_ABORT_GRACE_PERIOD_MS = 5_000;
|
|
10
|
+
|
|
11
|
+
export interface WorkerRuntimeSettings {
|
|
12
|
+
heartbeatIntervalMs: number;
|
|
13
|
+
turnMaxDurationMs: number;
|
|
14
|
+
turnInactivityTimeoutMs: number;
|
|
15
|
+
turnAbortGracePeriodMs: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function duration(value: string | undefined, fallback: number): number {
|
|
19
|
+
return value ? parseDurationMs(value, fallback, { allowHours: true }) : fallback;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Resolves immutable runtime settings at the worker.start boundary. */
|
|
23
|
+
export function resolveWorkerRuntimeSettings(
|
|
24
|
+
config: WorkerRuntimeConfig,
|
|
25
|
+
payload: WorkerStartPayload,
|
|
26
|
+
): WorkerRuntimeSettings {
|
|
27
|
+
const workers = isLlmWorkerStartPayload(payload) ? payload.configSnapshot.workers : null;
|
|
28
|
+
return {
|
|
29
|
+
heartbeatIntervalMs:
|
|
30
|
+
config.heartbeatIntervalMs ?? duration(workers?.heartbeat_interval, DEFAULT_HEARTBEAT_MS),
|
|
31
|
+
turnMaxDurationMs:
|
|
32
|
+
config.turnMaxDurationMs ??
|
|
33
|
+
duration(workers?.turn_max_duration, DEFAULT_TURN_MAX_DURATION_MS),
|
|
34
|
+
turnInactivityTimeoutMs:
|
|
35
|
+
config.turnInactivityTimeoutMs ??
|
|
36
|
+
duration(workers?.turn_inactivity_timeout, DEFAULT_TURN_INACTIVITY_TIMEOUT_MS),
|
|
37
|
+
turnAbortGracePeriodMs:
|
|
38
|
+
config.turnAbortGracePeriodMs ??
|
|
39
|
+
duration(workers?.turn_abort_grace_period, DEFAULT_TURN_ABORT_GRACE_PERIOD_MS),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type WorkerSnapshotPoint =
|
|
2
|
+
| "after_worker_ready"
|
|
3
|
+
| "before_turn_outcome"
|
|
4
|
+
| "before_turn_failed"
|
|
5
|
+
| "before_cleanup_completed"
|
|
6
|
+
| "before_worker_failed";
|
|
7
|
+
|
|
8
|
+
export type WorkerSnapshotPolicy =
|
|
9
|
+
| { upload: false }
|
|
10
|
+
| { upload: true; required: boolean; turnCorrelated: boolean };
|
|
11
|
+
|
|
12
|
+
/** Pure snapshot requiredness and correlation policy. */
|
|
13
|
+
export function resolveWorkerSnapshotPolicy(
|
|
14
|
+
point: WorkerSnapshotPoint,
|
|
15
|
+
sessionKind: "llm" | "automatic",
|
|
16
|
+
piAvailable: boolean,
|
|
17
|
+
): WorkerSnapshotPolicy {
|
|
18
|
+
if (sessionKind === "automatic") return { upload: false };
|
|
19
|
+
if (point === "before_cleanup_completed" && !piAvailable) return { upload: false };
|
|
20
|
+
if (point === "after_worker_ready" || point === "before_worker_failed") {
|
|
21
|
+
return { upload: true, required: false, turnCorrelated: false };
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
upload: true,
|
|
25
|
+
required: true,
|
|
26
|
+
turnCorrelated: point !== "before_cleanup_completed",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { ProcessSemanticEntryRefKey } from "@leitwerk-dev/domain";
|
|
2
|
+
import type {
|
|
3
|
+
LlmTurnDefinition,
|
|
4
|
+
TurnOptions,
|
|
5
|
+
TurnResult,
|
|
6
|
+
WorkerProcessContext,
|
|
7
|
+
WorkerRunHandle,
|
|
8
|
+
} from "@leitwerk-dev/process-sdk";
|
|
9
|
+
import { assertValidLlmTurnDefinition } from "@leitwerk-dev/process-sdk";
|
|
10
|
+
import { createAutomaticTurnExecutor } from "../automatic-turn-executor.js";
|
|
11
|
+
import type { WorkerOperationEmitter } from "../diagnostics.js";
|
|
12
|
+
import type { PiTreeHandle } from "../pi-adapter.js";
|
|
13
|
+
import type { PreTurnTargetedInput } from "../pre-turn-targeted-inputs.js";
|
|
14
|
+
import type { WorkerQuestionRequest } from "../question-tool.js";
|
|
15
|
+
import { TurnExecutionError } from "../turn-execution-error.js";
|
|
16
|
+
import { TurnExecutionFailure, type TurnExecutionMeta } from "../turn-execution-result.js";
|
|
17
|
+
import type { ResultImageToolFactory, WorkerRuntimeScheduler } from "./adapters.js";
|
|
18
|
+
import type { PreparedWorkerSession } from "./bootstrap-session.js";
|
|
19
|
+
import { executeLlmTurn } from "./llm-turn-execution.js";
|
|
20
|
+
|
|
21
|
+
export interface AppliedTargetedInput {
|
|
22
|
+
inputId: string;
|
|
23
|
+
sequence: number;
|
|
24
|
+
meta?: {
|
|
25
|
+
currentPrimaryPathLeafId?: string | null;
|
|
26
|
+
rootEntryId?: string | null;
|
|
27
|
+
targetSemanticRef?: ProcessSemanticEntryRefKey | null;
|
|
28
|
+
targetProductName?: string | null;
|
|
29
|
+
targetEntryId?: string | null;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type SelectedTurnExecutionResult =
|
|
34
|
+
| {
|
|
35
|
+
kind: "outcome";
|
|
36
|
+
turnId: string;
|
|
37
|
+
outcome: string;
|
|
38
|
+
params: Record<string, unknown>;
|
|
39
|
+
meta: TurnExecutionMeta;
|
|
40
|
+
appliedTargetedInputs: readonly AppliedTargetedInput[];
|
|
41
|
+
}
|
|
42
|
+
| {
|
|
43
|
+
kind: "failed";
|
|
44
|
+
failure: TurnExecutionFailure;
|
|
45
|
+
appliedTargetedInputs: readonly AppliedTargetedInput[];
|
|
46
|
+
}
|
|
47
|
+
| { kind: "parked"; reason?: string; appliedTargetedInputs: readonly AppliedTargetedInput[] };
|
|
48
|
+
|
|
49
|
+
export interface SelectedTurnExecutionInput {
|
|
50
|
+
session: PreparedWorkerSession;
|
|
51
|
+
piHandle: PiTreeHandle | null;
|
|
52
|
+
turnRecordId: string;
|
|
53
|
+
targetedInputs: readonly PreTurnTargetedInput[];
|
|
54
|
+
scheduler: WorkerRuntimeScheduler;
|
|
55
|
+
resultImageTools: ResultImageToolFactory;
|
|
56
|
+
requestQuestions?: (request: WorkerQuestionRequest) => Promise<string[]>;
|
|
57
|
+
signal: AbortSignal;
|
|
58
|
+
emit: WorkerOperationEmitter;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function failedResult(
|
|
62
|
+
failure: TurnExecutionFailure,
|
|
63
|
+
appliedTargetedInputs: readonly AppliedTargetedInput[],
|
|
64
|
+
): SelectedTurnExecutionResult {
|
|
65
|
+
return { kind: "failed", failure, appliedTargetedInputs };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Execute one accepted selected turn and return its single terminal fact. */
|
|
69
|
+
export async function executeSelectedTurn(
|
|
70
|
+
input: SelectedTurnExecutionInput,
|
|
71
|
+
): Promise<SelectedTurnExecutionResult> {
|
|
72
|
+
const { resolvedWorkerProcess, processSnapshot, projectSnapshots } = input.session;
|
|
73
|
+
const { piHandle } = input;
|
|
74
|
+
const currentTurnId = input.session.selectedTurnId;
|
|
75
|
+
const selectedTurnType = input.session.kind;
|
|
76
|
+
if (selectedTurnType === "llm" && !piHandle) {
|
|
77
|
+
throw new TurnExecutionError(
|
|
78
|
+
currentTurnId,
|
|
79
|
+
"infrastructure",
|
|
80
|
+
`Turn '${currentTurnId}' requires a Pi handle`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const handler = resolvedWorkerProcess.definition.turns.get(currentTurnId);
|
|
84
|
+
if (!handler) throw new Error(`Validated turn handler '${currentTurnId}' is unavailable`);
|
|
85
|
+
|
|
86
|
+
const ctx = {
|
|
87
|
+
process: processSnapshot,
|
|
88
|
+
projects: projectSnapshots,
|
|
89
|
+
params: resolvedWorkerProcess.params,
|
|
90
|
+
state: resolvedWorkerProcess.state,
|
|
91
|
+
turnResultMarkdownBySemanticRef: input.session.turnResultMarkdownBySemanticRef,
|
|
92
|
+
turnResultMarkdownByProduct: input.session.turnResultMarkdownByProduct,
|
|
93
|
+
workspaceRoot: input.session.workspaceRoot,
|
|
94
|
+
} as WorkerProcessContext;
|
|
95
|
+
let terminal: SelectedTurnExecutionResult | null = null;
|
|
96
|
+
const appliedTargetedInputs: AppliedTargetedInput[] = [];
|
|
97
|
+
let parked = false;
|
|
98
|
+
let parkReason: string | undefined;
|
|
99
|
+
const automaticExecutor =
|
|
100
|
+
selectedTurnType === "automatic"
|
|
101
|
+
? createAutomaticTurnExecutor({
|
|
102
|
+
currentTurnId,
|
|
103
|
+
processSnapshot,
|
|
104
|
+
acceptedTurnRecordId: input.turnRecordId,
|
|
105
|
+
state: ctx.state,
|
|
106
|
+
piHandle,
|
|
107
|
+
})
|
|
108
|
+
: null;
|
|
109
|
+
|
|
110
|
+
const run: WorkerRunHandle = {
|
|
111
|
+
ctx,
|
|
112
|
+
async turn<TOutcome extends string>(
|
|
113
|
+
turnDef: LlmTurnDefinition<TOutcome, unknown, unknown>,
|
|
114
|
+
_options?: TurnOptions,
|
|
115
|
+
): Promise<TurnResult<TOutcome>> {
|
|
116
|
+
if (selectedTurnType !== "llm") {
|
|
117
|
+
throw new TurnExecutionError(
|
|
118
|
+
currentTurnId,
|
|
119
|
+
"protocol_error",
|
|
120
|
+
`Selected turn '${currentTurnId}' of type '${selectedTurnType}' cannot call run.turn()`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
assertValidLlmTurnDefinition(currentTurnId, turnDef);
|
|
124
|
+
if (!piHandle) {
|
|
125
|
+
throw new TurnExecutionError(
|
|
126
|
+
currentTurnId,
|
|
127
|
+
"infrastructure",
|
|
128
|
+
`Turn '${currentTurnId}' requires a Pi handle`,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
const completed = await executeLlmTurn({
|
|
132
|
+
resolvedWorkerProcess,
|
|
133
|
+
ctx,
|
|
134
|
+
piHandle,
|
|
135
|
+
turnDef,
|
|
136
|
+
turnId: currentTurnId,
|
|
137
|
+
acceptedTurnRecordId: input.turnRecordId,
|
|
138
|
+
turnStartRecordId: input.session.startRecordId,
|
|
139
|
+
preparedTurnStart: input.session.kind === "llm" ? input.session.preparedTurnStart : null,
|
|
140
|
+
configSnapshot: input.session.kind === "llm" ? input.session.configSnapshot : undefined,
|
|
141
|
+
preTurnTargetedInputs: input.targetedInputs,
|
|
142
|
+
scheduler: input.scheduler,
|
|
143
|
+
resultImageTools: input.resultImageTools,
|
|
144
|
+
turnMaxDurationMs: input.session.settings.turnMaxDurationMs,
|
|
145
|
+
turnInactivityTimeoutMs: input.session.settings.turnInactivityTimeoutMs,
|
|
146
|
+
turnAbortGracePeriodMs: input.session.settings.turnAbortGracePeriodMs,
|
|
147
|
+
operatorAbortSignal: input.signal,
|
|
148
|
+
callbacks: {
|
|
149
|
+
requestQuestions: input.requestQuestions,
|
|
150
|
+
onPreTurnTargetedInputApplied(inputId, sequence, meta) {
|
|
151
|
+
appliedTargetedInputs.push({ inputId, sequence, ...(meta ? { meta } : {}) });
|
|
152
|
+
},
|
|
153
|
+
emit: input.emit,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
terminal = {
|
|
157
|
+
kind: "outcome",
|
|
158
|
+
turnId: currentTurnId,
|
|
159
|
+
outcome: completed.turnResult.outcome,
|
|
160
|
+
params: completed.turnResult.params,
|
|
161
|
+
meta: completed.meta,
|
|
162
|
+
appliedTargetedInputs,
|
|
163
|
+
};
|
|
164
|
+
return completed.turnResult;
|
|
165
|
+
},
|
|
166
|
+
async complete(completeInput) {
|
|
167
|
+
if (!automaticExecutor) {
|
|
168
|
+
throw new TurnExecutionError(
|
|
169
|
+
currentTurnId,
|
|
170
|
+
"protocol_error",
|
|
171
|
+
`Selected turn '${currentTurnId}' cannot call run.complete()`,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
await automaticExecutor.complete(completeInput);
|
|
175
|
+
},
|
|
176
|
+
park(reason?: string) {
|
|
177
|
+
parked = true;
|
|
178
|
+
parkReason = reason;
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
await handler(run);
|
|
184
|
+
automaticExecutor?.assertCompletedUnlessParked(parked);
|
|
185
|
+
if (parked) return { kind: "parked", reason: parkReason, appliedTargetedInputs };
|
|
186
|
+
if (automaticExecutor?.result) {
|
|
187
|
+
return { kind: "outcome", ...automaticExecutor.result, appliedTargetedInputs };
|
|
188
|
+
}
|
|
189
|
+
if (!terminal) {
|
|
190
|
+
throw new TurnExecutionError(
|
|
191
|
+
currentTurnId,
|
|
192
|
+
"protocol_error",
|
|
193
|
+
`Selected turn '${currentTurnId}' returned without an outcome or park`,
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
return terminal;
|
|
197
|
+
} catch (error) {
|
|
198
|
+
if (error instanceof TurnExecutionFailure) return failedResult(error, appliedTargetedInputs);
|
|
199
|
+
if (automaticExecutor)
|
|
200
|
+
return failedResult(automaticExecutor.failure(error), appliedTargetedInputs);
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { isEnoent } from "@leitwerk-dev/process-sdk";
|
|
3
|
+
import {
|
|
4
|
+
buildWorkerSessionSnapshotPath,
|
|
5
|
+
WORKER_IPC_SERVER_URL_ENV,
|
|
6
|
+
WORKER_SESSION_SNAPSHOT_CONTENT_TYPE,
|
|
7
|
+
WORKER_SESSION_SNAPSHOT_REASON_HEADER,
|
|
8
|
+
WORKER_SESSION_SNAPSHOT_TURN_RECORD_ID_HEADER,
|
|
9
|
+
WORKER_SESSION_SNAPSHOT_WORKER_ID_HEADER,
|
|
10
|
+
WORKER_SNAPSHOT_TOKEN_ENV,
|
|
11
|
+
} from "@leitwerk-dev/worker-protocol";
|
|
12
|
+
import { resolveWorkerHttpUrl } from "./worker-http.js";
|
|
13
|
+
|
|
14
|
+
export type SessionSnapshotUploadResult =
|
|
15
|
+
| { kind: "disabled" }
|
|
16
|
+
| { kind: "missing" }
|
|
17
|
+
| { kind: "empty" }
|
|
18
|
+
| { kind: "uploaded"; bytes: number };
|
|
19
|
+
|
|
20
|
+
export interface WorkerSessionSnapshotUploadMetadata {
|
|
21
|
+
turnRecordId?: string | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface WorkerSessionSnapshotExchange {
|
|
25
|
+
uploadSnapshot(
|
|
26
|
+
treeFile: string,
|
|
27
|
+
reason: string,
|
|
28
|
+
metadata?: WorkerSessionSnapshotUploadMetadata,
|
|
29
|
+
): Promise<SessionSnapshotUploadResult>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type FetchLike = typeof fetch;
|
|
33
|
+
|
|
34
|
+
export function resolveWorkerSessionSnapshotUrl(input: {
|
|
35
|
+
serverUrl: string;
|
|
36
|
+
instanceId: string;
|
|
37
|
+
}): string {
|
|
38
|
+
return resolveWorkerHttpUrl(input.serverUrl, buildWorkerSessionSnapshotPath(input.instanceId));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function localFileSize(filePath: string): Promise<number | null> {
|
|
42
|
+
try {
|
|
43
|
+
return (await stat(filePath)).size;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
if (isEnoent(error)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function fetchWithTimeout(input: {
|
|
53
|
+
fetchImpl: FetchLike;
|
|
54
|
+
url: string;
|
|
55
|
+
init: RequestInit;
|
|
56
|
+
timeoutMs: number;
|
|
57
|
+
}): Promise<Response> {
|
|
58
|
+
const controller = new AbortController();
|
|
59
|
+
const timeout = setTimeout(() => controller.abort(), input.timeoutMs);
|
|
60
|
+
timeout.unref?.();
|
|
61
|
+
try {
|
|
62
|
+
return await input.fetchImpl(input.url, { ...input.init, signal: controller.signal });
|
|
63
|
+
} finally {
|
|
64
|
+
clearTimeout(timeout);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function createWorkerSessionSnapshotExchange(input: {
|
|
69
|
+
serverUrl: string;
|
|
70
|
+
token: string;
|
|
71
|
+
instanceId: string;
|
|
72
|
+
workerId: string;
|
|
73
|
+
fetchImpl?: FetchLike;
|
|
74
|
+
timeoutMs?: number;
|
|
75
|
+
}): WorkerSessionSnapshotExchange {
|
|
76
|
+
const fetchImpl = input.fetchImpl ?? globalThis.fetch;
|
|
77
|
+
if (!fetchImpl) {
|
|
78
|
+
return disabledWorkerSessionSnapshotExchange;
|
|
79
|
+
}
|
|
80
|
+
const timeoutMs = input.timeoutMs ?? 30_000;
|
|
81
|
+
const snapshotUrl = resolveWorkerSessionSnapshotUrl({
|
|
82
|
+
serverUrl: input.serverUrl,
|
|
83
|
+
instanceId: input.instanceId,
|
|
84
|
+
});
|
|
85
|
+
const authHeaders = {
|
|
86
|
+
authorization: `Bearer ${input.token}`,
|
|
87
|
+
[WORKER_SESSION_SNAPSHOT_WORKER_ID_HEADER]: input.workerId,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
async uploadSnapshot(treeFile, reason, metadata = {}) {
|
|
92
|
+
const size = await localFileSize(treeFile);
|
|
93
|
+
if (size === null) {
|
|
94
|
+
return { kind: "missing" };
|
|
95
|
+
}
|
|
96
|
+
if (size === 0) {
|
|
97
|
+
return { kind: "empty" };
|
|
98
|
+
}
|
|
99
|
+
const content = await readFile(treeFile, "utf8");
|
|
100
|
+
if (content.length === 0) {
|
|
101
|
+
return { kind: "empty" };
|
|
102
|
+
}
|
|
103
|
+
const response = await fetchWithTimeout({
|
|
104
|
+
fetchImpl,
|
|
105
|
+
url: snapshotUrl,
|
|
106
|
+
timeoutMs,
|
|
107
|
+
init: {
|
|
108
|
+
method: "PUT",
|
|
109
|
+
headers: {
|
|
110
|
+
...authHeaders,
|
|
111
|
+
"content-type": WORKER_SESSION_SNAPSHOT_CONTENT_TYPE,
|
|
112
|
+
[WORKER_SESSION_SNAPSHOT_REASON_HEADER]: reason,
|
|
113
|
+
...(metadata.turnRecordId
|
|
114
|
+
? { [WORKER_SESSION_SNAPSHOT_TURN_RECORD_ID_HEADER]: metadata.turnRecordId }
|
|
115
|
+
: {}),
|
|
116
|
+
},
|
|
117
|
+
body: content,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
if (!response.ok) {
|
|
121
|
+
throw new Error(`Session snapshot upload failed with HTTP ${response.status}`);
|
|
122
|
+
}
|
|
123
|
+
return { kind: "uploaded", bytes: Buffer.byteLength(content, "utf8") };
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const disabledWorkerSessionSnapshotExchange: WorkerSessionSnapshotExchange = {
|
|
129
|
+
async uploadSnapshot() {
|
|
130
|
+
return { kind: "disabled" };
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export function createWorkerSessionSnapshotExchangeFromEnv(input: {
|
|
135
|
+
env?: NodeJS.ProcessEnv;
|
|
136
|
+
instanceId: string;
|
|
137
|
+
workerId: string;
|
|
138
|
+
fetchImpl?: FetchLike;
|
|
139
|
+
timeoutMs?: number;
|
|
140
|
+
}): WorkerSessionSnapshotExchange {
|
|
141
|
+
const env = input.env ?? process.env;
|
|
142
|
+
const serverUrl = env[WORKER_IPC_SERVER_URL_ENV];
|
|
143
|
+
const token = env[WORKER_SNAPSHOT_TOKEN_ENV];
|
|
144
|
+
if (!serverUrl || !token) {
|
|
145
|
+
return disabledWorkerSessionSnapshotExchange;
|
|
146
|
+
}
|
|
147
|
+
return createWorkerSessionSnapshotExchange({
|
|
148
|
+
serverUrl,
|
|
149
|
+
token,
|
|
150
|
+
instanceId: input.instanceId,
|
|
151
|
+
workerId: input.workerId,
|
|
152
|
+
fetchImpl: input.fetchImpl,
|
|
153
|
+
timeoutMs: input.timeoutMs,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export class FakeWorkerWebSocket {
|
|
2
|
+
static instances: FakeWorkerWebSocket[] = [];
|
|
3
|
+
readonly url: string;
|
|
4
|
+
readyState = 0;
|
|
5
|
+
sent: string[] = [];
|
|
6
|
+
throwOnSend = false;
|
|
7
|
+
private listeners = new Map<string, Set<(event?: unknown) => void>>();
|
|
8
|
+
|
|
9
|
+
constructor(url: string) {
|
|
10
|
+
this.url = url;
|
|
11
|
+
FakeWorkerWebSocket.instances.push(this);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
addEventListener(event: string, handler: (event?: unknown) => void): void {
|
|
15
|
+
const existing = this.listeners.get(event) ?? new Set();
|
|
16
|
+
existing.add(handler);
|
|
17
|
+
this.listeners.set(event, existing);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
emit(event: string, payload?: unknown): void {
|
|
21
|
+
for (const handler of this.listeners.get(event) ?? []) {
|
|
22
|
+
handler(payload);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
open(): void {
|
|
27
|
+
this.readyState = 1;
|
|
28
|
+
this.emit("open");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
receive(data: string): void {
|
|
32
|
+
this.emit("message", { data });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
send(data: string): void {
|
|
36
|
+
if (this.throwOnSend) {
|
|
37
|
+
throw new Error("send failed");
|
|
38
|
+
}
|
|
39
|
+
this.sent.push(data);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
close(code?: number, reason?: string): void {
|
|
43
|
+
this.readyState = 3;
|
|
44
|
+
this.emit("close", { code, reason });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createTestConfigSnapshot, IPC_PROTOCOL_VERSION } from "@leitwerk-dev/worker-protocol";
|
|
2
|
+
|
|
3
|
+
export async function flushAsyncWork(iterations = 30): Promise<void> {
|
|
4
|
+
for (let i = 0; i < iterations; i++) {
|
|
5
|
+
await new Promise<void>((resolve) => setImmediate(resolve));
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const testConfigSnapshot = createTestConfigSnapshot;
|
|
10
|
+
|
|
11
|
+
export function baseEnvelope(instanceId: string, workerId: string, messageId: string) {
|
|
12
|
+
return {
|
|
13
|
+
protocol: IPC_PROTOCOL_VERSION as typeof IPC_PROTOCOL_VERSION,
|
|
14
|
+
messageId,
|
|
15
|
+
instanceId,
|
|
16
|
+
workerId,
|
|
17
|
+
sentAt: new Date().toISOString(),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { ProcessSemanticEntryRefKey } from "@leitwerk-dev/domain";
|
|
2
|
+
import type {
|
|
3
|
+
InputDelivery,
|
|
4
|
+
ProcessInstanceSnapshot,
|
|
5
|
+
ProcessProjectSnapshot,
|
|
6
|
+
ServerToWorkerMessage,
|
|
7
|
+
} from "@leitwerk-dev/worker-protocol";
|
|
8
|
+
import { createIpcMessage } from "@leitwerk-dev/worker-protocol";
|
|
9
|
+
import { baseEnvelope } from "./ipc-harness.js";
|
|
10
|
+
|
|
11
|
+
export type TestInputDelivery = Omit<InputDelivery, "receivedAt" | "source" | "kind" | "target"> & {
|
|
12
|
+
receivedAt?: string;
|
|
13
|
+
source?: string;
|
|
14
|
+
kind?: string;
|
|
15
|
+
target?: InputDelivery["target"];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const DEFAULT_PROJECT_SNAPSHOTS: ProcessProjectSnapshot[] = [
|
|
19
|
+
{
|
|
20
|
+
key: "c1",
|
|
21
|
+
repoLocator: "https://example.com/r.git",
|
|
22
|
+
baseBranch: "main",
|
|
23
|
+
workBranch: "feat-1",
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export function toInputDelivery(input: TestInputDelivery): InputDelivery {
|
|
28
|
+
return {
|
|
29
|
+
inputId: input.inputId,
|
|
30
|
+
sequence: input.sequence,
|
|
31
|
+
source: input.source ?? "user",
|
|
32
|
+
kind: input.kind ?? "user",
|
|
33
|
+
target: input.target ?? null,
|
|
34
|
+
receivedAt: input.receivedAt ?? new Date().toISOString(),
|
|
35
|
+
bodyMarkdown: input.bodyMarkdown,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function workerStartMessage(
|
|
40
|
+
instanceId: string,
|
|
41
|
+
workerId: string,
|
|
42
|
+
opts: {
|
|
43
|
+
processSnapshot?: ProcessInstanceSnapshot;
|
|
44
|
+
workspaceRoot: string;
|
|
45
|
+
primaryTreeFile: string;
|
|
46
|
+
resume: boolean;
|
|
47
|
+
resumeLeafEntryId?: string | null;
|
|
48
|
+
pendingInputs?: TestInputDelivery[];
|
|
49
|
+
projectSnapshots?: ProcessProjectSnapshot[];
|
|
50
|
+
turnResultMarkdownBySemanticRef?: Partial<Record<ProcessSemanticEntryRefKey, string>>;
|
|
51
|
+
turnResultMarkdownByProduct?: Record<string, string>;
|
|
52
|
+
},
|
|
53
|
+
): ServerToWorkerMessage {
|
|
54
|
+
return createIpcMessage({
|
|
55
|
+
...baseEnvelope(instanceId, workerId, "start-1"),
|
|
56
|
+
type: "worker.start",
|
|
57
|
+
payload: {
|
|
58
|
+
processSnapshot: opts.processSnapshot ?? {},
|
|
59
|
+
projectSnapshots: opts.projectSnapshots ?? DEFAULT_PROJECT_SNAPSHOTS,
|
|
60
|
+
pendingInputs: (opts.pendingInputs ?? []).map(toInputDelivery),
|
|
61
|
+
workerLeaseId: "lease-1",
|
|
62
|
+
turnStart: {
|
|
63
|
+
id: "start-1",
|
|
64
|
+
instanceId,
|
|
65
|
+
turnId: "automatic",
|
|
66
|
+
turnType: "automatic",
|
|
67
|
+
proposedTurnRecordId: "turn-record-1",
|
|
68
|
+
startKind: "selected_turn",
|
|
69
|
+
recoveryTurnRecordId: null,
|
|
70
|
+
continuation: null,
|
|
71
|
+
state: { kind: "starting", start: { kind: "automatic" } },
|
|
72
|
+
createdAt: new Date().toISOString(),
|
|
73
|
+
updatedAt: new Date().toISOString(),
|
|
74
|
+
},
|
|
75
|
+
bootstrap: { kind: "automatic" },
|
|
76
|
+
treePaths: {
|
|
77
|
+
primaryTreeFile: opts.primaryTreeFile,
|
|
78
|
+
workspaceRoot: opts.workspaceRoot,
|
|
79
|
+
},
|
|
80
|
+
resume: opts.resume,
|
|
81
|
+
...(opts.resumeLeafEntryId !== undefined
|
|
82
|
+
? { resumeLeafEntryId: opts.resumeLeafEntryId }
|
|
83
|
+
: {}),
|
|
84
|
+
...(opts.turnResultMarkdownBySemanticRef
|
|
85
|
+
? { turnResultMarkdownBySemanticRef: opts.turnResultMarkdownBySemanticRef }
|
|
86
|
+
: {}),
|
|
87
|
+
...(opts.turnResultMarkdownByProduct
|
|
88
|
+
? { turnResultMarkdownByProduct: opts.turnResultMarkdownByProduct }
|
|
89
|
+
: {}),
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|