@yolk-sdk/emulators 0.1.0-canary.96
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/LICENSE +21 -0
- package/README.md +2135 -0
- package/dist/anthropic.d.mts +269 -0
- package/dist/anthropic.d.mts.map +1 -0
- package/dist/anthropic.mjs +177 -0
- package/dist/anthropic.mjs.map +1 -0
- package/dist/chat-completions.d.mts +288 -0
- package/dist/chat-completions.d.mts.map +1 -0
- package/dist/chat-completions.mjs +451 -0
- package/dist/chat-completions.mjs.map +1 -0
- package/dist/codex.d.mts +265 -0
- package/dist/codex.d.mts.map +1 -0
- package/dist/codex.mjs +199 -0
- package/dist/codex.mjs.map +1 -0
- package/dist/dropbox/api.d.mts +63 -0
- package/dist/dropbox/api.d.mts.map +1 -0
- package/dist/dropbox/api.mjs +565 -0
- package/dist/dropbox/api.mjs.map +1 -0
- package/dist/dropbox/state.d.mts +136 -0
- package/dist/dropbox/state.d.mts.map +1 -0
- package/dist/dropbox/state.mjs +209 -0
- package/dist/dropbox/state.mjs.map +1 -0
- package/dist/dropbox.d.mts +79 -0
- package/dist/dropbox.d.mts.map +1 -0
- package/dist/dropbox.mjs +124 -0
- package/dist/dropbox.mjs.map +1 -0
- package/dist/email-fixtures.d.mts +36 -0
- package/dist/email-fixtures.d.mts.map +1 -0
- package/dist/email-fixtures.mjs +1080 -0
- package/dist/email-fixtures.mjs.map +1 -0
- package/dist/email.d.mts +160 -0
- package/dist/email.d.mts.map +1 -0
- package/dist/email.mjs +608 -0
- package/dist/email.mjs.map +1 -0
- package/dist/emulator-compose.d.mts +40 -0
- package/dist/emulator-compose.d.mts.map +1 -0
- package/dist/emulator-compose.mjs +91 -0
- package/dist/emulator-compose.mjs.map +1 -0
- package/dist/emulator-http.d.mts +53 -0
- package/dist/emulator-http.d.mts.map +1 -0
- package/dist/emulator-http.mjs +117 -0
- package/dist/emulator-http.mjs.map +1 -0
- package/dist/emulator-kernel.d.mts +176 -0
- package/dist/emulator-kernel.d.mts.map +1 -0
- package/dist/emulator-kernel.mjs +413 -0
- package/dist/emulator-kernel.mjs.map +1 -0
- package/dist/fixture-route.d.mts +129 -0
- package/dist/fixture-route.d.mts.map +1 -0
- package/dist/fixture-route.mjs +257 -0
- package/dist/fixture-route.mjs.map +1 -0
- package/dist/fortnox/api.d.mts +92 -0
- package/dist/fortnox/api.d.mts.map +1 -0
- package/dist/fortnox/api.mjs +750 -0
- package/dist/fortnox/api.mjs.map +1 -0
- package/dist/fortnox/state.d.mts +533 -0
- package/dist/fortnox/state.d.mts.map +1 -0
- package/dist/fortnox/state.mjs +612 -0
- package/dist/fortnox/state.mjs.map +1 -0
- package/dist/fortnox.d.mts +128 -0
- package/dist/fortnox.d.mts.map +1 -0
- package/dist/fortnox.mjs +403 -0
- package/dist/fortnox.mjs.map +1 -0
- package/dist/gateway-evaluate-recordings.d.mts +12 -0
- package/dist/gateway-evaluate-recordings.d.mts.map +1 -0
- package/dist/gateway-evaluate-recordings.mjs +128 -0
- package/dist/gateway-evaluate-recordings.mjs.map +1 -0
- package/dist/gateway.d.mts +272 -0
- package/dist/gateway.d.mts.map +1 -0
- package/dist/gateway.mjs +400 -0
- package/dist/gateway.mjs.map +1 -0
- package/dist/github/api.d.mts +63 -0
- package/dist/github/api.d.mts.map +1 -0
- package/dist/github/api.mjs +527 -0
- package/dist/github/api.mjs.map +1 -0
- package/dist/github/state.d.mts +272 -0
- package/dist/github/state.d.mts.map +1 -0
- package/dist/github/state.mjs +303 -0
- package/dist/github/state.mjs.map +1 -0
- package/dist/github.d.mts +77 -0
- package/dist/github.d.mts.map +1 -0
- package/dist/github.mjs +180 -0
- package/dist/github.mjs.map +1 -0
- package/dist/google/calendar.d.mts +10 -0
- package/dist/google/calendar.d.mts.map +1 -0
- package/dist/google/calendar.mjs +252 -0
- package/dist/google/calendar.mjs.map +1 -0
- package/dist/google/drive.d.mts +8 -0
- package/dist/google/drive.d.mts.map +1 -0
- package/dist/google/drive.mjs +252 -0
- package/dist/google/drive.mjs.map +1 -0
- package/dist/google/gmail.d.mts +10 -0
- package/dist/google/gmail.d.mts.map +1 -0
- package/dist/google/gmail.mjs +591 -0
- package/dist/google/gmail.mjs.map +1 -0
- package/dist/google/shared.d.mts +107 -0
- package/dist/google/shared.d.mts.map +1 -0
- package/dist/google/shared.mjs +146 -0
- package/dist/google/shared.mjs.map +1 -0
- package/dist/google/state.d.mts +385 -0
- package/dist/google/state.d.mts.map +1 -0
- package/dist/google/state.mjs +496 -0
- package/dist/google/state.mjs.map +1 -0
- package/dist/google.d.mts +75 -0
- package/dist/google.d.mts.map +1 -0
- package/dist/google.mjs +210 -0
- package/dist/google.mjs.map +1 -0
- package/dist/linkedin-search/api.d.mts +45 -0
- package/dist/linkedin-search/api.d.mts.map +1 -0
- package/dist/linkedin-search/api.mjs +181 -0
- package/dist/linkedin-search/api.mjs.map +1 -0
- package/dist/linkedin-search/state.d.mts +123 -0
- package/dist/linkedin-search/state.d.mts.map +1 -0
- package/dist/linkedin-search/state.mjs +261 -0
- package/dist/linkedin-search/state.mjs.map +1 -0
- package/dist/linkedin-search.d.mts +69 -0
- package/dist/linkedin-search.d.mts.map +1 -0
- package/dist/linkedin-search.mjs +158 -0
- package/dist/linkedin-search.mjs.map +1 -0
- package/dist/mcp/api.d.mts +44 -0
- package/dist/mcp/api.d.mts.map +1 -0
- package/dist/mcp/api.mjs +557 -0
- package/dist/mcp/api.mjs.map +1 -0
- package/dist/mcp/recordings.d.mts +40 -0
- package/dist/mcp/recordings.d.mts.map +1 -0
- package/dist/mcp/recordings.mjs +2390 -0
- package/dist/mcp/recordings.mjs.map +1 -0
- package/dist/mcp/state.d.mts +71 -0
- package/dist/mcp/state.d.mts.map +1 -0
- package/dist/mcp/state.mjs +83 -0
- package/dist/mcp/state.mjs.map +1 -0
- package/dist/mcp.d.mts +84 -0
- package/dist/mcp.d.mts.map +1 -0
- package/dist/mcp.mjs +241 -0
- package/dist/mcp.mjs.map +1 -0
- package/dist/messages.d.mts +183 -0
- package/dist/messages.d.mts.map +1 -0
- package/dist/messages.mjs +532 -0
- package/dist/messages.mjs.map +1 -0
- package/dist/microsoft/api.d.mts +47 -0
- package/dist/microsoft/api.d.mts.map +1 -0
- package/dist/microsoft/api.mjs +178 -0
- package/dist/microsoft/api.mjs.map +1 -0
- package/dist/microsoft/calendar.d.mts +30 -0
- package/dist/microsoft/calendar.d.mts.map +1 -0
- package/dist/microsoft/calendar.mjs +271 -0
- package/dist/microsoft/calendar.mjs.map +1 -0
- package/dist/microsoft/drive.d.mts +36 -0
- package/dist/microsoft/drive.d.mts.map +1 -0
- package/dist/microsoft/drive.mjs +298 -0
- package/dist/microsoft/drive.mjs.map +1 -0
- package/dist/microsoft/graph.d.mts +198 -0
- package/dist/microsoft/graph.d.mts.map +1 -0
- package/dist/microsoft/graph.mjs +264 -0
- package/dist/microsoft/graph.mjs.map +1 -0
- package/dist/microsoft/mail.d.mts +48 -0
- package/dist/microsoft/mail.d.mts.map +1 -0
- package/dist/microsoft/mail.mjs +488 -0
- package/dist/microsoft/mail.mjs.map +1 -0
- package/dist/microsoft/state.d.mts +480 -0
- package/dist/microsoft/state.d.mts.map +1 -0
- package/dist/microsoft/state.mjs +625 -0
- package/dist/microsoft/state.mjs.map +1 -0
- package/dist/microsoft.d.mts +168 -0
- package/dist/microsoft.d.mts.map +1 -0
- package/dist/microsoft.mjs +483 -0
- package/dist/microsoft.mjs.map +1 -0
- package/dist/node.d.mts +47 -0
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +178 -0
- package/dist/node.mjs.map +1 -0
- package/dist/notion/api.d.mts +51 -0
- package/dist/notion/api.d.mts.map +1 -0
- package/dist/notion/api.mjs +507 -0
- package/dist/notion/api.mjs.map +1 -0
- package/dist/notion/state.d.mts +329 -0
- package/dist/notion/state.d.mts.map +1 -0
- package/dist/notion/state.mjs +432 -0
- package/dist/notion/state.mjs.map +1 -0
- package/dist/notion.d.mts +72 -0
- package/dist/notion.d.mts.map +1 -0
- package/dist/notion.mjs +127 -0
- package/dist/notion.mjs.map +1 -0
- package/dist/openai.d.mts +165 -0
- package/dist/openai.d.mts.map +1 -0
- package/dist/openai.mjs +141 -0
- package/dist/openai.mjs.map +1 -0
- package/dist/opencode-recordings.d.mts +7 -0
- package/dist/opencode-recordings.d.mts.map +1 -0
- package/dist/opencode-recordings.mjs +222 -0
- package/dist/opencode-recordings.mjs.map +1 -0
- package/dist/opencode.d.mts +70 -0
- package/dist/opencode.d.mts.map +1 -0
- package/dist/opencode.mjs +217 -0
- package/dist/opencode.mjs.map +1 -0
- package/dist/r2-fixtures.d.mts +36 -0
- package/dist/r2-fixtures.d.mts.map +1 -0
- package/dist/r2-fixtures.mjs +245 -0
- package/dist/r2-fixtures.mjs.map +1 -0
- package/dist/r2-guard.d.mts +43 -0
- package/dist/r2-guard.d.mts.map +1 -0
- package/dist/r2-guard.mjs +215 -0
- package/dist/r2-guard.mjs.map +1 -0
- package/dist/r2.d.mts +166 -0
- package/dist/r2.d.mts.map +1 -0
- package/dist/r2.mjs +517 -0
- package/dist/r2.mjs.map +1 -0
- package/dist/responses.d.mts +231 -0
- package/dist/responses.d.mts.map +1 -0
- package/dist/responses.mjs +556 -0
- package/dist/responses.mjs.map +1 -0
- package/dist/route-evidence.d.mts +45 -0
- package/dist/route-evidence.d.mts.map +1 -0
- package/dist/route-evidence.mjs +56 -0
- package/dist/route-evidence.mjs.map +1 -0
- package/dist/router.d.mts +93 -0
- package/dist/router.d.mts.map +1 -0
- package/dist/router.mjs +259 -0
- package/dist/router.mjs.map +1 -0
- package/dist/stateful-core.d.mts +17 -0
- package/dist/stateful-core.d.mts.map +1 -0
- package/dist/stateful-core.mjs +41 -0
- package/dist/stateful-core.mjs.map +1 -0
- package/dist/stateful-emulator.d.mts +565 -0
- package/dist/stateful-emulator.d.mts.map +1 -0
- package/dist/stateful-emulator.mjs +1228 -0
- package/dist/stateful-emulator.mjs.map +1 -0
- package/dist/stateful-secrets.d.mts +84 -0
- package/dist/stateful-secrets.d.mts.map +1 -0
- package/dist/stateful-secrets.mjs +216 -0
- package/dist/stateful-secrets.mjs.map +1 -0
- package/dist/subscription-usage-recordings.d.mts +9 -0
- package/dist/subscription-usage-recordings.d.mts.map +1 -0
- package/dist/subscription-usage-recordings.mjs +53 -0
- package/dist/subscription-usage-recordings.mjs.map +1 -0
- package/dist/subscription-usage.d.mts +53 -0
- package/dist/subscription-usage.d.mts.map +1 -0
- package/dist/subscription-usage.mjs +21 -0
- package/dist/subscription-usage.mjs.map +1 -0
- package/dist/telegram/api.d.mts +34 -0
- package/dist/telegram/api.d.mts.map +1 -0
- package/dist/telegram/api.mjs +257 -0
- package/dist/telegram/api.mjs.map +1 -0
- package/dist/telegram/state.d.mts +128 -0
- package/dist/telegram/state.d.mts.map +1 -0
- package/dist/telegram/state.mjs +154 -0
- package/dist/telegram/state.mjs.map +1 -0
- package/dist/telegram.d.mts +62 -0
- package/dist/telegram.d.mts.map +1 -0
- package/dist/telegram.mjs +127 -0
- package/dist/telegram.mjs.map +1 -0
- package/dist/todoist/api.d.mts +55 -0
- package/dist/todoist/api.d.mts.map +1 -0
- package/dist/todoist/api.mjs +415 -0
- package/dist/todoist/api.mjs.map +1 -0
- package/dist/todoist/state.d.mts +275 -0
- package/dist/todoist/state.d.mts.map +1 -0
- package/dist/todoist/state.mjs +345 -0
- package/dist/todoist/state.mjs.map +1 -0
- package/dist/todoist.d.mts +68 -0
- package/dist/todoist.d.mts.map +1 -0
- package/dist/todoist.mjs +181 -0
- package/dist/todoist.mjs.map +1 -0
- package/dist/xai.d.mts +267 -0
- package/dist/xai.d.mts.map +1 -0
- package/dist/xai.mjs +252 -0
- package/dist/xai.mjs.map +1 -0
- package/package.json +157 -0
- package/src/anthropic.ts +289 -0
- package/src/chat-completions.ts +924 -0
- package/src/codex.ts +296 -0
- package/src/dropbox/api.ts +1084 -0
- package/src/dropbox/state.ts +364 -0
- package/src/dropbox.ts +203 -0
- package/src/email-fixtures.ts +1297 -0
- package/src/email.ts +1108 -0
- package/src/emulator-compose.ts +147 -0
- package/src/emulator-http.ts +184 -0
- package/src/emulator-kernel.ts +844 -0
- package/src/fixture-route.ts +561 -0
- package/src/fortnox/api.ts +1352 -0
- package/src/fortnox/state.ts +798 -0
- package/src/fortnox.ts +801 -0
- package/src/gateway-evaluate-recordings.ts +153 -0
- package/src/gateway.ts +530 -0
- package/src/github/api.ts +986 -0
- package/src/github/state.ts +439 -0
- package/src/github.ts +271 -0
- package/src/google/calendar.ts +486 -0
- package/src/google/drive.ts +471 -0
- package/src/google/gmail.ts +1011 -0
- package/src/google/shared.ts +321 -0
- package/src/google/state.ts +686 -0
- package/src/google.ts +298 -0
- package/src/linkedin-search/api.ts +363 -0
- package/src/linkedin-search/state.ts +373 -0
- package/src/linkedin-search.ts +241 -0
- package/src/mcp/api.ts +995 -0
- package/src/mcp/recordings.ts +2665 -0
- package/src/mcp/state.ts +125 -0
- package/src/mcp.ts +319 -0
- package/src/messages.ts +844 -0
- package/src/microsoft/api.ts +426 -0
- package/src/microsoft/calendar.ts +491 -0
- package/src/microsoft/drive.ts +541 -0
- package/src/microsoft/graph.ts +550 -0
- package/src/microsoft/mail.ts +833 -0
- package/src/microsoft/state.ts +822 -0
- package/src/microsoft.ts +982 -0
- package/src/node.ts +293 -0
- package/src/notion/api.ts +976 -0
- package/src/notion/state.ts +512 -0
- package/src/notion.ts +210 -0
- package/src/openai.ts +198 -0
- package/src/opencode-recordings.ts +257 -0
- package/src/opencode.ts +271 -0
- package/src/r2-fixtures.ts +295 -0
- package/src/r2-guard.ts +323 -0
- package/src/r2.ts +890 -0
- package/src/responses.ts +901 -0
- package/src/route-evidence.ts +90 -0
- package/src/router.ts +490 -0
- package/src/stateful-core.ts +70 -0
- package/src/stateful-emulator.ts +2571 -0
- package/src/stateful-secrets.ts +299 -0
- package/src/subscription-usage-recordings.ts +77 -0
- package/src/subscription-usage.ts +68 -0
- package/src/telegram/api.ts +437 -0
- package/src/telegram/state.ts +229 -0
- package/src/telegram.ts +227 -0
- package/src/todoist/api.ts +736 -0
- package/src/todoist/state.ts +456 -0
- package/src/todoist.ts +316 -0
- package/src/xai.ts +341 -0
package/dist/xai.mjs
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { emulatorEvidenceHeader } from "./route-evidence.mjs";
|
|
2
|
+
import { EmulatorFaultMatch, EmulatorScriptedError } from "./emulator-kernel.mjs";
|
|
3
|
+
import { withSubscriptionUsage } from "./emulator-compose.mjs";
|
|
4
|
+
import { SubscriptionUsageFault, makeSubscriptionUsageEmulator, recordedUsageBody } from "./subscription-usage.mjs";
|
|
5
|
+
import { xAiGrokUsageRecording } from "./subscription-usage-recordings.mjs";
|
|
6
|
+
import { ResponsesErrorEventFault, ResponsesFault, ResponsesScriptedFunctionCall, ResponsesScriptedResponse, ResponsesScriptedTurn, ResponsesScriptedUsage, ResponsesStreamError, makeResponsesEmulator } from "./responses.mjs";
|
|
7
|
+
import { Data } from "effect";
|
|
8
|
+
//#region src/xai.ts
|
|
9
|
+
/**
|
|
10
|
+
* xAI Grok CLI proxy Responses emulator: a plain fetch handler for `POST /v1/responses` (origin
|
|
11
|
+
* `https://cli-chat-proxy.grok.com`), with scripted turns, wire faults, a request ledger, and an
|
|
12
|
+
* `/_emulate/*` control plane.
|
|
13
|
+
*
|
|
14
|
+
* It never imports SDK code: its wire shapes follow the synthetic Grok Responses conformance
|
|
15
|
+
* fixtures (Responses SSE with typed `event:` names, the `response` JSON body, and the
|
|
16
|
+
* `{ error: { message, type, param, code } }` envelope) and are linked to those conformance case
|
|
17
|
+
* ids in `xAiGrokEmulatorRoutes`. The Responses machinery lives in the internal `responses.ts`
|
|
18
|
+
* core and is shared with the Codex emulator.
|
|
19
|
+
*
|
|
20
|
+
* Requests authenticate with a non-empty `Authorization: Bearer` credential (a Grok OAuth access
|
|
21
|
+
* token) and must also send, in this order, a non-empty `X-XAI-Token-Auth` (401 without it; never
|
|
22
|
+
* recorded or checked), `x-grok-client-version` (426 without it: the proxy version-gates
|
|
23
|
+
* requests), and `x-grok-model-override` (400 without it). The client version and model override
|
|
24
|
+
* are recorded in the ledger; the version value itself is not checked.
|
|
25
|
+
*
|
|
26
|
+
* The same fetch handler also answers the Grok subscription-usage route
|
|
27
|
+
* (`GET /v1/billing?format=credits`, `emulator.usage`) with its own manifest
|
|
28
|
+
* (`xAiGrokSubscriptionUsageEmulatorRoutes`), ledger, faults, and turns; see
|
|
29
|
+
* `makeXAiGrokEmulator`.
|
|
30
|
+
*
|
|
31
|
+
* Runtime-portable Web APIs only (`Request`, `Response`, `ReadableStream`, `TextEncoder`, `URL`);
|
|
32
|
+
* no Effect runtime is required to use it.
|
|
33
|
+
*
|
|
34
|
+
* @experimental
|
|
35
|
+
*/
|
|
36
|
+
const xAiGrokResponsesPath = "/v1/responses";
|
|
37
|
+
/**
|
|
38
|
+
* The Grok subscription-usage path; the SDK fetcher (`xAiGrokSubscriptionUsageUrl`) adds
|
|
39
|
+
* `?format=credits`, the recorded query.
|
|
40
|
+
*/
|
|
41
|
+
const xAiGrokSubscriptionUsagePath = "/v1/billing";
|
|
42
|
+
/**
|
|
43
|
+
* Route evidence manifest of the Grok subscription-usage route (served by the same fetch handler
|
|
44
|
+
* as the Responses route, with its own ledger and coverage). Synthetic, unverified.
|
|
45
|
+
*/
|
|
46
|
+
const xAiGrokSubscriptionUsageEmulatorRoutes = [{
|
|
47
|
+
method: "GET",
|
|
48
|
+
path: xAiGrokSubscriptionUsagePath,
|
|
49
|
+
kind: "provider",
|
|
50
|
+
write: false,
|
|
51
|
+
caseIds: ["xai.grok.usage.snapshot"],
|
|
52
|
+
evidence: "unverified",
|
|
53
|
+
observedAt: void 0
|
|
54
|
+
}];
|
|
55
|
+
/**
|
|
56
|
+
* The recorded Grok usage body (the synthetic `xai.grok.usage.snapshot` fixture, copied as data):
|
|
57
|
+
* `config.creditUsagePercent` and `config.currentPeriod` `{ type, start, end }`.
|
|
58
|
+
*/
|
|
59
|
+
const xAiGrokSubscriptionUsageDefault = recordedUsageBody(xAiGrokUsageRecording);
|
|
60
|
+
/** Synthetic-safe default model ids, including the Grok conformance defaults. */
|
|
61
|
+
const xAiGrokEmulatorDefaultModels = ["grok-build", "grok-4.6"];
|
|
62
|
+
/**
|
|
63
|
+
* Route evidence manifest: every emulated Grok route and the conformance cases whose (currently
|
|
64
|
+
* synthetic, unverified) wire shapes it follows.
|
|
65
|
+
*/
|
|
66
|
+
const xAiGrokEmulatorRoutes = [{
|
|
67
|
+
method: "POST",
|
|
68
|
+
path: xAiGrokResponsesPath,
|
|
69
|
+
kind: "provider",
|
|
70
|
+
write: false,
|
|
71
|
+
caseIds: [
|
|
72
|
+
"xai.grok.stream.plain-text",
|
|
73
|
+
"xai.grok.stream.function-call-arguments",
|
|
74
|
+
"xai.grok.stream.error-envelope",
|
|
75
|
+
"xai.grok.stream.terminal-event"
|
|
76
|
+
],
|
|
77
|
+
evidence: "unverified",
|
|
78
|
+
observedAt: void 0
|
|
79
|
+
}];
|
|
80
|
+
/** Optional fault filter; an omitted field matches every request. `path` ending in `*` is a prefix. */
|
|
81
|
+
const XAiGrokFaultMatch = EmulatorFaultMatch;
|
|
82
|
+
/** A mid-stream Responses error (`{ code, message }`). */
|
|
83
|
+
const XAiGrokStreamError = ResponsesStreamError;
|
|
84
|
+
/** A mid-stream `error` or `response.failed` event fault, streamed responses only. */
|
|
85
|
+
const XAiGrokErrorEventFault = ResponsesErrorEventFault;
|
|
86
|
+
/**
|
|
87
|
+
* Wire faults: `status` (for example 429 with `retry-after`; the body defaults to the error
|
|
88
|
+
* envelope for the status), `error-after-chunks` (a dropped connection),
|
|
89
|
+
* `truncate-after-chunks` (a clean close, for example before `response.completed`), and
|
|
90
|
+
* `error-event-after-chunks` (a mid-stream `error` or `response.failed` event). Statuses that
|
|
91
|
+
* cannot carry a body and redirects are rejected, as are invalid headers and `location`. A fault
|
|
92
|
+
* that cannot take effect answers 500 and is not consumed.
|
|
93
|
+
*/
|
|
94
|
+
const XAiGrokFault = ResponsesFault;
|
|
95
|
+
/** Usage for a scripted turn (sent in `response.completed` or the JSON body). */
|
|
96
|
+
const XAiGrokScriptedUsage = ResponsesScriptedUsage;
|
|
97
|
+
/** One scripted `function_call` item; its arguments stream as these fragments. */
|
|
98
|
+
const XAiGrokScriptedFunctionCall = ResponsesScriptedFunctionCall;
|
|
99
|
+
/**
|
|
100
|
+
* A scripted response: `reasoning` (summary fragments), `text`, `functionCalls`, `order`,
|
|
101
|
+
* `usage` (`null` drops it), and `format` (`sse` or `json`, default: the request's `stream`).
|
|
102
|
+
*/
|
|
103
|
+
const XAiGrokScriptedResponse = ResponsesScriptedResponse;
|
|
104
|
+
/** A scripted error response: status, body (a string is sent as is), and optional headers. */
|
|
105
|
+
const XAiGrokScriptedError = EmulatorScriptedError;
|
|
106
|
+
/** A turn queued for the next Grok request. */
|
|
107
|
+
const XAiGrokScriptedTurn = ResponsesScriptedTurn;
|
|
108
|
+
/** Thrown by the JS API (`faults.add`, `script.enqueue`) for invalid input; a programmer error. */
|
|
109
|
+
var XAiGrokEmulatorInputInvalid = class extends Data.TaggedError("XAiGrokEmulatorInputInvalid") {
|
|
110
|
+
get message() {
|
|
111
|
+
return `Invalid xAI Grok emulator ${this.input}: ${this.reason}`;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/** A usage-route fault (`status`, `error-after-chunks`, `truncate-after-chunks`). */
|
|
115
|
+
const XAiGrokUsageFault = SubscriptionUsageFault;
|
|
116
|
+
const errorEnvelope = (error) => ({ error: {
|
|
117
|
+
message: error.message,
|
|
118
|
+
type: error.type,
|
|
119
|
+
param: error.param ?? null,
|
|
120
|
+
code: error.code
|
|
121
|
+
} });
|
|
122
|
+
/**
|
|
123
|
+
* Create a Grok CLI proxy Responses emulator. Each call has independent ledger, fault, and script
|
|
124
|
+
* state.
|
|
125
|
+
*
|
|
126
|
+
* Without a script, `POST /v1/responses` answers a known model with synthetic output: `stream:
|
|
127
|
+
* true` streams `response.created`, `response.in_progress`, the output items
|
|
128
|
+
* (`response.output_item.added`, their parts and deltas, `response.output_item.done`), and
|
|
129
|
+
* `response.completed` with usage; `stream: false` returns one `response` JSON body. A request
|
|
130
|
+
* whose `reasoning` asks for a `summary` gets a reasoning item first. A request with function
|
|
131
|
+
* `tools` gets one `function_call` item whose arguments are synthesized from the tool's JSON
|
|
132
|
+
* Schema and streamed as `response.function_call_arguments.delta` fragments. Unknown models get
|
|
133
|
+
* 400 `model_not_found`; a request without a bearer credential gets 401 `invalid_api_key`,
|
|
134
|
+
* without `X-XAI-Token-Auth` 401, without `x-grok-client-version` 426, and without
|
|
135
|
+
* `x-grok-model-override` 400; a non-positive `max_output_tokens` gets 400; unknown routes get a
|
|
136
|
+
* 404 envelope. Not enforced: that `x-grok-model-override` matches the body `model`, the client
|
|
137
|
+
* version value, and the output limit itself (recorded as `maxOutputTokens`).
|
|
138
|
+
*
|
|
139
|
+
* `GET /v1/billing?format=credits` is fixture-only: a request with the headers the SDK fetcher
|
|
140
|
+
* sends (a non-empty bearer, `X-XAI-Token-Auth: xai-grok-cli`, a non-empty `x-userid`, a
|
|
141
|
+
* non-empty `x-grok-client-version`, and `x-grok-client-mode: headless`; the bearer, user id, and
|
|
142
|
+
* client-version values are request-shape latitude, and the user id and token-auth are never
|
|
143
|
+
* recorded),
|
|
144
|
+
* `accept: application/json`, and exactly the recorded `format=credits` query gets the recorded
|
|
145
|
+
* body (`xAiGrokSubscriptionUsageDefault`, or a same-shaped `options.subscriptionUsage` / scripted
|
|
146
|
+
* `{ usage }`); anything else answers 400 not-emulated. The client version and mode are recorded.
|
|
147
|
+
* Its ledger, faults, turns, and coverage are `emulator.usage`
|
|
148
|
+
* (control plane `/_emulate/usage/*`); `reset()` and `POST /_emulate/reset` reset both routes.
|
|
149
|
+
*/
|
|
150
|
+
const makeXAiGrokEmulator = (options = {}) => withSubscriptionUsage(makeXAiGrokResponsesEmulator(options), makeXAiGrokUsageEmulator(options), xAiGrokSubscriptionUsagePath);
|
|
151
|
+
const makeXAiGrokUsageEmulator = (options) => makeSubscriptionUsageEmulator({
|
|
152
|
+
path: xAiGrokSubscriptionUsagePath,
|
|
153
|
+
routes: xAiGrokSubscriptionUsageEmulatorRoutes,
|
|
154
|
+
recording: xAiGrokUsageRecording,
|
|
155
|
+
headers: [
|
|
156
|
+
{
|
|
157
|
+
name: "x-xai-token-auth",
|
|
158
|
+
record: false,
|
|
159
|
+
accepts: (value) => value === "xai-grok-cli"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "x-userid",
|
|
163
|
+
record: false
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "x-grok-client-version",
|
|
167
|
+
record: true
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "x-grok-client-mode",
|
|
171
|
+
record: true,
|
|
172
|
+
accepts: (value) => value === "headless"
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
subscriptionUsage: options.subscriptionUsage,
|
|
176
|
+
inputInvalid: (input, reason) => new XAiGrokEmulatorInputInvalid({
|
|
177
|
+
input,
|
|
178
|
+
reason
|
|
179
|
+
})
|
|
180
|
+
});
|
|
181
|
+
const makeXAiGrokResponsesEmulator = (options) => makeResponsesEmulator({
|
|
182
|
+
path: xAiGrokResponsesPath,
|
|
183
|
+
routes: xAiGrokEmulatorRoutes,
|
|
184
|
+
knownModels: options.knownModels ?? xAiGrokEmulatorDefaultModels,
|
|
185
|
+
errorEnvelope,
|
|
186
|
+
unknownModel: {
|
|
187
|
+
status: 400,
|
|
188
|
+
error: {
|
|
189
|
+
message: "Synthetic placeholder: the requested model does not exist.",
|
|
190
|
+
type: "invalid_request_error",
|
|
191
|
+
code: "model_not_found",
|
|
192
|
+
param: "model"
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
unauthorized: {
|
|
196
|
+
message: "Synthetic: missing or invalid bearer credential.",
|
|
197
|
+
type: "invalid_request_error",
|
|
198
|
+
code: "invalid_api_key"
|
|
199
|
+
},
|
|
200
|
+
headers: [
|
|
201
|
+
{
|
|
202
|
+
name: "x-xai-token-auth",
|
|
203
|
+
record: false,
|
|
204
|
+
required: {
|
|
205
|
+
status: 401,
|
|
206
|
+
error: {
|
|
207
|
+
message: "Synthetic: the X-XAI-Token-Auth header is required.",
|
|
208
|
+
type: "invalid_request_error",
|
|
209
|
+
code: "missing_token_auth"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "x-grok-client-version",
|
|
215
|
+
record: true,
|
|
216
|
+
required: {
|
|
217
|
+
status: 426,
|
|
218
|
+
error: {
|
|
219
|
+
message: "Synthetic: a supported x-grok-client-version header is required.",
|
|
220
|
+
type: "invalid_request_error",
|
|
221
|
+
code: "upgrade_required"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: "x-grok-model-override",
|
|
227
|
+
record: true,
|
|
228
|
+
required: {
|
|
229
|
+
status: 400,
|
|
230
|
+
error: {
|
|
231
|
+
message: "Synthetic: the x-grok-model-override header is required.",
|
|
232
|
+
type: "invalid_request_error",
|
|
233
|
+
code: "missing_model_override"
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
],
|
|
238
|
+
outputTokenLimit: "optional",
|
|
239
|
+
defaultText: [
|
|
240
|
+
"Hello",
|
|
241
|
+
" from the",
|
|
242
|
+
" synthetic Grok emulator."
|
|
243
|
+
],
|
|
244
|
+
inputInvalid: (input, reason) => new XAiGrokEmulatorInputInvalid({
|
|
245
|
+
input,
|
|
246
|
+
reason
|
|
247
|
+
})
|
|
248
|
+
});
|
|
249
|
+
//#endregion
|
|
250
|
+
export { XAiGrokEmulatorInputInvalid, XAiGrokErrorEventFault, XAiGrokFault, XAiGrokFaultMatch, XAiGrokScriptedError, XAiGrokScriptedFunctionCall, XAiGrokScriptedResponse, XAiGrokScriptedTurn, XAiGrokScriptedUsage, XAiGrokStreamError, XAiGrokUsageFault, emulatorEvidenceHeader, makeXAiGrokEmulator, xAiGrokEmulatorDefaultModels, xAiGrokEmulatorRoutes, xAiGrokResponsesPath, xAiGrokSubscriptionUsageDefault, xAiGrokSubscriptionUsageEmulatorRoutes, xAiGrokSubscriptionUsagePath };
|
|
251
|
+
|
|
252
|
+
//# sourceMappingURL=xai.mjs.map
|
package/dist/xai.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xai.mjs","names":[],"sources":["../src/xai.ts"],"sourcesContent":["/**\n * xAI Grok CLI proxy Responses emulator: a plain fetch handler for `POST /v1/responses` (origin\n * `https://cli-chat-proxy.grok.com`), with scripted turns, wire faults, a request ledger, and an\n * `/_emulate/*` control plane.\n *\n * It never imports SDK code: its wire shapes follow the synthetic Grok Responses conformance\n * fixtures (Responses SSE with typed `event:` names, the `response` JSON body, and the\n * `{ error: { message, type, param, code } }` envelope) and are linked to those conformance case\n * ids in `xAiGrokEmulatorRoutes`. The Responses machinery lives in the internal `responses.ts`\n * core and is shared with the Codex emulator.\n *\n * Requests authenticate with a non-empty `Authorization: Bearer` credential (a Grok OAuth access\n * token) and must also send, in this order, a non-empty `X-XAI-Token-Auth` (401 without it; never\n * recorded or checked), `x-grok-client-version` (426 without it: the proxy version-gates\n * requests), and `x-grok-model-override` (400 without it). The client version and model override\n * are recorded in the ledger; the version value itself is not checked.\n *\n * The same fetch handler also answers the Grok subscription-usage route\n * (`GET /v1/billing?format=credits`, `emulator.usage`) with its own manifest\n * (`xAiGrokSubscriptionUsageEmulatorRoutes`), ledger, faults, and turns; see\n * `makeXAiGrokEmulator`.\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 { withSubscriptionUsage } from './emulator-compose.ts'\nimport type {\n EmulatorCoverage,\n EmulatorFaultState,\n EmulatorRouteCoverage\n} from './emulator-kernel.ts'\nimport { EmulatorFaultMatch, EmulatorScriptedError } from './emulator-kernel.ts'\nimport {\n makeResponsesEmulator,\n ResponsesErrorEventFault,\n ResponsesFault,\n ResponsesScriptedFunctionCall,\n ResponsesScriptedResponse,\n ResponsesScriptedTurn,\n ResponsesScriptedUsage,\n ResponsesStreamError,\n type ResponsesEmulator,\n type ResponsesFaultKind,\n type ResponsesLedgerEntry,\n type ResponsesWireError\n} from './responses.ts'\nimport type { EmulatorRouteEvidence } from './route-evidence.ts'\nimport {\n makeSubscriptionUsageEmulator,\n recordedUsageBody,\n SubscriptionUsageFault,\n type SubscriptionUsageEmulator,\n type SubscriptionUsageLedgerEntry,\n type SubscriptionUsageScriptedTurn\n} from './subscription-usage.ts'\nimport { xAiGrokUsageRecording } from './subscription-usage-recordings.ts'\n\nexport type { EmulatorEvidence, EmulatorRouteEvidence } from './route-evidence.ts'\n\nexport { emulatorEvidenceHeader } from './route-evidence.ts'\n\nexport const xAiGrokResponsesPath = '/v1/responses'\n\n/**\n * The Grok subscription-usage path; the SDK fetcher (`xAiGrokSubscriptionUsageUrl`) adds\n * `?format=credits`, the recorded query.\n */\nexport const xAiGrokSubscriptionUsagePath = '/v1/billing'\n\n/**\n * Route evidence manifest of the Grok subscription-usage route (served by the same fetch handler\n * as the Responses route, with its own ledger and coverage). Synthetic, unverified.\n */\nexport const xAiGrokSubscriptionUsageEmulatorRoutes: ReadonlyArray<EmulatorRouteEvidence> = [\n {\n method: 'GET',\n path: xAiGrokSubscriptionUsagePath,\n kind: 'provider',\n write: false,\n caseIds: ['xai.grok.usage.snapshot'],\n evidence: 'unverified',\n observedAt: undefined\n }\n]\n\n/**\n * The recorded Grok usage body (the synthetic `xai.grok.usage.snapshot` fixture, copied as data):\n * `config.creditUsagePercent` and `config.currentPeriod` `{ type, start, end }`.\n */\nexport const xAiGrokSubscriptionUsageDefault: Schema.Json = recordedUsageBody(xAiGrokUsageRecording)\n\n/** Synthetic-safe default model ids, including the Grok conformance defaults. */\nexport const xAiGrokEmulatorDefaultModels: ReadonlyArray<string> = ['grok-build', 'grok-4.6']\n\n/**\n * Route evidence manifest: every emulated Grok route and the conformance cases whose (currently\n * synthetic, unverified) wire shapes it follows.\n */\nexport const xAiGrokEmulatorRoutes: ReadonlyArray<EmulatorRouteEvidence> = [\n {\n method: 'POST',\n path: xAiGrokResponsesPath,\n kind: 'provider',\n write: false,\n caseIds: [\n 'xai.grok.stream.plain-text',\n 'xai.grok.stream.function-call-arguments',\n 'xai.grok.stream.error-envelope',\n 'xai.grok.stream.terminal-event'\n ],\n evidence: 'unverified',\n observedAt: undefined\n }\n]\n\n/** Optional fault filter; an omitted field matches every request. `path` ending in `*` is a prefix. */\nexport const XAiGrokFaultMatch = EmulatorFaultMatch\n\nexport type XAiGrokFaultMatch = typeof EmulatorFaultMatch.Type\n\n/** A mid-stream Responses error (`{ code, message }`). */\nexport const XAiGrokStreamError = ResponsesStreamError\n\nexport type XAiGrokStreamError = ResponsesStreamError\n\n/** A mid-stream `error` or `response.failed` event fault, streamed responses only. */\nexport const XAiGrokErrorEventFault = ResponsesErrorEventFault\n\nexport type XAiGrokErrorEventFault = typeof ResponsesErrorEventFault.Type\n\n/**\n * Wire faults: `status` (for example 429 with `retry-after`; the body defaults to the error\n * envelope for the status), `error-after-chunks` (a dropped connection),\n * `truncate-after-chunks` (a clean close, for example before `response.completed`), and\n * `error-event-after-chunks` (a mid-stream `error` or `response.failed` event). Statuses that\n * cannot carry a body and redirects are rejected, as are invalid headers and `location`. A fault\n * that cannot take effect answers 500 and is not consumed.\n */\nexport const XAiGrokFault = ResponsesFault\n\nexport type XAiGrokFault = ResponsesFault\n\nexport type XAiGrokFaultKind = ResponsesFaultKind\n\n/** Usage for a scripted turn (sent in `response.completed` or the JSON body). */\nexport const XAiGrokScriptedUsage = ResponsesScriptedUsage\n\nexport type XAiGrokScriptedUsage = ResponsesScriptedUsage\n\n/** One scripted `function_call` item; its arguments stream as these fragments. */\nexport const XAiGrokScriptedFunctionCall = ResponsesScriptedFunctionCall\n\nexport type XAiGrokScriptedFunctionCall = ResponsesScriptedFunctionCall\n\n/**\n * A scripted response: `reasoning` (summary fragments), `text`, `functionCalls`, `order`,\n * `usage` (`null` drops it), and `format` (`sse` or `json`, default: the request's `stream`).\n */\nexport const XAiGrokScriptedResponse = ResponsesScriptedResponse\n\nexport type XAiGrokScriptedResponse = ResponsesScriptedResponse\n\n/** A scripted error response: status, body (a string is sent as is), and optional headers. */\nexport const XAiGrokScriptedError = EmulatorScriptedError\n\nexport type XAiGrokScriptedError = typeof EmulatorScriptedError.Type\n\n/** A turn queued for the next Grok request. */\nexport const XAiGrokScriptedTurn = ResponsesScriptedTurn\n\nexport type XAiGrokScriptedTurn = ResponsesScriptedTurn\n\n/** Thrown by the JS API (`faults.add`, `script.enqueue`) for invalid input; a programmer error. */\nexport class XAiGrokEmulatorInputInvalid extends Data.TaggedError('XAiGrokEmulatorInputInvalid')<{\n readonly input: 'fault' | 'turn'\n readonly reason: string\n}> {\n override get message(): string {\n return `Invalid xAI Grok emulator ${this.input}: ${this.reason}`\n }\n}\n\nexport type XAiGrokLedgerEntry = ResponsesLedgerEntry\n\nexport type XAiGrokFaultState = EmulatorFaultState<XAiGrokFault>\n\nexport type XAiGrokRouteCoverage = EmulatorRouteCoverage\n\nexport type XAiGrokCoverage = EmulatorCoverage\n\n/** A usage-route fault (`status`, `error-after-chunks`, `truncate-after-chunks`). */\nexport const XAiGrokUsageFault = SubscriptionUsageFault\n\nexport type XAiGrokUsageFault = SubscriptionUsageFault\n\n/** A usage turn: `{ usage }` (a body with the recorded JSON shape) or `{ error }`. */\nexport type XAiGrokUsageScriptedTurn = SubscriptionUsageScriptedTurn\n\nexport type XAiGrokUsageLedgerEntry = SubscriptionUsageLedgerEntry\n\nexport type XAiGrokUsageEmulator = SubscriptionUsageEmulator\n\nexport type XAiGrokEmulatorOptions = {\n /** Model ids that exist. Defaults to `xAiGrokEmulatorDefaultModels`. */\n readonly knownModels?: ReadonlyArray<string>\n /**\n * Replacement usage-route body; must have the recorded JSON shape (same keys and value kinds).\n * Defaults to the recorded body (`xAiGrokSubscriptionUsageDefault`).\n */\n readonly subscriptionUsage?: Schema.Json\n}\n\n/** The Responses emulator, plus `usage`: the subscription-usage route's own emulator API. */\nexport type XAiGrokEmulator = ResponsesEmulator & { readonly usage: XAiGrokUsageEmulator }\n\nconst errorEnvelope = (error: ResponsesWireError): Schema.Json => ({\n error: {\n message: error.message,\n type: error.type,\n param: error.param ?? null,\n code: error.code\n }\n})\n\n/**\n * Create a Grok CLI proxy Responses emulator. Each call has independent ledger, fault, and script\n * state.\n *\n * Without a script, `POST /v1/responses` answers a known model with synthetic output: `stream:\n * true` streams `response.created`, `response.in_progress`, the output items\n * (`response.output_item.added`, their parts and deltas, `response.output_item.done`), and\n * `response.completed` with usage; `stream: false` returns one `response` JSON body. A request\n * whose `reasoning` asks for a `summary` gets a reasoning item first. A request with function\n * `tools` gets one `function_call` item whose arguments are synthesized from the tool's JSON\n * Schema and streamed as `response.function_call_arguments.delta` fragments. Unknown models get\n * 400 `model_not_found`; a request without a bearer credential gets 401 `invalid_api_key`,\n * without `X-XAI-Token-Auth` 401, without `x-grok-client-version` 426, and without\n * `x-grok-model-override` 400; a non-positive `max_output_tokens` gets 400; unknown routes get a\n * 404 envelope. Not enforced: that `x-grok-model-override` matches the body `model`, the client\n * version value, and the output limit itself (recorded as `maxOutputTokens`).\n *\n * `GET /v1/billing?format=credits` is fixture-only: a request with the headers the SDK fetcher\n * sends (a non-empty bearer, `X-XAI-Token-Auth: xai-grok-cli`, a non-empty `x-userid`, a\n * non-empty `x-grok-client-version`, and `x-grok-client-mode: headless`; the bearer, user id, and\n * client-version values are request-shape latitude, and the user id and token-auth are never\n * recorded),\n * `accept: application/json`, and exactly the recorded `format=credits` query gets the recorded\n * body (`xAiGrokSubscriptionUsageDefault`, or a same-shaped `options.subscriptionUsage` / scripted\n * `{ usage }`); anything else answers 400 not-emulated. The client version and mode are recorded.\n * Its ledger, faults, turns, and coverage are `emulator.usage`\n * (control plane `/_emulate/usage/*`); `reset()` and `POST /_emulate/reset` reset both routes.\n */\nexport const makeXAiGrokEmulator = (options: XAiGrokEmulatorOptions = {}): XAiGrokEmulator =>\n withSubscriptionUsage(\n makeXAiGrokResponsesEmulator(options),\n makeXAiGrokUsageEmulator(options),\n xAiGrokSubscriptionUsagePath\n )\n\nconst makeXAiGrokUsageEmulator = (options: XAiGrokEmulatorOptions): XAiGrokUsageEmulator =>\n makeSubscriptionUsageEmulator({\n path: xAiGrokSubscriptionUsagePath,\n routes: xAiGrokSubscriptionUsageEmulatorRoutes,\n recording: xAiGrokUsageRecording,\n headers: [\n { name: 'x-xai-token-auth', record: false, accepts: value => value === 'xai-grok-cli' },\n { name: 'x-userid', record: false },\n { name: 'x-grok-client-version', record: true },\n { name: 'x-grok-client-mode', record: true, accepts: value => value === 'headless' }\n ],\n subscriptionUsage: options.subscriptionUsage,\n inputInvalid: (input, reason) => new XAiGrokEmulatorInputInvalid({ input, reason })\n })\n\nconst makeXAiGrokResponsesEmulator = (options: XAiGrokEmulatorOptions): ResponsesEmulator =>\n makeResponsesEmulator({\n path: xAiGrokResponsesPath,\n routes: xAiGrokEmulatorRoutes,\n knownModels: options.knownModels ?? xAiGrokEmulatorDefaultModels,\n errorEnvelope,\n // Copied data shape of the synthetic Grok error-envelope fixture (unknown model id).\n unknownModel: {\n status: 400,\n error: {\n message: 'Synthetic placeholder: the requested model does not exist.',\n type: 'invalid_request_error',\n code: 'model_not_found',\n param: 'model'\n }\n },\n unauthorized: {\n message: 'Synthetic: missing or invalid bearer credential.',\n type: 'invalid_request_error',\n code: 'invalid_api_key'\n },\n headers: [\n {\n name: 'x-xai-token-auth',\n record: false,\n required: {\n status: 401,\n error: {\n message: 'Synthetic: the X-XAI-Token-Auth header is required.',\n type: 'invalid_request_error',\n code: 'missing_token_auth'\n }\n }\n },\n {\n name: 'x-grok-client-version',\n record: true,\n required: {\n status: 426,\n error: {\n message: 'Synthetic: a supported x-grok-client-version header is required.',\n type: 'invalid_request_error',\n code: 'upgrade_required'\n }\n }\n },\n {\n name: 'x-grok-model-override',\n record: true,\n required: {\n status: 400,\n error: {\n message: 'Synthetic: the x-grok-model-override header is required.',\n type: 'invalid_request_error',\n code: 'missing_model_override'\n }\n }\n }\n ],\n outputTokenLimit: 'optional',\n defaultText: ['Hello', ' from the', ' synthetic Grok emulator.'],\n inputInvalid: (input, reason) => new XAiGrokEmulatorInputInvalid({ input, reason })\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,MAAa,uBAAuB;;;;;AAMpC,MAAa,+BAA+B;;;;;AAM5C,MAAa,yCAA+E,CAC1F;CACE,QAAQ;CACR,MAAM;CACN,MAAM;CACN,OAAO;CACP,SAAS,CAAC,yBAAyB;CACnC,UAAU;CACV,YAAY,KAAA;AACd,CACF;;;;;AAMA,MAAa,kCAA+C,kBAAkB,qBAAqB;;AAGnG,MAAa,+BAAsD,CAAC,cAAc,UAAU;;;;;AAM5F,MAAa,wBAA8D,CACzE;CACE,QAAQ;CACR,MAAM;CACN,MAAM;CACN,OAAO;CACP,SAAS;EACP;EACA;EACA;EACA;CACF;CACA,UAAU;CACV,YAAY,KAAA;AACd,CACF;;AAGA,MAAa,oBAAoB;;AAKjC,MAAa,qBAAqB;;AAKlC,MAAa,yBAAyB;;;;;;;;;AAYtC,MAAa,eAAe;;AAO5B,MAAa,uBAAuB;;AAKpC,MAAa,8BAA8B;;;;;AAQ3C,MAAa,0BAA0B;;AAKvC,MAAa,uBAAuB;;AAKpC,MAAa,sBAAsB;;AAKnC,IAAa,8BAAb,cAAiD,KAAK,YAAY,6BAA6B,EAG5F;CACD,IAAa,UAAkB;EAC7B,OAAO,6BAA6B,KAAK,MAAM,IAAI,KAAK;CAC1D;AACF;;AAWA,MAAa,oBAAoB;AAwBjC,MAAM,iBAAiB,WAA4C,EACjE,OAAO;CACL,SAAS,MAAM;CACf,MAAM,MAAM;CACZ,OAAO,MAAM,SAAS;CACtB,MAAM,MAAM;AACd,EACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,uBAAuB,UAAkC,CAAC,MACrE,sBACE,6BAA6B,OAAO,GACpC,yBAAyB,OAAO,GAChC,4BACF;AAEF,MAAM,4BAA4B,YAChC,8BAA8B;CAC5B,MAAM;CACN,QAAQ;CACR,WAAW;CACX,SAAS;EACP;GAAE,MAAM;GAAoB,QAAQ;GAAO,UAAS,UAAS,UAAU;EAAe;EACtF;GAAE,MAAM;GAAY,QAAQ;EAAM;EAClC;GAAE,MAAM;GAAyB,QAAQ;EAAK;EAC9C;GAAE,MAAM;GAAsB,QAAQ;GAAM,UAAS,UAAS,UAAU;EAAW;CACrF;CACA,mBAAmB,QAAQ;CAC3B,eAAe,OAAO,WAAW,IAAI,4BAA4B;EAAE;EAAO;CAAO,CAAC;AACpF,CAAC;AAEH,MAAM,gCAAgC,YACpC,sBAAsB;CACpB,MAAM;CACN,QAAQ;CACR,aAAa,QAAQ,eAAe;CACpC;CAEA,cAAc;EACZ,QAAQ;EACR,OAAO;GACL,SAAS;GACT,MAAM;GACN,MAAM;GACN,OAAO;EACT;CACF;CACA,cAAc;EACZ,SAAS;EACT,MAAM;EACN,MAAM;CACR;CACA,SAAS;EACP;GACE,MAAM;GACN,QAAQ;GACR,UAAU;IACR,QAAQ;IACR,OAAO;KACL,SAAS;KACT,MAAM;KACN,MAAM;IACR;GACF;EACF;EACA;GACE,MAAM;GACN,QAAQ;GACR,UAAU;IACR,QAAQ;IACR,OAAO;KACL,SAAS;KACT,MAAM;KACN,MAAM;IACR;GACF;EACF;EACA;GACE,MAAM;GACN,QAAQ;GACR,UAAU;IACR,QAAQ;IACR,OAAO;KACL,SAAS;KACT,MAAM;KACN,MAAM;IACR;GACF;EACF;CACF;CACA,kBAAkB;CAClB,aAAa;EAAC;EAAS;EAAa;CAA2B;CAC/D,eAAe,OAAO,WAAW,IAAI,4BAA4B;EAAE;EAAO;CAAO,CAAC;AACpF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yolk-sdk/emulators",
|
|
3
|
+
"version": "0.1.0-canary.96",
|
|
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 MCP emulators, and a loopback Node server.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/magoz/yolk-sdk.git",
|
|
11
|
+
"directory": "packages/emulators"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/magoz/yolk-sdk/issues"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/magoz/yolk-sdk#readme",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"emulators",
|
|
19
|
+
"conformance",
|
|
20
|
+
"testing",
|
|
21
|
+
"http",
|
|
22
|
+
"effect"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
"./router": {
|
|
30
|
+
"types": "./dist/router.d.mts",
|
|
31
|
+
"import": "./dist/router.mjs",
|
|
32
|
+
"default": "./dist/router.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./gateway": {
|
|
35
|
+
"types": "./dist/gateway.d.mts",
|
|
36
|
+
"import": "./dist/gateway.mjs",
|
|
37
|
+
"default": "./dist/gateway.mjs"
|
|
38
|
+
},
|
|
39
|
+
"./openai": {
|
|
40
|
+
"types": "./dist/openai.d.mts",
|
|
41
|
+
"import": "./dist/openai.mjs",
|
|
42
|
+
"default": "./dist/openai.mjs"
|
|
43
|
+
},
|
|
44
|
+
"./anthropic": {
|
|
45
|
+
"types": "./dist/anthropic.d.mts",
|
|
46
|
+
"import": "./dist/anthropic.mjs",
|
|
47
|
+
"default": "./dist/anthropic.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./codex": {
|
|
50
|
+
"types": "./dist/codex.d.mts",
|
|
51
|
+
"import": "./dist/codex.mjs",
|
|
52
|
+
"default": "./dist/codex.mjs"
|
|
53
|
+
},
|
|
54
|
+
"./xai": {
|
|
55
|
+
"types": "./dist/xai.d.mts",
|
|
56
|
+
"import": "./dist/xai.mjs",
|
|
57
|
+
"default": "./dist/xai.mjs"
|
|
58
|
+
},
|
|
59
|
+
"./opencode": {
|
|
60
|
+
"types": "./dist/opencode.d.mts",
|
|
61
|
+
"import": "./dist/opencode.mjs",
|
|
62
|
+
"default": "./dist/opencode.mjs"
|
|
63
|
+
},
|
|
64
|
+
"./email": {
|
|
65
|
+
"types": "./dist/email.d.mts",
|
|
66
|
+
"import": "./dist/email.mjs",
|
|
67
|
+
"default": "./dist/email.mjs"
|
|
68
|
+
},
|
|
69
|
+
"./r2": {
|
|
70
|
+
"types": "./dist/r2.d.mts",
|
|
71
|
+
"import": "./dist/r2.mjs",
|
|
72
|
+
"default": "./dist/r2.mjs"
|
|
73
|
+
},
|
|
74
|
+
"./node": {
|
|
75
|
+
"types": "./dist/node.d.mts",
|
|
76
|
+
"import": "./dist/node.mjs",
|
|
77
|
+
"default": "./dist/node.mjs"
|
|
78
|
+
},
|
|
79
|
+
"./fortnox": {
|
|
80
|
+
"types": "./dist/fortnox.d.mts",
|
|
81
|
+
"import": "./dist/fortnox.mjs",
|
|
82
|
+
"default": "./dist/fortnox.mjs"
|
|
83
|
+
},
|
|
84
|
+
"./microsoft": {
|
|
85
|
+
"types": "./dist/microsoft.d.mts",
|
|
86
|
+
"import": "./dist/microsoft.mjs",
|
|
87
|
+
"default": "./dist/microsoft.mjs"
|
|
88
|
+
},
|
|
89
|
+
"./dropbox": {
|
|
90
|
+
"types": "./dist/dropbox.d.mts",
|
|
91
|
+
"import": "./dist/dropbox.mjs",
|
|
92
|
+
"default": "./dist/dropbox.mjs"
|
|
93
|
+
},
|
|
94
|
+
"./notion": {
|
|
95
|
+
"types": "./dist/notion.d.mts",
|
|
96
|
+
"import": "./dist/notion.mjs",
|
|
97
|
+
"default": "./dist/notion.mjs"
|
|
98
|
+
},
|
|
99
|
+
"./todoist": {
|
|
100
|
+
"types": "./dist/todoist.d.mts",
|
|
101
|
+
"import": "./dist/todoist.mjs",
|
|
102
|
+
"default": "./dist/todoist.mjs"
|
|
103
|
+
},
|
|
104
|
+
"./telegram": {
|
|
105
|
+
"types": "./dist/telegram.d.mts",
|
|
106
|
+
"import": "./dist/telegram.mjs",
|
|
107
|
+
"default": "./dist/telegram.mjs"
|
|
108
|
+
},
|
|
109
|
+
"./github": {
|
|
110
|
+
"types": "./dist/github.d.mts",
|
|
111
|
+
"import": "./dist/github.mjs",
|
|
112
|
+
"default": "./dist/github.mjs"
|
|
113
|
+
},
|
|
114
|
+
"./google": {
|
|
115
|
+
"types": "./dist/google.d.mts",
|
|
116
|
+
"import": "./dist/google.mjs",
|
|
117
|
+
"default": "./dist/google.mjs"
|
|
118
|
+
},
|
|
119
|
+
"./linkedin-search": {
|
|
120
|
+
"types": "./dist/linkedin-search.d.mts",
|
|
121
|
+
"import": "./dist/linkedin-search.mjs",
|
|
122
|
+
"default": "./dist/linkedin-search.mjs"
|
|
123
|
+
},
|
|
124
|
+
"./mcp": {
|
|
125
|
+
"types": "./dist/mcp.d.mts",
|
|
126
|
+
"import": "./dist/mcp.mjs",
|
|
127
|
+
"default": "./dist/mcp.mjs"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"files": [
|
|
131
|
+
"src/**/*.ts",
|
|
132
|
+
"!src/**/*.test.ts",
|
|
133
|
+
"!src/**/*.test.tsx",
|
|
134
|
+
"dist/**/*",
|
|
135
|
+
"README.md"
|
|
136
|
+
],
|
|
137
|
+
"publishConfig": {
|
|
138
|
+
"access": "public",
|
|
139
|
+
"provenance": true
|
|
140
|
+
},
|
|
141
|
+
"dependencies": {
|
|
142
|
+
"@emulators/core": "0.12.0",
|
|
143
|
+
"effect": "4.0.0-rc.115"
|
|
144
|
+
},
|
|
145
|
+
"devDependencies": {
|
|
146
|
+
"@yolk-sdk/agent": "^0.1.0-canary.96",
|
|
147
|
+
"@yolk-sdk/connectors": "^0.1.0-canary.96",
|
|
148
|
+
"@yolk-sdk/conformance": "^0.1.0-canary.96",
|
|
149
|
+
"@yolk-sdk/mcp": "^0.1.0-canary.96"
|
|
150
|
+
},
|
|
151
|
+
"scripts": {
|
|
152
|
+
"build": "tsdown",
|
|
153
|
+
"check": "tsc -p tsconfig.json --noEmit",
|
|
154
|
+
"test": "vitest run --passWithNoTests",
|
|
155
|
+
"test:run": "vitest run --passWithNoTests"
|
|
156
|
+
}
|
|
157
|
+
}
|