@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.
Files changed (56) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +131 -0
  3. package/client/openrouter-mirror.css +131 -0
  4. package/client/openrouter-mirror.tsx +221 -0
  5. package/dist/client/openrouter-mirror.bundle.js +235 -0
  6. package/dist/client/openrouter-mirror.css +131 -0
  7. package/dist/client/openrouter-mirror.d.ts +1 -0
  8. package/dist/client/openrouter-mirror.js +95 -0
  9. package/dist/client/openrouter-mirror.tsx +221 -0
  10. package/dist/src/cli.d.ts +2 -0
  11. package/dist/src/cli.js +31 -0
  12. package/dist/src/index.d.ts +15 -0
  13. package/dist/src/index.js +66 -0
  14. package/dist/src/openrouter-budget.d.ts +58 -0
  15. package/dist/src/openrouter-budget.js +133 -0
  16. package/dist/src/openrouter-capabilities.d.ts +3 -0
  17. package/dist/src/openrouter-capabilities.js +720 -0
  18. package/dist/src/openrouter-conformance.d.ts +11 -0
  19. package/dist/src/openrouter-conformance.js +53 -0
  20. package/dist/src/openrouter-connector.d.ts +90 -0
  21. package/dist/src/openrouter-connector.js +245 -0
  22. package/dist/src/openrouter-local-generation.d.ts +17 -0
  23. package/dist/src/openrouter-local-generation.js +271 -0
  24. package/dist/src/openrouter-mirror-ui.d.ts +12 -0
  25. package/dist/src/openrouter-mirror-ui.js +78 -0
  26. package/dist/src/openrouter-models.d.ts +39 -0
  27. package/dist/src/openrouter-models.js +78 -0
  28. package/dist/src/openrouter-scenario.d.ts +36 -0
  29. package/dist/src/openrouter-scenario.js +145 -0
  30. package/dist/src/openrouter-server.d.ts +20 -0
  31. package/dist/src/openrouter-server.js +144 -0
  32. package/dist/src/openrouter-stub.d.ts +8 -0
  33. package/dist/src/openrouter-stub.js +58 -0
  34. package/dist/src/openrouter-twin.d.ts +4 -0
  35. package/dist/src/openrouter-twin.js +1506 -0
  36. package/dist/src/openrouter-types.d.ts +50 -0
  37. package/dist/src/openrouter-types.js +1 -0
  38. package/dist/test-fixtures/openrouter-openapi-operations.SOURCE.md +16 -0
  39. package/dist/test-fixtures/openrouter-openapi-operations.json +1041 -0
  40. package/package.json +71 -0
  41. package/src/cli.ts +29 -0
  42. package/src/index.ts +108 -0
  43. package/src/openrouter-budget.ts +159 -0
  44. package/src/openrouter-capabilities.ts +861 -0
  45. package/src/openrouter-conformance.ts +60 -0
  46. package/src/openrouter-connector.ts +264 -0
  47. package/src/openrouter-local-generation.ts +207 -0
  48. package/src/openrouter-mirror-ui.ts +84 -0
  49. package/src/openrouter-models.ts +118 -0
  50. package/src/openrouter-scenario.ts +156 -0
  51. package/src/openrouter-server.ts +158 -0
  52. package/src/openrouter-stub.ts +60 -0
  53. package/src/openrouter-twin.ts +1441 -0
  54. package/src/openrouter-types.ts +49 -0
  55. package/test-fixtures/openrouter-openapi-operations.SOURCE.md +16 -0
  56. package/test-fixtures/openrouter-openapi-operations.json +1041 -0
@@ -0,0 +1,50 @@
1
+ import type { OpenRouterScenarioEngine } from './openrouter-scenario.js';
2
+ export type SseEvent = {
3
+ data?: Record<string, unknown>;
4
+ done?: boolean;
5
+ };
6
+ export type SseSink = (event: SseEvent) => void;
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
+ export type OpenRouterResponse = {
22
+ status: number;
23
+ body: unknown;
24
+ headers?: Record<string, string>;
25
+ };
26
+ export type ChatMessage = {
27
+ role: string;
28
+ content?: unknown;
29
+ tool_calls?: unknown;
30
+ cache_control?: unknown;
31
+ };
32
+ export type GenerationStat = {
33
+ id: string;
34
+ object: 'generation';
35
+ api_type: 'chat';
36
+ model: string;
37
+ provider_name: string;
38
+ created_at: string;
39
+ request_id: string;
40
+ finish_reason: string;
41
+ native_finish_reason: string;
42
+ total_cost: number;
43
+ tokens_prompt: number;
44
+ tokens_completion: number;
45
+ native_tokens_prompt: number;
46
+ native_tokens_completion: number;
47
+ usage: number;
48
+ app_id: number | null;
49
+ streamed: boolean;
50
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -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.