alchemylab-opencode 1.0.19 → 1.0.21

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 (101) hide show
  1. package/dist/{log-TOR3B2F5.js → arktype-aI7TBD0R-ETU7X65Q.js} +1 -8
  2. package/dist/chunk-5MPKKAWG.js +2215 -0
  3. package/dist/chunk-7KKA6WBY.js +12 -0
  4. package/dist/chunk-A4S3BYGY.js +12 -0
  5. package/dist/chunk-ABCQLKMJ.js +12 -0
  6. package/dist/chunk-BGADAZN4.js +0 -1
  7. package/dist/chunk-CMU5MV6S.js +75 -0
  8. package/dist/chunk-DBKYWUEM.js +18 -0
  9. package/dist/{mcp-W2Z3DXFD.js → chunk-LTCXIXYM.js} +1 -12
  10. package/dist/chunk-M4CB72HE.js +13 -0
  11. package/dist/chunk-MBZTOEAD.js +12 -0
  12. package/dist/chunk-N2IDMOID.js +18 -0
  13. package/dist/chunk-N7PLTD3P.js +13 -0
  14. package/dist/chunk-T6MY2WE4.js +12 -0
  15. package/dist/{chunk-H5AN6PD4.js → chunk-T7EXROHP.js} +1 -19
  16. package/dist/{schema-EWYI6LGA.js → chunk-XREX5MYM.js} +1 -13
  17. package/dist/{run-service-B4BDQWO3.js → default-u_dwuiYb-5QQ4GXMV.js} +1 -12
  18. package/dist/effect-QlVUlMFu-ORZ7TVO5.js +12 -0
  19. package/dist/log-MVJ7H4K5.js +12 -0
  20. package/dist/mcp-BCTN55WE.js +12 -0
  21. package/dist/{default-u_dwuiYb-644FBWJS.js → pty.node-X2EITEZ4.js} +1 -11
  22. package/dist/registry-MRPMZCK4.js +12 -0
  23. package/dist/run-O75PTUSN.js +20 -0
  24. package/dist/run-service-IUIOP7ZW.js +12 -0
  25. package/dist/run.js +1 -11
  26. package/dist/schema-YWIVP7UR.js +12 -0
  27. package/dist/serve.js +1 -40
  28. package/dist/server-QXCNOJQJ.js +12 -0
  29. package/dist/session-OLERO43H.js +12 -0
  30. package/dist/share-next-7PZI7GKT.js +12 -0
  31. package/dist/sury-CWZTCd75-IXNCX752.js +12 -0
  32. package/dist/typebox-Dei93FPO-K67WT2FO.js +12 -0
  33. package/dist/valibot--1zFm7rT-SSCP4J5I.js +12 -0
  34. package/dist/valibot-D_HTw1Gn-KPCJMJMC.js +12 -0
  35. package/dist/worktree-43SDNYPU.js +12 -0
  36. package/dist/{arktype-aI7TBD0R-LH6JTJZZ.js → zod-Bwrt9trS-BYLM45IZ.js} +1 -10
  37. package/dist/{chunk-BI5OUHTQ.js → zod-DSgpEGAE-T3VJY2W3.js} +1 -20
  38. package/package.json +2 -2
  39. package/dist/arktype-aI7TBD0R-LH6JTJZZ.js.map +0 -7
  40. package/dist/chunk-2FM4SJ4F.js +0 -506
  41. package/dist/chunk-2FM4SJ4F.js.map +0 -7
  42. package/dist/chunk-4UCKACGO.js +0 -106
  43. package/dist/chunk-4UCKACGO.js.map +0 -7
  44. package/dist/chunk-AHJSL352.js +0 -160
  45. package/dist/chunk-AHJSL352.js.map +0 -7
  46. package/dist/chunk-ASJTXZ3G.js +0 -730
  47. package/dist/chunk-ASJTXZ3G.js.map +0 -7
  48. package/dist/chunk-BGADAZN4.js.map +0 -7
  49. package/dist/chunk-BI5OUHTQ.js.map +0 -7
  50. package/dist/chunk-COCF34ZS.js +0 -144
  51. package/dist/chunk-COCF34ZS.js.map +0 -7
  52. package/dist/chunk-E2D2QSW7.js +0 -6675
  53. package/dist/chunk-E2D2QSW7.js.map +0 -7
  54. package/dist/chunk-FXA7YNMN.js +0 -49
  55. package/dist/chunk-FXA7YNMN.js.map +0 -7
  56. package/dist/chunk-H5AN6PD4.js.map +0 -7
  57. package/dist/chunk-HORZKFCR.js +0 -88
  58. package/dist/chunk-HORZKFCR.js.map +0 -7
  59. package/dist/chunk-PV6JYN6T.js +0 -24205
  60. package/dist/chunk-PV6JYN6T.js.map +0 -7
  61. package/dist/chunk-RYVKLRJZ.js +0 -321
  62. package/dist/chunk-RYVKLRJZ.js.map +0 -7
  63. package/dist/chunk-SZM3G6UF.js +0 -1857
  64. package/dist/chunk-SZM3G6UF.js.map +0 -7
  65. package/dist/chunk-WHJ5FGUS.js +0 -5706
  66. package/dist/chunk-WHJ5FGUS.js.map +0 -7
  67. package/dist/default-u_dwuiYb-644FBWJS.js.map +0 -7
  68. package/dist/effect-QlVUlMFu-GLKKNZAC.js +0 -29
  69. package/dist/effect-QlVUlMFu-GLKKNZAC.js.map +0 -7
  70. package/dist/log-TOR3B2F5.js.map +0 -7
  71. package/dist/mcp-W2Z3DXFD.js.map +0 -7
  72. package/dist/pty.node-RHOAUGH6.js +0 -40
  73. package/dist/pty.node-RHOAUGH6.js.map +0 -7
  74. package/dist/registry-FWM7Q3YW.js +0 -24
  75. package/dist/registry-FWM7Q3YW.js.map +0 -7
  76. package/dist/run-PMUMTYTZ.js +0 -4796
  77. package/dist/run-PMUMTYTZ.js.map +0 -7
  78. package/dist/run-service-B4BDQWO3.js.map +0 -7
  79. package/dist/run.js.map +0 -7
  80. package/dist/schema-EWYI6LGA.js.map +0 -7
  81. package/dist/serve.js.map +0 -7
  82. package/dist/server-HETOVWO6.js +0 -30
  83. package/dist/server-HETOVWO6.js.map +0 -7
  84. package/dist/session-37HDF4U2.js +0 -24
  85. package/dist/session-37HDF4U2.js.map +0 -7
  86. package/dist/share-next-MP7REE74.js +0 -25
  87. package/dist/share-next-MP7REE74.js.map +0 -7
  88. package/dist/sury-CWZTCd75-SVV5EKIT.js +0 -29
  89. package/dist/sury-CWZTCd75-SVV5EKIT.js.map +0 -7
  90. package/dist/typebox-Dei93FPO-LMTONO64.js +0 -21
  91. package/dist/typebox-Dei93FPO-LMTONO64.js.map +0 -7
  92. package/dist/valibot--1zFm7rT-HRT4VHTJ.js +0 -29
  93. package/dist/valibot--1zFm7rT-HRT4VHTJ.js.map +0 -7
  94. package/dist/valibot-D_HTw1Gn-SZJR3J76.js +0 -60
  95. package/dist/valibot-D_HTw1Gn-SZJR3J76.js.map +0 -7
  96. package/dist/worktree-ADWVQ6IR.js +0 -64
  97. package/dist/worktree-ADWVQ6IR.js.map +0 -7
  98. package/dist/zod-Bwrt9trS-5S7UQQDY.js +0 -43
  99. package/dist/zod-Bwrt9trS-5S7UQQDY.js.map +0 -7
  100. package/dist/zod-DSgpEGAE-X2KPFU7C.js +0 -56
  101. package/dist/zod-DSgpEGAE-X2KPFU7C.js.map +0 -7
