@leitwerk-dev/test-support 0.2.0 → 0.2.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.
Files changed (101) hide show
  1. package/dist/{chunk-7I4OCTF3.js → chunk-2PCDTYVH.js} +7 -2
  2. package/dist/chunk-2PCDTYVH.js.map +1 -0
  3. package/dist/{chunk-KPSK7EMY.js → chunk-5BZSJ4OO.js} +22 -157
  4. package/dist/chunk-5BZSJ4OO.js.map +1 -0
  5. package/dist/{chunk-2IICIB6D.js → chunk-ECAWLVYB.js} +38 -4
  6. package/dist/chunk-ECAWLVYB.js.map +1 -0
  7. package/dist/{chunk-JUH3LUYK.js → chunk-EXHTWQAE.js} +5 -1
  8. package/dist/chunk-EXHTWQAE.js.map +1 -0
  9. package/dist/compact-process-detail-fixture.d.ts +3 -0
  10. package/dist/compact-process-detail-fixture.d.ts.map +1 -1
  11. package/dist/fakes/fake-git-ops.d.ts +12 -0
  12. package/dist/fakes/fake-git-ops.d.ts.map +1 -1
  13. package/dist/fakes/fake-llm.d.ts +11 -0
  14. package/dist/fakes/fake-llm.d.ts.map +1 -1
  15. package/dist/fakes/index.d.ts +1 -1
  16. package/dist/fakes/index.d.ts.map +1 -1
  17. package/dist/fakes/index.js +105 -4
  18. package/dist/fakes/index.js.map +1 -1
  19. package/dist/fixtures.js +104 -2
  20. package/dist/fixtures.js.map +1 -1
  21. package/dist/http-launch.d.ts +2 -1
  22. package/dist/http-launch.d.ts.map +1 -1
  23. package/dist/index.d.ts +23 -13
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +10 -53
  26. package/dist/index.js.map +1 -1
  27. package/dist/integration-harness.d.ts +36 -1
  28. package/dist/integration-harness.d.ts.map +1 -1
  29. package/dist/integration.d.ts +2 -3
  30. package/dist/integration.d.ts.map +1 -1
  31. package/dist/integration.js +131 -13
  32. package/dist/integration.js.map +1 -1
  33. package/dist/local-git.d.ts +105 -8
  34. package/dist/local-git.d.ts.map +1 -1
  35. package/dist/local-git.js +155 -24
  36. package/dist/local-git.js.map +1 -1
  37. package/dist/model-provider-fixtures.d.ts +9 -1
  38. package/dist/model-provider-fixtures.d.ts.map +1 -1
  39. package/dist/polling.d.ts +1 -0
  40. package/dist/polling.d.ts.map +1 -1
  41. package/dist/process-driver.d.ts +5 -1
  42. package/dist/process-driver.d.ts.map +1 -1
  43. package/dist/question-fixtures.d.ts +2 -0
  44. package/dist/question-fixtures.d.ts.map +1 -1
  45. package/dist/server-extension-test-harness.d.ts +43 -3
  46. package/dist/server-extension-test-harness.d.ts.map +1 -1
  47. package/dist/stub-worker-entry.js +1 -1
  48. package/dist/test-diagnostics.d.ts +14 -0
  49. package/dist/test-diagnostics.d.ts.map +1 -0
  50. package/dist/worker-testing/in-process-worker-spawn.d.ts +17 -1
  51. package/dist/worker-testing/in-process-worker-spawn.d.ts.map +1 -1
  52. package/dist/worker-testing/index.d.ts +6 -7
  53. package/dist/worker-testing/index.d.ts.map +1 -1
  54. package/dist/worker-testing/index.js +32 -22
  55. package/dist/worker-testing/index.js.map +1 -1
  56. package/dist/worker-testing/schema-driven-stub-pi.d.ts +5 -0
  57. package/dist/worker-testing/schema-driven-stub-pi.d.ts.map +1 -1
  58. package/dist/worker-testing/stub-pi-controls.d.ts +4 -0
  59. package/dist/worker-testing/stub-pi-controls.d.ts.map +1 -1
  60. package/dist/worker-testing/stub-pi-tree-handle.d.ts +76 -2
  61. package/dist/worker-testing/stub-pi-tree-handle.d.ts.map +1 -1
  62. package/dist/worker-testing/worker-runtime-harness.d.ts +37 -2
  63. package/dist/worker-testing/worker-runtime-harness.d.ts.map +1 -1
  64. package/dist/worker-testing/worker-start-payload.d.ts +17 -1
  65. package/dist/worker-testing/worker-start-payload.d.ts.map +1 -1
  66. package/package.json +9 -8
  67. package/src/compact-process-detail-fixture.ts +9 -1
  68. package/src/fakes/fake-git-ops.ts +12 -0
  69. package/src/fakes/fake-llm.ts +11 -0
  70. package/src/fakes/index.ts +1 -1
  71. package/src/http-launch.ts +2 -1
  72. package/src/index.ts +28 -42
  73. package/src/integration-harness.ts +100 -9
  74. package/src/integration.ts +2 -9
  75. package/src/local-git.ts +195 -45
  76. package/src/model-provider-fixtures.ts +15 -2
  77. package/src/polling.ts +1 -0
  78. package/src/process-driver.ts +7 -1
  79. package/src/question-fixtures.ts +2 -0
  80. package/src/server-extension-test-harness.ts +64 -7
  81. package/src/test-diagnostics.ts +69 -0
  82. package/src/worker-testing/in-process-worker-spawn.ts +29 -2
  83. package/src/worker-testing/index.ts +4 -30
  84. package/src/worker-testing/schema-driven-stub-pi.ts +8 -1
  85. package/src/worker-testing/stub-pi-controls.ts +4 -0
  86. package/src/worker-testing/stub-pi-tree-handle.ts +82 -3
  87. package/src/worker-testing/worker-runtime-harness.ts +57 -6
  88. package/src/worker-testing/worker-start-payload.ts +17 -1
  89. package/dist/chunk-2IICIB6D.js.map +0 -1
  90. package/dist/chunk-3MQO3NCX.js +0 -15
  91. package/dist/chunk-3MQO3NCX.js.map +0 -1
  92. package/dist/chunk-7I4OCTF3.js.map +0 -1
  93. package/dist/chunk-7ZK5QRGP.js +0 -98
  94. package/dist/chunk-7ZK5QRGP.js.map +0 -1
  95. package/dist/chunk-JUH3LUYK.js.map +0 -1
  96. package/dist/chunk-KPSK7EMY.js.map +0 -1
  97. package/dist/chunk-MV4W6NOO.js +0 -105
  98. package/dist/chunk-MV4W6NOO.js.map +0 -1
  99. package/dist/test-app.d.ts +0 -23
  100. package/dist/test-app.d.ts.map +0 -1
  101. package/src/test-app.ts +0 -82
