@yolk-sdk/emulators 0.1.0-canary.111 → 0.1.0-canary.113

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/README.md CHANGED
@@ -440,14 +440,14 @@ gateway.evaluate.faults.add({
440
440
 
441
441
  `makeOpenCodeGoEmulator(options?)` (`@yolk-sdk/emulators/opencode`) answers the origin
442
442
  `https://opencode.ai` with one fetch handler for the routes the OpenCode Go provider and usage
443
- fetcher call under `/zen/go/v1`. Each route is fixture-only and answers its Go conformance fixture:
443
+ fetcher call under `/inference/go/v1`. Each route is fixture-only and answers its Go conformance fixture:
444
444
 
445
- | Route | Headers the provider sends | Recorded answer |
446
- | ---------------------------------- | -------------------------------------------- | ------------------------------------------------------------------- |
447
- | `POST /zen/go/v1/chat/completions` | `Authorization: Bearer` | Streamed plain text with a usage chunk and `data: [DONE]` |
448
- | `POST /zen/go/v1/messages` | `x-api-key`, `anthropic-version: 2023-06-01` | Streamed plain text ending with `message_stop` |
449
- | `POST /zen/go/v1/responses` | `Authorization: Bearer` | Streamed plain text, or (replayed tool turn) a streamed text answer |
450
- | `GET /zen/go/v1/usage` | `Authorization: Bearer` | `usage.rolling` / `weekly` / `monthly` as `{ percent, resetsAt }` |
445
+ | Route | Headers the provider sends | Recorded answer |
446
+ | ---------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------- |
447
+ | `POST /inference/go/v1/chat/completions` | `Authorization: Bearer` | Streamed plain text with a usage chunk and `data: [DONE]` |
448
+ | `POST /inference/go/v1/messages` | `x-api-key`, `anthropic-version: 2023-06-01` | Streamed plain text ending with `message_stop` |
449
+ | `POST /inference/go/v1/responses` | `Authorization: Bearer` | Streamed plain text, or (replayed tool turn) a streamed text answer |
450
+ | `GET /inference/go/v1/usage` | `Authorization: Bearer` | `usage.rolling` / `weekly` / `monthly` as `{ percent, resetsAt }` |
451
451
 
452
452
  Only the recorded models are emulated (`openCodeGoEmulatorDefaultModels`: `synthetic-go-chat`,
453
453
  `synthetic-go-messages`, `synthetic-go-responses`, one per protocol). It returns
@@ -492,7 +492,7 @@ are not checked except Grok's fixed `X-XAI-Token-Auth: xai-grok-cli`.
492
492
  | `/anthropic` | `GET /api/oauth/usage` | Bearer, `anthropic-beta` listing `oauth-2025-04-20` | `five_hour`, `seven_day` as `{ utilization, resets_at }` |
493
493
  | `/codex` | `GET /backend-api/wham/usage` | Bearer, `ChatGPT-Account-Id` | `rate_limit.primary_window` / `secondary_window` |
494
494
  | `/xai` | `GET /v1/billing?format=credits` | Bearer, `X-XAI-Token-Auth`, `x-userid`, `x-grok-client-version`, `x-grok-client-mode` | `config.creditUsagePercent` and `config.currentPeriod` |
495
- | `/opencode` | `GET /zen/go/v1/usage` | Bearer | `usage.rolling` / `weekly` / `monthly` |
495
+ | `/opencode` | `GET /inference/go/v1/usage` | Bearer | `usage.rolling` / `weekly` / `monthly` |
496
496
 
497
497
  The ledger records `anthropic-beta` (Claude) and `x-grok-client-version` / `x-grok-client-mode`
498
498
  (Grok), never `ChatGPT-Account-Id` or `x-userid`. The manifests
@@ -5,7 +5,7 @@ const openCodeGoRecordings = [
5
5
  caseId: "opencode.go.chat.stream.plain-text",
6
6
  request: {
7
7
  method: "POST",
8
- path: "/zen/go/v1/chat/completions",
8
+ path: "/inference/go/v1/chat/completions",
9
9
  query: "",
10
10
  headers: {
11
11
  accept: "text/event-stream",
@@ -46,7 +46,7 @@ const openCodeGoRecordings = [
46
46
  caseId: "opencode.go.messages.stream.plain-text",
47
47
  request: {
48
48
  method: "POST",
49
- path: "/zen/go/v1/messages",
49
+ path: "/inference/go/v1/messages",
50
50
  query: "",
51
51
  headers: {
52
52
  accept: "text/event-stream",
@@ -94,7 +94,7 @@ const openCodeGoRecordings = [
94
94
  caseId: "opencode.go.responses.stream.plain-text",
95
95
  request: {
96
96
  method: "POST",
97
- path: "/zen/go/v1/responses",
97
+ path: "/inference/go/v1/responses",
98
98
  query: "",
99
99
  headers: {
100
100
  accept: "text/event-stream",
@@ -137,7 +137,7 @@ const openCodeGoRecordings = [
137
137
  caseId: "opencode.go.responses.stream.commentary-replay",
138
138
  request: {
139
139
  method: "POST",
140
- path: "/zen/go/v1/responses",
140
+ path: "/inference/go/v1/responses",
141
141
  query: "",
142
142
  headers: {
143
143
  accept: "text/event-stream",
@@ -209,7 +209,7 @@ const openCodeGoRecordings = [
209
209
  caseId: "opencode.go.usage.snapshot",
210
210
  request: {
211
211
  method: "GET",
212
- path: "/zen/go/v1/usage",
212
+ path: "/inference/go/v1/usage",
213
213
  query: "",
214
214
  headers: { accept: "application/json" }
215
215
  },
@@ -1 +1 @@
1
- {"version":3,"file":"opencode-recordings.mjs","names":[],"sources":["../src/opencode-recordings.ts"],"sourcesContent":["/**\n * OpenCode Go recordings the `/opencode` emulator answers from: one per Go conformance fixture.\n *\n * Copied as data from the committed (synthetic, unverified) conformance fixtures; never imported.\n * `test/fixture-recordings.test.ts` fails when a fixture changes and this copy does not. Internal;\n * not a package export.\n */\nimport type { FixtureRecording } from './fixture-route.ts'\n\nexport const openCodeGoRecordings: ReadonlyArray<FixtureRecording> = [\n {\n fixtureId: 'opencode.go.chat.stream.plain-text.synthetic',\n caseId: 'opencode.go.chat.stream.plain-text',\n request: {\n method: 'POST',\n path: '/zen/go/v1/chat/completions',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-chat',\n messages: [\n {\n role: 'system',\n content: 'Reply in one short sentence.'\n },\n {\n role: 'user',\n content: 'Say hello.'\n }\n ],\n max_tokens: 64,\n stream: true,\n stream_options: {\n include_usage: true\n }\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,',\n '\"delta\":{\"content\":\" from the\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" synthetic model.\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[],\"usage\":{\"prompt_tokens\":53,\"completion_tokens\":12,\"total_tokens\":65}}\\n\\n',\n 'data: [DONE]\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.messages.stream.plain-text.synthetic',\n caseId: 'opencode.go.messages.stream.plain-text',\n request: {\n method: 'POST',\n path: '/zen/go/v1/messages',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-messages',\n system: [\n {\n type: 'text',\n text: 'Reply in one short sentence.',\n cache_control: {\n type: 'ephemeral'\n }\n }\n ],\n messages: [\n {\n role: 'user',\n content: [\n {\n type: 'text',\n text: 'Say hello.',\n cache_control: {\n type: 'ephemeral'\n }\n }\n ]\n }\n ],\n max_tokens: 64,\n stream: true\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'event: message_start\\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"msg_synthetic_1\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"synthetic-go-messages\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":45,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":1}}}\\n\\n',\n 'event: content_block_start\\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\\n\\n',\n 'event: ping\\ndata: {\"type\":\"ping\"}\\n\\n',\n 'event: content_block_delta\\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"Hello\"}}\\n\\n',\n 'event: content_block_delta\\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",',\n '\"text\":\" from the\"}}\\n\\n',\n 'event: content_block_delta\\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" synthetic Anthropic emulator.\"}}\\n\\n',\n 'event: content_block_stop\\ndata: {\"type\":\"content_block_stop\",\"index\":0}\\n\\n',\n 'event: message_delta\\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":45,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":11}}\\n\\n',\n 'event: message_stop\\ndata: {\"type\":\"message_stop\"}\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.responses.stream.plain-text.synthetic',\n caseId: 'opencode.go.responses.stream.plain-text',\n request: {\n method: 'POST',\n path: '/zen/go/v1/responses',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-responses',\n instructions: 'Reply in one short sentence.',\n input: [\n {\n role: 'user',\n content: 'Say hello.'\n }\n ],\n store: false,\n stream: true,\n max_output_tokens: 64\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'event: response.created\\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.in_progress\\ndata: {\"type\":\"response.in_progress\",\"sequence_number\":1,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.output_item.added\\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":2,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}\\n\\n',\n 'event: response.content_part.added\\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":3,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":4,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\"Hello\"}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":5,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,',\n '\"delta\":\" from the\"}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":6,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\" synthetic model.\"}\\n\\n',\n 'event: response.output_text.done\\ndata: {\"type\":\"response.output_text.done\",\"sequence_number\":7,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"text\":\"Hello from the synthetic model.\"}\\n\\n',\n 'event: response.content_part.done\\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":8,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_item.done\\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":9,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}]}}\\n\\n',\n 'event: response.completed\\ndata: {\"type\":\"response.completed\",\"sequence_number\":10,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"completed\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}]}],\"usage\":{\"input_tokens\":45,\"input_tokens_details\":{\"cached_tokens\":0},\"output_tokens\":12,\"output_tokens_details\":{\"reasoning_tokens\":0},\"total_tokens\":57}}}\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.responses.stream.commentary-replay.synthetic',\n caseId: 'opencode.go.responses.stream.commentary-replay',\n request: {\n method: 'POST',\n path: '/zen/go/v1/responses',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-responses',\n instructions: 'Reply in one short sentence.',\n input: [\n {\n role: 'user',\n content: 'What is the weather in Springfield?'\n },\n {\n role: 'assistant',\n content: 'I will look up the weather first.',\n phase: 'commentary'\n },\n {\n type: 'function_call',\n call_id: 'call_synthetic_weather',\n name: 'lookup_weather',\n arguments: '{\"city\":\"Springfield\"}'\n },\n {\n type: 'function_call_output',\n call_id: 'call_synthetic_weather',\n output: 'Sunny and mild.'\n }\n ],\n store: false,\n stream: true,\n max_output_tokens: 64,\n tools: [\n {\n type: 'function',\n name: 'lookup_weather',\n description: 'Look up the current weather for a city.',\n parameters: {\n type: 'object',\n properties: {\n city: {\n type: 'string'\n }\n },\n required: ['city'],\n additionalProperties: false\n }\n }\n ],\n parallel_tool_calls: true\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'event: response.created\\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.in_progress\\ndata: {\"type\":\"response.in_progress\",\"sequence_number\":1,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.output_item.added\\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":2,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}\\n\\n',\n 'event: response.content_part.added\\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":3,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":4,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\"It is sunny\"}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":5,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,',\n '\"delta\":\" and mild in Springfield.\"}\\n\\n',\n 'event: response.output_text.done\\ndata: {\"type\":\"response.output_text.done\",\"sequence_number\":6,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"text\":\"It is sunny and mild in Springfield.\"}\\n\\n',\n 'event: response.content_part.done\\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":7,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_item.done\\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":8,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}]}}\\n\\n',\n 'event: response.completed\\ndata: {\"type\":\"response.completed\",\"sequence_number\":9,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"completed\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}]}],\"usage\":{\"input_tokens\":193,\"input_tokens_details\":{\"cached_tokens\":0},\"output_tokens\":9,\"output_tokens_details\":{\"reasoning_tokens\":0},\"total_tokens\":202}}}\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.usage.snapshot.synthetic',\n caseId: 'opencode.go.usage.snapshot',\n request: {\n method: 'GET',\n path: '/zen/go/v1/usage',\n query: '',\n headers: {\n accept: 'application/json'\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'application/json'\n },\n streamed: false,\n chunks: [\n '{\"usage\":{\"rolling\":{\"percent\":12.5,\"resetsAt\":\"2026-10-01T03:00:00.000Z\"},\"weekly\":{\"percent\":40,\"resetsAt\":\"2026-10-05T00:00:00.000Z\"},\"monthly\":{\"percent\":55,\"resetsAt\":\"2026-10-31T00:00:00.000Z\"}}}'\n ]\n }\n }\n]\n"],"mappings":";AASA,MAAa,uBAAwD;CACnE;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,UAAU,CACR;KACE,MAAM;KACN,SAAS;IACX,GACA;KACE,MAAM;KACN,SAAS;IACX,CACF;IACA,YAAY;IACZ,QAAQ;IACR,gBAAgB,EACd,eAAe,KACjB;GACF;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,QAAQ,CACN;KACE,MAAM;KACN,MAAM;KACN,eAAe,EACb,MAAM,YACR;IACF,CACF;IACA,UAAU,CACR;KACE,MAAM;KACN,SAAS,CACP;MACE,MAAM;MACN,MAAM;MACN,eAAe,EACb,MAAM,YACR;KACF,CACF;IACF,CACF;IACA,YAAY;IACZ,QAAQ;GACV;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,cAAc;IACd,OAAO,CACL;KACE,MAAM;KACN,SAAS;IACX,CACF;IACA,OAAO;IACP,QAAQ;IACR,mBAAmB;GACrB;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,cAAc;IACd,OAAO;KACL;MACE,MAAM;MACN,SAAS;KACX;KACA;MACE,MAAM;MACN,SAAS;MACT,OAAO;KACT;KACA;MACE,MAAM;MACN,SAAS;MACT,MAAM;MACN,WAAW;KACb;KACA;MACE,MAAM;MACN,SAAS;MACT,QAAQ;KACV;IACF;IACA,OAAO;IACP,QAAQ;IACR,mBAAmB;IACnB,OAAO,CACL;KACE,MAAM;KACN,MAAM;KACN,aAAa;KACb,YAAY;MACV,MAAM;MACN,YAAY,EACV,MAAM,EACJ,MAAM,SACR,EACF;MACA,UAAU,CAAC,MAAM;MACjB,sBAAsB;KACxB;IACF,CACF;IACA,qBAAqB;GACvB;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS,EACP,QAAQ,mBACV;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,UAAU;GACV,QAAQ,CACN,qOACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"opencode-recordings.mjs","names":[],"sources":["../src/opencode-recordings.ts"],"sourcesContent":["/**\n * OpenCode Go recordings the `/opencode` emulator answers from: one per Go conformance fixture.\n *\n * Copied as data from the committed (synthetic, unverified) conformance fixtures; never imported.\n * `test/fixture-recordings.test.ts` fails when a fixture changes and this copy does not. Internal;\n * not a package export.\n */\nimport type { FixtureRecording } from './fixture-route.ts'\n\nexport const openCodeGoRecordings: ReadonlyArray<FixtureRecording> = [\n {\n fixtureId: 'opencode.go.chat.stream.plain-text.synthetic',\n caseId: 'opencode.go.chat.stream.plain-text',\n request: {\n method: 'POST',\n path: '/inference/go/v1/chat/completions',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-chat',\n messages: [\n {\n role: 'system',\n content: 'Reply in one short sentence.'\n },\n {\n role: 'user',\n content: 'Say hello.'\n }\n ],\n max_tokens: 64,\n stream: true,\n stream_options: {\n include_usage: true\n }\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,',\n '\"delta\":{\"content\":\" from the\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" synthetic model.\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[],\"usage\":{\"prompt_tokens\":53,\"completion_tokens\":12,\"total_tokens\":65}}\\n\\n',\n 'data: [DONE]\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.messages.stream.plain-text.synthetic',\n caseId: 'opencode.go.messages.stream.plain-text',\n request: {\n method: 'POST',\n path: '/inference/go/v1/messages',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-messages',\n system: [\n {\n type: 'text',\n text: 'Reply in one short sentence.',\n cache_control: {\n type: 'ephemeral'\n }\n }\n ],\n messages: [\n {\n role: 'user',\n content: [\n {\n type: 'text',\n text: 'Say hello.',\n cache_control: {\n type: 'ephemeral'\n }\n }\n ]\n }\n ],\n max_tokens: 64,\n stream: true\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'event: message_start\\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"msg_synthetic_1\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"synthetic-go-messages\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":45,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":1}}}\\n\\n',\n 'event: content_block_start\\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\\n\\n',\n 'event: ping\\ndata: {\"type\":\"ping\"}\\n\\n',\n 'event: content_block_delta\\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"Hello\"}}\\n\\n',\n 'event: content_block_delta\\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",',\n '\"text\":\" from the\"}}\\n\\n',\n 'event: content_block_delta\\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" synthetic Anthropic emulator.\"}}\\n\\n',\n 'event: content_block_stop\\ndata: {\"type\":\"content_block_stop\",\"index\":0}\\n\\n',\n 'event: message_delta\\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":45,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":11}}\\n\\n',\n 'event: message_stop\\ndata: {\"type\":\"message_stop\"}\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.responses.stream.plain-text.synthetic',\n caseId: 'opencode.go.responses.stream.plain-text',\n request: {\n method: 'POST',\n path: '/inference/go/v1/responses',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-responses',\n instructions: 'Reply in one short sentence.',\n input: [\n {\n role: 'user',\n content: 'Say hello.'\n }\n ],\n store: false,\n stream: true,\n max_output_tokens: 64\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'event: response.created\\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.in_progress\\ndata: {\"type\":\"response.in_progress\",\"sequence_number\":1,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.output_item.added\\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":2,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}\\n\\n',\n 'event: response.content_part.added\\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":3,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":4,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\"Hello\"}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":5,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,',\n '\"delta\":\" from the\"}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":6,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\" synthetic model.\"}\\n\\n',\n 'event: response.output_text.done\\ndata: {\"type\":\"response.output_text.done\",\"sequence_number\":7,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"text\":\"Hello from the synthetic model.\"}\\n\\n',\n 'event: response.content_part.done\\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":8,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_item.done\\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":9,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}]}}\\n\\n',\n 'event: response.completed\\ndata: {\"type\":\"response.completed\",\"sequence_number\":10,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"completed\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}]}],\"usage\":{\"input_tokens\":45,\"input_tokens_details\":{\"cached_tokens\":0},\"output_tokens\":12,\"output_tokens_details\":{\"reasoning_tokens\":0},\"total_tokens\":57}}}\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.responses.stream.commentary-replay.synthetic',\n caseId: 'opencode.go.responses.stream.commentary-replay',\n request: {\n method: 'POST',\n path: '/inference/go/v1/responses',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-responses',\n instructions: 'Reply in one short sentence.',\n input: [\n {\n role: 'user',\n content: 'What is the weather in Springfield?'\n },\n {\n role: 'assistant',\n content: 'I will look up the weather first.',\n phase: 'commentary'\n },\n {\n type: 'function_call',\n call_id: 'call_synthetic_weather',\n name: 'lookup_weather',\n arguments: '{\"city\":\"Springfield\"}'\n },\n {\n type: 'function_call_output',\n call_id: 'call_synthetic_weather',\n output: 'Sunny and mild.'\n }\n ],\n store: false,\n stream: true,\n max_output_tokens: 64,\n tools: [\n {\n type: 'function',\n name: 'lookup_weather',\n description: 'Look up the current weather for a city.',\n parameters: {\n type: 'object',\n properties: {\n city: {\n type: 'string'\n }\n },\n required: ['city'],\n additionalProperties: false\n }\n }\n ],\n parallel_tool_calls: true\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'event: response.created\\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.in_progress\\ndata: {\"type\":\"response.in_progress\",\"sequence_number\":1,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.output_item.added\\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":2,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}\\n\\n',\n 'event: response.content_part.added\\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":3,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":4,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\"It is sunny\"}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":5,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,',\n '\"delta\":\" and mild in Springfield.\"}\\n\\n',\n 'event: response.output_text.done\\ndata: {\"type\":\"response.output_text.done\",\"sequence_number\":6,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"text\":\"It is sunny and mild in Springfield.\"}\\n\\n',\n 'event: response.content_part.done\\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":7,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_item.done\\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":8,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}]}}\\n\\n',\n 'event: response.completed\\ndata: {\"type\":\"response.completed\",\"sequence_number\":9,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"completed\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}]}],\"usage\":{\"input_tokens\":193,\"input_tokens_details\":{\"cached_tokens\":0},\"output_tokens\":9,\"output_tokens_details\":{\"reasoning_tokens\":0},\"total_tokens\":202}}}\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.usage.snapshot.synthetic',\n caseId: 'opencode.go.usage.snapshot',\n request: {\n method: 'GET',\n path: '/inference/go/v1/usage',\n query: '',\n headers: {\n accept: 'application/json'\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'application/json'\n },\n streamed: false,\n chunks: [\n '{\"usage\":{\"rolling\":{\"percent\":12.5,\"resetsAt\":\"2026-10-01T03:00:00.000Z\"},\"weekly\":{\"percent\":40,\"resetsAt\":\"2026-10-05T00:00:00.000Z\"},\"monthly\":{\"percent\":55,\"resetsAt\":\"2026-10-31T00:00:00.000Z\"}}}'\n ]\n }\n }\n]\n"],"mappings":";AASA,MAAa,uBAAwD;CACnE;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,UAAU,CACR;KACE,MAAM;KACN,SAAS;IACX,GACA;KACE,MAAM;KACN,SAAS;IACX,CACF;IACA,YAAY;IACZ,QAAQ;IACR,gBAAgB,EACd,eAAe,KACjB;GACF;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,QAAQ,CACN;KACE,MAAM;KACN,MAAM;KACN,eAAe,EACb,MAAM,YACR;IACF,CACF;IACA,UAAU,CACR;KACE,MAAM;KACN,SAAS,CACP;MACE,MAAM;MACN,MAAM;MACN,eAAe,EACb,MAAM,YACR;KACF,CACF;IACF,CACF;IACA,YAAY;IACZ,QAAQ;GACV;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,cAAc;IACd,OAAO,CACL;KACE,MAAM;KACN,SAAS;IACX,CACF;IACA,OAAO;IACP,QAAQ;IACR,mBAAmB;GACrB;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,cAAc;IACd,OAAO;KACL;MACE,MAAM;MACN,SAAS;KACX;KACA;MACE,MAAM;MACN,SAAS;MACT,OAAO;KACT;KACA;MACE,MAAM;MACN,SAAS;MACT,MAAM;MACN,WAAW;KACb;KACA;MACE,MAAM;MACN,SAAS;MACT,QAAQ;KACV;IACF;IACA,OAAO;IACP,QAAQ;IACR,mBAAmB;IACnB,OAAO,CACL;KACE,MAAM;KACN,MAAM;KACN,aAAa;KACb,YAAY;MACV,MAAM;MACN,YAAY,EACV,MAAM,EACJ,MAAM,SACR,EACF;MACA,UAAU,CAAC,MAAM;MACjB,sBAAsB;KACxB;IACF,CACF;IACA,qBAAqB;GACvB;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS,EACP,QAAQ,mBACV;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,UAAU;GACV,QAAQ,CACN,qOACF;EACF;CACF;AACF"}
@@ -4,11 +4,11 @@ import { FixtureRouteEmulator, FixtureRouteFault, FixtureRouteLedgerEntry, Fixtu
4
4
  import * as Schema from "effect/Schema";
5
5
 
6
6
  //#region src/opencode.d.ts
7
- declare const openCodeGoChatCompletionsPath = "/zen/go/v1/chat/completions";
8
- declare const openCodeGoMessagesPath = "/zen/go/v1/messages";
9
- declare const openCodeGoResponsesPath = "/zen/go/v1/responses";
7
+ declare const openCodeGoChatCompletionsPath = "/inference/go/v1/chat/completions";
8
+ declare const openCodeGoMessagesPath = "/inference/go/v1/messages";
9
+ declare const openCodeGoResponsesPath = "/inference/go/v1/responses";
10
10
  /** The Go subscription-usage path (`openCodeGoSubscriptionUsageUrl` in the SDK). */
11
- declare const openCodeGoUsagePath = "/zen/go/v1/usage";
11
+ declare const openCodeGoUsagePath = "/inference/go/v1/usage";
12
12
  /**
13
13
  * The model ids the Go fixtures record, one per protocol (synthetic placeholders). A protocol
14
14
  * route answers only its recorded model; any other model is not emulated.
@@ -47,10 +47,10 @@ type OpenCodeGoRouteEmulator = FixtureRouteEmulator;
47
47
  type OpenCodeGoEmulator = {
48
48
  /** The fetch handler for every route and the `/_emulate/*` control plane. Never rejects. */readonly fetch: (request: Request) => Promise<Response>; /** Reset every part (ledgers, faults, and scripted turns). */
49
49
  readonly reset: () => void; /** Every route's coverage, in manifest order. */
50
- readonly coverage: () => EmulatorCoverage; /** `POST /zen/go/v1/chat/completions` (control plane `/_emulate/chat/*`). */
51
- readonly chat: OpenCodeGoRouteEmulator; /** `POST /zen/go/v1/messages` (control plane `/_emulate/messages/*`). */
52
- readonly messages: OpenCodeGoRouteEmulator; /** `POST /zen/go/v1/responses` (control plane `/_emulate/responses/*`). */
53
- readonly responses: OpenCodeGoRouteEmulator; /** `GET /zen/go/v1/usage` (control plane `/_emulate/usage/*`). */
50
+ readonly coverage: () => EmulatorCoverage; /** `POST /inference/go/v1/chat/completions` (control plane `/_emulate/chat/*`). */
51
+ readonly chat: OpenCodeGoRouteEmulator; /** `POST /inference/go/v1/messages` (control plane `/_emulate/messages/*`). */
52
+ readonly messages: OpenCodeGoRouteEmulator; /** `POST /inference/go/v1/responses` (control plane `/_emulate/responses/*`). */
53
+ readonly responses: OpenCodeGoRouteEmulator; /** `GET /inference/go/v1/usage` (control plane `/_emulate/usage/*`). */
54
54
  readonly usage: OpenCodeGoRouteEmulator;
55
55
  };
