alchemylab-opencode 1.0.1 → 1.0.4

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