@valni/cli-darwin-x64 0.0.0-stage → 0.1.3

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 (183) hide show
  1. package/LICENSE +52 -0
  2. package/package.json +18 -5
  3. package/runtime/LICENSE +52 -0
  4. package/runtime/assets/clankolas.png +0 -0
  5. package/runtime/examples/extensions/auto-commit-on-exit.ts +49 -0
  6. package/runtime/examples/extensions/bash-spawn-hook.ts +30 -0
  7. package/runtime/examples/extensions/bookmark.ts +50 -0
  8. package/runtime/examples/extensions/border-status-editor.ts +145 -0
  9. package/runtime/examples/extensions/built-in-tool-renderer.ts +249 -0
  10. package/runtime/examples/extensions/claude-rules.ts +86 -0
  11. package/runtime/examples/extensions/commands.ts +72 -0
  12. package/runtime/examples/extensions/confirm-destructive.ts +59 -0
  13. package/runtime/examples/extensions/custom-footer.ts +64 -0
  14. package/runtime/examples/extensions/custom-header.ts +73 -0
  15. package/runtime/examples/extensions/custom-provider-anthropic/index.ts +604 -0
  16. package/runtime/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  17. package/runtime/examples/extensions/custom-provider-anthropic/package.json +19 -0
  18. package/runtime/examples/extensions/dirty-repo-guard.ts +56 -0
  19. package/runtime/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  20. package/runtime/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  21. package/runtime/examples/extensions/doom-overlay/doom/build.sh +152 -0
  22. package/runtime/examples/extensions/doom-overlay/doom/doomgeneric_valni.c +72 -0
  23. package/runtime/examples/extensions/doom-overlay/doom-component.ts +132 -0
  24. package/runtime/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  25. package/runtime/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  26. package/runtime/examples/extensions/doom-overlay/index.ts +74 -0
  27. package/runtime/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  28. package/runtime/examples/extensions/dynamic-resources/dynamic.json +78 -0
  29. package/runtime/examples/extensions/dynamic-resources/index.ts +13 -0
  30. package/runtime/examples/extensions/dynamic-tools.ts +74 -0
  31. package/runtime/examples/extensions/entry-renderer.ts +41 -0
  32. package/runtime/examples/extensions/event-bus.ts +43 -0
  33. package/runtime/examples/extensions/file-trigger.ts +41 -0
  34. package/runtime/examples/extensions/git-checkpoint.ts +53 -0
  35. package/runtime/examples/extensions/git-merge-and-resolve.ts +115 -0
  36. package/runtime/examples/extensions/github-issue-autocomplete.ts +185 -0
  37. package/runtime/examples/extensions/hello.ts +26 -0
  38. package/runtime/examples/extensions/hidden-thinking-label.ts +53 -0
  39. package/runtime/examples/extensions/inline-bash.ts +94 -0
  40. package/runtime/examples/extensions/input-transform-streaming.ts +39 -0
  41. package/runtime/examples/extensions/input-transform.ts +43 -0
  42. package/runtime/examples/extensions/interactive-shell.ts +196 -0
  43. package/runtime/examples/extensions/mac-system-theme.ts +47 -0
  44. package/runtime/examples/extensions/message-renderer.ts +59 -0
  45. package/runtime/examples/extensions/minimal-mode.ts +426 -0
  46. package/runtime/examples/extensions/modal-editor.ts +85 -0
  47. package/runtime/examples/extensions/model-status.ts +31 -0
  48. package/runtime/examples/extensions/notify.ts +55 -0
  49. package/runtime/examples/extensions/overlay-qa-tests.ts +1450 -0
  50. package/runtime/examples/extensions/overlay-test.ts +153 -0
  51. package/runtime/examples/extensions/permission-gate.ts +34 -0
  52. package/runtime/examples/extensions/pirate.ts +47 -0
  53. package/runtime/examples/extensions/plan-mode/index.ts +390 -0
  54. package/runtime/examples/extensions/plan-mode/utils.ts +168 -0
  55. package/runtime/examples/extensions/preset.ts +436 -0
  56. package/runtime/examples/extensions/project-trust.ts +64 -0
  57. package/runtime/examples/extensions/prompt-customizer.ts +97 -0
  58. package/runtime/examples/extensions/protected-paths.ts +30 -0
  59. package/runtime/examples/extensions/provider-payload.ts +18 -0
  60. package/runtime/examples/extensions/question.ts +278 -0
  61. package/runtime/examples/extensions/questionnaire.ts +440 -0
  62. package/runtime/examples/extensions/rainbow-editor.ts +88 -0
  63. package/runtime/examples/extensions/reload-runtime.ts +37 -0
  64. package/runtime/examples/extensions/rpc-demo.ts +118 -0
  65. package/runtime/examples/extensions/sandbox/index.ts +321 -0
  66. package/runtime/examples/extensions/sandbox/package-lock.json +92 -0
  67. package/runtime/examples/extensions/sandbox/package.json +19 -0
  68. package/runtime/examples/extensions/send-user-message.ts +97 -0
  69. package/runtime/examples/extensions/session-name.ts +27 -0
  70. package/runtime/examples/extensions/shutdown-command.ts +63 -0
  71. package/runtime/examples/extensions/snake.ts +343 -0
  72. package/runtime/examples/extensions/space-invaders.ts +560 -0
  73. package/runtime/examples/extensions/ssh.ts +220 -0
  74. package/runtime/examples/extensions/status-line.ts +32 -0
  75. package/runtime/examples/extensions/structured-output.ts +65 -0
  76. package/runtime/examples/extensions/subagent/agents.ts +126 -0
  77. package/runtime/examples/extensions/subagent/index.ts +1009 -0
  78. package/runtime/examples/extensions/system-prompt-header.ts +17 -0
  79. package/runtime/examples/extensions/tic-tac-toe.ts +1008 -0
  80. package/runtime/examples/extensions/timed-confirm.ts +70 -0
  81. package/runtime/examples/extensions/titlebar-spinner.ts +58 -0
  82. package/runtime/examples/extensions/todo.ts +297 -0
  83. package/runtime/examples/extensions/tool-override.ts +144 -0
  84. package/runtime/examples/extensions/tools.ts +146 -0
  85. package/runtime/examples/extensions/trigger-compact.ts +50 -0
  86. package/runtime/examples/extensions/truncated-tool.ts +195 -0
  87. package/runtime/examples/extensions/widget-placement.ts +9 -0
  88. package/runtime/examples/extensions/with-deps/index.ts +32 -0
  89. package/runtime/examples/extensions/with-deps/package-lock.json +31 -0
  90. package/runtime/examples/extensions/with-deps/package.json +22 -0
  91. package/runtime/examples/extensions/working-indicator.ts +123 -0
  92. package/runtime/examples/extensions/working-message-test.ts +25 -0
  93. package/runtime/examples/rpc-extension-ui.ts +632 -0
  94. package/runtime/examples/sdk/01-minimal.ts +26 -0
  95. package/runtime/examples/sdk/02-custom-model.ts +43 -0
  96. package/runtime/examples/sdk/03-custom-prompt.ts +70 -0
  97. package/runtime/examples/sdk/04-skills.ts +55 -0
  98. package/runtime/examples/sdk/05-tools.ts +48 -0
  99. package/runtime/examples/sdk/06-extensions.ts +94 -0
  100. package/runtime/examples/sdk/07-context-files.ts +42 -0
  101. package/runtime/examples/sdk/08-prompt-templates.ts +51 -0
  102. package/runtime/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  103. package/runtime/examples/sdk/10-settings.ts +53 -0
  104. package/runtime/examples/sdk/11-sessions.ts +52 -0
  105. package/runtime/examples/sdk/12-full-control.ts +71 -0
  106. package/runtime/examples/sdk/13-session-runtime.ts +67 -0
  107. package/runtime/export-html/ansi-to-html.js +249 -0
  108. package/runtime/export-html/index.js +226 -0
  109. package/runtime/export-html/template.css +1066 -0
  110. package/runtime/export-html/template.html +55 -0
  111. package/runtime/export-html/template.js +1864 -0
  112. package/runtime/export-html/tool-renderer.js +108 -0
  113. package/runtime/export-html/vendor/highlight.min.js +1213 -0
  114. package/runtime/export-html/vendor/marked.min.js +78 -0
  115. package/runtime/extensions/pi-switchboard/.github/workflows/ci.yml +51 -0
  116. package/runtime/extensions/pi-switchboard/LICENSE +22 -0
  117. package/runtime/extensions/pi-switchboard/README.md +85 -0
  118. package/runtime/extensions/pi-switchboard/extensions/switchboard/catalog.ts +183 -0
  119. package/runtime/extensions/pi-switchboard/extensions/switchboard/config.ts +97 -0
  120. package/runtime/extensions/pi-switchboard/extensions/switchboard/connections.ts +386 -0
  121. package/runtime/extensions/pi-switchboard/extensions/switchboard/constants.ts +12 -0
  122. package/runtime/extensions/pi-switchboard/extensions/switchboard/device-auth.ts +127 -0
  123. package/runtime/extensions/pi-switchboard/extensions/switchboard/envelope.ts +199 -0
  124. package/runtime/extensions/pi-switchboard/extensions/switchboard/errors.ts +180 -0
  125. package/runtime/extensions/pi-switchboard/extensions/switchboard/index.ts +125 -0
  126. package/runtime/extensions/pi-switchboard/extensions/switchboard/participant.ts +17 -0
  127. package/runtime/extensions/pi-switchboard/extensions/switchboard/sessionStream.ts +131 -0
  128. package/runtime/extensions/pi-switchboard/extensions/switchboard/toolProxy.ts +136 -0
  129. package/runtime/extensions/pi-switchboard/extensions/switchboard/tools.ts +16 -0
  130. package/runtime/extensions/pi-switchboard/extensions/switchboard/types.ts +37 -0
  131. package/runtime/extensions/pi-switchboard/package.json +30 -0
  132. package/runtime/extensions/pi-switchboard/tsconfig.json +13 -0
  133. package/runtime/extensions/switchboard-local/.github/workflows/ci.yml +80 -0
  134. package/runtime/extensions/switchboard-local/.github/workflows/release.yml +46 -0
  135. package/runtime/extensions/switchboard-local/README.md +98 -0
  136. package/runtime/extensions/switchboard-local/extensions/local/engine.ts +28 -0
  137. package/runtime/extensions/switchboard-local/extensions/local/engines/gguf.ts +324 -0
  138. package/runtime/extensions/switchboard-local/extensions/local/engines/llamaBuild.ts +62 -0
  139. package/runtime/extensions/switchboard-local/extensions/local/engines/mlx.ts +245 -0
  140. package/runtime/extensions/switchboard-local/extensions/local/engines/select.ts +38 -0
  141. package/runtime/extensions/switchboard-local/extensions/local/engines/support.ts +151 -0
  142. package/runtime/extensions/switchboard-local/extensions/local/hf.ts +106 -0
  143. package/runtime/extensions/switchboard-local/extensions/local/index.ts +67 -0
  144. package/runtime/extensions/switchboard-local/extensions/local/nativeStream.ts +602 -0
  145. package/runtime/extensions/switchboard-local/extensions/local/paths.ts +44 -0
  146. package/runtime/extensions/switchboard-local/extensions/local/provider.ts +57 -0
  147. package/runtime/extensions/switchboard-local/extensions/local/store.ts +82 -0
  148. package/runtime/extensions/switchboard-local/extensions/local/ui.ts +60 -0
  149. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/apiTypes.js +74 -0
  150. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/client.js +292 -0
  151. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/deviceAuth.js +155 -0
  152. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/errors.js +95 -0
  153. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/index.js +8 -0
  154. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/messages.js +253 -0
  155. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/models.js +19 -0
  156. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/native.js +886 -0
  157. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/dist/wire.js +85 -0
  158. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard/package.json +39 -0
  159. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/package.json +29 -0
  160. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/anthropic.ts +127 -0
  161. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/google.ts +111 -0
  162. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/index.ts +8 -0
  163. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/modelRecord.test.ts +25 -0
  164. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/modelRecord.ts +57 -0
  165. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/openaiGeneric.ts +103 -0
  166. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/openaiPro.ts +89 -0
  167. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/profile.ts +120 -0
  168. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/routing.test.ts +82 -0
  169. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/routing.ts +74 -0
  170. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.google.test.ts +137 -0
  171. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.openai.test.ts +241 -0
  172. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.test.ts +174 -0
  173. package/runtime/extensions/switchboard-local/node_modules/@valni/switchboard-native/src/validateConfig.ts +438 -0
  174. package/runtime/extensions/switchboard-local/package.json +34 -0
  175. package/runtime/extensions/switchboard-local/tsconfig.json +13 -0
  176. package/runtime/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
  177. package/runtime/package.json +98 -0
  178. package/runtime/photon_rs_bg.wasm +0 -0
  179. package/runtime/theme/dark.json +86 -0
  180. package/runtime/theme/light.json +85 -0
  181. package/runtime/theme/theme-schema.json +340 -0
  182. package/runtime/valni +4 -0
  183. package/README.md +0 -3