56
56
  /**
package/dist/opencode.mjs CHANGED
@@ -8,13 +8,13 @@ import { Data } from "effect";
8
8
  //#region src/opencode.ts
9
9
  /**
10
10
  * OpenCode Go emulator: one plain fetch handler for the origin `https://opencode.ai`, serving the
11
- * routes the OpenCode Go provider and usage fetcher call under `/zen/go/v1`:
11
+ * routes the OpenCode Go provider and usage fetcher call under `/inference/go/v1`:
12
12
  *
13
- * - `POST /zen/go/v1/chat/completions` (Bearer, `max_tokens`, streamed with usage);
14
- * - `POST /zen/go/v1/messages` (`x-api-key`, `anthropic-version: 2023-06-01`, streamed);
15
- * - `POST /zen/go/v1/responses` (Bearer, `max_output_tokens`, streamed; plain text or a replayed
13
+ * - `POST /inference/go/v1/chat/completions` (Bearer, `max_tokens`, streamed with usage);
14
+ * - `POST /inference/go/v1/messages` (`x-api-key`, `anthropic-version: 2023-06-01`, streamed);
15
+ * - `POST /inference/go/v1/responses` (Bearer, `max_output_tokens`, streamed; plain text or a replayed
16
16
  * tool turn with commentary-tagged text);
17
- * - `GET /zen/go/v1/usage` (Bearer).
17
+ * - `GET /inference/go/v1/usage` (Bearer).
18
18
  *
19
19
  * Fixture-only (the owner rule for new routes; `fixture-route.ts`): a request matching a recorded
20
20
  * request shape, within the documented request-shape latitude, gets that Go conformance fixture's
@@ -34,11 +34,11 @@ import { Data } from "effect";
34
34
  *
35
35
  * @experimental
36
36
  */
