@leitwerk-dev/test-support 0.2.0 → 0.3.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-KPSK7EMY.js → chunk-5BZSJ4OO.js} +22 -157
- package/dist/chunk-5BZSJ4OO.js.map +1 -0
- package/dist/{chunk-2IICIB6D.js → chunk-E4Y7XND5.js} +40 -4
- package/dist/chunk-E4Y7XND5.js.map +1 -0
- package/dist/{chunk-JUH3LUYK.js → chunk-EXHTWQAE.js} +5 -1
- package/dist/chunk-EXHTWQAE.js.map +1 -0
- package/dist/chunk-KJVNI2UP.js +17 -0
- package/dist/chunk-KJVNI2UP.js.map +1 -0
- package/dist/{chunk-7I4OCTF3.js → chunk-OE4NHDVS.js} +15 -4
- package/dist/chunk-OE4NHDVS.js.map +1 -0
- package/dist/chunk-P2FF4AP7.js +72 -0
- package/dist/chunk-P2FF4AP7.js.map +1 -0
- package/dist/chunk-RY6Y6V5E.js +54 -0
- package/dist/chunk-RY6Y6V5E.js.map +1 -0
- package/dist/compact-process-detail-fixture.d.ts +3 -0
- package/dist/compact-process-detail-fixture.d.ts.map +1 -1
- package/dist/extension-integration-harness.d.ts +357 -0
- package/dist/extension-integration-harness.d.ts.map +1 -0
- package/dist/fakes/fake-git-ops.d.ts +12 -0
- package/dist/fakes/fake-git-ops.d.ts.map +1 -1
- package/dist/fakes/fake-llm.d.ts +11 -0
- package/dist/fakes/fake-llm.d.ts.map +1 -1
- package/dist/fakes/index.d.ts +1 -1
- package/dist/fakes/index.d.ts.map +1 -1
- package/dist/fakes/index.js +105 -4
- package/dist/fakes/index.js.map +1 -1
- package/dist/fixtures.d.ts +2 -0
- package/dist/fixtures.d.ts.map +1 -1
- package/dist/fixtures.js +157 -2
- package/dist/fixtures.js.map +1 -1
- package/dist/http-launch.d.ts +2 -1
- package/dist/http-launch.d.ts.map +1 -1
- package/dist/index.d.ts +6 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -119
- package/dist/index.js.map +1 -1
- package/dist/integration-harness.d.ts +36 -1
- package/dist/integration-harness.d.ts.map +1 -1
- package/dist/integration.d.ts +3 -3
- package/dist/integration.d.ts.map +1 -1
- package/dist/integration.js +693 -13
- package/dist/integration.js.map +1 -1
- package/dist/local-git.d.ts +105 -8
- package/dist/local-git.d.ts.map +1 -1
- package/dist/local-git.js +155 -24
- package/dist/local-git.js.map +1 -1
- package/dist/model-provider-fixtures.d.ts +9 -1
- package/dist/model-provider-fixtures.d.ts.map +1 -1
- package/dist/observations.d.ts +7 -0
- package/dist/observations.d.ts.map +1 -0
- package/dist/polling.d.ts +1 -0
- package/dist/polling.d.ts.map +1 -1
- package/dist/process-driver.d.ts +5 -1
- package/dist/process-driver.d.ts.map +1 -1
- package/dist/process-fixtures.d.ts +56 -0
- package/dist/process-fixtures.d.ts.map +1 -0
- package/dist/process.d.ts +440 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +484 -0
- package/dist/process.js.map +1 -0
- package/dist/question-fixtures.d.ts +2 -0
- package/dist/question-fixtures.d.ts.map +1 -1
- package/dist/server-extension-test-harness.d.ts +43 -3
- 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 +96 -0
- package/dist/supported-question-fixtures.d.ts.map +1 -0
- package/dist/test-capability.d.ts +9 -0
- package/dist/test-capability.d.ts.map +1 -0
- package/dist/test-diagnostics.d.ts +14 -0
- package/dist/test-diagnostics.d.ts.map +1 -0
- package/dist/worker-testing/in-process-worker-spawn.d.ts +19 -1
- package/dist/worker-testing/in-process-worker-spawn.d.ts.map +1 -1
- package/dist/worker-testing/index.d.ts +6 -7
- package/dist/worker-testing/index.d.ts.map +1 -1
- package/dist/worker-testing/index.js +32 -22
- package/dist/worker-testing/index.js.map +1 -1
- package/dist/worker-testing/schema-driven-stub-pi.d.ts +5 -0
- package/dist/worker-testing/schema-driven-stub-pi.d.ts.map +1 -1
- package/dist/worker-testing/stub-pi-controls.d.ts +4 -0
- package/dist/worker-testing/stub-pi-controls.d.ts.map +1 -1
- package/dist/worker-testing/stub-pi-tree-handle.d.ts +78 -2
- package/dist/worker-testing/stub-pi-tree-handle.d.ts.map +1 -1
- package/dist/worker-testing/worker-runtime-harness.d.ts +37 -2
- package/dist/worker-testing/worker-runtime-harness.d.ts.map +1 -1
- package/dist/worker-testing/worker-start-payload.d.ts +17 -1
- package/dist/worker-testing/worker-start-payload.d.ts.map +1 -1
- package/package.json +14 -8
- package/src/compact-process-detail-fixture.ts +9 -1
- package/src/extension-integration-harness.ts +1059 -0
- package/src/fakes/fake-git-ops.ts +12 -0
- package/src/fakes/fake-llm.ts +11 -0
- package/src/fakes/index.ts +1 -1
- package/src/fixtures.ts +16 -0
- package/src/http-launch.ts +2 -1
- package/src/index.ts +13 -42
- package/src/integration-harness.ts +100 -9
- package/src/integration.ts +23 -9
- package/src/local-git.ts +196 -45
- package/src/model-provider-fixtures.ts +15 -2
- package/src/observations.ts +19 -0
- package/src/polling.ts +1 -0
- package/src/process-driver.ts +7 -1
- package/src/process-fixtures.ts +123 -0
- package/src/process.ts +768 -0
- package/src/question-fixtures.ts +2 -0
- package/src/server-extension-test-harness.ts +64 -7
- package/src/supported-question-fixtures.ts +168 -0
- package/src/test-capability.ts +9 -0
- package/src/test-diagnostics.ts +69 -0
- package/src/worker-testing/in-process-worker-spawn.ts +44 -4
- package/src/worker-testing/index.ts +4 -30
- package/src/worker-testing/schema-driven-stub-pi.ts +8 -1
- package/src/worker-testing/stub-pi-controls.ts +4 -0
- package/src/worker-testing/stub-pi-tree-handle.ts +87 -3
- package/src/worker-testing/worker-runtime-harness.ts +57 -6
- package/src/worker-testing/worker-start-payload.ts +17 -1
- package/dist/chunk-2IICIB6D.js.map +0 -1
- package/dist/chunk-3MQO3NCX.js +0 -15
- package/dist/chunk-3MQO3NCX.js.map +0 -1
- package/dist/chunk-7I4OCTF3.js.map +0 -1
- package/dist/chunk-7ZK5QRGP.js +0 -98
- package/dist/chunk-7ZK5QRGP.js.map +0 -1
- package/dist/chunk-JUH3LUYK.js.map +0 -1
- package/dist/chunk-KPSK7EMY.js.map +0 -1
- package/dist/chunk-MV4W6NOO.js +0 -105
- package/dist/chunk-MV4W6NOO.js.map +0 -1
- package/dist/test-app.d.ts +0 -23
- package/dist/test-app.d.ts.map +0 -1
- package/src/test-app.ts +0 -82
package/dist/integration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/process-driver.ts"],"sourcesContent":["import type { ProcessInstance } from \"@leitwerk-dev/domain\";\nimport type { AppContext } from \"@leitwerk-dev/server\";\nimport { waitForValue } from \"./polling.js\";\n\n/** Drive a running or restarted app without bypassing process HTTP actions. */\nexport function createProcessDriver(context: () => AppContext) {\n\tasync function post(url: string, payload: Record<string, unknown> = {}) {\n\t\tconst response = await context().app.inject({ method: \"POST\", url, payload });\n\t\tif (response.statusCode !== 200)\n\t\t\tthrow new Error(`POST ${url} failed with ${response.statusCode}: ${response.body}`);\n\t\treturn response;\n\t}\n\tasync function waitForProcess(\n\t\tid: string,\n\t\tpredicate: (process: ProcessInstance) => boolean,\n\t\tdescription: string,\n\t\ttimeout = 12000,\n\t\tallowError = false,\n\t): Promise<ProcessInstance> {\n\t\ttry {\n\t\t\tconst process = await waitForValue(\n\t\t\t\t() => {\n\t\t\t\t\tconst current = context().deps.processes.getById(id);\n\t\t\t\t\tif (current?.lifecycleStatus === \"error\" && !allowError)\n\t\t\t\t\t\tthrow new Error(\"Process entered error lifecycle\");\n\t\t\t\t\treturn current;\n\t\t\t\t},\n\t\t\t\t(process) => !!process && predicate(process),\n\t\t\t\ttimeout,\n\t\t\t);\n\t\t\tif (!process) throw new Error(\"Missing process\");\n\t\t\treturn process;\n\t\t} catch (error) {\n\t\t\tconst { processes, turnRecords } = context().deps;\n\t\t\tthrow new Error(\n\t\t\t\t`Waiting for ${id}: ${description}; ${JSON.stringify({ process: processes.getById(id), turns: turnRecords.listByInstance(id) })}`,\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\tpost,\n\t\twaitForProcess,\n\t\twait: (id: string, turn: string | null, lifecycle = \"waiting\", timeout = 12000) =>\n\t\t\twaitForProcess(\n\t\t\t\tid,\n\t\t\t\t(p) => p.selectedTurnId === turn && p.lifecycleStatus === lifecycle,\n\t\t\t\t`${turn}/${lifecycle}`,\n\t\t\t\ttimeout,\n\t\t\t\tlifecycle === \"error\",\n\t\t\t),\n\t\taction: (id: string, action: string, input: Record<string, unknown> = {}) =>\n\t\t\tpost(`/api/processes/${encodeURIComponent(id)}/actions/${encodeURIComponent(action)}`, {\n\t\t\t\tinput,\n\t\t\t}),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;AAKO,SAAS,oBAAoB,SAA2B;AAC9D,iBAAe,KAAK,KAAa,UAAmC,CAAC,GAAG;AACvE,UAAM,WAAW,MAAM,QAAQ,EAAE,IAAI,OAAO,EAAE,QAAQ,QAAQ,KAAK,QAAQ,CAAC;AAC5E,QAAI,SAAS,eAAe;AAC3B,YAAM,IAAI,MAAM,QAAQ,GAAG,gBAAgB,SAAS,UAAU,KAAK,SAAS,IAAI,EAAE;AACnF,WAAO;AAAA,EACR;AACA,iBAAe,eACd,IACA,WACA,aACA,UAAU,MACV,aAAa,OACc;AAC3B,QAAI;AACH,YAAM,UAAU,MAAM;AAAA,QACrB,MAAM;AACL,gBAAM,UAAU,QAAQ,EAAE,KAAK,UAAU,QAAQ,EAAE;AACnD,cAAI,SAAS,oBAAoB,WAAW,CAAC;AAC5C,kBAAM,IAAI,MAAM,iCAAiC;AAClD,iBAAO;AAAA,QACR;AAAA,QACA,CAACA,aAAY,CAAC,CAACA,YAAW,UAAUA,QAAO;AAAA,QAC3C;AAAA,MACD;AACA,UAAI,CAAC,QAAS,OAAM,IAAI,MAAM,iBAAiB;AAC/C,aAAO;AAAA,IACR,SAAS,OAAO;AACf,YAAM,EAAE,WAAW,YAAY,IAAI,QAAQ,EAAE;AAC7C,YAAM,IAAI;AAAA,QACT,eAAe,EAAE,KAAK,WAAW,KAAK,KAAK,UAAU,EAAE,SAAS,UAAU,QAAQ,EAAE,GAAG,OAAO,YAAY,eAAe,EAAE,EAAE,CAAC,CAAC;AAAA,QAC/H,EAAE,OAAO,MAAM;AAAA,MAChB;AAAA,IACD;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,MAAM,CAAC,IAAY,MAAqB,YAAY,WAAW,UAAU,SACxE;AAAA,MACC;AAAA,MACA,CAAC,MAAM,EAAE,mBAAmB,QAAQ,EAAE,oBAAoB;AAAA,MAC1D,GAAG,IAAI,IAAI,SAAS;AAAA,MACpB;AAAA,MACA,cAAc;AAAA,IACf;AAAA,IACD,QAAQ,CAAC,IAAY,QAAgB,QAAiC,CAAC,MACtE,KAAK,kBAAkB,mBAAmB,EAAE,CAAC,YAAY,mBAAmB,MAAM,CAAC,IAAI;AAAA,MACtF;AAAA,IACD,CAAC;AAAA,EACH;AACD;","names":["process"]}
|
|
1
|
+
{"version":3,"sources":["../src/extension-integration-harness.ts","../src/integration-harness.ts","../src/polling.ts","../src/process-driver.ts"],"sourcesContent":["import type { ExtensionTestCapability } from \"./test-capability.js\";\n\nexport type { ExtensionTestCapability } from \"./test-capability.js\";\n\nimport { randomUUID } from \"node:crypto\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n\tActor,\n\tExternalWriteLog,\n\tProcessInstance,\n\tProcessProject,\n\tProcessTurnRecord,\n} from \"@leitwerk-dev/domain\";\nimport { buildExtensionCatalogFromModules } from \"@leitwerk-dev/extension-runtime/testing\";\nimport {\n\tcoreHostCapabilities,\n\ttype ExtensionProcessDefinition,\n\ttype LeitwerkExtensionModule,\n} from \"@leitwerk-dev/process-sdk\";\nimport { createAcceptedLlmTurn, prepareAcceptedFixtureStart } from \"@leitwerk-dev/server/testing\";\nimport { postImmediateLaunch } from \"./http-launch.js\";\nimport { createPersistentIntegrationFixture } from \"./integration-harness.js\";\nimport { observe, type TestObservation } from \"./observations.js\";\nimport { createProcessFixture, type ProcessFixtureOptions } from \"./process-fixtures.js\";\nimport type { QuestionRequestFixture } from \"./supported-question-fixtures.js\";\nimport { StubPiTreeHandleFactory } from \"./worker-testing/stub-pi-tree-handle.js\";\n\n/** Model-visible inputs for a scripted invocation. @public */\nexport interface IntegrationPromptObservation {\n\t/** @public */\n\tturnId: string;\n\t/** Working directory available for fixture repository edits. @public */\n\tcwd: string;\n\t/** Opaque branch-session identity for comparing execution relationships. @public */\n\tbranchId: string;\n\t/** Text inherited by the current branch. @public */\n\thistory: string;\n\t/** @public */\n\ttools: readonly {\n\t\t/** @public */\n\t\tname: string;\n\t\t/** @public */\n\t\tparameters: Record<string, unknown>;\n\t}[];\n}\n\n/** Rendered result retained at a tree leaf. @public */\nexport interface IntegrationLeafObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tleafEntryId: string;\n\t/** @public */\n\tturnRecordId: string | null;\n\t/** @public */\n\trendererId: string | null;\n\t/** @public */\n\tschemaVersion: number | null;\n\t/** @public */\n\tprops: Record<string, unknown> | null;\n\t/** @public */\n\tfallbackMarkdown: string | null;\n\t/** @public */\n\tstatus: \"ready\" | \"capture_error\";\n}\n\n/** Recorded semantic event. @public */\nexport interface IntegrationEventObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\teventType: string;\n\t/** @public */\n\tdata: Record<string, unknown>;\n\t/** @public */\n\tcreatedAt: string;\n}\n\n/** Durable annotation of process execution. @public */\nexport interface IntegrationAnnotationObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tannotationType: string;\n\t/** @public */\n\tpayload: Record<string, unknown>;\n}\n\n/** One scripted model prompt, executed through registered tools. @public */\nexport interface IntegrationTurnScript {\n\t/** @public */\n\ttools: readonly IntegrationToolCall[];\n\t/** Scripted reasoning retained by the normal worker path. @public */\n\tthinking?: readonly string[];\n\t/** Assistant markdown for turns completed by model output. @public */\n\tmarkdown?: string;\n\t/** Optional model response after an integration-tool result. @public */\n\tafterToolResult?(call: IntegrationToolCall, result: unknown): IntegrationToolCall | undefined;\n}\n\n/** @public */\nexport interface IntegrationToolCall {\n\t/** @public */\n\tname: string;\n\t/** @public */\n\targuments: Record<string, unknown>;\n}\n\n/** Instruction delivered through the application's durable input queue. @public */\nexport interface IntegrationProcessInput {\n\t/** @public */\n\tbodyMarkdown: string;\n\t/** Target a published product branch. @public */\n\tproduct?: string;\n}\n\n/** Durable instruction delivery observations. @public */\nexport interface IntegrationInputObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tsequence: number;\n\t/** @public */\n\tsource: string;\n\t/** @public */\n\tkind: string;\n\t/** @public */\n\tbodyMarkdown: string;\n\t/** @public */\n\ttarget: {\n\t\t/** @public */\n\t\tproductName?: string;\n\t\t/** @public */\n\t\tsemanticRef?: string;\n\t} | null;\n\t/** @public */\n\tactor: Actor;\n\t/** @public */\n\treceivedAt: string;\n\t/** @public */\n\tconsumedAt: string | null;\n}\n\n/** Operator approval observations. @public */\nexport interface IntegrationApprovalObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tturnRecordId: string;\n\t/** @public */\n\ttoolCallId: string;\n\t/** @public */\n\ttoolName: string;\n\t/** @public */\n\targuments: Record<string, unknown>;\n\t/** @public */\n\tdestination: {\n\t\t/** @public */\n\t\tid: string;\n\t\t/** @public */\n\t\tdisplayName: string;\n\t\t/** @public */\n\t\tgroup?: string;\n\t\t/** @public */\n\t\tdescription?: string;\n\t} | null;\n\t/** @public */\n\tstatus: \"open\" | \"accepted\" | \"feedback\" | \"declined\" | \"cancelled\";\n\t/** @public */\n\trequestedAt: string;\n\t/** @public */\n\tresolvedAt: string | null;\n\t/** @public */\n\tresolvedBy: Actor | null;\n\t/** @public */\n\tfeedback: string | null;\n}\n\n/** Explicit accepted execution setup, independent of process business state. @public */\nexport interface AcceptedTurnFixture {\n\t/** @public */\n\tturnId: string;\n\t/** @public */\n\texecution:\n\t\t| {\n\t\t\t\t/** @public */\n\t\t\t\tstatus: \"running\";\n\t\t }\n\t\t| {\n\t\t\t\t/** @public */\n\t\t\t\tstatus: \"succeeded\";\n\t\t\t\t/** @public */\n\t\t\t\toutcome: string;\n\t\t\t\t/** @public */\n\t\t\t\tmarkdown: string;\n\t\t };\n}\n\n/** Detached durable observations. @public */\nexport interface ExtensionIntegrationSnapshot {\n\t/** Harness-owned process workspace. @public */\n\tworkspaceRoot: string;\n\t/** @public */\n\tevents: IntegrationEventObservation[];\n\t/** @public */\n\tannotations: IntegrationAnnotationObservation[];\n\t/** @public */\n\tleafOutcomes: IntegrationLeafObservation[];\n\n\t/** @public */\n\tprocess: ProcessInstance;\n\t/** @public */\n\tparams: unknown;\n\t/** @public */\n\tstate: unknown;\n\t/** @public */\n\tprojects: ProcessProject[];\n\t/** @public */\n\tturns: ProcessTurnRecord[];\n\t/** @public */\n\tinputs: IntegrationInputObservation[];\n\t/** @public */\n\tquestions: QuestionRequestFixture[];\n\t/** @public */\n\tapprovals: IntegrationApprovalObservation[];\n\t/** @public */\n\twriteReceipts: ExternalWriteLog[];\n}\n\n/** @public */\nexport interface ExtensionIntegrationHarnessOptions {\n\t/** Per-process watcher configuration. @public */\n\twatchers?: Readonly<Record<string, Record<string, unknown>>>;\n\t/** Advance extension provider pollers explicitly in tests. @public */\n\tpolling?: \"automatic\" | \"manual\";\n\t/** Host Docker boundary for extensions which require it. @public */\n\thostDocker?: {\n\t\t/** @public */\n\t\tpreflight(timeoutMs: number): Promise<void>;\n\t};\n\n\t/** Configuration keyed by extension manifest id. @public */\n\textensionConfig?: Readonly<Record<string, unknown>>;\n\t/** @public */\n\textensions: readonly LeitwerkExtensionModule[];\n\t/** @public */\n\tcapabilities?: readonly ExtensionTestCapability[];\n\t/** Automatic execution starts admitted work immediately. @public */\n\texecution?: \"automatic\" | \"manual\";\n\t/** Model catalog used by the supplied provider extensions. @public */\n\tmodels?: readonly {\n\t\t/** @public */\n\t\tid: string;\n\t\t/** @public */\n\t\tprovider: string;\n\t\t/** @public */\n\t\tmodelId: string;\n\t\t/** @public */\n\t\tthinkingLevel?: \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\";\n\t}[];\n\t/** Default model profile for all registered processes. @public */\n\tdefaultModel?: string;\n\t/** Model scripts for automatic execution, in prompt order per process. @public */\n\tscript?(\n\t\tinstanceId: string,\n\t\tprompt: string,\n\t\tobservation: TestObservation<IntegrationPromptObservation>,\n\t): IntegrationTurnScript | Promise<IntegrationTurnScript>;\n}\n\n/** HTTP-shaped requests without a Fastify handle. @public */\nexport interface ExtensionTestRequest {\n\t/** @public */\n\tmethod?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\t/** @public */\n\turl: string;\n\t/** @public */\n\tpayload?: Record<string, unknown>;\n\t/** @public */\n\theaders?: Record<string, string>;\n}\n\n/** HTTP response observation. @public */\nexport interface ExtensionTestResponse {\n\t/** @public */\n\tstatusCode: number;\n\t/** @public */\n\tbody: string;\n\t/** @public */\n\tjson<T = unknown>(): T;\n}\n\n/** Accepted turn identity and optional retained result. @public */\nexport interface AcceptedTurnReference {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tturnId: string;\n\t/** @public */\n\tartifact: {\n\t\t/** @public */ kind: \"turn_result\";\n\t\t/** @public */\n\t\tturnRecordId: string;\n\t} | null;\n}\n\n/** One durably settled worker execution. @public */\nexport interface IntegrationTurnResult {\n\t/** @public */\n\tturn: ProcessTurnRecord | null;\n\t/** @public */\n\toutcome: string | null;\n\t/** @public */\n\tfailure: string | null;\n\t/** @public */\n\tprompts: string[];\n\t/** @public */\n\ttoolResults: {\n\t\t/** @public */ name: string;\n\t\t/** @public */\n\t\tresult: unknown;\n\t}[];\n\t/** @public */\n\tresult: AcceptedTurnReference[\"artifact\"];\n}\n\n/** Durable process commands and observations. @public */\nexport interface ExtensionIntegrationProcess {\n\t/** @public */\n\treadonly id: string;\n\t/** @public */\n\tseedAcceptedTurn(fixture: AcceptedTurnFixture): Promise<TestObservation<AcceptedTurnReference>>;\n\t/** @public */\n\tsnapshot(): TestObservation<ExtensionIntegrationSnapshot>;\n\t/** @public */\n\twaitFor(\n\t\tcondition: (snapshot: TestObservation<ExtensionIntegrationSnapshot>) => boolean,\n\t\toptions?: {\n\t\t\t/** @public */ timeoutMs?: number;\n\t\t\t/** @public */\n\t\t\tdescription?: string;\n\t\t},\n\t): Promise<TestObservation<ExtensionIntegrationSnapshot>>;\n\t/** @public */\n\trunTurn(script?: IntegrationTurnScript): Promise<TestObservation<IntegrationTurnResult>>;\n\t/** @public */\n\taction(id: string, input?: Record<string, unknown>): Promise<ExtensionTestResponse>;\n\t/** @public */\n\tretry(): Promise<ExtensionTestResponse>;\n\t/** @public */\n\tsupplyInput(\n\t\tinput: IntegrationProcessInput,\n\t): Promise<TestObservation<ExtensionIntegrationSnapshot>>;\n\t/** @public */\n\tanswerQuestions(\n\t\tid: string,\n\t\tanswers: readonly {\n\t\t\t/** @public */\n\t\t\tselectedOptionIds: readonly string[];\n\t\t\t/** @public */\n\t\t\tfreeText: string;\n\t\t\t/** @public */\n\t\t\tcomment: string;\n\t\t}[],\n\t): Promise<ExtensionTestResponse>;\n\t/** @public */\n\trespondToApproval(\n\t\tid: string,\n\t\tresponse: {\n\t\t\t/** @public */\n\t\t\taction: \"accept\" | \"feedback\" | \"decline\";\n\t\t\t/** @public */\n\t\t\tfeedback?: string;\n\t\t},\n\t): Promise<ExtensionTestResponse>;\n}\n\n/** Disposable persistent extension test environment. @public */\nexport interface ExtensionIntegrationHarness {\n\t/** Detached processes discovered or launched by extensions. @public */\n\tprocesses(): TestObservation<ProcessInstance[]>;\n\n\t/** @public */\n\trequest(input: ExtensionTestRequest): Promise<ExtensionTestResponse>;\n\t/** @public */\n\tprocess(id: string): ExtensionIntegrationProcess;\n\t/** @public */\n\tlaunch(id: string, input: Record<string, unknown>): Promise<ExtensionIntegrationProcess>;\n\t/** @public */\n\tcreateProcess<TParams, TState>(\n\t\tdefinition: ExtensionProcessDefinition<TParams, TState>,\n\t\tinput?: Omit<ProcessFixtureOptions<TParams, TState>, \"id\" | \"processId\"> & {\n\t\t\t/** @public */\n\t\t\tprojects?: readonly ProcessProject[];\n\t\t},\n\t): Promise<ExtensionIntegrationProcess>;\n\t/** @public */\n\trestart(options?: {\n\t\t/** Update extension wiring on the reopened server. @public */\n\t\textensionConfig?: Readonly<Record<string, unknown>>;\n\t\t/** Apply external changes while the server is offline. @public */\n\t\twhileStopped?(): void | Promise<void>;\n\t}): Promise<void>;\n\t/** @public */\n\tclose(): Promise<void>;\n}\n\n/** Own server, workers, and disposable persistent storage. @public */\nexport async function createExtensionIntegrationHarness(\n\toptions: ExtensionIntegrationHarnessOptions,\n): Promise<ExtensionIntegrationHarness> {\n\tconst catalog = await buildExtensionCatalogFromModules([\n\t\t...(options.polling === \"manual\"\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmanifest: { id: \"test-support-manual-polling\", version: \"1\" },\n\t\t\t\t\t\tsetupServer(api: import(\"@leitwerk-dev/process-sdk\").ServerExtensionAPI) {\n\t\t\t\t\t\t\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\t\t\t\t\t\t\tif (!deps || Array.isArray(deps)) throw new Error(\"Missing polling host\");\n\t\t\t\t\t\t\tdeps.polling = {\n\t\t\t\t\t\t\t\tcreate(input) {\n\t\t\t\t\t\t\t\t\treturn { poll: input.pollOnce };\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: []),\n\t\t...options.extensions,\n\t]);\n\tconst persistent = createPersistentIntegrationFixture(\"leitwerk-extension-test-\", (config) => {\n\t\tconfig.extensions = structuredClone(options.extensionConfig ?? {});\n\t\tif (options.hostDocker && config.local_worker) config.local_worker.allow_host_docker = true;\n\t\tconfig.pi.model_profiles = (options.models ?? []).map((model) => ({\n\t\t\tid: model.id,\n\t\t\tprovider: model.provider,\n\t\t\tmodel_id: model.modelId,\n\t\t\tthinking_level: model.thinkingLevel ?? \"off\",\n\t\t}));\n\t\tif (options.defaultModel) {\n\t\t\tconfig.pi.process_title_generation.model_profile = options.defaultModel;\n\t\t\tconfig.process_configs = Object.fromEntries(\n\t\t\t\t[...catalog.processes.keys()].map((id) => [\n\t\t\t\t\tid,\n\t\t\t\t\t{\n\t\t\t\t\t\tdefault_model_profile: options.defaultModel,\n\t\t\t\t\t\tturn_configs: {},\n\t\t\t\t\t\twatchers: structuredClone(options.watchers?.[id] ?? {}),\n\t\t\t\t\t},\n\t\t\t\t]),\n\t\t\t);\n\t\t}\n\t});\n\tconst manual = options.execution === \"manual\";\n\tlet closed = false;\n\tconst pending = new Map<\n\t\tstring,\n\t\t{ turnId: string; resolve(): void; reject(error: Error): void }\n\t>();\n\tconst permits = new Set<string>();\n\tconst executing = new Set<string>();\n\tconst scripts = new Map<string, IntegrationTurnScript>();\n\tconst observations = new Map<\n\t\tstring,\n\t\t{ prompts: string[]; toolResults: { name: string; result: unknown }[] }\n\t>();\n\tconst context = () => {\n\t\tif (closed) throw new Error(\"Extension integration harness is closed\");\n\t\treturn persistent.context();\n\t};\n\tasync function open() {\n\t\tconst piFactory: StubPiTreeHandleFactory = new StubPiTreeHandleFactory({\n\t\t\trecordSessionTrace: true,\n\t\t\ttoolCallScriptResolver: async (input) => {\n\t\t\t\tconst id = input.instanceId;\n\t\t\t\tif (!id) throw new Error(\"Scripted prompt has no process identity\");\n\t\t\t\tconst observation = observations.get(id) ?? { prompts: [], toolResults: [] };\n\t\t\t\tobservations.set(id, observation);\n\t\t\t\tconst prompt = input.identifiedPromptText ?? input.promptText;\n\t\t\t\tobservation.prompts.push(prompt);\n\t\t\t\tconst session = [...piFactory.sessions]\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.find((session) => session.treeFile === input.treeFile);\n\t\t\t\tconst history =\n\t\t\t\t\tsession\n\t\t\t\t\t\t?.getBranch()\n\t\t\t\t\t\t.map((entry) => {\n\t\t\t\t\t\t\tif (entry.type === \"custom_message\") return entry.content;\n\t\t\t\t\t\t\tif (entry.type === \"message\" && entry.message) return entry.message.content;\n\t\t\t\t\t\t\treturn \"\";\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((value) => typeof value === \"string\")\n\t\t\t\t\t\t.join(\"\\n\\n\") ?? \"\";\n\t\t\t\tconst script = manual\n\t\t\t\t\t? scripts.get(id)\n\t\t\t\t\t: await options.script?.(\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tprompt,\n\t\t\t\t\t\t\tobserve({\n\t\t\t\t\t\t\t\tturnId: context().deps.processes.getById(id)?.selectedTurnId ?? \"\",\n\t\t\t\t\t\t\t\tcwd: input.sessionCwd ?? input.workspaceRoot ?? \"\",\n\t\t\t\t\t\t\t\tbranchId: session?.sessionId ?? \"\",\n\t\t\t\t\t\t\t\thistory,\n\t\t\t\t\t\t\t\ttools: input.tools.map((tool) => ({\n\t\t\t\t\t\t\t\t\tname: tool.name,\n\t\t\t\t\t\t\t\t\tparameters: tool.parameters,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\tscripts.delete(id);\n\t\t\t\tif (!script || (script.tools.length === 0 && script.markdown === undefined))\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Script exhausted for process '${id}' after ${observation.prompts.length} prompt(s)`,\n\t\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tthinkingChunks: script.thinking ? [...script.thinking] : undefined,\n\t\t\t\t\ttextChunks: script.markdown === undefined ? undefined : [script.markdown],\n\t\t\t\t\tcalls: script.tools.map((call) => ({\n\t\t\t\t\t\ttoolName: call.name,\n\t\t\t\t\t\targs: structuredClone(call.arguments),\n\t\t\t\t\t})),\n\t\t\t\t\tafterToolResult(call, result) {\n\t\t\t\t\t\tobservation.toolResults.push({ name: call.toolName, result: structuredClone(result) });\n\t\t\t\t\t\tconst next = script.afterToolResult?.(\n\t\t\t\t\t\t\t{ name: call.toolName, arguments: structuredClone(call.args) },\n\t\t\t\t\t\t\tstructuredClone(result),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn next ? { toolName: next.name, args: next.arguments } : undefined;\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t});\n\t\tawait persistent.open({\n\t\t\tappOverrides: options.hostDocker\n\t\t\t\t? { localWorkerDockerPreflightImpl: options.hostDocker.preflight }\n\t\t\t\t: undefined,\n\t\t\textensionCatalog: catalog,\n\t\t\tpreProvidedCapabilities: options.capabilities,\n\t\t\tinProcessWorkers: {\n\t\t\t\tpiFactory,\n\t\t\t\tbeforeTurnBootstrap: manual\n\t\t\t\t\t? (id, turnId, signal) =>\n\t\t\t\t\t\t\tnew Promise<void>((resolve, reject) => {\n\t\t\t\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (permits.delete(id)) {\n\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (pending.has(id)) {\n\t\t\t\t\t\t\t\t\treject(new Error(`Conflicting pending worker for '${id}'`));\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst abort = () => {\n\t\t\t\t\t\t\t\t\tpending.delete(id);\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tsignal.addEventListener(\"abort\", abort, { once: true });\n\t\t\t\t\t\t\t\tpending.set(id, {\n\t\t\t\t\t\t\t\t\tturnId,\n\t\t\t\t\t\t\t\t\tresolve() {\n\t\t\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", abort);\n\t\t\t\t\t\t\t\t\t\tpending.delete(id);\n\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\treject,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t})\n\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t});\n\t}\n\ttry {\n\t\tawait open();\n\t} catch (error) {\n\t\tawait persistent.dispose();\n\t\tthrow error;\n\t}\n\t/** @public */\n\tasync function request(input: ExtensionTestRequest) {\n\t\tconst response = await context().app.inject({ ...input, method: input.method ?? \"GET\" });\n\t\treturn {\n\t\t\t/** @public */\n\t\t\tstatusCode: response.statusCode,\n\t\t\t/** @public */\n\t\t\tbody: response.body,\n\t\t\t/** @public */\n\t\t\tjson<T = unknown>(): T {\n\t\t\t\treturn JSON.parse(response.body) as T;\n\t\t\t},\n\t\t};\n\t}\n\tasync function post(url: string, payload: Record<string, unknown> = {}) {\n\t\tconst response = await request({ method: \"POST\", url, payload });\n\t\tif (response.statusCode >= 400)\n\t\t\tthrow new Error(`POST ${url}: ${response.statusCode} ${response.body}`);\n\t\treturn response;\n\t}\n\t/** @public */\n\tfunction processHandle(id: string): ExtensionIntegrationProcess {\n\t\tconst prefix = `/api/processes/${encodeURIComponent(id)}`;\n\t\t/** @public */\n\t\tfunction snapshot(): TestObservation<ExtensionIntegrationSnapshot> {\n\t\t\tconst { deps } = context();\n\t\t\tconst process = deps.processes.getById(id);\n\t\t\tif (!process) throw new Error(`Unknown process '${id}'`);\n\t\t\tconst definition = catalog.processes.get(process.processId);\n\t\t\treturn observe({\n\t\t\t\tworkspaceRoot: path.join(context().config.storage.process_workspaces_dir, id),\n\t\t\t\tevents: deps.events.listByInstance(id),\n\t\t\t\tannotations: deps.turnAnnotations.listByInstance(id),\n\t\t\t\tleafOutcomes: deps.leafOutcomeSnapshots.listByInstance(id),\n\t\t\t\tprocess,\n\t\t\t\tparams: definition?.paramsCodec.parse(JSON.parse(process.paramsJson ?? \"null\")),\n\t\t\t\tstate: definition?.stateCodec.parse(JSON.parse(process.stateJson ?? \"null\")),\n\t\t\t\tprojects: deps.projects.listByInstance(id),\n\t\t\t\tturns: deps.turnRecords.listByInstance(id),\n\t\t\t\tinputs: deps.inputs.listByInstance(id),\n\t\t\t\tquestions: deps.questionRequests.listByInstance(id),\n\t\t\t\tapprovals: deps.toolApprovalRequests.listByInstance(id),\n\t\t\t\twriteReceipts: deps.externalWrites.listByInstance(id),\n\t\t\t});\n\t\t}\n\t\t/** @public */\n\t\tasync function waitFor(\n\t\t\tcondition: (snapshot: TestObservation<ExtensionIntegrationSnapshot>) => boolean,\n\t\t\toptions: {\n\t\t\t\t/** @public */\n\t\t\t\ttimeoutMs?: number;\n\t\t\t\t/** @public */\n\t\t\t\tdescription?: string;\n\t\t\t} = {},\n\t\t) {\n\t\t\tconst deadline = Date.now() + (options.timeoutMs ?? 12000);\n\t\t\tfor (;;) {\n\t\t\t\tconst current = snapshot();\n\t\t\t\tif (condition(current)) return current;\n\t\t\t\tif (Date.now() >= deadline)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Timed out waiting for ${id}: ${options.description ?? \"condition\"}; ${JSON.stringify({\n\t\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t\t\tselectedTurnId: current.process.selectedTurnId,\n\t\t\t\t\t\t\t\tlifecycleStatus: current.process.lifecycleStatus,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tturns: current.turns.map((turn) => ({\n\t\t\t\t\t\t\t\tid: turn.id,\n\t\t\t\t\t\t\t\tturnId: turn.turnId,\n\t\t\t\t\t\t\t\tstatus: turn.status,\n\t\t\t\t\t\t\t\terror: turn.errorSummary,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\tinputs: current.inputs.map((input) => ({\n\t\t\t\t\t\t\t\tid: input.id,\n\t\t\t\t\t\t\t\tconsumedAt: input.consumedAt,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\tquestions: current.questions.map((question) => ({\n\t\t\t\t\t\t\t\tid: question.id,\n\t\t\t\t\t\t\t\tstatus: question.status,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\tapprovals: current.approvals.map((approval) => ({\n\t\t\t\t\t\t\t\tid: approval.id,\n\t\t\t\t\t\t\t\tstatus: approval.status,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t})}`,\n\t\t\t\t\t);\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 10));\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t/** @public */\n\t\t\tid,\n\t\t\t/** Establish correlated accepted records under exclusive server coordination. @public */\n\t\t\tasync seedAcceptedTurn(fixture: AcceptedTurnFixture) {\n\t\t\t\tconst ctx = context();\n\t\t\t\treturn ctx.deps.processOperations.runExclusive(id, async () => {\n\t\t\t\t\tconst process = ctx.deps.processes.getById(id);\n\t\t\t\t\tif (!process) throw new Error(`Unknown process '${id}'`);\n\t\t\t\t\tconst turn = catalog.processes\n\t\t\t\t\t\t.get(process.processId)\n\t\t\t\t\t\t?.turns.get(fixture.turnId)?.definition;\n\t\t\t\t\tif (!turn || (turn.kind !== \"llm\" && turn.kind !== \"automatic\"))\n\t\t\t\t\t\tthrow new Error(`Undeclared worker turn '${fixture.turnId}'`);\n\t\t\t\t\tif (process.currentExecution || ctx.deps.leases.getByInstance(id))\n\t\t\t\t\t\tthrow new Error(\"Cannot seed accepted execution while a live execution exists\");\n\t\t\t\t\tconst running = fixture.execution.status === \"running\";\n\t\t\t\t\tif (running && process.selectedTurnId !== fixture.turnId)\n\t\t\t\t\t\tthrow new Error(\"Running fixture must match the selected turn\");\n\t\t\t\t\tif (\n\t\t\t\t\t\tfixture.execution.status === \"succeeded\" &&\n\t\t\t\t\t\t!Object.hasOwn(turn.outcomes ?? {}, fixture.execution.outcome) &&\n\t\t\t\t\t\tturn.turnEnd?.outcome !== fixture.execution.outcome\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new Error(`Undeclared outcome '${fixture.execution.outcome}'`);\n\t\t\t\t\tif (fixture.execution.status === \"succeeded\" && !fixture.execution.markdown.trim())\n\t\t\t\t\t\tthrow new Error(\"A successful accepted fixture requires non-empty result markdown\");\n\t\t\t\t\tconst prepared =\n\t\t\t\t\t\tturn.kind === \"llm\"\n\t\t\t\t\t\t\t? await prepareAcceptedFixtureStart(\n\t\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\tprocess,\n\t\t\t\t\t\t\t\t\tfixture.turnId,\n\t\t\t\t\t\t\t\t\tcatalog.piContributions,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\treturn ctx.deps.transaction((repos) => {\n\t\t\t\t\t\tconst turnId = `trn_${randomUUID()}`;\n\t\t\t\t\t\tconst timestamp = new Date().toISOString();\n\t\t\t\t\t\tconst input = {\n\t\t\t\t\t\t\tid: turnId,\n\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\tturnId: fixture.turnId,\n\t\t\t\t\t\t\tstatus: fixture.execution.status,\n\t\t\t\t\t\t\tattemptNumber:\n\t\t\t\t\t\t\t\tMath.max(\n\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t...repos.turnRecords\n\t\t\t\t\t\t\t\t\t\t.listByInstance(id)\n\t\t\t\t\t\t\t\t\t\t.filter((record) => record.turnId === fixture.turnId)\n\t\t\t\t\t\t\t\t\t\t.map((record) => record.attemptNumber),\n\t\t\t\t\t\t\t\t) + 1,\n\t\t\t\t\t\t\tstartedAt: timestamp,\n\t\t\t\t\t\t\tendedAt: running ? null : timestamp,\n\t\t\t\t\t\t\tturnResultMarkdown:\n\t\t\t\t\t\t\t\tfixture.execution.status === \"succeeded\" ? fixture.execution.markdown : null,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (turn.kind === \"llm\") {\n\t\t\t\t\t\t\tif (!prepared) throw new Error(\"Missing fixture preparation\");\n\t\t\t\t\t\t\tconst bundleDir = path.join(\n\t\t\t\t\t\t\t\tctx.config.storage.process_workspaces_dir,\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\".leitwerk\",\n\t\t\t\t\t\t\t\t\"pi-resource-bundles\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tmkdirSync(path.join(bundleDir, \"starts\"), { recursive: true, mode: 0o700 });\n\t\t\t\t\t\t\twriteFileSync(\n\t\t\t\t\t\t\t\tpath.join(bundleDir, `${prepared.bundle.digest}.tar`),\n\t\t\t\t\t\t\t\tprepared.bundle.bytes,\n\t\t\t\t\t\t\t\t{ mode: 0o600 },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\twriteFileSync(\n\t\t\t\t\t\t\t\tpath.join(bundleDir, \"starts\", `tsr_${turnId}.json`),\n\t\t\t\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\t\t\t\tstartRecordId: `tsr_${turnId}`,\n\t\t\t\t\t\t\t\t\tdigest: prepared.bundle.digest,\n\t\t\t\t\t\t\t\t\tpersistedAt: timestamp,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t{ mode: 0o600 },\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tcreateAcceptedLlmTurn(\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...ctx,\n\t\t\t\t\t\t\t\t\tdeps: {\n\t\t\t\t\t\t\t\t\t\t...ctx.deps,\n\t\t\t\t\t\t\t\t\t\tprocesses: repos.processes,\n\t\t\t\t\t\t\t\t\t\tturnRecords: repos.turnRecords,\n\t\t\t\t\t\t\t\t\t\tturnStarts: repos.turnStarts,\n\t\t\t\t\t\t\t\t\t\tleases: repos.leases,\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\t{ ...input, turnType: \"llm\", modelProfileId: prepared.start.model.profileId },\n\t\t\t\t\t\t\t\t{ current: running, preparedStart: prepared?.start },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst lease = repos.leases.create({\n\t\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\t\tworkerId: `wkr_${randomUUID()}`,\n\t\t\t\t\t\t\t\tstate: running ? \"busy\" : \"exited\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst start = repos.turnStarts.create({\n\t\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\t\tturnId: fixture.turnId,\n\t\t\t\t\t\t\t\tturnType: \"automatic\",\n\t\t\t\t\t\t\t\tproposedTurnRecordId: turnId,\n\t\t\t\t\t\t\t\tstartKind: \"selected_turn\",\n\t\t\t\t\t\t\t\trecoveryTurnRecordId: null,\n\t\t\t\t\t\t\t\tcontinuation: null,\n\t\t\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\t\t\tkind: \"accepted\",\n\t\t\t\t\t\t\t\t\tstart: { kind: \"automatic\" },\n\t\t\t\t\t\t\t\t\tturnRecordId: turnId,\n\t\t\t\t\t\t\t\t\tacceptedWorkerLeaseId: lease.id,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\trepos.turnRecords.create({\n\t\t\t\t\t\t\t\t...input,\n\t\t\t\t\t\t\t\tturnType: \"automatic\",\n\t\t\t\t\t\t\t\tturnStartRecordId: start.id,\n\t\t\t\t\t\t\t\tacceptedWorkerLeaseId: lease.id,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (running)\n\t\t\t\t\t\t\t\trepos.processes.update(id, {\n\t\t\t\t\t\t\t\t\tcurrentExecution: { kind: \"worker_start\", id: start.id },\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\telse repos.leases.update(lease.id, { exitedAt: timestamp });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (fixture.execution.status === \"succeeded\")\n\t\t\t\t\t\t\trepos.turnAnnotations.create({\n\t\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\t\tannotationType: \"turn_milestone\",\n\t\t\t\t\t\t\t\tannotationKey: `turn_milestone:${turnId}`,\n\t\t\t\t\t\t\t\treferences: [{ kind: \"turn_record\", turnRecordId: turnId, role: \"subject\" }],\n\t\t\t\t\t\t\t\tpayload: {\n\t\t\t\t\t\t\t\t\tturnId: fixture.turnId,\n\t\t\t\t\t\t\t\t\tturnType: turn.kind,\n\t\t\t\t\t\t\t\t\tpathType: \"primary\",\n\t\t\t\t\t\t\t\t\toutcome: fixture.execution.outcome,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tif (running) repos.processes.update(id, { lifecycleStatus: \"active\" });\n\t\t\t\t\t\treturn observe({\n\t\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\t\tid: turnId,\n\t\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\t\tturnId: fixture.turnId,\n\t\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\t\tartifact: running ? null : { kind: \"turn_result\" as const, turnRecordId: turnId },\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\t/** Read detached durable business and execution observations. @public */\n\t\t\tsnapshot,\n\t\t\t/** Wait with a bounded deadline and final observations on failure. @public */\n\t\t\twaitFor,\n\t\t\t/** Execute one selected worker turn; resolves after durable completion or failure. @public */\n\t\t\tasync runTurn(script: IntegrationTurnScript = { tools: [] }) {\n\t\t\t\tif (!manual) throw new Error(\"runTurn requires manual execution mode\");\n\t\t\t\tif (executing.has(id)) throw new Error(`A turn is already running for '${id}'`);\n\t\t\t\tconst before = snapshot();\n\t\t\t\tconst selected = before.process.selectedTurnId;\n\t\t\t\tconst turn = selected\n\t\t\t\t\t? catalog.processes.get(before.process.processId)?.turns.get(selected)?.definition\n\t\t\t\t\t: undefined;\n\t\t\t\tif (\n\t\t\t\t\t!selected ||\n\t\t\t\t\t!turn ||\n\t\t\t\t\t(turn.kind !== \"llm\" && turn.kind !== \"automatic\") ||\n\t\t\t\t\tbefore.process.lifecycleStatus !== \"active\"\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(`Process '${id}' has no active worker turn: ${JSON.stringify(before)}`);\n\t\t\t\texecuting.add(id);\n\t\t\t\tconst previous = new Set(before.turns.map((turn) => turn.id));\n\t\t\t\tobservations.set(id, { prompts: [], toolResults: [] });\n\t\t\t\tscripts.set(id, script);\n\t\t\t\ttry {\n\t\t\t\t\tconst gate = pending.get(id);\n\t\t\t\t\tif (gate) {\n\t\t\t\t\t\tif (gate.turnId !== selected)\n\t\t\t\t\t\t\tthrow new Error(\"Pending turn does not match selected turn\");\n\t\t\t\t\t\tgate.resolve();\n\t\t\t\t\t} else permits.add(id);\n\t\t\t\t\tconst after = await waitFor(\n\t\t\t\t\t\t(current) =>\n\t\t\t\t\t\t\tcurrent.turns.some((turn) => !previous.has(turn.id) && turn.status !== \"running\") ||\n\t\t\t\t\t\t\tcurrent.process.lifecycleStatus === \"error\",\n\t\t\t\t\t\t{ description: `durable outcome of ${selected}` },\n\t\t\t\t\t);\n\t\t\t\t\tconst record = after.turns.find((turn) => !previous.has(turn.id));\n\t\t\t\t\tconst milestone = record\n\t\t\t\t\t\t? context().deps.turnAnnotations.findByKey(id, `turn_milestone:${record.id}`)\n\t\t\t\t\t\t: null;\n\t\t\t\t\treturn observe({\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\tturn: record ?? null,\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\toutcome:\n\t\t\t\t\t\t\ttypeof milestone?.payload.outcome === \"string\" ? milestone.payload.outcome : null,\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\tfailure:\n\t\t\t\t\t\t\trecord?.errorSummary ??\n\t\t\t\t\t\t\t(after.process.lifecycleStatus === \"error\"\n\t\t\t\t\t\t\t\t? \"Worker start failed before acceptance\"\n\t\t\t\t\t\t\t\t: null),\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\tprompts: observations.get(id)?.prompts ?? [],\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\ttoolResults: observations.get(id)?.toolResults ?? [],\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\tresult:\n\t\t\t\t\t\t\trecord?.status === \"succeeded\" && record.turnResultMarkdown\n\t\t\t\t\t\t\t\t? { kind: \"turn_result\" as const, turnRecordId: record.id }\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t});\n\t\t\t\t} finally {\n\t\t\t\t\texecuting.delete(id);\n\t\t\t\t\tscripts.delete(id);\n\t\t\t\t\tpermits.delete(id);\n\t\t\t\t}\n\t\t\t},\n\t\t\t/** Execute an application action. @public */\n\t\t\taction: (actionId: string, input: Record<string, unknown> = {}) =>\n\t\t\t\tpost(`${prefix}/actions/${encodeURIComponent(actionId)}`, { input }),\n\t\t\t/** Retry the failed execution through the application command. @public */\n\t\t\tretry: () => post(`${prefix}/retry`),\n\t\t\t/** Queue an instruction using the application command and normal delivery. @public */\n\t\t\tasync supplyInput(input: IntegrationProcessInput) {\n\t\t\t\tconst result = await context().deps.processEngine.queueInputs(id, [\n\t\t\t\t\t{\n\t\t\t\t\t\tsource: \"app_steer\",\n\t\t\t\t\t\tkind: \"instruction\",\n\t\t\t\t\t\tbodyMarkdown: input.bodyMarkdown,\n\t\t\t\t\t\t...(input.product ? { target: { productName: input.product } } : {}),\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t\tif (!result.ok) throw new Error(`Input rejected: ${result.message}`);\n\t\t\t\treturn snapshot();\n\t\t\t},\n\t\t\t/** Answer an open question request. @public */\n\t\t\tanswerQuestions: (\n\t\t\t\trequestId: string,\n\t\t\t\tanswers: readonly {\n\t\t\t\t\t/** @public */\n\t\t\t\t\tselectedOptionIds: readonly string[];\n\t\t\t\t\t/** @public */\n\t\t\t\t\tfreeText: string;\n\t\t\t\t\t/** @public */\n\t\t\t\t\tcomment: string;\n\t\t\t\t}[],\n\t\t\t) =>\n\t\t\t\tpost(`${prefix}/question-requests/${encodeURIComponent(requestId)}/answers`, {\n\t\t\t\t\tdraft: answers,\n\t\t\t\t}),\n\t\t\t/** Resolve an open tool approval. @public */\n\t\t\trespondToApproval: (\n\t\t\t\trequestId: string,\n\t\t\t\tresponse: {\n\t\t\t\t\t/** @public */\n\t\t\t\t\taction: \"accept\" | \"feedback\" | \"decline\";\n\t\t\t\t\t/** @public */\n\t\t\t\t\tfeedback?: string;\n\t\t\t\t},\n\t\t\t) => post(`${prefix}/tool-approval-requests/${encodeURIComponent(requestId)}`, response),\n\t\t};\n\t}\n\treturn {\n\t\t/** Observe discovered processes. @public */\n\t\tprocesses: () => observe(context().deps.processes.listAll()),\n\t\t/** Send an HTTP-shaped request, retaining error status and body. @public */\n\t\trequest,\n\t\t/** Get a handle that remains valid across restart. @public */\n\t\tprocess: processHandle,\n\t\t/** Admit work through a registered UI launcher. @public */\n\t\tasync launch(id: string, input: Record<string, unknown>) {\n\t\t\tconst response = await postImmediateLaunch(context().config.server.base_url, id, {\n\t\t\t\tlauncherInput: input,\n\t\t\t});\n\t\t\tconst body = (await response.json()) as { process?: { id: string } };\n\t\t\tif (!response.ok || !body.process)\n\t\t\t\tthrow new Error(`Launch '${id}' failed: ${JSON.stringify(body)}`);\n\t\t\treturn processHandle(body.process.id);\n\t\t},\n\t\t/** Create validated business data and start an active position through the engine. @public */\n\t\tasync createProcess<TParams, TState>(\n\t\t\tdefinition: ExtensionProcessDefinition<TParams, TState>,\n\t\t\tinput: Omit<ProcessFixtureOptions<TParams, TState>, \"id\" | \"processId\"> & {\n\t\t\t\t/** @public */\n\t\t\t\tprojects?: readonly ProcessProject[];\n\t\t\t} = {},\n\t\t) {\n\t\t\tif (catalog.processes.get(definition.id) !== definition)\n\t\t\t\tthrow new Error(`Process '${definition.id}' must be registered by an extension`);\n\t\t\tconst fixture = createProcessFixture(input, definition);\n\t\t\tconst { deps } = context();\n\t\t\tconst process = deps.transaction((repos) => {\n\t\t\t\tconst process = repos.processes.create({\n\t\t\t\t\tprocessId: definition.id,\n\t\t\t\t\ttitle: fixture.title,\n\t\t\t\t\texternalId: fixture.externalId,\n\t\t\t\t\texternalUrl: fixture.externalUrl,\n\t\t\t\t\tmetadata: fixture.metadata,\n\t\t\t\t\tparamsJson: fixture.paramsJson,\n\t\t\t\t\tstateJson: fixture.stateJson,\n\t\t\t\t\tselectedTurnId: fixture.selectedTurnId,\n\t\t\t\t\tlifecycleStatus:\n\t\t\t\t\t\tfixture.lifecycleStatus === \"active\" ? \"waiting\" : fixture.lifecycleStatus,\n\t\t\t\t});\n\t\t\t\tif (fixture.planRevision !== 0)\n\t\t\t\t\trepos.processes.update(process.id, { planRevision: fixture.planRevision });\n\t\t\t\tfor (const project of input.projects ?? [])\n\t\t\t\t\trepos.projects.create({\n\t\t\t\t\t\tinstanceId: process.id,\n\t\t\t\t\t\tkey: project.key,\n\t\t\t\t\t\trepoLocator: project.repoLocator,\n\t\t\t\t\t\tbaseBranch: project.baseBranch,\n\t\t\t\t\t\tworkBranch: project.workBranch,\n\t\t\t\t\t\tmetadata: project.metadata,\n\t\t\t\t\t\texternalId: project.externalId,\n\t\t\t\t\t\texternalUrl: project.externalUrl,\n\t\t\t\t\t\tpipelineStatus: project.pipelineStatus,\n\t\t\t\t\t});\n\t\t\t\treturn process;\n\t\t\t});\n\t\t\tif (fixture.lifecycleStatus === \"active\" && fixture.selectedTurnId) {\n\t\t\t\tconst result = await deps.processEngine.startProcess(process.id, fixture.selectedTurnId);\n\t\t\t\tif (!result.ok) throw new Error(`Process start failed: ${result.message}`);\n\t\t\t}\n\t\t\treturn processHandle(process.id);\n\t\t},\n\t\t/** Reopen the same file-backed storage and retain existing handles. @public */\n\t\tasync restart(restartOptions = {}) {\n\t\t\tif (executing.size) throw new Error(\"Cannot restart during runTurn\");\n\t\t\tconst { deps } = context();\n\t\t\tconst paused = manual\n\t\t\t\t? deps.processes.listAll().flatMap((process) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tprocess.lifecycleStatus !== \"active\" ||\n\t\t\t\t\t\t\tprocess.currentExecution?.kind !== \"worker_start\"\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\tconst start = deps.turnStarts.getById(process.currentExecution.id);\n\t\t\t\t\t\treturn start?.state.kind === \"starting\"\n\t\t\t\t\t\t\t? [{ instanceId: process.id, startId: start.id }]\n\t\t\t\t\t\t\t: [];\n\t\t\t\t\t})\n\t\t\t\t: [];\n\t\t\tawait persistent.close();\n\t\t\tif (restartOptions.extensionConfig)\n\t\t\t\toptions.extensionConfig = structuredClone(restartOptions.extensionConfig);\n\t\t\tawait restartOptions.whileStopped?.();\n\t\t\tpending.clear();\n\t\t\tpermits.clear();\n\t\t\tscripts.clear();\n\t\t\tawait open();\n\t\t\tfor (const pausedStart of paused) {\n\t\t\t\tif (context().deps.processes.getById(pausedStart.instanceId)?.lifecycleStatus !== \"error\")\n\t\t\t\t\tcontinue;\n\t\t\t\tconst result = await context().deps.processEngine.retryStartup(\n\t\t\t\t\tpausedStart.instanceId,\n\t\t\t\t\tpausedStart.startId,\n\t\t\t\t);\n\t\t\t\tif (!result.ok)\n\t\t\t\t\tthrow new Error(`Cannot restore paused turn after restart: ${result.message}`);\n\t\t\t}\n\t\t},\n\t\t/** Release all resources and remove harness-owned files. @public */\n\t\tasync close() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\ttry {\n\t\t\t\tawait persistent.dispose();\n\t\t\t} finally {\n\t\t\t\tpending.clear();\n\t\t\t\tpermits.clear();\n\t\t\t\tscripts.clear();\n\t\t\t}\n\t\t},\n\t};\n}\n","import { mkdtempSync, rmSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport type { ExtensionCatalog } from \"@leitwerk-dev/extension-runtime\";\nimport type { ProvidedCapability } from \"@leitwerk-dev/process-sdk\";\nimport {\n\ttype AppContext,\n\ttype AppOptions,\n\tcreateAppContext,\n\tgetDefaultConfig,\n\ttype LeitwerkConfig,\n} from \"@leitwerk-dev/server\";\nimport {\n\tcreateInProcessWorkerSpawn,\n\ttype InProcessWorkerSpawnOptions,\n} from \"./in-process-worker.js\";\n\n/** @public */\nexport interface IntegrationHarness<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n> {\n\t/** @public */\n\tctx: AppContext;\n\t/** @public */\n\tclose(): Promise<void>;\n\t/** @internal */\n\tconfig: LeitwerkConfig;\n\t/** @public */\n\taddress: string;\n\t/** @internal */\n\tresources: TResources;\n}\n\n/** @public */\nexport interface IntegrationHarnessOptions<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n> {\n\t/** @internal */\n\tconfig?: LeitwerkConfig;\n\t/** @public */\n\tconfigOverride?: (config: LeitwerkConfig) => void;\n\t/** @public */\n\tappOverrides?: Partial<AppOptions>;\n\t/** @internal */\n\tlisten?: boolean;\n\t/** Start background services when binding a listener. Defaults to true. @public */\n\tbackgroundServices?: boolean;\n\t/** @internal */\n\tinProcessWorkers?: boolean | Omit<InProcessWorkerSpawnOptions, \"extensionCatalog\">;\n\t/** @public */\n\textensionCatalog: ExtensionCatalog | Promise<ExtensionCatalog>;\n\t/** @internal */\n\tpreProvidedCapabilities?: readonly ProvidedCapability[];\n\t/** @internal */\n\tresources?: TResources;\n}\n\n/** Owns disposable file-backed storage; close retains it for the next open, dispose removes it. @internal */\nexport function createPersistentIntegrationFixture(\n\tprefix: string,\n\tconfigure?: (config: LeitwerkConfig) => void,\n) {\n\tconst root = mkdtempSync(path.join(tmpdir(), prefix));\n\tlet harness: IntegrationHarness | undefined;\n\t/** @internal */\n\tfunction createConfig() {\n\t\tconst config = getDefaultConfig();\n\t\tconfig.storage.sqlite_path = path.join(root, \"state.sqlite\");\n\t\tconfig.storage.process_workspaces_dir = path.join(root, \"workspaces\");\n\t\tconfig.storage.tree_files_dir = path.join(root, \"trees\");\n\t\tconfig.pi.agent_dir = path.join(root, \"pi\");\n\t\tconfigure?.(config);\n\t\treturn config;\n\t}\n\t/** @internal */\n\tasync function close() {\n\t\tawait harness?.close();\n\t\tharness = undefined;\n\t}\n\treturn {\n\t\t/** @internal */\n\t\troot,\n\t\t/** @internal */\n\t\tcreateConfig,\n\t\t/** @internal */\n\t\tcontext() {\n\t\t\tif (!harness) throw new Error(\"Fixture is not open\");\n\t\t\treturn harness.ctx;\n\t\t},\n\t\t/** @internal */\n\t\tasync open(options: IntegrationHarnessOptions) {\n\t\t\tharness = await createIntegrationHarness({\n\t\t\t\t...options,\n\t\t\t\tconfig: options.config ?? createConfig(),\n\t\t\t});\n\t\t\treturn harness;\n\t\t},\n\t\t/** @internal */\n\t\tclose,\n\t\t/** @internal */\n\t\tasync dispose() {\n\t\t\ttry {\n\t\t\t\tawait close();\n\t\t\t} finally {\n\t\t\t\trmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });\n\t\t\t}\n\t\t},\n\t};\n}\n/** @public */\nexport async function createIntegrationHarness<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n>(opts: IntegrationHarnessOptions<TResources>): Promise<IntegrationHarness<TResources>> {\n\tconst config = opts.config ?? getDefaultConfig();\n\tif (!opts.appOverrides?.workerRunnerRuntime) {\n\t\tconfig.workers.runner = \"local\";\n\t}\n\topts.configOverride?.(config);\n\n\tconst extensionCatalog = await Promise.resolve(opts.extensionCatalog);\n\n\tconst appOpts: AppOptions = {\n\t\tlogger: false,\n\t\tconfig,\n\t\textensionCatalog,\n\t\tpreProvidedCapabilities: opts.preProvidedCapabilities,\n\t\t...opts.appOverrides,\n\t};\n\n\tif (opts.inProcessWorkers !== false && !appOpts.localWorkerSpawnImpl) {\n\t\tappOpts.localWorkerSpawnImpl = createInProcessWorkerSpawn({\n\t\t\t...(typeof opts.inProcessWorkers === \"object\" ? opts.inProcessWorkers : {}),\n\t\t\textensionCatalog,\n\t\t});\n\t}\n\tconst ctx = await createAppContext(appOpts);\n\n\tlet address = \"\";\n\ttry {\n\t\tif (opts.listen !== false) {\n\t\t\tif (opts.backgroundServices !== false) {\n\t\t\t\t({ address } = await ctx.listen({\n\t\t\t\t\thost: \"127.0.0.1\",\n\t\t\t\t\tport: 0,\n\t\t\t\t\tuseBoundAddressAsBaseUrl: true,\n\t\t\t\t}));\n\t\t\t} else {\n\t\t\t\taddress = await ctx.app.listen({ host: \"127.0.0.1\", port: 0 });\n\t\t\t\tctx.config.server.base_url = address;\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tawait ctx.close().catch(() => {});\n\t\tthrow error;\n\t}\n\n\treturn {\n\t\tctx,\n\t\tclose: () => ctx.close(),\n\t\tconfig,\n\t\tget address() {\n\t\t\treturn address || (ctx.app.server.listening ? ctx.config.server.base_url : \"\");\n\t\t},\n\t\tresources: opts.resources ?? ({} as TResources),\n\t};\n}\n","/** @public */\nexport async function waitForValue<T>(\n\tread: () => T | Promise<T>,\n\tpredicate: (value: T) => boolean,\n\ttimeoutMs = 5_000,\n): Promise<T> {\n\tconst deadline = Date.now() + timeoutMs;\n\twhile (true) {\n\t\tconst value = await read();\n\t\tif (predicate(value)) {\n\t\t\treturn value;\n\t\t}\n\t\tif (Date.now() >= deadline) {\n\t\t\tthrow new Error(\"Timed out waiting for value\");\n\t\t}\n\t\tawait new Promise((resolve) => setTimeout(resolve, 25));\n\t}\n}\n","import type { ProcessInstance } from \"@leitwerk-dev/domain\";\nimport type { AppContext } from \"@leitwerk-dev/server\";\nimport { waitForValue } from \"./polling.js\";\n\n/** Drive a running or restarted app without bypassing process HTTP actions. @public */\nexport function createProcessDriver(context: () => AppContext) {\n\t/** @public */\n\tasync function post(url: string, payload: Record<string, unknown> = {}) {\n\t\tconst response = await context().app.inject({ method: \"POST\", url, payload });\n\t\tif (response.statusCode !== 200)\n\t\t\tthrow new Error(`POST ${url} failed with ${response.statusCode}: ${response.body}`);\n\t\treturn response;\n\t}\n\t/** @public */\n\tasync function waitForProcess(\n\t\tid: string,\n\t\tpredicate: (process: ProcessInstance) => boolean,\n\t\tdescription: string,\n\t\ttimeout = 12000,\n\t\tallowError = false,\n\t): Promise<ProcessInstance> {\n\t\ttry {\n\t\t\tconst process = await waitForValue(\n\t\t\t\t() => {\n\t\t\t\t\tconst current = context().deps.processes.getById(id);\n\t\t\t\t\tif (current?.lifecycleStatus === \"error\" && !allowError)\n\t\t\t\t\t\tthrow new Error(\"Process entered error lifecycle\");\n\t\t\t\t\treturn current;\n\t\t\t\t},\n\t\t\t\t(process) => !!process && predicate(process),\n\t\t\t\ttimeout,\n\t\t\t);\n\t\t\tif (!process) throw new Error(\"Missing process\");\n\t\t\treturn process;\n\t\t} catch (error) {\n\t\t\tconst { processes, turnRecords } = context().deps;\n\t\t\tthrow new Error(\n\t\t\t\t`Waiting for ${id}: ${description}; ${JSON.stringify({ process: processes.getById(id), turns: turnRecords.listByInstance(id) })}`,\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\t/** @public */\n\t\tpost,\n\t\t/** @public */\n\t\twaitForProcess,\n\t\t/** @public */\n\t\twait: (id: string, turn: string | null, lifecycle = \"waiting\", timeout = 12000) =>\n\t\t\twaitForProcess(\n\t\t\t\tid,\n\t\t\t\t(p) => p.selectedTurnId === turn && p.lifecycleStatus === lifecycle,\n\t\t\t\t`${turn}/${lifecycle}`,\n\t\t\t\ttimeout,\n\t\t\t\tlifecycle === \"error\",\n\t\t\t),\n\t\t/** @public */\n\t\taction: (id: string, action: string, input: Record<string, unknown> = {}) =>\n\t\t\tpost(`/api/processes/${encodeURIComponent(id)}/actions/${encodeURIComponent(action)}`, {\n\t\t\t\tinput,\n\t\t\t}),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA,SAAS,kBAAkB;AAC3B,SAAS,WAAW,qBAAqB;AACzC,OAAOA,WAAU;AAQjB,SAAS,wCAAwC;AACjD;AAAA,EACC;AAAA,OAGM;AACP,SAAS,uBAAuB,mCAAmC;;;ACpBnE,SAAS,aAAa,cAAc;AACpC,SAAS,c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AQ,EAAE,KAAK,UAAU,QAAQ,EAAE;AACnD,cAAI,SAAS,oBAAoB,WAAW,CAAC;AAC5C,kBAAM,IAAI,MAAM,iCAAiC;AAClD,iBAAO;AAAA,QACR;AAAA,QACA,CAACC,aAAY,CAAC,CAACA,YAAW,UAAUA,QAAO;AAAA,QAC3C;AAAA,MACD;AACA,UAAI,CAAC,QAAS,OAAM,IAAI,MAAM,iBAAiB;AAC/C,aAAO;AAAA,IACR,SAAS,OAAO;AACf,YAAM,EAAE,WAAW,YAAY,IAAI,QAAQ,EAAE;AAC7C,YAAM,IAAI;AAAA,QACT,eAAe,EAAE,KAAK,WAAW,KAAK,KAAK,UAAU,EAAE,SAAS,UAAU,QAAQ,EAAE,GAAG,OAAO,YAAY,eAAe,EAAE,EAAE,CAAC,CAAC;AAAA,QAC/H,EAAE,OAAO,MAAM;AAAA,MAChB;AAAA,IACD;AAAA,EACD;AACA,SAAO;AAAA;AAAA,IAEN;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA,MAAM,CAAC,IAAY,MAAqB,YAAY,WAAW,UAAU,SACxE;AAAA,MACC;AAAA,MACA,CAAC,MAAM,EAAE,mBAAmB,QAAQ,EAAE,oBAAoB;AAAA,MAC1D,GAAG,IAAI,IAAI,SAAS;AAAA,MACpB;AAAA,MACA,cAAc;AAAA,IACf;AAAA;AAAA,IAED,QAAQ,CAAC,IAAY,QAAgB,QAAiC,CAAC,MACtE,KAAK,kBAAkB,mBAAmB,EAAE,CAAC,YAAY,mBAAmB,MAAM,CAAC,IAAI;AAAA,MACtF;AAAA,IACD,CAAC;AAAA,EACH;AACD;","names":["path","session","path","options","turn","process","process"]}
|
package/dist/local-git.d.ts
CHANGED
|
@@ -1,134 +1,231 @@
|
|
|
1
1
|
import type { RepositoryFeedbackItem, RepositoryPullRequest } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
export { createTestDiagnostics } from "./test-diagnostics.js";
|
|
3
|
+
/** @public */
|
|
2
4
|
export interface LocalRepositorySeed {
|
|
5
|
+
/** @public */
|
|
3
6
|
owner: string;
|
|
7
|
+
/** @public */
|
|
4
8
|
name: string;
|
|
9
|
+
/** @internal */
|
|
5
10
|
defaultBranch?: string;
|
|
11
|
+
/** @public */
|
|
6
12
|
files?: Record<string, string>;
|
|
7
|
-
/** Retain a pre-existing sandbox checkout layout. */
|
|
13
|
+
/** Retain a pre-existing sandbox checkout layout. @internal */
|
|
8
14
|
directoryName?: string;
|
|
15
|
+
/** @internal */
|
|
9
16
|
commitMessage?: string;
|
|
17
|
+
/** @internal */
|
|
10
18
|
signoff?: boolean;
|
|
11
19
|
}
|
|
12
|
-
/** Reject escaping paths and symlinks, including a not-yet-created file's parents. */
|
|
20
|
+
/** Reject escaping paths and symlinks, including a not-yet-created file's parents. @public */
|
|
13
21
|
export declare function localPath(root: string, relative: string): string;
|
|
22
|
+
/** @public */
|
|
14
23
|
export declare function readLocalJson<T extends {
|
|
24
|
+
/** @internal */
|
|
15
25
|
version: number;
|
|
16
26
|
}>(root: string, file: string, initial: T): T;
|
|
27
|
+
/** @public */
|
|
17
28
|
export declare function writeLocalJson(root: string, file: string, value: unknown): void;
|
|
18
|
-
/** Persist local adapter state with a shared clock and monotonically increasing ids. */
|
|
29
|
+
/** Persist local adapter state with a shared clock and monotonically increasing ids. @public */
|
|
19
30
|
export declare class LocalProviderStore<S extends {
|
|
31
|
+
/** @internal */
|
|
20
32
|
version: number;
|
|
33
|
+
/** @internal */
|
|
21
34
|
sequence: number;
|
|
22
35
|
}, O extends {
|
|
36
|
+
/** @internal */
|
|
23
37
|
root: string;
|
|
38
|
+
/** @internal */
|
|
24
39
|
now?: () => number;
|
|
40
|
+
/** @internal */
|
|
25
41
|
nextId?: () => number;
|
|
26
42
|
}> {
|
|
43
|
+
/** @public */
|
|
27
44
|
readonly options: O;
|
|
28
45
|
private readonly file;
|
|
46
|
+
/** @public */
|
|
29
47
|
readonly git: LocalGit;
|
|
48
|
+
/** @public */
|
|
30
49
|
state: S;
|
|
31
|
-
|
|
50
|
+
/** @public */
|
|
51
|
+
constructor(
|
|
52
|
+
/** @public */
|
|
53
|
+
options: O, file: string, initial: S);
|
|
54
|
+
/** @public */
|
|
32
55
|
save(): void;
|
|
56
|
+
/** @internal */
|
|
33
57
|
id(): number;
|
|
58
|
+
/** @internal */
|
|
34
59
|
timestamp(): string;
|
|
35
60
|
}
|
|
61
|
+
/** @public */
|
|
36
62
|
type LocalPullRequest = Pick<RepositoryPullRequest, "number" | "title" | "body" | "state" | "merged" | "merge_commit_sha" | "head" | "base">;
|
|
63
|
+
/** @public */
|
|
37
64
|
interface LocalPullRequestRepository<P extends LocalPullRequest> {
|
|
65
|
+
/** @public */
|
|
38
66
|
repository: {
|
|
67
|
+
/** @internal */
|
|
39
68
|
ssh_url: string;
|
|
40
69
|
};
|
|
70
|
+
/** @public */
|
|
41
71
|
pulls: P[];
|
|
42
72
|
}
|
|
43
|
-
/** Common PR operations; adapters retain their provider-specific state and clients. */
|
|
73
|
+
/** Common PR operations; adapters retain their provider-specific state and clients. @public */
|
|
44
74
|
export declare class LocalForgeStore<S extends {
|
|
75
|
+
/** @internal */
|
|
45
76
|
version: number;
|
|
77
|
+
/** @internal */
|
|
46
78
|
sequence: number;
|
|
47
79
|
}, O extends {
|
|
80
|
+
/** @internal */
|
|
48
81
|
root: string;
|
|
82
|
+
/** @internal */
|
|
49
83
|
baseUrl: string;
|
|
84
|
+
/** @internal */
|
|
50
85
|
now?: () => number;
|
|
86
|
+
/** @internal */
|
|
51
87
|
nextId?: () => number;
|
|
52
88
|
}> extends LocalProviderStore<S, O> {
|
|
89
|
+
/** @public */
|
|
53
90
|
newRepository(seed: LocalRepositorySeed): {
|
|
91
|
+
/** @public */
|
|
54
92
|
id: number;
|
|
93
|
+
/** @public */
|
|
55
94
|
owner: {
|
|
95
|
+
/** @internal */
|
|
56
96
|
login: string;
|
|
57
97
|
};
|
|
98
|
+
/** @public */
|
|
58
99
|
name: string;
|
|
100
|
+
/** @public */
|
|
59
101
|
full_name: string;
|
|
102
|
+
/** @public */
|
|
60
103
|
ssh_url: string;
|
|
104
|
+
/** @public */
|
|
61
105
|
html_url: string;
|
|
106
|
+
/** @public */
|
|
62
107
|
default_branch: string;
|
|
63
108
|
};
|
|
109
|
+
/** @internal */
|
|
64
110
|
pullRequestClient<P extends LocalPullRequest>(repo: (owner: string, name: string) => LocalPullRequestRepository<P>, missing?: string): {
|
|
111
|
+
/** @internal */
|
|
65
112
|
getPullRequest: (owner: string, name: string, number: number) => Promise<P>;
|
|
113
|
+
/** @internal */
|
|
66
114
|
listPullRequests: (owner: string, name: string, state?: string) => Promise<P[]>;
|
|
115
|
+
/** @internal */
|
|
67
116
|
updatePullRequest: (owner: string, name: string, number: number, patch: Record<string, unknown>) => Promise<P>;
|
|
68
117
|
};
|
|
118
|
+
/** @public */
|
|
69
119
|
refresh<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, pr: P): P;
|
|
120
|
+
/** @public */
|
|
70
121
|
merge<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, number: number): P;
|
|
122
|
+
/** @public */
|
|
71
123
|
addFeedback<F extends RepositoryFeedbackItem>(repo: {
|
|
124
|
+
/** @public */
|
|
72
125
|
pulls: Array<{
|
|
126
|
+
/** @internal */
|
|
73
127
|
number: number;
|
|
74
128
|
}>;
|
|
129
|
+
/** @public */
|
|
75
130
|
feedback: Record<string, F[]>;
|
|
76
131
|
}, number: number, input: Omit<F, "id" | "createdAt">): F;
|
|
132
|
+
/** @public */
|
|
77
133
|
newComment(body: string): {
|
|
134
|
+
/** @internal */
|
|
78
135
|
id: number;
|
|
136
|
+
/** @internal */
|
|
79
137
|
body: string;
|
|
138
|
+
/** @public */
|
|
80
139
|
user: {
|
|
140
|
+
/** @public */
|
|
81
141
|
login: string;
|
|
82
142
|
};
|
|
143
|
+
/** @internal */
|
|
83
144
|
created_at: string;
|
|
84
145
|
};
|
|
146
|
+
/** @internal */
|
|
85
147
|
newPullRequest(repo: {
|
|
148
|
+
/** @internal */
|
|
86
149
|
repository: {
|
|
150
|
+
/** @internal */
|
|
87
151
|
ssh_url: string;
|
|
88
152
|
};
|
|
89
153
|
}, input: {
|
|
154
|
+
/** @internal */
|
|
90
155
|
title: string;
|
|
156
|
+
/** @internal */
|
|
91
157
|
body: string;
|
|
158
|
+
/** @internal */
|
|
92
159
|
head: string;
|
|
160
|
+
/** @internal */
|
|
93
161
|
base: string;
|
|
94
162
|
}): {
|
|
163
|
+
/** @internal */
|
|
95
164
|
number: number;
|
|
165
|
+
/** @internal */
|
|
96
166
|
title: string;
|
|
167
|
+
/** @internal */
|
|
97
168
|
body: string;
|
|
169
|
+
/** @internal */
|
|
98
170
|
state: string;
|
|
171
|
+
/** @internal */
|
|
99
172
|
merged: boolean;
|
|
173
|
+
/** @internal */
|
|
100
174
|
merge_commit_sha: null;
|
|
175
|
+
/** @internal */
|
|
101
176
|
html_url: string;
|
|
177
|
+
/** @internal */
|
|
102
178
|
head: {
|
|
179
|
+
/** @internal */
|
|
103
180
|
ref: string;
|
|
181
|
+
/** @internal */
|
|
104
182
|
sha: string;
|
|
105
183
|
};
|
|
184
|
+
/** @internal */
|
|
106
185
|
base: {
|
|
186
|
+
/** @internal */
|
|
107
187
|
ref: string;
|
|
188
|
+
/** @internal */
|
|
108
189
|
sha: string;
|
|
109
190
|
};
|
|
110
191
|
};
|
|
111
192
|
}
|
|
112
|
-
/** Real Git with file-only transport and no ambient credentials or hooks. */
|
|
193
|
+
/** Real Git with file-only transport and no ambient credentials or hooks. @public */
|
|
113
194
|
export declare class LocalGit {
|
|
195
|
+
/** @internal */
|
|
114
196
|
readonly root: string;
|
|
115
|
-
|
|
197
|
+
/** @public */
|
|
198
|
+
constructor(
|
|
199
|
+
/** @internal */
|
|
200
|
+
root: string);
|
|
201
|
+
/** @public */
|
|
116
202
|
run(directory: string, args: string[]): string;
|
|
203
|
+
/** @public */
|
|
117
204
|
head(directory: string, ref: string): string;
|
|
205
|
+
/** @internal */
|
|
118
206
|
isAncestor(directory: string, ancestor: string, descendant: string): boolean;
|
|
119
207
|
private isAncestorCommit;
|
|
208
|
+
/** @internal */
|
|
120
209
|
mergeability(directory: string, head: string, base: string): {
|
|
210
|
+
/** @internal */
|
|
121
211
|
headSha: string;
|
|
212
|
+
/** @internal */
|
|
122
213
|
baseSha: string;
|
|
214
|
+
/** @internal */
|
|
123
215
|
mergeable: boolean;
|
|
216
|
+
/** @internal */
|
|
124
217
|
mergeable_state: string;
|
|
125
218
|
};
|
|
219
|
+
/** @internal */
|
|
126
220
|
merge(directory: string, head: string, base: string): string;
|
|
221
|
+
/** @internal */
|
|
127
222
|
seed(seed: LocalRepositorySeed): {
|
|
223
|
+
/** @internal */
|
|
128
224
|
bare: string;
|
|
225
|
+
/** @internal */
|
|
129
226
|
worktree: string;
|
|
227
|
+
/** @internal */
|
|
130
228
|
branch: string;
|
|
131
229
|
};
|
|
132
230
|
}
|
|
133
|
-
export {};
|
|
134
231
|
//# sourceMappingURL=local-git.d.ts.map
|
package/dist/local-git.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-git.d.ts","sourceRoot":"","sources":["../src/local-git.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"local-git.d.ts","sourceRoot":"","sources":["../src/local-git.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAI/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,cAAc;AACd,MAAM,WAAW,mBAAmB;IACnC,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;IACd,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc;IACd,KAAK,CAAC,EAAE,MAAM,CAAC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