@@ -6,51 +6,86 @@ type ServerMessagePayloadByType = {
6
6
  type: T;
7
7
  }>["payload"];
8
8
  };
9
+ /** @internal */
9
10
  type WorkerMessageType = WorkerToServerMessage["type"];
11
+ /** @internal */
10
12
  type WorkerMessageByType<T extends WorkerMessageType> = Extract<WorkerToServerMessage, {
13
+ /** @internal */
11
14
  type: T;
12
15
  }>;
16
+ /** @internal */
13
17
  export interface ManualWorkerRuntimeScheduler extends WorkerRuntimeScheduler {
18
+ /** @internal */
14
19
  advanceBy(delayMs: number): Promise<void>;
20
+ /** @internal */
15
21
  pendingDelays(): number[];
16
22
  }
23
+ /** @internal */
17
24
  export declare function createManualWorkerRuntimeScheduler(initialNow?: Date): ManualWorkerRuntimeScheduler;
25
+ /** @internal */
18
26
  export interface WorkerRuntimeHarnessOptions {
27
+ /** @internal */
19
28
  config?: Partial<WorkerRuntimeConfig>;
20
- /** Optional default used by start() and startLlmTo(). */
29
+ /** Optional default used by start() and startLlmTo(). @internal */
21
30
  startPayload?: WorkerStartPayload;
22
- /** Model the server's durable terminal acknowledgement. Defaults to true. */
31
+ /** Model the server's durable terminal acknowledgement. Defaults to true. @internal */
23
32
  autoAcknowledgeTerminals?: boolean;
33
+ /** @internal */
24
34
  adapters: Pick<WorkerRuntimeAdapters, "piFactory" | "gitOps"> & Partial<Pick<WorkerRuntimeAdapters, "sessionSnapshots" | "resultImageTools" | "sampleCredentials" | "resolveWorkerProcess" | "stderr" | "extensionEvents">>;
25
35
  }
36
+ /** @internal */
26
37
  export type WorkerRuntimeObservation = {
38
+ /** @internal */
27
39
  kind: "ipc";
40
+ /** @internal */
28
41
  type: WorkerToServerMessage["type"];
29
42
  } | {
43
+ /** @internal */
30
44
  kind: "extension";
45
+ /** @internal */
31
46
  event: string;
32
47
  };
