@leitwerk-dev/test-support 0.3.0 → 0.3.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/{chunk-OE4NHDVS.js → chunk-JGXSXRIJ.js} +2 -2
- package/dist/{chunk-E4Y7XND5.js → chunk-WT7V7REB.js} +2 -1
- package/dist/chunk-WT7V7REB.js.map +1 -0
- package/dist/extension-integration-harness.d.ts.map +1 -1
- package/dist/fixtures.js.map +1 -1
- package/dist/integration.js +26 -87
- package/dist/integration.js.map +1 -1
- package/dist/stub-worker-entry.js +1 -1
- package/dist/supported-question-fixtures.d.ts.map +1 -1
- package/dist/worker-testing/index.js +2 -2
- package/dist/worker-testing/stub-pi-tree-handle.d.ts +13 -0
- package/dist/worker-testing/stub-pi-tree-handle.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/extension-integration-harness.ts +34 -127
- package/src/supported-question-fixtures.ts +0 -20
- package/src/worker-testing/stub-pi-tree-handle.ts +14 -0
- package/dist/chunk-E4Y7XND5.js.map +0 -1
- /package/dist/{chunk-OE4NHDVS.js.map → chunk-JGXSXRIJ.js.map} +0 -0
|
@@ -3,7 +3,6 @@ import type { ExtensionTestCapability } from "./test-capability.js";
|
|
|
3
3
|
export type { ExtensionTestCapability } from "./test-capability.js";
|
|
4
4
|
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
7
6
|
import path from "node:path";
|
|
8
7
|
import type {
|
|
9
8
|
Actor,
|
|
@@ -18,7 +17,11 @@ import {
|
|
|
18
17
|
type ExtensionProcessDefinition,
|
|
19
18
|
type LeitwerkExtensionModule,
|
|
20
19
|
} from "@leitwerk-dev/process-sdk";
|
|
21
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
createAcceptedWorkerTurn,
|
|
22
|
+
prepareAcceptedFixtureStart,
|
|
23
|
+
} from "@leitwerk-dev/server/testing";
|
|
24
|
+
import { persistPiResourceBundleForStart } from "@leitwerk-dev/worker";
|
|
22
25
|
import { postImmediateLaunch } from "./http-launch.js";
|
|
23
26
|
import { createPersistentIntegrationFixture } from "./integration-harness.js";
|
|
24
27
|
import { observe, type TestObservation } from "./observations.js";
|
|
@@ -462,10 +465,7 @@ export async function createExtensionIntegrationHarness(
|
|
|
462
465
|
});
|
|
463
466
|
const manual = options.execution === "manual";
|
|
464
467
|
let closed = false;
|
|
465
|
-
const pending = new Map<
|
|
466
|
-
string,
|
|
467
|
-
{ turnId: string; resolve(): void; reject(error: Error): void }
|
|
468
|
-
>();
|
|
468
|
+
const pending = new Map<string, { turnId: string; resolve(): void }>();
|
|
469
469
|
const permits = new Set<string>();
|
|
470
470
|
const executing = new Set<string>();
|
|
471
471
|
const scripts = new Map<string, IntegrationTurnScript>();
|
|
@@ -572,7 +572,6 @@ export async function createExtensionIntegrationHarness(
|
|
|
572
572
|
pending.delete(id);
|
|
573
573
|
resolve();
|
|
574
574
|
},
|
|
575
|
-
reject,
|
|
576
575
|
});
|
|
577
576
|
})
|
|
578
577
|
: undefined,
|
|
@@ -633,12 +632,7 @@ export async function createExtensionIntegrationHarness(
|
|
|
633
632
|
/** @public */
|
|
634
633
|
async function waitFor(
|
|
635
634
|
condition: (snapshot: TestObservation<ExtensionIntegrationSnapshot>) => boolean,
|
|
636
|
-
options: {
|
|
637
|
-
/** @public */
|
|
638
|
-
timeoutMs?: number;
|
|
639
|
-
/** @public */
|
|
640
|
-
description?: string;
|
|
641
|
-
} = {},
|
|
635
|
+
options: Parameters<ExtensionIntegrationProcess["waitFor"]>[1] = {},
|
|
642
636
|
) {
|
|
643
637
|
const deadline = Date.now() + (options.timeoutMs ?? 12000);
|
|
644
638
|
for (;;) {
|
|
@@ -678,7 +672,7 @@ export async function createExtensionIntegrationHarness(
|
|
|
678
672
|
/** @public */
|
|
679
673
|
id,
|
|
680
674
|
/** Establish correlated accepted records under exclusive server coordination. @public */
|
|
681
|
-
async seedAcceptedTurn(fixture
|
|
675
|
+
async seedAcceptedTurn(fixture) {
|
|
682
676
|
const ctx = context();
|
|
683
677
|
return ctx.deps.processOperations.runExclusive(id, async () => {
|
|
684
678
|
const process = ctx.deps.processes.getById(id);
|
|
@@ -710,8 +704,20 @@ export async function createExtensionIntegrationHarness(
|
|
|
710
704
|
catalog.piContributions,
|
|
711
705
|
)
|
|
712
706
|
: null;
|
|
707
|
+
const turnId = `trn_${randomUUID()}`;
|
|
708
|
+
if (prepared)
|
|
709
|
+
await persistPiResourceBundleForStart({
|
|
710
|
+
bundlesDir: path.join(
|
|
711
|
+
ctx.config.storage.process_workspaces_dir,
|
|
712
|
+
id,
|
|
713
|
+
".leitwerk",
|
|
714
|
+
"pi-resource-bundles",
|
|
715
|
+
),
|
|
716
|
+
startRecordId: `tsr_${turnId}`,
|
|
717
|
+
digest: prepared.bundle.digest,
|
|
718
|
+
deliveredBundle: prepared.bundle.bytes,
|
|
719
|
+
});
|
|
713
720
|
return ctx.deps.transaction((repos) => {
|
|
714
|
-
const turnId = `trn_${randomUUID()}`;
|
|
715
721
|
const timestamp = new Date().toISOString();
|
|
716
722
|
const input = {
|
|
717
723
|
id: turnId,
|
|
@@ -731,77 +737,11 @@ export async function createExtensionIntegrationHarness(
|
|
|
731
737
|
turnResultMarkdown:
|
|
732
738
|
fixture.execution.status === "succeeded" ? fixture.execution.markdown : null,
|
|
733
739
|
};
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
".leitwerk",
|
|
740
|
-
"pi-resource-bundles",
|
|
741
|
-
);
|
|
742
|
-
mkdirSync(path.join(bundleDir, "starts"), { recursive: true, mode: 0o700 });
|
|
743
|
-
writeFileSync(
|
|
744
|
-
path.join(bundleDir, `${prepared.bundle.digest}.tar`),
|
|
745
|
-
prepared.bundle.bytes,
|
|
746
|
-
{ mode: 0o600 },
|
|
747
|
-
);
|
|
748
|
-
writeFileSync(
|
|
749
|
-
path.join(bundleDir, "starts", `tsr_${turnId}.json`),
|
|
750
|
-
JSON.stringify({
|
|
751
|
-
startRecordId: `tsr_${turnId}`,
|
|
752
|
-
digest: prepared.bundle.digest,
|
|
753
|
-
persistedAt: timestamp,
|
|
754
|
-
}),
|
|
755
|
-
{ mode: 0o600 },
|
|
756
|
-
);
|
|
757
|
-
|
|
758
|
-
createAcceptedLlmTurn(
|
|
759
|
-
{
|
|
760
|
-
...ctx,
|
|
761
|
-
deps: {
|
|
762
|
-
...ctx.deps,
|
|
763
|
-
processes: repos.processes,
|
|
764
|
-
turnRecords: repos.turnRecords,
|
|
765
|
-
turnStarts: repos.turnStarts,
|
|
766
|
-
leases: repos.leases,
|
|
767
|
-
},
|
|
768
|
-
},
|
|
769
|
-
{ ...input, turnType: "llm", modelProfileId: prepared.start.model.profileId },
|
|
770
|
-
{ current: running, preparedStart: prepared?.start },
|
|
771
|
-
);
|
|
772
|
-
} else {
|
|
773
|
-
const lease = repos.leases.create({
|
|
774
|
-
instanceId: id,
|
|
775
|
-
workerId: `wkr_${randomUUID()}`,
|
|
776
|
-
state: running ? "busy" : "exited",
|
|
777
|
-
});
|
|
778
|
-
const start = repos.turnStarts.create({
|
|
779
|
-
instanceId: id,
|
|
780
|
-
turnId: fixture.turnId,
|
|
781
|
-
turnType: "automatic",
|
|
782
|
-
proposedTurnRecordId: turnId,
|
|
783
|
-
startKind: "selected_turn",
|
|
784
|
-
recoveryTurnRecordId: null,
|
|
785
|
-
continuation: null,
|
|
786
|
-
state: {
|
|
787
|
-
kind: "accepted",
|
|
788
|
-
start: { kind: "automatic" },
|
|
789
|
-
turnRecordId: turnId,
|
|
790
|
-
acceptedWorkerLeaseId: lease.id,
|
|
791
|
-
},
|
|
792
|
-
});
|
|
793
|
-
repos.turnRecords.create({
|
|
794
|
-
...input,
|
|
795
|
-
turnType: "automatic",
|
|
796
|
-
turnStartRecordId: start.id,
|
|
797
|
-
acceptedWorkerLeaseId: lease.id,
|
|
798
|
-
});
|
|
799
|
-
if (running)
|
|
800
|
-
repos.processes.update(id, {
|
|
801
|
-
currentExecution: { kind: "worker_start", id: start.id },
|
|
802
|
-
});
|
|
803
|
-
else repos.leases.update(lease.id, { exitedAt: timestamp });
|
|
804
|
-
}
|
|
740
|
+
createAcceptedWorkerTurn(
|
|
741
|
+
{ deps: repos },
|
|
742
|
+
{ ...input, turnType: turn.kind, modelProfileId: prepared?.start.model.profileId },
|
|
743
|
+
{ current: running, preparedStart: prepared?.start },
|
|
744
|
+
);
|
|
805
745
|
if (fixture.execution.status === "succeeded")
|
|
806
746
|
repos.turnAnnotations.create({
|
|
807
747
|
instanceId: id,
|
|
@@ -817,13 +757,9 @@ export async function createExtensionIntegrationHarness(
|
|
|
817
757
|
});
|
|
818
758
|
if (running) repos.processes.update(id, { lifecycleStatus: "active" });
|
|
819
759
|
return observe({
|
|
820
|
-
/** @public */
|
|
821
760
|
id: turnId,
|
|
822
|
-
/** @public */
|
|
823
761
|
instanceId: id,
|
|
824
|
-
/** @public */
|
|
825
762
|
turnId: fixture.turnId,
|
|
826
|
-
/** @public */
|
|
827
763
|
artifact: running ? null : { kind: "turn_result" as const, turnRecordId: turnId },
|
|
828
764
|
});
|
|
829
765
|
});
|
|
@@ -834,7 +770,7 @@ export async function createExtensionIntegrationHarness(
|
|
|
834
770
|
/** Wait with a bounded deadline and final observations on failure. @public */
|
|
835
771
|
waitFor,
|
|
836
772
|
/** Execute one selected worker turn; resolves after durable completion or failure. @public */
|
|
837
|
-
async runTurn(script
|
|
773
|
+
async runTurn(script = { tools: [] }) {
|
|
838
774
|
if (!manual) throw new Error("runTurn requires manual execution mode");
|
|
839
775
|
if (executing.has(id)) throw new Error(`A turn is already running for '${id}'`);
|
|
840
776
|
const before = snapshot();
|
|
@@ -871,22 +807,16 @@ export async function createExtensionIntegrationHarness(
|
|
|
871
807
|
? context().deps.turnAnnotations.findByKey(id, `turn_milestone:${record.id}`)
|
|
872
808
|
: null;
|
|
873
809
|
return observe({
|
|
874
|
-
/** @public */
|
|
875
810
|
turn: record ?? null,
|
|
876
|
-
/** @public */
|
|
877
811
|
outcome:
|
|
878
812
|
typeof milestone?.payload.outcome === "string" ? milestone.payload.outcome : null,
|
|
879
|
-
/** @public */
|
|
880
813
|
failure:
|
|
881
814
|
record?.errorSummary ??
|
|
882
815
|
(after.process.lifecycleStatus === "error"
|
|
883
816
|
? "Worker start failed before acceptance"
|
|
884
817
|
: null),
|
|
885
|
-
/** @public */
|
|
886
818
|
prompts: observations.get(id)?.prompts ?? [],
|
|
887
|
-
/** @public */
|
|
888
819
|
toolResults: observations.get(id)?.toolResults ?? [],
|
|
889
|
-
/** @public */
|
|
890
820
|
result:
|
|
891
821
|
record?.status === "succeeded" && record.turnResultMarkdown
|
|
892
822
|
? { kind: "turn_result" as const, turnRecordId: record.id }
|
|
@@ -899,12 +829,12 @@ export async function createExtensionIntegrationHarness(
|
|
|
899
829
|
}
|
|
900
830
|
},
|
|
901
831
|
/** Execute an application action. @public */
|
|
902
|
-
action: (actionId
|
|
832
|
+
action: (actionId, input = {}) =>
|
|
903
833
|
post(`${prefix}/actions/${encodeURIComponent(actionId)}`, { input }),
|
|
904
834
|
/** Retry the failed execution through the application command. @public */
|
|
905
835
|
retry: () => post(`${prefix}/retry`),
|
|
906
836
|
/** Queue an instruction using the application command and normal delivery. @public */
|
|
907
|
-
async supplyInput(input
|
|
837
|
+
async supplyInput(input) {
|
|
908
838
|
const result = await context().deps.processEngine.queueInputs(id, [
|
|
909
839
|
{
|
|
910
840
|
source: "app_steer",
|
|
@@ -917,30 +847,13 @@ export async function createExtensionIntegrationHarness(
|
|
|
917
847
|
return snapshot();
|
|
918
848
|
},
|
|
919
849
|
/** Answer an open question request. @public */
|
|
920
|
-
answerQuestions: (
|
|
921
|
-
requestId: string,
|
|
922
|
-
answers: readonly {
|
|
923
|
-
/** @public */
|
|
924
|
-
selectedOptionIds: readonly string[];
|
|
925
|
-
/** @public */
|
|
926
|
-
freeText: string;
|
|
927
|
-
/** @public */
|
|
928
|
-
comment: string;
|
|
929
|
-
}[],
|
|
930
|
-
) =>
|
|
850
|
+
answerQuestions: (requestId, answers) =>
|
|
931
851
|
post(`${prefix}/question-requests/${encodeURIComponent(requestId)}/answers`, {
|
|
932
852
|
draft: answers,
|
|
933
853
|
}),
|
|
934
854
|
/** Resolve an open tool approval. @public */
|
|
935
|
-
respondToApproval: (
|
|
936
|
-
requestId
|
|
937
|
-
response: {
|
|
938
|
-
/** @public */
|
|
939
|
-
action: "accept" | "feedback" | "decline";
|
|
940
|
-
/** @public */
|
|
941
|
-
feedback?: string;
|
|
942
|
-
},
|
|
943
|
-
) => post(`${prefix}/tool-approval-requests/${encodeURIComponent(requestId)}`, response),
|
|
855
|
+
respondToApproval: (requestId, response) =>
|
|
856
|
+
post(`${prefix}/tool-approval-requests/${encodeURIComponent(requestId)}`, response),
|
|
944
857
|
};
|
|
945
858
|
}
|
|
946
859
|
return {
|
|
@@ -951,7 +864,7 @@ export async function createExtensionIntegrationHarness(
|
|
|
951
864
|
/** Get a handle that remains valid across restart. @public */
|
|
952
865
|
process: processHandle,
|
|
953
866
|
/** Admit work through a registered UI launcher. @public */
|
|
954
|
-
async launch(id
|
|
867
|
+
async launch(id, input) {
|
|
955
868
|
const response = await postImmediateLaunch(context().config.server.base_url, id, {
|
|
956
869
|
launcherInput: input,
|
|
957
870
|
});
|
|
@@ -961,13 +874,7 @@ export async function createExtensionIntegrationHarness(
|
|
|
961
874
|
return processHandle(body.process.id);
|
|
962
875
|
},
|
|
963
876
|
/** Create validated business data and start an active position through the engine. @public */
|
|
964
|
-
async createProcess
|
|
965
|
-
definition: ExtensionProcessDefinition<TParams, TState>,
|
|
966
|
-
input: Omit<ProcessFixtureOptions<TParams, TState>, "id" | "processId"> & {
|
|
967
|
-
/** @public */
|
|
968
|
-
projects?: readonly ProcessProject[];
|
|
969
|
-
} = {},
|
|
970
|
-
) {
|
|
877
|
+
async createProcess(definition, input = {}) {
|
|
971
878
|
if (catalog.processes.get(definition.id) !== definition)
|
|
972
879
|
throw new Error(`Process '${definition.id}' must be registered by an extension`);
|
|
973
880
|
const fixture = createProcessFixture(input, definition);
|
|
@@ -48,19 +48,13 @@ export interface QuestionRequestFixture {
|
|
|
48
48
|
/** Question content with generated stable option identities. @public */
|
|
49
49
|
export interface QuestionFixtureOptions {
|
|
50
50
|
/** @public */
|
|
51
|
-
|
|
52
51
|
question?: string;
|
|
53
|
-
|
|
54
52
|
/** @public */
|
|
55
|
-
|
|
56
53
|
selection?: "single" | "multiple";
|
|
57
|
-
|
|
58
54
|
/** @public */
|
|
59
|
-
|
|
60
55
|
options?: readonly {
|
|
61
56
|
/** @public */
|
|
62
57
|
label: string;
|
|
63
|
-
|
|
64
58
|
/** @public */
|
|
65
59
|
details?: string | null;
|
|
66
60
|
}[];
|
|
@@ -86,13 +80,9 @@ export type QuestionFixtureResolution =
|
|
|
86
80
|
| {
|
|
87
81
|
/** @public */
|
|
88
82
|
status: "answered";
|
|
89
|
-
|
|
90
83
|
/** @public */
|
|
91
|
-
|
|
92
84
|
answers: readonly string[];
|
|
93
|
-
|
|
94
85
|
/** @public */
|
|
95
|
-
|
|
96
86
|
actor?: Actor;
|
|
97
87
|
}
|
|
98
88
|
| {
|
|
@@ -103,32 +93,22 @@ export type QuestionFixtureResolution =
|
|
|
103
93
|
/** Reference inputs and question content, without durable status overrides. @public */
|
|
104
94
|
export interface QuestionRequestFixtureOptions {
|
|
105
95
|
/** @public */
|
|
106
|
-
|
|
107
96
|
id?: string;
|
|
108
|
-
|
|
109
97
|
/** @public */
|
|
110
|
-
|
|
111
98
|
process?: {
|
|
112
99
|
/** @public */
|
|
113
100
|
id: string;
|
|
114
101
|
};
|
|
115
|
-
|
|
116
102
|
/** @public */
|
|
117
|
-
|
|
118
103
|
turn?: {
|
|
119
104
|
/** @public */
|
|
120
105
|
id: string;
|
|
121
|
-
|
|
122
106
|
/** @public */
|
|
123
107
|
instanceId: string;
|
|
124
108
|
};
|
|
125
|
-
|
|
126
109
|
/** @public */
|
|
127
|
-
|
|
128
110
|
questions?: readonly QuestionFixtureOptions[];
|
|
129
|
-
|
|
130
111
|
/** @public */
|
|
131
|
-
|
|
132
112
|
resolution?: QuestionFixtureResolution;
|
|
133
113
|
}
|
|
134
114
|
|
|
@@ -65,6 +65,19 @@ export interface StubToolCallScriptResolverContext {
|
|
|
65
65
|
tools: readonly PiCustomTool[];
|
|
66
66
|
/** @public */
|
|
67
67
|
instanceId?: string;
|
|
68
|
+
/** Active frozen item when the turn is one item of a mapped LLM turn. @public */
|
|
69
|
+
iteration?: {
|
|
70
|
+
/** @public */
|
|
71
|
+
itemKey: string;
|
|
72
|
+
/** @public */
|
|
73
|
+
itemLabel: string;
|
|
74
|
+
/** @public */
|
|
75
|
+
itemIndex: number;
|
|
76
|
+
/** @public */
|
|
77
|
+
itemCount: number;
|
|
78
|
+
/** @public */
|
|
79
|
+
item: unknown;
|
|
80
|
+
};
|
|
68
81
|
/** @public */
|
|
69
82
|
workspaceRoot?: string;
|
|
70
83
|
/** @public */
|
|
@@ -952,6 +965,7 @@ export class StubPiTreeHandleFactory implements PiTreeHandleFactory {
|
|
|
952
965
|
this.toolCallScriptResolver?.({
|
|
953
966
|
...context,
|
|
954
967
|
instanceId: opts.instanceId,
|
|
968
|
+
...(opts.iteration ? { iteration: opts.iteration } : {}),
|
|
955
969
|
workspaceRoot: opts.workspaceRoot,
|
|
956
970
|
sessionCwd: opts.sessionCwd,
|
|
957
971
|
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/worker-testing/stub-pi-tree-handle.ts","../src/worker-testing/schema-driven-stub-pi.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { CURRENT_SESSION_VERSION, type SessionHeader } from \"@earendil-works/pi-coding-agent\";\nimport type {\n\tPiCustomMessageInput,\n\tPiCustomTool,\n\tPiEvent,\n\tPiEventHandler,\n\tPiPromptOptions,\n\tPiRunDetails,\n\tPiSessionDiagnostic,\n\tPiSessionDiagnosticHandler,\n\tPiTreeEntry,\n\tPiTreeHandle,\n\tPiTreeNode,\n\tPiTurnExecutionResult,\n} from \"@leitwerk-dev/process-sdk\";\nimport { isEnoent } from \"@leitwerk-dev/process-sdk\";\nimport type {\n\tPiManagedBootstrapOptions,\n\tPiManagedBootstrapResult,\n\tPiTreeHandleFactory,\n\tPiTreeHandleOptions,\n\tPiTreePlanningOptions,\n\tPiTreePlanningSnapshot,\n} from \"@leitwerk-dev/worker\";\n\n/** @public */\nexport interface StubToolCallScriptCall {\n\t/** @public */\n\ttoolName: string;\n\t/** @public */\n\targs: Record<string, unknown>;\n\t/** @internal */\n\tintermediateEntryCount?: number;\n}\n\n/** @public */\nexport type StubToolCallScriptItem =\n\t| StubToolCallScriptCall\n\t| {\n\t\t\t/** @public */\n\t\t\tcalls: readonly StubToolCallScriptCall[];\n\t\t\t/** @public */\n\t\t\ttextChunks?: readonly string[];\n\t\t\t/** @public */\n\t\t\tthinkingChunks?: readonly string[];\n\t\t\t/** @public */\n\t\t\tchunkDelayMs?: number;\n\t\t\t/** Optional scripted model reaction to a tool result, within the same turn. @internal */\n\t\t\tafterToolResult?: (\n\t\t\t\tcall: StubToolCallScriptCall,\n\t\t\t\tresult: unknown,\n\t\t\t) => StubToolCallScriptCall | undefined;\n\t };\n\n/** @public */\nexport interface StubToolCallScriptResolverContext {\n\t/** @public */\n\tpromptText: string;\n\t/** Identified turn prompt, when the SDK prompt uses a custom message. @internal */\n\tidentifiedPromptText?: string;\n\t/** @public */\n\ttools: readonly PiCustomTool[];\n\t/** @public */\n\tinstanceId?: string;\n\t/** @public */\n\tworkspaceRoot?: string;\n\t/** @public */\n\tsessionCwd?: string;\n\t/** @public */\n\ttreeFile: string;\n\t/** @internal */\n\tturnSequence: number;\n}\n\n/** @public */\nexport type StubToolCallScriptResolver = (\n\tcontext: StubToolCallScriptResolverContext,\n) => StubToolCallScriptItem | undefined | Promise<StubToolCallScriptItem | undefined>;\n\nfunction stringifyToolResult(result: unknown): string {\n\tif (typeof result === \"string\") {\n\t\treturn result;\n\t}\n\tif (result === undefined) {\n\t\treturn \"ok\";\n\t}\n\ttry {\n\t\treturn JSON.stringify(result, null, 2);\n\t} catch {\n\t\treturn String(result);\n\t}\n}\n\nfunction expandStubToolCallScriptItem(item: StubToolCallScriptItem): StubToolCallScriptCall[] {\n\tif (\"calls\" in item) {\n\t\treturn [...item.calls];\n\t}\n\treturn [item];\n}\n\nfunction stubToolCallId(turnSeq: number, totalCalls: number, index: number): string {\n\tif (totalCalls <= 1) {\n\t\treturn `tool-${turnSeq}`;\n\t}\n\treturn `tool-${turnSeq}-${index + 1}`;\n}\n\n/** @internal */\ninterface StubPiTreeState {\n\t/** @internal */\n\theader?: SessionHeader;\n\t/** @internal */\n\tturnSeq: number;\n\t/** @internal */\n\tcurrentLeafId: string | null;\n\t/** @internal */\n\tentries: Map<string, PiTreeEntry>;\n\t/** @internal */\n\tchildIdsByParent: Map<string | null, string[]>;\n}\n\ninterface PersistedStubPiTreeState {\n\tturnSeq: number;\n\tcurrentLeafId: string | null;\n\tentries: PiTreeEntry[];\n\tchildIdsByParent: Array<{ parentId: string | null; childIds: string[] }>;\n}\n\nfunction createEmptyStubPiTreeState(): StubPiTreeState {\n\treturn {\n\t\tturnSeq: 0,\n\t\tcurrentLeafId: null,\n\t\tentries: new Map<string, PiTreeEntry>(),\n\t\tchildIdsByParent: new Map<string | null, string[]>(),\n\t};\n}\n\nfunction indexStubEntry(state: StubPiTreeState, entry: PiTreeEntry): void {\n\tstate.entries.set(entry.id, entry);\n\tconst siblings = state.childIdsByParent.get(entry.parentId) ?? [];\n\tsiblings.push(entry.id);\n\tstate.childIdsByParent.set(entry.parentId, siblings);\n}\n\nfunction deriveStubLeafIdFromEntries(state: StubPiTreeState): string | null {\n\tlet leafId: string | null = null;\n\tfor (const entryId of state.entries.keys()) {\n\t\tleafId = entryId;\n\t}\n\treturn leafId;\n}\n\nfunction serializeStubPiTreeState(state: StubPiTreeState, recordSessionTrace: boolean): string {\n\tif (recordSessionTrace) {\n\t\treturn `${[\n\t\t\tJSON.stringify({\n\t\t\t\t...state.header,\n\t\t\t\tstubState: { turnSeq: state.turnSeq, currentLeafId: state.currentLeafId },\n\t\t\t}),\n\t\t\t...[...state.entries.values()].map((entry) => JSON.stringify(entry)),\n\t\t].join(\"\\n\")}\\n`;\n\t}\n\tconst persisted: PersistedStubPiTreeState = {\n\t\tturnSeq: state.turnSeq,\n\t\tcurrentLeafId: state.currentLeafId,\n\t\tentries: [...state.entries.values()],\n\t\tchildIdsByParent: [...state.childIdsByParent.entries()].map(([parentId, childIds]) => ({\n\t\t\tparentId,\n\t\t\tchildIds: [...childIds],\n\t\t})),\n\t};\n\treturn JSON.stringify(persisted);\n}\n\nfunction deserializeStubPiTreeState(value: string): StubPiTreeState {\n\tconst lines = value.trim().split(\"\\n\");\n\tconst header = JSON.parse(lines[0]) as SessionHeader & {\n\t\tstubState?: { turnSeq: number; currentLeafId: string | null };\n\t};\n\tif (header.type === \"session\") {\n\t\tconst entries = lines\n\t\t\t.slice(1)\n\t\t\t.filter(Boolean)\n\t\t\t.map((line) => JSON.parse(line) as PiTreeEntry);\n\t\tconst state = createEmptyStubPiTreeState();\n\t\tstate.header = header;\n\t\tstate.turnSeq = header.stubState?.turnSeq ?? 0;\n\t\tstate.currentLeafId = header.stubState?.currentLeafId ?? null;\n\t\tfor (const entry of entries) indexStubEntry(state, entry);\n\t\treturn state;\n\t}\n\tconst parsed = JSON.parse(value) as PersistedStubPiTreeState;\n\treturn {\n\t\tturnSeq: typeof parsed.turnSeq === \"number\" ? parsed.turnSeq : 0,\n\t\tcurrentLeafId:\n\t\t\ttypeof parsed.currentLeafId === \"string\" || parsed.currentLeafId === null\n\t\t\t\t? parsed.currentLeafId\n\t\t\t\t: null,\n\t\tentries: new Map((parsed.entries ?? []).map((entry) => [entry.id, entry])),\n\t\tchildIdsByParent: new Map(\n\t\t\t(parsed.childIdsByParent ?? []).map((entry) => [entry.parentId, [...entry.childIds]]),\n\t\t),\n\t};\n}\n\n/** @public */\nexport class StubPiTreeHandle implements PiTreeHandle {\n\t/** @public */\n\treadonly sessionId: string;\n\t/** @internal */\n\treadonly treeFile: string;\n\t/** @internal */\n\treadonly isResumed: boolean;\n\n\t/** @internal */\n\treadonly prompts: string[] = [];\n\t/** @internal */\n\treadonly steers: string[] = [];\n\t/** @internal */\n\tbeforeTurn?: (\n\t\tkind: \"prompt\" | \"literal\" | \"custom\" | \"continue\",\n\t\toptions: PiPromptOptions | undefined,\n\t\tpromptText: string | undefined,\n\t) => boolean | undefined | Promise<boolean | undefined>;\n\n\tprivate _closed = false;\n\tprivate turnAbort = new AbortController();\n\tprivate branchDriftPending = false;\n\tprivate readonly handlers = new Set<PiEventHandler>();\n\tprivate readonly diagnosticHandlers = new Set<PiSessionDiagnosticHandler>();\n\tprivate readonly toolCallScriptResolver?: StubToolCallScriptResolver;\n\tprivate readonly state: StubPiTreeState;\n\tprivate readonly runDetails: PiRunDetails;\n\tprivate readonly persistState?: (() => Promise<void>) | undefined;\n\tprivate readonly recordSessionTrace: boolean;\n\n\t/** @internal */\n\tconstructor(options: {\n\t\t/** @internal */\n\t\tsessionId: string;\n\t\t/** @internal */\n\t\ttreeFile: string;\n\t\t/** @internal */\n\t\tisResumed: boolean;\n\t\t/** @internal */\n\t\ttoolCallScriptResolver?: StubToolCallScriptResolver;\n\t\t/** @internal */\n\t\tstate?: StubPiTreeState;\n\t\t/** @internal */\n\t\trunDetails?: Partial<PiRunDetails>;\n\t\t/** @internal */\n\t\tpersistState?: () => Promise<void>;\n\t\t/** @internal */\n\t\trecordSessionTrace?: boolean;\n\t}) {\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.treeFile = options.treeFile;\n\t\tthis.isResumed = options.isResumed;\n\t\tthis.toolCallScriptResolver = options.toolCallScriptResolver;\n\t\tthis.state = options.state ?? createEmptyStubPiTreeState();\n\t\tthis.persistState = options.persistState;\n\t\tthis.recordSessionTrace = options.recordSessionTrace ?? false;\n\t\tthis.runDetails = {\n\t\t\tloadedAgentsFiles: options.runDetails?.loadedAgentsFiles?.map((file) => ({ ...file })) ?? [],\n\t\t\tloadedSkills: options.runDetails?.loadedSkills?.map((skill) => ({ ...skill })) ?? [],\n\t\t\tavailableToolNames: [...(options.runDetails?.availableToolNames ?? [])],\n\t\t};\n\t}\n\n\t/** @internal */\n\tget closed(): boolean {\n\t\treturn this._closed;\n\t}\n\n\t/** @internal */\n\tfailNextTurnWithBranchDrift(): void {\n\t\tthis.branchDriftPending = true;\n\t}\n\n\tprivate assertOpen(): void {\n\t\tif (this._closed) {\n\t\t\tthrow new Error(\"Handle is closed\");\n\t\t}\n\t}\n\n\tprivate addEntry(entry: PiTreeEntry): void {\n\t\tindexStubEntry(this.state, entry);\n\t\tthis.state.currentLeafId = entry.id;\n\t}\n\n\tprivate createMessageEntry(\n\t\tid: string,\n\t\tparentId: string | null,\n\t\trole: \"user\" | \"assistant\",\n\t\tcontent: unknown,\n\t\ttimestamp: string,\n\t): PiTreeEntry {\n\t\treturn {\n\t\t\tid,\n\t\t\tparentId,\n\t\t\ttype: \"message\",\n\t\t\ttimestamp,\n\t\t\tmessage: {\n\t\t\t\trole,\n\t\t\t\tcontent,\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate emitEvent(event: PiEvent): void {\n\t\tfor (const handler of this.handlers) {\n\t\t\thandler(event);\n\t\t}\n\t}\n\n\t/** @internal */\n\tgetRunDetails(): PiRunDetails {\n\t\treturn {\n\t\t\tloadedAgentsFiles: this.runDetails.loadedAgentsFiles.map((file) => ({ ...file })),\n\t\t\tloadedSkills: this.runDetails.loadedSkills.map((skill) => ({ ...skill })),\n\t\t\tavailableToolNames: [...this.runDetails.availableToolNames],\n\t\t};\n\t}\n\n\t/** @internal */\n\tgetLeafId(): string | null {\n\t\treturn this.state.currentLeafId;\n\t}\n\n\t/** @internal */\n\tgetEntry(id: string): PiTreeEntry | undefined {\n\t\treturn this.state.entries.get(id);\n\t}\n\n\t/** @public */\n\tgetBranch(fromId: string | undefined = this.state.currentLeafId ?? undefined): PiTreeEntry[] {\n\t\tif (!fromId) {\n\t\t\treturn [];\n\t\t}\n\t\tconst branch: PiTreeEntry[] = [];\n\t\tlet currentId: string | null = fromId;\n\t\twhile (currentId) {\n\t\t\tconst entry = this.state.entries.get(currentId);\n\t\t\tif (!entry) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbranch.push(entry);\n\t\t\tcurrentId = entry.parentId;\n\t\t}\n\t\tbranch.reverse();\n\t\treturn branch;\n\t}\n\n\t/** @internal */\n\tgetChildren(parentId: string): PiTreeEntry[] {\n\t\treturn (this.state.childIdsByParent.get(parentId) ?? [])\n\t\t\t.map((childId) => this.state.entries.get(childId))\n\t\t\t.filter((entry): entry is PiTreeEntry => entry !== undefined);\n\t}\n\n\t/** @internal */\n\tgetTree(): PiTreeNode[] {\n\t\tconst buildNode = (entry: PiTreeEntry): PiTreeNode => ({\n\t\t\tentry,\n\t\t\tchildren: this.getChildren(entry.id).map(buildNode),\n\t\t});\n\t\treturn (this.state.childIdsByParent.get(null) ?? [])\n\t\t\t.map((entryId) => this.state.entries.get(entryId))\n\t\t\t.filter((entry): entry is PiTreeEntry => entry !== undefined)\n\t\t\t.map(buildNode);\n\t}\n\n\t/** @internal */\n\tasync branch(entryId: string): Promise<void> {\n\t\tthis.assertOpen();\n\t\tif (!this.state.entries.has(entryId)) {\n\t\t\tthrow new Error(`Unknown Pi entry '${entryId}'`);\n\t\t}\n\t\tthis.state.currentLeafId = entryId;\n\t\tawait this.persistState?.();\n\t}\n\n\t/** @internal */\n\tasync branchFromRoot(): Promise<void> {\n\t\tthis.assertOpen();\n\t\tthis.state.currentLeafId = null;\n\t\tawait this.persistState?.();\n\t}\n\n\t/** @internal */\n\tasync resetLeaf(): Promise<void> {\n\t\tawait this.branchFromRoot();\n\t}\n\n\t/** @internal */\n\tasync compact(\n\t\t_customInstructions?: string,\n\t\tdetails?: unknown,\n\t): Promise<{\n\t\t/** @internal */\n\t\tsummary: string;\n\t}> {\n\t\tthis.assertOpen();\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst compactionEntryId = `compaction-${++this.state.turnSeq}`;\n\t\tthis.addEntry({\n\t\t\tid: compactionEntryId,\n\t\t\tparentId: this.state.currentLeafId,\n\t\t\ttype: \"compaction\",\n\t\t\ttimestamp,\n\t\t\tdetails,\n\t\t});\n\t\tawait this.persistState?.();\n\t\treturn { summary: \"Stub compaction\" };\n\t}\n\n\tprivate async executeTurn(input: {\n\t\tkind: \"prompt\" | \"literal\" | \"custom\" | \"continue\";\n\t\tpromptText?: string;\n\t\tscriptPromptText?: string;\n\t\toptions?: PiPromptOptions;\n\t\tappendPromptUserMessage: boolean;\n\t}): Promise<PiTurnExecutionResult> {\n\t\tthis.assertOpen();\n\t\tthis.turnAbort = new AbortController();\n\t\tconst signal = this.turnAbort.signal;\n\t\tif ((await this.beforeTurn?.(input.kind, input.options, input.promptText)) === false) {\n\t\t\tinput.options = undefined;\n\t\t}\n\t\tsignal.throwIfAborted();\n\t\tif (this.branchDriftPending) {\n\t\t\tthis.branchDriftPending = false;\n\t\t\tthrow Object.assign(new Error(\"stubbed Pi branch drift\"), {\n\t\t\t\tname: \"PiBranchDriftError\",\n\t\t\t\tfailureCode: \"branch_drift\",\n\t\t\t\ttoTurnFailureOptions: () => ({\n\t\t\t\t\tfailureCode: \"branch_drift\",\n\t\t\t\t\tfailureDetails: { operation: input.kind },\n\t\t\t\t\trecoveryContext: null,\n\t\t\t\t\trestorePrimaryLeaf: false,\n\t\t\t\t}),\n\t\t\t});\n\t\t}\n\t\tif (input.promptText !== undefined) {\n\t\t\tthis.prompts.push(input.promptText);\n\t\t}\n\t\tconst startLeafId = this.state.currentLeafId;\n\t\tconst turnId = `turn-${++this.state.turnSeq}`;\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst createdEntryIds: string[] = [];\n\t\tif (input.appendPromptUserMessage) {\n\t\t\tconst userEntryId = `user-${this.state.turnSeq}`;\n\t\t\tthis.addEntry(\n\t\t\t\tthis.createMessageEntry(\n\t\t\t\t\tuserEntryId,\n\t\t\t\t\tthis.state.currentLeafId,\n\t\t\t\t\t\"user\",\n\t\t\t\t\tinput.promptText ?? \"\",\n\t\t\t\t\ttimestamp,\n\t\t\t\t),\n\t\t\t);\n\t\t\tcreatedEntryIds.push(userEntryId);\n\t\t}\n\t\tawait this.persistState?.();\n\t\tsignal.throwIfAborted();\n\t\tthis.emitEvent({ type: \"turn.start\", turnId, data: {}, timestamp });\n\n\t\tconst tools = new Map((input.options?.tools ?? []).map((tool) => [tool.name, tool]));\n\t\tlet assistantContent = input.promptText ?? \"Continued.\";\n\t\tlet assistantContentFromScriptedMarkdown = false;\n\t\tconst scriptedItem = await this.toolCallScriptResolver?.({\n\t\t\ttreeFile: this.treeFile,\n\t\t\tturnSequence: this.state.turnSeq,\n\t\t\tpromptText: input.promptText ?? \"\",\n\t\t\tidentifiedPromptText: input.scriptPromptText,\n\t\t\ttools: input.options?.tools ?? [],\n\t\t});\n\t\tsignal.throwIfAborted();\n\t\tconst hasScriptedChunks = Boolean(\n\t\t\tscriptedItem &&\n\t\t\t\t\"calls\" in scriptedItem &&\n\t\t\t\t(scriptedItem.textChunks?.length ?? 0) + (scriptedItem.thinkingChunks?.length ?? 0),\n\t\t);\n\t\tif (hasScriptedChunks) assistantContent = \"\";\n\t\tif (scriptedItem && \"calls\" in scriptedItem) {\n\t\t\tconst streamed = { thinking: \"\", text: \"\" };\n\t\t\tconst streamEntryId = `stream-${this.state.turnSeq}`;\n\t\t\tconst streamParentId = this.state.currentLeafId;\n\t\t\tconst chunks = [\n\t\t\t\t...(scriptedItem.thinkingChunks ?? []).map((text) => ({\n\t\t\t\t\ttext,\n\t\t\t\t\tstreamType: \"thinking\" as const,\n\t\t\t\t})),\n\t\t\t\t...(scriptedItem.textChunks ?? []).map((text) => ({ text, streamType: \"text\" as const })),\n\t\t\t];\n\t\t\tfor (const { text, streamType } of chunks) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tstreamed[streamType] += text;\n\t\t\t\tassistantContent = streamed.text;\n\t\t\t\tif (this.recordSessionTrace) {\n\t\t\t\t\tconst entry = this.createMessageEntry(\n\t\t\t\t\t\tstreamEntryId,\n\t\t\t\t\t\tstreamParentId,\n\t\t\t\t\t\t\"assistant\",\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t...(streamed.thinking ? [{ type: \"thinking\", thinking: streamed.thinking }] : []),\n\t\t\t\t\t\t\t...(streamed.text ? [{ type: \"text\", text: streamed.text }] : []),\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t);\n\t\t\t\t\tif (this.state.entries.has(streamEntryId)) this.state.entries.set(streamEntryId, entry);\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.addEntry(entry);\n\t\t\t\t\t\tcreatedEntryIds.push(streamEntryId);\n\t\t\t\t\t}\n\t\t\t\t\tawait this.persistState?.();\n\t\t\t\t}\n\t\t\t\tthis.emitEvent({\n\t\t\t\t\ttype: \"stream.delta\",\n\t\t\t\t\tturnId,\n\t\t\t\t\tdata: { text, streamType },\n\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t});\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tif (scriptedItem.chunkDelayMs)\n\t\t\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", abort);\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t}, scriptedItem.chunkDelayMs);\n\t\t\t\t\t\tconst abort = () => {\n\t\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t\t\treject(signal.reason);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsignal.addEventListener(\"abort\", abort, { once: true });\n\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tconst scriptedCalls = scriptedItem ? expandStubToolCallScriptItem(scriptedItem) : [];\n\t\tif (scriptedCalls.length > 0) {\n\t\t\tfor (const [callIndex, scriptedCall] of scriptedCalls.entries()) {\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t\tconst toolCallId = stubToolCallId(this.state.turnSeq, scriptedCalls.length, callIndex);\n\t\t\t\tthis.emitEvent({\n\t\t\t\t\ttype: \"tool.call\",\n\t\t\t\t\tturnId,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\tname: scriptedCall.toolName,\n\t\t\t\t\t\targuments: scriptedCall.args,\n\t\t\t\t\t},\n\t\t\t\t\ttimestamp,\n\t\t\t\t});\n\t\t\t\tconst tool = tools.get(scriptedCall.toolName);\n\t\t\t\tif (!tool && scriptedCall.toolName === \"markdown_result\") {\n\t\t\t\t\tconst markdown = (scriptedCall.args as { markdown?: unknown }).markdown;\n\t\t\t\t\tif (typeof markdown === \"string\") {\n\t\t\t\t\t\tassistantContent = markdown;\n\t\t\t\t\t\tassistantContentFromScriptedMarkdown = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (tool) {\n\t\t\t\t\tif (this.recordSessionTrace) {\n\t\t\t\t\t\tconst entryId = `call-${toolCallId}`;\n\t\t\t\t\t\tthis.addEntry(\n\t\t\t\t\t\t\tthis.createMessageEntry(\n\t\t\t\t\t\t\t\tentryId,\n\t\t\t\t\t\t\t\tthis.state.currentLeafId,\n\t\t\t\t\t\t\t\t\"assistant\",\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: \"toolCall\",\n\t\t\t\t\t\t\t\t\t\tid: toolCallId,\n\t\t\t\t\t\t\t\t\t\tname: scriptedCall.toolName,\n\t\t\t\t\t\t\t\t\t\targuments: scriptedCall.args,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tnew Date().toISOString(),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tcreatedEntryIds.push(entryId);\n\t\t\t\t\t\tawait this.persistState?.();\n\t\t\t\t\t}\n\t\t\t\t\tconst recordToolResult = async (result: unknown, isError: boolean) => {\n\t\t\t\t\t\tif (!this.recordSessionTrace) return;\n\t\t\t\t\t\tconst entryId = `result-${toolCallId}`;\n\t\t\t\t\t\tconst entry = {\n\t\t\t\t\t\t\tid: entryId,\n\t\t\t\t\t\t\tparentId: this.state.currentLeafId,\n\t\t\t\t\t\t\ttype: \"message\",\n\t\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t\t\tmessage: {\n\t\t\t\t\t\t\t\trole: \"toolResult\",\n\t\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\t\ttoolName: scriptedCall.toolName,\n\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: stringifyToolResult(result) }],\n\t\t\t\t\t\t\t\tisError,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tthis.addEntry(entry);\n\t\t\t\t\t\tcreatedEntryIds.push(entryId);\n\t\t\t\t\t\tawait this.persistState?.();\n\t\t\t\t\t};\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\t\tconst blocked = input.options?.shouldBlockToolCall?.(scriptedCall.toolName);\n\t\t\t\t\t\tif (blocked) throw new Error(blocked);\n\t\t\t\t\t\tconst result = await tool.execute(scriptedCall.args, {\n\t\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\tsuspendPromptGuards: input.options?.suspendPromptGuards,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\t\tif (!assistantContentFromScriptedMarkdown) {\n\t\t\t\t\t\t\tassistantContent = stringifyToolResult(result);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait recordToolResult(result, false);\n\t\t\t\t\t\tconst followUp =\n\t\t\t\t\t\t\tscriptedItem && \"calls\" in scriptedItem\n\t\t\t\t\t\t\t\t? scriptedItem.afterToolResult?.(scriptedCall, result)\n\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\tif (followUp) scriptedCalls.push(followUp);\n\t\t\t\t\t\tthis.emitEvent({\n\t\t\t\t\t\t\ttype: \"tool.result\",\n\t\t\t\t\t\t\tturnId,\n\t\t\t\t\t\t\tdata: { toolCallId, name: scriptedCall.toolName, result },\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tawait recordToolResult(error instanceof Error ? error.message : String(error), true);\n\t\t\t\t\t\tthis.emitEvent({\n\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\tturnId,\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\t\t\ttoolName: scriptedCall.toolName,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (let i = 0; i < (scriptedCall.intermediateEntryCount ?? 0); i++) {\n\t\t\t\t\tconst intermediateEntryId =\n\t\t\t\t\t\tscriptedCalls.length === 1\n\t\t\t\t\t\t\t? `intermediate-${this.state.turnSeq}-${i + 1}`\n\t\t\t\t\t\t\t: `intermediate-${this.state.turnSeq}-${callIndex + 1}-${i + 1}`;\n\t\t\t\t\tthis.addEntry(\n\t\t\t\t\t\tthis.createMessageEntry(\n\t\t\t\t\t\t\tintermediateEntryId,\n\t\t\t\t\t\t\tthis.state.currentLeafId,\n\t\t\t\t\t\t\t\"assistant\",\n\t\t\t\t\t\t\t`Intermediate entry ${i + 1}`,\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tcreatedEntryIds.push(intermediateEntryId);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (tools.size > 0 && !hasScriptedChunks) {\n\t\t\tthrow new Error(\n\t\t\t\t`Stub Pi prompt requires a stub tool-call script when tools are provided (${[...tools.keys()].join(\", \")})`,\n\t\t\t);\n\t\t} else if (input.promptText !== undefined && !hasScriptedChunks) {\n\t\t\tthis.emitEvent({\n\t\t\t\ttype: \"stream.delta\",\n\t\t\t\tturnId,\n\t\t\t\tdata: { text: input.promptText },\n\t\t\t\ttimestamp,\n\t\t\t});\n\t\t}\n\n\t\tsignal.throwIfAborted();\n\t\t// Keep the result entry ID without repeating content already saved in the stream entry.\n\t\tthis.addEntry(\n\t\t\tthis.createMessageEntry(\n\t\t\t\tturnId,\n\t\t\t\tthis.state.currentLeafId,\n\t\t\t\t\"assistant\",\n\t\t\t\tthis.recordSessionTrace && hasScriptedChunks && scriptedCalls.length === 0\n\t\t\t\t\t? []\n\t\t\t\t\t: assistantContent,\n\t\t\t\ttimestamp,\n\t\t\t),\n\t\t);\n\t\tcreatedEntryIds.push(turnId);\n\t\tawait this.persistState?.();\n\t\tsignal.throwIfAborted();\n\t\tthis.emitEvent({ type: \"turn.end\", turnId, data: {}, timestamp });\n\t\tconst resultEntryId = this.state.currentLeafId;\n\t\tif (!resultEntryId) {\n\t\t\tthrow new Error(\n\t\t\t\tinput.appendPromptUserMessage\n\t\t\t\t\t? \"Stub Pi prompt completed without an active leaf\"\n\t\t\t\t\t: \"Stub Pi continuation completed without an active leaf\",\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tstartLeafId,\n\t\t\tendLeafId: resultEntryId,\n\t\t\tcreatedEntryIds,\n\t\t\tresultEntryId,\n\t\t\tassistantMarkdown: assistantContent,\n\t\t};\n\t}\n\n\t/** @internal */\n\tasync prompt(text: string, options: PiPromptOptions = {}): Promise<PiTurnExecutionResult> {\n\t\treturn await this.executeTurn({\n\t\t\tkind: \"prompt\",\n\t\t\tpromptText: text,\n\t\t\toptions,\n\t\t\tappendPromptUserMessage: true,\n\t\t});\n\t}\n\n\t/** @internal */\n\tasync promptLiteral(text: string, options: PiPromptOptions = {}): Promise<PiTurnExecutionResult> {\n\t\treturn await this.executeTurn({\n\t\t\tkind: \"literal\",\n\t\t\tpromptText: text,\n\t\t\toptions,\n\t\t\tappendPromptUserMessage: true,\n\t\t});\n\t}\n\n\t/** @internal */\n\tasync promptCustom(\n\t\tinput: PiCustomMessageInput,\n\t\toptions: PiPromptOptions = {},\n\t): Promise<PiTurnExecutionResult> {\n\t\tconst startLeafId = this.getLeafId();\n\t\tconst promptEntryId = await this.appendCustomMessage(input);\n\t\tconst result = await this.executeTurn({\n\t\t\tkind: \"custom\",\n\t\t\tscriptPromptText: input.content,\n\t\t\toptions,\n\t\t\tappendPromptUserMessage: false,\n\t\t});\n\t\treturn {\n\t\t\t...result,\n\t\t\tstartLeafId,\n\t\t\tcreatedEntryIds: [promptEntryId, ...result.createdEntryIds],\n\t\t};\n\t}\n\n\t/** @internal */\n\tasync continueTurn(options: PiPromptOptions = {}): Promise<PiTurnExecutionResult> {\n\t\treturn await this.executeTurn({\n\t\t\tkind: \"continue\",\n\t\t\toptions,\n\t\t\tappendPromptUserMessage: false,\n\t\t});\n\t}\n\n\t/** @internal */\n\tasync appendUserMessage(text: string): Promise<string> {\n\t\tthis.assertOpen();\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst userEntryId = `user-${++this.state.turnSeq}`;\n\t\tthis.addEntry(\n\t\t\tthis.createMessageEntry(userEntryId, this.state.currentLeafId, \"user\", text, timestamp),\n\t\t);\n\t\tawait this.persistState?.();\n\t\treturn userEntryId;\n\t}\n\n\t/** @internal */\n\tasync appendCustomMessage(input: PiCustomMessageInput): Promise<string> {\n\t\tthis.assertOpen();\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst entryId = `custom-${++this.state.turnSeq}`;\n\t\tthis.addEntry({\n\t\t\tid: entryId,\n\t\t\tparentId: this.state.currentLeafId,\n\t\t\ttype: \"custom_message\",\n\t\t\ttimestamp,\n\t\t\tcustomType: \"leitwerk\",\n\t\t\tcontent: input.content,\n\t\t\tdetails: input.details,\n\t\t});\n\t\tawait this.persistState?.();\n\t\treturn entryId;\n\t}\n\n\t/** @internal */\n\tasync steer(text: string): Promise<void> {\n\t\tthis.assertOpen();\n\t\tthis.steers.push(text);\n\t}\n\n\t/** @internal */\n\tasync abortTurn(): Promise<void> {\n\t\tthis.assertOpen();\n\t\tthis.turnAbort.abort(new Error(\"Scripted turn aborted\"));\n\t}\n\n\t/** @internal */\n\tsubscribe(handler: PiEventHandler): () => void {\n\t\tthis.handlers.add(handler);\n\t\treturn () => {\n\t\t\tthis.handlers.delete(handler);\n\t\t};\n\t}\n\n\t/** @internal */\n\tsubscribeDiagnostics(handler: PiSessionDiagnosticHandler): () => void {\n\t\tthis.diagnosticHandlers.add(handler);\n\t\treturn () => {\n\t\t\tthis.diagnosticHandlers.delete(handler);\n\t\t};\n\t}\n\n\t/** @internal */\n\temitDiagnostic(diagnostic: PiSessionDiagnostic): void {\n\t\tfor (const handler of this.diagnosticHandlers) handler(diagnostic);\n\t}\n\n\t/** @internal */\n\tasync close(): Promise<void> {\n\t\tthis.turnAbort.abort(new Error(\"Scripted session closed\"));\n\t\tawait this.persistState?.();\n\t\tthis._closed = true;\n\t\tthis.handlers.clear();\n\t\tthis.diagnosticHandlers.clear();\n\t}\n}\n\n/** @public */\nexport interface StubPiTreeHandleFactoryOptions {\n\t/** @public */\n\ttoolCallScriptResolver?: StubToolCallScriptResolver;\n\t/** Persist SDK-readable JSONL with reasoning and tool messages for history/detail tests. @public */\n\trecordSessionTrace?: boolean;\n}\n\n/** @public */\nexport class StubPiTreeHandleFactory implements PiTreeHandleFactory {\n\t/** @public */\n\treadonly sessions: StubPiTreeHandle[] = [];\n\t/** @internal */\n\ttoolCallScriptResolver?: StubToolCallScriptResolver;\n\n\tprivate seq = 0;\n\tprivate readonly treeStateByFile = new Map<string, StubPiTreeState>();\n\tprivate readonly recordSessionTrace: boolean;\n\n\t/** @public */\n\tconstructor(options: StubPiTreeHandleFactoryOptions = {}) {\n\t\tthis.toolCallScriptResolver = options.toolCallScriptResolver;\n\t\tthis.recordSessionTrace = options.recordSessionTrace ?? false;\n\t}\n\n\t/** @internal */\n\tasync prepareManagedBootstrap(\n\t\topts: PiManagedBootstrapOptions,\n\t): Promise<PiManagedBootstrapResult> {\n\t\treturn {\n\t\t\tloadedResourceIds: opts.manifest.provenance.map(\n\t\t\t\t(resource: { snapshotPath: string }) => resource.snapshotPath,\n\t\t\t),\n\t\t\tloadedAgentsFiles: [],\n\t\t\tloadedSkillFiles: [],\n\t\t\tresolvedModel: { ...opts.expectedModel },\n\t\t\tdiagnostics: [],\n\t\t};\n\t}\n\n\t/** @internal */\n\tasync inspectPrimaryTree(opts: PiTreePlanningOptions): Promise<PiTreePlanningSnapshot> {\n\t\tlet treeState = this.treeStateByFile.get(opts.treeFile);\n\t\tif (!treeState) {\n\t\t\ttry {\n\t\t\t\ttreeState = deserializeStubPiTreeState(readFileSync(opts.treeFile, \"utf8\"));\n\t\t\t} catch (error) {\n\t\t\t\tif (isEnoent(error)) {\n\t\t\t\t\treturn { currentLeafId: null, entries: [] };\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tcurrentLeafId: treeState.currentLeafId ?? deriveStubLeafIdFromEntries(treeState),\n\t\t\tentries: [...treeState.entries.values()].map((entry) => ({\n\t\t\t\tid: entry.id,\n\t\t\t\tparentId: entry.parentId,\n\t\t\t})),\n\t\t};\n\t}\n\n\t/** @public */\n\tasync createPrimaryTreeHandle(opts: PiTreeHandleOptions): Promise<PiTreeHandle> {\n\t\tconst persistState = async (state: StubPiTreeState): Promise<void> => {\n\t\t\tthis.treeStateByFile.set(opts.treeFile, state);\n\t\t\ttry {\n\t\t\t\tmkdirSync(path.dirname(opts.treeFile), { recursive: true });\n\t\t\t\twriteFileSync(\n\t\t\t\t\topts.treeFile,\n\t\t\t\t\tserializeStubPiTreeState(state, this.recordSessionTrace),\n\t\t\t\t\t\"utf8\",\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (\n\t\t\t\t\ttypeof error !== \"object\" ||\n\t\t\t\t\terror === null ||\n\t\t\t\t\t!(\"code\" in error) ||\n\t\t\t\t\t![\"ENOENT\", \"EACCES\", \"EROFS\", \"EPERM\"].includes(\n\t\t\t\t\t\tString((error as { code?: unknown }).code),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tlet treeState = this.treeStateByFile.get(opts.treeFile);\n\t\tif (!treeState && opts.resume) {\n\t\t\ttry {\n\t\t\t\tconst persisted = readFileSync(opts.treeFile, \"utf8\");\n\t\t\t\ttreeState = deserializeStubPiTreeState(persisted);\n\t\t\t} catch (error) {\n\t\t\t\tif (\n\t\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\t\"code\" in error &&\n\t\t\t\t\t(error as { code?: unknown }).code !== \"ENOENT\"\n\t\t\t\t) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttreeState ??= createEmptyStubPiTreeState();\n\t\ttreeState.header ??= {\n\t\t\ttype: \"session\",\n\t\t\tversion: CURRENT_SESSION_VERSION,\n\t\t\tid: randomUUID(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tcwd: opts.sessionCwd ?? opts.workspaceRoot ?? path.dirname(opts.treeFile),\n\t\t};\n\t\tif (opts.resume) {\n\t\t\ttreeState.currentLeafId = deriveStubLeafIdFromEntries(treeState);\n\t\t}\n\t\tthis.treeStateByFile.set(opts.treeFile, treeState);\n\t\tconst piHandle = new StubPiTreeHandle({\n\t\t\tsessionId: `stub-${++this.seq}`,\n\t\t\ttreeFile: opts.treeFile,\n\t\t\tisResumed: opts.resume,\n\t\t\ttoolCallScriptResolver: this.toolCallScriptResolver\n\t\t\t\t? (context) =>\n\t\t\t\t\t\tthis.toolCallScriptResolver?.({\n\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\tinstanceId: opts.instanceId,\n\t\t\t\t\t\t\tworkspaceRoot: opts.workspaceRoot,\n\t\t\t\t\t\t\tsessionCwd: opts.sessionCwd,\n\t\t\t\t\t\t})\n\t\t\t\t: undefined,\n\t\t\tstate: treeState,\n\t\t\tpersistState: () => persistState(treeState),\n\t\t\trecordSessionTrace: this.recordSessionTrace,\n\t\t\trunDetails: {\n\t\t\t\tavailableToolNames: opts.piConfig?.availableToolNames ?? [],\n\t\t\t},\n\t\t});\n\t\tthis.sessions.push(piHandle);\n\t\tif (!opts.resume) {\n\t\t\tawait persistState(treeState);\n\t\t}\n\t\treturn piHandle;\n\t}\n}\n","import {\n\tStubPiTreeHandleFactory,\n\ttype StubToolCallScriptResolver,\n\ttype StubToolCallScriptResolverContext,\n} from \"./stub-pi-tree-handle.js\";\n\nfunction isObjectLike(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\n/** @internal */\nexport function synthesizeStubArgValue(key: string, spec: unknown): unknown {\n\tif (key === \"changedProjects\") {\n\t\treturn undefined;\n\t}\n\tconst type = isObjectLike(spec) && typeof spec.type === \"string\" ? spec.type : \"string\";\n\tswitch (type) {\n\t\tcase \"number\":\n\t\tcase \"integer\":\n\t\t\treturn 1;\n\t\tcase \"boolean\":\n\t\t\treturn true;\n\t\tcase \"array\": {\n\t\t\tconst itemSpec = isObjectLike(spec) ? spec.items : undefined;\n\t\t\treturn [synthesizeStubArgValue(`${key}_item`, itemSpec)];\n\t\t}\n\t\tcase \"object\":\n\t\t\treturn {};\n\t\tdefault:\n\t\t\treturn `${key} value`;\n\t}\n}\n\n/** @internal */\nexport function synthesizeStubToolArgs(\n\tparameters: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst parameterEntries =\n\t\tisObjectLike(parameters) && parameters.type === \"object\" && isObjectLike(parameters.properties)\n\t\t\t? Object.entries(parameters.properties)\n\t\t\t: Object.entries(parameters);\n\treturn Object.fromEntries(\n\t\tparameterEntries.map(([key, spec]) => [key, synthesizeStubArgValue(key, spec)]),\n\t);\n}\n\n/** @internal */\nexport function createSchemaDrivenToolCallScriptResolver(): StubToolCallScriptResolver {\n\treturn ({ tools }: StubToolCallScriptResolverContext) => {\n\t\tconst markdownTool = tools.find((tool) => tool.name === \"markdown_result\");\n\t\tconst completionTool = tools.find(\n\t\t\t(tool) => tool.name !== \"markdown_result\" && tool.name !== \"upload_result_images\",\n\t\t);\n\t\tif (markdownTool && completionTool) {\n\t\t\treturn {\n\t\t\t\tcalls: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttoolName: markdownTool.name,\n\t\t\t\t\t\targs: synthesizeStubToolArgs(markdownTool.parameters),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttoolName: completionTool.name,\n\t\t\t\t\t\targs: synthesizeStubToolArgs(completionTool.parameters),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t\tconst tool = markdownTool ?? completionTool ?? tools[0];\n\t\tif (!tool) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn {\n\t\t\ttoolName: tool.name,\n\t\t\targs: synthesizeStubToolArgs(tool.parameters),\n\t\t};\n\t};\n}\n\n/** @internal */\nexport function createSchemaDrivenStubPiFactory(\n\toptions: {\n\t\t/** @internal */\n\t\ttoolCallScriptResolver?: StubToolCallScriptResolver;\n\t} = {},\n): StubPiTreeHandleFactory {\n\treturn new StubPiTreeHandleFactory({\n\t\ttoolCallScriptResolver:\n\t\t\toptions.toolCallScriptResolver ?? createSchemaDrivenToolCallScriptResolver(),\n\t});\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,WAAW,cAAc,qBAAqB;AACvD,OAAO,UAAU;AACjB,SAAS,+BAAmD;AAe5D,SAAS,gBAAgB;AAgEzB,SAAS,oBAAoB,QAAyB;AACrD,MAAI,OAAO,WAAW,UAA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