@@ -0,0 +1,886 @@
1
+ import * as wire from "./wire.js";
2
+ import * as messages from "./messages.js";
3
+ import { EncodingFailedError } from "./errors.js";
4
+ export const KIND_ANTHROPIC = "anthropic";
5
+ export const KIND_OPENAI_PRO = "openai_pro";
6
+ export const KIND_OPENAI_GENERIC = "openai_generic";
7
+ export const KIND_GOOGLE = "google";
8
+ export const DONE_SENTINEL = "[DONE]";
9
+ export class AnthropicMessage {
10
+ role;
11
+ content;
12
+ constructor(role, content) {
13
+ this.role = role;
14
+ this.content = content;
15
+ }
16
+ static user(content) {
17
+ return new AnthropicMessage("user", content);
18
+ }
19
+ static assistant(content) {
20
+ return new AnthropicMessage("assistant", content);
21
+ }
22
+ toWire() {
23
+ return { role: this.role, content: this.content };
24
+ }
25
+ }
26
+ export class AnthropicMessagesRequest {
27
+ model;
28
+ messages;
29
+ max_tokens;
30
+ system;
31
+ temperature;
32
+ top_p;
33
+ top_k;
34
+ stop_sequences;
35
+ stream;
36
+ tools;
37
+ tool_choice;
38
+ thinking;
39
+ output_config;
40
+ metadata;
41
+ constructor(options) {
42
+ this.model = options.model;
43
+ this.messages = options.messages;
44
+ this.max_tokens = options.max_tokens;
45
+ this.system = options.system ?? null;
46
+ this.temperature = options.temperature ?? null;
47
+ this.top_p = options.top_p ?? null;
48
+ this.top_k = options.top_k ?? null;
49
+ this.stop_sequences = options.stop_sequences ?? null;
50
+ this.stream = options.stream ?? null;
51
+ this.tools = options.tools ?? null;
52
+ this.tool_choice = options.tool_choice ?? null;
53
+ this.thinking = options.thinking ?? null;
54
+ this.output_config = options.output_config ?? null;
55
+ this.metadata = options.metadata ?? null;
56
+ }
57
+ streaming() {
58
+ return new AnthropicMessagesRequest({ ...this, stream: true });
59
+ }
60
+ toWire() {
61
+ const encoded = {
62
+ model: this.model,
63
+ messages: this.messages.map((message) => message.toWire()),
64
+ max_tokens: this.max_tokens,
65
+ };
66
+ if (this.system !== null)
67
+ encoded["system"] = this.system;
68
+ if (this.temperature !== null)
69
+ encoded["temperature"] = this.temperature;
70
+ if (this.top_p !== null)
71
+ encoded["top_p"] = this.top_p;
72
+ if (this.top_k !== null)
73
+ encoded["top_k"] = this.top_k;
74
+ if (this.stop_sequences !== null)
75
+ encoded["stop_sequences"] = [...this.stop_sequences];
76
+ if (this.stream !== null)
77
+ encoded["stream"] = this.stream;
78
+ if (this.tools !== null)
79
+ encoded["tools"] = [...this.tools];
80
+ if (this.tool_choice !== null)
81
+ encoded["tool_choice"] = this.tool_choice;
82
+ if (this.thinking !== null)
83
+ encoded["thinking"] = this.thinking;
84
+ if (this.output_config !== null)
85
+ encoded["output_config"] = this.output_config;
86
+ if (this.metadata !== null)
87
+ encoded["metadata"] = this.metadata;
88
+ return encoded;
89
+ }
90
+ }
91
+ export class OpenAIResponsesRequest {
92
+ model;
93
+ input;
94
+ instructions;
95
+ max_output_tokens;
96
+ max_tool_calls;
97
+ temperature;
98
+ top_p;
99
+ stream;
100
+ tools;
101
+ tool_choice;
102
+ parallel_tool_calls;
103
+ reasoning;
104
+ text;
105
+ include;
106
+ store;
107
+ previous_response_id;
108
+ prompt_cache_key;
109
+ metadata;
110
+ constructor(options) {
111
+ this.model = options.model;
112
+ this.input = options.input;
113
+ this.instructions = options.instructions ?? null;
114
+ this.max_output_tokens = options.max_output_tokens ?? null;
115
+ this.max_tool_calls = options.max_tool_calls ?? null;
116
+ this.temperature = options.temperature ?? null;
117
+ this.top_p = options.top_p ?? null;
118
+ this.stream = options.stream ?? null;
119
+ this.tools = options.tools ?? null;
120
+ this.tool_choice = options.tool_choice ?? null;
121
+ this.parallel_tool_calls = options.parallel_tool_calls ?? null;
122
+ this.reasoning = options.reasoning ?? null;
123
+ this.text = options.text ?? null;
124
+ this.include = options.include ?? null;
125
+ this.store = options.store ?? null;
126
+ this.previous_response_id = options.previous_response_id ?? null;
127
+ this.prompt_cache_key = options.prompt_cache_key ?? null;
128
+ this.metadata = options.metadata ?? null;
129
+ }
130
+ streaming() {
131
+ return new OpenAIResponsesRequest({ ...this, stream: true });
132
+ }
133
+ toWire() {
134
+ const encoded = {
135
+ model: this.model,
136
+ input: this.input,
137
+ };
138
+ if (this.instructions !== null)
139
+ encoded["instructions"] = this.instructions;
140
+ if (this.max_output_tokens !== null)
141
+ encoded["max_output_tokens"] = this.max_output_tokens;
142
+ if (this.max_tool_calls !== null)
143
+ encoded["max_tool_calls"] = this.max_tool_calls;
144
+ if (this.temperature !== null)
145
+ encoded["temperature"] = this.temperature;
146
+ if (this.top_p !== null)
147
+ encoded["top_p"] = this.top_p;
148
+ if (this.stream !== null)
149
+ encoded["stream"] = this.stream;
150
+ if (this.tools !== null)
151
+ encoded["tools"] = [...this.tools];
152
+ if (this.tool_choice !== null)
153
+ encoded["tool_choice"] = this.tool_choice;
154
+ if (this.parallel_tool_calls !== null)
155
+ encoded["parallel_tool_calls"] = this.parallel_tool_calls;
156
+ if (this.reasoning !== null)
157
+ encoded["reasoning"] = this.reasoning;
158
+ if (this.text !== null)
159
+ encoded["text"] = this.text;
160
+ if (this.include !== null)
161
+ encoded["include"] = [...this.include];
162
+ if (this.store !== null)
163
+ encoded["store"] = this.store;
164
+ if (this.previous_response_id !== null)
165
+ encoded["previous_response_id"] = this.previous_response_id;
166
+ if (this.prompt_cache_key !== null)
167
+ encoded["prompt_cache_key"] = this.prompt_cache_key;
168
+ if (this.metadata !== null)
169
+ encoded["metadata"] = this.metadata;
170
+ return encoded;
171
+ }
172
+ }
173
+ export class OpenAIChatRequest {
174
+ model;
175
+ messages;
176
+ max_completion_tokens;
177
+ max_tokens;
178
+ temperature;
179
+ top_p;
180
+ frequency_penalty;
181
+ presence_penalty;
182
+ seed;
183
+ n;
184
+ logit_bias;
185
+ stop;
186
+ stream;
187
+ stream_options;
188
+ tools;
189
+ tool_choice;
190
+ parallel_tool_calls;
191
+ response_format;
192
+ reasoning_effort;
193
+ verbosity;
194
+ prompt_cache_key;
195
+ store;
196
+ metadata;
197
+ user;
198
+ constructor(options) {
199
+ this.model = options.model;
200
+ this.messages = options.messages;
201
+ this.max_completion_tokens = options.max_completion_tokens ?? null;
202
+ this.max_tokens = options.max_tokens ?? null;
203
+ this.temperature = options.temperature ?? null;
204
+ this.top_p = options.top_p ?? null;
205
+ this.frequency_penalty = options.frequency_penalty ?? null;
206
+ this.presence_penalty = options.presence_penalty ?? null;
207
+ this.seed = options.seed ?? null;
208
+ this.n = options.n ?? null;
209
+ this.logit_bias = options.logit_bias ?? null;
210
+ this.stop = options.stop ?? null;
211
+ this.stream = options.stream ?? null;
212
+ this.stream_options = options.stream_options ?? null;
213
+ this.tools = options.tools ?? null;
214
+ this.tool_choice = options.tool_choice ?? null;
215
+ this.parallel_tool_calls = options.parallel_tool_calls ?? null;
216
+ this.response_format = options.response_format ?? null;
217
+ this.reasoning_effort = options.reasoning_effort ?? null;
218
+ this.verbosity = options.verbosity ?? null;
219
+ this.prompt_cache_key = options.prompt_cache_key ?? null;
220
+ this.store = options.store ?? null;
221
+ this.metadata = options.metadata ?? null;
222
+ this.user = options.user ?? null;
223
+ }
224
+ streaming() {
225
+ return new OpenAIChatRequest({
226
+ ...this,
227
+ stream: true,
228
+ stream_options: this.stream_options ?? { include_usage: true },
229
+ });
230
+ }
231
+ toWire() {
232
+ const encoded = {
233
+ model: this.model,
234
+ messages: this.messages.map((message) => message.toWire()),
235
+ };
236
+ if (this.max_completion_tokens !== null)
237
+ encoded["max_completion_tokens"] = this.max_completion_tokens;
238
+ if (this.max_tokens !== null)
239
+ encoded["max_tokens"] = this.max_tokens;
240
+ if (this.temperature !== null)
241
+ encoded["temperature"] = this.temperature;
242
+ if (this.top_p !== null)
243
+ encoded["top_p"] = this.top_p;
244
+ if (this.frequency_penalty !== null)
245
+ encoded["frequency_penalty"] = this.frequency_penalty;
246
+ if (this.presence_penalty !== null)
247
+ encoded["presence_penalty"] = this.presence_penalty;
248
+ if (this.seed !== null)
249
+ encoded["seed"] = this.seed;
250
+ if (this.n !== null)
251
+ encoded["n"] = this.n;
252
+ if (this.logit_bias !== null)
253
+ encoded["logit_bias"] = this.logit_bias;
254
+ if (this.stop !== null)
255
+ encoded["stop"] = this.stop;
256
+ if (this.stream !== null)
257
+ encoded["stream"] = this.stream;
258
+ if (this.stream_options !== null)
259
+ encoded["stream_options"] = this.stream_options;
260
+ if (this.tools !== null)
261
+ encoded["tools"] = this.tools.map((tool) => tool.toWire());
262
+ if (this.tool_choice !== null)
263
+ encoded["tool_choice"] = this.tool_choice;
264
+ if (this.parallel_tool_calls !== null)
265
+ encoded["parallel_tool_calls"] = this.parallel_tool_calls;
266
+ if (this.response_format !== null)
267
+ encoded["response_format"] = this.response_format;
268
+ if (this.reasoning_effort !== null)
269
+ encoded["reasoning_effort"] = this.reasoning_effort;
270
+ if (this.verbosity !== null)
271
+ encoded["verbosity"] = this.verbosity;
272
+ if (this.prompt_cache_key !== null)
273
+ encoded["prompt_cache_key"] = this.prompt_cache_key;
274
+ if (this.store !== null)
275
+ encoded["store"] = this.store;
276
+ if (this.metadata !== null)
277
+ encoded["metadata"] = this.metadata;
278
+ if (this.user !== null)
279
+ encoded["user"] = this.user;
280
+ return encoded;
281
+ }
282
+ }
283
+ export class GoogleGenerateContentRequest {
284
+ model;
285
+ contents;
286
+ systemInstruction;
287
+ tools;
288
+ toolConfig;
289
+ generationConfig;
290
+ safetySettings;
291
+ stream;
292
+ constructor(options) {
293
+ this.model = options.model;
294
+ this.contents = options.contents;
295
+ this.systemInstruction = options.systemInstruction ?? null;
296
+ this.tools = options.tools ?? null;
297
+ this.toolConfig = options.toolConfig ?? null;
298
+ this.generationConfig = options.generationConfig ?? null;
299
+ this.safetySettings = options.safetySettings ?? null;
300
+ this.stream = options.stream ?? null;
301
+ }
302
+ streaming() {
303
+ return new GoogleGenerateContentRequest({ ...this, stream: true });
304
+ }
305
+ toWire() {
306
+ const encoded = {
307
+ model: this.model,
308
+ contents: [...this.contents],
309
+ };
310
+ if (this.systemInstruction !== null)
311
+ encoded["systemInstruction"] = this.systemInstruction;
312
+ if (this.tools !== null)
313
+ encoded["tools"] = [...this.tools];
314
+ if (this.toolConfig !== null)
315
+ encoded["toolConfig"] = this.toolConfig;
316
+ if (this.generationConfig !== null)
317
+ encoded["generationConfig"] = this.generationConfig;
318
+ if (this.safetySettings !== null)
319
+ encoded["safetySettings"] = [...this.safetySettings];
320
+ if (this.stream !== null)
321
+ encoded["stream"] = this.stream;
322
+ return encoded;
323
+ }
324
+ }
325
+ export function kindTag(body) {
326
+ if (body instanceof AnthropicMessagesRequest)
327
+ return KIND_ANTHROPIC;
328
+ if (body instanceof OpenAIResponsesRequest)
329
+ return KIND_OPENAI_PRO;
330
+ if (body instanceof OpenAIChatRequest)
331
+ return KIND_OPENAI_GENERIC;
332
+ if (body instanceof GoogleGenerateContentRequest)
333
+ return KIND_GOOGLE;
334
+ throw new EncodingFailedError(new TypeError("unsupported router body type"));
335
+ }
336
+ export class SwitchboardRouter {
337
+ user_id;
338
+ time;
339
+ idempotency_key;
340
+ kind;
341
+ constructor(options) {
342
+ this.user_id = options.user_id;
343
+ this.time = options.time;
344
+ this.idempotency_key = options.idempotency_key;
345
+ this.kind = options.kind;
346
+ }
347
+ static create(userId, kind) {
348
+ return new SwitchboardRouter({
349
+ user_id: userId,
350
+ time: new Date().toISOString(),
351
+ idempotency_key: crypto.randomUUID(),
352
+ kind,
353
+ });
354
+ }
355
+ streaming() {
356
+ return new SwitchboardRouter({ ...this, kind: this.kind.streaming() });
357
+ }
358
+ toWire() {
359
+ return {
360
+ user_id: this.user_id,
361
+ time: this.time,
362
+ idempotency_key: this.idempotency_key,
363
+ kind: { [kindTag(this.kind)]: this.kind.toWire() },
364
+ };
365
+ }
366
+ }
367
+ export class AnthropicUsage {
368
+ input_tokens;
369
+ output_tokens;
370
+ cache_creation_input_tokens;
371
+ cache_read_input_tokens;
372
+ constructor(inputTokens, outputTokens, cacheCreationInputTokens = null, cacheReadInputTokens = null) {
373
+ this.input_tokens = inputTokens;
374
+ this.output_tokens = outputTokens;
375
+ this.cache_creation_input_tokens = cacheCreationInputTokens;
376
+ this.cache_read_input_tokens = cacheReadInputTokens;
377
+ }
378
+ static fromWire(value) {
379
+ const fields = wire.mapping(value, "usage");
380
+ return new AnthropicUsage(wire.integer(fields, "input_tokens", "usage"), wire.integer(fields, "output_tokens", "usage"), wire.optionalInteger(fields, "cache_creation_input_tokens", "usage"), wire.optionalInteger(fields, "cache_read_input_tokens", "usage"));
381
+ }
382
+ }
383
+ export class AnthropicMessageResponse {
384
+ id;
385
+ role;
386
+ model;
387
+ content;
388
+ stop_reason;
389
+ stop_sequence;
390
+ usage;
391
+ constructor(id, role, model, content, stopReason, stopSequence, usage) {
392
+ this.id = id;
393
+ this.role = role;
394
+ this.model = model;
395
+ this.content = content;
396
+ this.stop_reason = stopReason;
397
+ this.stop_sequence = stopSequence;
398
+ this.usage = usage;
399
+ }
400
+ get text() {
401
+ return this.content
402
+ .filter((block) => block !== null &&
403
+ typeof block === "object" &&
404
+ block["type"] === "text" &&
405
+ typeof block["text"] === "string")
406
+ .map((block) => block.text)
407
+ .join("");
408
+ }
409
+ static fromWire(value) {
410
+ const fields = wire.mapping(value, "message");
411
+ return new AnthropicMessageResponse(wire.string(fields, "id", "message"), wire.string(fields, "role", "message"), wire.string(fields, "model", "message"), wire.array(fields, "content", "message"), wire.optionalString(fields, "stop_reason", "message"), wire.optionalString(fields, "stop_sequence", "message"), AnthropicUsage.fromWire(fields["usage"]));
412
+ }
413
+ }
414
+ export class OpenAIUsage {
415
+ prompt_tokens;
416
+ completion_tokens;
417
+ total_tokens;
418
+ prompt_tokens_details;
419
+ completion_tokens_details;
420
+ constructor(promptTokens, completionTokens, totalTokens, promptTokensDetails = null, completionTokensDetails = null) {
421
+ this.prompt_tokens = promptTokens;
422
+ this.completion_tokens = completionTokens;
423
+ this.total_tokens = totalTokens;
424
+ this.prompt_tokens_details = promptTokensDetails;
425
+ this.completion_tokens_details = completionTokensDetails;
426
+ }
427
+ static fromWire(value) {
428
+ const fields = wire.mapping(value, "usage");
429
+ return new OpenAIUsage(wire.integer(fields, "prompt_tokens", "usage"), wire.integer(fields, "completion_tokens", "usage"), wire.integer(fields, "total_tokens", "usage"), wire.optionalMapping(fields, "prompt_tokens_details", "usage"), wire.optionalMapping(fields, "completion_tokens_details", "usage"));
430
+ }
431
+ }
432
+ export class OpenAIChatResponseMessage {
433
+ role;
434
+ content;
435
+ tool_calls;
436
+ constructor(role, content = null, toolCalls = null) {
437
+ this.role = role;
438
+ this.content = content;
439
+ this.tool_calls = toolCalls;
440
+ }
441
+ static fromWire(value) {
442
+ const fields = wire.mapping(value, "choice.message");
443
+ return new OpenAIChatResponseMessage(wire.string(fields, "role", "choice.message"), wire.optionalString(fields, "content", "choice.message"), wire.optionalArray(fields, "tool_calls", "choice.message"));
444
+ }
445
+ }
446
+ export class OpenAIChatChoice {
447
+ index;
448
+ message;
449
+ finish_reason;
450
+ constructor(index, message, finishReason = null) {
451
+ this.index = index;
452
+ this.message = message;
453
+ this.finish_reason = finishReason;
454
+ }
455
+ static fromWire(value) {
456
+ const fields = wire.mapping(value, "choice");
457
+ return new OpenAIChatChoice(wire.integer(fields, "index", "choice"), OpenAIChatResponseMessage.fromWire(fields["message"]), wire.optionalString(fields, "finish_reason", "choice"));
458
+ }
459
+ }
460
+ export class OpenAIChatResponse {
461
+ id;
462
+ model;
463
+ choices;
464
+ usage;
465
+ constructor(id, model, choices, usage) {
466
+ this.id = id;
467
+ this.model = model;
468
+ this.choices = choices;
469
+ this.usage = usage;
470
+ }
471
+ static fromWire(value) {
472
+ const fields = wire.mapping(value, "response");
473
+ return new OpenAIChatResponse(wire.string(fields, "id", "response"), wire.string(fields, "model", "response"), wire.array(fields, "choices", "response").map((item) => OpenAIChatChoice.fromWire(item)), OpenAIUsage.fromWire(fields["usage"]));
474
+ }
475
+ }
476
+ export class OpenAIResponsesUsage {
477
+ input_tokens;
478
+ output_tokens;
479
+ total_tokens;
480
+ input_tokens_details;
481
+ output_tokens_details;
482
+ constructor(inputTokens, outputTokens, totalTokens, inputTokensDetails = null, outputTokensDetails = null) {
483
+ this.input_tokens = inputTokens;
484
+ this.output_tokens = outputTokens;
485
+ this.total_tokens = totalTokens;
486
+ this.input_tokens_details = inputTokensDetails;
487
+ this.output_tokens_details = outputTokensDetails;
488
+ }
489
+ static fromWire(value) {
490
+ const fields = wire.mapping(value, "usage");
491
+ return new OpenAIResponsesUsage(wire.integer(fields, "input_tokens", "usage"), wire.integer(fields, "output_tokens", "usage"), wire.integer(fields, "total_tokens", "usage"), wire.optionalMapping(fields, "input_tokens_details", "usage"), wire.optionalMapping(fields, "output_tokens_details", "usage"));
492
+ }
493
+ }
494
+ export class OpenAIResponsesResponse {
495
+ id;
496
+ model;
497
+ status;
498
+ output;
499
+ usage;
500
+ constructor(id, model, status, output, usage) {
501
+ this.id = id;
502
+ this.model = model;
503
+ this.status = status;
504
+ this.output = output;
505
+ this.usage = usage;
506
+ }
507
+ get outputText() {
508
+ const collected = [];
509
+ for (const item of this.output) {
510
+ if (item === null || typeof item !== "object")
511
+ continue;
512
+ const itemFields = item;
513
+ if (itemFields["type"] !== "message")
514
+ continue;
515
+ const content = itemFields["content"];
516
+ if (!Array.isArray(content))
517
+ continue;
518
+ for (const part of content) {
519
+ if (part === null || typeof part !== "object")
520
+ continue;
521
+ const partFields = part;
522
+ if (partFields["type"] === "output_text" && typeof partFields["text"] === "string") {
523
+ collected.push(partFields["text"]);
524
+ }
525
+ }
526
+ }
527
+ return collected.join("");
528
+ }
529
+ static fromWire(value) {
530
+ const fields = wire.mapping(value, "response");
531
+ return new OpenAIResponsesResponse(wire.string(fields, "id", "response"), wire.string(fields, "model", "response"), wire.string(fields, "status", "response"), wire.array(fields, "output", "response"), OpenAIResponsesUsage.fromWire(fields["usage"]));
532
+ }
533
+ }
534
+ export class GoogleUsageMetadata {
535
+ promptTokenCount;
536
+ candidatesTokenCount;
537
+ thoughtsTokenCount;
538
+ cachedContentTokenCount;
539
+ totalTokenCount;
540
+ constructor(promptTokenCount = null, candidatesTokenCount = null, thoughtsTokenCount = null, cachedContentTokenCount = null, totalTokenCount = null) {
541
+ this.promptTokenCount = promptTokenCount;
542
+ this.candidatesTokenCount = candidatesTokenCount;
543
+ this.thoughtsTokenCount = thoughtsTokenCount;
544
+ this.cachedContentTokenCount = cachedContentTokenCount;
545
+ this.totalTokenCount = totalTokenCount;
546
+ }
547
+ static fromWire(value) {
548
+ const fields = wire.mapping(value, "usage");
549
+ return new GoogleUsageMetadata(wire.optionalInteger(fields, "promptTokenCount", "usage"), wire.optionalInteger(fields, "candidatesTokenCount", "usage"), wire.optionalInteger(fields, "thoughtsTokenCount", "usage"), wire.optionalInteger(fields, "cachedContentTokenCount", "usage"), wire.optionalInteger(fields, "totalTokenCount", "usage"));
550
+ }
551
+ }
552
+ export class GoogleGenerateContentResponse {
553
+ candidates;
554
+ usageMetadata;
555
+ modelVersion;
556
+ responseId;
557
+ constructor(candidates = null, usageMetadata = null, modelVersion = null, responseId = null) {
558
+ this.candidates = candidates;
559
+ this.usageMetadata = usageMetadata;
560
+ this.modelVersion = modelVersion;
561
+ this.responseId = responseId;
562
+ }
563
+ static fromWire(value) {
564
+ const fields = wire.mapping(value, "response");
565
+ const usageMetadataWire = fields["usageMetadata"];
566
+ return new GoogleGenerateContentResponse(wire.optionalArray(fields, "candidates", "response"), usageMetadataWire === null || usageMetadataWire === undefined
567
+ ? null
568
+ : GoogleUsageMetadata.fromWire(usageMetadataWire), wire.optionalString(fields, "modelVersion", "response"), wire.optionalString(fields, "responseId", "response"));
569
+ }
570
+ }
571
+ export var AnthropicStream;
572
+ (function (AnthropicStream) {
573
+ class MessageStart {
574
+ message;
575
+ constructor(message) {
576
+ this.message = message;
577
+ }
578
+ }
579
+ AnthropicStream.MessageStart = MessageStart;
580
+ class ContentBlockStart {
581
+ index;
582
+ content_block;
583
+ constructor(index, contentBlock) {
584
+ this.index = index;
585
+ this.content_block = contentBlock;
586
+ }
587
+ }
588
+ AnthropicStream.ContentBlockStart = ContentBlockStart;
589
+ class ContentBlockDelta {
590
+ index;
591
+ delta;
592
+ constructor(index, delta) {
593
+ this.index = index;
594
+ this.delta = delta;
595
+ }
596
+ }
597
+ AnthropicStream.ContentBlockDelta = ContentBlockDelta;
598
+ class ContentBlockStop {
599
+ index;
600
+ constructor(index) {
601
+ this.index = index;
602
+ }
603
+ }
604
+ AnthropicStream.ContentBlockStop = ContentBlockStop;
605
+ class MessageDelta {
606
+ delta;
607
+ usage;
608
+ constructor(delta, usage) {
609
+ this.delta = delta;
610
+ this.usage = usage;
611
+ }
612
+ }
613
+ AnthropicStream.MessageDelta = MessageDelta;
614
+ class MessageStop {
615
+ }
616
+ AnthropicStream.MessageStop = MessageStop;
617
+ class Ping {
618
+ }
619
+ AnthropicStream.Ping = Ping;
620
+ class Error {
621
+ error_type;
622
+ message;
623
+ constructor(errorType, message) {
624
+ this.error_type = errorType;
625
+ this.message = message;
626
+ }
627
+ }
628
+ AnthropicStream.Error = Error;
629
+ function parse(value) {
630
+ const fields = wire.mapping(value, "anthropic event");
631
+ const eventType = wire.string(fields, "type", "anthropic event");
632
+ if (eventType === "message_start") {
633
+ return new MessageStart(wire.mapping(fields["message"], "message_start.message"));
634
+ }
635
+ if (eventType === "content_block_start") {
636
+ return new ContentBlockStart(wire.integer(fields, "index", "content_block_start"), wire.mapping(fields["content_block"], "content_block_start.content_block"));
637
+ }
638
+ if (eventType === "content_block_delta") {
639
+ return new ContentBlockDelta(wire.integer(fields, "index", "content_block_delta"), wire.mapping(fields["delta"], "content_block_delta.delta"));
640
+ }
641
+ if (eventType === "content_block_stop") {
642
+ return new ContentBlockStop(wire.integer(fields, "index", "content_block_stop"));
643
+ }
644
+ if (eventType === "message_delta") {
645
+ return new MessageDelta(wire.mapping(fields["delta"], "message_delta.delta"), wire.mapping(fields["usage"], "message_delta.usage"));
646
+ }
647
+ if (eventType === "message_stop") {
648
+ return new MessageStop();
649
+ }
650
+ if (eventType === "ping") {
651
+ return new Ping();
652
+ }
653
+ if (eventType === "error") {
654
+ const errorFields = wire.mapping(fields["error"], "error.error");
655
+ return new Error(wire.string(errorFields, "type", "error.error"), wire.string(errorFields, "message", "error.error"));
656
+ }
657
+ return null;
658
+ }
659
+ AnthropicStream.parse = parse;
660
+ })(AnthropicStream || (AnthropicStream = {}));
661
+ export class OpenAIChatChunkChoice {
662
+ index;
663
+ delta;
664
+ finish_reason;
665
+ constructor(index, delta, finishReason = null) {
666
+ this.index = index;
667
+ this.delta = delta;
668
+ this.finish_reason = finishReason;
669
+ }
670
+ static fromWire(value) {
671
+ const fields = wire.mapping(value, "chunk.choice");
672
+ return new OpenAIChatChunkChoice(wire.integer(fields, "index", "chunk.choice"), wire.mapping(fields["delta"], "chunk.choice.delta"), wire.optionalString(fields, "finish_reason", "chunk.choice"));
673
+ }
674
+ }
675
+ export class OpenAIChatChunk {
676
+ id;
677
+ model;
678
+ choices;
679
+ usage;
680
+ constructor(id, model, choices, usage = null) {
681
+ this.id = id;
682
+ this.model = model;
683
+ this.choices = choices;
684
+ this.usage = usage;
685
+ }
686
+ static fromWire(value) {
687
+ const fields = wire.mapping(value, "chunk");
688
+ const usageWire = fields["usage"];
689
+ return new OpenAIChatChunk(wire.string(fields, "id", "chunk"), wire.string(fields, "model", "chunk"), wire.array(fields, "choices", "chunk").map((item) => OpenAIChatChunkChoice.fromWire(item)), usageWire === null || usageWire === undefined ? null : OpenAIUsage.fromWire(usageWire));
690
+ }
691
+ }
692
+ export var OpenAIResponsesStream;
693
+ (function (OpenAIResponsesStream) {
694
+ class ResponseCreated {
695
+ response;
696
+ constructor(response) {
697
+ this.response = response;
698
+ }
699
+ }
700
+ OpenAIResponsesStream.ResponseCreated = ResponseCreated;
701
+ class ResponseInProgress {
702
+ response;
703
+ constructor(response) {
704
+ this.response = response;
705
+ }
706
+ }
707
+ OpenAIResponsesStream.ResponseInProgress = ResponseInProgress;
708
+ class OutputItemAdded {
709
+ output_index;
710
+ item;
711
+ constructor(outputIndex, item) {
712
+ this.output_index = outputIndex;
713
+ this.item = item;
714
+ }
715
+ }
716
+ OpenAIResponsesStream.OutputItemAdded = OutputItemAdded;
717
+ class ContentPartAdded {
718
+ item_id;
719
+ output_index;
720
+ content_index;
721
+ part;
722
+ constructor(itemId, outputIndex, contentIndex, part) {
723
+ this.item_id = itemId;
724
+ this.output_index = outputIndex;
725
+ this.content_index = contentIndex;
726
+ this.part = part;
727
+ }
728
+ }
729
+ OpenAIResponsesStream.ContentPartAdded = ContentPartAdded;
730
+ class OutputTextDelta {
731
+ delta;
732
+ constructor(delta) {
733
+ this.delta = delta;
734
+ }
735
+ }
736
+ OpenAIResponsesStream.OutputTextDelta = OutputTextDelta;
737
+ class OutputTextDone {
738
+ item_id;
739
+ output_index;
740
+ content_index;
741
+ text;
742
+ constructor(itemId, outputIndex, contentIndex, text) {
743
+ this.item_id = itemId;
744
+ this.output_index = outputIndex;
745
+ this.content_index = contentIndex;
746
+ this.text = text;
747
+ }
748
+ }
749
+ OpenAIResponsesStream.OutputTextDone = OutputTextDone;
750
+ class ContentPartDone {
751
+ item_id;
752
+ output_index;
753
+ content_index;
754
+ part;
755
+ constructor(itemId, outputIndex, contentIndex, part) {
756
+ this.item_id = itemId;
757
+ this.output_index = outputIndex;
758
+ this.content_index = contentIndex;
759
+ this.part = part;
760
+ }
761
+ }
762
+ OpenAIResponsesStream.ContentPartDone = ContentPartDone;
763
+ class FunctionCallArgumentsDelta {
764
+ item_id;
765
+ output_index;
766
+ delta;
767
+ constructor(itemId, outputIndex, delta) {
768
+ this.item_id = itemId;
769
+ this.output_index = outputIndex;
770
+ this.delta = delta;
771
+ }
772
+ }
773
+ OpenAIResponsesStream.FunctionCallArgumentsDelta = FunctionCallArgumentsDelta;
774
+ class FunctionCallArgumentsDone {
775
+ item_id;
776
+ output_index;
777
+ name;
778
+ arguments;
779
+ constructor(itemId, outputIndex, name, argumentsText) {
780
+ this.item_id = itemId;
781
+ this.output_index = outputIndex;
782
+ this.name = name;
783
+ this.arguments = argumentsText;
784
+ }
785
+ }
786
+ OpenAIResponsesStream.FunctionCallArgumentsDone = FunctionCallArgumentsDone;
787
+ class ReasoningSummaryTextDelta {
788
+ item_id;
789
+ output_index;
790
+ summary_index;
791
+ delta;
792
+ constructor(itemId, outputIndex, summaryIndex, delta) {
793
+ this.item_id = itemId;
794
+ this.output_index = outputIndex;
795
+ this.summary_index = summaryIndex;
796
+ this.delta = delta;
797
+ }
798
+ }
799
+ OpenAIResponsesStream.ReasoningSummaryTextDelta = ReasoningSummaryTextDelta;
800
+ class OutputItemDone {
801
+ item;
802
+ constructor(item) {
803
+ this.item = item;
804
+ }
805
+ }
806
+ OpenAIResponsesStream.OutputItemDone = OutputItemDone;
807
+ class ResponseCompleted {
808
+ response;
809
+ constructor(response) {
810
+ this.response = response;
811
+ }
812
+ }
813
+ OpenAIResponsesStream.ResponseCompleted = ResponseCompleted;
814
+ class ResponseIncomplete {
815
+ response;
816
+ constructor(response) {
817
+ this.response = response;
818
+ }
819
+ }
820
+ OpenAIResponsesStream.ResponseIncomplete = ResponseIncomplete;
821
+ class ResponseFailed {
822
+ response;
823
+ constructor(response) {
824
+ this.response = response;
825
+ }
826
+ }
827
+ OpenAIResponsesStream.ResponseFailed = ResponseFailed;
828
+ class Error {
829
+ message;
830
+ constructor(message) {
831
+ this.message = message;
832
+ }
833
+ }
834
+ OpenAIResponsesStream.Error = Error;
835
+ function parse(value) {
836
+ const fields = wire.mapping(value, "responses event");
837
+ const eventType = wire.string(fields, "type", "responses event");
838
+ if (eventType === "response.created") {
839
+ return new ResponseCreated(wire.mapping(fields["response"], "response.created.response"));
840
+ }
841
+ if (eventType === "response.in_progress") {
842
+ return new ResponseInProgress(wire.mapping(fields["response"], "response.in_progress.response"));
843
+ }
844
+ if (eventType === "response.output_item.added") {
845
+ return new OutputItemAdded(wire.integer(fields, "output_index", "response.output_item.added"), wire.mapping(fields["item"], "response.output_item.added.item"));
846
+ }
847
+ if (eventType === "response.content_part.added") {
848
+ return new ContentPartAdded(wire.string(fields, "item_id", "response.content_part.added"), wire.integer(fields, "output_index", "response.content_part.added"), wire.integer(fields, "content_index", "response.content_part.added"), wire.mapping(fields["part"], "response.content_part.added.part"));
849
+ }
850
+ if (eventType === "response.output_text.delta") {
851
+ return new OutputTextDelta(wire.string(fields, "delta", "response.output_text.delta"));
852
+ }
853
+ if (eventType === "response.output_text.done") {
854
+ return new OutputTextDone(wire.string(fields, "item_id", "response.output_text.done"), wire.integer(fields, "output_index", "response.output_text.done"), wire.integer(fields, "content_index", "response.output_text.done"), wire.string(fields, "text", "response.output_text.done"));
855
+ }
856
+ if (eventType === "response.content_part.done") {
857
+ return new ContentPartDone(wire.string(fields, "item_id", "response.content_part.done"), wire.integer(fields, "output_index", "response.content_part.done"), wire.integer(fields, "content_index", "response.content_part.done"), wire.mapping(fields["part"], "response.content_part.done.part"));
858
+ }
859
+ if (eventType === "response.function_call_arguments.delta") {
860
+ return new FunctionCallArgumentsDelta(wire.string(fields, "item_id", "response.function_call_arguments.delta"), wire.integer(fields, "output_index", "response.function_call_arguments.delta"), wire.string(fields, "delta", "response.function_call_arguments.delta"));
861
+ }
862
+ if (eventType === "response.function_call_arguments.done") {
863
+ return new FunctionCallArgumentsDone(wire.string(fields, "item_id", "response.function_call_arguments.done"), wire.integer(fields, "output_index", "response.function_call_arguments.done"), wire.string(fields, "name", "response.function_call_arguments.done"), wire.string(fields, "arguments", "response.function_call_arguments.done"));
864
+ }
865
+ if (eventType === "response.reasoning_summary_text.delta") {
866
+ return new ReasoningSummaryTextDelta(wire.string(fields, "item_id", "response.reasoning_summary_text.delta"), wire.integer(fields, "output_index", "response.reasoning_summary_text.delta"), wire.integer(fields, "summary_index", "response.reasoning_summary_text.delta"), wire.string(fields, "delta", "response.reasoning_summary_text.delta"));
867
+ }
868
+ if (eventType === "response.output_item.done") {
869
+ return new OutputItemDone(wire.mapping(fields["item"], "response.output_item.done.item"));
870
+ }
871
+ if (eventType === "response.completed") {
872
+ return new ResponseCompleted(wire.mapping(fields["response"], "response.completed.response"));
873
+ }
874
+ if (eventType === "response.incomplete") {
875
+ return new ResponseIncomplete(wire.mapping(fields["response"], "response.incomplete.response"));
876
+ }
877
+ if (eventType === "response.failed") {
878
+ return new ResponseFailed(wire.mapping(fields["response"], "response.failed.response"));
879
+ }
880
+ if (eventType === "error") {
881
+ return new Error(wire.string(fields, "message", "error"));
882
+ }
883
+ return null;
884
+ }
885
+ OpenAIResponsesStream.parse = parse;
886
+ })(OpenAIResponsesStream || (OpenAIResponsesStream = {}));