@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.
Files changed (236) hide show
  1. package/LICENSE +53 -0
  2. package/package.json +18 -5
  3. package/runtime/LICENSE +53 -0
  4. package/runtime/README.md +674 -0
  5. package/runtime/assets/clankolas.png +0 -0
  6. package/runtime/docs/extensions.md +2910 -0
  7. package/runtime/docs/json.md +82 -0
  8. package/runtime/docs/models.md +540 -0
  9. package/runtime/docs/packages.md +228 -0
  10. package/runtime/docs/rpc.md +1480 -0
  11. package/runtime/docs/sdk.md +1183 -0
  12. package/runtime/docs/session-format.md +422 -0
  13. package/runtime/docs/settings.md +315 -0
  14. package/runtime/docs/shell-aliases.md +13 -0
  15. package/runtime/docs/terminal-setup.md +142 -0
  16. package/runtime/docs/termux.md +127 -0
  17. package/runtime/docs/tmux.md +63 -0
  18. package/runtime/docs/tui.md +927 -0
  19. package/runtime/docs/windows.md +17 -0
  20. package/runtime/examples/README.md +25 -0
  21. package/runtime/examples/extensions/README.md +212 -0
  22. package/runtime/examples/extensions/auto-commit-on-exit.ts +49 -0
  23. package/runtime/examples/extensions/bash-spawn-hook.ts +30 -0
  24. package/runtime/examples/extensions/bookmark.ts +50 -0
  25. package/runtime/examples/extensions/border-status-editor.ts +145 -0
  26. package/runtime/examples/extensions/built-in-tool-renderer.ts +249 -0
  27. package/runtime/examples/extensions/claude-rules.ts +86 -0
  28. package/runtime/examples/extensions/commands.ts +72 -0
  29. package/runtime/examples/extensions/confirm-destructive.ts +59 -0
  30. package/runtime/examples/extensions/custom-footer.ts +64 -0
  31. package/runtime/examples/extensions/custom-header.ts +73 -0
  32. package/runtime/examples/extensions/custom-provider-anthropic/index.ts +604 -0
  33. package/runtime/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  34. package/runtime/examples/extensions/custom-provider-anthropic/package.json +19 -0
  35. package/runtime/examples/extensions/dirty-repo-guard.ts +56 -0
  36. package/runtime/examples/extensions/doom-overlay/README.md +46 -0
  37. package/runtime/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  38. package/runtime/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  39. package/runtime/examples/extensions/doom-overlay/doom/build.sh +152 -0
  40. package/runtime/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  41. package/runtime/examples/extensions/doom-overlay/doom-component.ts +132 -0
  42. package/runtime/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  43. package/runtime/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  44. package/runtime/examples/extensions/doom-overlay/index.ts +74 -0
  45. package/runtime/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  46. package/runtime/examples/extensions/dynamic-resources/SKILL.md +8 -0
  47. package/runtime/examples/extensions/dynamic-resources/dynamic.json +79 -0
  48. package/runtime/examples/extensions/dynamic-resources/dynamic.md +5 -0
  49. package/runtime/examples/extensions/dynamic-resources/index.ts +15 -0
  50. package/runtime/examples/extensions/dynamic-tools.ts +74 -0
  51. package/runtime/examples/extensions/entry-renderer.ts +41 -0
  52. package/runtime/examples/extensions/event-bus.ts +43 -0
  53. package/runtime/examples/extensions/file-trigger.ts +41 -0
  54. package/runtime/examples/extensions/git-checkpoint.ts +53 -0
  55. package/runtime/examples/extensions/git-merge-and-resolve.ts +115 -0
  56. package/runtime/examples/extensions/github-issue-autocomplete.ts +185 -0
  57. package/runtime/examples/extensions/gondolin/index.ts +531 -0
  58. package/runtime/examples/extensions/gondolin/package-lock.json +185 -0
  59. package/runtime/examples/extensions/gondolin/package.json +19 -0
  60. package/runtime/examples/extensions/hello.ts +26 -0
  61. package/runtime/examples/extensions/hidden-thinking-label.ts +53 -0
  62. package/runtime/examples/extensions/inline-bash.ts +94 -0
  63. package/runtime/examples/extensions/input-transform-streaming.ts +39 -0
  64. package/runtime/examples/extensions/input-transform.ts +43 -0
  65. package/runtime/examples/extensions/interactive-shell.ts +196 -0
  66. package/runtime/examples/extensions/mac-system-theme.ts +47 -0
  67. package/runtime/examples/extensions/message-renderer.ts +59 -0
  68. package/runtime/examples/extensions/minimal-mode.ts +426 -0
  69. package/runtime/examples/extensions/modal-editor.ts +85 -0
  70. package/runtime/examples/extensions/model-status.ts +31 -0
  71. package/runtime/examples/extensions/notify.ts +55 -0
  72. package/runtime/examples/extensions/overlay-qa-tests.ts +1450 -0
  73. package/runtime/examples/extensions/overlay-test.ts +153 -0
  74. package/runtime/examples/extensions/permission-gate.ts +34 -0
  75. package/runtime/examples/extensions/pirate.ts +47 -0
  76. package/runtime/examples/extensions/plan-mode/README.md +66 -0
  77. package/runtime/examples/extensions/plan-mode/index.ts +390 -0
  78. package/runtime/examples/extensions/plan-mode/utils.ts +168 -0
  79. package/runtime/examples/extensions/preset.ts +436 -0
  80. package/runtime/examples/extensions/project-trust.ts +64 -0
  81. package/runtime/examples/extensions/prompt-customizer.ts +97 -0
  82. package/runtime/examples/extensions/protected-paths.ts +30 -0
  83. package/runtime/examples/extensions/provider-payload.ts +18 -0
  84. package/runtime/examples/extensions/question.ts +278 -0
  85. package/runtime/examples/extensions/questionnaire.ts +440 -0
  86. package/runtime/examples/extensions/rainbow-editor.ts +88 -0
  87. package/runtime/examples/extensions/reload-runtime.ts +37 -0
  88. package/runtime/examples/extensions/rpc-demo.ts +118 -0
  89. package/runtime/examples/extensions/sandbox/index.ts +321 -0
  90. package/runtime/examples/extensions/sandbox/package-lock.json +92 -0
  91. package/runtime/examples/extensions/sandbox/package.json +19 -0
  92. package/runtime/examples/extensions/send-user-message.ts +97 -0
  93. package/runtime/examples/extensions/session-name.ts +27 -0
  94. package/runtime/examples/extensions/shutdown-command.ts +63 -0
  95. package/runtime/examples/extensions/snake.ts +343 -0
  96. package/runtime/examples/extensions/space-invaders.ts +560 -0
  97. package/runtime/examples/extensions/ssh.ts +220 -0
  98. package/runtime/examples/extensions/status-line.ts +32 -0
  99. package/runtime/examples/extensions/structured-output.ts +65 -0
  100. package/runtime/examples/extensions/subagent/README.md +175 -0
  101. package/runtime/examples/extensions/subagent/agents/planner.md +37 -0
  102. package/runtime/examples/extensions/subagent/agents/reviewer.md +35 -0
  103. package/runtime/examples/extensions/subagent/agents/scout.md +50 -0
  104. package/runtime/examples/extensions/subagent/agents/worker.md +24 -0
  105. package/runtime/examples/extensions/subagent/agents.ts +126 -0
  106. package/runtime/examples/extensions/subagent/index.ts +1009 -0
  107. package/runtime/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  108. package/runtime/examples/extensions/subagent/prompts/implement.md +10 -0
  109. package/runtime/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  110. package/runtime/examples/extensions/system-prompt-header.ts +17 -0
  111. package/runtime/examples/extensions/tic-tac-toe.ts +1008 -0
  112. package/runtime/examples/extensions/timed-confirm.ts +70 -0
  113. package/runtime/examples/extensions/titlebar-spinner.ts +58 -0
  114. package/runtime/examples/extensions/todo.ts +297 -0
  115. package/runtime/examples/extensions/tool-override.ts +144 -0
  116. package/runtime/examples/extensions/tools.ts +146 -0
  117. package/runtime/examples/extensions/trigger-compact.ts +50 -0
  118. package/runtime/examples/extensions/truncated-tool.ts +195 -0
  119. package/runtime/examples/extensions/widget-placement.ts +9 -0
  120. package/runtime/examples/extensions/with-deps/index.ts +32 -0
  121. package/runtime/examples/extensions/with-deps/package-lock.json +31 -0
  122. package/runtime/examples/extensions/with-deps/package.json +22 -0
  123. package/runtime/examples/extensions/working-indicator.ts +123 -0
  124. package/runtime/examples/extensions/working-message-test.ts +25 -0
  125. package/runtime/examples/rpc-extension-ui.ts +632 -0
  126. package/runtime/examples/sdk/01-minimal.ts +26 -0
  127. package/runtime/examples/sdk/02-custom-model.ts +43 -0
  128. package/runtime/examples/sdk/03-custom-prompt.ts +70 -0
  129. package/runtime/examples/sdk/04-skills.ts +55 -0
  130. package/runtime/examples/sdk/05-tools.ts +48 -0
  131. package/runtime/examples/sdk/06-extensions.ts +94 -0
  132. package/runtime/examples/sdk/07-context-files.ts +42 -0
  133. package/runtime/examples/sdk/08-prompt-templates.ts +51 -0
  134. package/runtime/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  135. package/runtime/examples/sdk/10-settings.ts +53 -0
  136. package/runtime/examples/sdk/11-sessions.ts +52 -0
  137. package/runtime/examples/sdk/12-full-control.ts +71 -0
  138. package/runtime/examples/sdk/13-session-runtime.ts +67 -0
  139. package/runtime/examples/sdk/README.md +140 -0
  140. package/runtime/export-html/ansi-to-html.js +249 -0
  141. package/runtime/export-html/index.js +226 -0
  142. package/runtime/export-html/template.css +1066 -0
  143. package/runtime/export-html/template.html +55 -0
  144. package/runtime/export-html/template.js +1864 -0
  145. package/runtime/export-html/tool-renderer.js +108 -0
  146. package/runtime/export-html/vendor/highlight.min.js +1213 -0
  147. package/runtime/export-html/vendor/marked.min.js +78 -0
  148. package/runtime/extensions/pi-switchboard/.github/workflows/ci.yml +51 -0
  149. package/runtime/extensions/pi-switchboard/LICENSE +22 -0
  150. package/runtime/extensions/pi-switchboard/README.md +85 -0
  151. package/runtime/extensions/pi-switchboard/extensions/switchboard/catalog.ts +183 -0
  152. package/runtime/extensions/pi-switchboard/extensions/switchboard/config.ts +97 -0
  153. package/runtime/extensions/pi-switchboard/extensions/switchboard/connections.ts +386 -0
  154. package/runtime/extensions/pi-switchboard/extensions/switchboard/constants.ts +12 -0
  155. package/runtime/extensions/pi-switchboard/extensions/switchboard/device-auth.ts +127 -0
  156. package/runtime/extensions/pi-switchboard/extensions/switchboard/envelope.ts +199 -0
  157. package/runtime/extensions/pi-switchboard/extensions/switchboard/errors.ts +180 -0
  158. package/runtime/extensions/pi-switchboard/extensions/switchboard/index.ts +125 -0
  159. package/runtime/extensions/pi-switchboard/extensions/switchboard/participant.ts +17 -0
  160. package/runtime/extensions/pi-switchboard/extensions/switchboard/sessionStream.ts +131 -0
  161. package/runtime/extensions/pi-switchboard/extensions/switchboard/toolProxy.ts +136 -0
  162. package/runtime/extensions/pi-switchboard/extensions/switchboard/tools.ts +16 -0
  163. package/runtime/extensions/pi-switchboard/extensions/switchboard/types.ts +37 -0
  164. package/runtime/extensions/pi-switchboard/package.json +30 -0
  165. package/runtime/extensions/pi-switchboard/tsconfig.json +13 -0
  166. package/runtime/extensions/switchboard-local/.github/workflows/ci.yml +80 -0
  167. package/runtime/extensions/switchboard-local/.github/workflows/release.yml +46 -0
  168. package/runtime/extensions/switchboard-local/README.md +98 -0
  169. package/runtime/extensions/switchboard-local/extensions/local/engine.ts +28 -0
  170. package/runtime/extensions/switchboard-local/extensions/local/engines/gguf.ts +324 -0
  171. package/runtime/extensions/switchboard-local/extensions/local/engines/llamaBuild.ts +62 -0
  172. package/runtime/extensions/switchboard-local/extensions/local/engines/mlx.ts +245 -0
  173. package/runtime/extensions/switchboard-local/extensions/local/engines/select.ts +38 -0
  174. package/runtime/extensions/switchboard-local/extensions/local/engines/support.ts +151 -0
  175. package/runtime/extensions/switchboard-local/extensions/local/hf.ts +106 -0
  176. package/runtime/extensions/switchboard-local/extensions/local/index.ts +67 -0
  177. package/runtime/extensions/switchboard-local/extensions/local/nativeStream.ts +602 -0
  178. package/runtime/extensions/switchboard-local/extensions/local/paths.ts +44 -0
  179. package/runtime/extensions/switchboard-local/extensions/local/provider.ts +57 -0
  180. package/runtime/extensions/switchboard-local/extensions/local/store.ts +82 -0
  181. package/runtime/extensions/switchboard-local/extensions/local/ui.ts +60 -0
  182. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/apiTypes.js +74 -0
  183. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/client.js +292 -0
  184. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/deviceAuth.js +155 -0
  185. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/errors.js +95 -0
  186. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/index.js +8 -0
  187. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/messages.js +253 -0
  188. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/models.js +19 -0
  189. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/native.js +886 -0
  190. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/wire.js +85 -0
  191. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/package.json +39 -0
  192. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/package.json +29 -0
  193. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/anthropic.ts +127 -0
  194. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/google.ts +111 -0
  195. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/index.ts +8 -0
  196. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/modelRecord.test.ts +25 -0
  197. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/modelRecord.ts +57 -0
  198. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/openaiGeneric.ts +103 -0
  199. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/openaiPro.ts +89 -0
  200. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/profile.ts +120 -0
  201. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/routing.test.ts +82 -0
  202. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/routing.ts +74 -0
  203. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.google.test.ts +137 -0
  204. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.openai.test.ts +241 -0
  205. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.test.ts +174 -0
  206. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.ts +438 -0
  207. package/runtime/extensions/switchboard-local/package.json +34 -0
  208. package/runtime/extensions/switchboard-local/tsconfig.json +13 -0
  209. package/runtime/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
  210. package/runtime/node_modules/@mariozechner/clipboard/.yarnrc.yml +1 -0
  211. package/runtime/node_modules/@mariozechner/clipboard/Cargo.toml +45 -0
  212. package/runtime/node_modules/@mariozechner/clipboard/README.md +60 -0
  213. package/runtime/node_modules/@mariozechner/clipboard/build.rs +5 -0
  214. package/runtime/node_modules/@mariozechner/clipboard/clipboard.darwin-x64.node +0 -0
  215. package/runtime/node_modules/@mariozechner/clipboard/exp.ts +12 -0
  216. package/runtime/node_modules/@mariozechner/clipboard/index.js +606 -0
  217. package/runtime/node_modules/@mariozechner/clipboard/package.json +56 -0
  218. package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/common.rs +307 -0
  219. package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/mod.rs +93 -0
  220. package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/ios.rs +313 -0
  221. package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/macos.rs +471 -0
  222. package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/mod.rs +252 -0
  223. package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/wayland.rs +431 -0
  224. package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/win.rs +712 -0
  225. package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/x11.rs +916 -0
  226. package/runtime/node_modules/@mariozechner/clipboard/src/lib.rs +194 -0
  227. package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/README.md +3 -0
  228. package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/clipboard.darwin-x64.node +0 -0
  229. package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/package.json +22 -0
  230. package/runtime/package.json +104 -0
  231. package/runtime/photon_rs_bg.wasm +0 -0
  232. package/runtime/theme/dark.json +87 -0
  233. package/runtime/theme/light.json +86 -0
  234. package/runtime/theme/theme-schema.json +340 -0
  235. package/runtime/valni +4 -0
  236. 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
+ }
@@ -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
+ }
@@ -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 } };
@@ -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
+ }
@@ -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
+ }
@@ -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 };