@mostra/conformance 0.6.1 → 0.7.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/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as SCENARIOS, t as runConformance, y as readBaseline } from "./runner-C8SO70qb.js";
2
+ import { n as SCENARIOS, t as runConformance, y as readBaseline } from "./runner-DYbtXiL9.js";
3
3
  import { parseArgs } from "node:util";
4
4
  //#region src/cli.ts
5
5
  /**
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as StoreResult, a as CallParams, c as EventsResult, d as HarnessFeature, f as InitializeParams, g as StartResult, h as StartParams, i as CallError, l as HARNESS_METHODS, m as ScriptParams, n as ReferenceStore, o as CallResult, p as InitializeResult, r as runReferenceHost, s as EventsParams, t as REFERENCE_FAULTS, u as HARNESS_REVISIONS, v as StoredDelivery } from "./reference-host-BJ-A_Qd_.js";
1
+ import { _ as StoreResult, a as CallParams, c as EventsResult, d as HarnessFeature, f as InitializeParams, g as StartResult, h as StartParams, i as CallError, l as HARNESS_METHODS, m as ScriptParams, n as ReferenceStore, o as CallResult, p as InitializeResult, r as runReferenceHost, s as EventsParams, t as REFERENCE_FAULTS, u as HARNESS_REVISIONS, v as StoredDelivery } from "./reference-host-DYKrtRCH.js";
2
2
  import { EventRecord, Frame, FrameTicket, Results, RpcPeer } from "@mostra/protocol";
3
3
  //#region src/baseline.d.ts
4
4
  /** A baseline: the scenarios a host is expected to fail, each with its reason. */
@@ -148,6 +148,10 @@ export declare function parseLink(link: string): ParsedLink;
148
148
  /** A browser-like client with a per-host cookie jar. */
