alchemylab-opencode 1.0.3 → 1.0.5

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