48
+ /** @internal */
33
49
  export declare function createWorkerRuntimeHarness(options: WorkerRuntimeHarnessOptions): {
50
+ /** @internal */
34
51
  scheduler: ManualWorkerRuntimeScheduler;
52
+ /** @internal */
35
53
  outgoing: WorkerToServerMessage[];
54
+ /** @internal */
36
55
  observations: WorkerRuntimeObservation[];
56
+ /** @internal */
37
57
  exitCodes: number[];
58
+ /** @internal */
38
59
  readonly transportStartCount: number;
60
+ /** @internal */
39
61
  readonly transportStopCount: number;
62
+ /** @internal */
40
63
  deliver: <T extends ServerMessageType>(type: T, payload: ServerMessagePayloadByType[T]) => void;
64
+ /** @internal */
41
65
  connect(): Promise<void>;
66
+ /** @internal */
42
67
  start(payload?: WorkerStartPayload | undefined): Promise<void>;
68
+ /** @internal */
43
69
  stop(reason: string): Promise<void>;
70
+ /** @internal */
44
71
  acceptStart(acceptance?: {
72
+ /** @internal */
45
73
  startRecordId?: string;
74
+ /** @internal */
46
75
  turnRecordId?: string;
47
76
  }): Promise<void>;
77
+ /** @internal */
48
78
  startLlmTo<T extends WorkerMessageType>(type: T, payload?: WorkerStartPayload | undefined): Promise<WorkerMessageByType<T>>;
79
+ /** @internal */
49
80
  reconnect(): void;
81
+ /** @internal */
50
82
  failTransport(error: Error): void;
83
+ /** @internal */
51
84
  waitForMessage<T extends WorkerMessageType>(type: T, count?: number): Promise<WorkerMessageByType<T>>;
85
+ /** @internal */
52
86
  flush(): Promise<void>;
53
87
  };
88
+ /** @internal */
54
89
  export type WorkerRuntimeHarness = ReturnType<typeof createWorkerRuntimeHarness>;
55
90
  export {};
56
91
  //# sourceMappingURL=worker-runtime-harness.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-runtime-harness.d.ts","sourceRoot":"","sources":["../../src/worker-testing/worker-runtime-harness.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEN,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,MAAM,+BAA+B,CAAC;AAGvC,KAAK,iBAAiB,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACvD,KAAK,0BAA0B,GAAG;KAChC,CAAC,IAAI,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC,SAAS,CAAC;CAChF,CAAC;AACF,KAAK,iBAAiB,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACvD,KAAK,mBAAmB,CAAC,CAAC,SAAS,iBAAi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,CAAC,CAAC;;yBAab,KAAK;mBAGL,CAAC,SAAS,iBAAiB,QACzC,CAAC,mBAEL,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;;EAgBnC;AAED,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