149
149
  export declare class Browser {
150
150
  #private;
151
+ /** Signs every later request to `origin` with a worker-mode frame session, as its worker does. */
152
+ enterFrame(origin: string, secret: string): void;
153
+ /** Whether `origin` has a worker-mode frame session in this browser. */
154
+ workerFrame(origin: string): boolean;
151
155
  /** The cookies the jar sends to `url`: every cookie of the host whose path matches. */
152
156
  cookiesFor(url: string): string;
153
157
  /** Sends a request with the jar's cookies and keeps the ones that come back. */
@@ -222,7 +226,7 @@ export declare class Viewer {
222
226
  signal(name: string, payload?: unknown): Promise<Answer>;
223
227
  /** Starts an action run (D130) and follows it until it ends. */
224
228
  run(fnId: string, args: unknown[], timeoutMs?: number): Promise<RunState>;
225
- /** The page's long poll: events after `cursor` (D47). */
229
+ /** The page's long poll: events after `cursor` (D47); in worker mode with its ticket (D70). */
226
230
  poll(cursor?: string): Promise<Answer>;
227
231
  }
228
232
  /** A run's result, from its stored batches. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/baseline.ts","../src/fixtures.ts","../src/harness/client.ts","../src/harness/serve.ts","../src/viewer.ts","../src/scenario.ts","../src/runner.ts","../src/scenarios/index.ts"],"mappings":";;;;UAciB;;WAEN;;WAEA,kBAAkB,SAAS;;;qBASzB,aAAa;;;;;wBAMV,aAAa,cAAc,2BAA2B;;;;;;;;;KC1B1D,UAAU,SAAS;;qBA2ElB,UAAU,SAAS,eAAe;;;;qBCtClC,sBAAsB;;WAExB;;WAEA;;WAEA,MAAM;EAEf,YAAY,gBAAgB,OAAO;;;qBAUxB;;;EAMX,MAAM;UAEE;;SA4CK,MACX,iBACA,MAAK,SAAS,0BACb,QAAQ;;MAgBP;;EAKJ,OAAO;;EAIP,SAAS;;EAST,cAAoB,QAAQ,cAAc,QAAQ;;EAKlD,QAAc,gBAAgB,iBAAiB,qBAAqB,QAAQ;;EAW5E,KAAW,IAAI,yBACb,gBACA,iBACA,qBACC,QAAQ;;EAOX,gBAAsB;;EAKtB,SAAe,QAAQ;;EAKvB,OAAa,QAAQ,eAAe;;EAKpC,OAAa,QAAQ,eAAe,QAAQ;;;;;;;;EAa5C,SAAe;;;wBAwCD,OAAO;;;;UCrNN;;EAEf,cAAc,KAAK,gCAAgC,QAAQ,KAAK;;EAEhE,MAAM,QAAQ,cAAc,cAAc,QAAQ;;EAElD,KA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AAS,aAAa,QAAQ;;;;qBC9GtD,oBAAoB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/baseline.ts","../src/fixtures.ts","../src/harness/client.ts","../src/harness/serve.ts","../src/viewer.ts","../src/scenario.ts","../src/runner.ts","../src/scenarios/index.ts"],"mappings":";;;;UAciB;;WAEN;;WAEA,kBAAkB,SAAS;;;qBASzB,aAAa;;;;;wBAMV,aAAa,cAAc,2BAA2B;;;;;;;;;KC1B1D,UAAU,SAAS;;qBA2ElB,UAAU,SAAS,eAAe;;;;qBCtClC,sBAAsB;;WAExB;;WAEA;;WAEA,MAAM;EAEf,YAAY,gBAAgB,OAAO;;;qBAUxB;;;EAMX,MAAM;UAEE;;SA4CK,MACX,iBACA,MAAK,SAAS,0BACb,QAAQ;;MAgBP;;EAKJ,OAAO;;EAIP,SAAS;;EAST,cAAoB,QAAQ,cAAc,QAAQ;;EAKlD,QAAc,gBAAgB,iBAAiB,qBAAqB,QAAQ;;EAW5E,KAAW,IAAI,yBACb,gBACA,iBACA,qBACC,QAAQ;;EAOX,gBAAsB;;EAKtB,SAAe,QAAQ;;EAKvB,OAAa,QAAQ,eAAe;;EAKpC,OAAa,QAAQ,eAAe,QAAQ;;;;;;;;EAa5C,SAAe;;;wBAwCD,OAAO;;;;UCrNN;;EAEf,cAAc,KAAK,gCAAgC,QAAQ,KAAK;;EAEhE,MAAM,QAAQ,cAAc,cAAc,QAAQ;;EAElD,KAAK,gBAAgB,iBAAiB;;EAEtC,eAAe;;EAEf,SAAS,cAAc,QAAQ;;EAE/B,QAAQ,QAAQ,sBAAsB;;EAEtC,QAAQ,QAAQ,eAAe,eAAe,QAAQ;;;;;;wBAcxC,aACd,gBAAgB,uBAChB;EAAM,QAAQ,OAAO;EAAgB,SAAS,OAAO;IACpD;;;;UCzCc;;WAEN;;WAEA,SAAS,SAAS;;WAElB;;EAET,KAAK,IAAI,4BAA4B;;;UAItB;;WAEN;;WAEA;;WAEA,UAAU,SAAS;;WAEnB;;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d,eAAqB,QAAQ;;EAO7B,YAAY,QAAO,SAAS,0BAA+B;;EAU3D,MACE;IACE,MAAM,SAAS;IACf,OAAO;IACP,OAAO;MAER,QAAQ;;EAUX,QAAc;IAAW,MAAM,SAAS;MAAiC,QAAQ;;EAMjF,OAAO,SAAS,SAAS;;EAWzB,QAAQ,aAAa,SAAS;;EAK9B,QACE,aACA;IAAW;IAAkB;MAC5B;IACD;IACA;IACA;IACA;IACA;IACA;;;EAUF,UACE,SAAS,SACT;IAAW;MACV;IACD;IACA;IACA;IACA;IACA;IACA;IACA;;;EAOF,KAAW,oBAAoB,SAAQ,0BAA+B;;EAStE,OACE,oBACA;IAAW,OAAO;IAAyB,UAAU;MACpD,QAAQ;;EAOX,QAAQ,oBAAoB,sBAAsB,QAAQ;;EAQ1D,OACE;IAAU;IAAsB;KAChC,iBACC;IAAU,QAAQ;IAAe;;;EAKpC,SAAS,QAAQ;;EAKjB,WAAiB,GACf,cACA,iBAAiB,QAAQ,yBAAyB,uBAClD,qBACC,QAAQ;;EAWX,YAAY;;EAKZ,eAAe;;EAMf;;EAYA,SAAe;;;;;KC9RL;;UAaK;;WAEN;;WAEA;;WAEA;;WAEA,QAAQ;;WAER;;WAEA;;;UAIM;;WAEN,MAAM;;WAEN,mBAAmB;;WAEnB;;;UAIM;;WAEN;;WAEA,UAAU,SAAS;;WAEnB;;WAEA,WAAW;;WAEX;;WAEA;;WAEA;;WAEA,aAAa,SAAS;;WAEtB,qBAAqB;;;wBAqDV,eAAe,SAAS,aAAa,QAAQ;;;;qBC9GtD,oBAAoB"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as FIXTURES, a as ScenarioFailure, c as Browser, d as parseLink, f as resultOf, g as codeOf, h as InstanceError, i as ScenarioContext, l as OpenError, m as HostUnderTest, n as SCENARIOS, o as check, p as send, r as NotApplicable, s as same, t as runConformance, u as Viewer, v as NO_BASELINE, y as readBaseline } from "./runner-C8SO70qb.js";
2
- import { a as HARNESS_METHODS, o as HARNESS_REVISIONS } from "./protocol-RQ9lbehE.js";
3
- import { i as serveHarness, n as ReferenceStore, r as runReferenceHost, t as REFERENCE_FAULTS } from "./reference-host-D7fe25go.js";
1
+ import { _ as FIXTURES, a as ScenarioFailure, c as Browser, d as parseLink, f as resultOf, g as codeOf, h as InstanceError, i as ScenarioContext, l as OpenError, m as HostUnderTest, n as SCENARIOS, o as check, p as send, r as NotApplicable, s as same, t as runConformance, u as Viewer, v as NO_BASELINE, y as readBaseline } from "./runner-DYbtXiL9.js";
2
+ import { a as HARNESS_METHODS, o as HARNESS_REVISIONS } from "./protocol-Bi4gZzsu.js";
3
+ import { i as serveHarness, n as ReferenceStore, r as runReferenceHost, t as REFERENCE_FAULTS } from "./reference-host-BAAxMabg.js";
4
4
  export { Browser, FIXTURES, HARNESS_METHODS, HARNESS_REVISIONS, HostUnderTest, InstanceError, NO_BASELINE, NotApplicable, OpenError, REFERENCE_FAULTS, ReferenceStore, SCENARIOS, ScenarioContext, ScenarioFailure, Viewer, check, codeOf, parseLink, readBaseline, resultOf, runConformance, runReferenceHost, same, send, serveHarness };
@@ -139,7 +139,16 @@ const StoreResult = z.object({
139
139
  secrets: z.array(z.object({
140
140
  artifactId: z.string(),
141
141
  name: z.string()
142
- }))
142
+ })),
143
+ addressing: z.array(z.object({
144
+ artifactId: z.string(),
145
+ listener: z.string(),
146
+ local: z.string(),
147
+ answer: z.union([z.object({
148
+ origin: z.string(),
149
+ mode: z.string().optional()
150
+ }), z.null()]).optional()
151
+ })).optional()
143
152
  });
144
153
  /** The schema of `ScriptParams`. */
145
154
  const ScriptParams = z.union([
@@ -181,6 +190,18 @@ const ScriptParams = z.union([
181
190
  z.object({
182
191
  port: z.literal("secrets"),
183
192
  answer: z.record(z.string(), z.string())
193
+ }),
194
+ z.object({
195
+ port: z.literal("addressing"),
196
+ answer: z.union([
197
+ z.null(),
198
+ z.literal("fail"),
199
+ z.object({
200
+ shellHost: z.string(),
201
+ artifactHost: z.string(),
202
+ mode: z.enum(["cookie", "worker"]).optional()
203
+ })
204
+ ])
184
205
  })
185
206
  ]);
186
207
  /** The schema of `EventsParams`. */
@@ -204,4 +225,4 @@ const EventsResult = z.object({ pages: z.array(z.object({
204
225
  //#endregion
205
226
  export { HARNESS_METHODS as a, ScriptParams as c, StoreResult as d, kitVersion as f, EventsResult as i, StartParams as l, CallResult as n, HARNESS_REVISIONS as o, EventsParams as r, InitializeResult as s, CallParams as t, StartResult as u };
206
227
 
207
- //# sourceMappingURL=protocol-RQ9lbehE.js.map
228
+ //# sourceMappingURL=protocol-Bi4gZzsu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol-RQ9lbehE.js","names":[],"sources":["../src/version.ts","../src/harness/protocol.ts"],"sourcesContent":["/** The kit's own release, from its package.json (found upwards from this module). */\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nlet found: string | undefined;\n\n/** This kit's release: what it reports to a host's shim and to an instance. */\nexport function kitVersion(): string {\n if (found !== undefined) return found;\n let dir = dirname(fileURLToPath(import.meta.url));\n for (;;) {\n try {\n const manifest = JSON.parse(readFileSync(join(dir, \"package.json\"), \"utf8\")) as {\n name?: string;\n version?: string;\n };\n if (manifest.name === \"@mostra/conformance\" && manifest.version) {\n found = manifest.version;\n return found;\n }\n } catch {\n // Keep looking upwards.\n }\n const parent = dirname(dir);\n if (parent === dir) throw new Error(\"Couldn't find @mostra/conformance's package.json.\");\n dir = parent;\n }\n}\n","/**\n * The conformance harness protocol (D143 item 3): how the kit drives a host under test. A host\n * ships a small shim, a program the kit starts, that speaks JSON-RPC 2.0 over its stdin and\n * stdout (one message per line, as the host protocol does) and answers these methods with its\n * real integration: its own client, its own ports, its own store. Any language can implement it;\n * TypeScript hosts get `serveHarness`, and the Rust reference host shows it in Rust.\n *\n * | Method | What the host does |\n * |---|---|\n * | `harness/initialize` | names itself, the ports it serves and the features it supports |\n * | `harness/start` | starts (spawns or attaches to) its Mostra instance for a home, with its ports |\n * | `harness/call` | sends one host-protocol request through its own client and returns the answer |\n * | `harness/stop` | ends its session (a spawned instance exits) |\n * | `harness/store` | reports what its own store holds: deliveries, mirrors, activations, calls |\n * | `harness/script` | (feature `faults`) answers a port the way the kit asks |\n * | `harness/events` | (feature `events`) reads pages from its own named event stream |\n *\n * Within a revision the protocol changes only additively, like the host protocol (D32).\n */\nimport * as z from \"zod\";\n\n/** The harness protocol revisions this kit speaks, newest last. */\nexport const HARNESS_REVISIONS: readonly string[] = [\"2026-10-21\"];\n\n/** The harness methods by name. */\nexport const HARNESS_METHODS: {\n readonly initialize: \"harness/initialize\";\n readonly start: \"harness/start\";\n readonly call: \"harness/call\";\n readonly stop: \"harness/stop\";\n readonly store: \"harness/store\";\n readonly script: \"harness/script\";\n readonly events: \"harness/events\";\n} = {\n initialize: \"harness/initialize\",\n start: \"harness/start\",\n call: \"harness/call\",\n stop: \"harness/stop\",\n store: \"harness/store\",\n script: \"harness/script\",\n events: \"harness/events\",\n};\n\n/**\n * What a host can do beyond the required methods: `attach` (`harness/start` with\n * `mode: \"attach\"`), `faults` (`harness/script`, for reference and test hosts) and `events`\n * (`harness/events`). Unknown features are ignored.\n */\nexport type HarnessFeature = \"attach\" | \"faults\" | \"events\" | (string & {});\n\n/** `harness/initialize`'s params. */\nexport interface InitializeParams {\n /** The harness protocol revision. */\n readonly revision: string;\n /** The kit that drives the host. */\n readonly kit: { readonly name: string; readonly version: string };\n}\n\n/** `harness/initialize`'s result. */\nexport interface InitializeResult {\n /** The harness protocol revision. */\n readonly revision: string;\n /** The host: its name and version. */\n readonly host: { readonly name: string; readonly version: string };\n /** The ports the host registers in `mostra/initialize`. */\n readonly ports: readonly string[];\n /** The harness features the host supports. */\n readonly features: readonly HarnessFeature[];\n}\n\n/** The schema of `InitializeResult`. */\nexport const InitializeResult: z.ZodType<InitializeResult> = z.object({\n revision: z.string(),\n host: z.object({ name: z.string(), version: z.string() }),\n ports: z.array(z.string()),\n features: z.array(z.string()),\n});\n\n/** `harness/start`'s params. */\nexport interface StartParams {\n /** The home the host must use: its own choice in production (HO-08), the kit's in a run. */\n readonly home: string;\n /** Variables the host adds to its instance's environment (test switches, fault points). */\n readonly env: Readonly<Record<string, string>>;\n /** Spawn an instance over stdio (default) or attach to the home's daemon (feature `attach`). */\n readonly mode?: \"spawn\" | \"attach\";\n}\n\n/** The schema of `StartParams`. */\nexport const StartParams: z.ZodType<StartParams> = z.object({\n home: z.string(),\n env: z.record(z.string(), z.string()),\n mode: z.enum([\"spawn\", \"attach\"]).exactOptional(),\n});\n\n/** `harness/start`'s result: what `mostra/initialize` answered the host. */\nexport interface StartResult {\n /** The harness protocol revision. */\n readonly revision: string;\n /** The instance the host's session reached: its home, mode, PID, release and platform. */\n readonly instance: {\n readonly home: string;\n readonly mode: string;\n readonly pid: number;\n readonly version: string;\n readonly platform: string;\n };\n /** The session's warnings, such as an unsupported port. */\n readonly warnings: readonly { readonly code: string }[];\n}\n\n/** The schema of `StartResult`. */\nexport const StartResult: z.ZodType<StartResult> = z.object({\n revision: z.string(),\n instance: z.object({\n home: z.string(),\n mode: z.string(),\n pid: z.number(),\n version: z.string(),\n platform: z.string(),\n }),\n warnings: z.array(z.looseObject({ code: z.string() })),\n});\n\n/** `harness/call`'s params: one host-protocol request. */\nexport interface CallParams {\n /** The host-protocol method. */\n readonly method: string;\n /** Its params. */\n readonly params: unknown;\n /** How long the host waits for the answer, in milliseconds. */\n readonly timeoutMs?: number;\n}\n\n/** The schema of `CallParams`. */\nexport const CallParams: z.ZodType<CallParams> = z.object({\n method: z.string(),\n params: z.unknown(),\n timeoutMs: z.number().exactOptional(),\n});\n\n/** An instance's error as the host received it: the JSON-RPC code and the diagnostic. */\nexport interface CallError {\n /** The diagnostic code (`MOSTRA_…`). */\n readonly code: number;\n /** The diagnostic as it arrived. */\n readonly data: { readonly code: string; readonly message?: string } & Record<string, unknown>;\n}\n\n/** `harness/call`'s result: the answer, or the instance's error as it arrived. */\nexport type CallResult = { readonly result: unknown } | { readonly error: CallError };\n\n/** The schema of `CallResult`. */\nexport const CallResult: z.ZodType<CallResult> = z.union([\n z.object({ error: z.object({ code: z.number(), data: z.looseObject({ code: z.string() }) }) }),\n z.object({ result: z.unknown() }),\n]) as z.ZodType<CallResult>;\n\n/** One delivery the host's submissions port received, as its store records it. */\nexport interface StoredDelivery {\n /** The delivery's stable ID (`dlv_…`). */\n readonly deliveryId: string;\n /** The submission it delivers. */\n readonly submissionId: string;\n /** The artifact. */\n readonly artifactId: string;\n /** How many times the port was called with this delivery. */\n readonly calls: number;\n /** How many copies the host's store holds: one for a conformant host (H-03). */\n readonly stored: number;\n /** The attempt numbers it saw, in order. */\n readonly attempts: readonly number[];\n /** `envelope.kind` as received. */\n readonly kind: string;\n /** `results.submission.channel`, `.viewer.kind` and `.viewer.ref`. */\n readonly channel: string;\n /** `results.submission.viewer.kind`. */\n readonly viewerKind: string;\n /** `results.submission.viewer.ref`, when the viewer has one. */\n readonly viewerRef?: string;\n /** The order the host stored it in, from 1. */\n readonly order: number;\n}\n\n/** What the host's own store and port handlers saw. */\nexport interface StoreResult {\n /** The deliveries the host's store holds, in the order it stored them. */\n readonly deliveries: readonly StoredDelivery[];\n /** Draft mirrors, in arrival order. */\n readonly drafts: readonly {\n readonly artifactId: string;\n readonly viewerId: string;\n readonly revision: string;\n readonly kind: string;\n }[];\n /** `trustedControls.activated` calls, in arrival order. */\n readonly activations: readonly {\n readonly artifactId: string;\n readonly control: string;\n readonly viewId: string;\n }[];\n /**\n * `identity.resolve` calls: the artifact, how the request arrived, the header names, and what\n * the host answered (absent when it failed or never answered). Scenarios judge the session by\n * this answer, so a host may name people however it likes.\n */\n readonly identity: readonly {\n readonly artifactId: string;\n readonly via: string;\n readonly headers: readonly string[];\n readonly answer?: { readonly ref: string; readonly name?: string } | null;\n }[];\n /**\n * `trustedControls.policy` calls, with what the host answered (absent when it failed or never\n * answered). Scenarios judge the view by this answer when they can't script one.\n */\n readonly policies: readonly {\n readonly artifactId: string;\n readonly answer?: {\n readonly submitChannels: readonly string[];\n readonly controls?: readonly string[];\n };\n }[];\n /** `secrets.get` calls. */\n readonly secrets: readonly { readonly artifactId: string; readonly name: string }[];\n}\n\n/** The schema of `StoreResult`. */\nexport const StoreResult: z.ZodType<StoreResult> = z.object({\n deliveries: z.array(\n z.object({\n deliveryId: z.string(),\n submissionId: z.string(),\n artifactId: z.string(),\n calls: z.number(),\n stored: z.number(),\n attempts: z.array(z.number()),\n kind: z.string(),\n channel: z.string(),\n viewerKind: z.string(),\n viewerRef: z.string().optional(),\n order: z.number(),\n }),\n ),\n drafts: z.array(\n z.object({\n artifactId: z.string(),\n viewerId: z.string(),\n revision: z.string(),\n kind: z.string(),\n }),\n ),\n activations: z.array(\n z.object({ artifactId: z.string(), control: z.string(), viewId: z.string() }),\n ),\n identity: z.array(\n z.object({\n artifactId: z.string(),\n via: z.string(),\n headers: z.array(z.string()),\n answer: z\n .union([z.object({ ref: z.string(), name: z.string().optional() }), z.null()])\n .optional(),\n }),\n ),\n policies: z.array(\n z.object({\n artifactId: z.string(),\n answer: z\n .object({\n submitChannels: z.array(z.string()),\n controls: z.array(z.string()).optional(),\n })\n .optional(),\n }),\n ),\n secrets: z.array(z.object({ artifactId: z.string(), name: z.string() })),\n}) as z.ZodType<StoreResult>;\n\n/** How a scripted port answers from now on (feature `faults`). */\nexport type ScriptParams =\n | {\n readonly port: \"submissions\";\n readonly answer: \"accept\" | \"retry\" | \"undeliverable\" | \"reject\" | \"fail\" | \"hang\";\n }\n | {\n readonly port: \"trustedControls\";\n readonly answer:\n | \"fail\"\n | \"hang\"\n | {\n readonly submitChannels: readonly string[];\n readonly controls?: readonly string[];\n };\n }\n | {\n readonly port: \"identity\";\n /** `headers`: the person named by `x-forwarded-user`, else none. */\n readonly answer:\n | \"fail\"\n | \"hang\"\n | \"headers\"\n | null\n | { readonly ref: string; readonly name?: string };\n }\n | { readonly port: \"secrets\"; readonly answer: Readonly<Record<string, string>> };\n\n/** The schema of `ScriptParams`. */\nexport const ScriptParams: z.ZodType<ScriptParams> = z.union([\n z.object({\n port: z.literal(\"submissions\"),\n answer: z.enum([\"accept\", \"retry\", \"undeliverable\", \"reject\", \"fail\", \"hang\"]),\n }),\n z.object({\n port: z.literal(\"trustedControls\"),\n answer: z.union([\n z.literal(\"fail\"),\n z.literal(\"hang\"),\n z.object({\n submitChannels: z.array(z.string()),\n controls: z.array(z.string()).optional(),\n }),\n ]),\n }),\n z.object({\n port: z.literal(\"identity\"),\n answer: z.union([\n z.literal(\"fail\"),\n z.literal(\"hang\"),\n z.literal(\"headers\"),\n z.null(),\n z.object({ ref: z.string(), name: z.string().optional() }),\n ]),\n }),\n z.object({ port: z.literal(\"secrets\"), answer: z.record(z.string(), z.string()) }),\n]) as z.ZodType<ScriptParams>;\n\n/** `harness/events`'s params: read pages from the host's own named stream (feature `events`). */\nexport interface EventsParams {\n /** The subscriber name: the stream resumes after what this name acknowledged. */\n readonly name: string;\n /** The events filter. */\n readonly filter: { readonly artifacts?: readonly string[]; readonly types?: readonly string[] };\n /** Stop after this many pages, or when `timeoutMs` passes. */\n readonly pages: number;\n /** How long the host waits for the answer, in milliseconds. */\n readonly timeoutMs: number;\n}\n\n/** The schema of `EventsParams`. */\nexport const EventsParams: z.ZodType<EventsParams> = z.object({\n name: z.string(),\n filter: z.object({\n artifacts: z.array(z.string()).optional(),\n types: z.array(z.string()).optional(),\n }),\n pages: z.number(),\n timeoutMs: z.number(),\n}) as z.ZodType<EventsParams>;\n\n/** `harness/events`'s result: the pages read, every one handled and acknowledged. */\nexport interface EventsResult {\n /** The pages read, in cursor order. */\n readonly pages: readonly {\n readonly cursor: string;\n readonly events: readonly ({ readonly cursor: string; readonly type: string } & Record<\n string,\n unknown\n >)[];\n }[];\n}\n\n/** The schema of `EventsResult`. */\nexport const EventsResult: z.ZodType<EventsResult> = z.object({\n pages: z.array(\n z.object({\n cursor: z.string(),\n events: z.array(z.looseObject({ cursor: z.string(), type: z.string() })),\n }),\n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AAO;IAAE,KAAK,EAAE,OAAO;IAAG,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;GAAE,CAAC;EAC3D,CAAC;CACH,CAAC;CACD,EAAE,OAAO;EAAE,MAAM,EAAE,QAAQ,SAAS;EAAG,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;CAAE,CAAC;AACnF,CAAC;;AAeD,MAAa,eAAwC,EAAE,OAAO;CAC5D,MAAM,EAAE,OAAO;CACf,QAAQ,EAAE,OAAO;EACf,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;EACxC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACtC,CAAC;CACD,OAAO,EAAE,OAAO;CAChB,WAAW,EAAE,OAAO;AACtB,CAAC;;AAeD,MAAa,eAAwC,EAAE,OAAO,EAC5D,OAAO,EAAE,MACP,EAAE,OAAO;CACP,QAAQ,EAAE,OAAO;CACjB,QAAQ,EAAE,MAAM,EAAE,YAAY;EAAE,QAAQ,EAAE,OAAO;EAAG,MAAM,EAAE,OAAO;CAAE,CAAC,CAAC;AACzE,CAAC,CACH,EACF,CAAC"}
1
+ {"version":3,"file":"protocol-Bi4gZzsu.js","names":[],"sources":["../src/version.ts","../src/harness/protocol.ts"],"sourcesContent":["/** The kit's own release, from its package.json (found upwards from this module). */\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nlet found: string | undefined;\n\n/** This kit's release: what it reports to a host's shim and to an instance. */\nexport function kitVersion(): string {\n if (found !== undefined) return found;\n let dir = dirname(fileURLToPath(import.meta.url));\n for (;;) {\n try {\n const manifest = JSON.parse(readFileSync(join(dir, \"package.json\"), \"utf8\")) as {\n name?: string;\n version?: string;\n };\n if (manifest.name === \"@mostra/conformance\" && manifest.version) {\n found = manifest.version;\n return found;\n }\n } catch {\n // Keep looking upwards.\n }\n const parent = dirname(dir);\n if (parent === dir) throw new Error(\"Couldn't find @mostra/conformance's package.json.\");\n dir = parent;\n }\n}\n","/**\n * The conformance harness protocol (D143 item 3): how the kit drives a host under test. A host\n * ships a small shim, a program the kit starts, that speaks JSON-RPC 2.0 over its stdin and\n * stdout (one message per line, as the host protocol does) and answers these methods with its\n * real integration: its own client, its own ports, its own store. Any language can implement it;\n * TypeScript hosts get `serveHarness`, and the Rust reference host shows it in Rust.\n *\n * | Method | What the host does |\n * |---|---|\n * | `harness/initialize` | names itself, the ports it serves and the features it supports |\n * | `harness/start` | starts (spawns or attaches to) its Mostra instance for a home, with its ports |\n * | `harness/call` | sends one host-protocol request through its own client and returns the answer |\n * | `harness/stop` | ends its session (a spawned instance exits) |\n * | `harness/store` | reports what its own store holds: deliveries, mirrors, activations, calls |\n * | `harness/script` | (feature `faults`) answers a port the way the kit asks |\n * | `harness/events` | (feature `events`) reads pages from its own named event stream |\n *\n * Within a revision the protocol changes only additively, like the host protocol (D32).\n */\nimport * as z from \"zod\";\n\n/** The harness protocol revisions this kit speaks, newest last. */\nexport const HARNESS_REVISIONS: readonly string[] = [\"2026-10-21\"];\n\n/** The harness methods by name. */\nexport const HARNESS_METHODS: {\n readonly initialize: \"harness/initialize\";\n readonly start: \"harness/start\";\n readonly call: \"harness/call\";\n readonly stop: \"harness/stop\";\n readonly store: \"harness/store\";\n readonly script: \"harness/script\";\n readonly events: \"harness/events\";\n} = {\n initialize: \"harness/initialize\",\n start: \"harness/start\",\n call: \"harness/call\",\n stop: \"harness/stop\",\n store: \"harness/store\",\n script: \"harness/script\",\n events: \"harness/events\",\n};\n\n/**\n * What a host can do beyond the required methods: `attach` (`harness/start` with\n * `mode: \"attach\"`), `faults` (`harness/script`, for reference and test hosts) and `events`\n * (`harness/events`). Unknown features are ignored.\n */\nexport type HarnessFeature = \"attach\" | \"faults\" | \"events\" | (string & {});\n\n/** `harness/initialize`'s params. */\nexport interface InitializeParams {\n /** The harness protocol revision. */\n readonly revision: string;\n /** The kit that drives the host. */\n readonly kit: { readonly name: string; readonly version: string };\n}\n\n/** `harness/initialize`'s result. */\nexport interface InitializeResult {\n /** The harness protocol revision. */\n readonly revision: string;\n /** The host: its name and version. */\n readonly host: { readonly name: string; readonly version: string };\n /** The ports the host registers in `mostra/initialize`. */\n readonly ports: readonly string[];\n /** The harness features the host supports. */\n readonly features: readonly HarnessFeature[];\n}\n\n/** The schema of `InitializeResult`. */\nexport const InitializeResult: z.ZodType<InitializeResult> = z.object({\n revision: z.string(),\n host: z.object({ name: z.string(), version: z.string() }),\n ports: z.array(z.string()),\n features: z.array(z.string()),\n});\n\n/** `harness/start`'s params. */\nexport interface StartParams {\n /** The home the host must use: its own choice in production (HO-08), the kit's in a run. */\n readonly home: string;\n /** Variables the host adds to its instance's environment (test switches, fault points). */\n readonly env: Readonly<Record<string, string>>;\n /** Spawn an instance over stdio (default) or attach to the home's daemon (feature `attach`). */\n readonly mode?: \"spawn\" | \"attach\";\n}\n\n/** The schema of `StartParams`. */\nexport const StartParams: z.ZodType<StartParams> = z.object({\n home: z.string(),\n env: z.record(z.string(), z.string()),\n mode: z.enum([\"spawn\", \"attach\"]).exactOptional(),\n});\n\n/** `harness/start`'s result: what `mostra/initialize` answered the host. */\nexport interface StartResult {\n /** The harness protocol revision. */\n readonly revision: string;\n /** The instance the host's session reached: its home, mode, PID, release and platform. */\n readonly instance: {\n readonly home: string;\n readonly mode: string;\n readonly pid: number;\n readonly version: string;\n readonly platform: string;\n };\n /** The session's warnings, such as an unsupported port. */\n readonly warnings: readonly { readonly code: string }[];\n}\n\n/** The schema of `StartResult`. */\nexport const StartResult: z.ZodType<StartResult> = z.object({\n revision: z.string(),\n instance: z.object({\n home: z.string(),\n mode: z.string(),\n pid: z.number(),\n version: z.string(),\n platform: z.string(),\n }),\n warnings: z.array(z.looseObject({ code: z.string() })),\n});\n\n/** `harness/call`'s params: one host-protocol request. */\nexport interface CallParams {\n /** The host-protocol method. */\n readonly method: string;\n /** Its params. */\n readonly params: unknown;\n /** How long the host waits for the answer, in milliseconds. */\n readonly timeoutMs?: number;\n}\n\n/** The schema of `CallParams`. */\nexport const CallParams: z.ZodType<CallParams> = z.object({\n method: z.string(),\n params: z.unknown(),\n timeoutMs: z.number().exactOptional(),\n});\n\n/** An instance's error as the host received it: the JSON-RPC code and the diagnostic. */\nexport interface CallError {\n /** The diagnostic code (`MOSTRA_…`). */\n readonly code: number;\n /** The diagnostic as it arrived. */\n readonly data: { readonly code: string; readonly message?: string } & Record<string, unknown>;\n}\n\n/** `harness/call`'s result: the answer, or the instance's error as it arrived. */\nexport type CallResult = { readonly result: unknown } | { readonly error: CallError };\n\n/** The schema of `CallResult`. */\nexport const CallResult: z.ZodType<CallResult> = z.union([\n z.object({ error: z.object({ code: z.number(), data: z.looseObject({ code: z.string() }) }) }),\n z.object({ result: z.unknown() }),\n]) as z.ZodType<CallResult>;\n\n/** One delivery the host's submissions port received, as its store records it. */\nexport interface StoredDelivery {\n /** The delivery's stable ID (`dlv_…`). */\n readonly deliveryId: string;\n /** The submission it delivers. */\n readonly submissionId: string;\n /** The artifact. */\n readonly artifactId: string;\n /** How many times the port was called with this delivery. */\n readonly calls: number;\n /** How many copies the host's store holds: one for a conformant host (H-03). */\n readonly stored: number;\n /** The attempt numbers it saw, in order. */\n readonly attempts: readonly number[];\n /** `envelope.kind` as received. */\n readonly kind: string;\n /** `results.submission.channel`, `.viewer.kind` and `.viewer.ref`. */\n readonly channel: string;\n /** `results.submission.viewer.kind`. */\n readonly viewerKind: string;\n /** `results.submission.viewer.ref`, when the viewer has one. */\n readonly viewerRef?: string;\n /** The order the host stored it in, from 1. */\n readonly order: number;\n}\n\n/** What the host's own store and port handlers saw. */\nexport interface StoreResult {\n /** The deliveries the host's store holds, in the order it stored them. */\n readonly deliveries: readonly StoredDelivery[];\n /** Draft mirrors, in arrival order. */\n readonly drafts: readonly {\n readonly artifactId: string;\n readonly viewerId: string;\n readonly revision: string;\n readonly kind: string;\n }[];\n /** `trustedControls.activated` calls, in arrival order. */\n readonly activations: readonly {\n readonly artifactId: string;\n readonly control: string;\n readonly viewId: string;\n }[];\n /**\n * `identity.resolve` calls: the artifact, how the request arrived, the header names, and what\n * the host answered (absent when it failed or never answered). Scenarios judge the session by\n * this answer, so a host may name people however it likes.\n */\n readonly identity: readonly {\n readonly artifactId: string;\n readonly via: string;\n readonly headers: readonly string[];\n readonly answer?: { readonly ref: string; readonly name?: string } | null;\n }[];\n /**\n * `trustedControls.policy` calls, with what the host answered (absent when it failed or never\n * answered). Scenarios judge the view by this answer when they can't script one.\n */\n readonly policies: readonly {\n readonly artifactId: string;\n readonly answer?: {\n readonly submitChannels: readonly string[];\n readonly controls?: readonly string[];\n };\n }[];\n /** `secrets.get` calls. */\n readonly secrets: readonly { readonly artifactId: string; readonly name: string }[];\n /**\n * `addressing.externalBase` calls (WP-13): the artifact, the listener, the loopback origin the\n * host forwards to, and what the host answered (absent when it failed). A host without the port\n * leaves it out.\n */\n readonly addressing?: readonly {\n readonly artifactId: string;\n readonly listener: string;\n readonly local: string;\n readonly answer?: { readonly origin: string; readonly mode?: string } | null;\n }[];\n}\n\n/** The schema of `StoreResult`. */\nexport const StoreResult: z.ZodType<StoreResult> = z.object({\n deliveries: z.array(\n z.object({\n deliveryId: z.string(),\n submissionId: z.string(),\n artifactId: z.string(),\n calls: z.number(),\n stored: z.number(),\n attempts: z.array(z.number()),\n kind: z.string(),\n channel: z.string(),\n viewerKind: z.string(),\n viewerRef: z.string().optional(),\n order: z.number(),\n }),\n ),\n drafts: z.array(\n z.object({\n artifactId: z.string(),\n viewerId: z.string(),\n revision: z.string(),\n kind: z.string(),\n }),\n ),\n activations: z.array(\n z.object({ artifactId: z.string(), control: z.string(), viewId: z.string() }),\n ),\n identity: z.array(\n z.object({\n artifactId: z.string(),\n via: z.string(),\n headers: z.array(z.string()),\n answer: z\n .union([z.object({ ref: z.string(), name: z.string().optional() }), z.null()])\n .optional(),\n }),\n ),\n policies: z.array(\n z.object({\n artifactId: z.string(),\n answer: z\n .object({\n submitChannels: z.array(z.string()),\n controls: z.array(z.string()).optional(),\n })\n .optional(),\n }),\n ),\n secrets: z.array(z.object({ artifactId: z.string(), name: z.string() })),\n addressing: z\n .array(\n z.object({\n artifactId: z.string(),\n listener: z.string(),\n local: z.string(),\n answer: z\n .union([z.object({ origin: z.string(), mode: z.string().optional() }), z.null()])\n .optional(),\n }),\n )\n .optional(),\n}) as z.ZodType<StoreResult>;\n\n/** How a scripted port answers from now on (feature `faults`). */\nexport type ScriptParams =\n | {\n readonly port: \"submissions\";\n readonly answer: \"accept\" | \"retry\" | \"undeliverable\" | \"reject\" | \"fail\" | \"hang\";\n }\n | {\n readonly port: \"trustedControls\";\n readonly answer:\n | \"fail\"\n | \"hang\"\n | {\n readonly submitChannels: readonly string[];\n readonly controls?: readonly string[];\n };\n }\n | {\n readonly port: \"identity\";\n /** `headers`: the person named by `x-forwarded-user`, else none. */\n readonly answer:\n | \"fail\"\n | \"hang\"\n | \"headers\"\n | null\n | { readonly ref: string; readonly name?: string };\n }\n | { readonly port: \"secrets\"; readonly answer: Readonly<Record<string, string>> }\n | {\n readonly port: \"addressing\";\n /**\n * `null`: no external base (the loopback ports); `fail`: the call fails; a pair of host\n * names: each listener at its loopback port under that name (`http://<host>:<port>`), the\n * shell's and the artifact's, which the kit sets apart to make them two sites (WP-13).\n */\n readonly answer:\n | null\n | \"fail\"\n | {\n readonly shellHost: string;\n readonly artifactHost: string;\n readonly mode?: \"cookie\" | \"worker\";\n };\n };\n\n/** The schema of `ScriptParams`. */\nexport const ScriptParams: z.ZodType<ScriptParams> = z.union([\n z.object({\n port: z.literal(\"submissions\"),\n answer: z.enum([\"accept\", \"retry\", \"undeliverable\", \"reject\", \"fail\", \"hang\"]),\n }),\n z.object({\n port: z.literal(\"trustedControls\"),\n answer: z.union([\n z.literal(\"fail\"),\n z.literal(\"hang\"),\n z.object({\n submitChannels: z.array(z.string()),\n controls: z.array(z.string()).optional(),\n }),\n ]),\n }),\n z.object({\n port: z.literal(\"identity\"),\n answer: z.union([\n z.literal(\"fail\"),\n z.literal(\"hang\"),\n z.literal(\"headers\"),\n z.null(),\n z.object({ ref: z.string(), name: z.string().optional() }),\n ]),\n }),\n z.object({ port: z.literal(\"secrets\"), answer: z.record(z.string(), z.string()) }),\n z.object({\n port: z.literal(\"addressing\"),\n answer: z.union([\n z.null(),\n z.literal(\"fail\"),\n z.object({\n shellHost: z.string(),\n artifactHost: z.string(),\n mode: z.enum([\"cookie\", \"worker\"]).optional(),\n }),\n ]),\n }),\n]) as z.ZodType<ScriptParams>;\n\n/** `harness/events`'s params: read pages from the host's own named stream (feature `events`). */\nexport interface EventsParams {\n /** The subscriber name: the stream resumes after what this name acknowledged. */\n readonly name: string;\n /** The events filter. */\n readonly filter: { readonly artifacts?: readonly string[]; readonly types?: readonly string[] };\n /** Stop after this many pages, or when `timeoutMs` passes. */\n readonly pages: number;\n /** How long the host waits for the answer, in milliseconds. */\n readonly timeoutMs: number;\n}\n\n/** The schema of `EventsParams`. */\nexport const EventsParams: z.ZodType<EventsParams> = z.object({\n name: z.string(),\n filter: z.object({\n artifacts: z.array(z.string()).optional(),\n types: z.array(z.string()).optional(),\n }),\n pages: z.number(),\n timeoutMs: z.number(),\n}) as z.ZodType<EventsParams>;\n\n/** `harness/events`'s result: the pages read, every one handled and acknowledged. */\nexport interface EventsResult {\n /** The pages read, in cursor order. */\n readonly pages: readonly {\n readonly cursor: string;\n readonly events: readonly ({ readonly cursor: string; readonly type: string } & Record<\n string,\n unknown\n >)[];\n }[];\n}\n\n/** The schema of `EventsResult`. */\nexport const EventsResult: z.ZodType<EventsResult> = z.object({\n pages: z.array(\n z.object({\n cursor: z.string(),\n events: z.array(z.looseObject({ cursor: z.string(), type: z.string() })),\n }),\n ),\n}) as z.ZodType<EventsResult>;\n"],"mappings":";;;;;;AAKA,IAAI;;AAGJ,SAAgB,aAAqB;CACnC,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,MAAM,QAAQ,cAAc,YAAY,G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Version, l as StartParams, o as HARNESS_REVISIONS, r as EventsParams, t as CallParams } from "./protocol-RQ9lbehE.js";
1
+ import { a as HARNESS_METHODS, c as ScriptParams, f as kitVersion, l as StartParams, o as HARNESS_REVISIONS, r as EventsParams, t as CallParams } from "./protocol-Bi4gZzsu.js";
2
2
  import { realpathSync } from "node:fs";
3
3
  import { LineSplitter, RpcError, RpcPeer, createDiagnostic, encodeLine, hostMethods } from "@mostra/protocol";
4
4
  import { createMostra } from "@mostra/sdk";
@@ -133,6 +133,9 @@ var ReferenceStore = class {
133
133
  #identity = [];
134
134
  #policies = [];
135
135
  #secrets = [];
136
+ #addressing = [];
137
+ /** No external base until scripted: the loopback ports every other scenario expects. */
138
+ #base = null;
136
139
  #faults;
137
140
  #order = 0;
138
141
  /** How the scripted ports answer (feature `faults`). */
@@ -160,6 +163,7 @@ var ReferenceStore = class {
160
163
  if (params.port === "submissions") this.#deliver = params.answer;
161
164
  else if (params.port === "trustedControls") this.#policy = params.answer;
162
165
  else if (params.port === "identity") this.#person = params.answer;
166
+ else if (params.port === "addressing") this.#base = params.answer;
163
167
  else this.#secretValues = params.answer;
164
168
  }
165
169
  /** Records one delivery the way a host's database would: once per `deliveryId`. */
@@ -281,6 +285,28 @@ var ReferenceStore = class {
281
285
  });
282
286
  }
283
287
  },
288
+ addressing: { externalBase: (request) => {
289
+ const answer = this.#base;
290
+ const call = {
291
+ artifactId: request.artifactId,
292
+ listener: request.listener,
293
+ local: request.local
294
+ };
295
+ if (answer === "fail") {
296
+ this.#addressing.push(call);
297
+ throw new Error("the host's tunnel is unavailable");
298
+ }
299
+ const host = request.listener === "shell" ? answer?.shellHost : answer?.artifactHost;
300
+ const base = answer === null ? null : {
301
+ origin: `http://${host}:${new URL(request.local).port}`,
302
+ ...answer.mode ? { mode: answer.mode } : {}
303
+ };
304
+ this.#addressing.push({
305
+ ...call,
306
+ answer: base
307
+ });
308
+ return base;
309
+ } },
284
310
  secrets: { get: (request) => {
285
311
  this.#secrets.push({
286
312
  artifactId: request.artifactId,
@@ -298,7 +324,8 @@ var ReferenceStore = class {
298
324
  activations: [...this.#activations],
299
325
  identity: [...this.#identity],
300
326
  policies: [...this.#policies],
301
- secrets: [...this.#secrets]
327
+ secrets: [...this.#secrets],
328
+ addressing: [...this.#addressing]
302
329
  };
303
330
  }
304
331
  };
@@ -421,4 +448,4 @@ if (isMain()) {
421
448
  //#endregion
422
449
  export { serveHarness as i, ReferenceStore as n, runReferenceHost as r, REFERENCE_FAULTS as t };
423
450
 
424
- //# sourceMappingURL=reference-host-D7fe25go.js.map
451
+ //# sourceMappingURL=reference-host-BAAxMabg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference-host-BAAxMabg.js","names":[],"sources":["../src/harness/serve.ts","../src/reference-host.ts"],"sourcesContent":["/**\n * The host's side of the harness protocol, for hosts written in TypeScript: `serveHarness` reads\n * the kit's requests on stdin and answers them with the host's implementation, on stdout. A host\n * writes its shim as one small program around its real integration:\n *\n * ```ts\n * serveHarness({\n * initialize: () => ({ host: { name: \"my-host\", version: \"1.0.0\" }, ports: [\"submissions\"], features: [] }),\n * start: (params) => myHost.startMostra(params.home, params.env),\n * call: (method, params) => myHost.mostra.call(method, params),\n * stop: () => myHost.stopMostra(),\n * store: () => myHost.conformanceStore(),\n * });\n * ```\n *\n * Nothing but protocol messages may go to stdout; log to stderr.\n */\nimport { createDiagnostic, encodeLine, LineSplitter, RpcError, RpcPeer } from \"@mostra/protocol\";\nimport {\n CallParams,\n type CallResult,\n EventsParams,\n type EventsResult,\n HARNESS_METHODS,\n HARNESS_REVISIONS,\n type InitializeResult,\n ScriptParams,\n StartParams,\n type StartResult,\n type StoreResult,\n} from \"./protocol.ts\";\n\n/** What a TypeScript host implements to be driven by the kit. */\nexport interface HarnessImplementation {\n /** Who the host is, the ports it serves and its features. */\n initialize(): Omit<InitializeResult, \"revision\"> | Promise<Omit<InitializeResult, \"revision\">>;\n /** Starts (or attaches to) the host's instance for `params.home`, with its real ports. */\n start(params: StartParams): StartResult | Promise<StartResult>;\n /** Sends one host-protocol request through the host's client; throw an `RpcError` for an error answer. */\n call(method: string, params: unknown, timeoutMs?: number): unknown;\n /** Ends the host's session. */\n stop(): void | Promise<void>;\n /** What the host's own store holds. */\n store(): StoreResult | Promise<StoreResult>;\n /** Feature `faults`: answer a port as the kit asks. */\n script?(params: ScriptParams): void | Promise<void>;\n /** Feature `events`: read pages from the host's own named event stream. */\n events?(params: EventsParams): EventsResult | Promise<EventsResult>;\n}\n\nfunction invalid(method: string, message: string): RpcError {\n return new RpcError(\n createDiagnostic(\"MOSTRA_HOST_INVALID_PARAMS\", { message: `${method}: ${message}` }),\n -32602,\n );\n}\n\n/**\n * Serves the harness protocol on this process's stdin and stdout until stdin ends, then stops\n * the host's session and resolves.\n */\nexport function serveHarness(\n implementation: HarnessImplementation,\n io: { input?: NodeJS.ReadableStream; output?: NodeJS.WritableStream } = {},\n): Promise<void> {\n const input = io.input ?? process.stdin;\n const output = io.output ?? process.stdout;\n const peer = new RpcPeer({\n send: (message) => {\n output.write(encodeLine(message));\n },\n onRequest: async (method, params) => {\n switch (method) {\n case HARNESS_METHODS.initialize: {\n const revision = HARNESS_REVISIONS.at(-1) as string;\n return { revision, ...(await implementation.initialize()) };\n }\n case HARNESS_METHODS.start: {\n const parsed = StartParams.safeParse(params);\n if (!parsed.success) throw invalid(method, parsed.error.message);\n return await implementation.start(parsed.data);\n }\n case HARNESS_METHODS.call: {\n const parsed = CallParams.safeParse(params);\n if (!parsed.success) throw invalid(method, parsed.error.message);\n try {\n const result = await implementation.call(\n parsed.data.method,\n parsed.data.params,\n parsed.data.timeoutMs,\n );\n return { result: result ?? null } satisfies CallResult;\n } catch (error) {\n if (error instanceof RpcError)\n return {\n error: { code: error.code, data: { ...error.diagnostic } },\n } satisfies CallResult;\n throw error;\n }\n }\n case HARNESS_METHODS.stop:\n await implementation.stop();\n return {};\n case HARNESS_METHODS.store:\n return await implementation.store();\n case HARNESS_METHODS.script: {\n if (!implementation.script) break;\n const parsed = ScriptParams.safeParse(params);\n if (!parsed.success) throw invalid(method, parsed.error.message);\n await implementation.script(parsed.data);\n return {};\n }\n case HARNESS_METHODS.events: {\n if (!implementation.events) break;\n const parsed = EventsParams.safeParse(params);\n if (!parsed.success) throw invalid(method, parsed.error.message);\n return await implementation.events(parsed.data);\n }\n }\n throw new RpcError(\n createDiagnostic(\"MOSTRA_HOST_METHOD_UNKNOWN\", {\n message: `This host serves no harness method ${method}.`,\n }),\n -32601,\n );\n },\n onInternalError: (error, method) => {\n process.stderr.write(`harness: ${method} failed: ${(error as Error).stack ?? error}\\n`);\n },\n });\n const lines = new LineSplitter();\n (input as NodeJS.ReadStream).setEncoding?.(\"utf8\");\n input.on(\"data\", (chunk: string) => {\n for (const line of lines.push(chunk)) peer.receiveLine(line);\n });\n return new Promise((done) => {\n input.on(\"end\", () => {\n void Promise.resolve(implementation.stop())\n .catch(() => undefined)\n .finally(() => {\n peer.close();\n done();\n });\n });\n });\n}\n","#!/usr/bin/env node\n/**\n * `mostra-conformance-reference-host`: the TypeScript reference host (HO-05). A host built the way\n * the docs recommend, on `@mostra/sdk`, with a store that keeps each submission once by its\n * `deliveryId` (H-03), every port the SDK serves, and the harness shim the kit drives. It is the\n * model a TypeScript host copies, and the kit's own proof that its scenarios pass.\n *\n * mostra-conformance-reference-host every port\n * mostra-conformance-reference-host --standalone no port: Mostra's built-in adapters\n * mostra-conformance-reference-host --unscripted every port, without the `faults` feature:\n * its policy allows both channels and it names people by its own IDs (`user-1` …), so the\n * kit judges it by the answers it reports, as it must any host that can't be scripted\n * mostra-conformance-reference-host --break <fault,…> a deliberately broken host:\n * store-duplicates stores every delivery call, so a redelivery is stored twice\n * drafts-as-submissions takes draft mirrors for submissions\n * ignore-policy allows both channels whatever the kit scripted\n *\n * Its own runtime is found like any SDK host's (`MOSTRA_BUNDLE`, `MOSTRA_RUNTIME_BIN`, the pinned\n * bundle, a development checkout).\n */\nimport { realpathSync } from \"node:fs\";\nimport { pathToFileURL } from \"node:url\";\nimport { parseArgs } from \"node:util\";\nimport {\n type ArtifactSummary,\n type ControlsPolicy,\n createDiagnostic,\n type DraftMirror,\n hostMethods,\n type PortAddressingExternalBaseParams,\n type PortAddressingExternalBaseResult,\n type PortIdentityResolveParams,\n type PortSecretsGetParams,\n type PortTrustedControlsActivatedParams,\n RpcError,\n type SubmissionEnvelope,\n type SubmissionsDeliverResult,\n} from \"@mostra/protocol\";\nimport { createMostra, type Mostra, type Ports } from \"@mostra/sdk\";\nimport type {\n EventsParams,\n EventsResult,\n ScriptParams,\n StartParams,\n StartResult,\n StoredDelivery,\n StoreResult,\n} from \"./harness/protocol.ts\";\nimport { serveHarness } from \"./harness/serve.ts\";\nimport { kitVersion } from \"./version.ts\";\n\n/** The faults a broken reference host can carry. */\nexport const REFERENCE_FAULTS: readonly string[] = [\n \"store-duplicates\",\n \"drafts-as-submissions\",\n \"ignore-policy\",\n];\n\n/** The reference host's store and port answers: what a real host keeps in its own database. */\nexport class ReferenceStore {\n readonly #deliveries = new Map<string, StoredDelivery & { attempts: number[] }>();\n readonly #drafts: StoreResult[\"drafts\"][number][] = [];\n readonly #activations: StoreResult[\"activations\"][number][] = [];\n readonly #identity: StoreResult[\"identity\"][number][] = [];\n readonly #policies: StoreResult[\"policies\"][number][] = [];\n readonly #secrets: StoreResult[\"secrets\"][number][] = [];\n readonly #addressing: NonNullable<StoreResult[\"addressing\"]>[number][] = [];\n /** No external base until scripted: the loopback ports every other scenario expects. */\n #base: Extract<ScriptParams, { port: \"addressing\" }>[\"answer\"] = null;\n readonly #faults: ReadonlySet<string>;\n #order = 0;\n /** How the scripted ports answer (feature `faults`). */\n #deliver: Extract<ScriptParams, { port: \"submissions\" }>[\"answer\"] = \"accept\";\n #policy: Extract<ScriptParams, { port: \"trustedControls\" }>[\"answer\"] = {\n submitChannels: [\"shell\"],\n controls: [\"submit\", \"choose\", \"approve\"],\n };\n #person: Extract<ScriptParams, { port: \"identity\" }>[\"answer\"] = \"headers\";\n #secretValues: Readonly<Record<string, string>> = {};\n\n /** People by the header that named them, for an unscripted host's own IDs. */\n readonly #people = new Map<string, string>();\n readonly #unscripted: boolean;\n\n constructor(faults: ReadonlySet<string> = new Set(), unscripted = false) {\n this.#faults = faults;\n this.#unscripted = unscripted;\n if (unscripted) this.#policy = { submitChannels: [\"artifact\", \"shell\"] };\n }\n\n /** Sets how a port answers from now on (feature `faults`). */\n script(params: ScriptParams): void {\n if (params.port === \"submissions\") this.#deliver = params.answer;\n else if (params.port === \"trustedControls\") this.#policy = params.answer;\n else if (params.port === \"identity\") this.#person = params.answer;\n else if (params.port === \"addressing\") this.#base = params.answer;\n else this.#secretValues = params.answer;\n }\n\n /** Records one delivery the way a host's database would: once per `deliveryId`. */\n #record(envelope: SubmissionEnvelope | (DraftMirror & { kind: string })): void {\n const id =\n \"deliveryId\" in envelope\n ? envelope.deliveryId\n : `draft-${envelope.viewerId}-${envelope.revision}`;\n const existing = this.#deliveries.get(id);\n const attempt = \"attempt\" in envelope ? envelope.attempt : 1;\n if (existing) {\n existing.attempts.push(attempt);\n (existing as { calls: number }).calls += 1;\n if (this.#faults.has(\"store-duplicates\")) (existing as { stored: number }).stored += 1;\n return;\n }\n const results = \"results\" in envelope ? envelope.results : undefined;\n this.#order += 1;\n this.#deliveries.set(id, {\n deliveryId: id,\n submissionId: results?.submission.id ?? \"\",\n artifactId: envelope.artifactId,\n calls: 1,\n stored: 1,\n attempts: [attempt],\n kind: envelope.kind,\n channel: results?.submission.channel ?? \"\",\n viewerKind: results?.submission.viewer.kind ?? \"\",\n ...(results?.submission.viewer.ref !== undefined\n ? { viewerRef: results.submission.viewer.ref }\n : {}),\n order: this.#order,\n });\n }\n\n /** The ports, as the SDK takes them. */\n ports(): Ports {\n return {\n submissions: {\n deliver: async (envelope: SubmissionEnvelope): Promise<SubmissionsDeliverResult> => {\n const answer = this.#deliver;\n if (answer === \"fail\") throw new Error(\"the host's store is unavailable\");\n if (answer === \"hang\") return new Promise(() => undefined);\n if (answer === \"retry\") return { accepted: false, reason: \"busy\", retry: true };\n if (answer === \"undeliverable\")\n return { accepted: false, reason: \"undeliverable\", retry: false };\n if (answer === \"reject\") return { accepted: false, reason: \"invalid\", retry: false };\n // A redelivery of a delivery the store holds is accepted again, never stored twice.\n this.#record(envelope);\n return { accepted: true };\n },\n },\n drafts: {\n mirror: (draft: DraftMirror) => {\n this.#drafts.push({\n artifactId: draft.artifactId,\n viewerId: draft.viewerId,\n revision: draft.revision,\n kind: draft.kind,\n });\n if (this.#faults.has(\"drafts-as-submissions\")) this.#record(draft);\n },\n },\n identity: {\n resolve: async (request: PortIdentityResolveParams) => {\n const call = {\n artifactId: request.artifactId,\n via: request.via,\n headers: Object.keys(request.headers).sort(),\n };\n const answer = this.#person;\n if (answer === \"fail\" || answer === \"hang\") {\n this.#identity.push(call);\n if (answer === \"fail\") throw new Error(\"the host's directory is unavailable\");\n return new Promise<never>(() => undefined);\n }\n let person: { ref: string; name?: string } | null = answer === \"headers\" ? null : answer;\n if (answer === \"headers\") {\n const user = request.headers[\"x-forwarded-user\"];\n if (user && this.#unscripted && !this.#people.has(user)) {\n this.#people.set(user, `user-${this.#people.size + 1}`);\n }\n const ref = user && this.#unscripted ? this.#people.get(user) : user;\n person = user && ref ? { ref, name: user.split(\"@\")[0] ?? user } : null;\n }\n this.#identity.push({ ...call, answer: person });\n return person;\n },\n },\n trustedControls: {\n policy: async (artifact: ArtifactSummary): Promise<ControlsPolicy> => {\n const answer = this.#policy;\n if (this.#faults.has(\"ignore-policy\")) {\n const both: ControlsPolicy = { submitChannels: [\"shell\", \"artifact\"] };\n this.#policies.push({ artifactId: artifact.id, answer: both });\n return both;\n }\n if (answer === \"fail\" || answer === \"hang\") {\n this.#policies.push({ artifactId: artifact.id });\n if (answer === \"fail\") throw new Error(\"the host's policy service is unavailable\");\n return new Promise<never>(() => undefined);\n }\n this.#policies.push({ artifactId: artifact.id, answer: answer as ControlsPolicy });\n return answer as ControlsPolicy;\n },\n activated: (event: PortTrustedControlsActivatedParams) => {\n this.#activations.push({\n artifactId: event.artifactId,\n control: event.control,\n viewId: event.viewId,\n });\n },\n },\n addressing: {\n externalBase: (\n request: PortAddressingExternalBaseParams,\n ): PortAddressingExternalBaseResult => {\n const answer = this.#base;\n const call = {\n artifactId: request.artifactId,\n listener: request.listener,\n local: request.local,\n };\n if (answer === \"fail\") {\n this.#addressing.push(call);\n throw new Error(\"the host's tunnel is unavailable\");\n }\n const host = request.listener === \"shell\" ? answer?.shellHost : answer?.artifactHost;\n const base =\n answer === null\n ? null\n : {\n origin: `http://${host}:${new URL(request.local).port}`,\n ...(answer.mode ? { mode: answer.mode } : {}),\n };\n this.#addressing.push({ ...call, answer: base });\n return base;\n },\n },\n secrets: {\n get: (request: PortSecretsGetParams) => {\n this.#secrets.push({ artifactId: request.artifactId, name: request.name });\n return this.#secretValues[request.name] ?? null;\n },\n },\n };\n }\n\n /** What the store holds now. */\n snapshot(): StoreResult {\n return {\n deliveries: [...this.#deliveries.values()].sort((a, b) => a.order - b.order),\n drafts: [...this.#drafts],\n activations: [...this.#activations],\n identity: [...this.#identity],\n policies: [...this.#policies],\n secrets: [...this.#secrets],\n addressing: [...this.#addressing],\n };\n }\n}\n\n/** Runs the reference host's harness on stdio. */\nexport async function runReferenceHost(\n options: { standalone?: boolean; unscripted?: boolean; faults?: readonly string[] } = {},\n): Promise<void> {\n const faults = new Set(options.faults ?? []);\n const unscripted = options.unscripted ?? false;\n const store = new ReferenceStore(faults, unscripted);\n let mostra: Mostra | undefined;\n const ports = options.standalone ? {} : store.ports();\n const portNames = Object.keys(ports);\n const name = options.standalone\n ? \"reference-host-ts-standalone\"\n : unscripted\n ? \"reference-host-ts-unscripted\"\n : faults.size > 0\n ? \"reference-host-ts-broken\"\n : \"reference-host-ts\";\n await serveHarness({\n initialize: () => ({\n host: { name, version: kitVersion() },\n ports: portNames,\n features: options.standalone || unscripted ? [\"events\"] : [\"faults\", \"events\"],\n }),\n async start(params: StartParams): Promise<StartResult> {\n if (params.mode === \"attach\") {\n throw new RpcError(\n createDiagnostic(\"MOSTRA_HOST_INVALID_PARAMS\", {\n message: \"The TypeScript reference host spawns its instance; it doesn't attach.\",\n }),\n );\n }\n await mostra?.close();\n mostra = await createMostra({\n home: params.home,\n client: { name, version: kitVersion() },\n ports,\n env: { ...process.env, ...params.env },\n onLog: () => undefined,\n });\n return {\n revision: mostra.revision,\n instance: mostra.instance,\n warnings: mostra.warnings,\n };\n },\n async call(method: string, params: unknown, timeoutMs?: number) {\n const definition = hostMethods.find((candidate) => candidate.method === method);\n if (!mostra) {\n throw new RpcError(\n createDiagnostic(\"MOSTRA_HOST_CONNECTION_CLOSED\", { message: \"No instance runs.\" }),\n );\n }\n if (!definition) {\n throw new RpcError(\n createDiagnostic(\"MOSTRA_HOST_METHOD_UNKNOWN\", { message: `No method ${method}.` }),\n -32601,\n );\n }\n return mostra.call(definition, params, timeoutMs !== undefined ? { timeoutMs } : {});\n },\n async stop() {\n const current = mostra;\n mostra = undefined;\n await current?.close();\n },\n store: () => store.snapshot(),\n ...(options.standalone || unscripted\n ? {}\n : { script: (params: ScriptParams) => store.script(params) }),\n async events(params: EventsParams): Promise<EventsResult> {\n if (!mostra) throw new Error(\"No instance runs.\");\n const pages: EventsResult[\"pages\"][number][] = [];\n const stream = mostra\n .events({\n name: params.name,\n filter: {\n ...(params.filter.artifacts ? { artifacts: [...params.filter.artifacts] } : {}),\n ...(params.filter.types ? { types: [...params.filter.types] } : {}),\n },\n })\n [Symbol.asyncIterator]();\n const deadline = Date.now() + params.timeoutMs;\n try {\n while (pages.length < params.pages) {\n const left = deadline - Date.now();\n if (left <= 0) break;\n const next = await Promise.race([\n stream.next(),\n new Promise<\"timeout\">((done) => setTimeout(() => done(\"timeout\"), left)),\n ]);\n if (next === \"timeout\" || next.done) break;\n pages.push({\n cursor: next.value.cursor,\n events: next.value.events.map((event) => ({ ...event })),\n });\n }\n } finally {\n // Asking for the next page is what tells the SDK the last one was handled: it acknowledges\n // it at once, then waits for a page this stream won't read, so the wait is cut short.\n await Promise.race([\n stream.next().catch(() => undefined),\n new Promise((done) => setTimeout(done, 1000)),\n ]);\n await stream.return?.();\n }\n return { pages };\n },\n });\n}\n\n/**\n * Whether this module is the program Node.js was started with: by file URL, which spells a\n * Windows path (`file:///D:/…`) as no string concatenation does, through any link, or as the\n * installed binary (`mostra-conformance-reference-host`, a link or npm's shim to `dist/`).\n */\nfunction isMain(): boolean {\n const entry = process.argv[1];\n if (entry === undefined) return false;\n try {\n if (pathToFileURL(realpathSync(entry)).href === import.meta.url) return true;\n } catch {\n // An entry that doesn't exist as a file is judged by its name alone.\n }\n return entry.endsWith(\"reference-host.js\");\n}\n\nif (isMain()) {\n const { values } = parseArgs({\n options: {\n standalone: { type: \"boolean\" },\n unscripted: { type: \"boolean\" },\n break: { type: \"string\" },\n },\n strict: true,\n });\n const faults = values.break ? values.break.split(\",\").filter(Boolean) : [];\n for (const fault of faults) {\n if (!REFERENCE_FAULTS.includes(fault)) {\n process.stderr.write(`Unknown fault ${fault}; known: ${REFERENCE_FAULTS.join(\", \")}\\n`);\n process.exit(2);\n }\n }\n void runReferenceHost({\n standalone: values.standalone ?? false,\n unscripted: values.unscripted ?? false,\n faults,\n }).then(() => process.exit(0));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAS,QAAQ,QAAgB,SAA2B;CAC1D,OAAO,IAAI,SACT,iBAAiB,8BAA8B,EAAE,SAAS,GAAG,OAAO,IAAI,UAAU,CAAC,GACnF,MACF;AACF;;;;;AAMA,SAAgB,aACd,gBACA,KAAwE,CAAC,GAC1D;CACf,MAAM,QAAQ,GAAG,SAAS,QAAQ;CAClC,MAAM,SAAS,GAAG,UAAU,QAAQ;CACpC,MAAM,OAAO,IAAI,QAAQ;EACvB,OAAO,YAAY;GACjB,OAAO,MAAM,WAAW,OAAO,CAAC;EAClC;EACA,WAAW,OAAO,QAAQ,WAAW;GACnC,QAAQ,QAAR;IACE,KAAK,g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cAAc;EACjC,YAAY,OAAO,cAAc;EACjC;CACF,CAAC,CAAC,CAAC,WAAW,QAAQ,KAAK,CAAC,CAAC;AAC/B"}
@@ -176,6 +176,20 @@ interface StoreResult {
176
176
  readonly artifactId: string;
177
177
  readonly name: string;
178
178
  }[];
179
+ /**
180
+ * `addressing.externalBase` calls (WP-13): the artifact, the listener, the loopback origin the
181
+ * host forwards to, and what the host answered (absent when it failed). A host without the port
182
+ * leaves it out.
183
+ */
184
+ readonly addressing?: readonly {
185
+ readonly artifactId: string;
186
+ readonly listener: string;
187
+ readonly local: string;
188
+ readonly answer?: {
189
+ readonly origin: string;
190
+ readonly mode?: string;
191
+ } | null;
192
+ }[];
179
193
  }
180
194
  /** The schema of `StoreResult`. */
181
195
  declare const StoreResult: z.ZodType<StoreResult>;
@@ -199,6 +213,18 @@ type ScriptParams = {
199
213
  } | {
200
214
  readonly port: "secrets";
201
215
  readonly answer: Readonly<Record<string, string>>;
216
+ } | {
217
+ readonly port: "addressing";
218
+ /**
219
+ * `null`: no external base (the loopback ports); `fail`: the call fails; a pair of host
220
+ * names: each listener at its loopback port under that name (`http://<host>:<port>`), the
221
+ * shell's and the artifact's, which the kit sets apart to make them two sites (WP-13).
222
+ */
223
+ readonly answer: null | "fail" | {
224
+ readonly shellHost: string;
225
+ readonly artifactHost: string;
226
+ readonly mode?: "cookie" | "worker";
227
+ };
202
228
  };
203
229
  /** The schema of `ScriptParams`. */
204
230
  declare const ScriptParams: z.ZodType<ScriptParams>;
@@ -254,4 +280,4 @@ declare function runReferenceHost(options?: {
254
280
  }): Promise<void>;
255
281
  //#endregion
256
282
  export { StoreResult as _, CallParams as a, EventsResult as c, HarnessFeature as d, InitializeParams as f, StartResult as g, StartParams as h, CallError as i, HARNESS_METHODS as l, ScriptParams as m, ReferenceStore as n, CallResult as o, InitializeResult as p, runReferenceHost as r, EventsParams as s, REFERENCE_FAULTS as t, HARNESS_REVISIONS as u, StoredDelivery as v };
257
- //# sourceMappingURL=reference-host-BJ-A_Qd_.d.ts.map
283
+ //# sourceMappingURL=reference-host-DYKrtRCH.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reference-host-BJ-A_Qd_.d.ts","names":[],"sources":["../src/harness/protocol.ts","../src/reference-host.ts"],"mappings":";;;;cAsBa;;cAGA;WACF;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;;KAgBC;;UAGK;;WAEN;;WAEA;aAAgB;aAAuB;;;;UAIjC;;WAEN;;WAEA;aAAiB;aAAuB;;;WAExC;;WAEA,mBAAmB;;;cAIjB,kBAAkB,EAAE,QAAQ;;UAQxB;;WAEN;;WAEA,KAAK,SAAS;;WAEd;;;cAIE,aAAa,EAAE,QAAQ;;UAOnB;;WAEN;;WAEA;aACE;aACA;aACA;aACA;aACA;;;WAGF;aAA8B;;;;cAI5B,aAAa,EAAE,QAAQ;;UAanB;;WAEN;;WAEA;;WAEA;;;cAIE,YAAY,EAAE,QAAQ;;UAOlB;;WAEN;;WAEA;aAAiB;aAAuB;MAAqB;;;KAI5D;WAAwB;;WAA+B,OAAO;;;cAG7D,YAAY,EAAE,QAAQ;;UAMlB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN,qBAAqB;;WAErB;aACE;aACA;aACA;aACA;;;WAGF;aACE;aACA;aACA;;;;;;;WAOF;aACE;aACA;aACA;aACA;eAAoB;eAAsB;;;;;;;WAM5C;aACE;aACA;eACE;eACA;;;;WAIJ;aAA6B;aAA6B;;;;cAIxD,aAAa,EAAE,QAAQ;;KAoDxB;WAEG;WACA;;WAGA;WACA;aAIM;aACA;;;WAIN;;WAEA;aAKM;aAAsB;;;WAE5B;WAA0B,QAAQ,SAAS;;;cAG7C,cAAc,EAAE,QAAQ;;UA8BpB;;WAEN;;WAEA;aAAmB;aAAwC;;;WAE3D;;WAEA;;;cAIE,cAAc,EAAE,QAAQ;;UAWpB;;WAEN;aACE;aACA;eAA6B;eAAyB;QAAiB;;;;cAQvE,cAAc,EAAE,QAAQ;;;;cCnUxB;;cAOA;;EAsBX,YAAY,SAAQ,qBAAiC;;EAOrD,OAAO,QAAQ;;EAyCf,SAAS;;EAuFT,YAAY;;;iBAaQ,iBACpB;EAAW;EAAsB;EAAsB;IACtD"}
1
+ {"version":3,"file":"reference-host-DYKrtRCH.d.ts","names":[],"sources":["../src/harness/protocol.ts","../src/reference-host.ts"],"mappings":";;;;cAsBa;;cAGA;WACF;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;;KAgBC;;UAGK;;WAEN;;WAEA;aAAgB;aAAuB;;;;UAIjC;;WAEN;;WAEA;aAAiB;aAAuB;;;WAExC;;WAEA,mBAAmB;;;cAIjB,kBAAkB,EAAE,QAAQ;;UAQxB;;WAEN;;WAEA,KAAK,SAAS;;WAEd;;;cAIE,aAAa,EAAE,QAAQ;;UAOnB;;WAEN;;WAEA;aACE;aACA;aACA;aACA;aACA;;;WAGF;aAA8B;;;;cAI5B,aAAa,EAAE,QAAQ;;UAanB;;WAEN;;WAEA;;WAEA;;;cAIE,YAAY,EAAE,QAAQ;;UAOlB;;WAEN;;WAEA;aAAiB;aAAuB;MAAqB;;;KAI5D;WAAwB;;WAA+B,OAAO;;;cAG7D,YAAY,EAAE,QAAQ;;UAMlB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN,qBAAqB;;WAErB;aACE;aACA;aACA;aACA;;;WAGF;aACE;aACA;aACA;;;;;;;WAOF;aACE;aACA;aACA;aACA;eAAoB;eAAsB;;;;;;;WAM5C;aACE;aACA;eACE;eACA;;;;WAIJ;aAA6B;aAA6B;;;;;;;WAM1D;aACE;aACA;aACA;aACA;eAAoB;eAAyB;;;;;cAK7C,aAAa,EAAE,QAAQ;;KAgExB;WAEG;WACA;;WAGA;WACA;aAIM;aACA;;;WAIN;;WAEA;aAKM;aAAsB;;;WAE5B;WAA0B,QAAQ,SAAS;;WAE3C;;;;;;WAMA;aAIM;aACA;aACA;;;;cAKR,cAAc,EAAE,QAAQ;;UA0CpB;;WAEN;;WAEA;aAAmB;aAAwC;;;WAE3D;;WAEA;;;cAIE,cAAc,EAAE,QAAQ;;UAWpB;;WAEN;aACE;aACA;eAA6B;eAAyB;QAAiB;;;;cAQvE,cAAc,EAAE,QAAQ;;;;cCpXxB;;cAOA;;EAyBX,YAAY,SAAQ,qBAAiC;;EAOrD,OAAO,QAAQ;;EA0Cf,SAAS;;EAiHT,YAAY;;;iBAcQ,iBACpB;EAAW;EAAsB;EAAsB;IACtD"}
@@ -1,2 +1,2 @@
1
- import { n as ReferenceStore, r as runReferenceHost, t as REFERENCE_FAULTS } from "./reference-host-BJ-A_Qd_.js";
1
+ import { n as ReferenceStore, r as runReferenceHost, t as REFERENCE_FAULTS } from "./reference-host-DYKrtRCH.js";
2
2
  export { REFERENCE_FAULTS, ReferenceStore, runReferenceHost };
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export { t as REFERENCE_FAULTS, n as ReferenceStore, r as runReferenceHost } from "./reference-host-D7fe25go.js";
2
+ export { t as REFERENCE_FAULTS, n as ReferenceStore, r as runReferenceHost } from "./reference-host-BAAxMabg.js";