@@ -1,4796 +0,0 @@
1
- // Built by esbuild from opencode-server source
2
- if (typeof globalThis.Bun === 'undefined') {
3
- globalThis.Bun = {
4
- version: '0.0.0-node-compat',
5
- stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
- which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
- };
8
- }
9
- if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
- if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
-
12
- import {
13
- Server
14
- } from "./chunk-WHJ5FGUS.js";
15
- import {
16
- InstanceBootstrap
17
- } from "./chunk-ASJTXZ3G.js";
18
- import "./chunk-RYVKLRJZ.js";
19
- import "./chunk-FXA7YNMN.js";
20
- import "./chunk-BGADAZN4.js";
21
- import {
22
- Agent,
23
- Provider
24
- } from "./chunk-PV6JYN6T.js";
25
- import "./chunk-E2D2QSW7.js";
26
- import {
27
- Flag,
28
- Instance,
29
- NamedError
30
- } from "./chunk-SZM3G6UF.js";
31
- import "./chunk-COCF34ZS.js";
32
- import "./chunk-BI5OUHTQ.js";
33
- import {
34
- Filesystem
35
- } from "./chunk-2FM4SJ4F.js";
36
- import "./chunk-AHJSL352.js";
37
- import {
38
- __require
39
- } from "./chunk-HORZKFCR.js";
40
-
41
- // packages/opencode/src/cli/cmd/run.ts
42
- import path from "path";
43
- import { pathToFileURL } from "url";
44
-
45
- // packages/opencode/src/cli/ui.ts
46
- import z from "zod";
47
- import { EOL } from "os";
48
-
49
- // packages/opencode/src/cli/logo.ts
50
- var logo = {
51
- left: [" ", "\u2588\u2580\u2580\u2588 \u2588\u2580\u2580\u2588 \u2588\u2580\u2580\u2588 \u2588\u2580\u2580\u2584", "\u2588__\u2588 \u2588__\u2588 \u2588^^^ \u2588__\u2588", "\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580 \u2580\u2580\u2580\u2580 \u2580~~\u2580"],
52
- right: [" \u2584 ", "\u2588\u2580\u2580\u2580 \u2588\u2580\u2580\u2588 \u2588\u2580\u2580\u2588 \u2588\u2580\u2580\u2588", "\u2588___ \u2588__\u2588 \u2588__\u2588 \u2588^^^", "\u2580\u2580\u2580\u2580 \u2580\u2580\u2580\u2580 \u2580\u2580\u2580\u2580 \u2580\u2580\u2580\u2580"]
53
- };
54
-
55
- // packages/opencode/src/cli/ui.ts
56
- var UI;
57
- ((UI2) => {
58
- const wordmark = [
59
- `\u2800 \u2584 `,
60
- `\u2588\u2580\u2580\u2588 \u2588\u2580\u2580\u2588 \u2588\u2580\u2580\u2588 \u2588\u2580\u2580\u2584 \u2588\u2580\u2580\u2580 \u2588\u2580\u2580\u2588 \u2588\u2580\u2580\u2588 \u2588\u2580\u2580\u2588`,
61
- `\u2588 \u2588 \u2588 \u2588 \u2588\u2580\u2580\u2580 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2580\u2580\u2580`,
62
- `\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580 \u2580\u2580\u2580\u2580 \u2580 \u2580 \u2580\u2580\u2580\u2580 \u2580\u2580\u2580\u2580 \u2580\u2580\u2580\u2580 \u2580\u2580\u2580\u2580`
63
- ];
64
- UI2.CancelledError = NamedError.create("UICancelledError", z.void());
65
- UI2.Style = {
66
- TEXT_HIGHLIGHT: "\x1B[96m",
67
- TEXT_HIGHLIGHT_BOLD: "\x1B[96m\x1B[1m",
68
- TEXT_DIM: "\x1B[90m",
69
- TEXT_DIM_BOLD: "\x1B[90m\x1B[1m",
70
- TEXT_NORMAL: "\x1B[0m",
71
- TEXT_NORMAL_BOLD: "\x1B[1m",
72
- TEXT_WARNING: "\x1B[93m",
73
- TEXT_WARNING_BOLD: "\x1B[93m\x1B[1m",
74
- TEXT_DANGER: "\x1B[91m",
75
- TEXT_DANGER_BOLD: "\x1B[91m\x1B[1m",
76
- TEXT_SUCCESS: "\x1B[92m",
77
- TEXT_SUCCESS_BOLD: "\x1B[92m\x1B[1m",
78
- TEXT_INFO: "\x1B[94m",
79
- TEXT_INFO_BOLD: "\x1B[94m\x1B[1m"
80
- };
81
- function println(...message) {
82
- print(...message);
83
- process.stderr.write(EOL);
84
- }
85
- UI2.println = println;
86
- function print(...message) {
87
- blank = false;
88
- process.stderr.write(message.join(" "));
89
- }
90
- UI2.print = print;
91
- let blank = false;
92
- function empty() {
93
- if (blank) return;
94
- println("" + UI2.Style.TEXT_NORMAL);
95
- blank = true;
96
- }
97
- UI2.empty = empty;
98
- function logo2(pad) {
99
- if (!process.stdout.isTTY && !process.stderr.isTTY) {
100
- const result2 = [];
101
- for (const row of wordmark) {
102
- if (pad) result2.push(pad);
103
- result2.push(row);
104
- result2.push(EOL);
105
- }
106
- return result2.join("").trimEnd();
107
- }
108
- const result = [];
109
- const reset = "\x1B[0m";
110
- const left = {
111
- fg: "\x1B[90m",
112
- shadow: "\x1B[38;5;235m",
113
- bg: "\x1B[48;5;235m"
114
- };
115
- const right = {
116
- fg: reset,
117
- shadow: "\x1B[38;5;238m",
118
- bg: "\x1B[48;5;238m"
119
- };
120
- const gap = " ";
121
- const draw = (line, fg, shadow, bg) => {
122
- const parts = [];
123
- for (const char of line) {
124
- if (char === "_") {
125
- parts.push(bg, " ", reset);
126
- continue;
127
- }
128
- if (char === "^") {
129
- parts.push(fg, bg, "\u2580", reset);
130
- continue;
131
- }
132
- if (char === "~") {
133
- parts.push(shadow, "\u2580", reset);
134
- continue;
135
- }
136
- if (char === " ") {
137
- parts.push(" ");
138
- continue;
139
- }
140
- parts.push(fg, char, reset);
141
- }
142
- return parts.join("");
143
- };
144
- logo.left.forEach((row, index) => {
145
- if (pad) result.push(pad);
146
- result.push(draw(row, left.fg, left.shadow, left.bg));
147
- result.push(gap);
148
- const other = logo.right[index] ?? "";
149
- result.push(draw(other, right.fg, right.shadow, right.bg));
150
- result.push(EOL);
151
- });
152
- return result.join("").trimEnd();
153
- }
154
- UI2.logo = logo2;
155
- async function input(prompt) {
156
- const readline = __require("readline");
157
- const rl = readline.createInterface({
158
- input: process.stdin,
159
- output: process.stdout
160
- });
161
- return new Promise((resolve) => {
162
- rl.question(prompt, (answer) => {
163
- rl.close();
164
- resolve(answer.trim());
165
- });
166
- });
167
- }
168
- UI2.input = input;
169
- function error(message) {
170
- if (message.startsWith("Error: ")) {
171
- message = message.slice("Error: ".length);
172
- }
173
- println(UI2.Style.TEXT_DANGER_BOLD + "Error: " + UI2.Style.TEXT_NORMAL + message);
174
- }
175
- UI2.error = error;
176
- function markdown(text) {
177
- return text;
178
- }
179
- UI2.markdown = markdown;
180
- })(UI || (UI = {}));
181
-
182
- // packages/opencode/src/cli/cmd/cmd.ts
183
- function cmd(input) {
184
- return input;
185
- }
186
-
187
- // packages/opencode/src/cli/bootstrap.ts
188
- async function bootstrap(directory, cb) {
189
- return Instance.provide({
190
- directory,
191
- init: InstanceBootstrap,
192
- fn: async () => {
193
- try {
194
- const result = await cb();
195
- return result;
196
- } finally {
197
- await Instance.dispose();
198
- }
199
- }
200
- });
201
- }
202
-
203
- // packages/opencode/src/cli/cmd/run.ts
204
- import { EOL as EOL2 } from "os";
205
-
206
- // packages/sdk/src/v2/gen/core/serverSentEvents.gen.ts
207
- var createSseClient = ({
208
- onRequest,
209
- onSseError,
210
- onSseEvent,
211
- responseTransformer,
212
- responseValidator,
213
- sseDefaultRetryDelay,
214
- sseMaxRetryAttempts,
215
- sseMaxRetryDelay,
216
- sseSleepFn,
217
- url,
218
- ...options
219
- }) => {
220
- let lastEventId;
221
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
222
- const createStream = async function* () {
223
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
224
- let attempt = 0;
225
- const signal = options.signal ?? new AbortController().signal;
226
- while (true) {
227
- if (signal.aborted) break;
228
- attempt++;
229
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
230
- if (lastEventId !== void 0) {
231
- headers.set("Last-Event-ID", lastEventId);
232
- }
233
- try {
234
- const requestInit = {
235
- redirect: "follow",
236
- ...options,
237
- body: options.serializedBody,
238
- headers,
239
- signal
240
- };
241
- let request = new Request(url, requestInit);
242
- if (onRequest) {
243
- request = await onRequest(url, requestInit);
244
- }
245
- const _fetch = options.fetch ?? globalThis.fetch;
246
- const response = await _fetch(request);
247
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
248
- if (!response.body) throw new Error("No body in SSE response");
249
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
250
- let buffer = "";
251
- const abortHandler = () => {
252
- try {
253
- reader.cancel();
254
- } catch {
255
- }
256
- };
257
- signal.addEventListener("abort", abortHandler);
258
- try {
259
- while (true) {
260
- const { done, value } = await reader.read();
261
- if (done) break;
262
- buffer += value;
263
- buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
264
- const chunks = buffer.split("\n\n");
265
- buffer = chunks.pop() ?? "";
266
- for (const chunk of chunks) {
267
- const lines = chunk.split("\n");
268
- const dataLines = [];
269
- let eventName;
270
- for (const line of lines) {
271
- if (line.startsWith("data:")) {
272
- dataLines.push(line.replace(/^data:\s*/, ""));
273
- } else if (line.startsWith("event:")) {
274
- eventName = line.replace(/^event:\s*/, "");
275
- } else if (line.startsWith("id:")) {
276
- lastEventId = line.replace(/^id:\s*/, "");
277
- } else if (line.startsWith("retry:")) {
278
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
279
- if (!Number.isNaN(parsed)) {
280
- retryDelay = parsed;
281
- }
282
- }
283
- }
284
- let data;
285
- let parsedJson = false;
286
- if (dataLines.length) {
287
- const rawData = dataLines.join("\n");
288
- try {
289
- data = JSON.parse(rawData);
290
- parsedJson = true;
291
- } catch {
292
- data = rawData;
293
- }
294
- }
295
- if (parsedJson) {
296
- if (responseValidator) {
297
- await responseValidator(data);
298
- }
299
- if (responseTransformer) {
300
- data = await responseTransformer(data);
301
- }
302
- }
303
- onSseEvent?.({
304
- data,
305
- event: eventName,
306
- id: lastEventId,
307
- retry: retryDelay
308
- });
309
- if (dataLines.length) {
310
- yield data;
311
- }
312
- }
313
- }
314
- } finally {
315
- signal.removeEventListener("abort", abortHandler);
316
- reader.releaseLock();
317
- }
318
- break;
319
- } catch (error) {
320
- onSseError?.(error);
321
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
322
- break;
323
- }
324
- const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
325
- await sleep(backoff);
326
- }
327
- }
328
- };
329
- const stream = createStream();
330
- return { stream };
331
- };
332
-
333
- // packages/sdk/src/v2/gen/core/pathSerializer.gen.ts
334
- var separatorArrayExplode = (style) => {
335
- switch (style) {
336
- case "label":
337
- return ".";
338
- case "matrix":
339
- return ";";
340
- case "simple":
341
- return ",";
342
- default:
343
- return "&";
344
- }
345
- };
346
- var separatorArrayNoExplode = (style) => {
347
- switch (style) {
348
- case "form":
349
- return ",";
350
- case "pipeDelimited":
351
- return "|";
352
- case "spaceDelimited":
353
- return "%20";
354
- default:
355
- return ",";
356
- }
357
- };
358
- var separatorObjectExplode = (style) => {
359
- switch (style) {
360
- case "label":
361
- return ".";
362
- case "matrix":
363
- return ";";
364
- case "simple":
365
- return ",";
366
- default:
367
- return "&";
368
- }
369
- };
370
- var serializeArrayParam = ({
371
- allowReserved,
372
- explode,
373
- name,
374
- style,
375
- value
376
- }) => {
377
- if (!explode) {
378
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(
379
- separatorArrayNoExplode(style)
380
- );
381
- switch (style) {
382
- case "label":
383
- return `.${joinedValues2}`;
384
- case "matrix":
385
- return `;${name}=${joinedValues2}`;
386
- case "simple":
387
- return joinedValues2;
388
- default:
389
- return `${name}=${joinedValues2}`;
390
- }
391
- }
392
- const separator = separatorArrayExplode(style);
393
- const joinedValues = value.map((v) => {
394
- if (style === "label" || style === "simple") {
395
- return allowReserved ? v : encodeURIComponent(v);
396
- }
397
- return serializePrimitiveParam({
398
- allowReserved,
399
- name,
400
- value: v
401
- });
402
- }).join(separator);
403
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
404
- };
405
- var serializePrimitiveParam = ({ allowReserved, name, value }) => {
406
- if (value === void 0 || value === null) {
407
- return "";
408
- }
409
- if (typeof value === "object") {
410
- throw new Error(
411
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
412
- );
413
- }
414
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
415
- };
416
- var serializeObjectParam = ({
417
- allowReserved,
418
- explode,
419
- name,
420
- style,
421
- value,
422
- valueOnly
423
- }) => {
424
- if (value instanceof Date) {
425
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
426
- }
427
- if (style !== "deepObject" && !explode) {
428
- let values = [];
429
- Object.entries(value).forEach(([key, v]) => {
430
- values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
431
- });
432
- const joinedValues2 = values.join(",");
433
- switch (style) {
434
- case "form":
435
- return `${name}=${joinedValues2}`;
436
- case "label":
437
- return `.${joinedValues2}`;
438
- case "matrix":
439
- return `;${name}=${joinedValues2}`;
440
- default:
441
- return joinedValues2;
442
- }
443
- }
444
- const separator = separatorObjectExplode(style);
445
- const joinedValues = Object.entries(value).map(
446
- ([key, v]) => serializePrimitiveParam({
447
- allowReserved,
448
- name: style === "deepObject" ? `${name}[${key}]` : key,
449
- value: v
450
- })
451
- ).join(separator);
452
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
453
- };
454
-
455
- // packages/sdk/src/v2/gen/core/utils.gen.ts
456
- var PATH_PARAM_RE = /\{[^{}]+\}/g;
457
- var defaultPathSerializer = ({ path: path2, url: _url }) => {
458
- let url = _url;
459
- const matches = _url.match(PATH_PARAM_RE);
460
- if (matches) {
461
- for (const match of matches) {
462
- let explode = false;
463
- let name = match.substring(1, match.length - 1);
464
- let style = "simple";
465
- if (name.endsWith("*")) {
466
- explode = true;
467
- name = name.substring(0, name.length - 1);
468
- }
469
- if (name.startsWith(".")) {
470
- name = name.substring(1);
471
- style = "label";
472
- } else if (name.startsWith(";")) {
473
- name = name.substring(1);
474
- style = "matrix";
475
- }
476
- const value = path2[name];
477
- if (value === void 0 || value === null) {
478
- continue;
479
- }
480
- if (Array.isArray(value)) {
481
- url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
482
- continue;
483
- }
484
- if (typeof value === "object") {
485
- url = url.replace(
486
- match,
487
- serializeObjectParam({
488
- explode,
489
- name,
490
- style,
491
- value,
492
- valueOnly: true
493
- })
494
- );
495
- continue;
496
- }
497
- if (style === "matrix") {
498
- url = url.replace(
499
- match,
500
- `;${serializePrimitiveParam({
501
- name,
502
- value
503
- })}`
504
- );
505
- continue;
506
- }
507
- const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
508
- url = url.replace(match, replaceValue);
509
- }
510
- }
511
- return url;
512
- };
513
- var getUrl = ({
514
- baseUrl,
515
- path: path2,
516
- query,
517
- querySerializer,
518
- url: _url
519
- }) => {
520
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
521
- let url = (baseUrl ?? "") + pathUrl;
522
- if (path2) {
523
- url = defaultPathSerializer({ path: path2, url });
524
- }
525
- let search = query ? querySerializer(query) : "";
526
- if (search.startsWith("?")) {
527
- search = search.substring(1);
528
- }
529
- if (search) {
530
- url += `?${search}`;
531
- }
532
- return url;
533
- };
534
- function getValidRequestBody(options) {
535
- const hasBody = options.body !== void 0;
536
- const isSerializedBody = hasBody && options.bodySerializer;
537
- if (isSerializedBody) {
538
- if ("serializedBody" in options) {
539
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
540
- return hasSerializedBody ? options.serializedBody : null;
541
- }
542
- return options.body !== "" ? options.body : null;
543
- }
544
- if (hasBody) {
545
- return options.body;
546
- }
547
- return void 0;
548
- }
549
-
550
- // packages/sdk/src/v2/gen/core/auth.gen.ts
551
- var getAuthToken = async (auth, callback) => {
552
- const token = typeof callback === "function" ? await callback(auth) : callback;
553
- if (!token) {
554
- return;
555
- }
556
- if (auth.scheme === "bearer") {
557
- return `Bearer ${token}`;
558
- }
559
- if (auth.scheme === "basic") {
560
- return `Basic ${btoa(token)}`;
561
- }
562
- return token;
563
- };
564
-
565
- // packages/sdk/src/v2/gen/core/bodySerializer.gen.ts
566
- var jsonBodySerializer = {
567
- bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
568
- };
569
-
570
- // packages/sdk/src/v2/gen/client/utils.gen.ts
571
- var createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
572
- const querySerializer = (queryParams) => {
573
- const search = [];
574
- if (queryParams && typeof queryParams === "object") {
575
- for (const name in queryParams) {
576
- const value = queryParams[name];
577
- if (value === void 0 || value === null) {
578
- continue;
579
- }
580
- const options = parameters[name] || args;
581
- if (Array.isArray(value)) {
582
- const serializedArray = serializeArrayParam({
583
- allowReserved: options.allowReserved,
584
- explode: true,
585
- name,
586
- style: "form",
587
- value,
588
- ...options.array
589
- });
590
- if (serializedArray) search.push(serializedArray);
591
- } else if (typeof value === "object") {
592
- const serializedObject = serializeObjectParam({
593
- allowReserved: options.allowReserved,
594
- explode: true,
595
- name,
596
- style: "deepObject",
597
- value,
598
- ...options.object
599
- });
600
- if (serializedObject) search.push(serializedObject);
601
- } else {
602
- const serializedPrimitive = serializePrimitiveParam({
603
- allowReserved: options.allowReserved,
604
- name,
605
- value
606
- });
607
- if (serializedPrimitive) search.push(serializedPrimitive);
608
- }
609
- }
610
- }
611
- return search.join("&");
612
- };
613
- return querySerializer;
614
- };
615
- var getParseAs = (contentType) => {
616
- if (!contentType) {
617
- return "stream";
618
- }
619
- const cleanContent = contentType.split(";")[0]?.trim();
620
- if (!cleanContent) {
621
- return;
622
- }
623
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
624
- return "json";
625
- }
626
- if (cleanContent === "multipart/form-data") {
627
- return "formData";
628
- }
629
- if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
630
- return "blob";
631
- }
632
- if (cleanContent.startsWith("text/")) {
633
- return "text";
634
- }
635
- return;
636
- };
637
- var checkForExistence = (options, name) => {
638
- if (!name) {
639
- return false;
640
- }
641
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
642
- return true;
643
- }
644
- return false;
645
- };
646
- var setAuthParams = async ({
647
- security,
648
- ...options
649
- }) => {
650
- for (const auth of security) {
651
- if (checkForExistence(options, auth.name)) {
652
- continue;
653
- }
654
- const token = await getAuthToken(auth, options.auth);
655
- if (!token) {
656
- continue;
657
- }
658
- const name = auth.name ?? "Authorization";
659
- switch (auth.in) {
660
- case "query":
661
- if (!options.query) {
662
- options.query = {};
663
- }
664
- options.query[name] = token;
665
- break;
666
- case "cookie":
667
- options.headers.append("Cookie", `${name}=${token}`);
668
- break;
669
- case "header":
670
- default:
671
- options.headers.set(name, token);
672
- break;
673
- }
674
- }
675
- };
676
- var buildUrl = (options) => getUrl({
677
- baseUrl: options.baseUrl,
678
- path: options.path,
679
- query: options.query,
680
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
681
- url: options.url
682
- });
683
- var mergeConfigs = (a, b) => {
684
- const config = { ...a, ...b };
685
- if (config.baseUrl?.endsWith("/")) {
686
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
687
- }
688
- config.headers = mergeHeaders(a.headers, b.headers);
689
- return config;
690
- };
691
- var headersEntries = (headers) => {
692
- const entries = [];
693
- headers.forEach((value, key) => {
694
- entries.push([key, value]);
695
- });
696
- return entries;
697
- };
698
- var mergeHeaders = (...headers) => {
699
- const mergedHeaders = new Headers();
700
- for (const header of headers) {
701
- if (!header) {
702
- continue;
703
- }
704
- const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
705
- for (const [key, value] of iterator) {
706
- if (value === null) {
707
- mergedHeaders.delete(key);
708
- } else if (Array.isArray(value)) {
709
- for (const v of value) {
710
- mergedHeaders.append(key, v);
711
- }
712
- } else if (value !== void 0) {
713
- mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
714
- }
715
- }
716
- }
717
- return mergedHeaders;
718
- };
719
- var Interceptors = class {
720
- fns = [];
721
- clear() {
722
- this.fns = [];
723
- }
724
- eject(id) {
725
- const index = this.getInterceptorIndex(id);
726
- if (this.fns[index]) {
727
- this.fns[index] = null;
728
- }
729
- }
730
- exists(id) {
731
- const index = this.getInterceptorIndex(id);
732
- return Boolean(this.fns[index]);
733
- }
734
- getInterceptorIndex(id) {
735
- if (typeof id === "number") {
736
- return this.fns[id] ? id : -1;
737
- }
738
- return this.fns.indexOf(id);
739
- }
740
- update(id, fn) {
741
- const index = this.getInterceptorIndex(id);
742
- if (this.fns[index]) {
743
- this.fns[index] = fn;
744
- return id;
745
- }
746
- return false;
747
- }
748
- use(fn) {
749
- this.fns.push(fn);
750
- return this.fns.length - 1;
751
- }
752
- };
753
- var createInterceptors = () => ({
754
- error: new Interceptors(),
755
- request: new Interceptors(),
756
- response: new Interceptors()
757
- });
758
- var defaultQuerySerializer = createQuerySerializer({
759
- allowReserved: false,
760
- array: {
761
- explode: true,
762
- style: "form"
763
- },
764
- object: {
765
- explode: true,
766
- style: "deepObject"
767
- }
768
- });
769
- var defaultHeaders = {
770
- "Content-Type": "application/json"
771
- };
772
- var createConfig = (override = {}) => ({
773
- ...jsonBodySerializer,
774
- headers: defaultHeaders,
775
- parseAs: "auto",
776
- querySerializer: defaultQuerySerializer,
777
- ...override
778
- });
779
-
780
- // packages/sdk/src/v2/gen/client/client.gen.ts
781
- var createClient = (config = {}) => {
782
- let _config = mergeConfigs(createConfig(), config);
783
- const getConfig = () => ({ ..._config });
784
- const setConfig = (config2) => {
785
- _config = mergeConfigs(_config, config2);
786
- return getConfig();
787
- };
788
- const interceptors = createInterceptors();
789
- const beforeRequest = async (options) => {
790
- const opts = {
791
- ..._config,
792
- ...options,
793
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
794
- headers: mergeHeaders(_config.headers, options.headers),
795
- serializedBody: void 0
796
- };
797
- if (opts.security) {
798
- await setAuthParams({
799
- ...opts,
800
- security: opts.security
801
- });
802
- }
803
- if (opts.requestValidator) {
804
- await opts.requestValidator(opts);
805
- }
806
- if (opts.body !== void 0 && opts.bodySerializer) {
807
- opts.serializedBody = opts.bodySerializer(opts.body);
808
- }
809
- if (opts.body === void 0 || opts.serializedBody === "") {
810
- opts.headers.delete("Content-Type");
811
- }
812
- const url = buildUrl(opts);
813
- return { opts, url };
814
- };
815
- const request = async (options) => {
816
- const { opts, url } = await beforeRequest(options);
817
- const requestInit = {
818
- redirect: "follow",
819
- ...opts,
820
- body: getValidRequestBody(opts)
821
- };
822
- let request2 = new Request(url, requestInit);
823
- for (const fn of interceptors.request.fns) {
824
- if (fn) {
825
- request2 = await fn(request2, opts);
826
- }
827
- }
828
- const _fetch = opts.fetch;
829
- let response;
830
- try {
831
- response = await _fetch(request2);
832
- } catch (error2) {
833
- let finalError2 = error2;
834
- for (const fn of interceptors.error.fns) {
835
- if (fn) {
836
- finalError2 = await fn(error2, void 0, request2, opts);
837
- }
838
- }
839
- finalError2 = finalError2 || {};
840
- if (opts.throwOnError) {
841
- throw finalError2;
842
- }
843
- return opts.responseStyle === "data" ? void 0 : {
844
- error: finalError2,
845
- request: request2,
846
- response: void 0
847
- };
848
- }
849
- for (const fn of interceptors.response.fns) {
850
- if (fn) {
851
- response = await fn(response, request2, opts);
852
- }
853
- }
854
- const result = {
855
- request: request2,
856
- response
857
- };
858
- if (response.ok) {
859
- const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
860
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
861
- let emptyData;
862
- switch (parseAs) {
863
- case "arrayBuffer":
864
- case "blob":
865
- case "text":
866
- emptyData = await response[parseAs]();
867
- break;
868
- case "formData":
869
- emptyData = new FormData();
870
- break;
871
- case "stream":
872
- emptyData = response.body;
873
- break;
874
- case "json":
875
- default:
876
- emptyData = {};
877
- break;
878
- }
879
- return opts.responseStyle === "data" ? emptyData : {
880
- data: emptyData,
881
- ...result
882
- };
883
- }
884
- let data;
885
- switch (parseAs) {
886
- case "arrayBuffer":
887
- case "blob":
888
- case "formData":
889
- case "text":
890
- data = await response[parseAs]();
891
- break;
892
- case "json": {
893
- const text = await response.text();
894
- data = text ? JSON.parse(text) : {};
895
- break;
896
- }
897
- case "stream":
898
- return opts.responseStyle === "data" ? response.body : {
899
- data: response.body,
900
- ...result
901
- };
902
- }
903
- if (parseAs === "json") {
904
- if (opts.responseValidator) {
905
- await opts.responseValidator(data);
906
- }
907
- if (opts.responseTransformer) {
908
- data = await opts.responseTransformer(data);
909
- }
910
- }
911
- return opts.responseStyle === "data" ? data : {
912
- data,
913
- ...result
914
- };
915
- }
916
- const textError = await response.text();
917
- let jsonError;
918
- try {
919
- jsonError = JSON.parse(textError);
920
- } catch {
921
- }
922
- const error = jsonError ?? textError;
923
- let finalError = error;
924
- for (const fn of interceptors.error.fns) {
925
- if (fn) {
926
- finalError = await fn(error, response, request2, opts);
927
- }
928
- }
929
- finalError = finalError || {};
930
- if (opts.throwOnError) {
931
- throw finalError;
932
- }
933
- return opts.responseStyle === "data" ? void 0 : {
934
- error: finalError,
935
- ...result
936
- };
937
- };
938
- const makeMethodFn = (method) => (options) => request({ ...options, method });
939
- const makeSseFn = (method) => async (options) => {
940
- const { opts, url } = await beforeRequest(options);
941
- return createSseClient({
942
- ...opts,
943
- body: opts.body,
944
- headers: opts.headers,
945
- method,
946
- onRequest: async (url2, init) => {
947
- let request2 = new Request(url2, init);
948
- for (const fn of interceptors.request.fns) {
949
- if (fn) {
950
- request2 = await fn(request2, opts);
951
- }
952
- }
953
- return request2;
954
- },
955
- serializedBody: getValidRequestBody(opts),
956
- url
957
- });
958
- };
959
- return {
960
- buildUrl,
961
- connect: makeMethodFn("CONNECT"),
962
- delete: makeMethodFn("DELETE"),
963
- get: makeMethodFn("GET"),
964
- getConfig,
965
- head: makeMethodFn("HEAD"),
966
- interceptors,
967
- options: makeMethodFn("OPTIONS"),
968
- patch: makeMethodFn("PATCH"),
969
- post: makeMethodFn("POST"),
970
- put: makeMethodFn("PUT"),
971
- request,
972
- setConfig,
973
- sse: {
974
- connect: makeSseFn("CONNECT"),
975
- delete: makeSseFn("DELETE"),
976
- get: makeSseFn("GET"),
977
- head: makeSseFn("HEAD"),
978
- options: makeSseFn("OPTIONS"),
979
- patch: makeSseFn("PATCH"),
980
- post: makeSseFn("POST"),
981
- put: makeSseFn("PUT"),
982
- trace: makeSseFn("TRACE")
983
- },
984
- trace: makeMethodFn("TRACE")
985
- };
986
- };
987
-
988
- // packages/sdk/src/v2/gen/core/params.gen.ts
989
- var extraPrefixesMap = {
990
- $body_: "body",
991
- $headers_: "headers",
992
- $path_: "path",
993
- $query_: "query"
994
- };
995
- var extraPrefixes = Object.entries(extraPrefixesMap);
996
- var buildKeyMap = (fields, map) => {
997
- if (!map) {
998
- map = /* @__PURE__ */ new Map();
999
- }
1000
- for (const config of fields) {
1001
- if ("in" in config) {
1002
- if (config.key) {
1003
- map.set(config.key, {
1004
- in: config.in,
1005
- map: config.map
1006
- });
1007
- }
1008
- } else if ("key" in config) {
1009
- map.set(config.key, {
1010
- map: config.map
1011
- });
1012
- } else if (config.args) {
1013
- buildKeyMap(config.args, map);
1014
- }
1015
- }
1016
- return map;
1017
- };
1018
- var stripEmptySlots = (params) => {
1019
- for (const [slot, value] of Object.entries(params)) {
1020
- if (value && typeof value === "object" && !Object.keys(value).length) {
1021
- delete params[slot];
1022
- }
1023
- }
1024
- };
1025
- var buildClientParams = (args, fields) => {
1026
- const params = {
1027
- body: {},
1028
- headers: {},
1029
- path: {},
1030
- query: {}
1031
- };
1032
- const map = buildKeyMap(fields);
1033
- let config;
1034
- for (const [index, arg] of args.entries()) {
1035
- if (fields[index]) {
1036
- config = fields[index];
1037
- }
1038
- if (!config) {
1039
- continue;
1040
- }
1041
- if ("in" in config) {
1042
- if (config.key) {
1043
- const field = map.get(config.key);
1044
- const name = field.map || config.key;
1045
- if (field.in) {
1046
- ;
1047
- params[field.in][name] = arg;
1048
- }
1049
- } else {
1050
- params.body = arg;
1051
- }
1052
- } else {
1053
- for (const [key, value] of Object.entries(arg ?? {})) {
1054
- const field = map.get(key);
1055
- if (field) {
1056
- if (field.in) {
1057
- const name = field.map || key;
1058
- params[field.in][name] = value;
1059
- } else {
1060
- params[field.map] = value;
1061
- }
1062
- } else {
1063
- const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
1064
- if (extra) {
1065
- const [prefix, slot] = extra;
1066
- params[slot][key.slice(prefix.length)] = value;
1067
- } else if ("allowExtra" in config && config.allowExtra) {
1068
- for (const [slot, allowed] of Object.entries(config.allowExtra)) {
1069
- if (allowed) {
1070
- ;
1071
- params[slot][key] = value;
1072
- break;
1073
- }
1074
- }
1075
- }
1076
- }
1077
- }
1078
- }
1079
- }
1080
- stripEmptySlots(params);
1081
- return params;
1082
- };
1083
-
1084
- // packages/sdk/src/v2/gen/client.gen.ts
1085
- var client = createClient(createConfig({ baseUrl: "http://localhost:4096" }));
1086
-
1087
- // packages/sdk/src/v2/gen/sdk.gen.ts
1088
- var HeyApiClient = class {
1089
- client;
1090
- constructor(args) {
1091
- this.client = args?.client ?? client;
1092
- }
1093
- };
1094
- var HeyApiRegistry = class {
1095
- defaultKey = "default";
1096
- instances = /* @__PURE__ */ new Map();
1097
- get(key) {
1098
- const instance = this.instances.get(key ?? this.defaultKey);
1099
- if (!instance) {
1100
- throw new Error(`No SDK client found. Create one with "new OpencodeClient()" to fix this error.`);
1101
- }
1102
- return instance;
1103
- }
1104
- set(value, key) {
1105
- this.instances.set(key ?? this.defaultKey, value);
1106
- }
1107
- };
1108
- var SyncEvent = class extends HeyApiClient {
1109
- /**
1110
- * Subscribe to global sync events
1111
- *
1112
- * Get global sync events
1113
- */
1114
- subscribe(options) {
1115
- return (options?.client ?? this.client).sse.get({
1116
- url: "/global/sync-event",
1117
- ...options
1118
- });
1119
- }
1120
- };
1121
- var Config = class extends HeyApiClient {
1122
- /**
1123
- * Get global configuration
1124
- *
1125
- * Retrieve the current global OpenCode configuration settings and preferences.
1126
- */
1127
- get(options) {
1128
- return (options?.client ?? this.client).get({
1129
- url: "/global/config",
1130
- ...options
1131
- });
1132
- }
1133
- /**
1134
- * Update global configuration
1135
- *
1136
- * Update global OpenCode configuration settings and preferences.
1137
- */
1138
- update(parameters, options) {
1139
- const params = buildClientParams([parameters], [{ args: [{ key: "config", map: "body" }] }]);
1140
- return (options?.client ?? this.client).patch({
1141
- url: "/global/config",
1142
- ...options,
1143
- ...params,
1144
- headers: {
1145
- "Content-Type": "application/json",
1146
- ...options?.headers,
1147
- ...params.headers
1148
- }
1149
- });
1150
- }
1151
- };
1152
- var Global = class extends HeyApiClient {
1153
- /**
1154
- * Get health
1155
- *
1156
- * Get health information about the OpenCode server.
1157
- */
1158
- health(options) {
1159
- return (options?.client ?? this.client).get({
1160
- url: "/global/health",
1161
- ...options
1162
- });
1163
- }
1164
- /**
1165
- * Get global events
1166
- *
1167
- * Subscribe to global events from the OpenCode system using server-sent events.
1168
- */
1169
- event(options) {
1170
- return (options?.client ?? this.client).sse.get({
1171
- url: "/global/event",
1172
- ...options
1173
- });
1174
- }
1175
- /**
1176
- * Dispose instance
1177
- *
1178
- * Clean up and dispose all OpenCode instances, releasing all resources.
1179
- */
1180
- dispose(options) {
1181
- return (options?.client ?? this.client).post({
1182
- url: "/global/dispose",
1183
- ...options
1184
- });
1185
- }
1186
- /**
1187
- * Upgrade opencode
1188
- *
1189
- * Upgrade opencode to the specified version or latest if not specified.
1190
- */
1191
- upgrade(parameters, options) {
1192
- const params = buildClientParams([parameters], [{ args: [{ in: "body", key: "target" }] }]);
1193
- return (options?.client ?? this.client).post({
1194
- url: "/global/upgrade",
1195
- ...options,
1196
- ...params,
1197
- headers: {
1198
- "Content-Type": "application/json",
1199
- ...options?.headers,
1200
- ...params.headers
1201
- }
1202
- });
1203
- }
1204
- _syncEvent;
1205
- get syncEvent() {
1206
- return this._syncEvent ??= new SyncEvent({ client: this.client });
1207
- }
1208
- _config;
1209
- get config() {
1210
- return this._config ??= new Config({ client: this.client });
1211
- }
1212
- };
1213
- var Auth = class extends HeyApiClient {
1214
- /**
1215
- * Remove auth credentials
1216
- *
1217
- * Remove authentication credentials
1218
- */
1219
- remove(parameters, options) {
1220
- const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "providerID" }] }]);
1221
- return (options?.client ?? this.client).delete({
1222
- url: "/auth/{providerID}",
1223
- ...options,
1224
- ...params
1225
- });
1226
- }
1227
- /**
1228
- * Set auth credentials
1229
- *
1230
- * Set authentication credentials
1231
- */
1232
- set(parameters, options) {
1233
- const params = buildClientParams(
1234
- [parameters],
1235
- [
1236
- {
1237
- args: [
1238
- { in: "path", key: "providerID" },
1239
- { key: "auth", map: "body" }
1240
- ]
1241
- }
1242
- ]
1243
- );
1244
- return (options?.client ?? this.client).put({
1245
- url: "/auth/{providerID}",
1246
- ...options,
1247
- ...params,
1248
- headers: {
1249
- "Content-Type": "application/json",
1250
- ...options?.headers,
1251
- ...params.headers
1252
- }
1253
- });
1254
- }
1255
- };
1256
- var App = class extends HeyApiClient {
1257
- /**
1258
- * Write log
1259
- *
1260
- * Write a log entry to the server logs with specified level and metadata.
1261
- */
1262
- log(parameters, options) {
1263
- const params = buildClientParams(
1264
- [parameters],
1265
- [
1266
- {
1267
- args: [
1268
- { in: "query", key: "directory" },
1269
- { in: "query", key: "workspace" },
1270
- { in: "body", key: "service" },
1271
- { in: "body", key: "level" },
1272
- { in: "body", key: "message" },
1273
- { in: "body", key: "extra" }
1274
- ]
1275
- }
1276
- ]
1277
- );
1278
- return (options?.client ?? this.client).post({
1279
- url: "/log",
1280
- ...options,
1281
- ...params,
1282
- headers: {
1283
- "Content-Type": "application/json",
1284
- ...options?.headers,
1285
- ...params.headers
1286
- }
1287
- });
1288
- }
1289
- /**
1290
- * List agents
1291
- *
1292
- * Get a list of all available AI agents in the OpenCode system.
1293
- */
1294
- agents(parameters, options) {
1295
- const params = buildClientParams(
1296
- [parameters],
1297
- [
1298
- {
1299
- args: [
1300
- { in: "query", key: "directory" },
1301
- { in: "query", key: "workspace" }
1302
- ]
1303
- }
1304
- ]
1305
- );
1306
- return (options?.client ?? this.client).get({
1307
- url: "/agent",
1308
- ...options,
1309
- ...params
1310
- });
1311
- }
1312
- /**
1313
- * List skills
1314
- *
1315
- * Get a list of all available skills in the OpenCode system.
1316
- */
1317
- skills(parameters, options) {
1318
- const params = buildClientParams(
1319
- [parameters],
1320
- [
1321
- {
1322
- args: [
1323
- { in: "query", key: "directory" },
1324
- { in: "query", key: "workspace" }
1325
- ]
1326
- }
1327
- ]
1328
- );
1329
- return (options?.client ?? this.client).get({
1330
- url: "/skill",
1331
- ...options,
1332
- ...params
1333
- });
1334
- }
1335
- };
1336
- var Project = class extends HeyApiClient {
1337
- /**
1338
- * List all projects
1339
- *
1340
- * Get a list of projects that have been opened with OpenCode.
1341
- */
1342
- list(parameters, options) {
1343
- const params = buildClientParams(
1344
- [parameters],
1345
- [
1346
- {
1347
- args: [
1348
- { in: "query", key: "directory" },
1349
- { in: "query", key: "workspace" }
1350
- ]
1351
- }
1352
- ]
1353
- );
1354
- return (options?.client ?? this.client).get({
1355
- url: "/project",
1356
- ...options,
1357
- ...params
1358
- });
1359
- }
1360
- /**
1361
- * Get current project
1362
- *
1363
- * Retrieve the currently active project that OpenCode is working with.
1364
- */
1365
- current(parameters, options) {
1366
- const params = buildClientParams(
1367
- [parameters],
1368
- [
1369
- {
1370
- args: [
1371
- { in: "query", key: "directory" },
1372
- { in: "query", key: "workspace" }
1373
- ]
1374
- }
1375
- ]
1376
- );
1377
- return (options?.client ?? this.client).get({
1378
- url: "/project/current",
1379
- ...options,
1380
- ...params
1381
- });
1382
- }
1383
- /**
1384
- * Initialize git repository
1385
- *
1386
- * Create a git repository for the current project and return the refreshed project info.
1387
- */
1388
- initGit(parameters, options) {
1389
- const params = buildClientParams(
1390
- [parameters],
1391
- [
1392
- {
1393
- args: [
1394
- { in: "query", key: "directory" },
1395
- { in: "query", key: "workspace" }
1396
- ]
1397
- }
1398
- ]
1399
- );
1400
- return (options?.client ?? this.client).post({
1401
- url: "/project/git/init",
1402
- ...options,
1403
- ...params
1404
- });
1405
- }
1406
- /**
1407
- * Update project
1408
- *
1409
- * Update project properties such as name, icon, and commands.
1410
- */
1411
- update(parameters, options) {
1412
- const params = buildClientParams(
1413
- [parameters],
1414
- [
1415
- {
1416
- args: [
1417
- { in: "path", key: "projectID" },
1418
- { in: "query", key: "directory" },
1419
- { in: "query", key: "workspace" },
1420
- { in: "body", key: "name" },
1421
- { in: "body", key: "icon" },
1422
- { in: "body", key: "commands" }
1423
- ]
1424
- }
1425
- ]
1426
- );
1427
- return (options?.client ?? this.client).patch({
1428
- url: "/project/{projectID}",
1429
- ...options,
1430
- ...params,
1431
- headers: {
1432
- "Content-Type": "application/json",
1433
- ...options?.headers,
1434
- ...params.headers
1435
- }
1436
- });
1437
- }
1438
- };
1439
- var Pty = class extends HeyApiClient {
1440
- /**
1441
- * List PTY sessions
1442
- *
1443
- * Get a list of all active pseudo-terminal (PTY) sessions managed by OpenCode.
1444
- */
1445
- list(parameters, options) {
1446
- const params = buildClientParams(
1447
- [parameters],
1448
- [
1449
- {
1450
- args: [
1451
- { in: "query", key: "directory" },
1452
- { in: "query", key: "workspace" }
1453
- ]
1454
- }
1455
- ]
1456
- );
1457
- return (options?.client ?? this.client).get({
1458
- url: "/pty",
1459
- ...options,
1460
- ...params
1461
- });
1462
- }
1463
- /**
1464
- * Create PTY session
1465
- *
1466
- * Create a new pseudo-terminal (PTY) session for running shell commands and processes.
1467
- */
1468
- create(parameters, options) {
1469
- const params = buildClientParams(
1470
- [parameters],
1471
- [
1472
- {
1473
- args: [
1474
- { in: "query", key: "directory" },
1475
- { in: "query", key: "workspace" },
1476
- { in: "body", key: "command" },
1477
- { in: "body", key: "args" },
1478
- { in: "body", key: "cwd" },
1479
- { in: "body", key: "title" },
1480
- { in: "body", key: "env" }
1481
- ]
1482
- }
1483
- ]
1484
- );
1485
- return (options?.client ?? this.client).post({
1486
- url: "/pty",
1487
- ...options,
1488
- ...params,
1489
- headers: {
1490
- "Content-Type": "application/json",
1491
- ...options?.headers,
1492
- ...params.headers
1493
- }
1494
- });
1495
- }
1496
- /**
1497
- * Remove PTY session
1498
- *
1499
- * Remove and terminate a specific pseudo-terminal (PTY) session.
1500
- */
1501
- remove(parameters, options) {
1502
- const params = buildClientParams(
1503
- [parameters],
1504
- [
1505
- {
1506
- args: [
1507
- { in: "path", key: "ptyID" },
1508
- { in: "query", key: "directory" },
1509
- { in: "query", key: "workspace" }
1510
- ]
1511
- }
1512
- ]
1513
- );
1514
- return (options?.client ?? this.client).delete({
1515
- url: "/pty/{ptyID}",
1516
- ...options,
1517
- ...params
1518
- });
1519
- }
1520
- /**
1521
- * Get PTY session
1522
- *
1523
- * Retrieve detailed information about a specific pseudo-terminal (PTY) session.
1524
- */
1525
- get(parameters, options) {
1526
- const params = buildClientParams(
1527
- [parameters],
1528
- [
1529
- {
1530
- args: [
1531
- { in: "path", key: "ptyID" },
1532
- { in: "query", key: "directory" },
1533
- { in: "query", key: "workspace" }
1534
- ]
1535
- }
1536
- ]
1537
- );
1538
- return (options?.client ?? this.client).get({
1539
- url: "/pty/{ptyID}",
1540
- ...options,
1541
- ...params
1542
- });
1543
- }
1544
- /**
1545
- * Update PTY session
1546
- *
1547
- * Update properties of an existing pseudo-terminal (PTY) session.
1548
- */
1549
- update(parameters, options) {
1550
- const params = buildClientParams(
1551
- [parameters],
1552
- [
1553
- {
1554
- args: [
1555
- { in: "path", key: "ptyID" },
1556
- { in: "query", key: "directory" },
1557
- { in: "query", key: "workspace" },
1558
- { in: "body", key: "title" },
1559
- { in: "body", key: "size" }
1560
- ]
1561
- }
1562
- ]
1563
- );
1564
- return (options?.client ?? this.client).put({
1565
- url: "/pty/{ptyID}",
1566
- ...options,
1567
- ...params,
1568
- headers: {
1569
- "Content-Type": "application/json",
1570
- ...options?.headers,
1571
- ...params.headers
1572
- }
1573
- });
1574
- }
1575
- /**
1576
- * Connect to PTY session
1577
- *
1578
- * Establish a WebSocket connection to interact with a pseudo-terminal (PTY) session in real-time.
1579
- */
1580
- connect(parameters, options) {
1581
- const params = buildClientParams(
1582
- [parameters],
1583
- [
1584
- {
1585
- args: [
1586
- { in: "path", key: "ptyID" },
1587
- { in: "query", key: "directory" },
1588
- { in: "query", key: "workspace" }
1589
- ]
1590
- }
1591
- ]
1592
- );
1593
- return (options?.client ?? this.client).get({
1594
- url: "/pty/{ptyID}/connect",
1595
- ...options,
1596
- ...params
1597
- });
1598
- }
1599
- };
1600
- var Config2 = class extends HeyApiClient {
1601
- /**
1602
- * Get configuration
1603
- *
1604
- * Retrieve the current OpenCode configuration settings and preferences.
1605
- */
1606
- get(parameters, options) {
1607
- const params = buildClientParams(
1608
- [parameters],
1609
- [
1610
- {
1611
- args: [
1612
- { in: "query", key: "directory" },
1613
- { in: "query", key: "workspace" }
1614
- ]
1615
- }
1616
- ]
1617
- );
1618
- return (options?.client ?? this.client).get({
1619
- url: "/config",
1620
- ...options,
1621
- ...params
1622
- });
1623
- }
1624
- /**
1625
- * Update configuration
1626
- *
1627
- * Update OpenCode configuration settings and preferences.
1628
- */
1629
- update(parameters, options) {
1630
- const params = buildClientParams(
1631
- [parameters],
1632
- [
1633
- {
1634
- args: [
1635
- { in: "query", key: "directory" },
1636
- { in: "query", key: "workspace" },
1637
- { key: "config", map: "body" }
1638
- ]
1639
- }
1640
- ]
1641
- );
1642
- return (options?.client ?? this.client).patch({
1643
- url: "/config",
1644
- ...options,
1645
- ...params,
1646
- headers: {
1647
- "Content-Type": "application/json",
1648
- ...options?.headers,
1649
- ...params.headers
1650
- }
1651
- });
1652
- }
1653
- /**
1654
- * List config providers
1655
- *
1656
- * Get a list of all configured AI providers and their default models.
1657
- */
1658
- providers(parameters, options) {
1659
- const params = buildClientParams(
1660
- [parameters],
1661
- [
1662
- {
1663
- args: [
1664
- { in: "query", key: "directory" },
1665
- { in: "query", key: "workspace" }
1666
- ]
1667
- }
1668
- ]
1669
- );
1670
- return (options?.client ?? this.client).get({
1671
- url: "/config/providers",
1672
- ...options,
1673
- ...params
1674
- });
1675
- }
1676
- };
1677
- var Console = class extends HeyApiClient {
1678
- /**
1679
- * Get active Console provider metadata
1680
- *
1681
- * Get the active Console org name and the set of provider IDs managed by that Console org.
1682
- */
1683
- get(parameters, options) {
1684
- const params = buildClientParams(
1685
- [parameters],
1686
- [
1687
- {
1688
- args: [
1689
- { in: "query", key: "directory" },
1690
- { in: "query", key: "workspace" }
1691
- ]
1692
- }
1693
- ]
1694
- );
1695
- return (options?.client ?? this.client).get({
1696
- url: "/experimental/console",
1697
- ...options,
1698
- ...params
1699
- });
1700
- }
1701
- /**
1702
- * List switchable Console orgs
1703
- *
1704
- * Get the available Console orgs across logged-in accounts, including the current active org.
1705
- */
1706
- listOrgs(parameters, options) {
1707
- const params = buildClientParams(
1708
- [parameters],
1709
- [
1710
- {
1711
- args: [
1712
- { in: "query", key: "directory" },
1713
- { in: "query", key: "workspace" }
1714
- ]
1715
- }
1716
- ]
1717
- );
1718
- return (options?.client ?? this.client).get({
1719
- url: "/experimental/console/orgs",
1720
- ...options,
1721
- ...params
1722
- });
1723
- }
1724
- /**
1725
- * Switch active Console org
1726
- *
1727
- * Persist a new active Console account/org selection for the current local OpenCode state.
1728
- */
1729
- switchOrg(parameters, options) {
1730
- const params = buildClientParams(
1731
- [parameters],
1732
- [
1733
- {
1734
- args: [
1735
- { in: "query", key: "directory" },
1736
- { in: "query", key: "workspace" },
1737
- { in: "body", key: "accountID" },
1738
- { in: "body", key: "orgID" }
1739
- ]
1740
- }
1741
- ]
1742
- );
1743
- return (options?.client ?? this.client).post({
1744
- url: "/experimental/console/switch",
1745
- ...options,
1746
- ...params,
1747
- headers: {
1748
- "Content-Type": "application/json",
1749
- ...options?.headers,
1750
- ...params.headers
1751
- }
1752
- });
1753
- }
1754
- };
1755
- var Workspace = class extends HeyApiClient {
1756
- /**
1757
- * List workspaces
1758
- *
1759
- * List all workspaces.
1760
- */
1761
- list(parameters, options) {
1762
- const params = buildClientParams(
1763
- [parameters],
1764
- [
1765
- {
1766
- args: [
1767
- { in: "query", key: "directory" },
1768
- { in: "query", key: "workspace" }
1769
- ]
1770
- }
1771
- ]
1772
- );
1773
- return (options?.client ?? this.client).get({
1774
- url: "/experimental/workspace",
1775
- ...options,
1776
- ...params
1777
- });
1778
- }
1779
- /**
1780
- * Create workspace
1781
- *
1782
- * Create a workspace for the current project.
1783
- */
1784
- create(parameters, options) {
1785
- const params = buildClientParams(
1786
- [parameters],
1787
- [
1788
- {
1789
- args: [
1790
- { in: "query", key: "directory" },
1791
- { in: "query", key: "workspace" },
1792
- { in: "body", key: "id" },
1793
- { in: "body", key: "type" },
1794
- { in: "body", key: "branch" },
1795
- { in: "body", key: "extra" }
1796
- ]
1797
- }
1798
- ]
1799
- );
1800
- return (options?.client ?? this.client).post({
1801
- url: "/experimental/workspace",
1802
- ...options,
1803
- ...params,
1804
- headers: {
1805
- "Content-Type": "application/json",
1806
- ...options?.headers,
1807
- ...params.headers
1808
- }
1809
- });
1810
- }
1811
- /**
1812
- * Remove workspace
1813
- *
1814
- * Remove an existing workspace.
1815
- */
1816
- remove(parameters, options) {
1817
- const params = buildClientParams(
1818
- [parameters],
1819
- [
1820
- {
1821
- args: [
1822
- { in: "path", key: "id" },
1823
- { in: "query", key: "directory" },
1824
- { in: "query", key: "workspace" }
1825
- ]
1826
- }
1827
- ]
1828
- );
1829
- return (options?.client ?? this.client).delete({
1830
- url: "/experimental/workspace/{id}",
1831
- ...options,
1832
- ...params
1833
- });
1834
- }
1835
- };
1836
- var Session = class extends HeyApiClient {
1837
- /**
1838
- * List sessions
1839
- *
1840
- * Get a list of all OpenCode sessions across projects, sorted by most recently updated. Archived sessions are excluded by default.
1841
- */
1842
- list(parameters, options) {
1843
- const params = buildClientParams(
1844
- [parameters],
1845
- [
1846
- {
1847
- args: [
1848
- { in: "query", key: "directory" },
1849
- { in: "query", key: "workspace" },
1850
- { in: "query", key: "roots" },
1851
- { in: "query", key: "start" },
1852
- { in: "query", key: "cursor" },
1853
- { in: "query", key: "search" },
1854
- { in: "query", key: "limit" },
1855
- { in: "query", key: "archived" }
1856
- ]
1857
- }
1858
- ]
1859
- );
1860
- return (options?.client ?? this.client).get({
1861
- url: "/experimental/session",
1862
- ...options,
1863
- ...params
1864
- });
1865
- }
1866
- };
1867
- var Resource = class extends HeyApiClient {
1868
- /**
1869
- * Get MCP resources
1870
- *
1871
- * Get all available MCP resources from connected servers. Optionally filter by name.
1872
- */
1873
- list(parameters, options) {
1874
- const params = buildClientParams(
1875
- [parameters],
1876
- [
1877
- {
1878
- args: [
1879
- { in: "query", key: "directory" },
1880
- { in: "query", key: "workspace" }
1881
- ]
1882
- }
1883
- ]
1884
- );
1885
- return (options?.client ?? this.client).get({
1886
- url: "/experimental/resource",
1887
- ...options,
1888
- ...params
1889
- });
1890
- }
1891
- };
1892
- var Experimental = class extends HeyApiClient {
1893
- _console;
1894
- get console() {
1895
- return this._console ??= new Console({ client: this.client });
1896
- }
1897
- _workspace;
1898
- get workspace() {
1899
- return this._workspace ??= new Workspace({ client: this.client });
1900
- }
1901
- _session;
1902
- get session() {
1903
- return this._session ??= new Session({ client: this.client });
1904
- }
1905
- _resource;
1906
- get resource() {
1907
- return this._resource ??= new Resource({ client: this.client });
1908
- }
1909
- };
1910
- var Tool = class extends HeyApiClient {
1911
- /**
1912
- * List tool IDs
1913
- *
1914
- * Get a list of all available tool IDs, including both built-in tools and dynamically registered tools.
1915
- */
1916
- ids(parameters, options) {
1917
- const params = buildClientParams(
1918
- [parameters],
1919
- [
1920
- {
1921
- args: [
1922
- { in: "query", key: "directory" },
1923
- { in: "query", key: "workspace" }
1924
- ]
1925
- }
1926
- ]
1927
- );
1928
- return (options?.client ?? this.client).get({
1929
- url: "/experimental/tool/ids",
1930
- ...options,
1931
- ...params
1932
- });
1933
- }
1934
- /**
1935
- * List tools
1936
- *
1937
- * Get a list of available tools with their JSON schema parameters for a specific provider and model combination.
1938
- */
1939
- list(parameters, options) {
1940
- const params = buildClientParams(
1941
- [parameters],
1942
- [
1943
- {
1944
- args: [
1945
- { in: "query", key: "directory" },
1946
- { in: "query", key: "workspace" },
1947
- { in: "query", key: "provider" },
1948
- { in: "query", key: "model" }
1949
- ]
1950
- }
1951
- ]
1952
- );
1953
- return (options?.client ?? this.client).get({
1954
- url: "/experimental/tool",
1955
- ...options,
1956
- ...params
1957
- });
1958
- }
1959
- };
1960
- var Worktree = class extends HeyApiClient {
1961
- /**
1962
- * Remove worktree
1963
- *
1964
- * Remove a git worktree and delete its branch.
1965
- */
1966
- remove(parameters, options) {
1967
- const params = buildClientParams(
1968
- [parameters],
1969
- [
1970
- {
1971
- args: [
1972
- { in: "query", key: "directory" },
1973
- { in: "query", key: "workspace" },
1974
- { key: "worktreeRemoveInput", map: "body" }
1975
- ]
1976
- }
1977
- ]
1978
- );
1979
- return (options?.client ?? this.client).delete({
1980
- url: "/experimental/worktree",
1981
- ...options,
1982
- ...params,
1983
- headers: {
1984
- "Content-Type": "application/json",
1985
- ...options?.headers,
1986
- ...params.headers
1987
- }
1988
- });
1989
- }
1990
- /**
1991
- * List worktrees
1992
- *
1993
- * List all sandbox worktrees for the current project.
1994
- */
1995
- list(parameters, options) {
1996
- const params = buildClientParams(
1997
- [parameters],
1998
- [
1999
- {
2000
- args: [
2001
- { in: "query", key: "directory" },
2002
- { in: "query", key: "workspace" }
2003
- ]
2004
- }
2005
- ]
2006
- );
2007
- return (options?.client ?? this.client).get({
2008
- url: "/experimental/worktree",
2009
- ...options,
2010
- ...params
2011
- });
2012
- }
2013
- /**
2014
- * Create worktree
2015
- *
2016
- * Create a new git worktree for the current project and run any configured startup scripts.
2017
- */
2018
- create(parameters, options) {
2019
- const params = buildClientParams(
2020
- [parameters],
2021
- [
2022
- {
2023
- args: [
2024
- { in: "query", key: "directory" },
2025
- { in: "query", key: "workspace" },
2026
- { key: "worktreeCreateInput", map: "body" }
2027
- ]
2028
- }
2029
- ]
2030
- );
2031
- return (options?.client ?? this.client).post({
2032
- url: "/experimental/worktree",
2033
- ...options,
2034
- ...params,
2035
- headers: {
2036
- "Content-Type": "application/json",
2037
- ...options?.headers,
2038
- ...params.headers
2039
- }
2040
- });
2041
- }
2042
- /**
2043
- * Reset worktree
2044
- *
2045
- * Reset a worktree branch to the primary default branch.
2046
- */
2047
- reset(parameters, options) {
2048
- const params = buildClientParams(
2049
- [parameters],
2050
- [
2051
- {
2052
- args: [
2053
- { in: "query", key: "directory" },
2054
- { in: "query", key: "workspace" },
2055
- { key: "worktreeResetInput", map: "body" }
2056
- ]
2057
- }
2058
- ]
2059
- );
2060
- return (options?.client ?? this.client).post({
2061
- url: "/experimental/worktree/reset",
2062
- ...options,
2063
- ...params,
2064
- headers: {
2065
- "Content-Type": "application/json",
2066
- ...options?.headers,
2067
- ...params.headers
2068
- }
2069
- });
2070
- }
2071
- };
2072
- var Session2 = class extends HeyApiClient {
2073
- /**
2074
- * List sessions
2075
- *
2076
- * Get a list of all OpenCode sessions, sorted by most recently updated.
2077
- */
2078
- list(parameters, options) {
2079
- const params = buildClientParams(
2080
- [parameters],
2081
- [
2082
- {
2083
- args: [
2084
- { in: "query", key: "directory" },
2085
- { in: "query", key: "workspace" },
2086
- { in: "query", key: "roots" },
2087
- { in: "query", key: "start" },
2088
- { in: "query", key: "search" },
2089
- { in: "query", key: "limit" }
2090
- ]
2091
- }
2092
- ]
2093
- );
2094
- return (options?.client ?? this.client).get({
2095
- url: "/session",
2096
- ...options,
2097
- ...params
2098
- });
2099
- }
2100
- /**
2101
- * Create session
2102
- *
2103
- * Create a new OpenCode session for interacting with AI assistants and managing conversations.
2104
- */
2105
- create(parameters, options) {
2106
- const params = buildClientParams(
2107
- [parameters],
2108
- [
2109
- {
2110
- args: [
2111
- { in: "query", key: "directory" },
2112
- { in: "query", key: "workspace" },
2113
- { in: "body", key: "parentID" },
2114
- { in: "body", key: "title" },
2115
- { in: "body", key: "permission" },
2116
- { in: "body", key: "workspaceID" }
2117
- ]
2118
- }
2119
- ]
2120
- );
2121
- return (options?.client ?? this.client).post({
2122
- url: "/session",
2123
- ...options,
2124
- ...params,
2125
- headers: {
2126
- "Content-Type": "application/json",
2127
- ...options?.headers,
2128
- ...params.headers
2129
- }
2130
- });
2131
- }
2132
- /**
2133
- * Get session status
2134
- *
2135
- * Retrieve the current status of all sessions, including active, idle, and completed states.
2136
- */
2137
- status(parameters, options) {
2138
- const params = buildClientParams(
2139
- [parameters],
2140
- [
2141
- {
2142
- args: [
2143
- { in: "query", key: "directory" },
2144
- { in: "query", key: "workspace" }
2145
- ]
2146
- }
2147
- ]
2148
- );
2149
- return (options?.client ?? this.client).get({
2150
- url: "/session/status",
2151
- ...options,
2152
- ...params
2153
- });
2154
- }
2155
- /**
2156
- * Delete session
2157
- *
2158
- * Delete a session and permanently remove all associated data, including messages and history.
2159
- */
2160
- delete(parameters, options) {
2161
- const params = buildClientParams(
2162
- [parameters],
2163
- [
2164
- {
2165
- args: [
2166
- { in: "path", key: "sessionID" },
2167
- { in: "query", key: "directory" },
2168
- { in: "query", key: "workspace" }
2169
- ]
2170
- }
2171
- ]
2172
- );
2173
- return (options?.client ?? this.client).delete({
2174
- url: "/session/{sessionID}",
2175
- ...options,
2176
- ...params
2177
- });
2178
- }
2179
- /**
2180
- * Get session
2181
- *
2182
- * Retrieve detailed information about a specific OpenCode session.
2183
- */
2184
- get(parameters, options) {
2185
- const params = buildClientParams(
2186
- [parameters],
2187
- [
2188
- {
2189
- args: [
2190
- { in: "path", key: "sessionID" },
2191
- { in: "query", key: "directory" },
2192
- { in: "query", key: "workspace" }
2193
- ]
2194
- }
2195
- ]
2196
- );
2197
- return (options?.client ?? this.client).get({
2198
- url: "/session/{sessionID}",
2199
- ...options,
2200
- ...params
2201
- });
2202
- }
2203
- /**
2204
- * Update session
2205
- *
2206
- * Update properties of an existing session, such as title or other metadata.
2207
- */
2208
- update(parameters, options) {
2209
- const params = buildClientParams(
2210
- [parameters],
2211
- [
2212
- {
2213
- args: [
2214
- { in: "path", key: "sessionID" },
2215
- { in: "query", key: "directory" },
2216
- { in: "query", key: "workspace" },
2217
- { in: "body", key: "title" },
2218
- { in: "body", key: "time" }
2219
- ]
2220
- }
2221
- ]
2222
- );
2223
- return (options?.client ?? this.client).patch({
2224
- url: "/session/{sessionID}",
2225
- ...options,
2226
- ...params,
2227
- headers: {
2228
- "Content-Type": "application/json",
2229
- ...options?.headers,
2230
- ...params.headers
2231
- }
2232
- });
2233
- }
2234
- /**
2235
- * Get session children
2236
- *
2237
- * Retrieve all child sessions that were forked from the specified parent session.
2238
- */
2239
- children(parameters, options) {
2240
- const params = buildClientParams(
2241
- [parameters],
2242
- [
2243
- {
2244
- args: [
2245
- { in: "path", key: "sessionID" },
2246
- { in: "query", key: "directory" },
2247
- { in: "query", key: "workspace" }
2248
- ]
2249
- }
2250
- ]
2251
- );
2252
- return (options?.client ?? this.client).get({
2253
- url: "/session/{sessionID}/children",
2254
- ...options,
2255
- ...params
2256
- });
2257
- }
2258
- /**
2259
- * Get session todos
2260
- *
2261
- * Retrieve the todo list associated with a specific session, showing tasks and action items.
2262
- */
2263
- todo(parameters, options) {
2264
- const params = buildClientParams(
2265
- [parameters],
2266
- [
2267
- {
2268
- args: [
2269
- { in: "path", key: "sessionID" },
2270
- { in: "query", key: "directory" },
2271
- { in: "query", key: "workspace" }
2272
- ]
2273
- }
2274
- ]
2275
- );
2276
- return (options?.client ?? this.client).get({
2277
- url: "/session/{sessionID}/todo",
2278
- ...options,
2279
- ...params
2280
- });
2281
- }
2282
- /**
2283
- * Initialize session
2284
- *
2285
- * Analyze the current application and create an AGENTS.md file with project-specific agent configurations.
2286
- */
2287
- init(parameters, options) {
2288
- const params = buildClientParams(
2289
- [parameters],
2290
- [
2291
- {
2292
- args: [
2293
- { in: "path", key: "sessionID" },
2294
- { in: "query", key: "directory" },
2295
- { in: "query", key: "workspace" },
2296
- { in: "body", key: "modelID" },
2297
- { in: "body", key: "providerID" },
2298
- { in: "body", key: "messageID" }
2299
- ]
2300
- }
2301
- ]
2302
- );
2303
- return (options?.client ?? this.client).post({
2304
- url: "/session/{sessionID}/init",
2305
- ...options,
2306
- ...params,
2307
- headers: {
2308
- "Content-Type": "application/json",
2309
- ...options?.headers,
2310
- ...params.headers
2311
- }
2312
- });
2313
- }
2314
- /**
2315
- * Fork session
2316
- *
2317
- * Create a new session by forking an existing session at a specific message point.
2318
- */
2319
- fork(parameters, options) {
2320
- const params = buildClientParams(
2321
- [parameters],
2322
- [
2323
- {
2324
- args: [
2325
- { in: "path", key: "sessionID" },
2326
- { in: "query", key: "directory" },
2327
- { in: "query", key: "workspace" },
2328
- { in: "body", key: "messageID" }
2329
- ]
2330
- }
2331
- ]
2332
- );
2333
- return (options?.client ?? this.client).post({
2334
- url: "/session/{sessionID}/fork",
2335
- ...options,
2336
- ...params,
2337
- headers: {
2338
- "Content-Type": "application/json",
2339
- ...options?.headers,
2340
- ...params.headers
2341
- }
2342
- });
2343
- }
2344
- /**
2345
- * Abort session
2346
- *
2347
- * Abort an active session and stop any ongoing AI processing or command execution.
2348
- */
2349
- abort(parameters, options) {
2350
- const params = buildClientParams(
2351
- [parameters],
2352
- [
2353
- {
2354
- args: [
2355
- { in: "path", key: "sessionID" },
2356
- { in: "query", key: "directory" },
2357
- { in: "query", key: "workspace" }
2358
- ]
2359
- }
2360
- ]
2361
- );
2362
- return (options?.client ?? this.client).post({
2363
- url: "/session/{sessionID}/abort",
2364
- ...options,
2365
- ...params
2366
- });
2367
- }
2368
- /**
2369
- * Unshare session
2370
- *
2371
- * Remove the shareable link for a session, making it private again.
2372
- */
2373
- unshare(parameters, options) {
2374
- const params = buildClientParams(
2375
- [parameters],
2376
- [
2377
- {
2378
- args: [
2379
- { in: "path", key: "sessionID" },
2380
- { in: "query", key: "directory" },
2381
- { in: "query", key: "workspace" }
2382
- ]
2383
- }
2384
- ]
2385
- );
2386
- return (options?.client ?? this.client).delete({
2387
- url: "/session/{sessionID}/share",
2388
- ...options,
2389
- ...params
2390
- });
2391
- }
2392
- /**
2393
- * Share session
2394
- *
2395
- * Create a shareable link for a session, allowing others to view the conversation.
2396
- */
2397
- share(parameters, options) {
2398
- const params = buildClientParams(
2399
- [parameters],
2400
- [
2401
- {
2402
- args: [
2403
- { in: "path", key: "sessionID" },
2404
- { in: "query", key: "directory" },
2405
- { in: "query", key: "workspace" }
2406
- ]
2407
- }
2408
- ]
2409
- );
2410
- return (options?.client ?? this.client).post({
2411
- url: "/session/{sessionID}/share",
2412
- ...options,
2413
- ...params
2414
- });
2415
- }
2416
- /**
2417
- * Get message diff
2418
- *
2419
- * Get the file changes (diff) that resulted from a specific user message in the session.
2420
- */
2421
- diff(parameters, options) {
2422
- const params = buildClientParams(
2423
- [parameters],
2424
- [
2425
- {
2426
- args: [
2427
- { in: "path", key: "sessionID" },
2428
- { in: "query", key: "directory" },
2429
- { in: "query", key: "workspace" },
2430
- { in: "query", key: "messageID" }
2431
- ]
2432
- }
2433
- ]
2434
- );
2435
- return (options?.client ?? this.client).get({
2436
- url: "/session/{sessionID}/diff",
2437
- ...options,
2438
- ...params
2439
- });
2440
- }
2441
- /**
2442
- * Summarize session
2443
- *
2444
- * Generate a concise summary of the session using AI compaction to preserve key information.
2445
- */
2446
- summarize(parameters, options) {
2447
- const params = buildClientParams(
2448
- [parameters],
2449
- [
2450
- {
2451
- args: [
2452
- { in: "path", key: "sessionID" },
2453
- { in: "query", key: "directory" },
2454
- { in: "query", key: "workspace" },
2455
- { in: "body", key: "providerID" },
2456
- { in: "body", key: "modelID" },
2457
- { in: "body", key: "auto" }
2458
- ]
2459
- }
2460
- ]
2461
- );
2462
- return (options?.client ?? this.client).post({
2463
- url: "/session/{sessionID}/summarize",
2464
- ...options,
2465
- ...params,
2466
- headers: {
2467
- "Content-Type": "application/json",
2468
- ...options?.headers,
2469
- ...params.headers
2470
- }
2471
- });
2472
- }
2473
- /**
2474
- * Get session messages
2475
- *
2476
- * Retrieve all messages in a session, including user prompts and AI responses.
2477
- */
2478
- messages(parameters, options) {
2479
- const params = buildClientParams(
2480
- [parameters],
2481
- [
2482
- {
2483
- args: [
2484
- { in: "path", key: "sessionID" },
2485
- { in: "query", key: "directory" },
2486
- { in: "query", key: "workspace" },
2487
- { in: "query", key: "limit" },
2488
- { in: "query", key: "before" }
2489
- ]
2490
- }
2491
- ]
2492
- );
2493
- return (options?.client ?? this.client).get({
2494
- url: "/session/{sessionID}/message",
2495
- ...options,
2496
- ...params
2497
- });
2498
- }
2499
- /**
2500
- * Send message
2501
- *
2502
- * Create and send a new message to a session, streaming the AI response.
2503
- */
2504
- prompt(parameters, options) {
2505
- const params = buildClientParams(
2506
- [parameters],
2507
- [
2508
- {
2509
- args: [
2510
- { in: "path", key: "sessionID" },
2511
- { in: "query", key: "directory" },
2512
- { in: "query", key: "workspace" },
2513
- { in: "body", key: "messageID" },
2514
- { in: "body", key: "model" },
2515
- { in: "body", key: "agent" },
2516
- { in: "body", key: "noReply" },
2517
- { in: "body", key: "tools" },
2518
- { in: "body", key: "format" },
2519
- { in: "body", key: "system" },
2520
- { in: "body", key: "variant" },
2521
- { in: "body", key: "parts" }
2522
- ]
2523
- }
2524
- ]
2525
- );
2526
- return (options?.client ?? this.client).post({
2527
- url: "/session/{sessionID}/message",
2528
- ...options,
2529
- ...params,
2530
- headers: {
2531
- "Content-Type": "application/json",
2532
- ...options?.headers,
2533
- ...params.headers
2534
- }
2535
- });
2536
- }
2537
- /**
2538
- * Delete message
2539
- *
2540
- * Permanently delete a specific message (and all of its parts) from a session. This does not revert any file changes that may have been made while processing the message.
2541
- */
2542
- deleteMessage(parameters, options) {
2543
- const params = buildClientParams(
2544
- [parameters],
2545
- [
2546
- {
2547
- args: [
2548
- { in: "path", key: "sessionID" },
2549
- { in: "path", key: "messageID" },
2550
- { in: "query", key: "directory" },
2551
- { in: "query", key: "workspace" }
2552
- ]
2553
- }
2554
- ]
2555
- );
2556
- return (options?.client ?? this.client).delete({
2557
- url: "/session/{sessionID}/message/{messageID}",
2558
- ...options,
2559
- ...params
2560
- });
2561
- }
2562
- /**
2563
- * Get message
2564
- *
2565
- * Retrieve a specific message from a session by its message ID.
2566
- */
2567
- message(parameters, options) {
2568
- const params = buildClientParams(
2569
- [parameters],
2570
- [
2571
- {
2572
- args: [
2573
- { in: "path", key: "sessionID" },
2574
- { in: "path", key: "messageID" },
2575
- { in: "query", key: "directory" },
2576
- { in: "query", key: "workspace" }
2577
- ]
2578
- }
2579
- ]
2580
- );
2581
- return (options?.client ?? this.client).get({
2582
- url: "/session/{sessionID}/message/{messageID}",
2583
- ...options,
2584
- ...params
2585
- });
2586
- }
2587
- /**
2588
- * Send async message
2589
- *
2590
- * Create and send a new message to a session asynchronously, starting the session if needed and returning immediately.
2591
- */
2592
- promptAsync(parameters, options) {
2593
- const params = buildClientParams(
2594
- [parameters],
2595
- [
2596
- {
2597
- args: [
2598
- { in: "path", key: "sessionID" },
2599
- { in: "query", key: "directory" },
2600
- { in: "query", key: "workspace" },
2601
- { in: "body", key: "messageID" },
2602
- { in: "body", key: "model" },
2603
- { in: "body", key: "agent" },
2604
- { in: "body", key: "noReply" },
2605
- { in: "body", key: "tools" },
2606
- { in: "body", key: "format" },
2607
- { in: "body", key: "system" },
2608
- { in: "body", key: "variant" },
2609
- { in: "body", key: "parts" }
2610
- ]
2611
- }
2612
- ]
2613
- );
2614
- return (options?.client ?? this.client).post({
2615
- url: "/session/{sessionID}/prompt_async",
2616
- ...options,
2617
- ...params,
2618
- headers: {
2619
- "Content-Type": "application/json",
2620
- ...options?.headers,
2621
- ...params.headers
2622
- }
2623
- });
2624
- }
2625
- /**
2626
- * Send command
2627
- *
2628
- * Send a new command to a session for execution by the AI assistant.
2629
- */
2630
- command(parameters, options) {
2631
- const params = buildClientParams(
2632
- [parameters],
2633
- [
2634
- {
2635
- args: [
2636
- { in: "path", key: "sessionID" },
2637
- { in: "query", key: "directory" },
2638
- { in: "query", key: "workspace" },
2639
- { in: "body", key: "messageID" },
2640
- { in: "body", key: "agent" },
2641
- { in: "body", key: "model" },
2642
- { in: "body", key: "arguments" },
2643
- { in: "body", key: "command" },
2644
- { in: "body", key: "variant" },
2645
- { in: "body", key: "parts" }
2646
- ]
2647
- }
2648
- ]
2649
- );
2650
- return (options?.client ?? this.client).post({
2651
- url: "/session/{sessionID}/command",
2652
- ...options,
2653
- ...params,
2654
- headers: {
2655
- "Content-Type": "application/json",
2656
- ...options?.headers,
2657
- ...params.headers
2658
- }
2659
- });
2660
- }
2661
- /**
2662
- * Run shell command
2663
- *
2664
- * Execute a shell command within the session context and return the AI's response.
2665
- */
2666
- shell(parameters, options) {
2667
- const params = buildClientParams(
2668
- [parameters],
2669
- [
2670
- {
2671
- args: [
2672
- { in: "path", key: "sessionID" },
2673
- { in: "query", key: "directory" },
2674
- { in: "query", key: "workspace" },
2675
- { in: "body", key: "messageID" },
2676
- { in: "body", key: "agent" },
2677
- { in: "body", key: "model" },
2678
- { in: "body", key: "command" }
2679
- ]
2680
- }
2681
- ]
2682
- );
2683
- return (options?.client ?? this.client).post({
2684
- url: "/session/{sessionID}/shell",
2685
- ...options,
2686
- ...params,
2687
- headers: {
2688
- "Content-Type": "application/json",
2689
- ...options?.headers,
2690
- ...params.headers
2691
- }
2692
- });
2693
- }
2694
- /**
2695
- * Revert message
2696
- *
2697
- * Revert a specific message in a session, undoing its effects and restoring the previous state.
2698
- */
2699
- revert(parameters, options) {
2700
- const params = buildClientParams(
2701
- [parameters],
2702
- [
2703
- {
2704
- args: [
2705
- { in: "path", key: "sessionID" },
2706
- { in: "query", key: "directory" },
2707
- { in: "query", key: "workspace" },
2708
- { in: "body", key: "messageID" },
2709
- { in: "body", key: "partID" }
2710
- ]
2711
- }
2712
- ]
2713
- );
2714
- return (options?.client ?? this.client).post({
2715
- url: "/session/{sessionID}/revert",
2716
- ...options,
2717
- ...params,
2718
- headers: {
2719
- "Content-Type": "application/json",
2720
- ...options?.headers,
2721
- ...params.headers
2722
- }
2723
- });
2724
- }
2725
- /**
2726
- * Restore reverted messages
2727
- *
2728
- * Restore all previously reverted messages in a session.
2729
- */
2730
- unrevert(parameters, options) {
2731
- const params = buildClientParams(
2732
- [parameters],
2733
- [
2734
- {
2735
- args: [
2736
- { in: "path", key: "sessionID" },
2737
- { in: "query", key: "directory" },
2738
- { in: "query", key: "workspace" }
2739
- ]
2740
- }
2741
- ]
2742
- );
2743
- return (options?.client ?? this.client).post({
2744
- url: "/session/{sessionID}/unrevert",
2745
- ...options,
2746
- ...params
2747
- });
2748
- }
2749
- };
2750
- var Part = class extends HeyApiClient {
2751
- /**
2752
- * Delete a part from a message
2753
- */
2754
- delete(parameters, options) {
2755
- const params = buildClientParams(
2756
- [parameters],
2757
- [
2758
- {
2759
- args: [
2760
- { in: "path", key: "sessionID" },
2761
- { in: "path", key: "messageID" },
2762
- { in: "path", key: "partID" },
2763
- { in: "query", key: "directory" },
2764
- { in: "query", key: "workspace" }
2765
- ]
2766
- }
2767
- ]
2768
- );
2769
- return (options?.client ?? this.client).delete({
2770
- url: "/session/{sessionID}/message/{messageID}/part/{partID}",
2771
- ...options,
2772
- ...params
2773
- });
2774
- }
2775
- /**
2776
- * Update a part in a message
2777
- */
2778
- update(parameters, options) {
2779
- const params = buildClientParams(
2780
- [parameters],
2781
- [
2782
- {
2783
- args: [
2784
- { in: "path", key: "sessionID" },
2785
- { in: "path", key: "messageID" },
2786
- { in: "path", key: "partID" },
2787
- { in: "query", key: "directory" },
2788
- { in: "query", key: "workspace" },
2789
- { key: "part", map: "body" }
2790
- ]
2791
- }
2792
- ]
2793
- );
2794
- return (options?.client ?? this.client).patch({
2795
- url: "/session/{sessionID}/message/{messageID}/part/{partID}",
2796
- ...options,
2797
- ...params,
2798
- headers: {
2799
- "Content-Type": "application/json",
2800
- ...options?.headers,
2801
- ...params.headers
2802
- }
2803
- });
2804
- }
2805
- };
2806
- var Permission = class extends HeyApiClient {
2807
- /**
2808
- * Respond to permission
2809
- *
2810
- * Approve or deny a permission request from the AI assistant.
2811
- *
2812
- * @deprecated
2813
- */
2814
- respond(parameters, options) {
2815
- const params = buildClientParams(
2816
- [parameters],
2817
- [
2818
- {
2819
- args: [
2820
- { in: "path", key: "sessionID" },
2821
- { in: "path", key: "permissionID" },
2822
- { in: "query", key: "directory" },
2823
- { in: "query", key: "workspace" },
2824
- { in: "body", key: "response" }
2825
- ]
2826
- }
2827
- ]
2828
- );
2829
- return (options?.client ?? this.client).post({
2830
- url: "/session/{sessionID}/permissions/{permissionID}",
2831
- ...options,
2832
- ...params,
2833
- headers: {
2834
- "Content-Type": "application/json",
2835
- ...options?.headers,
2836
- ...params.headers
2837
- }
2838
- });
2839
- }
2840
- /**
2841
- * Respond to permission request
2842
- *
2843
- * Approve or deny a permission request from the AI assistant.
2844
- */
2845
- reply(parameters, options) {
2846
- const params = buildClientParams(
2847
- [parameters],
2848
- [
2849
- {
2850
- args: [
2851
- { in: "path", key: "requestID" },
2852
- { in: "query", key: "directory" },
2853
- { in: "query", key: "workspace" },
2854
- { in: "body", key: "reply" },
2855
- { in: "body", key: "message" }
2856
- ]
2857
- }
2858
- ]
2859
- );
2860
- return (options?.client ?? this.client).post({
2861
- url: "/permission/{requestID}/reply",
2862
- ...options,
2863
- ...params,
2864
- headers: {
2865
- "Content-Type": "application/json",
2866
- ...options?.headers,
2867
- ...params.headers
2868
- }
2869
- });
2870
- }
2871
- /**
2872
- * List pending permissions
2873
- *
2874
- * Get all pending permission requests across all sessions.
2875
- */
2876
- list(parameters, options) {
2877
- const params = buildClientParams(
2878
- [parameters],
2879
- [
2880
- {
2881
- args: [
2882
- { in: "query", key: "directory" },
2883
- { in: "query", key: "workspace" }
2884
- ]
2885
- }
2886
- ]
2887
- );
2888
- return (options?.client ?? this.client).get({
2889
- url: "/permission",
2890
- ...options,
2891
- ...params
2892
- });
2893
- }
2894
- };
2895
- var Question = class extends HeyApiClient {
2896
- /**
2897
- * List pending questions
2898
- *
2899
- * Get all pending question requests across all sessions.
2900
- */
2901
- list(parameters, options) {
2902
- const params = buildClientParams(
2903
- [parameters],
2904
- [
2905
- {
2906
- args: [
2907
- { in: "query", key: "directory" },
2908
- { in: "query", key: "workspace" }
2909
- ]
2910
- }
2911
- ]
2912
- );
2913
- return (options?.client ?? this.client).get({
2914
- url: "/question",
2915
- ...options,
2916
- ...params
2917
- });
2918
- }
2919
- /**
2920
- * Reply to question request
2921
- *
2922
- * Provide answers to a question request from the AI assistant.
2923
- */
2924
- reply(parameters, options) {
2925
- const params = buildClientParams(
2926
- [parameters],
2927
- [
2928
- {
2929
- args: [
2930
- { in: "path", key: "requestID" },
2931
- { in: "query", key: "directory" },
2932
- { in: "query", key: "workspace" },
2933
- { in: "body", key: "answers" }
2934
- ]
2935
- }
2936
- ]
2937
- );
2938
- return (options?.client ?? this.client).post({
2939
- url: "/question/{requestID}/reply",
2940
- ...options,
2941
- ...params,
2942
- headers: {
2943
- "Content-Type": "application/json",
2944
- ...options?.headers,
2945
- ...params.headers
2946
- }
2947
- });
2948
- }
2949
- /**
2950
- * Reject question request
2951
- *
2952
- * Reject a question request from the AI assistant.
2953
- */
2954
- reject(parameters, options) {
2955
- const params = buildClientParams(
2956
- [parameters],
2957
- [
2958
- {
2959
- args: [
2960
- { in: "path", key: "requestID" },
2961
- { in: "query", key: "directory" },
2962
- { in: "query", key: "workspace" }
2963
- ]
2964
- }
2965
- ]
2966
- );
2967
- return (options?.client ?? this.client).post({
2968
- url: "/question/{requestID}/reject",
2969
- ...options,
2970
- ...params
2971
- });
2972
- }
2973
- };
2974
- var Oauth = class extends HeyApiClient {
2975
- /**
2976
- * OAuth authorize
2977
- *
2978
- * Initiate OAuth authorization for a specific AI provider to get an authorization URL.
2979
- */
2980
- authorize(parameters, options) {
2981
- const params = buildClientParams(
2982
- [parameters],
2983
- [
2984
- {
2985
- args: [
2986
- { in: "path", key: "providerID" },
2987
- { in: "query", key: "directory" },
2988
- { in: "query", key: "workspace" },
2989
- { in: "body", key: "method" },
2990
- { in: "body", key: "inputs" }
2991
- ]
2992
- }
2993
- ]
2994
- );
2995
- return (options?.client ?? this.client).post({
2996
- url: "/provider/{providerID}/oauth/authorize",
2997
- ...options,
2998
- ...params,
2999
- headers: {
3000
- "Content-Type": "application/json",
3001
- ...options?.headers,
3002
- ...params.headers
3003
- }
3004
- });
3005
- }
3006
- /**
3007
- * OAuth callback
3008
- *
3009
- * Handle the OAuth callback from a provider after user authorization.
3010
- */
3011
- callback(parameters, options) {
3012
- const params = buildClientParams(
3013
- [parameters],
3014
- [
3015
- {
3016
- args: [
3017
- { in: "path", key: "providerID" },
3018
- { in: "query", key: "directory" },
3019
- { in: "query", key: "workspace" },
3020
- { in: "body", key: "method" },
3021
- { in: "body", key: "code" }
3022
- ]
3023
- }
3024
- ]
3025
- );
3026
- return (options?.client ?? this.client).post({
3027
- url: "/provider/{providerID}/oauth/callback",
3028
- ...options,
3029
- ...params,
3030
- headers: {
3031
- "Content-Type": "application/json",
3032
- ...options?.headers,
3033
- ...params.headers
3034
- }
3035
- });
3036
- }
3037
- };
3038
- var Provider2 = class extends HeyApiClient {
3039
- /**
3040
- * List providers
3041
- *
3042
- * Get a list of all available AI providers, including both available and connected ones.
3043
- */
3044
- list(parameters, options) {
3045
- const params = buildClientParams(
3046
- [parameters],
3047
- [
3048
- {
3049
- args: [
3050
- { in: "query", key: "directory" },
3051
- { in: "query", key: "workspace" }
3052
- ]
3053
- }
3054
- ]
3055
- );
3056
- return (options?.client ?? this.client).get({
3057
- url: "/provider",
3058
- ...options,
3059
- ...params
3060
- });
3061
- }
3062
- /**
3063
- * Get provider auth methods
3064
- *
3065
- * Retrieve available authentication methods for all AI providers.
3066
- */
3067
- auth(parameters, options) {
3068
- const params = buildClientParams(
3069
- [parameters],
3070
- [
3071
- {
3072
- args: [
3073
- { in: "query", key: "directory" },
3074
- { in: "query", key: "workspace" }
3075
- ]
3076
- }
3077
- ]
3078
- );
3079
- return (options?.client ?? this.client).get({
3080
- url: "/provider/auth",
3081
- ...options,
3082
- ...params
3083
- });
3084
- }
3085
- _oauth;
3086
- get oauth() {
3087
- return this._oauth ??= new Oauth({ client: this.client });
3088
- }
3089
- };
3090
- var Find = class extends HeyApiClient {
3091
- /**
3092
- * Find text
3093
- *
3094
- * Search for text patterns across files in the project using ripgrep.
3095
- */
3096
- text(parameters, options) {
3097
- const params = buildClientParams(
3098
- [parameters],
3099
- [
3100
- {
3101
- args: [
3102
- { in: "query", key: "directory" },
3103
- { in: "query", key: "workspace" },
3104
- { in: "query", key: "pattern" }
3105
- ]
3106
- }
3107
- ]
3108
- );
3109
- return (options?.client ?? this.client).get({
3110
- url: "/find",
3111
- ...options,
3112
- ...params
3113
- });
3114
- }
3115
- /**
3116
- * Find files
3117
- *
3118
- * Search for files or directories by name or pattern in the project directory.
3119
- */
3120
- files(parameters, options) {
3121
- const params = buildClientParams(
3122
- [parameters],
3123
- [
3124
- {
3125
- args: [
3126
- { in: "query", key: "directory" },
3127
- { in: "query", key: "workspace" },
3128
- { in: "query", key: "query" },
3129
- { in: "query", key: "dirs" },
3130
- { in: "query", key: "type" },
3131
- { in: "query", key: "limit" }
3132
- ]
3133
- }
3134
- ]
3135
- );
3136
- return (options?.client ?? this.client).get({
3137
- url: "/find/file",
3138
- ...options,
3139
- ...params
3140
- });
3141
- }
3142
- /**
3143
- * Find symbols
3144
- *
3145
- * Search for workspace symbols like functions, classes, and variables using LSP.
3146
- */
3147
- symbols(parameters, options) {
3148
- const params = buildClientParams(
3149
- [parameters],
3150
- [
3151
- {
3152
- args: [
3153
- { in: "query", key: "directory" },
3154
- { in: "query", key: "workspace" },
3155
- { in: "query", key: "query" }
3156
- ]
3157
- }
3158
- ]
3159
- );
3160
- return (options?.client ?? this.client).get({
3161
- url: "/find/symbol",
3162
- ...options,
3163
- ...params
3164
- });
3165
- }
3166
- };
3167
- var File = class extends HeyApiClient {
3168
- /**
3169
- * List files
3170
- *
3171
- * List files and directories in a specified path.
3172
- */
3173
- list(parameters, options) {
3174
- const params = buildClientParams(
3175
- [parameters],
3176
- [
3177
- {
3178
- args: [
3179
- { in: "query", key: "directory" },
3180
- { in: "query", key: "workspace" },
3181
- { in: "query", key: "path" }
3182
- ]
3183
- }
3184
- ]
3185
- );
3186
- return (options?.client ?? this.client).get({
3187
- url: "/file",
3188
- ...options,
3189
- ...params
3190
- });
3191
- }
3192
- /**
3193
- * Read file
3194
- *
3195
- * Read the content of a specified file.
3196
- */
3197
- read(parameters, options) {
3198
- const params = buildClientParams(
3199
- [parameters],
3200
- [
3201
- {
3202
- args: [
3203
- { in: "query", key: "directory" },
3204
- { in: "query", key: "workspace" },
3205
- { in: "query", key: "path" }
3206
- ]
3207
- }
3208
- ]
3209
- );
3210
- return (options?.client ?? this.client).get({
3211
- url: "/file/content",
3212
- ...options,
3213
- ...params
3214
- });
3215
- }
3216
- /**
3217
- * Get file status
3218
- *
3219
- * Get the git status of all files in the project.
3220
- */
3221
- status(parameters, options) {
3222
- const params = buildClientParams(
3223
- [parameters],
3224
- [
3225
- {
3226
- args: [
3227
- { in: "query", key: "directory" },
3228
- { in: "query", key: "workspace" }
3229
- ]
3230
- }
3231
- ]
3232
- );
3233
- return (options?.client ?? this.client).get({
3234
- url: "/file/status",
3235
- ...options,
3236
- ...params
3237
- });
3238
- }
3239
- };
3240
- var Event = class extends HeyApiClient {
3241
- /**
3242
- * Subscribe to events
3243
- *
3244
- * Get events
3245
- */
3246
- subscribe(parameters, options) {
3247
- const params = buildClientParams(
3248
- [parameters],
3249
- [
3250
- {
3251
- args: [
3252
- { in: "query", key: "directory" },
3253
- { in: "query", key: "workspace" }
3254
- ]
3255
- }
3256
- ]
3257
- );
3258
- return (options?.client ?? this.client).sse.get({
3259
- url: "/event",
3260
- ...options,
3261
- ...params
3262
- });
3263
- }
3264
- };
3265
- var Auth2 = class extends HeyApiClient {
3266
- /**
3267
- * Remove MCP OAuth
3268
- *
3269
- * Remove OAuth credentials for an MCP server
3270
- */
3271
- remove(parameters, options) {
3272
- const params = buildClientParams(
3273
- [parameters],
3274
- [
3275
- {
3276
- args: [
3277
- { in: "path", key: "name" },
3278
- { in: "query", key: "directory" },
3279
- { in: "query", key: "workspace" }
3280
- ]
3281
- }
3282
- ]
3283
- );
3284
- return (options?.client ?? this.client).delete({
3285
- url: "/mcp/{name}/auth",
3286
- ...options,
3287
- ...params
3288
- });
3289
- }
3290
- /**
3291
- * Start MCP OAuth
3292
- *
3293
- * Start OAuth authentication flow for a Model Context Protocol (MCP) server.
3294
- */
3295
- start(parameters, options) {
3296
- const params = buildClientParams(
3297
- [parameters],
3298
- [
3299
- {
3300
- args: [
3301
- { in: "path", key: "name" },
3302
- { in: "query", key: "directory" },
3303
- { in: "query", key: "workspace" }
3304
- ]
3305
- }
3306
- ]
3307
- );
3308
- return (options?.client ?? this.client).post({
3309
- url: "/mcp/{name}/auth",
3310
- ...options,
3311
- ...params
3312
- });
3313
- }
3314
- /**
3315
- * Complete MCP OAuth
3316
- *
3317
- * Complete OAuth authentication for a Model Context Protocol (MCP) server using the authorization code.
3318
- */
3319
- callback(parameters, options) {
3320
- const params = buildClientParams(
3321
- [parameters],
3322
- [
3323
- {
3324
- args: [
3325
- { in: "path", key: "name" },
3326
- { in: "query", key: "directory" },
3327
- { in: "query", key: "workspace" },
3328
- { in: "body", key: "code" }
3329
- ]
3330
- }
3331
- ]
3332
- );
3333
- return (options?.client ?? this.client).post({
3334
- url: "/mcp/{name}/auth/callback",
3335
- ...options,
3336
- ...params,
3337
- headers: {
3338
- "Content-Type": "application/json",
3339
- ...options?.headers,
3340
- ...params.headers
3341
- }
3342
- });
3343
- }
3344
- /**
3345
- * Authenticate MCP OAuth
3346
- *
3347
- * Start OAuth flow and wait for callback (opens browser)
3348
- */
3349
- authenticate(parameters, options) {
3350
- const params = buildClientParams(
3351
- [parameters],
3352
- [
3353
- {
3354
- args: [
3355
- { in: "path", key: "name" },
3356
- { in: "query", key: "directory" },
3357
- { in: "query", key: "workspace" }
3358
- ]
3359
- }
3360
- ]
3361
- );
3362
- return (options?.client ?? this.client).post(
3363
- {
3364
- url: "/mcp/{name}/auth/authenticate",
3365
- ...options,
3366
- ...params
3367
- }
3368
- );
3369
- }
3370
- };
3371
- var Mcp = class extends HeyApiClient {
3372
- /**
3373
- * Get MCP status
3374
- *
3375
- * Get the status of all Model Context Protocol (MCP) servers.
3376
- */
3377
- status(parameters, options) {
3378
- const params = buildClientParams(
3379
- [parameters],
3380
- [
3381
- {
3382
- args: [
3383
- { in: "query", key: "directory" },
3384
- { in: "query", key: "workspace" }
3385
- ]
3386
- }
3387
- ]
3388
- );
3389
- return (options?.client ?? this.client).get({
3390
- url: "/mcp",
3391
- ...options,
3392
- ...params
3393
- });
3394
- }
3395
- /**
3396
- * Add MCP server
3397
- *
3398
- * Dynamically add a new Model Context Protocol (MCP) server to the system.
3399
- */
3400
- add(parameters, options) {
3401
- const params = buildClientParams(
3402
- [parameters],
3403
- [
3404
- {
3405
- args: [
3406
- { in: "query", key: "directory" },
3407
- { in: "query", key: "workspace" },
3408
- { in: "body", key: "name" },
3409
- { in: "body", key: "config" }
3410
- ]
3411
- }
3412
- ]
3413
- );
3414
- return (options?.client ?? this.client).post({
3415
- url: "/mcp",
3416
- ...options,
3417
- ...params,
3418
- headers: {
3419
- "Content-Type": "application/json",
3420
- ...options?.headers,
3421
- ...params.headers
3422
- }
3423
- });
3424
- }
3425
- /**
3426
- * Connect an MCP server
3427
- */
3428
- connect(parameters, options) {
3429
- const params = buildClientParams(
3430
- [parameters],
3431
- [
3432
- {
3433
- args: [
3434
- { in: "path", key: "name" },
3435
- { in: "query", key: "directory" },
3436
- { in: "query", key: "workspace" }
3437
- ]
3438
- }
3439
- ]
3440
- );
3441
- return (options?.client ?? this.client).post({
3442
- url: "/mcp/{name}/connect",
3443
- ...options,
3444
- ...params
3445
- });
3446
- }
3447
- /**
3448
- * Disconnect an MCP server
3449
- */
3450
- disconnect(parameters, options) {
3451
- const params = buildClientParams(
3452
- [parameters],
3453
- [
3454
- {
3455
- args: [
3456
- { in: "path", key: "name" },
3457
- { in: "query", key: "directory" },
3458
- { in: "query", key: "workspace" }
3459
- ]
3460
- }
3461
- ]
3462
- );
3463
- return (options?.client ?? this.client).post({
3464
- url: "/mcp/{name}/disconnect",
3465
- ...options,
3466
- ...params
3467
- });
3468
- }
3469
- _auth;
3470
- get auth() {
3471
- return this._auth ??= new Auth2({ client: this.client });
3472
- }
3473
- };
3474
- var Control = class extends HeyApiClient {
3475
- /**
3476
- * Get next TUI request
3477
- *
3478
- * Retrieve the next TUI (Terminal User Interface) request from the queue for processing.
3479
- */
3480
- next(parameters, options) {
3481
- const params = buildClientParams(
3482
- [parameters],
3483
- [
3484
- {
3485
- args: [
3486
- { in: "query", key: "directory" },
3487
- { in: "query", key: "workspace" }
3488
- ]
3489
- }
3490
- ]
3491
- );
3492
- return (options?.client ?? this.client).get({
3493
- url: "/tui/control/next",
3494
- ...options,
3495
- ...params
3496
- });
3497
- }
3498
- /**
3499
- * Submit TUI response
3500
- *
3501
- * Submit a response to the TUI request queue to complete a pending request.
3502
- */
3503
- response(parameters, options) {
3504
- const params = buildClientParams(
3505
- [parameters],
3506
- [
3507
- {
3508
- args: [
3509
- { in: "query", key: "directory" },
3510
- { in: "query", key: "workspace" },
3511
- { key: "body", map: "body" }
3512
- ]
3513
- }
3514
- ]
3515
- );
3516
- return (options?.client ?? this.client).post({
3517
- url: "/tui/control/response",
3518
- ...options,
3519
- ...params,
3520
- headers: {
3521
- "Content-Type": "application/json",
3522
- ...options?.headers,
3523
- ...params.headers
3524
- }
3525
- });
3526
- }
3527
- };
3528
- var Tui = class extends HeyApiClient {
3529
- /**
3530
- * Append TUI prompt
3531
- *
3532
- * Append prompt to the TUI
3533
- */
3534
- appendPrompt(parameters, options) {
3535
- const params = buildClientParams(
3536
- [parameters],
3537
- [
3538
- {
3539
- args: [
3540
- { in: "query", key: "directory" },
3541
- { in: "query", key: "workspace" },
3542
- { in: "body", key: "text" }
3543
- ]
3544
- }
3545
- ]
3546
- );
3547
- return (options?.client ?? this.client).post({
3548
- url: "/tui/append-prompt",
3549
- ...options,
3550
- ...params,
3551
- headers: {
3552
- "Content-Type": "application/json",
3553
- ...options?.headers,
3554
- ...params.headers
3555
- }
3556
- });
3557
- }
3558
- /**
3559
- * Open help dialog
3560
- *
3561
- * Open the help dialog in the TUI to display user assistance information.
3562
- */
3563
- openHelp(parameters, options) {
3564
- const params = buildClientParams(
3565
- [parameters],
3566
- [
3567
- {
3568
- args: [
3569
- { in: "query", key: "directory" },
3570
- { in: "query", key: "workspace" }
3571
- ]
3572
- }
3573
- ]
3574
- );
3575
- return (options?.client ?? this.client).post({
3576
- url: "/tui/open-help",
3577
- ...options,
3578
- ...params
3579
- });
3580
- }
3581
- /**
3582
- * Open sessions dialog
3583
- *
3584
- * Open the session dialog
3585
- */
3586
- openSessions(parameters, options) {
3587
- const params = buildClientParams(
3588
- [parameters],
3589
- [
3590
- {
3591
- args: [
3592
- { in: "query", key: "directory" },
3593
- { in: "query", key: "workspace" }
3594
- ]
3595
- }
3596
- ]
3597
- );
3598
- return (options?.client ?? this.client).post({
3599
- url: "/tui/open-sessions",
3600
- ...options,
3601
- ...params
3602
- });
3603
- }
3604
- /**
3605
- * Open themes dialog
3606
- *
3607
- * Open the theme dialog
3608
- */
3609
- openThemes(parameters, options) {
3610
- const params = buildClientParams(
3611
- [parameters],
3612
- [
3613
- {
3614
- args: [
3615
- { in: "query", key: "directory" },
3616
- { in: "query", key: "workspace" }
3617
- ]
3618
- }
3619
- ]
3620
- );
3621
- return (options?.client ?? this.client).post({
3622
- url: "/tui/open-themes",
3623
- ...options,
3624
- ...params
3625
- });
3626
- }
3627
- /**
3628
- * Open models dialog
3629
- *
3630
- * Open the model dialog
3631
- */
3632
- openModels(parameters, options) {
3633
- const params = buildClientParams(
3634
- [parameters],
3635
- [
3636
- {
3637
- args: [
3638
- { in: "query", key: "directory" },
3639
- { in: "query", key: "workspace" }
3640
- ]
3641
- }
3642
- ]
3643
- );
3644
- return (options?.client ?? this.client).post({
3645
- url: "/tui/open-models",
3646
- ...options,
3647
- ...params
3648
- });
3649
- }
3650
- /**
3651
- * Submit TUI prompt
3652
- *
3653
- * Submit the prompt
3654
- */
3655
- submitPrompt(parameters, options) {
3656
- const params = buildClientParams(
3657
- [parameters],
3658
- [
3659
- {
3660
- args: [
3661
- { in: "query", key: "directory" },
3662
- { in: "query", key: "workspace" }
3663
- ]
3664
- }
3665
- ]
3666
- );
3667
- return (options?.client ?? this.client).post({
3668
- url: "/tui/submit-prompt",
3669
- ...options,
3670
- ...params
3671
- });
3672
- }
3673
- /**
3674
- * Clear TUI prompt
3675
- *
3676
- * Clear the prompt
3677
- */
3678
- clearPrompt(parameters, options) {
3679
- const params = buildClientParams(
3680
- [parameters],
3681
- [
3682
- {
3683
- args: [
3684
- { in: "query", key: "directory" },
3685
- { in: "query", key: "workspace" }
3686
- ]
3687
- }
3688
- ]
3689
- );
3690
- return (options?.client ?? this.client).post({
3691
- url: "/tui/clear-prompt",
3692
- ...options,
3693
- ...params
3694
- });
3695
- }
3696
- /**
3697
- * Execute TUI command
3698
- *
3699
- * Execute a TUI command (e.g. agent_cycle)
3700
- */
3701
- executeCommand(parameters, options) {
3702
- const params = buildClientParams(
3703
- [parameters],
3704
- [
3705
- {
3706
- args: [
3707
- { in: "query", key: "directory" },
3708
- { in: "query", key: "workspace" },
3709
- { in: "body", key: "command" }
3710
- ]
3711
- }
3712
- ]
3713
- );
3714
- return (options?.client ?? this.client).post({
3715
- url: "/tui/execute-command",
3716
- ...options,
3717
- ...params,
3718
- headers: {
3719
- "Content-Type": "application/json",
3720
- ...options?.headers,
3721
- ...params.headers
3722
- }
3723
- });
3724
- }
3725
- /**
3726
- * Show TUI toast
3727
- *
3728
- * Show a toast notification in the TUI
3729
- */
3730
- showToast(parameters, options) {
3731
- const params = buildClientParams(
3732
- [parameters],
3733
- [
3734
- {
3735
- args: [
3736
- { in: "query", key: "directory" },
3737
- { in: "query", key: "workspace" },
3738
- { in: "body", key: "title" },
3739
- { in: "body", key: "message" },
3740
- { in: "body", key: "variant" },
3741
- { in: "body", key: "duration" }
3742
- ]
3743
- }
3744
- ]
3745
- );
3746
- return (options?.client ?? this.client).post({
3747
- url: "/tui/show-toast",
3748
- ...options,
3749
- ...params,
3750
- headers: {
3751
- "Content-Type": "application/json",
3752
- ...options?.headers,
3753
- ...params.headers
3754
- }
3755
- });
3756
- }
3757
- /**
3758
- * Publish TUI event
3759
- *
3760
- * Publish a TUI event
3761
- */
3762
- publish(parameters, options) {
3763
- const params = buildClientParams(
3764
- [parameters],
3765
- [
3766
- {
3767
- args: [
3768
- { in: "query", key: "directory" },
3769
- { in: "query", key: "workspace" },
3770
- { key: "body", map: "body" }
3771
- ]
3772
- }
3773
- ]
3774
- );
3775
- return (options?.client ?? this.client).post({
3776
- url: "/tui/publish",
3777
- ...options,
3778
- ...params,
3779
- headers: {
3780
- "Content-Type": "application/json",
3781
- ...options?.headers,
3782
- ...params.headers
3783
- }
3784
- });
3785
- }
3786
- /**
3787
- * Select session
3788
- *
3789
- * Navigate the TUI to display the specified session.
3790
- */
3791
- selectSession(parameters, options) {
3792
- const params = buildClientParams(
3793
- [parameters],
3794
- [
3795
- {
3796
- args: [
3797
- { in: "query", key: "directory" },
3798
- { in: "query", key: "workspace" },
3799
- { in: "body", key: "sessionID" }
3800
- ]
3801
- }
3802
- ]
3803
- );
3804
- return (options?.client ?? this.client).post({
3805
- url: "/tui/select-session",
3806
- ...options,
3807
- ...params,
3808
- headers: {
3809
- "Content-Type": "application/json",
3810
- ...options?.headers,
3811
- ...params.headers
3812
- }
3813
- });
3814
- }
3815
- _control;
3816
- get control() {
3817
- return this._control ??= new Control({ client: this.client });
3818
- }
3819
- };
3820
- var Instance2 = class extends HeyApiClient {
3821
- /**
3822
- * Dispose instance
3823
- *
3824
- * Clean up and dispose the current OpenCode instance, releasing all resources.
3825
- */
3826
- dispose(parameters, options) {
3827
- const params = buildClientParams(
3828
- [parameters],
3829
- [
3830
- {
3831
- args: [
3832
- { in: "query", key: "directory" },
3833
- { in: "query", key: "workspace" }
3834
- ]
3835
- }
3836
- ]
3837
- );
3838
- return (options?.client ?? this.client).post({
3839
- url: "/instance/dispose",
3840
- ...options,
3841
- ...params
3842
- });
3843
- }
3844
- };
3845
- var Path = class extends HeyApiClient {
3846
- /**
3847
- * Get paths
3848
- *
3849
- * Retrieve the current working directory and related path information for the OpenCode instance.
3850
- */
3851
- get(parameters, options) {
3852
- const params = buildClientParams(
3853
- [parameters],
3854
- [
3855
- {
3856
- args: [
3857
- { in: "query", key: "directory" },
3858
- { in: "query", key: "workspace" }
3859
- ]
3860
- }
3861
- ]
3862
- );
3863
- return (options?.client ?? this.client).get({
3864
- url: "/path",
3865
- ...options,
3866
- ...params
3867
- });
3868
- }
3869
- };
3870
- var Vcs = class extends HeyApiClient {
3871
- /**
3872
- * Get VCS info
3873
- *
3874
- * Retrieve version control system (VCS) information for the current project, such as git branch.
3875
- */
3876
- get(parameters, options) {
3877
- const params = buildClientParams(
3878
- [parameters],
3879
- [
3880
- {
3881
- args: [
3882
- { in: "query", key: "directory" },
3883
- { in: "query", key: "workspace" }
3884
- ]
3885
- }
3886
- ]
3887
- );
3888
- return (options?.client ?? this.client).get({
3889
- url: "/vcs",
3890
- ...options,
3891
- ...params
3892
- });
3893
- }
3894
- /**
3895
- * Get VCS diff
3896
- *
3897
- * Retrieve the current git diff for the working tree or against the default branch.
3898
- */
3899
- diff(parameters, options) {
3900
- const params = buildClientParams(
3901
- [parameters],
3902
- [
3903
- {
3904
- args: [
3905
- { in: "query", key: "directory" },
3906
- { in: "query", key: "workspace" },
3907
- { in: "query", key: "mode" }
3908
- ]
3909
- }
3910
- ]
3911
- );
3912
- return (options?.client ?? this.client).get({
3913
- url: "/vcs/diff",
3914
- ...options,
3915
- ...params
3916
- });
3917
- }
3918
- };
3919
- var Command = class extends HeyApiClient {
3920
- /**
3921
- * List commands
3922
- *
3923
- * Get a list of all available commands in the OpenCode system.
3924
- */
3925
- list(parameters, options) {
3926
- const params = buildClientParams(
3927
- [parameters],
3928
- [
3929
- {
3930
- args: [
3931
- { in: "query", key: "directory" },
3932
- { in: "query", key: "workspace" }
3933
- ]
3934
- }
3935
- ]
3936
- );
3937
- return (options?.client ?? this.client).get({
3938
- url: "/command",
3939
- ...options,
3940
- ...params
3941
- });
3942
- }
3943
- };
3944
- var Lsp = class extends HeyApiClient {
3945
- /**
3946
- * Get LSP status
3947
- *
3948
- * Get LSP server status
3949
- */
3950
- status(parameters, options) {
3951
- const params = buildClientParams(
3952
- [parameters],
3953
- [
3954
- {
3955
- args: [
3956
- { in: "query", key: "directory" },
3957
- { in: "query", key: "workspace" }
3958
- ]
3959
- }
3960
- ]
3961
- );
3962
- return (options?.client ?? this.client).get({
3963
- url: "/lsp",
3964
- ...options,
3965
- ...params
3966
- });
3967
- }
3968
- };
3969
- var Formatter = class extends HeyApiClient {
3970
- /**
3971
- * Get formatter status
3972
- *
3973
- * Get formatter status
3974
- */
3975
- status(parameters, options) {
3976
- const params = buildClientParams(
3977
- [parameters],
3978
- [
3979
- {
3980
- args: [
3981
- { in: "query", key: "directory" },
3982
- { in: "query", key: "workspace" }
3983
- ]
3984
- }
3985
- ]
3986
- );
3987
- return (options?.client ?? this.client).get({
3988
- url: "/formatter",
3989
- ...options,
3990
- ...params
3991
- });
3992
- }
3993
- };
3994
- var OpencodeClient = class _OpencodeClient extends HeyApiClient {
3995
- static __registry = new HeyApiRegistry();
3996
- constructor(args) {
3997
- super(args);
3998
- _OpencodeClient.__registry.set(this, args?.key);
3999
- }
4000
- _global;
4001
- get global() {
4002
- return this._global ??= new Global({ client: this.client });
4003
- }
4004
- _auth;
4005
- get auth() {
4006
- return this._auth ??= new Auth({ client: this.client });
4007
- }
4008
- _app;
4009
- get app() {
4010
- return this._app ??= new App({ client: this.client });
4011
- }
4012
- _project;
4013
- get project() {
4014
- return this._project ??= new Project({ client: this.client });
4015
- }
4016
- _pty;
4017
- get pty() {
4018
- return this._pty ??= new Pty({ client: this.client });
4019
- }
4020
- _config;
4021
- get config() {
4022
- return this._config ??= new Config2({ client: this.client });
4023
- }
4024
- _experimental;
4025
- get experimental() {
4026
- return this._experimental ??= new Experimental({ client: this.client });
4027
- }
4028
- _tool;
4029
- get tool() {
4030
- return this._tool ??= new Tool({ client: this.client });
4031
- }
4032
- _worktree;
4033
- get worktree() {
4034
- return this._worktree ??= new Worktree({ client: this.client });
4035
- }
4036
- _session;
4037
- get session() {
4038
- return this._session ??= new Session2({ client: this.client });
4039
- }
4040
- _part;
4041
- get part() {
4042
- return this._part ??= new Part({ client: this.client });
4043
- }
4044
- _permission;
4045
- get permission() {
4046
- return this._permission ??= new Permission({ client: this.client });
4047
- }
4048
- _question;
4049
- get question() {
4050
- return this._question ??= new Question({ client: this.client });
4051
- }
4052
- _provider;
4053
- get provider() {
4054
- return this._provider ??= new Provider2({ client: this.client });
4055
- }
4056
- _find;
4057
- get find() {
4058
- return this._find ??= new Find({ client: this.client });
4059
- }
4060
- _file;
4061
- get file() {
4062
- return this._file ??= new File({ client: this.client });
4063
- }
4064
- _event;
4065
- get event() {
4066
- return this._event ??= new Event({ client: this.client });
4067
- }
4068
- _mcp;
4069
- get mcp() {
4070
- return this._mcp ??= new Mcp({ client: this.client });
4071
- }
4072
- _tui;
4073
- get tui() {
4074
- return this._tui ??= new Tui({ client: this.client });
4075
- }
4076
- _instance;
4077
- get instance() {
4078
- return this._instance ??= new Instance2({ client: this.client });
4079
- }
4080
- _path;
4081
- get path() {
4082
- return this._path ??= new Path({ client: this.client });
4083
- }
4084
- _vcs;
4085
- get vcs() {
4086
- return this._vcs ??= new Vcs({ client: this.client });
4087
- }
4088
- _command;
4089
- get command() {
4090
- return this._command ??= new Command({ client: this.client });
4091
- }
4092
- _lsp;
4093
- get lsp() {
4094
- return this._lsp ??= new Lsp({ client: this.client });
4095
- }
4096
- _formatter;
4097
- get formatter() {
4098
- return this._formatter ??= new Formatter({ client: this.client });
4099
- }
4100
- };
4101
-
4102
- // packages/sdk/src/v2/client.ts
4103
- function pick(value, fallback2, encode) {
4104
- if (!value) return;
4105
- if (!fallback2) return value;
4106
- if (value === fallback2) return fallback2;
4107
- if (encode && value === encode(fallback2)) return fallback2;
4108
- return value;
4109
- }
4110
- function rewrite(request, values) {
4111
- if (request.method !== "GET" && request.method !== "HEAD") return request;
4112
- const url = new URL(request.url);
4113
- let changed = false;
4114
- for (const [name, key] of [
4115
- ["x-opencode-directory", "directory"],
4116
- ["x-opencode-workspace", "workspace"]
4117
- ]) {
4118
- const value = pick(
4119
- request.headers.get(name),
4120
- key === "directory" ? values.directory : values.workspace,
4121
- key === "directory" ? encodeURIComponent : void 0
4122
- );
4123
- if (!value) continue;
4124
- if (!url.searchParams.has(key)) {
4125
- url.searchParams.set(key, value);
4126
- }
4127
- changed = true;
4128
- }
4129
- if (!changed) return request;
4130
- const next = new Request(url, request);
4131
- next.headers.delete("x-opencode-directory");
4132
- next.headers.delete("x-opencode-workspace");
4133
- return next;
4134
- }
4135
- function createOpencodeClient(config) {
4136
- if (!config?.fetch) {
4137
- const customFetch = (req) => {
4138
- req.timeout = false;
4139
- return fetch(req);
4140
- };
4141
- config = {
4142
- ...config,
4143
- fetch: customFetch
4144
- };
4145
- }
4146
- if (config?.directory) {
4147
- config.headers = {
4148
- ...config.headers,
4149
- "x-opencode-directory": encodeURIComponent(config.directory)
4150
- };
4151
- }
4152
- if (config?.experimental_workspaceID) {
4153
- config.headers = {
4154
- ...config.headers,
4155
- "x-opencode-workspace": config.experimental_workspaceID
4156
- };
4157
- }
4158
- const client2 = createClient(config);
4159
- client2.interceptors.request.use(
4160
- (request) => rewrite(request, {
4161
- directory: config?.directory,
4162
- workspace: config?.experimental_workspaceID
4163
- })
4164
- );
4165
- return new OpencodeClient({ client: client2 });
4166
- }
4167
-
4168
- // packages/sdk/src/v2/server.ts
4169
- import launch from "cross-spawn";
4170
-
4171
- // packages/opencode/src/util/locale.ts
4172
- var Locale;
4173
- ((Locale2) => {
4174
- function titlecase(str) {
4175
- return str.replace(/\b\w/g, (c) => c.toUpperCase());
4176
- }
4177
- Locale2.titlecase = titlecase;
4178
- function time(input) {
4179
- const date = new Date(input);
4180
- return date.toLocaleTimeString(void 0, { timeStyle: "short" });
4181
- }
4182
- Locale2.time = time;
4183
- function datetime(input) {
4184
- const date = new Date(input);
4185
- const localTime = time(input);
4186
- const localDate = date.toLocaleDateString();
4187
- return `${localTime} \xB7 ${localDate}`;
4188
- }
4189
- Locale2.datetime = datetime;
4190
- function todayTimeOrDateTime(input) {
4191
- const date = new Date(input);
4192
- const now = /* @__PURE__ */ new Date();
4193
- const isToday = date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate();
4194
- if (isToday) {
4195
- return time(input);
4196
- } else {
4197
- return datetime(input);
4198
- }
4199
- }
4200
- Locale2.todayTimeOrDateTime = todayTimeOrDateTime;
4201
- function number(num) {
4202
- if (num >= 1e6) {
4203
- return (num / 1e6).toFixed(1) + "M";
4204
- } else if (num >= 1e3) {
4205
- return (num / 1e3).toFixed(1) + "K";
4206
- }
4207
- return num.toString();
4208
- }
4209
- Locale2.number = number;
4210
- function duration(input) {
4211
- if (input < 1e3) {
4212
- return `${input}ms`;
4213
- }
4214
- if (input < 6e4) {
4215
- return `${(input / 1e3).toFixed(1)}s`;
4216
- }
4217
- if (input < 36e5) {
4218
- const minutes = Math.floor(input / 6e4);
4219
- const seconds = Math.floor(input % 6e4 / 1e3);
4220
- return `${minutes}m ${seconds}s`;
4221
- }
4222
- if (input < 864e5) {
4223
- const hours2 = Math.floor(input / 36e5);
4224
- const minutes = Math.floor(input % 36e5 / 6e4);
4225
- return `${hours2}h ${minutes}m`;
4226
- }
4227
- const hours = Math.floor(input / 36e5);
4228
- const days = Math.floor(input % 36e5 / 864e5);
4229
- return `${days}d ${hours}h`;
4230
- }
4231
- Locale2.duration = duration;
4232
- function truncate(str, len) {
4233
- if (str.length <= len) return str;
4234
- return str.slice(0, len - 1) + "\u2026";
4235
- }
4236
- Locale2.truncate = truncate;
4237
- function truncateMiddle(str, maxLength = 35) {
4238
- if (str.length <= maxLength) return str;
4239
- const ellipsis = "\u2026";
4240
- const keepStart = Math.ceil((maxLength - ellipsis.length) / 2);
4241
- const keepEnd = Math.floor((maxLength - ellipsis.length) / 2);
4242
- return str.slice(0, keepStart) + ellipsis + str.slice(-keepEnd);
4243
- }
4244
- Locale2.truncateMiddle = truncateMiddle;
4245
- function pluralize(count, singular, plural) {
4246
- const template = count === 1 ? singular : plural;
4247
- return template.replace("{}", count.toString());
4248
- }
4249
- Locale2.pluralize = pluralize;
4250
- })(Locale || (Locale = {}));
4251
-
4252
- // packages/opencode/src/cli/cmd/run.ts
4253
- function props(part) {
4254
- const state = part.state;
4255
- return {
4256
- input: state.input,
4257
- metadata: "metadata" in state ? state.metadata : {},
4258
- part
4259
- };
4260
- }
4261
- function inline(info) {
4262
- const suffix = info.description ? UI.Style.TEXT_DIM + ` ${info.description}` + UI.Style.TEXT_NORMAL : "";
4263
- UI.println(UI.Style.TEXT_NORMAL + info.icon, UI.Style.TEXT_NORMAL + info.title + suffix);
4264
- }
4265
- function block(info, output) {
4266
- UI.empty();
4267
- inline(info);
4268
- if (!output?.trim()) return;
4269
- UI.println(output);
4270
- UI.empty();
4271
- }
4272
- function fallback(part) {
4273
- const state = part.state;
4274
- const input = "input" in state ? state.input : void 0;
4275
- const title = ("title" in state && state.title ? state.title : void 0) || (input && typeof input === "object" && Object.keys(input).length > 0 ? JSON.stringify(input) : "Unknown");
4276
- inline({
4277
- icon: "\u2699",
4278
- title: `${part.tool} ${title}`
4279
- });
4280
- }
4281
- function glob(info) {
4282
- const root = info.input.path ?? "";
4283
- const title = `Glob "${info.input.pattern}"`;
4284
- const suffix = root ? `in ${normalizePath(root)}` : "";
4285
- const num = info.metadata.count;
4286
- const description = num === void 0 ? suffix : `${suffix}${suffix ? " \xB7 " : ""}${num} ${num === 1 ? "match" : "matches"}`;
4287
- inline({
4288
- icon: "\u2731",
4289
- title,
4290
- ...description && { description }
4291
- });
4292
- }
4293
- function grep(info) {
4294
- const root = info.input.path ?? "";
4295
- const title = `Grep "${info.input.pattern}"`;
4296
- const suffix = root ? `in ${normalizePath(root)}` : "";
4297
- const num = info.metadata.matches;
4298
- const description = num === void 0 ? suffix : `${suffix}${suffix ? " \xB7 " : ""}${num} ${num === 1 ? "match" : "matches"}`;
4299
- inline({
4300
- icon: "\u2731",
4301
- title,
4302
- ...description && { description }
4303
- });
4304
- }
4305
- function list(info) {
4306
- const dir = info.input.path ? normalizePath(info.input.path) : "";
4307
- inline({
4308
- icon: "\u2192",
4309
- title: dir ? `List ${dir}` : "List"
4310
- });
4311
- }
4312
- function read(info) {
4313
- const file = normalizePath(info.input.filePath);
4314
- const pairs = Object.entries(info.input).filter(([key, value]) => {
4315
- if (key === "filePath") return false;
4316
- return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
4317
- });
4318
- const description = pairs.length ? `[${pairs.map(([key, value]) => `${key}=${value}`).join(", ")}]` : void 0;
4319
- inline({
4320
- icon: "\u2192",
4321
- title: `Read ${file}`,
4322
- ...description && { description }
4323
- });
4324
- }
4325
- function write(info) {
4326
- block(
4327
- {
4328
- icon: "\u2190",
4329
- title: `Write ${normalizePath(info.input.filePath)}`
4330
- },
4331
- info.part.state.status === "completed" ? info.part.state.output : void 0
4332
- );
4333
- }
4334
- function webfetch(info) {
4335
- inline({
4336
- icon: "%",
4337
- title: `WebFetch ${info.input.url}`
4338
- });
4339
- }
4340
- function edit(info) {
4341
- const title = normalizePath(info.input.filePath);
4342
- const diff = info.metadata.diff;
4343
- block(
4344
- {
4345
- icon: "\u2190",
4346
- title: `Edit ${title}`
4347
- },
4348
- diff
4349
- );
4350
- }
4351
- function codesearch(info) {
4352
- inline({
4353
- icon: "\u25C7",
4354
- title: `Exa Code Search "${info.input.query}"`
4355
- });
4356
- }
4357
- function websearch(info) {
4358
- inline({
4359
- icon: "\u25C8",
4360
- title: `Exa Web Search "${info.input.query}"`
4361
- });
4362
- }
4363
- function task(info) {
4364
- const input = info.part.state.input;
4365
- const status = info.part.state.status;
4366
- const subagent = typeof input.subagent_type === "string" && input.subagent_type.trim().length > 0 ? input.subagent_type : "unknown";
4367
- const agent = Locale.titlecase(subagent);
4368
- const desc = typeof input.description === "string" && input.description.trim().length > 0 ? input.description : void 0;
4369
- const icon = status === "error" ? "\u2717" : status === "running" ? "\u2022" : "\u2713";
4370
- const name = desc ?? `${agent} Task`;
4371
- inline({
4372
- icon,
4373
- title: name,
4374
- description: desc ? `${agent} Agent` : void 0
4375
- });
4376
- }
4377
- function skill(info) {
4378
- inline({
4379
- icon: "\u2192",
4380
- title: `Skill "${info.input.name}"`
4381
- });
4382
- }
4383
- function bash(info) {
4384
- const output = info.part.state.status === "completed" ? info.part.state.output?.trim() : void 0;
4385
- block(
4386
- {
4387
- icon: "$",
4388
- title: `${info.input.command}`
4389
- },
4390
- output
4391
- );
4392
- }
4393
- function todo(info) {
4394
- block(
4395
- {
4396
- icon: "#",
4397
- title: "Todos"
4398
- },
4399
- info.input.todos.map((item) => `${item.status === "completed" ? "[x]" : "[ ]"} ${item.content}`).join("\n")
4400
- );
4401
- }
4402
- function normalizePath(input) {
4403
- if (!input) return "";
4404
- if (path.isAbsolute(input)) return path.relative(process.cwd(), input) || ".";
4405
- return input;
4406
- }
4407
- var RunCommand = cmd({
4408
- command: "run [message..]",
4409
- describe: "run opencode with a message",
4410
- builder: (yargs) => {
4411
- return yargs.positional("message", {
4412
- describe: "message to send",
4413
- type: "string",
4414
- array: true,
4415
- default: []
4416
- }).option("command", {
4417
- describe: "the command to run, use message for args",
4418
- type: "string"
4419
- }).option("continue", {
4420
- alias: ["c"],
4421
- describe: "continue the last session",
4422
- type: "boolean"
4423
- }).option("session", {
4424
- alias: ["s"],
4425
- describe: "session id to continue",
4426
- type: "string"
4427
- }).option("fork", {
4428
- describe: "fork the session before continuing (requires --continue or --session)",
4429
- type: "boolean"
4430
- }).option("share", {
4431
- type: "boolean",
4432
- describe: "share the session"
4433
- }).option("model", {
4434
- type: "string",
4435
- alias: ["m"],
4436
- describe: "model to use in the format of provider/model"
4437
- }).option("agent", {
4438
- type: "string",
4439
- describe: "agent to use"
4440
- }).option("format", {
4441
- type: "string",
4442
- choices: ["default", "json"],
4443
- default: "default",
4444
- describe: "format: default (formatted) or json (raw JSON events)"
4445
- }).option("file", {
4446
- alias: ["f"],
4447
- type: "string",
4448
- array: true,
4449
- describe: "file(s) to attach to message"
4450
- }).option("title", {
4451
- type: "string",
4452
- describe: "title for the session (uses truncated prompt if no value provided)"
4453
- }).option("attach", {
4454
- type: "string",
4455
- describe: "attach to a running opencode server (e.g., http://localhost:4096)"
4456
- }).option("password", {
4457
- alias: ["p"],
4458
- type: "string",
4459
- describe: "basic auth password (defaults to OPENCODE_SERVER_PASSWORD)"
4460
- }).option("dir", {
4461
- type: "string",
4462
- describe: "directory to run in, path on remote server if attaching"
4463
- }).option("port", {
4464
- type: "number",
4465
- describe: "port for the local server (defaults to random port if no value provided)"
4466
- }).option("variant", {
4467
- type: "string",
4468
- describe: "model variant (provider-specific reasoning effort, e.g., high, max, minimal)"
4469
- }).option("thinking", {
4470
- type: "boolean",
4471
- describe: "show thinking blocks",
4472
- default: false
4473
- }).option("dangerously-skip-permissions", {
4474
- type: "boolean",
4475
- describe: "auto-approve permissions that are not explicitly denied (dangerous!)",
4476
- default: false
4477
- });
4478
- },
4479
- handler: async (args) => {
4480
- let message = [...args.message, ...args["--"] || []].map((arg) => arg.includes(" ") ? `"${arg.replace(/"/g, '\\"')}"` : arg).join(" ");
4481
- const directory = (() => {
4482
- if (!args.dir) return void 0;
4483
- if (args.attach) return args.dir;
4484
- try {
4485
- process.chdir(args.dir);
4486
- return process.cwd();
4487
- } catch {
4488
- UI.error("Failed to change directory to " + args.dir);
4489
- process.exit(1);
4490
- }
4491
- })();
4492
- const files = [];
4493
- if (args.file) {
4494
- const list2 = Array.isArray(args.file) ? args.file : [args.file];
4495
- for (const filePath of list2) {
4496
- const resolvedPath = path.resolve(process.cwd(), filePath);
4497
- if (!await Filesystem.exists(resolvedPath)) {
4498
- UI.error(`File not found: ${filePath}`);
4499
- process.exit(1);
4500
- }
4501
- const mime = await Filesystem.isDir(resolvedPath) ? "application/x-directory" : "text/plain";
4502
- files.push({
4503
- type: "file",
4504
- url: pathToFileURL(resolvedPath).href,
4505
- filename: path.basename(resolvedPath),
4506
- mime
4507
- });
4508
- }
4509
- }
4510
- if (!process.stdin.isTTY) message += "\n" + await Bun.stdin.text();
4511
- if (message.trim().length === 0 && !args.command) {
4512
- UI.error("You must provide a message or a command");
4513
- process.exit(1);
4514
- }
4515
- if (args.fork && !args.continue && !args.session) {
4516
- UI.error("--fork requires --continue or --session");
4517
- process.exit(1);
4518
- }
4519
- const rules = [
4520
- {
4521
- permission: "question",
4522
- action: "deny",
4523
- pattern: "*"
4524
- },
4525
- {
4526
- permission: "plan_enter",
4527
- action: "deny",
4528
- pattern: "*"
4529
- },
4530
- {
4531
- permission: "plan_exit",
4532
- action: "deny",
4533
- pattern: "*"
4534
- }
4535
- ];
4536
- function title() {
4537
- if (args.title === void 0) return;
4538
- if (args.title !== "") return args.title;
4539
- return message.slice(0, 50) + (message.length > 50 ? "..." : "");
4540
- }
4541
- async function session(sdk) {
4542
- const baseID = args.continue ? (await sdk.session.list()).data?.find((s) => !s.parentID)?.id : args.session;
4543
- if (baseID && args.fork) {
4544
- const forked = await sdk.session.fork({ sessionID: baseID });
4545
- return forked.data?.id;
4546
- }
4547
- if (baseID) return baseID;
4548
- const name = title();
4549
- const result = await sdk.session.create({ title: name, permission: rules });
4550
- return result.data?.id;
4551
- }
4552
- async function share(sdk, sessionID) {
4553
- const cfg = await sdk.config.get();
4554
- if (!cfg.data) return;
4555
- if (cfg.data.share !== "auto" && !Flag.OPENCODE_AUTO_SHARE && !args.share) return;
4556
- const res = await sdk.session.share({ sessionID }).catch((error) => {
4557
- if (error instanceof Error && error.message.includes("disabled")) {
4558
- UI.println(UI.Style.TEXT_DANGER_BOLD + "! " + error.message);
4559
- }
4560
- return { error };
4561
- });
4562
- if (!res.error && "data" in res && res.data?.share?.url) {
4563
- UI.println(UI.Style.TEXT_INFO_BOLD + "~ " + res.data.share.url);
4564
- }
4565
- }
4566
- async function execute(sdk) {
4567
- function tool(part) {
4568
- try {
4569
- if (part.tool === "bash") return bash(props(part));
4570
- if (part.tool === "glob") return glob(props(part));
4571
- if (part.tool === "grep") return grep(props(part));
4572
- if (part.tool === "list") return list(props(part));
4573
- if (part.tool === "read") return read(props(part));
4574
- if (part.tool === "write") return write(props(part));
4575
- if (part.tool === "webfetch") return webfetch(props(part));
4576
- if (part.tool === "edit") return edit(props(part));
4577
- if (part.tool === "codesearch") return codesearch(props(part));
4578
- if (part.tool === "websearch") return websearch(props(part));
4579
- if (part.tool === "task") return task(props(part));
4580
- if (part.tool === "todowrite") return todo(props(part));
4581
- if (part.tool === "skill") return skill(props(part));
4582
- return fallback(part);
4583
- } catch {
4584
- return fallback(part);
4585
- }
4586
- }
4587
- function emit(type, data) {
4588
- if (args.format === "json") {
4589
- process.stdout.write(JSON.stringify({ type, timestamp: Date.now(), sessionID, ...data }) + EOL2);
4590
- return true;
4591
- }
4592
- return false;
4593
- }
4594
- const events = await sdk.event.subscribe();
4595
- let error;
4596
- async function loop() {
4597
- const toggles = /* @__PURE__ */ new Map();
4598
- for await (const event of events.stream) {
4599
- if (event.type === "message.updated" && event.properties.info.role === "assistant" && args.format !== "json" && toggles.get("start") !== true) {
4600
- UI.empty();
4601
- UI.println(`> ${event.properties.info.agent} \xB7 ${event.properties.info.modelID}`);
4602
- UI.empty();
4603
- toggles.set("start", true);
4604
- }
4605
- if (event.type === "message.part.updated") {
4606
- const part = event.properties.part;
4607
- if (part.sessionID !== sessionID) continue;
4608
- if (part.type === "tool" && (part.state.status === "completed" || part.state.status === "error")) {
4609
- if (emit("tool_use", { part })) continue;
4610
- if (part.state.status === "completed") {
4611
- tool(part);
4612
- continue;
4613
- }
4614
- inline({
4615
- icon: "\u2717",
4616
- title: `${part.tool} failed`
4617
- });
4618
- UI.error(part.state.error);
4619
- }
4620
- if (part.type === "tool" && part.tool === "task" && part.state.status === "running" && args.format !== "json") {
4621
- if (toggles.get(part.id) === true) continue;
4622
- task(props(part));
4623
- toggles.set(part.id, true);
4624
- }
4625
- if (part.type === "step-start") {
4626
- if (emit("step_start", { part })) continue;
4627
- }
4628
- if (part.type === "step-finish") {
4629
- if (emit("step_finish", { part })) continue;
4630
- }
4631
- if (part.type === "text" && part.time?.end) {
4632
- if (emit("text", { part })) continue;
4633
- const text = part.text.trim();
4634
- if (!text) continue;
4635
- if (!process.stdout.isTTY) {
4636
- process.stdout.write(text + EOL2);
4637
- continue;
4638
- }
4639
- UI.empty();
4640
- UI.println(text);
4641
- UI.empty();
4642
- }
4643
- if (part.type === "reasoning" && part.time?.end && args.thinking) {
4644
- if (emit("reasoning", { part })) continue;
4645
- const text = part.text.trim();
4646
- if (!text) continue;
4647
- const line = `Thinking: ${text}`;
4648
- if (process.stdout.isTTY) {
4649
- UI.empty();
4650
- UI.println(`${UI.Style.TEXT_DIM}\x1B[3m${line}\x1B[0m${UI.Style.TEXT_NORMAL}`);
4651
- UI.empty();
4652
- continue;
4653
- }
4654
- process.stdout.write(line + EOL2);
4655
- }
4656
- }
4657
- if (event.type === "session.error") {
4658
- const props2 = event.properties;
4659
- if (props2.sessionID !== sessionID || !props2.error) continue;
4660
- let err = String(props2.error.name);
4661
- if ("data" in props2.error && props2.error.data && "message" in props2.error.data) {
4662
- err = String(props2.error.data.message);
4663
- }
4664
- error = error ? error + EOL2 + err : err;
4665
- if (emit("error", { error: props2.error })) continue;
4666
- UI.error(err);
4667
- }
4668
- if (event.type === "session.status" && event.properties.sessionID === sessionID && event.properties.status.type === "idle") {
4669
- break;
4670
- }
4671
- if (event.type === "permission.asked") {
4672
- const permission = event.properties;
4673
- if (permission.sessionID !== sessionID) continue;
4674
- if (args["dangerously-skip-permissions"]) {
4675
- await sdk.permission.reply({
4676
- requestID: permission.id,
4677
- reply: "once"
4678
- });
4679
- } else {
4680
- UI.println(
4681
- UI.Style.TEXT_WARNING_BOLD + "!",
4682
- UI.Style.TEXT_NORMAL + `permission requested: ${permission.permission} (${permission.patterns.join(", ")}); auto-rejecting`
4683
- );
4684
- await sdk.permission.reply({
4685
- requestID: permission.id,
4686
- reply: "reject"
4687
- });
4688
- }
4689
- }
4690
- }
4691
- }
4692
- const agent = await (async () => {
4693
- if (!args.agent) return void 0;
4694
- if (args.attach) {
4695
- const modes = await sdk.app.agents(void 0, { throwOnError: true }).then((x) => x.data ?? []).catch(() => void 0);
4696
- if (!modes) {
4697
- UI.println(
4698
- UI.Style.TEXT_WARNING_BOLD + "!",
4699
- UI.Style.TEXT_NORMAL,
4700
- `failed to list agents from ${args.attach}. Falling back to default agent`
4701
- );
4702
- return void 0;
4703
- }
4704
- const agent2 = modes.find((a) => a.name === args.agent);
4705
- if (!agent2) {
4706
- UI.println(
4707
- UI.Style.TEXT_WARNING_BOLD + "!",
4708
- UI.Style.TEXT_NORMAL,
4709
- `agent "${args.agent}" not found. Falling back to default agent`
4710
- );
4711
- return void 0;
4712
- }
4713
- if (agent2.mode === "subagent") {
4714
- UI.println(
4715
- UI.Style.TEXT_WARNING_BOLD + "!",
4716
- UI.Style.TEXT_NORMAL,
4717
- `agent "${args.agent}" is a subagent, not a primary agent. Falling back to default agent`
4718
- );
4719
- return void 0;
4720
- }
4721
- return args.agent;
4722
- }
4723
- const entry = await Agent.get(args.agent);
4724
- if (!entry) {
4725
- UI.println(
4726
- UI.Style.TEXT_WARNING_BOLD + "!",
4727
- UI.Style.TEXT_NORMAL,
4728
- `agent "${args.agent}" not found. Falling back to default agent`
4729
- );
4730
- return void 0;
4731
- }
4732
- if (entry.mode === "subagent") {
4733
- UI.println(
4734
- UI.Style.TEXT_WARNING_BOLD + "!",
4735
- UI.Style.TEXT_NORMAL,
4736
- `agent "${args.agent}" is a subagent, not a primary agent. Falling back to default agent`
4737
- );
4738
- return void 0;
4739
- }
4740
- return args.agent;
4741
- })();
4742
- const sessionID = await session(sdk);
4743
- if (!sessionID) {
4744
- UI.error("Session not found");
4745
- process.exit(1);
4746
- }
4747
- await share(sdk, sessionID);
4748
- loop().catch((e) => {
4749
- console.error(e);
4750
- process.exit(1);
4751
- });
4752
- if (args.command) {
4753
- await sdk.session.command({
4754
- sessionID,
4755
- agent,
4756
- model: args.model,
4757
- command: args.command,
4758
- arguments: message,
4759
- variant: args.variant
4760
- });
4761
- } else {
4762
- const model = args.model ? Provider.parseModel(args.model) : void 0;
4763
- await sdk.session.prompt({
4764
- sessionID,
4765
- agent,
4766
- model,
4767
- variant: args.variant,
4768
- parts: [...files, { type: "text", text: message }]
4769
- });
4770
- }
4771
- }
4772
- if (args.attach) {
4773
- const headers = (() => {
4774
- const password = args.password ?? process.env.OPENCODE_SERVER_PASSWORD;
4775
- if (!password) return void 0;
4776
- const username = process.env.OPENCODE_SERVER_USERNAME ?? "opencode";
4777
- const auth = `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`;
4778
- return { Authorization: auth };
4779
- })();
4780
- const sdk = createOpencodeClient({ baseUrl: args.attach, directory, headers });
4781
- return await execute(sdk);
4782
- }
4783
- await bootstrap(process.cwd(), async () => {
4784
- const fetchFn = (async (input, init) => {
4785
- const request = new Request(input, init);
4786
- return Server.Default().fetch(request);
4787
- });
4788
- const sdk = createOpencodeClient({ baseUrl: "http://opencode.internal", fetch: fetchFn });
4789
- await execute(sdk);
4790
- });
4791
- }
4792
- });
4793
- export {
4794
- RunCommand
4795
- };
4796
- //# sourceMappingURL=run-PMUMTYTZ.js.map