@leitwerk-dev/test-support 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OE4NHDVS.js → chunk-3RWI5WJK.js} +2 -2
- package/dist/{chunk-5BZSJ4OO.js → chunk-DNUGHAYN.js} +37 -4
- package/dist/chunk-DNUGHAYN.js.map +1 -0
- package/dist/{chunk-P2FF4AP7.js → chunk-FDXRT6UZ.js} +57 -2
- package/dist/chunk-FDXRT6UZ.js.map +1 -0
- package/dist/{chunk-E4Y7XND5.js → chunk-WRAVDPEM.js} +16 -27
- package/dist/chunk-WRAVDPEM.js.map +1 -0
- package/dist/extension-integration-harness.d.ts +2 -2
- package/dist/extension-integration-harness.d.ts.map +1 -1
- package/dist/fixtures.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -26
- package/dist/index.js.map +1 -1
- package/dist/integration-harness.d.ts +2 -0
- package/dist/integration-harness.d.ts.map +1 -1
- package/dist/integration.d.ts +1 -1
- package/dist/integration.d.ts.map +1 -1
- package/dist/integration.js +54 -101
- package/dist/integration.js.map +1 -1
- package/dist/local-git.d.ts +9 -0
- package/dist/local-git.d.ts.map +1 -1
- package/dist/local-git.js +31 -0
- package/dist/local-git.js.map +1 -1
- package/dist/model-provider-fixtures.d.ts +7 -0
- package/dist/model-provider-fixtures.d.ts.map +1 -1
- package/dist/process.d.ts +32 -2
- package/dist/process.d.ts.map +1 -1
- package/dist/process.js +24 -15
- package/dist/process.js.map +1 -1
- package/dist/server-extension-test-harness.d.ts +3 -1
- package/dist/server-extension-test-harness.d.ts.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.d.ts +1 -1
- package/dist/worker-testing/index.d.ts.map +1 -1
- package/dist/worker-testing/index.js +7 -4
- package/dist/worker-testing/index.js.map +1 -1
- package/dist/worker-testing/schema-driven-stub-pi.d.ts.map +1 -1
- package/dist/worker-testing/stub-pi-tree-handle.d.ts +15 -0
- package/dist/worker-testing/stub-pi-tree-handle.d.ts.map +1 -1
- package/dist/worker-testing/worker-start-payload.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/extension-integration-harness.ts +44 -139
- package/src/index.ts +2 -0
- package/src/integration-harness.ts +17 -1
- package/src/integration.ts +1 -0
- package/src/local-git.ts +34 -0
- package/src/model-provider-fixtures.ts +40 -0
- package/src/process.ts +22 -12
- package/src/server-extension-test-harness.ts +40 -1
- package/src/supported-question-fixtures.ts +0 -20
- package/src/worker-testing/index.ts +1 -0
- package/src/worker-testing/schema-driven-stub-pi.ts +11 -23
- package/src/worker-testing/stub-pi-tree-handle.ts +34 -1
- package/src/worker-testing/worker-start-payload.ts +1 -0
- package/dist/chunk-5BZSJ4OO.js.map +0 -1
- package/dist/chunk-E4Y7XND5.js.map +0 -1
- package/dist/chunk-P2FF4AP7.js.map +0 -1
- /package/dist/{chunk-OE4NHDVS.js.map → chunk-3RWI5WJK.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,39 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
+
fixtureModelProfiles,
|
|
3
|
+
fixtureModelProviders,
|
|
2
4
|
postImmediateLaunch,
|
|
3
|
-
postImmediateLaunchRequest
|
|
4
|
-
|
|
5
|
+
postImmediateLaunchRequest,
|
|
6
|
+
withDefaultModelFixture
|
|
7
|
+
} from "./chunk-FDXRT6UZ.js";
|
|
5
8
|
import {
|
|
6
9
|
createInMemoryExternalWriteLog,
|
|
7
10
|
createPollingTestExtension,
|
|
8
11
|
createTestServerSetupCapability,
|
|
9
12
|
createToolCollector
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-DNUGHAYN.js";
|
|
11
14
|
import {
|
|
12
15
|
FakeLlmProvider
|
|
13
16
|
} from "./chunk-EXHTWQAE.js";
|
|
14
17
|
|
|
15
|
-
// src/model-provider-fixtures.ts
|
|
16
|
-
import {
|
|
17
|
-
builtinPiProvider,
|
|
18
|
-
defineModelProvider,
|
|
19
|
-
defineModelProviders
|
|
20
|
-
} from "@leitwerk-dev/process-sdk";
|
|
21
|
-
function fixtureModelProviders(...models) {
|
|
22
|
-
return defineModelProviders(
|
|
23
|
-
(rawConfig) => models.map(({ id, modelId, piProvider = id, server = false }) => ({
|
|
24
|
-
definition: defineModelProvider({
|
|
25
|
-
id,
|
|
26
|
-
parseConfig: () => ({ config: {} }),
|
|
27
|
-
worker: builtinPiProvider(piProvider),
|
|
28
|
-
...server ? { server: builtinPiProvider(piProvider) } : {},
|
|
29
|
-
models: () => [{ modelId, availability: "available" }],
|
|
30
|
-
secrets: () => ({})
|
|
31
|
-
}),
|
|
32
|
-
rawConfig
|
|
33
|
-
}))
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
18
|
// src/index.ts
|
|
38
19
|
function createInMemoryExternalWriteLog2() {
|
|
39
20
|
return createInMemoryExternalWriteLog();
|
|
@@ -44,8 +25,10 @@ export {
|
|
|
44
25
|
createPollingTestExtension,
|
|
45
26
|
createTestServerSetupCapability,
|
|
46
27
|
createToolCollector,
|
|
28
|
+
fixtureModelProfiles,
|
|
47
29
|
fixtureModelProviders,
|
|
48
30
|
postImmediateLaunch,
|
|
49
|
-
postImmediateLaunchRequest
|
|
31
|
+
postImmediateLaunchRequest,
|
|
32
|
+
withDefaultModelFixture
|
|
50
33
|
};
|
|
51
34
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createInMemoryExternalWriteLog as createInMemoryExternalWriteLogImpl } from \"./server-extension-test-harness.js\";\n\nexport { FakeLlmProvider } from \"./fakes/fake-llm.js\";\nexport { postImmediateLaunch, postImmediateLaunchRequest } from \"./http-launch.js\";\nexport {\n\ttype FixtureModelProviderSet,\n\tfixtureModelProfiles,\n\tfixtureModelProviders,\n\twithDefaultModelFixture,\n} from \"./model-provider-fixtures.js\";\nexport {\n\tcreatePollingTestExtension,\n\tcreateTestServerSetupCapability,\n\tcreateToolCollector,\n} from \"./server-extension-test-harness.js\";\n\n/** @internal */\nexport function createInMemoryExternalWriteLog(): ReturnType<\n\ttypeof createInMemoryExternalWriteLogImpl\n> {\n\treturn createInMemoryExternalWriteLogImpl();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBO,SAASA,kCAEd;AACD,SAAO,+BAAmC;AAC3C;","names":["createInMemoryExternalWriteLog"]}
|
|
@@ -2,6 +2,8 @@ import type { ExtensionCatalog } from "@leitwerk-dev/extension-runtime";
|
|
|
2
2
|
import type { ProvidedCapability } from "@leitwerk-dev/process-sdk";
|
|
3
3
|
import { type AppContext, type AppOptions, type LeitwerkConfig } from "@leitwerk-dev/server";
|
|
4
4
|
import { type InProcessWorkerSpawnOptions } from "./in-process-worker.js";
|
|
5
|
+
/** Server fixture with an explicit synthetic model when the test supplies no model catalog. @internal */
|
|
6
|
+
export declare function createTestAppContext(options?: AppOptions): Promise<AppContext>;
|
|
5
7
|
/** @public */
|
|
6
8
|
export interface IntegrationHarness<TResources extends Record<string, unknown> = Record<string, never>> {
|
|
7
9
|
/** @public */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-harness.d.ts","sourceRoot":"","sources":["../src/integration-harness.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"integration-harness.d.ts","sourceRoot":"","sources":["../src/integration-harness.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACN,KAAK,UAAU,EACf,KAAK,UAAU,EAGf,KAAK,cAAc,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEN,KAAK,2BAA2B,EAChC,MAAM,wBAAwB,CAAC;AAGhC,yGAAyG;AACzG,wBAAsB,oBAAoB,CAAC,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAQxF;AAED,cAAc;AACd,MAAM,WAAW,kBAAkB,CAClC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAElE,cAAc;IACd,GAAG,EAAE,UAAU,CAAC;IAChB,cAAc;IACd,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,gBAAgB;IAChB,MAAM,EAAE,cAAc,CAAC;IACvB,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,SAAS,EAAE,UAAU,CAAC;CACtB;AAED,cAAc;AACd,MAAM,WAAW,yBAAyB,CACzC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAElE,gBAAgB;IAChB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,cAAc;IACd,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAClD,cAAc;IACd,YAAY,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACnC,gBAAgB;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mFAAmF;IACnF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,gBAAgB;IAChB,gBAAgB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,2BAA2B,EAAE,kBAAkB,CAAC,CAAC;IACnF,cAAc;IACd,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC/D,gBAAgB;IAChB,uBAAuB,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACxD,gBAAgB;IAChB,SAAS,CAAC,EAAE,UAAU,CAAC;CACvB;AAED,6GAA6G;AAC7G,wBAAgB,kCAAkC,CACjD,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI;IAoB3C,gBAAgB;;IAEhB,gBAAgB;;IAEhB,gBAAgB;;IAKhB,gBAAgB;kBACI,yBAAyB;IAO7C,gBAAgB;;IAEhB,gBAAgB;;EASjB;AACD,cAAc;AACd,wBAAsB,wBAAwB,CAC7C,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACjE,IAAI,EAAE,yBAAyB,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAwDtF"}
|
package/dist/integration.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { type AcceptedTurnFixture, type AcceptedTurnReference, createExtensionIntegrationHarness, type ExtensionIntegrationHarness, type ExtensionIntegrationHarnessOptions, type ExtensionIntegrationProcess, type ExtensionIntegrationSnapshot, type ExtensionTestRequest, type ExtensionTestResponse, type IntegrationAnnotationObservation, type IntegrationApprovalObservation, type IntegrationEventObservation, type IntegrationInputObservation, type IntegrationLeafObservation, type IntegrationProcessInput, type IntegrationPromptObservation, type IntegrationToolCall, type IntegrationTurnResult, type IntegrationTurnScript, } from "./extension-integration-harness.js";
|
|
2
|
-
export { createIntegrationHarness, createPersistentIntegrationFixture, type IntegrationHarness, } from "./integration-harness.js";
|
|
2
|
+
export { createIntegrationHarness, createPersistentIntegrationFixture, createTestAppContext, type IntegrationHarness, } from "./integration-harness.js";
|
|
3
3
|
export { waitForValue } from "./polling.js";
|
|
4
4
|
export { createProcessDriver } from "./process-driver.js";
|
|
5
5
|
export { createTestServerSetupCapability } from "./server-extension-test-harness.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../src/integration.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,iCAAiC,EACjC,KAAK,2BAA2B,EAChC,KAAK,kCAAkC,EACvC,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EACnC,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,wBAAwB,EACxB,kCAAkC,EAClC,KAAK,kBAAkB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,+BAA+B,EAAE,MAAM,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../src/integration.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,iCAAiC,EACjC,KAAK,2BAA2B,EAChC,KAAK,kCAAkC,EACvC,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EACnC,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,wBAAwB,EACxB,kCAAkC,EAClC,oBAAoB,EACpB,KAAK,kBAAkB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,+BAA+B,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dist/integration.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
postImmediateLaunch
|
|
3
|
-
|
|
2
|
+
postImmediateLaunch,
|
|
3
|
+
withDefaultModelFixture
|
|
4
|
+
} from "./chunk-FDXRT6UZ.js";
|
|
4
5
|
import {
|
|
5
6
|
observe
|
|
6
7
|
} from "./chunk-KJVNI2UP.js";
|
|
@@ -9,32 +10,46 @@ import {
|
|
|
9
10
|
} from "./chunk-RY6Y6V5E.js";
|
|
10
11
|
import {
|
|
11
12
|
createTestServerSetupCapability
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-DNUGHAYN.js";
|
|
13
14
|
import {
|
|
14
15
|
createInProcessWorkerSpawn
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-3RWI5WJK.js";
|
|
16
17
|
import {
|
|
17
|
-
StubPiTreeHandleFactory
|
|
18
|
-
|
|
18
|
+
StubPiTreeHandleFactory,
|
|
19
|
+
formatBranchText
|
|
20
|
+
} from "./chunk-WRAVDPEM.js";
|
|
19
21
|
|
|
20
22
|
// src/extension-integration-harness.ts
|
|
21
23
|
import { randomUUID } from "crypto";
|
|
22
|
-
import { mkdirSync, writeFileSync } from "fs";
|
|
23
24
|
import path2 from "path";
|
|
24
|
-
import { buildExtensionCatalogFromModules } from "@leitwerk-dev/extension-runtime/testing";
|
|
25
|
+
import { buildExtensionCatalogFromModules as buildExtensionCatalogFromModules2 } from "@leitwerk-dev/extension-runtime/testing";
|
|
25
26
|
import {
|
|
26
27
|
coreHostCapabilities
|
|
27
28
|
} from "@leitwerk-dev/process-sdk";
|
|
28
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
createAcceptedWorkerTurn,
|
|
31
|
+
prepareAcceptedFixtureStart
|
|
32
|
+
} from "@leitwerk-dev/server/testing";
|
|
33
|
+
import { persistPiResourceBundleForStart } from "@leitwerk-dev/worker";
|
|
29
34
|
|
|
30
35
|
// src/integration-harness.ts
|
|
31
36
|
import { mkdtempSync, rmSync } from "fs";
|
|
32
37
|
import { tmpdir } from "os";
|
|
33
38
|
import path from "path";
|
|
39
|
+
import { buildExtensionCatalogFromModules } from "@leitwerk-dev/extension-runtime/testing";
|
|
34
40
|
import {
|
|
35
41
|
createAppContext,
|
|
36
42
|
getDefaultConfig
|
|
37
43
|
} from "@leitwerk-dev/server";
|
|
44
|
+
async function createTestAppContext(options = {}) {
|
|
45
|
+
const config = options.config ?? getDefaultConfig();
|
|
46
|
+
const catalog = await (options.extensionCatalog ?? buildExtensionCatalogFromModules([]));
|
|
47
|
+
return createAppContext({
|
|
48
|
+
...options,
|
|
49
|
+
config,
|
|
50
|
+
extensionCatalog: withDefaultModelFixture(config, catalog)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
38
53
|
function createPersistentIntegrationFixture(prefix, configure) {
|
|
39
54
|
const root = mkdtempSync(path.join(tmpdir(), prefix));
|
|
40
55
|
let harness;
|
|
@@ -87,7 +102,10 @@ async function createIntegrationHarness(opts) {
|
|
|
87
102
|
config.workers.runner = "local";
|
|
88
103
|
}
|
|
89
104
|
opts.configOverride?.(config);
|
|
90
|
-
const extensionCatalog =
|
|
105
|
+
const extensionCatalog = withDefaultModelFixture(
|
|
106
|
+
config,
|
|
107
|
+
await Promise.resolve(opts.extensionCatalog)
|
|
108
|
+
);
|
|
91
109
|
const appOpts = {
|
|
92
110
|
logger: false,
|
|
93
111
|
config,
|
|
@@ -134,7 +152,7 @@ async function createIntegrationHarness(opts) {
|
|
|
134
152
|
|
|
135
153
|
// src/extension-integration-harness.ts
|
|
136
154
|
async function createExtensionIntegrationHarness(options) {
|
|
137
|
-
const catalog = await
|
|
155
|
+
const catalog = await buildExtensionCatalogFromModules2([
|
|
138
156
|
...options.polling === "manual" ? [
|
|
139
157
|
{
|
|
140
158
|
manifest: { id: "test-support-manual-polling", version: "1" },
|
|
@@ -161,6 +179,7 @@ async function createExtensionIntegrationHarness(options) {
|
|
|
161
179
|
thinking_level: model.thinkingLevel ?? "off"
|
|
162
180
|
}));
|
|
163
181
|
if (options.defaultModel) {
|
|
182
|
+
config.pi.default_model_profile = options.defaultModel;
|
|
164
183
|
config.pi.process_title_generation.model_profile = options.defaultModel;
|
|
165
184
|
config.process_configs = Object.fromEntries(
|
|
166
185
|
[...catalog.processes.keys()].map((id) => [
|
|
@@ -196,11 +215,7 @@ async function createExtensionIntegrationHarness(options) {
|
|
|
196
215
|
const prompt = input.identifiedPromptText ?? input.promptText;
|
|
197
216
|
observation.prompts.push(prompt);
|
|
198
217
|
const session = [...piFactory.sessions].reverse().find((session2) => session2.treeFile === input.treeFile);
|
|
199
|
-
const history = session?.getBranch()
|
|
200
|
-
if (entry.type === "custom_message") return entry.content;
|
|
201
|
-
if (entry.type === "message" && entry.message) return entry.message.content;
|
|
202
|
-
return "";
|
|
203
|
-
}).filter((value) => typeof value === "string").join("\n\n") ?? "";
|
|
218
|
+
const history = formatBranchText(session?.getBranch(), "");
|
|
204
219
|
const script = manual ? scripts.get(id) : await options.script?.(
|
|
205
220
|
id,
|
|
206
221
|
prompt,
|
|
@@ -266,8 +281,7 @@ async function createExtensionIntegrationHarness(options) {
|
|
|
266
281
|
signal.removeEventListener("abort", abort);
|
|
267
282
|
pending.delete(id);
|
|
268
283
|
resolve();
|
|
269
|
-
}
|
|
270
|
-
reject
|
|
284
|
+
}
|
|
271
285
|
});
|
|
272
286
|
}) : void 0
|
|
273
287
|
}
|
|
@@ -383,8 +397,20 @@ async function createExtensionIntegrationHarness(options) {
|
|
|
383
397
|
fixture.turnId,
|
|
384
398
|
catalog.piContributions
|
|
385
399
|
) : null;
|
|
400
|
+
const turnId = `trn_${randomUUID()}`;
|
|
401
|
+
if (prepared)
|
|
402
|
+
await persistPiResourceBundleForStart({
|
|
403
|
+
bundlesDir: path2.join(
|
|
404
|
+
ctx.config.storage.process_workspaces_dir,
|
|
405
|
+
id,
|
|
406
|
+
".leitwerk",
|
|
407
|
+
"pi-resource-bundles"
|
|
408
|
+
),
|
|
409
|
+
startRecordId: `tsr_${turnId}`,
|
|
410
|
+
digest: prepared.bundle.digest,
|
|
411
|
+
deliveredBundle: prepared.bundle.bytes
|
|
412
|
+
});
|
|
386
413
|
return ctx.deps.transaction((repos) => {
|
|
387
|
-
const turnId = `trn_${randomUUID()}`;
|
|
388
414
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
389
415
|
const input = {
|
|
390
416
|
id: turnId,
|
|
@@ -399,76 +425,11 @@ async function createExtensionIntegrationHarness(options) {
|
|
|
399
425
|
endedAt: running ? null : timestamp,
|
|
400
426
|
turnResultMarkdown: fixture.execution.status === "succeeded" ? fixture.execution.markdown : null
|
|
401
427
|
};
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
".leitwerk",
|
|
408
|
-
"pi-resource-bundles"
|
|
409
|
-
);
|
|
410
|
-
mkdirSync(path2.join(bundleDir, "starts"), { recursive: true, mode: 448 });
|
|
411
|
-
writeFileSync(
|
|
412
|
-
path2.join(bundleDir, `${prepared.bundle.digest}.tar`),
|
|
413
|
-
prepared.bundle.bytes,
|
|
414
|
-
{ mode: 384 }
|
|
415
|
-
);
|
|
416
|
-
writeFileSync(
|
|
417
|
-
path2.join(bundleDir, "starts", `tsr_${turnId}.json`),
|
|
418
|
-
JSON.stringify({
|
|
419
|
-
startRecordId: `tsr_${turnId}`,
|
|
420
|
-
digest: prepared.bundle.digest,
|
|
421
|
-
persistedAt: timestamp
|
|
422
|
-
}),
|
|
423
|
-
{ mode: 384 }
|
|
424
|
-
);
|
|
425
|
-
createAcceptedLlmTurn(
|
|
426
|
-
{
|
|
427
|
-
...ctx,
|
|
428
|
-
deps: {
|
|
429
|
-
...ctx.deps,
|
|
430
|
-
processes: repos.processes,
|
|
431
|
-
turnRecords: repos.turnRecords,
|
|
432
|
-
turnStarts: repos.turnStarts,
|
|
433
|
-
leases: repos.leases
|
|
434
|
-
}
|
|
435
|
-
},
|
|
436
|
-
{ ...input, turnType: "llm", modelProfileId: prepared.start.model.profileId },
|
|
437
|
-
{ current: running, preparedStart: prepared?.start }
|
|
438
|
-
);
|
|
439
|
-
} else {
|
|
440
|
-
const lease = repos.leases.create({
|
|
441
|
-
instanceId: id,
|
|
442
|
-
workerId: `wkr_${randomUUID()}`,
|
|
443
|
-
state: running ? "busy" : "exited"
|
|
444
|
-
});
|
|
445
|
-
const start = repos.turnStarts.create({
|
|
446
|
-
instanceId: id,
|
|
447
|
-
turnId: fixture.turnId,
|
|
448
|
-
turnType: "automatic",
|
|
449
|
-
proposedTurnRecordId: turnId,
|
|
450
|
-
startKind: "selected_turn",
|
|
451
|
-
recoveryTurnRecordId: null,
|
|
452
|
-
continuation: null,
|
|
453
|
-
state: {
|
|
454
|
-
kind: "accepted",
|
|
455
|
-
start: { kind: "automatic" },
|
|
456
|
-
turnRecordId: turnId,
|
|
457
|
-
acceptedWorkerLeaseId: lease.id
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
repos.turnRecords.create({
|
|
461
|
-
...input,
|
|
462
|
-
turnType: "automatic",
|
|
463
|
-
turnStartRecordId: start.id,
|
|
464
|
-
acceptedWorkerLeaseId: lease.id
|
|
465
|
-
});
|
|
466
|
-
if (running)
|
|
467
|
-
repos.processes.update(id, {
|
|
468
|
-
currentExecution: { kind: "worker_start", id: start.id }
|
|
469
|
-
});
|
|
470
|
-
else repos.leases.update(lease.id, { exitedAt: timestamp });
|
|
471
|
-
}
|
|
428
|
+
createAcceptedWorkerTurn(
|
|
429
|
+
{ deps: repos },
|
|
430
|
+
{ ...input, turnType: turn.kind, modelProfileId: prepared?.start.model.profileId },
|
|
431
|
+
{ current: running, preparedStart: prepared?.start }
|
|
432
|
+
);
|
|
472
433
|
if (fixture.execution.status === "succeeded")
|
|
473
434
|
repos.turnAnnotations.create({
|
|
474
435
|
instanceId: id,
|
|
@@ -484,13 +445,9 @@ async function createExtensionIntegrationHarness(options) {
|
|
|
484
445
|
});
|
|
485
446
|
if (running) repos.processes.update(id, { lifecycleStatus: "active" });
|
|
486
447
|
return observe({
|
|
487
|
-
/** @public */
|
|
488
448
|
id: turnId,
|
|
489
|
-
/** @public */
|
|
490
449
|
instanceId: id,
|
|
491
|
-
/** @public */
|
|
492
450
|
turnId: fixture.turnId,
|
|
493
|
-
/** @public */
|
|
494
451
|
artifact: running ? null : { kind: "turn_result", turnRecordId: turnId }
|
|
495
452
|
});
|
|
496
453
|
});
|
|
@@ -527,17 +484,11 @@ async function createExtensionIntegrationHarness(options) {
|
|
|
527
484
|
const record = after.turns.find((turn2) => !previous.has(turn2.id));
|
|
528
485
|
const milestone = record ? context().deps.turnAnnotations.findByKey(id, `turn_milestone:${record.id}`) : null;
|
|
529
486
|
return observe({
|
|
530
|
-
/** @public */
|
|
531
487
|
turn: record ?? null,
|
|
532
|
-
/** @public */
|
|
533
488
|
outcome: typeof milestone?.payload.outcome === "string" ? milestone.payload.outcome : null,
|
|
534
|
-
/** @public */
|
|
535
489
|
failure: record?.errorSummary ?? (after.process.lifecycleStatus === "error" ? "Worker start failed before acceptance" : null),
|
|
536
|
-
/** @public */
|
|
537
490
|
prompts: observations.get(id)?.prompts ?? [],
|
|
538
|
-
/** @public */
|
|
539
491
|
toolResults: observations.get(id)?.toolResults ?? [],
|
|
540
|
-
/** @public */
|
|
541
492
|
result: record?.status === "succeeded" && record.turnResultMarkdown ? { kind: "turn_result", turnRecordId: record.id } : null
|
|
542
493
|
});
|
|
543
494
|
} finally {
|
|
@@ -579,9 +530,10 @@ async function createExtensionIntegrationHarness(options) {
|
|
|
579
530
|
/** Get a handle that remains valid across restart. @public */
|
|
580
531
|
process: processHandle,
|
|
581
532
|
/** Admit work through a registered UI launcher. @public */
|
|
582
|
-
async launch(id, input) {
|
|
533
|
+
async launch(id, input, modelConfig) {
|
|
583
534
|
const response = await postImmediateLaunch(context().config.server.base_url, id, {
|
|
584
|
-
launcherInput: input
|
|
535
|
+
launcherInput: input,
|
|
536
|
+
...modelConfig ? { modelConfig } : {}
|
|
585
537
|
});
|
|
586
538
|
const body = await response.json();
|
|
587
539
|
if (!response.ok || !body.process)
|
|
@@ -741,6 +693,7 @@ export {
|
|
|
741
693
|
createIntegrationHarness,
|
|
742
694
|
createPersistentIntegrationFixture,
|
|
743
695
|
createProcessDriver,
|
|
696
|
+
createTestAppContext,
|
|
744
697
|
createTestServerSetupCapability,
|
|
745
698
|
waitForValue
|
|
746
699
|
};
|