@volter/twin-openai 0.1.2 → 2.0.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 (120) hide show
  1. package/README.md +33 -30
  2. package/defaults/handlers.json +10 -0
  3. package/dist/defaults/handlers.json +10 -0
  4. package/dist/src/cli.d.ts +2 -0
  5. package/dist/src/cli.js +29 -0
  6. package/dist/src/generated/surface.gen.json +1 -0
  7. package/dist/src/generated/ui.gen.json +1 -0
  8. package/dist/src/index.d.ts +19 -0
  9. package/dist/src/index.js +72 -0
  10. package/dist/src/manifest.d.ts +6 -0
  11. package/dist/src/manifest.js +323 -0
  12. package/dist/src/openai-budget.d.ts +53 -0
  13. package/dist/src/openai-budget.js +147 -0
  14. package/dist/src/openai-capabilities.d.ts +4 -0
  15. package/dist/src/openai-capabilities.js +1569 -0
  16. package/dist/src/openai-conformance.d.ts +13 -0
  17. package/dist/src/openai-conformance.js +116 -0
  18. package/dist/src/openai-connector.d.ts +86 -0
  19. package/dist/src/openai-connector.js +291 -0
  20. package/dist/src/openai-media.d.ts +43 -0
  21. package/dist/src/openai-media.js +257 -0
  22. package/dist/src/openai-models.d.ts +74 -0
  23. package/dist/src/openai-models.js +148 -0
  24. package/dist/src/openai-scenario.d.ts +51 -0
  25. package/dist/src/openai-scenario.js +166 -0
  26. package/dist/src/openai-server.d.ts +40 -0
  27. package/dist/src/openai-server.js +126 -0
  28. package/dist/src/openai-stub.d.ts +82 -0
  29. package/dist/src/openai-stub.js +256 -0
  30. package/dist/src/openai-twin.d.ts +182 -0
  31. package/dist/src/openai-twin.js +1117 -0
  32. package/dist/src/openai-types.d.ts +194 -0
  33. package/dist/src/openai-types.js +4 -0
  34. package/dist/src/openai-webhooks.d.ts +47 -0
  35. package/dist/src/openai-webhooks.js +99 -0
  36. package/dist/src/screens/api-keys.d.ts +16 -0
  37. package/dist/src/screens/api-keys.js +131 -0
  38. package/dist/src/screens/session.d.ts +22 -0
  39. package/dist/src/screens/session.js +115 -0
  40. package/dist/src/semantics/assistants.d.ts +2 -0
  41. package/dist/src/semantics/assistants.js +331 -0
  42. package/dist/src/semantics/audio.d.ts +2 -0
  43. package/dist/src/semantics/audio.js +27 -0
  44. package/dist/src/semantics/batches.d.ts +4 -0
  45. package/dist/src/semantics/batches.js +86 -0
  46. package/dist/src/semantics/chat-completions.d.ts +3 -0
  47. package/dist/src/semantics/chat-completions.js +58 -0
  48. package/dist/src/semantics/containers.d.ts +2 -0
  49. package/dist/src/semantics/containers.js +147 -0
  50. package/dist/src/semantics/embeddings.d.ts +2 -0
  51. package/dist/src/semantics/embeddings.js +13 -0
  52. package/dist/src/semantics/evals.d.ts +2 -0
  53. package/dist/src/semantics/evals.js +173 -0
  54. package/dist/src/semantics/files.d.ts +13 -0
  55. package/dist/src/semantics/files.js +59 -0
  56. package/dist/src/semantics/fine-tuning.d.ts +4 -0
  57. package/dist/src/semantics/fine-tuning.js +178 -0
  58. package/dist/src/semantics/images.d.ts +2 -0
  59. package/dist/src/semantics/images.js +18 -0
  60. package/dist/src/semantics/index.d.ts +8 -0
  61. package/dist/src/semantics/index.js +46 -0
  62. package/dist/src/semantics/models.d.ts +2 -0
  63. package/dist/src/semantics/models.js +34 -0
  64. package/dist/src/semantics/moderations.d.ts +2 -0
  65. package/dist/src/semantics/moderations.js +12 -0
  66. package/dist/src/semantics/organization.d.ts +2 -0
  67. package/dist/src/semantics/organization.js +67 -0
  68. package/dist/src/semantics/progress.d.ts +22 -0
  69. package/dist/src/semantics/progress.js +63 -0
  70. package/dist/src/semantics/responses.d.ts +3 -0
  71. package/dist/src/semantics/responses.js +153 -0
  72. package/dist/src/semantics/shared.d.ts +32 -0
  73. package/dist/src/semantics/shared.js +69 -0
  74. package/dist/src/semantics/uploads.d.ts +2 -0
  75. package/dist/src/semantics/uploads.js +84 -0
  76. package/dist/src/semantics/vector-stores.d.ts +2 -0
  77. package/dist/src/semantics/vector-stores.js +281 -0
  78. package/dist/test-fixtures/openai-openapi-operations.SOURCE.md +18 -0
  79. package/dist/test-fixtures/openai-openapi-operations.json +1849 -0
  80. package/package.json +21 -10
  81. package/src/cli.ts +9 -7
  82. package/src/generated/surface.gen.json +1 -0
  83. package/src/generated/ui.gen.json +1 -0
  84. package/src/index.ts +20 -10
  85. package/src/manifest.ts +343 -0
  86. package/src/openai-budget.ts +4 -4
  87. package/src/openai-capabilities.ts +177 -195
  88. package/src/openai-conformance.ts +1 -1
  89. package/src/openai-connector.ts +40 -43
  90. package/src/openai-media.ts +225 -0
  91. package/src/openai-models.ts +145 -15
  92. package/src/openai-scenario.ts +46 -10
  93. package/src/openai-server.ts +65 -108
  94. package/src/openai-stub.ts +54 -30
  95. package/src/openai-twin.ts +760 -1665
  96. package/src/openai-types.ts +24 -6
  97. package/src/openai-webhooks.ts +2 -1
  98. package/src/screens/api-keys.tsx +138 -0
  99. package/src/screens/session.tsx +131 -0
  100. package/src/semantics/assistants.ts +336 -0
  101. package/src/semantics/audio.ts +31 -0
  102. package/src/semantics/batches.ts +88 -0
  103. package/src/semantics/chat-completions.ts +66 -0
  104. package/src/semantics/containers.ts +151 -0
  105. package/src/semantics/embeddings.ts +19 -0
  106. package/src/semantics/evals.ts +182 -0
  107. package/src/semantics/files.ts +67 -0
  108. package/src/semantics/fine-tuning.ts +185 -0
  109. package/src/semantics/images.ts +23 -0
  110. package/src/semantics/index.ts +52 -0
  111. package/src/semantics/models.ts +41 -0
  112. package/src/semantics/moderations.ts +14 -0
  113. package/src/semantics/organization.ts +76 -0
  114. package/src/semantics/progress.ts +72 -0
  115. package/src/semantics/responses.ts +151 -0
  116. package/src/semantics/shared.ts +82 -0
  117. package/src/semantics/uploads.ts +92 -0
  118. package/src/semantics/vector-stores.ts +279 -0
  119. package/test-fixtures/openai-openapi-operations.SOURCE.md +4 -5
  120. package/test-fixtures/openai-openapi-operations.json +224 -1334
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@volter/twin-openai",
3
- "version": "0.1.2",
4
- "description": "Local OpenAI twin \u2014 a faithful, stateful local OpenAI API your real `openai` SDK talks to unmodified. The model is stubbed (deterministic) and embeddings are deterministic pseudo-vectors, but the protocol envelope (chat completions/streaming/tool_calls, the Responses API, embeddings, models, files, batches, moderations, fine-tuning, vector stores) is vendor-faithful. Built on @volter/twin.",
3
+ "version": "2.0.0",
4
+ "description": "Local OpenAI twin — a faithful, stateful local OpenAI API your real `openai` SDK talks to unmodified. The model is stubbed (deterministic) and embeddings are deterministic pseudo-vectors, but the protocol envelope (chat completions/streaming/tool_calls, the Responses API, embeddings, models, files, batches, moderations, fine-tuning, vector stores) is vendor-faithful. Built on @volter/world-core.",
5
5
  "keywords": [
6
6
  "twin",
7
7
  "local",
@@ -21,12 +21,14 @@
21
21
  "license": "Apache-2.0",
22
22
  "files": [
23
23
  "src",
24
+ "defaults",
24
25
  "client",
25
26
  "test-fixtures",
26
27
  "README.md",
27
28
  "LICENSE",
28
29
  "!**/*.test.ts",
29
- "!**/*.test.tsx"
30
+ "!**/*.test.tsx",
31
+ "dist"
30
32
  ],
31
33
  "repository": {
32
34
  "type": "git",
@@ -36,27 +38,36 @@
36
38
  "homepage": "https://github.com/volter-ai/twin/tree/main/packages/twin/openai#readme",
37
39
  "type": "module",
38
40
  "exports": {
39
- ".": "./src/index.ts"
41
+ ".": {
42
+ "types": "./dist/src/index.d.ts",
43
+ "default": "./dist/src/index.js"
44
+ }
40
45
  },
41
46
  "bin": {
42
- "world-openai": "src/cli.ts"
47
+ "world-openai": "dist/src/cli.js"
43
48
  },
44
49
  "scripts": {
45
50
  "test": "bun test src/*.test.ts",
46
- "typecheck": "tsc --noEmit"
51
+ "typecheck": "tsc --noEmit",
52
+ "build": "node ../../../scripts/publish/build.mjs",
53
+ "prepack": "node ../../../scripts/publish/prepare-publish.mjs prepack",
54
+ "postpack": "node ../../../scripts/publish/prepare-publish.mjs postpack"
47
55
  },
48
56
  "peerDependencies": {
49
- "@volter/twin": "^0.1.2"
57
+ "@volter/world-core": "2.0.0"
50
58
  },
51
59
  "devDependencies": {
52
- "@volter/twin": "workspace:*",
53
- "@volter/twin-tooling": "workspace:*",
60
+ "@volter/world-core": "2.0.0",
61
+ "@volter/world-tooling": "0.1.0",
54
62
  "openai": "^4.104.0",
55
63
  "@types/bun": "^1.2.20",
56
64
  "@types/node": "^24.0.0",
57
65
  "typescript": "^5.9.0"
58
66
  },
59
67
  "engines": {
60
- "bun": ">=1.2.0"
68
+ "node": ">=22.3"
69
+ },
70
+ "dependencies": {
71
+ "@volter/world-ui": "0.1.0"
61
72
  }
62
73
  }
package/src/cli.ts CHANGED
@@ -1,26 +1,28 @@
1
- #!/usr/bin/env bun
2
- import { keepProcessAlive } from '@volter/twin/lifecycle';
1
+ #!/usr/bin/env node
2
+ import { keepProcessAlive } from '@volter/world-core/lifecycle';
3
3
  // world-openai CLI: serve the OpenAI API twin or run conformance. OpenAI is an API-first
4
- // vendor with no meaningful product UI worth mirroring (ARCHITECTURE.md C1b), so this pack
4
+ // vendor with no meaningful product UI worth mirroring (docs/contributing/architecture.md C1b), so this pack
5
5
  // ships no mirror.
6
- import { hasFlag, optionValue } from '@volter/twin/args';
6
+ import { hasFlag, optionValue } from '@volter/world-core/args';
7
+ import './index.ts'; // the pack registers itself on load (protocol 2)
7
8
  import { createOpenAITwinServer } from './openai-server.ts';
8
9
 
9
10
  const [cmd, ...rest] = process.argv.slice(2);
10
11
  const port = Number(optionValue(rest, '--port', '0')) || undefined;
11
12
  const root = optionValue(rest, '--root') || undefined;
12
13
  const readOnly = hasFlag(rest, '--read-only'); // a twin accepts writes unless started read-only
14
+ const scenario = optionValue(rest, '--scenario') || undefined; // scripted completions (JSON file)
13
15
 
14
16
  if (cmd === 'serve') {
15
- const s = createOpenAITwinServer({ readOnly, ...(root ? { root } : {}), ...(port ? { port } : {}) });
17
+ const s = await createOpenAITwinServer({ readOnly, ...(root ? { root } : {}), ...(port ? { port } : {}), ...(scenario ? { scenarioPath: scenario } : {}) });
16
18
  process.stdout.write(`openai twin (chat/responses/embeddings output is a deterministic stub)${readOnly ? ' [read-only]' : ''} at http://127.0.0.1:${s.port}\n`);
17
19
  await keepProcessAlive();
18
20
  } else if (cmd === 'conformance') {
19
- // dev-only; lazy so the bin runs without @volter/twin-tooling
21
+ // dev-only; lazy so the bin runs without @volter/world-tooling
20
22
  const { checkOpenAIConformance } = await import('./openai-conformance.ts');
21
23
  const report = await checkOpenAIConformance({ ...(root ? { root } : {}) });
22
24
  process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
23
25
  if (!report.ok) process.exitCode = 1;
24
26
  } else {
25
- process.stdout.write('Usage: world-openai serve|conformance [--port N] [--root DIR] [--read-only]\n');
27
+ process.stdout.write('Usage: world-openai serve|conformance [--port N] [--root DIR] [--read-only] [--scenario FILE]\n');
26
28
  }