@valni/cli-darwin-x64 0.0.0-stage → 0.1.2
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 +53 -0
- package/package.json +18 -5
- package/runtime/LICENSE +53 -0
- package/runtime/README.md +674 -0
- package/runtime/assets/clankolas.png +0 -0
- package/runtime/docs/extensions.md +2910 -0
- package/runtime/docs/json.md +82 -0
- package/runtime/docs/models.md +540 -0
- package/runtime/docs/packages.md +228 -0
- package/runtime/docs/rpc.md +1480 -0
- package/runtime/docs/sdk.md +1183 -0
- package/runtime/docs/session-format.md +422 -0
- package/runtime/docs/settings.md +315 -0
- package/runtime/docs/shell-aliases.md +13 -0
- package/runtime/docs/terminal-setup.md +142 -0
- package/runtime/docs/termux.md +127 -0
- package/runtime/docs/tmux.md +63 -0
- package/runtime/docs/tui.md +927 -0
- package/runtime/docs/windows.md +17 -0
- package/runtime/examples/README.md +25 -0
- package/runtime/examples/extensions/README.md +212 -0
- package/runtime/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/runtime/examples/extensions/bash-spawn-hook.ts +30 -0
- package/runtime/examples/extensions/bookmark.ts +50 -0
- package/runtime/examples/extensions/border-status-editor.ts +145 -0
- package/runtime/examples/extensions/built-in-tool-renderer.ts +249 -0
- package/runtime/examples/extensions/claude-rules.ts +86 -0
- package/runtime/examples/extensions/commands.ts +72 -0
- package/runtime/examples/extensions/confirm-destructive.ts +59 -0
- package/runtime/examples/extensions/custom-footer.ts +64 -0
- package/runtime/examples/extensions/custom-header.ts +73 -0
- package/runtime/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/runtime/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/runtime/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/runtime/examples/extensions/dirty-repo-guard.ts +56 -0
- package/runtime/examples/extensions/doom-overlay/README.md +46 -0
- package/runtime/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/runtime/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/runtime/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/runtime/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/runtime/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/runtime/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/runtime/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/runtime/examples/extensions/doom-overlay/index.ts +74 -0
- package/runtime/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/runtime/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/runtime/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/runtime/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/runtime/examples/extensions/dynamic-resources/index.ts +15 -0
- package/runtime/examples/extensions/dynamic-tools.ts +74 -0
- package/runtime/examples/extensions/entry-renderer.ts +41 -0
- package/runtime/examples/extensions/event-bus.ts +43 -0
- package/runtime/examples/extensions/file-trigger.ts +41 -0
- package/runtime/examples/extensions/git-checkpoint.ts +53 -0
- package/runtime/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/runtime/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/runtime/examples/extensions/gondolin/index.ts +531 -0
- package/runtime/examples/extensions/gondolin/package-lock.json +185 -0
- package/runtime/examples/extensions/gondolin/package.json +19 -0
- package/runtime/examples/extensions/hello.ts +26 -0
- package/runtime/examples/extensions/hidden-thinking-label.ts +53 -0
- package/runtime/examples/extensions/inline-bash.ts +94 -0
- package/runtime/examples/extensions/input-transform-streaming.ts +39 -0
- package/runtime/examples/extensions/input-transform.ts +43 -0
- package/runtime/examples/extensions/interactive-shell.ts +196 -0
- package/runtime/examples/extensions/mac-system-theme.ts +47 -0
- package/runtime/examples/extensions/message-renderer.ts +59 -0
- package/runtime/examples/extensions/minimal-mode.ts +426 -0
- package/runtime/examples/extensions/modal-editor.ts +85 -0
- package/runtime/examples/extensions/model-status.ts +31 -0
- package/runtime/examples/extensions/notify.ts +55 -0
- package/runtime/examples/extensions/overlay-qa-tests.ts +1450 -0
- package/runtime/examples/extensions/overlay-test.ts +153 -0
- package/runtime/examples/extensions/permission-gate.ts +34 -0
- package/runtime/examples/extensions/pirate.ts +47 -0
- package/runtime/examples/extensions/plan-mode/README.md +66 -0
- package/runtime/examples/extensions/plan-mode/index.ts +390 -0
- package/runtime/examples/extensions/plan-mode/utils.ts +168 -0
- package/runtime/examples/extensions/preset.ts +436 -0
- package/runtime/examples/extensions/project-trust.ts +64 -0
- package/runtime/examples/extensions/prompt-customizer.ts +97 -0
- package/runtime/examples/extensions/protected-paths.ts +30 -0
- package/runtime/examples/extensions/provider-payload.ts +18 -0
- package/runtime/examples/extensions/question.ts +278 -0
- package/runtime/examples/extensions/questionnaire.ts +440 -0
- package/runtime/examples/extensions/rainbow-editor.ts +88 -0
- package/runtime/examples/extensions/reload-runtime.ts +37 -0
- package/runtime/examples/extensions/rpc-demo.ts +118 -0
- package/runtime/examples/extensions/sandbox/index.ts +321 -0
- package/runtime/examples/extensions/sandbox/package-lock.json +92 -0
- package/runtime/examples/extensions/sandbox/package.json +19 -0
- package/runtime/examples/extensions/send-user-message.ts +97 -0
- package/runtime/examples/extensions/session-name.ts +27 -0
- package/runtime/examples/extensions/shutdown-command.ts +63 -0
- package/runtime/examples/extensions/snake.ts +343 -0
- package/runtime/examples/extensions/space-invaders.ts +560 -0
- package/runtime/examples/extensions/ssh.ts +220 -0
- package/runtime/examples/extensions/status-line.ts +32 -0
- package/runtime/examples/extensions/structured-output.ts +65 -0
- package/runtime/examples/extensions/subagent/README.md +175 -0
- package/runtime/examples/extensions/subagent/agents/planner.md +37 -0
- package/runtime/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/runtime/examples/extensions/subagent/agents/scout.md +50 -0
- package/runtime/examples/extensions/subagent/agents/worker.md +24 -0
- package/runtime/examples/extensions/subagent/agents.ts +126 -0
- package/runtime/examples/extensions/subagent/index.ts +1009 -0
- package/runtime/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/runtime/examples/extensions/subagent/prompts/implement.md +10 -0
- package/runtime/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/runtime/examples/extensions/system-prompt-header.ts +17 -0
- package/runtime/examples/extensions/tic-tac-toe.ts +1008 -0
- package/runtime/examples/extensions/timed-confirm.ts +70 -0
- package/runtime/examples/extensions/titlebar-spinner.ts +58 -0
- package/runtime/examples/extensions/todo.ts +297 -0
- package/runtime/examples/extensions/tool-override.ts +144 -0
- package/runtime/examples/extensions/tools.ts +146 -0
- package/runtime/examples/extensions/trigger-compact.ts +50 -0
- package/runtime/examples/extensions/truncated-tool.ts +195 -0
- package/runtime/examples/extensions/widget-placement.ts +9 -0
- package/runtime/examples/extensions/with-deps/index.ts +32 -0
- package/runtime/examples/extensions/with-deps/package-lock.json +31 -0
- package/runtime/examples/extensions/with-deps/package.json +22 -0
- package/runtime/examples/extensions/working-indicator.ts +123 -0
- package/runtime/examples/extensions/working-message-test.ts +25 -0
- package/runtime/examples/rpc-extension-ui.ts +632 -0
- package/runtime/examples/sdk/01-minimal.ts +26 -0
- package/runtime/examples/sdk/02-custom-model.ts +43 -0
- package/runtime/examples/sdk/03-custom-prompt.ts +70 -0
- package/runtime/examples/sdk/04-skills.ts +55 -0
- package/runtime/examples/sdk/05-tools.ts +48 -0
- package/runtime/examples/sdk/06-extensions.ts +94 -0
- package/runtime/examples/sdk/07-context-files.ts +42 -0
- package/runtime/examples/sdk/08-prompt-templates.ts +51 -0
- package/runtime/examples/sdk/09-api-keys-and-oauth.ts +34 -0
- package/runtime/examples/sdk/10-settings.ts +53 -0
- package/runtime/examples/sdk/11-sessions.ts +52 -0
- package/runtime/examples/sdk/12-full-control.ts +71 -0
- package/runtime/examples/sdk/13-session-runtime.ts +67 -0
- package/runtime/examples/sdk/README.md +140 -0
- package/runtime/export-html/ansi-to-html.js +249 -0
- package/runtime/export-html/index.js +226 -0
- package/runtime/export-html/template.css +1066 -0
- package/runtime/export-html/template.html +55 -0
- package/runtime/export-html/template.js +1864 -0
- package/runtime/export-html/tool-renderer.js +108 -0
- package/runtime/export-html/vendor/highlight.min.js +1213 -0
- package/runtime/export-html/vendor/marked.min.js +78 -0
- package/runtime/extensions/pi-switchboard/.github/workflows/ci.yml +51 -0
- package/runtime/extensions/pi-switchboard/LICENSE +22 -0
- package/runtime/extensions/pi-switchboard/README.md +85 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/catalog.ts +183 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/config.ts +97 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/connections.ts +386 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/constants.ts +12 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/device-auth.ts +127 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/envelope.ts +199 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/errors.ts +180 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/index.ts +125 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/participant.ts +17 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/sessionStream.ts +131 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/toolProxy.ts +136 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/tools.ts +16 -0
- package/runtime/extensions/pi-switchboard/extensions/switchboard/types.ts +37 -0
- package/runtime/extensions/pi-switchboard/package.json +30 -0
- package/runtime/extensions/pi-switchboard/tsconfig.json +13 -0
- package/runtime/extensions/switchboard-local/.github/workflows/ci.yml +80 -0
- package/runtime/extensions/switchboard-local/.github/workflows/release.yml +46 -0
- package/runtime/extensions/switchboard-local/README.md +98 -0
- package/runtime/extensions/switchboard-local/extensions/local/engine.ts +28 -0
- package/runtime/extensions/switchboard-local/extensions/local/engines/gguf.ts +324 -0
- package/runtime/extensions/switchboard-local/extensions/local/engines/llamaBuild.ts +62 -0
- package/runtime/extensions/switchboard-local/extensions/local/engines/mlx.ts +245 -0
- package/runtime/extensions/switchboard-local/extensions/local/engines/select.ts +38 -0
- package/runtime/extensions/switchboard-local/extensions/local/engines/support.ts +151 -0
- package/runtime/extensions/switchboard-local/extensions/local/hf.ts +106 -0
- package/runtime/extensions/switchboard-local/extensions/local/index.ts +67 -0
- package/runtime/extensions/switchboard-local/extensions/local/nativeStream.ts +602 -0
- package/runtime/extensions/switchboard-local/extensions/local/paths.ts +44 -0
- package/runtime/extensions/switchboard-local/extensions/local/provider.ts +57 -0
- package/runtime/extensions/switchboard-local/extensions/local/store.ts +82 -0
- package/runtime/extensions/switchboard-local/extensions/local/ui.ts +60 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/apiTypes.js +74 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/client.js +292 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/deviceAuth.js +155 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/errors.js +95 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/index.js +8 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/messages.js +253 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/models.js +19 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/native.js +886 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/wire.js +85 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/package.json +39 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/package.json +29 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/anthropic.ts +127 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/google.ts +111 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/index.ts +8 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/modelRecord.test.ts +25 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/modelRecord.ts +57 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/openaiGeneric.ts +103 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/openaiPro.ts +89 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/profile.ts +120 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/routing.test.ts +82 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/routing.ts +74 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.google.test.ts +137 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.openai.test.ts +241 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.test.ts +174 -0
- package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.ts +438 -0
- package/runtime/extensions/switchboard-local/package.json +34 -0
- package/runtime/extensions/switchboard-local/tsconfig.json +13 -0
- package/runtime/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/runtime/node_modules/@mariozechner/clipboard/.yarnrc.yml +1 -0
- package/runtime/node_modules/@mariozechner/clipboard/Cargo.toml +45 -0
- package/runtime/node_modules/@mariozechner/clipboard/README.md +60 -0
- package/runtime/node_modules/@mariozechner/clipboard/build.rs +5 -0
- package/runtime/node_modules/@mariozechner/clipboard/clipboard.darwin-x64.node +0 -0
- package/runtime/node_modules/@mariozechner/clipboard/exp.ts +12 -0
- package/runtime/node_modules/@mariozechner/clipboard/index.js +606 -0
- package/runtime/node_modules/@mariozechner/clipboard/package.json +56 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/common.rs +307 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/mod.rs +93 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/ios.rs +313 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/macos.rs +471 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/mod.rs +252 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/wayland.rs +431 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/win.rs +712 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/x11.rs +916 -0
- package/runtime/node_modules/@mariozechner/clipboard/src/lib.rs +194 -0
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/README.md +3 -0
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/clipboard.darwin-x64.node +0 -0
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/package.json +22 -0
- package/runtime/package.json +104 -0
- package/runtime/photon_rs_bg.wasm +0 -0
- package/runtime/theme/dark.json +87 -0
- package/runtime/theme/light.json +86 -0
- package/runtime/theme/theme-schema.json +340 -0
- package/runtime/valni +4 -0
- package/README.md +0 -3
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
function shown(value) {
|
|
2
|
+
if (value === undefined)
|
|
3
|
+
return "undefined";
|
|
4
|
+
const encoded = JSON.stringify(value);
|
|
5
|
+
return encoded === undefined ? String(value) : encoded;
|
|
6
|
+
}
|
|
7
|
+
function typeName(value) {
|
|
8
|
+
if (value === null)
|
|
9
|
+
return "null";
|
|
10
|
+
if (Array.isArray(value))
|
|
11
|
+
return "array";
|
|
12
|
+
return typeof value;
|
|
13
|
+
}
|
|
14
|
+
export function mapping(value, parent) {
|
|
15
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
16
|
+
throw new Error(`${parent}: expected object, got ${typeName(value)}`);
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
export function string(wire, key, parent) {
|
|
21
|
+
const value = wire[key];
|
|
22
|
+
if (typeof value !== "string") {
|
|
23
|
+
throw new Error(`${parent}.${key}: expected string, got ${shown(value)}`);
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
export function optionalString(wire, key, parent) {
|
|
28
|
+
const value = wire[key];
|
|
29
|
+
if (value === null || value === undefined)
|
|
30
|
+
return null;
|
|
31
|
+
if (typeof value !== "string") {
|
|
32
|
+
throw new Error(`${parent}.${key}: expected string, got ${shown(value)}`);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
export function integer(wire, key, parent) {
|
|
37
|
+
const value = wire[key];
|
|
38
|
+
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
39
|
+
throw new Error(`${parent}.${key}: expected integer, got ${shown(value)}`);
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
export function optionalInteger(wire, key, parent) {
|
|
44
|
+
const value = wire[key];
|
|
45
|
+
if (value === null || value === undefined)
|
|
46
|
+
return null;
|
|
47
|
+
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
48
|
+
throw new Error(`${parent}.${key}: expected integer, got ${shown(value)}`);
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
export function array(wire, key, parent) {
|
|
53
|
+
const value = wire[key];
|
|
54
|
+
if (!Array.isArray(value)) {
|
|
55
|
+
throw new Error(`${parent}.${key}: expected array, got ${shown(value)}`);
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
export function optionalArray(wire, key, parent) {
|
|
60
|
+
const value = wire[key];
|
|
61
|
+
if (value === null || value === undefined)
|
|
62
|
+
return null;
|
|
63
|
+
if (!Array.isArray(value)) {
|
|
64
|
+
throw new Error(`${parent}.${key}: expected array, got ${shown(value)}`);
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
export function stringArray(wire, key, parent) {
|
|
69
|
+
const value = array(wire, key, parent);
|
|
70
|
+
for (const item of value) {
|
|
71
|
+
if (typeof item !== "string") {
|
|
72
|
+
throw new Error(`${parent}.${key}: expected array of strings, got ${shown(item)}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
export function optionalMapping(wire, key, parent) {
|
|
78
|
+
const value = wire[key];
|
|
79
|
+
if (value === null || value === undefined)
|
|
80
|
+
return null;
|
|
81
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
82
|
+
throw new Error(`${parent}.${key}: expected object, got ${shown(value)}`);
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@valni/switchboard",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript client for Switchboard.",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.build.json",
|
|
24
|
+
"prepare": "npm run build",
|
|
25
|
+
"test": "vitest run"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/Valni-Labs/switchboard-ts.git"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@valni/switchboard-native": "git+https://github.com/Valni-Labs/SwitchboardNative.git#1343e11248ce477220b839366a5fc586aef4ce09"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^22.15.0",
|
|
36
|
+
"typescript": "^5.8.0",
|
|
37
|
+
"vitest": "^3.1.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@valni/switchboard-native",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The Switchboard native wire contract: TypeScript source of truth plus generated language bindings.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"codegen:swift": "node codegen/generate-swift.mjs",
|
|
17
|
+
"codegen:python": "node codegen/generate-python.mjs"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^6.0.3",
|
|
21
|
+
"vitest": "^2.1.9"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/Valni-Labs/SwitchboardNative.git"
|
|
26
|
+
},
|
|
27
|
+
"license": "UNLICENSED",
|
|
28
|
+
"private": true
|
|
29
|
+
}
|
package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/anthropic.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export interface AnthropicCacheControl {
|
|
2
|
+
type: 'ephemeral';
|
|
3
|
+
ttl?: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface AnthropicImageSource {
|
|
7
|
+
type: 'base64' | 'url';
|
|
8
|
+
media_type?: string;
|
|
9
|
+
data?: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type AnthropicContentBlock =
|
|
14
|
+
| { type: 'text'; text: string; cache_control?: AnthropicCacheControl }
|
|
15
|
+
| { type: 'image'; source: AnthropicImageSource; cache_control?: AnthropicCacheControl }
|
|
16
|
+
| { type: 'tool_use'; id: string; name: string; input: unknown; cache_control?: AnthropicCacheControl }
|
|
17
|
+
| {
|
|
18
|
+
type: 'tool_result';
|
|
19
|
+
tool_use_id: string;
|
|
20
|
+
content: string | AnthropicContentBlock[];
|
|
21
|
+
is_error?: boolean;
|
|
22
|
+
cache_control?: AnthropicCacheControl;
|
|
23
|
+
}
|
|
24
|
+
| { type: 'thinking'; thinking: string; signature: string };
|
|
25
|
+
|
|
26
|
+
export interface AnthropicMessage {
|
|
27
|
+
role: 'user' | 'assistant';
|
|
28
|
+
content: string | AnthropicContentBlock[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface AnthropicSystemBlock {
|
|
32
|
+
type: 'text';
|
|
33
|
+
text: string;
|
|
34
|
+
cache_control?: AnthropicCacheControl;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type AnthropicSystem = string | AnthropicSystemBlock[];
|
|
38
|
+
|
|
39
|
+
export interface AnthropicTool {
|
|
40
|
+
name: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
input_schema: Record<string, unknown>;
|
|
43
|
+
cache_control?: AnthropicCacheControl;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type AnthropicToolChoice =
|
|
47
|
+
| { type: 'auto' }
|
|
48
|
+
| { type: 'any' }
|
|
49
|
+
| { type: 'none' }
|
|
50
|
+
| { type: 'tool'; name: string };
|
|
51
|
+
|
|
52
|
+
export type AnthropicThinking =
|
|
53
|
+
| { type: 'adaptive'; display?: 'summarized' | 'omitted' }
|
|
54
|
+
| { type: 'enabled'; budget_tokens: number }
|
|
55
|
+
| { type: 'disabled' };
|
|
56
|
+
|
|
57
|
+
export type AnthropicEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
58
|
+
|
|
59
|
+
export interface AnthropicOutputFormat {
|
|
60
|
+
type: 'json_schema';
|
|
61
|
+
schema: Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface AnthropicOutputConfig {
|
|
65
|
+
effort?: AnthropicEffort;
|
|
66
|
+
format?: AnthropicOutputFormat;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface AnthropicMetadata {
|
|
70
|
+
user_id?: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface AnthropicMessagesRequest {
|
|
74
|
+
model: string;
|
|
75
|
+
messages: AnthropicMessage[];
|
|
76
|
+
max_tokens: number;
|
|
77
|
+
system?: AnthropicSystem;
|
|
78
|
+
temperature?: number;
|
|
79
|
+
top_p?: number;
|
|
80
|
+
top_k?: number;
|
|
81
|
+
stop_sequences?: string[];
|
|
82
|
+
stream?: boolean;
|
|
83
|
+
tools?: AnthropicTool[];
|
|
84
|
+
tool_choice?: AnthropicToolChoice;
|
|
85
|
+
thinking?: AnthropicThinking;
|
|
86
|
+
output_config?: AnthropicOutputConfig;
|
|
87
|
+
metadata?: AnthropicMetadata;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface AnthropicUsage {
|
|
91
|
+
input_tokens: number;
|
|
92
|
+
output_tokens: number;
|
|
93
|
+
cache_creation_input_tokens?: number;
|
|
94
|
+
cache_read_input_tokens?: number;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type AnthropicResponseContentBlock =
|
|
98
|
+
| { type: 'text'; text: string }
|
|
99
|
+
| { type: 'tool_use'; id: string; name: string; input: unknown }
|
|
100
|
+
| { type: 'thinking'; thinking: string; signature: string };
|
|
101
|
+
|
|
102
|
+
export interface AnthropicMessageResponse {
|
|
103
|
+
id: string;
|
|
104
|
+
type: 'message';
|
|
105
|
+
role: 'assistant';
|
|
106
|
+
model: string;
|
|
107
|
+
content: AnthropicResponseContentBlock[];
|
|
108
|
+
stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'refusal' | null;
|
|
109
|
+
stop_sequence: string | null;
|
|
110
|
+
usage: AnthropicUsage;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type AnthropicBlockDelta =
|
|
114
|
+
| { type: 'text_delta'; text: string }
|
|
115
|
+
| { type: 'input_json_delta'; partial_json: string }
|
|
116
|
+
| { type: 'thinking_delta'; thinking: string }
|
|
117
|
+
| { type: 'signature_delta'; signature: string };
|
|
118
|
+
|
|
119
|
+
export type AnthropicStreamEvent =
|
|
120
|
+
| { type: 'message_start'; message: { id: string; role: 'assistant'; model: string; usage: AnthropicUsage } }
|
|
121
|
+
| { type: 'content_block_start'; index: number; content_block: AnthropicResponseContentBlock }
|
|
122
|
+
| { type: 'content_block_delta'; index: number; delta: AnthropicBlockDelta }
|
|
123
|
+
| { type: 'content_block_stop'; index: number }
|
|
124
|
+
| { type: 'message_delta'; delta: { stop_reason?: string; stop_sequence?: string | null }; usage: { output_tokens: number } }
|
|
125
|
+
| { type: 'message_stop' }
|
|
126
|
+
| { type: 'ping' }
|
|
127
|
+
| { type: 'error'; error: { type: string; message: string } };
|
package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/google.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export interface GoogleInlineData {
|
|
2
|
+
mimeType: string;
|
|
3
|
+
data: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface GoogleFileData {
|
|
7
|
+
mimeType?: string;
|
|
8
|
+
fileUri: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type GooglePart =
|
|
12
|
+
| { text: string }
|
|
13
|
+
| { inlineData: GoogleInlineData }
|
|
14
|
+
| { fileData: GoogleFileData }
|
|
15
|
+
| { functionCall: { name: string; args: Record<string, unknown> } }
|
|
16
|
+
| { functionResponse: { name: string; response: Record<string, unknown> } };
|
|
17
|
+
|
|
18
|
+
export interface GoogleContent {
|
|
19
|
+
role: 'user' | 'model';
|
|
20
|
+
parts: GooglePart[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface GoogleSystemInstruction {
|
|
24
|
+
parts: GooglePart[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface GoogleFunctionDeclaration {
|
|
28
|
+
name: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
parameters?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface GoogleTool {
|
|
34
|
+
functionDeclarations?: GoogleFunctionDeclaration[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type GoogleFunctionCallingMode = 'AUTO' | 'ANY' | 'NONE';
|
|
38
|
+
|
|
39
|
+
export interface GoogleFunctionCallingConfig {
|
|
40
|
+
mode?: GoogleFunctionCallingMode;
|
|
41
|
+
allowedFunctionNames?: string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface GoogleToolConfig {
|
|
45
|
+
functionCallingConfig?: GoogleFunctionCallingConfig;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface GoogleThinkingConfig {
|
|
49
|
+
thinkingBudget?: number;
|
|
50
|
+
includeThoughts?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface GoogleGenerationConfig {
|
|
54
|
+
temperature?: number;
|
|
55
|
+
topP?: number;
|
|
56
|
+
topK?: number;
|
|
57
|
+
maxOutputTokens?: number;
|
|
58
|
+
stopSequences?: string[];
|
|
59
|
+
candidateCount?: number;
|
|
60
|
+
responseMimeType?: string;
|
|
61
|
+
responseSchema?: Record<string, unknown>;
|
|
62
|
+
thinkingConfig?: GoogleThinkingConfig;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface GoogleSafetySetting {
|
|
66
|
+
category: string;
|
|
67
|
+
threshold: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface GoogleGenerateContentRequest {
|
|
71
|
+
model: string;
|
|
72
|
+
contents: GoogleContent[];
|
|
73
|
+
systemInstruction?: GoogleSystemInstruction;
|
|
74
|
+
tools?: GoogleTool[];
|
|
75
|
+
toolConfig?: GoogleToolConfig;
|
|
76
|
+
generationConfig?: GoogleGenerationConfig;
|
|
77
|
+
safetySettings?: GoogleSafetySetting[];
|
|
78
|
+
stream?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface GoogleUsageMetadata {
|
|
82
|
+
promptTokenCount?: number;
|
|
83
|
+
candidatesTokenCount?: number;
|
|
84
|
+
thoughtsTokenCount?: number;
|
|
85
|
+
cachedContentTokenCount?: number;
|
|
86
|
+
totalTokenCount?: number;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type GoogleFinishReason =
|
|
90
|
+
| 'STOP'
|
|
91
|
+
| 'MAX_TOKENS'
|
|
92
|
+
| 'SAFETY'
|
|
93
|
+
| 'RECITATION'
|
|
94
|
+
| 'BLOCKLIST'
|
|
95
|
+
| 'PROHIBITED_CONTENT'
|
|
96
|
+
| 'SPII'
|
|
97
|
+
| 'MALFORMED_FUNCTION_CALL'
|
|
98
|
+
| 'OTHER';
|
|
99
|
+
|
|
100
|
+
export interface GoogleCandidate {
|
|
101
|
+
content?: GoogleContent;
|
|
102
|
+
finishReason?: GoogleFinishReason;
|
|
103
|
+
index?: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface GoogleGenerateContentResponse {
|
|
107
|
+
candidates?: GoogleCandidate[];
|
|
108
|
+
usageMetadata?: GoogleUsageMetadata;
|
|
109
|
+
modelVersion?: string;
|
|
110
|
+
responseId?: string;
|
|
111
|
+
}
|
package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './routing.js';
|
|
2
|
+
export * from './anthropic.js';
|
|
3
|
+
export * from './google.js';
|
|
4
|
+
export * from './openaiGeneric.js';
|
|
5
|
+
export * from './openaiPro.js';
|
|
6
|
+
export * from './profile.js';
|
|
7
|
+
export * from './modelRecord.js';
|
|
8
|
+
export * from './validateConfig.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import type { AnthropicProfile, GoogleProfile, OpenAIGenericProfile, OpenAIProProfile } from './profile.js';
|
|
3
|
+
import { profileByKind } from './modelRecord.js';
|
|
4
|
+
|
|
5
|
+
const anthropicProfile: AnthropicProfile = { kind: 'anthropic', model: 'claude-test' };
|
|
6
|
+
const chatProfile: OpenAIGenericProfile = { kind: 'openai_generic', model: 'chat-test' };
|
|
7
|
+
const proProfile: OpenAIProProfile = { kind: 'openai_pro', model: 'pro-test' };
|
|
8
|
+
const googleProfile: GoogleProfile = { kind: 'google', model: 'gemini-test' };
|
|
9
|
+
|
|
10
|
+
describe('profileByKind', () => {
|
|
11
|
+
it('tags every kind with exactly its own discriminator', () => {
|
|
12
|
+
expect(profileByKind(anthropicProfile)).toEqual({ anthropic: anthropicProfile });
|
|
13
|
+
expect(profileByKind(chatProfile)).toEqual({ openai_generic: chatProfile });
|
|
14
|
+
expect(profileByKind(proProfile)).toEqual({ openai_pro: proProfile });
|
|
15
|
+
expect(profileByKind(googleProfile)).toEqual({ google: googleProfile });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('produces a single-key wrapper whose tag matches the profile kind', () => {
|
|
19
|
+
for (const profile of [anthropicProfile, chatProfile, proProfile, googleProfile]) {
|
|
20
|
+
const tagged = profileByKind(profile);
|
|
21
|
+
const tags = Object.keys(tagged);
|
|
22
|
+
expect(tags).toEqual([profile.kind]);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnthropicProfile,
|
|
3
|
+
GoogleProfile,
|
|
4
|
+
ModelProfile,
|
|
5
|
+
OpenAIGenericProfile,
|
|
6
|
+
OpenAIProProfile,
|
|
7
|
+
} from './profile.js';
|
|
8
|
+
|
|
9
|
+
export type ProfileByKind =
|
|
10
|
+
| { anthropic: AnthropicProfile }
|
|
11
|
+
| { openai_generic: OpenAIGenericProfile }
|
|
12
|
+
| { openai_pro: OpenAIProProfile }
|
|
13
|
+
| { google: GoogleProfile };
|
|
14
|
+
|
|
15
|
+
export type ModelRecordStatus =
|
|
16
|
+
| { kind: 'live' }
|
|
17
|
+
| { kind: 'deprecated'; at: number }
|
|
18
|
+
| { kind: 'retired'; at: number }
|
|
19
|
+
| { kind: 'gone'; at: number };
|
|
20
|
+
|
|
21
|
+
export interface ModelRecordPrice {
|
|
22
|
+
input_micro_cents_per_mtok: number;
|
|
23
|
+
output_micro_cents_per_mtok: number;
|
|
24
|
+
cached_input_micro_cents_per_mtok: number | null;
|
|
25
|
+
effective_at: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ModelRecord {
|
|
29
|
+
id: string;
|
|
30
|
+
kind: ProfileByKind;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type ModelPricesById = Record<string, ModelRecordPrice>;
|
|
34
|
+
export type ModelStatusById = Record<string, ModelRecordStatus>;
|
|
35
|
+
|
|
36
|
+
export interface ProviderRecordSummary {
|
|
37
|
+
id: string;
|
|
38
|
+
display_name: string;
|
|
39
|
+
model_ids: string[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function profileByKind(profile: ModelProfile): ProfileByKind {
|
|
43
|
+
switch (profile.kind) {
|
|
44
|
+
case 'anthropic':
|
|
45
|
+
return { anthropic: profile };
|
|
46
|
+
case 'openai_generic':
|
|
47
|
+
return { openai_generic: profile };
|
|
48
|
+
case 'openai_pro':
|
|
49
|
+
return { openai_pro: profile };
|
|
50
|
+
case 'google':
|
|
51
|
+
return { google: profile };
|
|
52
|
+
default: {
|
|
53
|
+
const exhaustive: never = profile;
|
|
54
|
+
return exhaustive;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export type OpenAIContentPart =
|
|
2
|
+
| { type: 'text'; text: string }
|
|
3
|
+
| { type: 'image_url'; image_url: { url: string; detail?: 'auto' | 'low' | 'high' } };
|
|
4
|
+
|
|
5
|
+
export interface OpenAIToolCall {
|
|
6
|
+
id: string;
|
|
7
|
+
type: 'function';
|
|
8
|
+
function: { name: string; arguments: string };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface OpenAIChatMessage {
|
|
12
|
+
role: 'system' | 'developer' | 'user' | 'assistant' | 'tool';
|
|
13
|
+
content: string | OpenAIContentPart[] | null;
|
|
14
|
+
name?: string;
|
|
15
|
+
tool_calls?: OpenAIToolCall[];
|
|
16
|
+
tool_call_id?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface OpenAITool {
|
|
20
|
+
type: 'function';
|
|
21
|
+
function: {
|
|
22
|
+
name: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
parameters?: Record<string, unknown>;
|
|
25
|
+
strict?: boolean;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type OpenAIToolChoice =
|
|
30
|
+
| 'auto'
|
|
31
|
+
| 'none'
|
|
32
|
+
| 'required'
|
|
33
|
+
| { type: 'function'; function: { name: string } };
|
|
34
|
+
|
|
35
|
+
export interface OpenAIChatRequest {
|
|
36
|
+
model: string;
|
|
37
|
+
messages: OpenAIChatMessage[];
|
|
38
|
+
max_completion_tokens?: number;
|
|
39
|
+
max_tokens?: number;
|
|
40
|
+
temperature?: number;
|
|
41
|
+
top_p?: number;
|
|
42
|
+
frequency_penalty?: number;
|
|
43
|
+
presence_penalty?: number;
|
|
44
|
+
seed?: number;
|
|
45
|
+
n?: number;
|
|
46
|
+
logit_bias?: Record<string, number>;
|
|
47
|
+
stop?: string | string[];
|
|
48
|
+
stream?: boolean;
|
|
49
|
+
stream_options?: { include_usage?: boolean };
|
|
50
|
+
tools?: OpenAITool[];
|
|
51
|
+
tool_choice?: OpenAIToolChoice;
|
|
52
|
+
parallel_tool_calls?: boolean;
|
|
53
|
+
response_format?: Record<string, unknown>;
|
|
54
|
+
reasoning_effort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
55
|
+
verbosity?: 'low' | 'medium' | 'high';
|
|
56
|
+
prompt_cache_key?: string;
|
|
57
|
+
store?: boolean;
|
|
58
|
+
metadata?: Record<string, string>;
|
|
59
|
+
user?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface OpenAIUsage {
|
|
63
|
+
prompt_tokens: number;
|
|
64
|
+
completion_tokens: number;
|
|
65
|
+
total_tokens: number;
|
|
66
|
+
prompt_tokens_details?: { cached_tokens?: number; cache_write_tokens?: number; audio_tokens?: number };
|
|
67
|
+
completion_tokens_details?: {
|
|
68
|
+
reasoning_tokens?: number;
|
|
69
|
+
accepted_prediction_tokens?: number;
|
|
70
|
+
rejected_prediction_tokens?: number;
|
|
71
|
+
audio_tokens?: number;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface OpenAIChatResponseMessage {
|
|
76
|
+
role: 'assistant';
|
|
77
|
+
content: string | null;
|
|
78
|
+
tool_calls?: OpenAIToolCall[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type OpenAIFinishReason = 'stop' | 'length' | 'tool_calls' | 'content_filter' | null;
|
|
82
|
+
|
|
83
|
+
export interface OpenAIChatResponse {
|
|
84
|
+
id: string;
|
|
85
|
+
object: 'chat.completion';
|
|
86
|
+
model: string;
|
|
87
|
+
choices: Array<{ index: number; message: OpenAIChatResponseMessage; finish_reason: OpenAIFinishReason }>;
|
|
88
|
+
usage: OpenAIUsage;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface OpenAIChatDelta {
|
|
92
|
+
role?: 'assistant';
|
|
93
|
+
content?: string | null;
|
|
94
|
+
tool_calls?: Array<{ index: number; id?: string; type?: 'function'; function?: { name?: string; arguments?: string } }>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface OpenAIChatChunk {
|
|
98
|
+
id: string;
|
|
99
|
+
object: 'chat.completion.chunk';
|
|
100
|
+
model: string;
|
|
101
|
+
choices: Array<{ index: number; delta: OpenAIChatDelta; finish_reason: OpenAIFinishReason }>;
|
|
102
|
+
usage?: OpenAIUsage | null;
|
|
103
|
+
}
|
package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/openaiPro.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export type OpenAIResponsesContentPart =
|
|
2
|
+
| { type: 'input_text'; text: string }
|
|
3
|
+
| { type: 'input_image'; image_url: string; detail?: 'auto' | 'low' | 'high' }
|
|
4
|
+
| { type: 'output_text'; text: string };
|
|
5
|
+
|
|
6
|
+
export type OpenAIResponsesInputItem =
|
|
7
|
+
| { type: 'message'; role: 'system' | 'developer' | 'user' | 'assistant'; content: string | OpenAIResponsesContentPart[] }
|
|
8
|
+
| { type: 'function_call'; call_id: string; name: string; arguments: string }
|
|
9
|
+
| { type: 'function_call_output'; call_id: string; output: string }
|
|
10
|
+
| { type: 'reasoning'; id: string; summary: unknown[] };
|
|
11
|
+
|
|
12
|
+
export interface OpenAIResponsesTool {
|
|
13
|
+
type: 'function';
|
|
14
|
+
name: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
parameters?: Record<string, unknown>;
|
|
17
|
+
strict?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type OpenAIResponsesToolChoice =
|
|
21
|
+
| 'auto'
|
|
22
|
+
| 'none'
|
|
23
|
+
| 'required'
|
|
24
|
+
| { type: 'function'; name: string };
|
|
25
|
+
|
|
26
|
+
export interface OpenAIResponsesRequest {
|
|
27
|
+
model: string;
|
|
28
|
+
input: string | OpenAIResponsesInputItem[];
|
|
29
|
+
instructions?: string;
|
|
30
|
+
max_output_tokens?: number;
|
|
31
|
+
max_tool_calls?: number;
|
|
32
|
+
temperature?: number;
|
|
33
|
+
top_p?: number;
|
|
34
|
+
stream?: boolean;
|
|
35
|
+
tools?: OpenAIResponsesTool[];
|
|
36
|
+
tool_choice?: OpenAIResponsesToolChoice;
|
|
37
|
+
parallel_tool_calls?: boolean;
|
|
38
|
+
reasoning?: { effort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'; summary?: 'auto' | 'concise' | 'detailed' };
|
|
39
|
+
text?: { format?: Record<string, unknown>; verbosity?: 'low' | 'medium' | 'high' };
|
|
40
|
+
include?: string[];
|
|
41
|
+
store?: boolean;
|
|
42
|
+
previous_response_id?: string;
|
|
43
|
+
prompt_cache_key?: string;
|
|
44
|
+
metadata?: Record<string, string>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface OpenAIResponsesUsage {
|
|
48
|
+
input_tokens: number;
|
|
49
|
+
output_tokens: number;
|
|
50
|
+
total_tokens: number;
|
|
51
|
+
input_tokens_details?: { cached_tokens?: number; cache_write_tokens?: number };
|
|
52
|
+
output_tokens_details?: { reasoning_tokens?: number };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type OpenAIResponsesOutputItem =
|
|
56
|
+
| { type: 'message'; id: string; role: 'assistant'; content: Array<{ type: 'output_text'; text: string }> }
|
|
57
|
+
| { type: 'function_call'; id: string; call_id: string; name: string; arguments: string }
|
|
58
|
+
| { type: 'reasoning'; id: string; summary: unknown[] };
|
|
59
|
+
|
|
60
|
+
export interface OpenAIResponsesResponse {
|
|
61
|
+
id: string;
|
|
62
|
+
object: 'response';
|
|
63
|
+
model: string;
|
|
64
|
+
status: 'completed' | 'incomplete' | 'failed' | 'in_progress';
|
|
65
|
+
output: OpenAIResponsesOutputItem[];
|
|
66
|
+
usage: OpenAIResponsesUsage;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type OpenAIResponsesStreamContentPart =
|
|
70
|
+
| { type: 'output_text'; text: string }
|
|
71
|
+
| { type: 'refusal'; refusal: string }
|
|
72
|
+
| { type: 'reasoning_text'; text: string };
|
|
73
|
+
|
|
74
|
+
export type OpenAIResponsesStreamEvent =
|
|
75
|
+
| { type: 'response.created'; response: { id: string } }
|
|
76
|
+
| { type: 'response.in_progress'; response: { id: string } }
|
|
77
|
+
| { type: 'response.output_item.added'; output_index: number; item: OpenAIResponsesOutputItem }
|
|
78
|
+
| { type: 'response.content_part.added'; item_id: string; output_index: number; content_index: number; part: OpenAIResponsesStreamContentPart }
|
|
79
|
+
| { type: 'response.output_text.delta'; delta: string }
|
|
80
|
+
| { type: 'response.output_text.done'; item_id: string; output_index: number; content_index: number; text: string }
|
|
81
|
+
| { type: 'response.content_part.done'; item_id: string; output_index: number; content_index: number; part: OpenAIResponsesStreamContentPart }
|
|
82
|
+
| { type: 'response.function_call_arguments.delta'; item_id: string; output_index: number; delta: string }
|
|
83
|
+
| { type: 'response.function_call_arguments.done'; item_id: string; output_index: number; name: string; arguments: string }
|
|
84
|
+
| { type: 'response.reasoning_summary_text.delta'; item_id: string; output_index: number; summary_index: number; delta: string }
|
|
85
|
+
| { type: 'response.output_item.done'; item: OpenAIResponsesOutputItem }
|
|
86
|
+
| { type: 'response.completed'; response: { status: string; usage: OpenAIResponsesUsage } }
|
|
87
|
+
| { type: 'response.incomplete'; response: { status: string; usage?: OpenAIResponsesUsage } }
|
|
88
|
+
| { type: 'response.failed'; response: { error?: { message: string } } }
|
|
89
|
+
| { type: 'error'; message: string };
|