1
+ {"version":3,"file":"worker-runtime-harness.d.ts","sourceRoot":"","sources":["../../src/worker-testing/worker-runtime-harness.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEN,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,MAAM,+BAA+B,CAAC;AAGvC,KAAK,iBAAiB,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACvD,KAAK,0BAA0B,GAAG;KAChC,CAAC,IAAI,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC,SAAS,CAAC;CAChF,CAAC;AACF,gBAAgB;AAChB,KAAK,iBAAiB,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACvD,gBAAgB;AAChB,KAAK,mBAAmB,CAAC,CAAC,SAAS,iBAAiB,IAAI,OAAO,CAC9D,qBAAqB,EACrB;IACC,gBAAgB;IAChB,IAAI,EAAE,CAAC,CAAC;CACR,CACD,CAAC;AAaF,gBAAgB;AAChB,MAAM,WAAW,4BAA6B,SAAQ,sBAAsB;IAC3E,gBAAgB;IAChB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,gBAAgB;IAChB,aAAa,IAAI,MAAM,EAAE,CAAC;CAC1B;AAED,gBAAgB;AAChB,wBAAgB,kCAAkC,CACjD,UAAU,OAAuC,GAC/C,4BAA4B,CA2C9B;AAED,gBA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,CAAC,CAAC,CAAC,CAAC;IAUlC,gBAAgB;;IAIhB,gBAAgB;yBACK,KAAK;IAG1B,gBAAgB;mBACK,CAAC,SAAS,iBAAiB,QACzC,CAAC,mBAEL,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAWlC,gBAAgB;;EAMjB;AAED,gBAAgB;AAChB,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
@@ -1,25 +1,41 @@
1
1
  import type { ResolvedTurnStart } from "@leitwerk-dev/domain";
2
2
  import { type InputDelivery, type ProcessInstanceSnapshot, type ProcessProjectSnapshot, type WorkerCredentialMaterial, type WorkerStartPayload } from "@leitwerk-dev/worker-protocol";
3
+ /** @internal */
3
4
  type LlmStart = Extract<ResolvedTurnStart, {
4
5
  kind: "llm";
5
6
  }>;
7
+ /** @internal */
6
8
  type LlmModel = LlmStart["model"];
9
+ /** @internal */
7
10
  export interface TestLlmWorkerStartPayloadOptions {
11
+ /** @internal */
8
12
  root: string;
13
+ /** @internal */
9
14
  processSnapshot: ProcessInstanceSnapshot;
15
+ /** @internal */
10
16
  projectSnapshots?: ProcessProjectSnapshot[];
17
+ /** @internal */
11
18
  turnResultMarkdownBySemanticRef?: WorkerStartPayload["turnResultMarkdownBySemanticRef"];
19
+ /** @internal */
12
20
  turnResultMarkdownByProduct?: WorkerStartPayload["turnResultMarkdownByProduct"];
21
+ /** @internal */
13
22
  pendingInputs?: InputDelivery[];
23
+ /** @internal */
14
24
  workerLeaseId?: string;
25
+ /** @internal */
15
26
  startRecordId?: string;
27
+ /** @internal */
16
28
  turnRecordId?: string;
29
+ /** @internal */
17
30
  model?: LlmModel;
31
+ /** @internal */
18
32
  credential?: WorkerCredentialMaterial | null;
33
+ /** @internal */
19
34
  resume?: boolean;
35
+ /** @internal */
20
36
  now?: string;
21
37
  }
22
- /** Builds a valid public LLM worker.start payload with canonical Pi resources. */
38
+ /** Builds a valid public LLM worker.start payload with canonical Pi resources. @internal */
23
39
  export declare function createTestLlmWorkerStartPayload(options: TestLlmWorkerStartPayloadOptions): WorkerStartPayload;
24
40
  export {};
25
41
  //# sourceMappingURL=worker-start-payload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-start-payload.d.ts","sourceRoot":"","sources":["../../src/worker-testing/worker-start-payload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAGN,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAG3B,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,MAAM,+BAA+B,CAAC;AAEvC,KAAK,QAAQ,GAAG,OAAO,CAAC,iBAAiB,EAAE;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAC5D,KAAK,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;AAElC,MAAM,WAAW,gCAAgC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,uBAAuB,CAAC;IACzC,gBAAgB,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAC5C,+BAA+B,CAAC,EAAE,kBAAkB,CAAC,iCAAiC,CAAC,CAAC;IACxF,2BAA2B,CAAC,EAAE,kBAAkB,CAAC,6BAA6B,CAAC,CAAC;IAChF,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,UAAU,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC7C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,kFAAkF;AAClF,wBAAgB,+BAA+B,CAC9C,OAAO,EAAE,gCAAgC,GACvC,kBAAkB,CAkGpB"}
1
+ {"version":3,"file":"worker-start-payload.d.ts","sourceRoot":"","sources":["../../src/worker-testing/worker-start-payload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAGN,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAG3B,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,MAAM,+BAA+B,CAAC;AAEvC,gBAAgB;AAChB,KAAK,QAAQ,GAAG,OAAO,CAAC,iBAAiB,EAAE;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAC5D,gBAAgB;AAChB,KAAK,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;AAElC,gBAAgB;AAChB,MAAM,WAAW,gCAAgC;IAChD,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,eAAe,EAAE,uBAAuB,CAAC;IACzC,gBAAgB;IAChB,gBAAgB,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAC5C,gBAAgB;IAChB,+BAA+B,CAAC,EAAE,kBAAkB,CAAC,iCAAiC,CAAC,CAAC;IACxF,gBAAgB;IAChB,2BAA2B,CAAC,EAAE,kBAAkB,CAAC,6BAA6B,CAAC,CAAC;IAChF,gBAAgB;IAChB,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;IAChC,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB;IAChB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,gBAAgB;IAChB,UAAU,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC7C,gBAAgB;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gBAAgB;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,4FAA4F;AAC5F,wBAAgB,+BAA+B,CAC9C,OAAO,EAAE,gCAAgC,GACvC,kBAAkB,CAkGpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leitwerk-dev/test-support",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/leitwerk-dev/leitwerk.git",
@@ -44,13 +44,14 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@earendil-works/pi-coding-agent": "^0.81.1",
47
- "@leitwerk-dev/domain": "0.2.0",
48
- "@leitwerk-dev/extension-runtime": "0.2.0",
49
- "@leitwerk-dev/process-sdk": "0.2.0",
50
- "@leitwerk-dev/protocol": "0.2.0",
51
- "@leitwerk-dev/server": "0.2.0",
52
- "@leitwerk-dev/worker": "0.2.0",
53
- "@leitwerk-dev/worker-protocol": "0.2.0"
47
+ "@leitwerk-dev/domain": "0.2.1",
48
+ "@leitwerk-dev/extension-runtime": "0.2.1",
49
+ "@leitwerk-dev/process-sdk": "0.2.1",
50
+ "@leitwerk-dev/protocol": "0.2.1",
51
+ "@leitwerk-dev/server": "0.2.1",
52
+ "@leitwerk-dev/worker": "0.2.1",
53
+ "@leitwerk-dev/worker-protocol": "0.2.1",
54
+ "@leitwerk-dev/external-writes": "0.2.1"
54
55
  },
55
56
  "devDependencies": {
56
57
  "tsup": "^8.5.1"
@@ -41,6 +41,7 @@ const EMPTY_TRACE: TurnTraceSnapshot = {
41
41
  piInput: null,
42
42
  };
43
43
 
44
+ /** @internal */
44
45
  export function createCompactProcessDetailFixtureFactory() {
45
46
  const reasoningSourceByInstanceId = new Map<
46
47
  string,
@@ -51,6 +52,7 @@ export function createCompactProcessDetailFixtureFactory() {
51
52
  }
52
53
  >();
53
54
 
55
+ /** @internal */
54
56
  function compact(input: unknown): ProcessDetailUiSnapshotResponseBody {
55
57
  const legacy = input as LegacyProcessDetailFixture;
56
58
  if (!Array.isArray(legacy.turnRecords)) {
@@ -124,6 +126,7 @@ export function createCompactProcessDetailFixtureFactory() {
124
126
  return compactDetail;
125
127
  }
126
128
 
129
+ /** @internal */
127
130
  function reasoningResponse(
128
131
  instanceId: string,
129
132
  turnRecordId: string,
@@ -139,5 +142,10 @@ export function createCompactProcessDetailFixtureFactory() {
139
142
  };
140
143
  }
141
144
 
142
- return { compact, reasoningResponse };
145
+ return {
146
+ /** @internal */
147
+ compact,
148
+ /** @internal */
149
+ reasoningResponse,
150
+ };
143
151
  }
@@ -1,31 +1,38 @@
1
1
  import path from "node:path";
2
2
 
3
+ /** @internal */
3
4
  export type RepoTemplate = Record<string, string>;
4
5
 
5
6
  /**
6
7
  * Structurally compatible with RunRootGitOps — call sites annotate
7
8
  * `const git: RunRootGitOps = new FakeGitOps(...)` so TS catches drift.
8
9
  */
10
+ /** @internal */
9
11
  export class FakeGitOps {
12
+ /** @internal */
10
13
  readonly operations: string[] = [];
11
14
  private readonly files = new Map<string, string>();
12
15
  private readonly repoState = new Map<string, { currentBranch: string; branches: Set<string> }>();
13
16
 
17
+ /** @internal */
14
18
  constructor(private readonly templates: Map<string, RepoTemplate>) {}
15
19
 
16
20
  private abs(repoDir: string, filePath: string): string {
17
21
  return path.normalize(path.join(repoDir, filePath));
18
22
  }
19
23
 
24
+ /** @internal */
20
25
  async writeFile(repoDir: string, filePath: string, content: string): Promise<void> {
21
26
  this.operations.push(`writeFile:${filePath}`);
22
27
  this.files.set(this.abs(repoDir, filePath), content);
23
28
  }
24
29
 
30
+ /** @internal */
25
31
  async readFile(repoDir: string, filePath: string): Promise<string | null> {
26
32
  return this.files.get(this.abs(repoDir, filePath)) ?? null;
27
33
  }
28
34
 
35
+ /** @internal */
29
36
  async clone(repoLocator: string, targetDir: string): Promise<void> {
30
37
  this.operations.push(`clone:${path.basename(targetDir)}`);
31
38
  const n = path.normalize(targetDir);
@@ -48,6 +55,7 @@ export class FakeGitOps {
48
55
  });
49
56
  }
50
57
 
58
+ /** @internal */
51
59
  async checkout(repoDir: string, branch: string): Promise<void> {
52
60
  const st = this.repoState.get(path.normalize(repoDir));
53
61
  if (!st) {
@@ -57,6 +65,7 @@ export class FakeGitOps {
57
65
  st.currentBranch = branch;
58
66
  }
59
67
 
68
+ /** @internal */
60
69
  async createBranch(repoDir: string, branchName: string, _startPoint: string): Promise<void> {
61
70
  const st = this.repoState.get(path.normalize(repoDir));
62
71
  if (!st) {
@@ -65,11 +74,13 @@ export class FakeGitOps {
65
74
  st.branches.add(branchName);
66
75
  }
67
76
 
77
+ /** @internal */
68
78
  async branchExists(repoDir: string, branchName: string): Promise<boolean> {
69
79
  const st = this.repoState.get(path.normalize(repoDir));
70
80
  return st?.branches.has(branchName) ?? false;
71
81
  }
72
82
 
83
+ /** @internal */
73
84
  async getHeadSha(repoDir: string): Promise<string> {
74
85
  const st = this.repoState.get(path.normalize(repoDir));
75
86
  if (!st) {
@@ -81,6 +92,7 @@ export class FakeGitOps {
81
92
  .padEnd(40, "0");
82
93
  }
83
94
 
95
+ /** @internal */
84
96
  async listFiles(repoDir: string, pattern: string): Promise<string[]> {
85
97
  const normRoot = path.normalize(repoDir);
86
98
  const prefix = normRoot + path.sep;
@@ -1,26 +1,36 @@
1
+ /** @public */
1
2
  export interface LlmResponse {
3
+ /** @public */
2
4
  content: string;
5
+ /** @public */
3
6
  toolCalls?: Array<{
7
+ /** @public */
4
8
  name: string;
9
+ /** @public */
5
10
  arguments: Record<string, unknown>;
6
11
  }>;
7
12
  }
8
13
 
14
+ /** @public */
9
15
  export type LlmHandler = (prompt: string) => LlmResponse;
10
16
 
11
17
  /**
12
18
  * Deterministic in-memory LLM fake for automated system tests.
13
19
  * Responds with scripted outputs based on registered handlers.
14
20
  */
21
+ /** @public */
15
22
  export class FakeLlmProvider {
16
23
  private handlers: LlmHandler[] = [];
17
24
  private callIndex = 0;
25
+ /** @public */
18
26
  readonly calls: string[] = [];
19
27
 
28
+ /** @public */
20
29
  onPrompt(handler: LlmHandler): void {
21
30
  this.handlers.push(handler);
22
31
  }
23
32
 
33
+ /** @public */
24
34
  respond(prompt: string): LlmResponse {
25
35
  this.calls.push(prompt);
26
36
  const handler = this.handlers[this.callIndex % this.handlers.length];
@@ -31,6 +41,7 @@ export class FakeLlmProvider {
31
41
  return { content: "No handler registered for this prompt." };
32
42
  }
33
43
 
44
+ /** @internal */
34
45
  reset(): void {
35
46
  this.handlers = [];
36
47
  this.callIndex = 0;
@@ -1,2 +1,2 @@
1
1
  export { FakeGitOps, type RepoTemplate } from "./fake-git-ops.js";
2
- export { FakeLlmProvider, type LlmResponse } from "./fake-llm.js";
2
+ export { FakeLlmProvider } from "./fake-llm.js";
@@ -1,6 +1,6 @@
1
1
  import type { LaunchRun } from "@leitwerk-dev/domain";
2
2
 
3
- /** Accepts a launch-run request shape and waits for its admitted process commit. */
3
+ /** Accepts a launch-run request shape and waits for its admitted process commit. @internal */
4
4
  export async function postImmediateLaunchRequest(
5
5
  input: string | URL | Request,
6
6
  init?: RequestInit,
@@ -16,6 +16,7 @@ export async function postImmediateLaunchRequest(
16
16
  * Admits an immediate launch through the public asynchronous HTTP contract and waits until the
17
17
  * process commit or a pre-commit failure is observable. Intended for integration-test setup.
18
18
  */
19
+ /** @public */
19
20
  export async function postImmediateLaunch(
20
21
  serverBaseUrl: string,
21
22
  launcherId: string,
package/src/index.ts CHANGED
@@ -1,49 +1,35 @@
1
- export {
2
- createTestConfigSnapshot as testConfigSnapshot,
3
- createTestIpcEnvelopeBase as baseEnvelope,
4
- flushAsyncWork,
5
- } from "@leitwerk-dev/worker-protocol";
6
- export { createCompactProcessDetailFixtureFactory } from "./compact-process-detail-fixture.js";
7
- export { FakeGitOps, type RepoTemplate } from "./fakes/fake-git-ops.js";
8
- export { FakeLlmProvider, type LlmResponse } from "./fakes/fake-llm.js";
1
+ import { createInMemoryExternalWriteLog as createInMemoryExternalWriteLogImpl } from "./server-extension-test-harness.js";
2
+
3
+ export { FakeLlmProvider } from "./fakes/fake-llm.js";
9
4
  export { postImmediateLaunch, postImmediateLaunchRequest } from "./http-launch.js";
10
5
  export {
11
- createInProcessWorkerSpawn,
12
- type InProcessWorkerSpawnOptions,
13
- } from "./in-process-worker.js";
14
- export {
15
- createIntegrationHarness,
16
- type IntegrationHarness,
17
- type IntegrationHarnessOptions,
18
- } from "./integration-harness.js";
19
- export { fixtureModelProviders } from "./model-provider-fixtures.js";
20
- export { waitForValue } from "./polling.js";
6
+ type FixtureModelProviderSet,
7
+ fixtureModelProviders,
8
+ } from "./model-provider-fixtures.js";
21
9
  export {
22
- createInMemoryExternalWriteLog,
23
10
  createPollingTestExtension,
24
11
  createTestServerSetupCapability,
25
12
  createToolCollector,
26
- type InMemoryExternalWriteLog,
27
- type ServerExtensionTestHarness,
28
- setupServerExtensionTest,
29
13
  } from "./server-extension-test-harness.js";
30
- export { createTestApp, type TestApp, type TestAppOptions } from "./test-app.js";
31
- export {
32
- createSchemaDrivenStubPiFactory,
33
- createSchemaDrivenToolCallScriptResolver,
34
- synthesizeStubArgValue,
35
- synthesizeStubToolArgs,
36
- } from "./worker-testing/schema-driven-stub-pi.js";
37
- export {
38
- createStubToolScriptController,
39
- type StubToolScriptController,
40
- } from "./worker-testing/stub-pi-controls.js";
41
- export {
42
- StubPiTreeHandle,
43
- StubPiTreeHandleFactory,
44
- type StubPiTreeHandleFactoryOptions,
45
- type StubToolCallScriptCall,
46
- type StubToolCallScriptItem,
47
- type StubToolCallScriptResolver,
48
- type StubToolCallScriptResolverContext,
49
- } from "./worker-testing/stub-pi-tree-handle.js";
14
+ /** @internal */
15
+ export function createInMemoryExternalWriteLog(): {
16
+ /** @internal */
17
+ records: Array<{
18
+ /** @internal */
19
+ dedupKey: string;
20
+ }>;
21
+ /** @internal */
22
+ hasDedupKey(key: string): boolean;
23
+ /** @internal */
24
+ record(input: {
25
+ /** @internal */
26
+ dedupKey: string;
27
+ }): {
28
+ /** @internal */
29
+ dedupKey: string;
30
+ };
31
+ /** @internal */
32
+ getDedupKeys(): ReadonlySet<string>;
33
+ } {
34
+ return createInMemoryExternalWriteLogImpl();
35
+ }
@@ -1,3 +1,6 @@
1
+ import { mkdtempSync, rmSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import path from "node:path";
1
4
  import type { ExtensionCatalog } from "@leitwerk-dev/extension-runtime";
2
5
  import type { ProvidedCapability } from "@leitwerk-dev/process-sdk";
3
6
  import {
@@ -7,30 +10,104 @@ import {
7
10
  getDefaultConfig,
8
11
  type LeitwerkConfig,
9
12
  } from "@leitwerk-dev/server";
10
- import { createInProcessWorkerSpawn } from "./in-process-worker.js";
13
+ import {
14
+ createInProcessWorkerSpawn,
15
+ type InProcessWorkerSpawnOptions,
16
+ } from "./in-process-worker.js";
11
17
 
18
+ /** @public */
12
19
  export interface IntegrationHarness<
13
20
  TResources extends Record<string, unknown> = Record<string, never>,
14
21
  > {
22
+ /** @public */
15
23
  ctx: AppContext;
24
+ /** @public */
25
+ close(): Promise<void>;
26
+ /** @internal */
16
27
  config: LeitwerkConfig;
28
+ /** @public */
17
29
  address: string;
30
+ /** @internal */
18
31
  resources: TResources;
19
32
  }
20
33
 
34
+ /** @public */
21
35
  export interface IntegrationHarnessOptions<
22
36
  TResources extends Record<string, unknown> = Record<string, never>,
23
37
  > {
38
+ /** @internal */
24
39
  config?: LeitwerkConfig;
40
+ /** @public */
25
41
  configOverride?: (config: LeitwerkConfig) => void;
42
+ /** @public */
26
43
  appOverrides?: Partial<AppOptions>;
44
+ /** @internal */
27
45
  listen?: boolean;
28
- inProcessWorkers?: boolean;
46
+ /** Start background services when binding a listener. Defaults to true. @public */
47
+ backgroundServices?: boolean;
48
+ /** @internal */
49
+ inProcessWorkers?: boolean | Omit<InProcessWorkerSpawnOptions, "extensionCatalog">;
50
+ /** @public */
29
51
  extensionCatalog: ExtensionCatalog | Promise<ExtensionCatalog>;
52
+ /** @internal */
30
53
  preProvidedCapabilities?: readonly ProvidedCapability[];
54
+ /** @internal */
31
55
  resources?: TResources;
32
56
  }
33
57
 
58
+ /** Owns disposable file-backed storage; close retains it for the next open, dispose removes it. @internal */
59
+ export function createPersistentIntegrationFixture(
60
+ prefix: string,
61
+ configure?: (config: LeitwerkConfig) => void,
62
+ ) {
63
+ const root = mkdtempSync(path.join(tmpdir(), prefix));
64
+ let harness: IntegrationHarness | undefined;
65
+ /** @internal */
66
+ function createConfig() {
67
+ const config = getDefaultConfig();
68
+ config.storage.sqlite_path = path.join(root, "state.sqlite");
69
+ config.storage.process_workspaces_dir = path.join(root, "workspaces");
70
+ config.storage.tree_files_dir = path.join(root, "trees");
71
+ config.pi.agent_dir = path.join(root, "pi");
72
+ configure?.(config);
73
+ return config;
74
+ }
75
+ /** @internal */
76
+ async function close() {
77
+ await harness?.close();
78
+ harness = undefined;
79
+ }
80
+ return {
81
+ /** @internal */
82
+ root,
83
+ /** @internal */
84
+ createConfig,
85
+ /** @internal */
86
+ context() {
87
+ if (!harness) throw new Error("Fixture is not open");
88
+ return harness.ctx;
89
+ },
90
+ /** @internal */
91
+ async open(options: IntegrationHarnessOptions) {
92
+ harness = await createIntegrationHarness({
93
+ ...options,
94
+ config: options.config ?? createConfig(),
95
+ });
96
+ return harness;
97
+ },
98
+ /** @internal */
99
+ close,
100
+ /** @internal */
101
+ async dispose() {
102
+ try {
103
+ await close();
104
+ } finally {
105
+ rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
106
+ }
107
+ },
108
+ };
109
+ }
110
+ /** @public */
34
111
  export async function createIntegrationHarness<
35
112
  TResources extends Record<string, unknown> = Record<string, never>,
36
113
  >(opts: IntegrationHarnessOptions<TResources>): Promise<IntegrationHarness<TResources>> {
@@ -52,24 +129,38 @@ export async function createIntegrationHarness<
52
129
 
53
130
  if (opts.inProcessWorkers !== false && !appOpts.localWorkerSpawnImpl) {
54
131
  appOpts.localWorkerSpawnImpl = createInProcessWorkerSpawn({
132
+ ...(typeof opts.inProcessWorkers === "object" ? opts.inProcessWorkers : {}),
55
133
  extensionCatalog,
56
134
  });
57
135
  }
58
136
  const ctx = await createAppContext(appOpts);
59
137
 
60
138
  let address = "";
61
- if (opts.listen !== false || config.workers.runner === "local") {
62
- await ctx.app.listen({ host: "127.0.0.1", port: 0 });
63
- const info = ctx.app.server.address();
64
- const port = typeof info === "object" && info ? info.port : 0;
65
- address = `http://127.0.0.1:${port}`;
66
- ctx.config.server.base_url = address;
139
+ try {
140
+ if (opts.listen !== false) {
141
+ if (opts.backgroundServices !== false) {
142
+ ({ address } = await ctx.listen({
143
+ host: "127.0.0.1",
144
+ port: 0,
145
+ useBoundAddressAsBaseUrl: true,
146
+ }));
147
+ } else {
148
+ address = await ctx.app.listen({ host: "127.0.0.1", port: 0 });
149
+ ctx.config.server.base_url = address;
150
+ }
151
+ }
152
+ } catch (error) {
153
+ await ctx.close().catch(() => {});
154
+ throw error;
67
155
  }
68
156
 
69
157
  return {
70
158
  ctx,
159
+ close: () => ctx.close(),
71
160
  config,
72
- address,
161
+ get address() {
162
+ return address || (ctx.app.server.listening ? ctx.config.server.base_url : "");
163
+ },
73
164
  resources: opts.resources ?? ({} as TResources),
74
165
  };
75
166
  }
@@ -1,15 +1,8 @@
1
1
  export {
2
2
  createIntegrationHarness,
3
+ createPersistentIntegrationFixture,
3
4
  type IntegrationHarness,
4
- type IntegrationHarnessOptions,
5
5
  } from "./integration-harness.js";
6
6
  export { waitForValue } from "./polling.js";
7
7
  export { createProcessDriver } from "./process-driver.js";
8
- export {
9
- createInMemoryExternalWriteLog,
10
- createTestServerSetupCapability,
11
- type InMemoryExternalWriteLog,
12
- type ServerExtensionTestHarness,
13
- setupServerExtensionTest,
14
- } from "./server-extension-test-harness.js";
15
- export { createTestApp, type TestApp, type TestAppOptions } from "./test-app.js";
8
+ export { createTestServerSetupCapability } from "./server-extension-test-harness.js";