37
- const openCodeGoChatCompletionsPath = "/zen/go/v1/chat/completions";
38
- const openCodeGoMessagesPath = "/zen/go/v1/messages";
39
- const openCodeGoResponsesPath = "/zen/go/v1/responses";
37
+ const openCodeGoChatCompletionsPath = "/inference/go/v1/chat/completions";
38
+ const openCodeGoMessagesPath = "/inference/go/v1/messages";
39
+ const openCodeGoResponsesPath = "/inference/go/v1/responses";
40
40
  /** The Go subscription-usage path (`openCodeGoSubscriptionUsageUrl` in the SDK). */
41
- const openCodeGoUsagePath = "/zen/go/v1/usage";
41
+ const openCodeGoUsagePath = "/inference/go/v1/usage";
42
42
  const recordingsFor = (path) => openCodeGoRecordings.filter((recording) => recording.request.path === path);
43
43
  const usageRecording = (() => {
44
44
  const [recording] = recordingsFor(openCodeGoUsagePath);
@@ -1 +1 @@
1
- {"version":3,"file":"opencode.mjs","names":[],"sources":["../src/opencode.ts"],"sourcesContent":["/**\n * OpenCode Go emulator: one plain fetch handler for the origin `https://opencode.ai`, serving the\n * routes the OpenCode Go provider and usage fetcher call under `/zen/go/v1`:\n *\n * - `POST /zen/go/v1/chat/completions` (Bearer, `max_tokens`, streamed with usage);\n * - `POST /zen/go/v1/messages` (`x-api-key`, `anthropic-version: 2023-06-01`, streamed);\n * - `POST /zen/go/v1/responses` (Bearer, `max_output_tokens`, streamed; plain text or a replayed\n * tool turn with commentary-tagged text);\n * - `GET /zen/go/v1/usage` (Bearer).\n *\n * Fixture-only (the owner rule for new routes; `fixture-route.ts`): a request matching a recorded\n * request shape, within the documented request-shape latitude, gets that Go conformance fixture's\n * recorded response, copied as data (`opencode-recordings.ts`); everything else (unknown routes,\n * missing credentials or headers, other models, non-streamed modes, tools other than the recorded\n * replay, reasoning, extra fields) answers one ledgered 400 not-emulated.\n *\n * Each route keeps its own ledger, faults, scripted turns, and control plane (`emulator.chat`,\n * `emulator.messages`, `emulator.responses`, `emulator.usage`; over HTTP `/_emulate/<part>/*`);\n * `emulator.coverage()` and `GET /_emulate/coverage` combine them, and `emulator.reset()` and\n * `POST /_emulate/reset` reset all four. Requests on no route are ledgered by the chat part.\n *\n * It never imports SDK code. All routes are `unverified` (the fixtures are synthetic).\n *\n * Runtime-portable Web APIs only (`Request`, `Response`, `ReadableStream`, `TextEncoder`, `URL`);\n * no Effect runtime is required to use it.\n *\n * @experimental\n */\nimport { Data } from 'effect'\nimport type * as Schema from 'effect/Schema'\nimport { combinedCoverage, composeFetch, type ComposedPart } from './emulator-compose.ts'\nimport { jsonResponse, stringField, type EmulatorCoverage } from './emulator-kernel.ts'\nimport {\n makeFixtureRouteEmulator,\n type FixtureRecording,\n type FixtureRouteEmulator\n} from './fixture-route.ts'\nimport { openCodeGoRecordings } from './opencode-recordings.ts'\nimport type { EmulatorRouteEvidence } from './route-evidence.ts'\nimport { makeSubscriptionUsageEmulator, recordedUsageBody } from './subscription-usage.ts'\n\nexport type { EmulatorEvidence, EmulatorRouteEvidence } from './route-evidence.ts'\n\nexport { emulatorEvidenceHeader } from './route-evidence.ts'\n\nexport type {\n FixtureRouteFault as OpenCodeGoFault,\n FixtureRouteLedgerEntry as OpenCodeGoLedgerEntry,\n FixtureRouteScriptedTurn as OpenCodeGoScriptedTurn\n} from './fixture-route.ts'\n\nexport const openCodeGoChatCompletionsPath = '/zen/go/v1/chat/completions'\n\nexport const openCodeGoMessagesPath = '/zen/go/v1/messages'\n\nexport const openCodeGoResponsesPath = '/zen/go/v1/responses'\n\n/** The Go subscription-usage path (`openCodeGoSubscriptionUsageUrl` in the SDK). */\nexport const openCodeGoUsagePath = '/zen/go/v1/usage'\n\nconst recordingsFor = (path: string): ReadonlyArray<FixtureRecording> =>\n openCodeGoRecordings.filter(recording => recording.request.path === path)\n\nconst usageRecording: FixtureRecording = (() => {\n const [recording] = recordingsFor(openCodeGoUsagePath)\n\n // Packaging-data invariant: the Go usage fixture is copied into this package.\n if (recording === undefined) throw new Error('the Go usage recording is missing')\n\n return recording\n})()\n\n/**\n * The model ids the Go fixtures record, one per protocol (synthetic placeholders). A protocol\n * route answers only its recorded model; any other model is not emulated.\n */\nexport const openCodeGoEmulatorDefaultModels: ReadonlyArray<string> = [\n ...new Set(\n openCodeGoRecordings.flatMap(recording => {\n const model = stringField(recording.request.body, 'model')\n\n return model === undefined ? [] : [model]\n })\n )\n]\n\n/**\n * Route evidence manifest: every emulated OpenCode Go route and the conformance cases whose\n * (synthetic, unverified) fixtures it answers from.\n */\nexport const openCodeGoEmulatorRoutes: ReadonlyArray<EmulatorRouteEvidence> = [\n {\n method: 'POST',\n path: openCodeGoChatCompletionsPath,\n kind: 'provider',\n write: false,\n caseIds: ['opencode.go.chat.stream.plain-text'],\n evidence: 'unverified',\n observedAt: undefined\n },\n {\n method: 'POST',\n path: openCodeGoMessagesPath,\n kind: 'provider',\n write: false,\n caseIds: ['opencode.go.messages.stream.plain-text'],\n evidence: 'unverified',\n observedAt: undefined\n },\n {\n method: 'POST',\n path: openCodeGoResponsesPath,\n kind: 'provider',\n write: false,\n caseIds: [\n 'opencode.go.responses.stream.plain-text',\n 'opencode.go.responses.stream.commentary-replay'\n ],\n evidence: 'unverified',\n observedAt: undefined\n },\n {\n method: 'GET',\n path: openCodeGoUsagePath,\n kind: 'provider',\n write: false,\n caseIds: ['opencode.go.usage.snapshot'],\n evidence: 'unverified',\n observedAt: undefined\n }\n]\n\n/**\n * The recorded Go usage body (the synthetic `opencode.go.usage.snapshot` fixture, copied as\n * data): `usage.rolling`, `usage.weekly`, and `usage.monthly` as `{ percent, resetsAt }`.\n */\nexport const openCodeGoUsageDefault: Schema.Json = recordedUsageBody(usageRecording)\n\n/** Thrown by the JS API (`faults.add`, `script.enqueue`) and at construction for invalid input. */\nexport class OpenCodeGoEmulatorInputInvalid extends Data.TaggedError(\n 'OpenCodeGoEmulatorInputInvalid'\n)<{\n readonly protocol: 'chat-completions' | 'messages' | 'responses' | 'usage'\n readonly input: 'fault' | 'turn'\n readonly reason: string\n}> {\n override get message(): string {\n return `Invalid OpenCode Go ${this.protocol} emulator ${this.input}: ${this.reason}`\n }\n}\n\nexport type OpenCodeGoEmulatorOptions = {\n /**\n * Replacement usage-route body; must have the recorded JSON shape (same keys and value kinds).\n * Defaults to the recorded body (`openCodeGoUsageDefault`).\n */\n readonly subscriptionUsage?: Schema.Json\n}\n\n/** One Go route: a fixture-only emulator API (ledger, faults, scripted turns, coverage). */\nexport type OpenCodeGoRouteEmulator = FixtureRouteEmulator\n\nexport type OpenCodeGoEmulator = {\n /** The fetch handler for every route and the `/_emulate/*` control plane. Never rejects. */\n readonly fetch: (request: Request) => Promise<Response>\n /** Reset every part (ledgers, faults, and scripted turns). */\n readonly reset: () => void\n /** Every route's coverage, in manifest order. */\n readonly coverage: () => EmulatorCoverage\n /** `POST /zen/go/v1/chat/completions` (control plane `/_emulate/chat/*`). */\n readonly chat: OpenCodeGoRouteEmulator\n /** `POST /zen/go/v1/messages` (control plane `/_emulate/messages/*`). */\n readonly messages: OpenCodeGoRouteEmulator\n /** `POST /zen/go/v1/responses` (control plane `/_emulate/responses/*`). */\n readonly responses: OpenCodeGoRouteEmulator\n /** `GET /zen/go/v1/usage` (control plane `/_emulate/usage/*`). */\n readonly usage: OpenCodeGoRouteEmulator\n}\n\nconst routesFor = (path: string): ReadonlyArray<EmulatorRouteEvidence> =>\n openCodeGoEmulatorRoutes.filter(route => route.path === path)\n\n/**\n * Create an OpenCode Go emulator. Each call has independent state for every part. Throws\n * `OpenCodeGoEmulatorInputInvalid` when `subscriptionUsage` does not have the recorded shape.\n *\n * Per route, a request carrying the credential and headers the Go provider or usage fetcher sends\n * (Bearer for chat, Responses, and usage; `x-api-key` and `anthropic-version: 2023-06-01` for\n * Messages), the recorded `accept` and `content-type`, and a body matching a recorded request\n * shape gets the recorded response; anything else answers 400 not-emulated. Test controls per\n * part: the shared kernel faults and scripted error turns (and, on usage, a scripted same-shaped\n * `{ usage }` body).\n */\nexport const makeOpenCodeGoEmulator = (\n options: OpenCodeGoEmulatorOptions = {}\n): OpenCodeGoEmulator => {\n const inputInvalid =\n (protocol: OpenCodeGoEmulatorInputInvalid['protocol']) =>\n (input: 'fault' | 'turn', reason: string) =>\n new OpenCodeGoEmulatorInputInvalid({ protocol, input, reason })\n\n const chat = makeFixtureRouteEmulator({\n method: 'POST',\n path: openCodeGoChatCompletionsPath,\n routes: routesFor(openCodeGoChatCompletionsPath),\n recordings: recordingsFor(openCodeGoChatCompletionsPath),\n credential: 'bearer',\n headers: [],\n inputInvalid: inputInvalid('chat-completions')\n })\n\n const messages = makeFixtureRouteEmulator({\n method: 'POST',\n path: openCodeGoMessagesPath,\n routes: routesFor(openCodeGoMessagesPath),\n recordings: recordingsFor(openCodeGoMessagesPath),\n credential: 'x-api-key',\n headers: [\n { name: 'anthropic-version', record: true, accepts: value => value === '2023-06-01' }\n ],\n inputInvalid: inputInvalid('messages')\n })\n\n const responses = makeFixtureRouteEmulator({\n method: 'POST',\n path: openCodeGoResponsesPath,\n routes: routesFor(openCodeGoResponsesPath),\n recordings: recordingsFor(openCodeGoResponsesPath),\n credential: 'bearer',\n headers: [],\n inputInvalid: inputInvalid('responses')\n })\n\n const usage = makeSubscriptionUsageEmulator({\n path: openCodeGoUsagePath,\n routes: routesFor(openCodeGoUsagePath),\n recording: usageRecording,\n headers: [],\n subscriptionUsage: options.subscriptionUsage,\n inputInvalid: inputInvalid('usage')\n })\n\n const parts: ReadonlyArray<ComposedPart> = [chat, messages, responses, usage]\n const coverage = () => combinedCoverage(parts)\n\n const reset = () => {\n for (const part of parts) part.reset()\n }\n\n const fetch = composeFetch({\n routes: [\n { name: 'chat', paths: [openCodeGoChatCompletionsPath], part: chat },\n { name: 'messages', paths: [openCodeGoMessagesPath], part: messages },\n { name: 'responses', paths: [openCodeGoResponsesPath], part: responses },\n { name: 'usage', paths: [openCodeGoUsagePath], part: usage }\n ],\n fallback: chat,\n control: async (request, path) =>\n path === '/_emulate/coverage' && request.method === 'GET'\n ? jsonResponse(200, coverage())\n : jsonResponse(404, {\n error: {\n message:\n 'unknown control-plane route: use /_emulate/{chat,messages,responses,usage}/*, GET /_emulate/coverage, or POST /_emulate/reset',\n type: 'emulator_error'\n }\n })\n })\n\n return { fetch, reset, coverage, chat, messages, responses, usage }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,gCAAgC;AAE7C,MAAa,yBAAyB;AAEtC,MAAa,0BAA0B;;AAGvC,MAAa,sBAAsB;AAEnC,MAAM,iBAAiB,SACrB,qBAAqB,QAAO,cAAa,UAAU,QAAQ,SAAS,IAAI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C,IAC5B,aAAa,KAAK,EAChB,OAAO;IACL,SACE;IACF,MAAM;GACR,EACF,CAAC;EACT,CAEa;EAAG;EAAO;EAAU;EAAM;EAAU;EAAW;CAAM;AACpE"}
1
+ {"version":3,"file":"opencode.mjs","names":[],"sources":["../src/opencode.ts"],"sourcesContent":["/**\n * OpenCode Go emulator: one plain fetch handler for the origin `https://opencode.ai`, serving the\n * routes the OpenCode Go provider and usage fetcher call under `/inference/go/v1`:\n *\n * - `POST /inference/go/v1/chat/completions` (Bearer, `max_tokens`, streamed with usage);\n * - `POST /inference/go/v1/messages` (`x-api-key`, `anthropic-version: 2023-06-01`, streamed);\n * - `POST /inference/go/v1/responses` (Bearer, `max_output_tokens`, streamed; plain text or a replayed\n * tool turn with commentary-tagged text);\n * - `GET /inference/go/v1/usage` (Bearer).\n *\n * Fixture-only (the owner rule for new routes; `fixture-route.ts`): a request matching a recorded\n * request shape, within the documented request-shape latitude, gets that Go conformance fixture's\n * recorded response, copied as data (`opencode-recordings.ts`); everything else (unknown routes,\n * missing credentials or headers, other models, non-streamed modes, tools other than the recorded\n * replay, reasoning, extra fields) answers one ledgered 400 not-emulated.\n *\n * Each route keeps its own ledger, faults, scripted turns, and control plane (`emulator.chat`,\n * `emulator.messages`, `emulator.responses`, `emulator.usage`; over HTTP `/_emulate/<part>/*`);\n * `emulator.coverage()` and `GET /_emulate/coverage` combine them, and `emulator.reset()` and\n * `POST /_emulate/reset` reset all four. Requests on no route are ledgered by the chat part.\n *\n * It never imports SDK code. All routes are `unverified` (the fixtures are synthetic).\n *\n * Runtime-portable Web APIs only (`Request`, `Response`, `ReadableStream`, `TextEncoder`, `URL`);\n * no Effect runtime is required to use it.\n *\n * @experimental\n */\nimport { Data } from 'effect'\nimport type * as Schema from 'effect/Schema'\nimport { combinedCoverage, composeFetch, type ComposedPart } from './emulator-compose.ts'\nimport { jsonResponse, stringField, type EmulatorCoverage } from './emulator-kernel.ts'\nimport {\n makeFixtureRouteEmulator,\n type FixtureRecording,\n type FixtureRouteEmulator\n} from './fixture-route.ts'\nimport { openCodeGoRecordings } from './opencode-recordings.ts'\nimport type { EmulatorRouteEvidence } from './route-evidence.ts'\nimport { makeSubscriptionUsageEmulator, recordedUsageBody } from './subscription-usage.ts'\n\nexport type { EmulatorEvidence, EmulatorRouteEvidence } from './route-evidence.ts'\n\nexport { emulatorEvidenceHeader } from './route-evidence.ts'\n\nexport type {\n FixtureRouteFault as OpenCodeGoFault,\n FixtureRouteLedgerEntry as OpenCodeGoLedgerEntry,\n FixtureRouteScriptedTurn as OpenCodeGoScriptedTurn\n} from './fixture-route.ts'\n\nexport const openCodeGoChatCompletionsPath = '/inference/go/v1/chat/completions'\n\nexport const openCodeGoMessagesPath = '/inference/go/v1/messages'\n\nexport const openCodeGoResponsesPath = '/inference/go/v1/responses'\n\n/** The Go subscription-usage path (`openCodeGoSubscriptionUsageUrl` in the SDK). */\nexport const openCodeGoUsagePath = '/inference/go/v1/usage'\n\nconst recordingsFor = (path: string): ReadonlyArray<FixtureRecording> =>\n openCodeGoRecordings.filter(recording => recording.request.path === path)\n\nconst usageRecording: FixtureRecording = (() => {\n const [recording] = recordingsFor(openCodeGoUsagePath)\n\n // Packaging-data invariant: the Go usage fixture is copied into this package.\n if (recording === undefined) throw new Error('the Go usage recording is missing')\n\n return recording\n})()\n\n/**\n * The model ids the Go fixtures record, one per protocol (synthetic placeholders). A protocol\n * route answers only its recorded model; any other model is not emulated.\n */\nexport const openCodeGoEmulatorDefaultModels: ReadonlyArray<string> = [\n ...new Set(\n openCodeGoRecordings.flatMap(recording => {\n const model = stringField(recording.request.body, 'model')\n\n return model === undefined ? [] : [model]\n })\n )\n]\n\n/**\n * Route evidence manifest: every emulated OpenCode Go route and the conformance cases whose\n * (synthetic, unverified) fixtures it answers from.\n */\nexport const openCodeGoEmulatorRoutes: ReadonlyArray<EmulatorRouteEvidence> = [\n {\n method: 'POST',\n path: openCodeGoChatCompletionsPath,\n kind: 'provider',\n write: false,\n caseIds: ['opencode.go.chat.stream.plain-text'],\n evidence: 'unverified',\n observedAt: undefined\n },\n {\n method: 'POST',\n path: openCodeGoMessagesPath,\n kind: 'provider',\n write: false,\n caseIds: ['opencode.go.messages.stream.plain-text'],\n evidence: 'unverified',\n observedAt: undefined\n },\n {\n method: 'POST',\n path: openCodeGoResponsesPath,\n kind: 'provider',\n write: false,\n caseIds: [\n 'opencode.go.responses.stream.plain-text',\n 'opencode.go.responses.stream.commentary-replay'\n ],\n evidence: 'unverified',\n observedAt: undefined\n },\n {\n method: 'GET',\n path: openCodeGoUsagePath,\n kind: 'provider',\n write: false,\n caseIds: ['opencode.go.usage.snapshot'],\n evidence: 'unverified',\n observedAt: undefined\n }\n]\n\n/**\n * The recorded Go usage body (the synthetic `opencode.go.usage.snapshot` fixture, copied as\n * data): `usage.rolling`, `usage.weekly`, and `usage.monthly` as `{ percent, resetsAt }`.\n */\nexport const openCodeGoUsageDefault: Schema.Json = recordedUsageBody(usageRecording)\n\n/** Thrown by the JS API (`faults.add`, `script.enqueue`) and at construction for invalid input. */\nexport class OpenCodeGoEmulatorInputInvalid extends Data.TaggedError(\n 'OpenCodeGoEmulatorInputInvalid'\n)<{\n readonly protocol: 'chat-completions' | 'messages' | 'responses' | 'usage'\n readonly input: 'fault' | 'turn'\n readonly reason: string\n}> {\n override get message(): string {\n return `Invalid OpenCode Go ${this.protocol} emulator ${this.input}: ${this.reason}`\n }\n}\n\nexport type OpenCodeGoEmulatorOptions = {\n /**\n * Replacement usage-route body; must have the recorded JSON shape (same keys and value kinds).\n * Defaults to the recorded body (`openCodeGoUsageDefault`).\n */\n readonly subscriptionUsage?: Schema.Json\n}\n\n/** One Go route: a fixture-only emulator API (ledger, faults, scripted turns, coverage). */\nexport type OpenCodeGoRouteEmulator = FixtureRouteEmulator\n\nexport type OpenCodeGoEmulator = {\n /** The fetch handler for every route and the `/_emulate/*` control plane. Never rejects. */\n readonly fetch: (request: Request) => Promise<Response>\n /** Reset every part (ledgers, faults, and scripted turns). */\n readonly reset: () => void\n /** Every route's coverage, in manifest order. */\n readonly coverage: () => EmulatorCoverage\n /** `POST /inference/go/v1/chat/completions` (control plane `/_emulate/chat/*`). */\n readonly chat: OpenCodeGoRouteEmulator\n /** `POST /inference/go/v1/messages` (control plane `/_emulate/messages/*`). */\n readonly messages: OpenCodeGoRouteEmulator\n /** `POST /inference/go/v1/responses` (control plane `/_emulate/responses/*`). */\n readonly responses: OpenCodeGoRouteEmulator\n /** `GET /inference/go/v1/usage` (control plane `/_emulate/usage/*`). */\n readonly usage: OpenCodeGoRouteEmulator\n}\n\nconst routesFor = (path: string): ReadonlyArray<EmulatorRouteEvidence> =>\n openCodeGoEmulatorRoutes.filter(route => route.path === path)\n\n/**\n * Create an OpenCode Go emulator. Each call has independent state for every part. Throws\n * `OpenCodeGoEmulatorInputInvalid` when `subscriptionUsage` does not have the recorded shape.\n *\n * Per route, a request carrying the credential and headers the Go provider or usage fetcher sends\n * (Bearer for chat, Responses, and usage; `x-api-key` and `anthropic-version: 2023-06-01` for\n * Messages), the recorded `accept` and `content-type`, and a body matching a recorded request\n * shape gets the recorded response; anything else answers 400 not-emulated. Test controls per\n * part: the shared kernel faults and scripted error turns (and, on usage, a scripted same-shaped\n * `{ usage }` body).\n */\nexport const makeOpenCodeGoEmulator = (\n options: OpenCodeGoEmulatorOptions = {}\n): OpenCodeGoEmulator => {\n const inputInvalid =\n (protocol: OpenCodeGoEmulatorInputInvalid['protocol']) =>\n (input: 'fault' | 'turn', reason: string) =>\n new OpenCodeGoEmulatorInputInvalid({ protocol, input, reason })\n\n const chat = makeFixtureRouteEmulator({\n method: 'POST',\n path: openCodeGoChatCompletionsPath,\n routes: routesFor(openCodeGoChatCompletionsPath),\n recordings: recordingsFor(openCodeGoChatCompletionsPath),\n credential: 'bearer',\n headers: [],\n inputInvalid: inputInvalid('chat-completions')\n })\n\n const messages = makeFixtureRouteEmulator({\n method: 'POST',\n path: openCodeGoMessagesPath,\n routes: routesFor(openCodeGoMessagesPath),\n recordings: recordingsFor(openCodeGoMessagesPath),\n credential: 'x-api-key',\n headers: [\n { name: 'anthropic-version', record: true, accepts: value => value === '2023-06-01' }\n ],\n inputInvalid: inputInvalid('messages')\n })\n\n const responses = makeFixtureRouteEmulator({\n method: 'POST',\n path: openCodeGoResponsesPath,\n routes: routesFor(openCodeGoResponsesPath),\n recordings: recordingsFor(openCodeGoResponsesPath),\n credential: 'bearer',\n headers: [],\n inputInvalid: inputInvalid('responses')\n })\n\n const usage = makeSubscriptionUsageEmulator({\n path: openCodeGoUsagePath,\n routes: routesFor(openCodeGoUsagePath),\n recording: usageRecording,\n headers: [],\n subscriptionUsage: options.subscriptionUsage,\n inputInvalid: inputInvalid('usage')\n })\n\n const parts: ReadonlyArray<ComposedPart> = [chat, messages, responses, usage]\n const coverage = () => combinedCoverage(parts)\n\n const reset = () => {\n for (const part of parts) part.reset()\n }\n\n const fetch = composeFetch({\n routes: [\n { name: 'chat', paths: [openCodeGoChatCompletionsPath], part: chat },\n { name: 'messages', paths: [openCodeGoMessagesPath], part: messages },\n { name: 'responses', paths: [openCodeGoResponsesPath], part: responses },\n { name: 'usage', paths: [openCodeGoUsagePath], part: usage }\n ],\n fallback: chat,\n control: async (request, path) =>\n path === '/_emulate/coverage' && request.method === 'GET'\n ? jsonResponse(200, coverage())\n : jsonResponse(404, {\n error: {\n message:\n 'unknown control-plane route: use /_emulate/{chat,messages,responses,usage}/*, GET /_emulate/coverage, or POST /_emulate/reset',\n type: 'emulator_error'\n }\n })\n })\n\n return { fetch, reset, coverage, chat, messages, responses, usage }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,gCAAgC;AAE7C,MAAa,yBAAyB;AAEtC,MAAa,0BAA0B;;AAGvC,MAAa,sBAAsB;AAEnC,MAAM,iBAAiB,SACrB,qBAAqB,QAAO,cAAa,UAAU,QAAQ,SAAS,IAAI;AAE1E,MAAM,wBAA0C;CAC9C,MAAM,CAAC,aAAa,cA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AM;GACR,EACF,CAAC;EACT,CAEa;EAAG;EAAO;EAAU;EAAM;EAAU;EAAW;CAAM;AACpE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolk-sdk/emulators",
3
- "version": "0.1.0-canary.111",
3
+ "version": "0.1.0-canary.113",
4
4
  "description": "Experimental emulators for outside services: an Effect HttpClient router, Vercel AI Gateway, OpenAI Chat Completions, Anthropic Messages, OpenAI Responses (Codex, xAI Grok), and OpenCode Go fetch-handler emulators with subscription-usage routes, fixture-driven fake EmailClient and R2 (R2Presigner, R2ObjectClient) backends, stateful Fortnox, Microsoft Graph, Dropbox, Notion, Todoist, Telegram, GitHub, Google (Gmail, Calendar, Drive), LinkedIn search (Exa, Enrich Layer), and synthetic and Afloat MCP emulators, and a loopback Node server.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -143,10 +143,10 @@
143
143
  "effect": "4.0.0"
144
144
  },
145
145
  "devDependencies": {
146
- "@yolk-sdk/agent": "^0.1.0-canary.111",
147
- "@yolk-sdk/conformance": "^0.1.0-canary.111",
148
- "@yolk-sdk/connectors": "^0.1.0-canary.111",
149
- "@yolk-sdk/mcp": "^0.1.0-canary.111"
146
+ "@yolk-sdk/agent": "^0.1.0-canary.113",
147
+ "@yolk-sdk/connectors": "^0.1.0-canary.113",
148
+ "@yolk-sdk/conformance": "^0.1.0-canary.113",
149
+ "@yolk-sdk/mcp": "^0.1.0-canary.113"
150
150
  },
151
151
  "scripts": {
152
152
  "build": "tsdown",
@@ -13,7 +13,7 @@ export const openCodeGoRecordings: ReadonlyArray<FixtureRecording> = [
13
13
  caseId: 'opencode.go.chat.stream.plain-text',
14
14
  request: {
15
15
  method: 'POST',
16
- path: '/zen/go/v1/chat/completions',
16
+ path: '/inference/go/v1/chat/completions',
17
17
  query: '',
18
18
  headers: {
19
19
  accept: 'text/event-stream',
@@ -61,7 +61,7 @@ export const openCodeGoRecordings: ReadonlyArray<FixtureRecording> = [
61
61
  caseId: 'opencode.go.messages.stream.plain-text',
62
62
  request: {
63
63
  method: 'POST',
64
- path: '/zen/go/v1/messages',
64
+ path: '/inference/go/v1/messages',
65
65
  query: '',
66
66
  headers: {
67
67
  accept: 'text/event-stream',
@@ -121,7 +121,7 @@ export const openCodeGoRecordings: ReadonlyArray<FixtureRecording> = [
121
121
  caseId: 'opencode.go.responses.stream.plain-text',
122
122
  request: {
123
123
  method: 'POST',
124
- path: '/zen/go/v1/responses',
124
+ path: '/inference/go/v1/responses',
125
125
  query: '',
126
126
  headers: {
127
127
  accept: 'text/event-stream',
@@ -168,7 +168,7 @@ export const openCodeGoRecordings: ReadonlyArray<FixtureRecording> = [
168
168
  caseId: 'opencode.go.responses.stream.commentary-replay',
169
169
  request: {
170
170
  method: 'POST',
171
- path: '/zen/go/v1/responses',
171
+ path: '/inference/go/v1/responses',
172
172
  query: '',
173
173
  headers: {
174
174
  accept: 'text/event-stream',
@@ -248,7 +248,7 @@ export const openCodeGoRecordings: ReadonlyArray<FixtureRecording> = [
248
248
  caseId: 'opencode.go.usage.snapshot',
249
249
  request: {
250
250
  method: 'GET',
251
- path: '/zen/go/v1/usage',
251
+ path: '/inference/go/v1/usage',
252
252
  query: '',
253
253
  headers: {
254
254
  accept: 'application/json'
package/src/opencode.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * OpenCode Go emulator: one plain fetch handler for the origin `https://opencode.ai`, serving the
3
- * routes the OpenCode Go provider and usage fetcher call under `/zen/go/v1`:
3
+ * routes the OpenCode Go provider and usage fetcher call under `/inference/go/v1`:
4
4
  *
5
- * - `POST /zen/go/v1/chat/completions` (Bearer, `max_tokens`, streamed with usage);
6
- * - `POST /zen/go/v1/messages` (`x-api-key`, `anthropic-version: 2023-06-01`, streamed);
7
- * - `POST /zen/go/v1/responses` (Bearer, `max_output_tokens`, streamed; plain text or a replayed
5
+ * - `POST /inference/go/v1/chat/completions` (Bearer, `max_tokens`, streamed with usage);
6
+ * - `POST /inference/go/v1/messages` (`x-api-key`, `anthropic-version: 2023-06-01`, streamed);
7
+ * - `POST /inference/go/v1/responses` (Bearer, `max_output_tokens`, streamed; plain text or a replayed
8
8
  * tool turn with commentary-tagged text);
9
- * - `GET /zen/go/v1/usage` (Bearer).
9
+ * - `GET /inference/go/v1/usage` (Bearer).
10
10
  *
11
11
  * Fixture-only (the owner rule for new routes; `fixture-route.ts`): a request matching a recorded
12
12
  * request shape, within the documented request-shape latitude, gets that Go conformance fixture's
@@ -49,14 +49,14 @@ export type {
49
49
  FixtureRouteScriptedTurn as OpenCodeGoScriptedTurn
50
50
  } from './fixture-route.ts'
51
51
 
52
- export const openCodeGoChatCompletionsPath = '/zen/go/v1/chat/completions'
52
+ export const openCodeGoChatCompletionsPath = '/inference/go/v1/chat/completions'
53
53
 
54
- export const openCodeGoMessagesPath = '/zen/go/v1/messages'
54
+ export const openCodeGoMessagesPath = '/inference/go/v1/messages'
55
55
 
56
- export const openCodeGoResponsesPath = '/zen/go/v1/responses'
56
+ export const openCodeGoResponsesPath = '/inference/go/v1/responses'
57
57
 
58
58
  /** The Go subscription-usage path (`openCodeGoSubscriptionUsageUrl` in the SDK). */
59
- export const openCodeGoUsagePath = '/zen/go/v1/usage'
59
+ export const openCodeGoUsagePath = '/inference/go/v1/usage'
60
60
 
61
61
  const recordingsFor = (path: string): ReadonlyArray<FixtureRecording> =>
62
62
  openCodeGoRecordings.filter(recording => recording.request.path === path)
@@ -167,13 +167,13 @@ export type OpenCodeGoEmulator = {
167
167
  readonly reset: () => void
168
168
  /** Every route's coverage, in manifest order. */
169
169
  readonly coverage: () => EmulatorCoverage
170
- /** `POST /zen/go/v1/chat/completions` (control plane `/_emulate/chat/*`). */
170
+ /** `POST /inference/go/v1/chat/completions` (control plane `/_emulate/chat/*`). */
171
171
  readonly chat: OpenCodeGoRouteEmulator
172
- /** `POST /zen/go/v1/messages` (control plane `/_emulate/messages/*`). */
172
+ /** `POST /inference/go/v1/messages` (control plane `/_emulate/messages/*`). */
173
173
  readonly messages: OpenCodeGoRouteEmulator
174
- /** `POST /zen/go/v1/responses` (control plane `/_emulate/responses/*`). */
174
+ /** `POST /inference/go/v1/responses` (control plane `/_emulate/responses/*`). */
175
175
  readonly responses: OpenCodeGoRouteEmulator
176
- /** `GET /zen/go/v1/usage` (control plane `/_emulate/usage/*`). */
176
+ /** `GET /inference/go/v1/usage` (control plane `/_emulate/usage/*`). */
177
177
  readonly usage: OpenCodeGoRouteEmulator
178
178
  }
179
179