@volter/twin-openrouter 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +131 -0
- package/client/openrouter-mirror.css +131 -0
- package/client/openrouter-mirror.tsx +221 -0
- package/dist/client/openrouter-mirror.bundle.js +235 -0
- package/dist/client/openrouter-mirror.css +131 -0
- package/dist/client/openrouter-mirror.d.ts +1 -0
- package/dist/client/openrouter-mirror.js +95 -0
- package/dist/client/openrouter-mirror.tsx +221 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +31 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.js +66 -0
- package/dist/src/openrouter-budget.d.ts +58 -0
- package/dist/src/openrouter-budget.js +133 -0
- package/dist/src/openrouter-capabilities.d.ts +3 -0
- package/dist/src/openrouter-capabilities.js +720 -0
- package/dist/src/openrouter-conformance.d.ts +11 -0
- package/dist/src/openrouter-conformance.js +53 -0
- package/dist/src/openrouter-connector.d.ts +90 -0
- package/dist/src/openrouter-connector.js +245 -0
- package/dist/src/openrouter-local-generation.d.ts +17 -0
- package/dist/src/openrouter-local-generation.js +271 -0
- package/dist/src/openrouter-mirror-ui.d.ts +12 -0
- package/dist/src/openrouter-mirror-ui.js +78 -0
- package/dist/src/openrouter-models.d.ts +39 -0
- package/dist/src/openrouter-models.js +78 -0
- package/dist/src/openrouter-scenario.d.ts +36 -0
- package/dist/src/openrouter-scenario.js +145 -0
- package/dist/src/openrouter-server.d.ts +20 -0
- package/dist/src/openrouter-server.js +144 -0
- package/dist/src/openrouter-stub.d.ts +8 -0
- package/dist/src/openrouter-stub.js +58 -0
- package/dist/src/openrouter-twin.d.ts +4 -0
- package/dist/src/openrouter-twin.js +1506 -0
- package/dist/src/openrouter-types.d.ts +50 -0
- package/dist/src/openrouter-types.js +1 -0
- package/dist/test-fixtures/openrouter-openapi-operations.SOURCE.md +16 -0
- package/dist/test-fixtures/openrouter-openapi-operations.json +1041 -0
- package/package.json +71 -0
- package/src/cli.ts +29 -0
- package/src/index.ts +108 -0
- package/src/openrouter-budget.ts +159 -0
- package/src/openrouter-capabilities.ts +861 -0
- package/src/openrouter-conformance.ts +60 -0
- package/src/openrouter-connector.ts +264 -0
- package/src/openrouter-local-generation.ts +207 -0
- package/src/openrouter-mirror-ui.ts +84 -0
- package/src/openrouter-models.ts +118 -0
- package/src/openrouter-scenario.ts +156 -0
- package/src/openrouter-server.ts +158 -0
- package/src/openrouter-stub.ts +60 -0
- package/src/openrouter-twin.ts +1441 -0
- package/src/openrouter-types.ts +49 -0
- package/test-fixtures/openrouter-openapi-operations.SOURCE.md +16 -0
- package/test-fixtures/openrouter-openapi-operations.json +1041 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Type-only edge to the scenario module (erased at build — no runtime import cycle).
|
|
2
|
+
import type { OpenRouterScenarioEngine } from './openrouter-scenario.ts';
|
|
3
|
+
|
|
4
|
+
export type SseEvent = { data?: Record<string, unknown>; done?: boolean };
|
|
5
|
+
export type SseSink = (event: SseEvent) => void;
|
|
6
|
+
|
|
7
|
+
export type OpenRouterRequest = {
|
|
8
|
+
method: string;
|
|
9
|
+
path: string;
|
|
10
|
+
body?: string;
|
|
11
|
+
root?: string;
|
|
12
|
+
readOnly?: boolean;
|
|
13
|
+
occurredAt?: string;
|
|
14
|
+
/** Caller disconnect/cancellation, if this request entered through the Fetch adapter. */
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
sseSink?: SseSink;
|
|
17
|
+
/** The pack's scenario engine, mounted by the fetch adapter when a world dir carries a
|
|
18
|
+
* handlers/openrouter.json. Absent → the labeled deterministic stub answers, unchanged. */
|
|
19
|
+
scenarioEngine?: OpenRouterScenarioEngine;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type OpenRouterResponse = { status: number; body: unknown; headers?: Record<string, string> };
|
|
23
|
+
|
|
24
|
+
export type ChatMessage = {
|
|
25
|
+
role: string;
|
|
26
|
+
content?: unknown;
|
|
27
|
+
tool_calls?: unknown;
|
|
28
|
+
cache_control?: unknown;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type GenerationStat = {
|
|
32
|
+
id: string;
|
|
33
|
+
object: 'generation';
|
|
34
|
+
api_type: 'chat';
|
|
35
|
+
model: string;
|
|
36
|
+
provider_name: string;
|
|
37
|
+
created_at: string;
|
|
38
|
+
request_id: string;
|
|
39
|
+
finish_reason: string;
|
|
40
|
+
native_finish_reason: string;
|
|
41
|
+
total_cost: number;
|
|
42
|
+
tokens_prompt: number;
|
|
43
|
+
tokens_completion: number;
|
|
44
|
+
native_tokens_prompt: number;
|
|
45
|
+
native_tokens_completion: number;
|
|
46
|
+
usage: number;
|
|
47
|
+
app_id: number | null;
|
|
48
|
+
streamed: boolean;
|
|
49
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# openrouter-openapi-operations.json — provenance
|
|
2
|
+
|
|
3
|
+
The operation-inventory denominator for `../openrouter-spec-census.json`: a scope-filtered subset of
|
|
4
|
+
the vendor's published spec, enumerated by `deriveFromOpenAPI` (`packages/world-tooling/src/derive.ts`).
|
|
5
|
+
|
|
6
|
+
- **Upstream:** https://openrouter.ai/openapi.json — `openapi.json`.
|
|
7
|
+
- **How it was built:** `bun scripts/spec-census-bootstrap.ts --vendor openrouter --from-file <openapi.json> --scope-paths /analytics,/audio,/auth,/byok,/chat/,/credits,/datasets,/embeddings,/files,/generation,/guardrails,/key,/messages,/models,/observability/destinations,/organization/members,/presets,/providers,/rerank,/responses,/videos,/workspaces --apply`
|
|
8
|
+
over a copy of the upstream file fetched 2026-09-02; operation metadata only (operationId, summary, tags,
|
|
9
|
+
servers), schemas and response codes dropped. The gate never fetches — refreshing the fixture is
|
|
10
|
+
`bun scripts/spec-refresh.ts --vendor openrouter --from-file <newer spec> --apply` over a newly fetched copy.
|
|
11
|
+
- **Scope (83 of 101 upstream operations):** every operation whose path starts with one of
|
|
12
|
+
`/analytics`, `/audio`, `/auth`, `/byok`, `/chat/`, `/credits`, `/datasets`, `/embeddings`, `/files`, `/generation`, `/guardrails`, `/key`, `/messages`, `/models`, `/observability/destinations`, `/organization/members`, `/presets`, `/providers`, `/rerank`, `/responses`, `/videos`, `/workspaces`.
|
|
13
|
+
- **Mapping at birth:** 59 operations mapped to done capability ids by the rules in `scripts/spec-census-map.ts`
|
|
14
|
+
behind the static served-surface probe; 24 left `unmapped`. The census, not this file, records what
|
|
15
|
+
happened next: hand rulings (a `$ruled` marker, a remap) and the per-operation probe's demotions
|
|
16
|
+
(`$probeComment`). This fixture changes only through a spec refresh.
|