@volter/twin-openai 0.1.1 → 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.
- package/README.md +33 -30
- package/defaults/handlers.json +10 -0
- package/dist/defaults/handlers.json +10 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +29 -0
- package/dist/src/generated/surface.gen.json +1 -0
- package/dist/src/generated/ui.gen.json +1 -0
- package/dist/src/index.d.ts +19 -0
- package/dist/src/index.js +72 -0
- package/dist/src/manifest.d.ts +6 -0
- package/dist/src/manifest.js +323 -0
- package/dist/src/openai-budget.d.ts +53 -0
- package/dist/src/openai-budget.js +147 -0
- package/dist/src/openai-capabilities.d.ts +4 -0
- package/dist/src/openai-capabilities.js +1569 -0
- package/dist/src/openai-conformance.d.ts +13 -0
- package/dist/src/openai-conformance.js +116 -0
- package/dist/src/openai-connector.d.ts +86 -0
- package/dist/src/openai-connector.js +291 -0
- package/dist/src/openai-media.d.ts +43 -0
- package/dist/src/openai-media.js +257 -0
- package/dist/src/openai-models.d.ts +74 -0
- package/dist/src/openai-models.js +148 -0
- package/dist/src/openai-scenario.d.ts +51 -0
- package/dist/src/openai-scenario.js +166 -0
- package/dist/src/openai-server.d.ts +40 -0
- package/dist/src/openai-server.js +126 -0
- package/dist/src/openai-stub.d.ts +82 -0
- package/dist/src/openai-stub.js +256 -0
- package/dist/src/openai-twin.d.ts +182 -0
- package/dist/src/openai-twin.js +1117 -0
- package/dist/src/openai-types.d.ts +194 -0
- package/dist/src/openai-types.js +4 -0
- package/dist/src/openai-webhooks.d.ts +47 -0
- package/dist/src/openai-webhooks.js +99 -0
- package/dist/src/screens/api-keys.d.ts +16 -0
- package/dist/src/screens/api-keys.js +131 -0
- package/dist/src/screens/session.d.ts +22 -0
- package/dist/src/screens/session.js +115 -0
- package/dist/src/semantics/assistants.d.ts +2 -0
- package/dist/src/semantics/assistants.js +331 -0
- package/dist/src/semantics/audio.d.ts +2 -0
- package/dist/src/semantics/audio.js +27 -0
- package/dist/src/semantics/batches.d.ts +4 -0
- package/dist/src/semantics/batches.js +86 -0
- package/dist/src/semantics/chat-completions.d.ts +3 -0
- package/dist/src/semantics/chat-completions.js +58 -0
- package/dist/src/semantics/containers.d.ts +2 -0
- package/dist/src/semantics/containers.js +147 -0
- package/dist/src/semantics/embeddings.d.ts +2 -0
- package/dist/src/semantics/embeddings.js +13 -0
- package/dist/src/semantics/evals.d.ts +2 -0
- package/dist/src/semantics/evals.js +173 -0
- package/dist/src/semantics/files.d.ts +13 -0
- package/dist/src/semantics/files.js +59 -0
- package/dist/src/semantics/fine-tuning.d.ts +4 -0
- package/dist/src/semantics/fine-tuning.js +178 -0
- package/dist/src/semantics/images.d.ts +2 -0
- package/dist/src/semantics/images.js +18 -0
- package/dist/src/semantics/index.d.ts +8 -0
- package/dist/src/semantics/index.js +46 -0
- package/dist/src/semantics/models.d.ts +2 -0
- package/dist/src/semantics/models.js +34 -0
- package/dist/src/semantics/moderations.d.ts +2 -0
- package/dist/src/semantics/moderations.js +12 -0
- package/dist/src/semantics/organization.d.ts +2 -0
- package/dist/src/semantics/organization.js +67 -0
- package/dist/src/semantics/progress.d.ts +22 -0
- package/dist/src/semantics/progress.js +63 -0
- package/dist/src/semantics/responses.d.ts +3 -0
- package/dist/src/semantics/responses.js +153 -0
- package/dist/src/semantics/shared.d.ts +32 -0
- package/dist/src/semantics/shared.js +69 -0
- package/dist/src/semantics/uploads.d.ts +2 -0
- package/dist/src/semantics/uploads.js +84 -0
- package/dist/src/semantics/vector-stores.d.ts +2 -0
- package/dist/src/semantics/vector-stores.js +281 -0
- package/dist/test-fixtures/openai-openapi-operations.SOURCE.md +18 -0
- package/dist/test-fixtures/openai-openapi-operations.json +1849 -0
- package/package.json +21 -10
- package/src/cli.ts +9 -7
- package/src/generated/surface.gen.json +1 -0
- package/src/generated/ui.gen.json +1 -0
- package/src/index.ts +20 -10
- package/src/manifest.ts +343 -0
- package/src/openai-budget.ts +4 -4
- package/src/openai-capabilities.ts +177 -195
- package/src/openai-conformance.ts +1 -1
- package/src/openai-connector.ts +40 -43
- package/src/openai-media.ts +225 -0
- package/src/openai-models.ts +145 -15
- package/src/openai-scenario.ts +46 -10
- package/src/openai-server.ts +65 -108
- package/src/openai-stub.ts +54 -30
- package/src/openai-twin.ts +760 -1665
- package/src/openai-types.ts +24 -6
- package/src/openai-webhooks.ts +2 -1
- package/src/screens/api-keys.tsx +138 -0
- package/src/screens/session.tsx +131 -0
- package/src/semantics/assistants.ts +336 -0
- package/src/semantics/audio.ts +31 -0
- package/src/semantics/batches.ts +88 -0
- package/src/semantics/chat-completions.ts +66 -0
- package/src/semantics/containers.ts +151 -0
- package/src/semantics/embeddings.ts +19 -0
- package/src/semantics/evals.ts +182 -0
- package/src/semantics/files.ts +67 -0
- package/src/semantics/fine-tuning.ts +185 -0
- package/src/semantics/images.ts +23 -0
- package/src/semantics/index.ts +52 -0
- package/src/semantics/models.ts +41 -0
- package/src/semantics/moderations.ts +14 -0
- package/src/semantics/organization.ts +76 -0
- package/src/semantics/progress.ts +72 -0
- package/src/semantics/responses.ts +151 -0
- package/src/semantics/shared.ts +82 -0
- package/src/semantics/uploads.ts +92 -0
- package/src/semantics/vector-stores.ts +279 -0
- package/test-fixtures/openai-openapi-operations.SOURCE.md +4 -5
- 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.
|
|
4
|
-
"description": "Local OpenAI 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
|
-
".":
|
|
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.
|
|
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/
|
|
57
|
+
"@volter/world-core": "2.0.0"
|
|
50
58
|
},
|
|
51
59
|
"devDependencies": {
|
|
52
|
-
"@volter/
|
|
53
|
-
"@volter/
|
|
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
|
-
"
|
|
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
|
|
2
|
-
import { keepProcessAlive } from '@volter/
|
|
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 (
|
|
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/
|
|
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/
|
|
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
|
}
|