@hueyexe/opencode-ensemble 0.5.1 → 0.6.1

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.
package/dist/index.js CHANGED
@@ -12334,8 +12334,2960 @@ function tool(input) {
12334
12334
  return input;
12335
12335
  }
12336
12336
  tool.schema = exports_external;
12337
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js
12338
+ var createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url: url2, ...options }) => {
12339
+ let lastEventId;
12340
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
12341
+ const createStream = async function* () {
12342
+ let retryDelay = sseDefaultRetryDelay ?? 3000;
12343
+ let attempt = 0;
12344
+ const signal = options.signal ?? new AbortController().signal;
12345
+ while (true) {
12346
+ if (signal.aborted)
12347
+ break;
12348
+ attempt++;
12349
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
12350
+ if (lastEventId !== undefined) {
12351
+ headers.set("Last-Event-ID", lastEventId);
12352
+ }
12353
+ try {
12354
+ const requestInit = {
12355
+ redirect: "follow",
12356
+ ...options,
12357
+ body: options.serializedBody,
12358
+ headers,
12359
+ signal
12360
+ };
12361
+ let request = new Request(url2, requestInit);
12362
+ if (onRequest) {
12363
+ request = await onRequest(url2, requestInit);
12364
+ }
12365
+ const _fetch = options.fetch ?? globalThis.fetch;
12366
+ const response = await _fetch(request);
12367
+ if (!response.ok)
12368
+ throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
12369
+ if (!response.body)
12370
+ throw new Error("No body in SSE response");
12371
+ const reader = response.body.pipeThrough(new TextDecoderStream).getReader();
12372
+ let buffer = "";
12373
+ const abortHandler = () => {
12374
+ try {
12375
+ reader.cancel();
12376
+ } catch {}
12377
+ };
12378
+ signal.addEventListener("abort", abortHandler);
12379
+ try {
12380
+ while (true) {
12381
+ const { done, value } = await reader.read();
12382
+ if (done)
12383
+ break;
12384
+ buffer += value;
12385
+ buffer = buffer.replace(/\r\n/g, `
12386
+ `).replace(/\r/g, `
12387
+ `);
12388
+ const chunks = buffer.split(`
12389
+
12390
+ `);
12391
+ buffer = chunks.pop() ?? "";
12392
+ for (const chunk of chunks) {
12393
+ const lines = chunk.split(`
12394
+ `);
12395
+ const dataLines = [];
12396
+ let eventName;
12397
+ for (const line of lines) {
12398
+ if (line.startsWith("data:")) {
12399
+ dataLines.push(line.replace(/^data:\s*/, ""));
12400
+ } else if (line.startsWith("event:")) {
12401
+ eventName = line.replace(/^event:\s*/, "");
12402
+ } else if (line.startsWith("id:")) {
12403
+ lastEventId = line.replace(/^id:\s*/, "");
12404
+ } else if (line.startsWith("retry:")) {
12405
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
12406
+ if (!Number.isNaN(parsed)) {
12407
+ retryDelay = parsed;
12408
+ }
12409
+ }
12410
+ }
12411
+ let data;
12412
+ let parsedJson = false;
12413
+ if (dataLines.length) {
12414
+ const rawData = dataLines.join(`
12415
+ `);
12416
+ try {
12417
+ data = JSON.parse(rawData);
12418
+ parsedJson = true;
12419
+ } catch {
12420
+ data = rawData;
12421
+ }
12422
+ }
12423
+ if (parsedJson) {
12424
+ if (responseValidator) {
12425
+ await responseValidator(data);
12426
+ }
12427
+ if (responseTransformer) {
12428
+ data = await responseTransformer(data);
12429
+ }
12430
+ }
12431
+ onSseEvent?.({
12432
+ data,
12433
+ event: eventName,
12434
+ id: lastEventId,
12435
+ retry: retryDelay
12436
+ });
12437
+ if (dataLines.length) {
12438
+ yield data;
12439
+ }
12440
+ }
12441
+ }
12442
+ } finally {
12443
+ signal.removeEventListener("abort", abortHandler);
12444
+ reader.releaseLock();
12445
+ }
12446
+ break;
12447
+ } catch (error45) {
12448
+ onSseError?.(error45);
12449
+ if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
12450
+ break;
12451
+ }
12452
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
12453
+ await sleep(backoff);
12454
+ }
12455
+ }
12456
+ };
12457
+ const stream = createStream();
12458
+ return { stream };
12459
+ };
12460
+
12461
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/pathSerializer.gen.js
12462
+ var separatorArrayExplode = (style) => {
12463
+ switch (style) {
12464
+ case "label":
12465
+ return ".";
12466
+ case "matrix":
12467
+ return ";";
12468
+ case "simple":
12469
+ return ",";
12470
+ default:
12471
+ return "&";
12472
+ }
12473
+ };
12474
+ var separatorArrayNoExplode = (style) => {
12475
+ switch (style) {
12476
+ case "form":
12477
+ return ",";
12478
+ case "pipeDelimited":
12479
+ return "|";
12480
+ case "spaceDelimited":
12481
+ return "%20";
12482
+ default:
12483
+ return ",";
12484
+ }
12485
+ };
12486
+ var separatorObjectExplode = (style) => {
12487
+ switch (style) {
12488
+ case "label":
12489
+ return ".";
12490
+ case "matrix":
12491
+ return ";";
12492
+ case "simple":
12493
+ return ",";
12494
+ default:
12495
+ return "&";
12496
+ }
12497
+ };
12498
+ var serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
12499
+ if (!explode) {
12500
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
12501
+ switch (style) {
12502
+ case "label":
12503
+ return `.${joinedValues2}`;
12504
+ case "matrix":
12505
+ return `;${name}=${joinedValues2}`;
12506
+ case "simple":
12507
+ return joinedValues2;
12508
+ default:
12509
+ return `${name}=${joinedValues2}`;
12510
+ }
12511
+ }
12512
+ const separator = separatorArrayExplode(style);
12513
+ const joinedValues = value.map((v) => {
12514
+ if (style === "label" || style === "simple") {
12515
+ return allowReserved ? v : encodeURIComponent(v);
12516
+ }
12517
+ return serializePrimitiveParam({
12518
+ allowReserved,
12519
+ name,
12520
+ value: v
12521
+ });
12522
+ }).join(separator);
12523
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
12524
+ };
12525
+ var serializePrimitiveParam = ({ allowReserved, name, value }) => {
12526
+ if (value === undefined || value === null) {
12527
+ return "";
12528
+ }
12529
+ if (typeof value === "object") {
12530
+ throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");
12531
+ }
12532
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
12533
+ };
12534
+ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
12535
+ if (value instanceof Date) {
12536
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
12537
+ }
12538
+ if (style !== "deepObject" && !explode) {
12539
+ let values = [];
12540
+ Object.entries(value).forEach(([key, v]) => {
12541
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
12542
+ });
12543
+ const joinedValues2 = values.join(",");
12544
+ switch (style) {
12545
+ case "form":
12546
+ return `${name}=${joinedValues2}`;
12547
+ case "label":
12548
+ return `.${joinedValues2}`;
12549
+ case "matrix":
12550
+ return `;${name}=${joinedValues2}`;
12551
+ default:
12552
+ return joinedValues2;
12553
+ }
12554
+ }
12555
+ const separator = separatorObjectExplode(style);
12556
+ const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
12557
+ allowReserved,
12558
+ name: style === "deepObject" ? `${name}[${key}]` : key,
12559
+ value: v
12560
+ })).join(separator);
12561
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
12562
+ };
12563
+
12564
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/utils.gen.js
12565
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
12566
+ var defaultPathSerializer = ({ path, url: _url2 }) => {
12567
+ let url2 = _url2;
12568
+ const matches = _url2.match(PATH_PARAM_RE);
12569
+ if (matches) {
12570
+ for (const match of matches) {
12571
+ let explode = false;
12572
+ let name = match.substring(1, match.length - 1);
12573
+ let style = "simple";
12574
+ if (name.endsWith("*")) {
12575
+ explode = true;
12576
+ name = name.substring(0, name.length - 1);
12577
+ }
12578
+ if (name.startsWith(".")) {
12579
+ name = name.substring(1);
12580
+ style = "label";
12581
+ } else if (name.startsWith(";")) {
12582
+ name = name.substring(1);
12583
+ style = "matrix";
12584
+ }
12585
+ const value = path[name];
12586
+ if (value === undefined || value === null) {
12587
+ continue;
12588
+ }
12589
+ if (Array.isArray(value)) {
12590
+ url2 = url2.replace(match, serializeArrayParam({ explode, name, style, value }));
12591
+ continue;
12592
+ }
12593
+ if (typeof value === "object") {
12594
+ url2 = url2.replace(match, serializeObjectParam({
12595
+ explode,
12596
+ name,
12597
+ style,
12598
+ value,
12599
+ valueOnly: true
12600
+ }));
12601
+ continue;
12602
+ }
12603
+ if (style === "matrix") {
12604
+ url2 = url2.replace(match, `;${serializePrimitiveParam({
12605
+ name,
12606
+ value
12607
+ })}`);
12608
+ continue;
12609
+ }
12610
+ const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
12611
+ url2 = url2.replace(match, replaceValue);
12612
+ }
12613
+ }
12614
+ return url2;
12615
+ };
12616
+ var getUrl = ({ baseUrl, path, query, querySerializer, url: _url2 }) => {
12617
+ const pathUrl = _url2.startsWith("/") ? _url2 : `/${_url2}`;
12618
+ let url2 = (baseUrl ?? "") + pathUrl;
12619
+ if (path) {
12620
+ url2 = defaultPathSerializer({ path, url: url2 });
12621
+ }
12622
+ let search = query ? querySerializer(query) : "";
12623
+ if (search.startsWith("?")) {
12624
+ search = search.substring(1);
12625
+ }
12626
+ if (search) {
12627
+ url2 += `?${search}`;
12628
+ }
12629
+ return url2;
12630
+ };
12631
+ function getValidRequestBody(options) {
12632
+ const hasBody = options.body !== undefined;
12633
+ const isSerializedBody = hasBody && options.bodySerializer;
12634
+ if (isSerializedBody) {
12635
+ if ("serializedBody" in options) {
12636
+ const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== "";
12637
+ return hasSerializedBody ? options.serializedBody : null;
12638
+ }
12639
+ return options.body !== "" ? options.body : null;
12640
+ }
12641
+ if (hasBody) {
12642
+ return options.body;
12643
+ }
12644
+ return;
12645
+ }
12646
+
12647
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/auth.gen.js
12648
+ var getAuthToken = async (auth, callback) => {
12649
+ const token = typeof callback === "function" ? await callback(auth) : callback;
12650
+ if (!token) {
12651
+ return;
12652
+ }
12653
+ if (auth.scheme === "bearer") {
12654
+ return `Bearer ${token}`;
12655
+ }
12656
+ if (auth.scheme === "basic") {
12657
+ return `Basic ${btoa(token)}`;
12658
+ }
12659
+ return token;
12660
+ };
12661
+
12662
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/bodySerializer.gen.js
12663
+ var jsonBodySerializer = {
12664
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
12665
+ };
12666
+
12667
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/client/utils.gen.js
12668
+ var createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
12669
+ const querySerializer = (queryParams) => {
12670
+ const search = [];
12671
+ if (queryParams && typeof queryParams === "object") {
12672
+ for (const name in queryParams) {
12673
+ const value = queryParams[name];
12674
+ if (value === undefined || value === null) {
12675
+ continue;
12676
+ }
12677
+ const options = parameters[name] || args;
12678
+ if (Array.isArray(value)) {
12679
+ const serializedArray = serializeArrayParam({
12680
+ allowReserved: options.allowReserved,
12681
+ explode: true,
12682
+ name,
12683
+ style: "form",
12684
+ value,
12685
+ ...options.array
12686
+ });
12687
+ if (serializedArray)
12688
+ search.push(serializedArray);
12689
+ } else if (typeof value === "object") {
12690
+ const serializedObject = serializeObjectParam({
12691
+ allowReserved: options.allowReserved,
12692
+ explode: true,
12693
+ name,
12694
+ style: "deepObject",
12695
+ value,
12696
+ ...options.object
12697
+ });
12698
+ if (serializedObject)
12699
+ search.push(serializedObject);
12700
+ } else {
12701
+ const serializedPrimitive = serializePrimitiveParam({
12702
+ allowReserved: options.allowReserved,
12703
+ name,
12704
+ value
12705
+ });
12706
+ if (serializedPrimitive)
12707
+ search.push(serializedPrimitive);
12708
+ }
12709
+ }
12710
+ }
12711
+ return search.join("&");
12712
+ };
12713
+ return querySerializer;
12714
+ };
12715
+ var getParseAs = (contentType) => {
12716
+ if (!contentType) {
12717
+ return "stream";
12718
+ }
12719
+ const cleanContent = contentType.split(";")[0]?.trim();
12720
+ if (!cleanContent) {
12721
+ return;
12722
+ }
12723
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
12724
+ return "json";
12725
+ }
12726
+ if (cleanContent === "multipart/form-data") {
12727
+ return "formData";
12728
+ }
12729
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
12730
+ return "blob";
12731
+ }
12732
+ if (cleanContent.startsWith("text/")) {
12733
+ return "text";
12734
+ }
12735
+ return;
12736
+ };
12737
+ var checkForExistence = (options, name) => {
12738
+ if (!name) {
12739
+ return false;
12740
+ }
12741
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
12742
+ return true;
12743
+ }
12744
+ return false;
12745
+ };
12746
+ var setAuthParams = async ({ security, ...options }) => {
12747
+ for (const auth of security) {
12748
+ if (checkForExistence(options, auth.name)) {
12749
+ continue;
12750
+ }
12751
+ const token = await getAuthToken(auth, options.auth);
12752
+ if (!token) {
12753
+ continue;
12754
+ }
12755
+ const name = auth.name ?? "Authorization";
12756
+ switch (auth.in) {
12757
+ case "query":
12758
+ if (!options.query) {
12759
+ options.query = {};
12760
+ }
12761
+ options.query[name] = token;
12762
+ break;
12763
+ case "cookie":
12764
+ options.headers.append("Cookie", `${name}=${token}`);
12765
+ break;
12766
+ case "header":
12767
+ default:
12768
+ options.headers.set(name, token);
12769
+ break;
12770
+ }
12771
+ }
12772
+ };
12773
+ var buildUrl = (options) => getUrl({
12774
+ baseUrl: options.baseUrl,
12775
+ path: options.path,
12776
+ query: options.query,
12777
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
12778
+ url: options.url
12779
+ });
12780
+ var mergeConfigs = (a, b) => {
12781
+ const config2 = { ...a, ...b };
12782
+ if (config2.baseUrl?.endsWith("/")) {
12783
+ config2.baseUrl = config2.baseUrl.substring(0, config2.baseUrl.length - 1);
12784
+ }
12785
+ config2.headers = mergeHeaders(a.headers, b.headers);
12786
+ return config2;
12787
+ };
12788
+ var headersEntries = (headers) => {
12789
+ const entries = [];
12790
+ headers.forEach((value, key) => {
12791
+ entries.push([key, value]);
12792
+ });
12793
+ return entries;
12794
+ };
12795
+ var mergeHeaders = (...headers) => {
12796
+ const mergedHeaders = new Headers;
12797
+ for (const header of headers) {
12798
+ if (!header) {
12799
+ continue;
12800
+ }
12801
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
12802
+ for (const [key, value] of iterator) {
12803
+ if (value === null) {
12804
+ mergedHeaders.delete(key);
12805
+ } else if (Array.isArray(value)) {
12806
+ for (const v of value) {
12807
+ mergedHeaders.append(key, v);
12808
+ }
12809
+ } else if (value !== undefined) {
12810
+ mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
12811
+ }
12812
+ }
12813
+ }
12814
+ return mergedHeaders;
12815
+ };
12816
+
12817
+ class Interceptors {
12818
+ fns = [];
12819
+ clear() {
12820
+ this.fns = [];
12821
+ }
12822
+ eject(id) {
12823
+ const index = this.getInterceptorIndex(id);
12824
+ if (this.fns[index]) {
12825
+ this.fns[index] = null;
12826
+ }
12827
+ }
12828
+ exists(id) {
12829
+ const index = this.getInterceptorIndex(id);
12830
+ return Boolean(this.fns[index]);
12831
+ }
12832
+ getInterceptorIndex(id) {
12833
+ if (typeof id === "number") {
12834
+ return this.fns[id] ? id : -1;
12835
+ }
12836
+ return this.fns.indexOf(id);
12837
+ }
12838
+ update(id, fn) {
12839
+ const index = this.getInterceptorIndex(id);
12840
+ if (this.fns[index]) {
12841
+ this.fns[index] = fn;
12842
+ return id;
12843
+ }
12844
+ return false;
12845
+ }
12846
+ use(fn) {
12847
+ this.fns.push(fn);
12848
+ return this.fns.length - 1;
12849
+ }
12850
+ }
12851
+ var createInterceptors = () => ({
12852
+ error: new Interceptors,
12853
+ request: new Interceptors,
12854
+ response: new Interceptors
12855
+ });
12856
+ var defaultQuerySerializer = createQuerySerializer({
12857
+ allowReserved: false,
12858
+ array: {
12859
+ explode: true,
12860
+ style: "form"
12861
+ },
12862
+ object: {
12863
+ explode: true,
12864
+ style: "deepObject"
12865
+ }
12866
+ });
12867
+ var defaultHeaders = {
12868
+ "Content-Type": "application/json"
12869
+ };
12870
+ var createConfig = (override = {}) => ({
12871
+ ...jsonBodySerializer,
12872
+ headers: defaultHeaders,
12873
+ parseAs: "auto",
12874
+ querySerializer: defaultQuerySerializer,
12875
+ ...override
12876
+ });
12877
+
12878
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/client/client.gen.js
12879
+ var createClient = (config2 = {}) => {
12880
+ let _config = mergeConfigs(createConfig(), config2);
12881
+ const getConfig = () => ({ ..._config });
12882
+ const setConfig = (config3) => {
12883
+ _config = mergeConfigs(_config, config3);
12884
+ return getConfig();
12885
+ };
12886
+ const interceptors = createInterceptors();
12887
+ const beforeRequest = async (options) => {
12888
+ const opts = {
12889
+ ..._config,
12890
+ ...options,
12891
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
12892
+ headers: mergeHeaders(_config.headers, options.headers),
12893
+ serializedBody: undefined
12894
+ };
12895
+ if (opts.security) {
12896
+ await setAuthParams({
12897
+ ...opts,
12898
+ security: opts.security
12899
+ });
12900
+ }
12901
+ if (opts.requestValidator) {
12902
+ await opts.requestValidator(opts);
12903
+ }
12904
+ if (opts.body !== undefined && opts.bodySerializer) {
12905
+ opts.serializedBody = opts.bodySerializer(opts.body);
12906
+ }
12907
+ if (opts.body === undefined || opts.serializedBody === "") {
12908
+ opts.headers.delete("Content-Type");
12909
+ }
12910
+ const url2 = buildUrl(opts);
12911
+ return { opts, url: url2 };
12912
+ };
12913
+ const request = async (options) => {
12914
+ const { opts, url: url2 } = await beforeRequest(options);
12915
+ const requestInit = {
12916
+ redirect: "follow",
12917
+ ...opts,
12918
+ body: getValidRequestBody(opts)
12919
+ };
12920
+ let request2 = new Request(url2, requestInit);
12921
+ for (const fn of interceptors.request.fns) {
12922
+ if (fn) {
12923
+ request2 = await fn(request2, opts);
12924
+ }
12925
+ }
12926
+ const _fetch = opts.fetch;
12927
+ let response;
12928
+ try {
12929
+ response = await _fetch(request2);
12930
+ } catch (error46) {
12931
+ let finalError2 = error46;
12932
+ for (const fn of interceptors.error.fns) {
12933
+ if (fn) {
12934
+ finalError2 = await fn(error46, undefined, request2, opts);
12935
+ }
12936
+ }
12937
+ finalError2 = finalError2 || {};
12938
+ if (opts.throwOnError) {
12939
+ throw finalError2;
12940
+ }
12941
+ return opts.responseStyle === "data" ? undefined : {
12942
+ error: finalError2,
12943
+ request: request2,
12944
+ response: undefined
12945
+ };
12946
+ }
12947
+ for (const fn of interceptors.response.fns) {
12948
+ if (fn) {
12949
+ response = await fn(response, request2, opts);
12950
+ }
12951
+ }
12952
+ const result = {
12953
+ request: request2,
12954
+ response
12955
+ };
12956
+ if (response.ok) {
12957
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
12958
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
12959
+ let emptyData;
12960
+ switch (parseAs) {
12961
+ case "arrayBuffer":
12962
+ case "blob":
12963
+ case "text":
12964
+ emptyData = await response[parseAs]();
12965
+ break;
12966
+ case "formData":
12967
+ emptyData = new FormData;
12968
+ break;
12969
+ case "stream":
12970
+ emptyData = response.body;
12971
+ break;
12972
+ case "json":
12973
+ default:
12974
+ emptyData = {};
12975
+ break;
12976
+ }
12977
+ return opts.responseStyle === "data" ? emptyData : {
12978
+ data: emptyData,
12979
+ ...result
12980
+ };
12981
+ }
12982
+ let data;
12983
+ switch (parseAs) {
12984
+ case "arrayBuffer":
12985
+ case "blob":
12986
+ case "formData":
12987
+ case "text":
12988
+ data = await response[parseAs]();
12989
+ break;
12990
+ case "json": {
12991
+ const text = await response.text();
12992
+ data = text ? JSON.parse(text) : {};
12993
+ break;
12994
+ }
12995
+ case "stream":
12996
+ return opts.responseStyle === "data" ? response.body : {
12997
+ data: response.body,
12998
+ ...result
12999
+ };
13000
+ }
13001
+ if (parseAs === "json") {
13002
+ if (opts.responseValidator) {
13003
+ await opts.responseValidator(data);
13004
+ }
13005
+ if (opts.responseTransformer) {
13006
+ data = await opts.responseTransformer(data);
13007
+ }
13008
+ }
13009
+ return opts.responseStyle === "data" ? data : {
13010
+ data,
13011
+ ...result
13012
+ };
13013
+ }
13014
+ const textError = await response.text();
13015
+ let jsonError;
13016
+ try {
13017
+ jsonError = JSON.parse(textError);
13018
+ } catch {}
13019
+ const error45 = jsonError ?? textError;
13020
+ let finalError = error45;
13021
+ for (const fn of interceptors.error.fns) {
13022
+ if (fn) {
13023
+ finalError = await fn(error45, response, request2, opts);
13024
+ }
13025
+ }
13026
+ finalError = finalError || {};
13027
+ if (opts.throwOnError) {
13028
+ throw finalError;
13029
+ }
13030
+ return opts.responseStyle === "data" ? undefined : {
13031
+ error: finalError,
13032
+ ...result
13033
+ };
13034
+ };
13035
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
13036
+ const makeSseFn = (method) => async (options) => {
13037
+ const { opts, url: url2 } = await beforeRequest(options);
13038
+ return createSseClient({
13039
+ ...opts,
13040
+ body: opts.body,
13041
+ headers: opts.headers,
13042
+ method,
13043
+ onRequest: async (url3, init) => {
13044
+ let request2 = new Request(url3, init);
13045
+ for (const fn of interceptors.request.fns) {
13046
+ if (fn) {
13047
+ request2 = await fn(request2, opts);
13048
+ }
13049
+ }
13050
+ return request2;
13051
+ },
13052
+ serializedBody: getValidRequestBody(opts),
13053
+ url: url2
13054
+ });
13055
+ };
13056
+ return {
13057
+ buildUrl,
13058
+ connect: makeMethodFn("CONNECT"),
13059
+ delete: makeMethodFn("DELETE"),
13060
+ get: makeMethodFn("GET"),
13061
+ getConfig,
13062
+ head: makeMethodFn("HEAD"),
13063
+ interceptors,
13064
+ options: makeMethodFn("OPTIONS"),
13065
+ patch: makeMethodFn("PATCH"),
13066
+ post: makeMethodFn("POST"),
13067
+ put: makeMethodFn("PUT"),
13068
+ request,
13069
+ setConfig,
13070
+ sse: {
13071
+ connect: makeSseFn("CONNECT"),
13072
+ delete: makeSseFn("DELETE"),
13073
+ get: makeSseFn("GET"),
13074
+ head: makeSseFn("HEAD"),
13075
+ options: makeSseFn("OPTIONS"),
13076
+ patch: makeSseFn("PATCH"),
13077
+ post: makeSseFn("POST"),
13078
+ put: makeSseFn("PUT"),
13079
+ trace: makeSseFn("TRACE")
13080
+ },
13081
+ trace: makeMethodFn("TRACE")
13082
+ };
13083
+ };
13084
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/core/params.gen.js
13085
+ var extraPrefixesMap = {
13086
+ $body_: "body",
13087
+ $headers_: "headers",
13088
+ $path_: "path",
13089
+ $query_: "query"
13090
+ };
13091
+ var extraPrefixes = Object.entries(extraPrefixesMap);
13092
+ var buildKeyMap = (fields, map2) => {
13093
+ if (!map2) {
13094
+ map2 = new Map;
13095
+ }
13096
+ for (const config2 of fields) {
13097
+ if ("in" in config2) {
13098
+ if (config2.key) {
13099
+ map2.set(config2.key, {
13100
+ in: config2.in,
13101
+ map: config2.map
13102
+ });
13103
+ }
13104
+ } else if ("key" in config2) {
13105
+ map2.set(config2.key, {
13106
+ map: config2.map
13107
+ });
13108
+ } else if (config2.args) {
13109
+ buildKeyMap(config2.args, map2);
13110
+ }
13111
+ }
13112
+ return map2;
13113
+ };
13114
+ var stripEmptySlots = (params) => {
13115
+ for (const [slot, value] of Object.entries(params)) {
13116
+ if (value && typeof value === "object" && !Object.keys(value).length) {
13117
+ delete params[slot];
13118
+ }
13119
+ }
13120
+ };
13121
+ var buildClientParams = (args, fields) => {
13122
+ const params = {
13123
+ body: {},
13124
+ headers: {},
13125
+ path: {},
13126
+ query: {}
13127
+ };
13128
+ const map2 = buildKeyMap(fields);
13129
+ let config2;
13130
+ for (const [index, arg] of args.entries()) {
13131
+ if (fields[index]) {
13132
+ config2 = fields[index];
13133
+ }
13134
+ if (!config2) {
13135
+ continue;
13136
+ }
13137
+ if ("in" in config2) {
13138
+ if (config2.key) {
13139
+ const field = map2.get(config2.key);
13140
+ const name = field.map || config2.key;
13141
+ if (field.in) {
13142
+ params[field.in][name] = arg;
13143
+ }
13144
+ } else {
13145
+ params.body = arg;
13146
+ }
13147
+ } else {
13148
+ for (const [key, value] of Object.entries(arg ?? {})) {
13149
+ const field = map2.get(key);
13150
+ if (field) {
13151
+ if (field.in) {
13152
+ const name = field.map || key;
13153
+ params[field.in][name] = value;
13154
+ } else {
13155
+ params[field.map] = value;
13156
+ }
13157
+ } else {
13158
+ const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
13159
+ if (extra) {
13160
+ const [prefix, slot] = extra;
13161
+ params[slot][key.slice(prefix.length)] = value;
13162
+ } else if ("allowExtra" in config2 && config2.allowExtra) {
13163
+ for (const [slot, allowed] of Object.entries(config2.allowExtra)) {
13164
+ if (allowed) {
13165
+ params[slot][key] = value;
13166
+ break;
13167
+ }
13168
+ }
13169
+ }
13170
+ }
13171
+ }
13172
+ }
13173
+ }
13174
+ stripEmptySlots(params);
13175
+ return params;
13176
+ };
13177
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/client.gen.js
13178
+ var client = createClient(createConfig({ baseUrl: "http://localhost:4096" }));
13179
+
13180
+ // node_modules/@opencode-ai/sdk/dist/v2/gen/sdk.gen.js
13181
+ class HeyApiClient {
13182
+ client;
13183
+ constructor(args) {
13184
+ this.client = args?.client ?? client;
13185
+ }
13186
+ }
13187
+
13188
+ class HeyApiRegistry {
13189
+ defaultKey = "default";
13190
+ instances = new Map;
13191
+ get(key) {
13192
+ const instance = this.instances.get(key ?? this.defaultKey);
13193
+ if (!instance) {
13194
+ throw new Error(`No SDK client found. Create one with "new OpencodeClient()" to fix this error.`);
13195
+ }
13196
+ return instance;
13197
+ }
13198
+ set(value, key) {
13199
+ this.instances.set(key ?? this.defaultKey, value);
13200
+ }
13201
+ }
13202
+
13203
+ class Config extends HeyApiClient {
13204
+ get(options) {
13205
+ return (options?.client ?? this.client).get({
13206
+ url: "/global/config",
13207
+ ...options
13208
+ });
13209
+ }
13210
+ update(parameters, options) {
13211
+ const params = buildClientParams([parameters], [{ args: [{ key: "config", map: "body" }] }]);
13212
+ return (options?.client ?? this.client).patch({
13213
+ url: "/global/config",
13214
+ ...options,
13215
+ ...params,
13216
+ headers: {
13217
+ "Content-Type": "application/json",
13218
+ ...options?.headers,
13219
+ ...params.headers
13220
+ }
13221
+ });
13222
+ }
13223
+ }
13224
+
13225
+ class Global extends HeyApiClient {
13226
+ health(options) {
13227
+ return (options?.client ?? this.client).get({
13228
+ url: "/global/health",
13229
+ ...options
13230
+ });
13231
+ }
13232
+ event(options) {
13233
+ return (options?.client ?? this.client).sse.get({
13234
+ url: "/global/event",
13235
+ ...options
13236
+ });
13237
+ }
13238
+ dispose(options) {
13239
+ return (options?.client ?? this.client).post({
13240
+ url: "/global/dispose",
13241
+ ...options
13242
+ });
13243
+ }
13244
+ upgrade(parameters, options) {
13245
+ const params = buildClientParams([parameters], [{ args: [{ in: "body", key: "target" }] }]);
13246
+ return (options?.client ?? this.client).post({
13247
+ url: "/global/upgrade",
13248
+ ...options,
13249
+ ...params,
13250
+ headers: {
13251
+ "Content-Type": "application/json",
13252
+ ...options?.headers,
13253
+ ...params.headers
13254
+ }
13255
+ });
13256
+ }
13257
+ _config;
13258
+ get config() {
13259
+ return this._config ??= new Config({ client: this.client });
13260
+ }
13261
+ }
13262
+
13263
+ class Auth extends HeyApiClient {
13264
+ remove(parameters, options) {
13265
+ const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "providerID" }] }]);
13266
+ return (options?.client ?? this.client).delete({
13267
+ url: "/auth/{providerID}",
13268
+ ...options,
13269
+ ...params
13270
+ });
13271
+ }
13272
+ set(parameters, options) {
13273
+ const params = buildClientParams([parameters], [
13274
+ {
13275
+ args: [
13276
+ { in: "path", key: "providerID" },
13277
+ { key: "auth", map: "body" }
13278
+ ]
13279
+ }
13280
+ ]);
13281
+ return (options?.client ?? this.client).put({
13282
+ url: "/auth/{providerID}",
13283
+ ...options,
13284
+ ...params,
13285
+ headers: {
13286
+ "Content-Type": "application/json",
13287
+ ...options?.headers,
13288
+ ...params.headers
13289
+ }
13290
+ });
13291
+ }
13292
+ }
13293
+
13294
+ class Project extends HeyApiClient {
13295
+ list(parameters, options) {
13296
+ const params = buildClientParams([parameters], [
13297
+ {
13298
+ args: [
13299
+ { in: "query", key: "directory" },
13300
+ { in: "query", key: "workspace" }
13301
+ ]
13302
+ }
13303
+ ]);
13304
+ return (options?.client ?? this.client).get({
13305
+ url: "/project",
13306
+ ...options,
13307
+ ...params
13308
+ });
13309
+ }
13310
+ current(parameters, options) {
13311
+ const params = buildClientParams([parameters], [
13312
+ {
13313
+ args: [
13314
+ { in: "query", key: "directory" },
13315
+ { in: "query", key: "workspace" }
13316
+ ]
13317
+ }
13318
+ ]);
13319
+ return (options?.client ?? this.client).get({
13320
+ url: "/project/current",
13321
+ ...options,
13322
+ ...params
13323
+ });
13324
+ }
13325
+ initGit(parameters, options) {
13326
+ const params = buildClientParams([parameters], [
13327
+ {
13328
+ args: [
13329
+ { in: "query", key: "directory" },
13330
+ { in: "query", key: "workspace" }
13331
+ ]
13332
+ }
13333
+ ]);
13334
+ return (options?.client ?? this.client).post({
13335
+ url: "/project/git/init",
13336
+ ...options,
13337
+ ...params
13338
+ });
13339
+ }
13340
+ update(parameters, options) {
13341
+ const params = buildClientParams([parameters], [
13342
+ {
13343
+ args: [
13344
+ { in: "path", key: "projectID" },
13345
+ { in: "query", key: "directory" },
13346
+ { in: "query", key: "workspace" },
13347
+ { in: "body", key: "name" },
13348
+ { in: "body", key: "icon" },
13349
+ { in: "body", key: "commands" }
13350
+ ]
13351
+ }
13352
+ ]);
13353
+ return (options?.client ?? this.client).patch({
13354
+ url: "/project/{projectID}",
13355
+ ...options,
13356
+ ...params,
13357
+ headers: {
13358
+ "Content-Type": "application/json",
13359
+ ...options?.headers,
13360
+ ...params.headers
13361
+ }
13362
+ });
13363
+ }
13364
+ }
13365
+
13366
+ class Pty extends HeyApiClient {
13367
+ list(parameters, options) {
13368
+ const params = buildClientParams([parameters], [
13369
+ {
13370
+ args: [
13371
+ { in: "query", key: "directory" },
13372
+ { in: "query", key: "workspace" }
13373
+ ]
13374
+ }
13375
+ ]);
13376
+ return (options?.client ?? this.client).get({
13377
+ url: "/pty",
13378
+ ...options,
13379
+ ...params
13380
+ });
13381
+ }
13382
+ create(parameters, options) {
13383
+ const params = buildClientParams([parameters], [
13384
+ {
13385
+ args: [
13386
+ { in: "query", key: "directory" },
13387
+ { in: "query", key: "workspace" },
13388
+ { in: "body", key: "command" },
13389
+ { in: "body", key: "args" },
13390
+ { in: "body", key: "cwd" },
13391
+ { in: "body", key: "title" },
13392
+ { in: "body", key: "env" }
13393
+ ]
13394
+ }
13395
+ ]);
13396
+ return (options?.client ?? this.client).post({
13397
+ url: "/pty",
13398
+ ...options,
13399
+ ...params,
13400
+ headers: {
13401
+ "Content-Type": "application/json",
13402
+ ...options?.headers,
13403
+ ...params.headers
13404
+ }
13405
+ });
13406
+ }
13407
+ remove(parameters, options) {
13408
+ const params = buildClientParams([parameters], [
13409
+ {
13410
+ args: [
13411
+ { in: "path", key: "ptyID" },
13412
+ { in: "query", key: "directory" },
13413
+ { in: "query", key: "workspace" }
13414
+ ]
13415
+ }
13416
+ ]);
13417
+ return (options?.client ?? this.client).delete({
13418
+ url: "/pty/{ptyID}",
13419
+ ...options,
13420
+ ...params
13421
+ });
13422
+ }
13423
+ get(parameters, options) {
13424
+ const params = buildClientParams([parameters], [
13425
+ {
13426
+ args: [
13427
+ { in: "path", key: "ptyID" },
13428
+ { in: "query", key: "directory" },
13429
+ { in: "query", key: "workspace" }
13430
+ ]
13431
+ }
13432
+ ]);
13433
+ return (options?.client ?? this.client).get({
13434
+ url: "/pty/{ptyID}",
13435
+ ...options,
13436
+ ...params
13437
+ });
13438
+ }
13439
+ update(parameters, options) {
13440
+ const params = buildClientParams([parameters], [
13441
+ {
13442
+ args: [
13443
+ { in: "path", key: "ptyID" },
13444
+ { in: "query", key: "directory" },
13445
+ { in: "query", key: "workspace" },
13446
+ { in: "body", key: "title" },
13447
+ { in: "body", key: "size" }
13448
+ ]
13449
+ }
13450
+ ]);
13451
+ return (options?.client ?? this.client).put({
13452
+ url: "/pty/{ptyID}",
13453
+ ...options,
13454
+ ...params,
13455
+ headers: {
13456
+ "Content-Type": "application/json",
13457
+ ...options?.headers,
13458
+ ...params.headers
13459
+ }
13460
+ });
13461
+ }
13462
+ connect(parameters, options) {
13463
+ const params = buildClientParams([parameters], [
13464
+ {
13465
+ args: [
13466
+ { in: "path", key: "ptyID" },
13467
+ { in: "query", key: "directory" },
13468
+ { in: "query", key: "workspace" }
13469
+ ]
13470
+ }
13471
+ ]);
13472
+ return (options?.client ?? this.client).get({
13473
+ url: "/pty/{ptyID}/connect",
13474
+ ...options,
13475
+ ...params
13476
+ });
13477
+ }
13478
+ }
13479
+
13480
+ class Config2 extends HeyApiClient {
13481
+ get(parameters, options) {
13482
+ const params = buildClientParams([parameters], [
13483
+ {
13484
+ args: [
13485
+ { in: "query", key: "directory" },
13486
+ { in: "query", key: "workspace" }
13487
+ ]
13488
+ }
13489
+ ]);
13490
+ return (options?.client ?? this.client).get({
13491
+ url: "/config",
13492
+ ...options,
13493
+ ...params
13494
+ });
13495
+ }
13496
+ update(parameters, options) {
13497
+ const params = buildClientParams([parameters], [
13498
+ {
13499
+ args: [
13500
+ { in: "query", key: "directory" },
13501
+ { in: "query", key: "workspace" },
13502
+ { key: "config", map: "body" }
13503
+ ]
13504
+ }
13505
+ ]);
13506
+ return (options?.client ?? this.client).patch({
13507
+ url: "/config",
13508
+ ...options,
13509
+ ...params,
13510
+ headers: {
13511
+ "Content-Type": "application/json",
13512
+ ...options?.headers,
13513
+ ...params.headers
13514
+ }
13515
+ });
13516
+ }
13517
+ providers(parameters, options) {
13518
+ const params = buildClientParams([parameters], [
13519
+ {
13520
+ args: [
13521
+ { in: "query", key: "directory" },
13522
+ { in: "query", key: "workspace" }
13523
+ ]
13524
+ }
13525
+ ]);
13526
+ return (options?.client ?? this.client).get({
13527
+ url: "/config/providers",
13528
+ ...options,
13529
+ ...params
13530
+ });
13531
+ }
13532
+ }
13533
+
13534
+ class Tool extends HeyApiClient {
13535
+ ids(parameters, options) {
13536
+ const params = buildClientParams([parameters], [
13537
+ {
13538
+ args: [
13539
+ { in: "query", key: "directory" },
13540
+ { in: "query", key: "workspace" }
13541
+ ]
13542
+ }
13543
+ ]);
13544
+ return (options?.client ?? this.client).get({
13545
+ url: "/experimental/tool/ids",
13546
+ ...options,
13547
+ ...params
13548
+ });
13549
+ }
13550
+ list(parameters, options) {
13551
+ const params = buildClientParams([parameters], [
13552
+ {
13553
+ args: [
13554
+ { in: "query", key: "directory" },
13555
+ { in: "query", key: "workspace" },
13556
+ { in: "query", key: "provider" },
13557
+ { in: "query", key: "model" }
13558
+ ]
13559
+ }
13560
+ ]);
13561
+ return (options?.client ?? this.client).get({
13562
+ url: "/experimental/tool",
13563
+ ...options,
13564
+ ...params
13565
+ });
13566
+ }
13567
+ }
13568
+
13569
+ class Workspace extends HeyApiClient {
13570
+ list(parameters, options) {
13571
+ const params = buildClientParams([parameters], [
13572
+ {
13573
+ args: [
13574
+ { in: "query", key: "directory" },
13575
+ { in: "query", key: "workspace" }
13576
+ ]
13577
+ }
13578
+ ]);
13579
+ return (options?.client ?? this.client).get({
13580
+ url: "/experimental/workspace",
13581
+ ...options,
13582
+ ...params
13583
+ });
13584
+ }
13585
+ create(parameters, options) {
13586
+ const params = buildClientParams([parameters], [
13587
+ {
13588
+ args: [
13589
+ { in: "query", key: "directory" },
13590
+ { in: "query", key: "workspace" },
13591
+ { in: "body", key: "id" },
13592
+ { in: "body", key: "type" },
13593
+ { in: "body", key: "branch" },
13594
+ { in: "body", key: "extra" }
13595
+ ]
13596
+ }
13597
+ ]);
13598
+ return (options?.client ?? this.client).post({
13599
+ url: "/experimental/workspace",
13600
+ ...options,
13601
+ ...params,
13602
+ headers: {
13603
+ "Content-Type": "application/json",
13604
+ ...options?.headers,
13605
+ ...params.headers
13606
+ }
13607
+ });
13608
+ }
13609
+ remove(parameters, options) {
13610
+ const params = buildClientParams([parameters], [
13611
+ {
13612
+ args: [
13613
+ { in: "path", key: "id" },
13614
+ { in: "query", key: "directory" },
13615
+ { in: "query", key: "workspace" }
13616
+ ]
13617
+ }
13618
+ ]);
13619
+ return (options?.client ?? this.client).delete({
13620
+ url: "/experimental/workspace/{id}",
13621
+ ...options,
13622
+ ...params
13623
+ });
13624
+ }
13625
+ }
13626
+
13627
+ class Session extends HeyApiClient {
13628
+ list(parameters, options) {
13629
+ const params = buildClientParams([parameters], [
13630
+ {
13631
+ args: [
13632
+ { in: "query", key: "directory" },
13633
+ { in: "query", key: "workspace" },
13634
+ { in: "query", key: "roots" },
13635
+ { in: "query", key: "start" },
13636
+ { in: "query", key: "cursor" },
13637
+ { in: "query", key: "search" },
13638
+ { in: "query", key: "limit" },
13639
+ { in: "query", key: "archived" }
13640
+ ]
13641
+ }
13642
+ ]);
13643
+ return (options?.client ?? this.client).get({
13644
+ url: "/experimental/session",
13645
+ ...options,
13646
+ ...params
13647
+ });
13648
+ }
13649
+ }
13650
+
13651
+ class Resource extends HeyApiClient {
13652
+ list(parameters, options) {
13653
+ const params = buildClientParams([parameters], [
13654
+ {
13655
+ args: [
13656
+ { in: "query", key: "directory" },
13657
+ { in: "query", key: "workspace" }
13658
+ ]
13659
+ }
13660
+ ]);
13661
+ return (options?.client ?? this.client).get({
13662
+ url: "/experimental/resource",
13663
+ ...options,
13664
+ ...params
13665
+ });
13666
+ }
13667
+ }
13668
+
13669
+ class Experimental extends HeyApiClient {
13670
+ _workspace;
13671
+ get workspace() {
13672
+ return this._workspace ??= new Workspace({ client: this.client });
13673
+ }
13674
+ _session;
13675
+ get session() {
13676
+ return this._session ??= new Session({ client: this.client });
13677
+ }
13678
+ _resource;
13679
+ get resource() {
13680
+ return this._resource ??= new Resource({ client: this.client });
13681
+ }
13682
+ }
13683
+
13684
+ class Worktree extends HeyApiClient {
13685
+ remove(parameters, options) {
13686
+ const params = buildClientParams([parameters], [
13687
+ {
13688
+ args: [
13689
+ { in: "query", key: "directory" },
13690
+ { in: "query", key: "workspace" },
13691
+ { key: "worktreeRemoveInput", map: "body" }
13692
+ ]
13693
+ }
13694
+ ]);
13695
+ return (options?.client ?? this.client).delete({
13696
+ url: "/experimental/worktree",
13697
+ ...options,
13698
+ ...params,
13699
+ headers: {
13700
+ "Content-Type": "application/json",
13701
+ ...options?.headers,
13702
+ ...params.headers
13703
+ }
13704
+ });
13705
+ }
13706
+ list(parameters, options) {
13707
+ const params = buildClientParams([parameters], [
13708
+ {
13709
+ args: [
13710
+ { in: "query", key: "directory" },
13711
+ { in: "query", key: "workspace" }
13712
+ ]
13713
+ }
13714
+ ]);
13715
+ return (options?.client ?? this.client).get({
13716
+ url: "/experimental/worktree",
13717
+ ...options,
13718
+ ...params
13719
+ });
13720
+ }
13721
+ create(parameters, options) {
13722
+ const params = buildClientParams([parameters], [
13723
+ {
13724
+ args: [
13725
+ { in: "query", key: "directory" },
13726
+ { in: "query", key: "workspace" },
13727
+ { key: "worktreeCreateInput", map: "body" }
13728
+ ]
13729
+ }
13730
+ ]);
13731
+ return (options?.client ?? this.client).post({
13732
+ url: "/experimental/worktree",
13733
+ ...options,
13734
+ ...params,
13735
+ headers: {
13736
+ "Content-Type": "application/json",
13737
+ ...options?.headers,
13738
+ ...params.headers
13739
+ }
13740
+ });
13741
+ }
13742
+ reset(parameters, options) {
13743
+ const params = buildClientParams([parameters], [
13744
+ {
13745
+ args: [
13746
+ { in: "query", key: "directory" },
13747
+ { in: "query", key: "workspace" },
13748
+ { key: "worktreeResetInput", map: "body" }
13749
+ ]
13750
+ }
13751
+ ]);
13752
+ return (options?.client ?? this.client).post({
13753
+ url: "/experimental/worktree/reset",
13754
+ ...options,
13755
+ ...params,
13756
+ headers: {
13757
+ "Content-Type": "application/json",
13758
+ ...options?.headers,
13759
+ ...params.headers
13760
+ }
13761
+ });
13762
+ }
13763
+ }
13764
+
13765
+ class Session2 extends HeyApiClient {
13766
+ list(parameters, options) {
13767
+ const params = buildClientParams([parameters], [
13768
+ {
13769
+ args: [
13770
+ { in: "query", key: "directory" },
13771
+ { in: "query", key: "workspace" },
13772
+ { in: "query", key: "roots" },
13773
+ { in: "query", key: "start" },
13774
+ { in: "query", key: "search" },
13775
+ { in: "query", key: "limit" }
13776
+ ]
13777
+ }
13778
+ ]);
13779
+ return (options?.client ?? this.client).get({
13780
+ url: "/session",
13781
+ ...options,
13782
+ ...params
13783
+ });
13784
+ }
13785
+ create(parameters, options) {
13786
+ const params = buildClientParams([parameters], [
13787
+ {
13788
+ args: [
13789
+ { in: "query", key: "directory" },
13790
+ { in: "query", key: "workspace" },
13791
+ { in: "body", key: "parentID" },
13792
+ { in: "body", key: "title" },
13793
+ { in: "body", key: "permission" },
13794
+ { in: "body", key: "workspaceID" }
13795
+ ]
13796
+ }
13797
+ ]);
13798
+ return (options?.client ?? this.client).post({
13799
+ url: "/session",
13800
+ ...options,
13801
+ ...params,
13802
+ headers: {
13803
+ "Content-Type": "application/json",
13804
+ ...options?.headers,
13805
+ ...params.headers
13806
+ }
13807
+ });
13808
+ }
13809
+ status(parameters, options) {
13810
+ const params = buildClientParams([parameters], [
13811
+ {
13812
+ args: [
13813
+ { in: "query", key: "directory" },
13814
+ { in: "query", key: "workspace" }
13815
+ ]
13816
+ }
13817
+ ]);
13818
+ return (options?.client ?? this.client).get({
13819
+ url: "/session/status",
13820
+ ...options,
13821
+ ...params
13822
+ });
13823
+ }
13824
+ delete(parameters, options) {
13825
+ const params = buildClientParams([parameters], [
13826
+ {
13827
+ args: [
13828
+ { in: "path", key: "sessionID" },
13829
+ { in: "query", key: "directory" },
13830
+ { in: "query", key: "workspace" }
13831
+ ]
13832
+ }
13833
+ ]);
13834
+ return (options?.client ?? this.client).delete({
13835
+ url: "/session/{sessionID}",
13836
+ ...options,
13837
+ ...params
13838
+ });
13839
+ }
13840
+ get(parameters, options) {
13841
+ const params = buildClientParams([parameters], [
13842
+ {
13843
+ args: [
13844
+ { in: "path", key: "sessionID" },
13845
+ { in: "query", key: "directory" },
13846
+ { in: "query", key: "workspace" }
13847
+ ]
13848
+ }
13849
+ ]);
13850
+ return (options?.client ?? this.client).get({
13851
+ url: "/session/{sessionID}",
13852
+ ...options,
13853
+ ...params
13854
+ });
13855
+ }
13856
+ update(parameters, options) {
13857
+ const params = buildClientParams([parameters], [
13858
+ {
13859
+ args: [
13860
+ { in: "path", key: "sessionID" },
13861
+ { in: "query", key: "directory" },
13862
+ { in: "query", key: "workspace" },
13863
+ { in: "body", key: "title" },
13864
+ { in: "body", key: "time" }
13865
+ ]
13866
+ }
13867
+ ]);
13868
+ return (options?.client ?? this.client).patch({
13869
+ url: "/session/{sessionID}",
13870
+ ...options,
13871
+ ...params,
13872
+ headers: {
13873
+ "Content-Type": "application/json",
13874
+ ...options?.headers,
13875
+ ...params.headers
13876
+ }
13877
+ });
13878
+ }
13879
+ children(parameters, options) {
13880
+ const params = buildClientParams([parameters], [
13881
+ {
13882
+ args: [
13883
+ { in: "path", key: "sessionID" },
13884
+ { in: "query", key: "directory" },
13885
+ { in: "query", key: "workspace" }
13886
+ ]
13887
+ }
13888
+ ]);
13889
+ return (options?.client ?? this.client).get({
13890
+ url: "/session/{sessionID}/children",
13891
+ ...options,
13892
+ ...params
13893
+ });
13894
+ }
13895
+ todo(parameters, options) {
13896
+ const params = buildClientParams([parameters], [
13897
+ {
13898
+ args: [
13899
+ { in: "path", key: "sessionID" },
13900
+ { in: "query", key: "directory" },
13901
+ { in: "query", key: "workspace" }
13902
+ ]
13903
+ }
13904
+ ]);
13905
+ return (options?.client ?? this.client).get({
13906
+ url: "/session/{sessionID}/todo",
13907
+ ...options,
13908
+ ...params
13909
+ });
13910
+ }
13911
+ init(parameters, options) {
13912
+ const params = buildClientParams([parameters], [
13913
+ {
13914
+ args: [
13915
+ { in: "path", key: "sessionID" },
13916
+ { in: "query", key: "directory" },
13917
+ { in: "query", key: "workspace" },
13918
+ { in: "body", key: "modelID" },
13919
+ { in: "body", key: "providerID" },
13920
+ { in: "body", key: "messageID" }
13921
+ ]
13922
+ }
13923
+ ]);
13924
+ return (options?.client ?? this.client).post({
13925
+ url: "/session/{sessionID}/init",
13926
+ ...options,
13927
+ ...params,
13928
+ headers: {
13929
+ "Content-Type": "application/json",
13930
+ ...options?.headers,
13931
+ ...params.headers
13932
+ }
13933
+ });
13934
+ }
13935
+ fork(parameters, options) {
13936
+ const params = buildClientParams([parameters], [
13937
+ {
13938
+ args: [
13939
+ { in: "path", key: "sessionID" },
13940
+ { in: "query", key: "directory" },
13941
+ { in: "query", key: "workspace" },
13942
+ { in: "body", key: "messageID" }
13943
+ ]
13944
+ }
13945
+ ]);
13946
+ return (options?.client ?? this.client).post({
13947
+ url: "/session/{sessionID}/fork",
13948
+ ...options,
13949
+ ...params,
13950
+ headers: {
13951
+ "Content-Type": "application/json",
13952
+ ...options?.headers,
13953
+ ...params.headers
13954
+ }
13955
+ });
13956
+ }
13957
+ abort(parameters, options) {
13958
+ const params = buildClientParams([parameters], [
13959
+ {
13960
+ args: [
13961
+ { in: "path", key: "sessionID" },
13962
+ { in: "query", key: "directory" },
13963
+ { in: "query", key: "workspace" }
13964
+ ]
13965
+ }
13966
+ ]);
13967
+ return (options?.client ?? this.client).post({
13968
+ url: "/session/{sessionID}/abort",
13969
+ ...options,
13970
+ ...params
13971
+ });
13972
+ }
13973
+ unshare(parameters, options) {
13974
+ const params = buildClientParams([parameters], [
13975
+ {
13976
+ args: [
13977
+ { in: "path", key: "sessionID" },
13978
+ { in: "query", key: "directory" },
13979
+ { in: "query", key: "workspace" }
13980
+ ]
13981
+ }
13982
+ ]);
13983
+ return (options?.client ?? this.client).delete({
13984
+ url: "/session/{sessionID}/share",
13985
+ ...options,
13986
+ ...params
13987
+ });
13988
+ }
13989
+ share(parameters, options) {
13990
+ const params = buildClientParams([parameters], [
13991
+ {
13992
+ args: [
13993
+ { in: "path", key: "sessionID" },
13994
+ { in: "query", key: "directory" },
13995
+ { in: "query", key: "workspace" }
13996
+ ]
13997
+ }
13998
+ ]);
13999
+ return (options?.client ?? this.client).post({
14000
+ url: "/session/{sessionID}/share",
14001
+ ...options,
14002
+ ...params
14003
+ });
14004
+ }
14005
+ diff(parameters, options) {
14006
+ const params = buildClientParams([parameters], [
14007
+ {
14008
+ args: [
14009
+ { in: "path", key: "sessionID" },
14010
+ { in: "query", key: "directory" },
14011
+ { in: "query", key: "workspace" },
14012
+ { in: "query", key: "messageID" }
14013
+ ]
14014
+ }
14015
+ ]);
14016
+ return (options?.client ?? this.client).get({
14017
+ url: "/session/{sessionID}/diff",
14018
+ ...options,
14019
+ ...params
14020
+ });
14021
+ }
14022
+ summarize(parameters, options) {
14023
+ const params = buildClientParams([parameters], [
14024
+ {
14025
+ args: [
14026
+ { in: "path", key: "sessionID" },
14027
+ { in: "query", key: "directory" },
14028
+ { in: "query", key: "workspace" },
14029
+ { in: "body", key: "providerID" },
14030
+ { in: "body", key: "modelID" },
14031
+ { in: "body", key: "auto" }
14032
+ ]
14033
+ }
14034
+ ]);
14035
+ return (options?.client ?? this.client).post({
14036
+ url: "/session/{sessionID}/summarize",
14037
+ ...options,
14038
+ ...params,
14039
+ headers: {
14040
+ "Content-Type": "application/json",
14041
+ ...options?.headers,
14042
+ ...params.headers
14043
+ }
14044
+ });
14045
+ }
14046
+ messages(parameters, options) {
14047
+ const params = buildClientParams([parameters], [
14048
+ {
14049
+ args: [
14050
+ { in: "path", key: "sessionID" },
14051
+ { in: "query", key: "directory" },
14052
+ { in: "query", key: "workspace" },
14053
+ { in: "query", key: "limit" },
14054
+ { in: "query", key: "before" }
14055
+ ]
14056
+ }
14057
+ ]);
14058
+ return (options?.client ?? this.client).get({
14059
+ url: "/session/{sessionID}/message",
14060
+ ...options,
14061
+ ...params
14062
+ });
14063
+ }
14064
+ prompt(parameters, options) {
14065
+ const params = buildClientParams([parameters], [
14066
+ {
14067
+ args: [
14068
+ { in: "path", key: "sessionID" },
14069
+ { in: "query", key: "directory" },
14070
+ { in: "query", key: "workspace" },
14071
+ { in: "body", key: "messageID" },
14072
+ { in: "body", key: "model" },
14073
+ { in: "body", key: "agent" },
14074
+ { in: "body", key: "noReply" },
14075
+ { in: "body", key: "tools" },
14076
+ { in: "body", key: "format" },
14077
+ { in: "body", key: "system" },
14078
+ { in: "body", key: "variant" },
14079
+ { in: "body", key: "parts" }
14080
+ ]
14081
+ }
14082
+ ]);
14083
+ return (options?.client ?? this.client).post({
14084
+ url: "/session/{sessionID}/message",
14085
+ ...options,
14086
+ ...params,
14087
+ headers: {
14088
+ "Content-Type": "application/json",
14089
+ ...options?.headers,
14090
+ ...params.headers
14091
+ }
14092
+ });
14093
+ }
14094
+ deleteMessage(parameters, options) {
14095
+ const params = buildClientParams([parameters], [
14096
+ {
14097
+ args: [
14098
+ { in: "path", key: "sessionID" },
14099
+ { in: "path", key: "messageID" },
14100
+ { in: "query", key: "directory" },
14101
+ { in: "query", key: "workspace" }
14102
+ ]
14103
+ }
14104
+ ]);
14105
+ return (options?.client ?? this.client).delete({
14106
+ url: "/session/{sessionID}/message/{messageID}",
14107
+ ...options,
14108
+ ...params
14109
+ });
14110
+ }
14111
+ message(parameters, options) {
14112
+ const params = buildClientParams([parameters], [
14113
+ {
14114
+ args: [
14115
+ { in: "path", key: "sessionID" },
14116
+ { in: "path", key: "messageID" },
14117
+ { in: "query", key: "directory" },
14118
+ { in: "query", key: "workspace" }
14119
+ ]
14120
+ }
14121
+ ]);
14122
+ return (options?.client ?? this.client).get({
14123
+ url: "/session/{sessionID}/message/{messageID}",
14124
+ ...options,
14125
+ ...params
14126
+ });
14127
+ }
14128
+ promptAsync(parameters, options) {
14129
+ const params = buildClientParams([parameters], [
14130
+ {
14131
+ args: [
14132
+ { in: "path", key: "sessionID" },
14133
+ { in: "query", key: "directory" },
14134
+ { in: "query", key: "workspace" },
14135
+ { in: "body", key: "messageID" },
14136
+ { in: "body", key: "model" },
14137
+ { in: "body", key: "agent" },
14138
+ { in: "body", key: "noReply" },
14139
+ { in: "body", key: "tools" },
14140
+ { in: "body", key: "format" },
14141
+ { in: "body", key: "system" },
14142
+ { in: "body", key: "variant" },
14143
+ { in: "body", key: "parts" }
14144
+ ]
14145
+ }
14146
+ ]);
14147
+ return (options?.client ?? this.client).post({
14148
+ url: "/session/{sessionID}/prompt_async",
14149
+ ...options,
14150
+ ...params,
14151
+ headers: {
14152
+ "Content-Type": "application/json",
14153
+ ...options?.headers,
14154
+ ...params.headers
14155
+ }
14156
+ });
14157
+ }
14158
+ command(parameters, options) {
14159
+ const params = buildClientParams([parameters], [
14160
+ {
14161
+ args: [
14162
+ { in: "path", key: "sessionID" },
14163
+ { in: "query", key: "directory" },
14164
+ { in: "query", key: "workspace" },
14165
+ { in: "body", key: "messageID" },
14166
+ { in: "body", key: "agent" },
14167
+ { in: "body", key: "model" },
14168
+ { in: "body", key: "arguments" },
14169
+ { in: "body", key: "command" },
14170
+ { in: "body", key: "variant" },
14171
+ { in: "body", key: "parts" }
14172
+ ]
14173
+ }
14174
+ ]);
14175
+ return (options?.client ?? this.client).post({
14176
+ url: "/session/{sessionID}/command",
14177
+ ...options,
14178
+ ...params,
14179
+ headers: {
14180
+ "Content-Type": "application/json",
14181
+ ...options?.headers,
14182
+ ...params.headers
14183
+ }
14184
+ });
14185
+ }
14186
+ shell(parameters, options) {
14187
+ const params = buildClientParams([parameters], [
14188
+ {
14189
+ args: [
14190
+ { in: "path", key: "sessionID" },
14191
+ { in: "query", key: "directory" },
14192
+ { in: "query", key: "workspace" },
14193
+ { in: "body", key: "agent" },
14194
+ { in: "body", key: "model" },
14195
+ { in: "body", key: "command" }
14196
+ ]
14197
+ }
14198
+ ]);
14199
+ return (options?.client ?? this.client).post({
14200
+ url: "/session/{sessionID}/shell",
14201
+ ...options,
14202
+ ...params,
14203
+ headers: {
14204
+ "Content-Type": "application/json",
14205
+ ...options?.headers,
14206
+ ...params.headers
14207
+ }
14208
+ });
14209
+ }
14210
+ revert(parameters, options) {
14211
+ const params = buildClientParams([parameters], [
14212
+ {
14213
+ args: [
14214
+ { in: "path", key: "sessionID" },
14215
+ { in: "query", key: "directory" },
14216
+ { in: "query", key: "workspace" },
14217
+ { in: "body", key: "messageID" },
14218
+ { in: "body", key: "partID" }
14219
+ ]
14220
+ }
14221
+ ]);
14222
+ return (options?.client ?? this.client).post({
14223
+ url: "/session/{sessionID}/revert",
14224
+ ...options,
14225
+ ...params,
14226
+ headers: {
14227
+ "Content-Type": "application/json",
14228
+ ...options?.headers,
14229
+ ...params.headers
14230
+ }
14231
+ });
14232
+ }
14233
+ unrevert(parameters, options) {
14234
+ const params = buildClientParams([parameters], [
14235
+ {
14236
+ args: [
14237
+ { in: "path", key: "sessionID" },
14238
+ { in: "query", key: "directory" },
14239
+ { in: "query", key: "workspace" }
14240
+ ]
14241
+ }
14242
+ ]);
14243
+ return (options?.client ?? this.client).post({
14244
+ url: "/session/{sessionID}/unrevert",
14245
+ ...options,
14246
+ ...params
14247
+ });
14248
+ }
14249
+ }
14250
+
14251
+ class Part extends HeyApiClient {
14252
+ delete(parameters, options) {
14253
+ const params = buildClientParams([parameters], [
14254
+ {
14255
+ args: [
14256
+ { in: "path", key: "sessionID" },
14257
+ { in: "path", key: "messageID" },
14258
+ { in: "path", key: "partID" },
14259
+ { in: "query", key: "directory" },
14260
+ { in: "query", key: "workspace" }
14261
+ ]
14262
+ }
14263
+ ]);
14264
+ return (options?.client ?? this.client).delete({
14265
+ url: "/session/{sessionID}/message/{messageID}/part/{partID}",
14266
+ ...options,
14267
+ ...params
14268
+ });
14269
+ }
14270
+ update(parameters, options) {
14271
+ const params = buildClientParams([parameters], [
14272
+ {
14273
+ args: [
14274
+ { in: "path", key: "sessionID" },
14275
+ { in: "path", key: "messageID" },
14276
+ { in: "path", key: "partID" },
14277
+ { in: "query", key: "directory" },
14278
+ { in: "query", key: "workspace" },
14279
+ { key: "part", map: "body" }
14280
+ ]
14281
+ }
14282
+ ]);
14283
+ return (options?.client ?? this.client).patch({
14284
+ url: "/session/{sessionID}/message/{messageID}/part/{partID}",
14285
+ ...options,
14286
+ ...params,
14287
+ headers: {
14288
+ "Content-Type": "application/json",
14289
+ ...options?.headers,
14290
+ ...params.headers
14291
+ }
14292
+ });
14293
+ }
14294
+ }
14295
+
14296
+ class Permission extends HeyApiClient {
14297
+ respond(parameters, options) {
14298
+ const params = buildClientParams([parameters], [
14299
+ {
14300
+ args: [
14301
+ { in: "path", key: "sessionID" },
14302
+ { in: "path", key: "permissionID" },
14303
+ { in: "query", key: "directory" },
14304
+ { in: "query", key: "workspace" },
14305
+ { in: "body", key: "response" }
14306
+ ]
14307
+ }
14308
+ ]);
14309
+ return (options?.client ?? this.client).post({
14310
+ url: "/session/{sessionID}/permissions/{permissionID}",
14311
+ ...options,
14312
+ ...params,
14313
+ headers: {
14314
+ "Content-Type": "application/json",
14315
+ ...options?.headers,
14316
+ ...params.headers
14317
+ }
14318
+ });
14319
+ }
14320
+ reply(parameters, options) {
14321
+ const params = buildClientParams([parameters], [
14322
+ {
14323
+ args: [
14324
+ { in: "path", key: "requestID" },
14325
+ { in: "query", key: "directory" },
14326
+ { in: "query", key: "workspace" },
14327
+ { in: "body", key: "reply" },
14328
+ { in: "body", key: "message" }
14329
+ ]
14330
+ }
14331
+ ]);
14332
+ return (options?.client ?? this.client).post({
14333
+ url: "/permission/{requestID}/reply",
14334
+ ...options,
14335
+ ...params,
14336
+ headers: {
14337
+ "Content-Type": "application/json",
14338
+ ...options?.headers,
14339
+ ...params.headers
14340
+ }
14341
+ });
14342
+ }
14343
+ list(parameters, options) {
14344
+ const params = buildClientParams([parameters], [
14345
+ {
14346
+ args: [
14347
+ { in: "query", key: "directory" },
14348
+ { in: "query", key: "workspace" }
14349
+ ]
14350
+ }
14351
+ ]);
14352
+ return (options?.client ?? this.client).get({
14353
+ url: "/permission",
14354
+ ...options,
14355
+ ...params
14356
+ });
14357
+ }
14358
+ }
14359
+
14360
+ class Question extends HeyApiClient {
14361
+ list(parameters, options) {
14362
+ const params = buildClientParams([parameters], [
14363
+ {
14364
+ args: [
14365
+ { in: "query", key: "directory" },
14366
+ { in: "query", key: "workspace" }
14367
+ ]
14368
+ }
14369
+ ]);
14370
+ return (options?.client ?? this.client).get({
14371
+ url: "/question",
14372
+ ...options,
14373
+ ...params
14374
+ });
14375
+ }
14376
+ reply(parameters, options) {
14377
+ const params = buildClientParams([parameters], [
14378
+ {
14379
+ args: [
14380
+ { in: "path", key: "requestID" },
14381
+ { in: "query", key: "directory" },
14382
+ { in: "query", key: "workspace" },
14383
+ { in: "body", key: "answers" }
14384
+ ]
14385
+ }
14386
+ ]);
14387
+ return (options?.client ?? this.client).post({
14388
+ url: "/question/{requestID}/reply",
14389
+ ...options,
14390
+ ...params,
14391
+ headers: {
14392
+ "Content-Type": "application/json",
14393
+ ...options?.headers,
14394
+ ...params.headers
14395
+ }
14396
+ });
14397
+ }
14398
+ reject(parameters, options) {
14399
+ const params = buildClientParams([parameters], [
14400
+ {
14401
+ args: [
14402
+ { in: "path", key: "requestID" },
14403
+ { in: "query", key: "directory" },
14404
+ { in: "query", key: "workspace" }
14405
+ ]
14406
+ }
14407
+ ]);
14408
+ return (options?.client ?? this.client).post({
14409
+ url: "/question/{requestID}/reject",
14410
+ ...options,
14411
+ ...params
14412
+ });
14413
+ }
14414
+ }
14415
+
14416
+ class Oauth extends HeyApiClient {
14417
+ authorize(parameters, options) {
14418
+ const params = buildClientParams([parameters], [
14419
+ {
14420
+ args: [
14421
+ { in: "path", key: "providerID" },
14422
+ { in: "query", key: "directory" },
14423
+ { in: "query", key: "workspace" },
14424
+ { in: "body", key: "method" },
14425
+ { in: "body", key: "inputs" }
14426
+ ]
14427
+ }
14428
+ ]);
14429
+ return (options?.client ?? this.client).post({
14430
+ url: "/provider/{providerID}/oauth/authorize",
14431
+ ...options,
14432
+ ...params,
14433
+ headers: {
14434
+ "Content-Type": "application/json",
14435
+ ...options?.headers,
14436
+ ...params.headers
14437
+ }
14438
+ });
14439
+ }
14440
+ callback(parameters, options) {
14441
+ const params = buildClientParams([parameters], [
14442
+ {
14443
+ args: [
14444
+ { in: "path", key: "providerID" },
14445
+ { in: "query", key: "directory" },
14446
+ { in: "query", key: "workspace" },
14447
+ { in: "body", key: "method" },
14448
+ { in: "body", key: "code" }
14449
+ ]
14450
+ }
14451
+ ]);
14452
+ return (options?.client ?? this.client).post({
14453
+ url: "/provider/{providerID}/oauth/callback",
14454
+ ...options,
14455
+ ...params,
14456
+ headers: {
14457
+ "Content-Type": "application/json",
14458
+ ...options?.headers,
14459
+ ...params.headers
14460
+ }
14461
+ });
14462
+ }
14463
+ }
14464
+
14465
+ class Provider extends HeyApiClient {
14466
+ list(parameters, options) {
14467
+ const params = buildClientParams([parameters], [
14468
+ {
14469
+ args: [
14470
+ { in: "query", key: "directory" },
14471
+ { in: "query", key: "workspace" }
14472
+ ]
14473
+ }
14474
+ ]);
14475
+ return (options?.client ?? this.client).get({
14476
+ url: "/provider",
14477
+ ...options,
14478
+ ...params
14479
+ });
14480
+ }
14481
+ auth(parameters, options) {
14482
+ const params = buildClientParams([parameters], [
14483
+ {
14484
+ args: [
14485
+ { in: "query", key: "directory" },
14486
+ { in: "query", key: "workspace" }
14487
+ ]
14488
+ }
14489
+ ]);
14490
+ return (options?.client ?? this.client).get({
14491
+ url: "/provider/auth",
14492
+ ...options,
14493
+ ...params
14494
+ });
14495
+ }
14496
+ _oauth;
14497
+ get oauth() {
14498
+ return this._oauth ??= new Oauth({ client: this.client });
14499
+ }
14500
+ }
14501
+
14502
+ class Find extends HeyApiClient {
14503
+ text(parameters, options) {
14504
+ const params = buildClientParams([parameters], [
14505
+ {
14506
+ args: [
14507
+ { in: "query", key: "directory" },
14508
+ { in: "query", key: "workspace" },
14509
+ { in: "query", key: "pattern" }
14510
+ ]
14511
+ }
14512
+ ]);
14513
+ return (options?.client ?? this.client).get({
14514
+ url: "/find",
14515
+ ...options,
14516
+ ...params
14517
+ });
14518
+ }
14519
+ files(parameters, options) {
14520
+ const params = buildClientParams([parameters], [
14521
+ {
14522
+ args: [
14523
+ { in: "query", key: "directory" },
14524
+ { in: "query", key: "workspace" },
14525
+ { in: "query", key: "query" },
14526
+ { in: "query", key: "dirs" },
14527
+ { in: "query", key: "type" },
14528
+ { in: "query", key: "limit" }
14529
+ ]
14530
+ }
14531
+ ]);
14532
+ return (options?.client ?? this.client).get({
14533
+ url: "/find/file",
14534
+ ...options,
14535
+ ...params
14536
+ });
14537
+ }
14538
+ symbols(parameters, options) {
14539
+ const params = buildClientParams([parameters], [
14540
+ {
14541
+ args: [
14542
+ { in: "query", key: "directory" },
14543
+ { in: "query", key: "workspace" },
14544
+ { in: "query", key: "query" }
14545
+ ]
14546
+ }
14547
+ ]);
14548
+ return (options?.client ?? this.client).get({
14549
+ url: "/find/symbol",
14550
+ ...options,
14551
+ ...params
14552
+ });
14553
+ }
14554
+ }
14555
+
14556
+ class File2 extends HeyApiClient {
14557
+ list(parameters, options) {
14558
+ const params = buildClientParams([parameters], [
14559
+ {
14560
+ args: [
14561
+ { in: "query", key: "directory" },
14562
+ { in: "query", key: "workspace" },
14563
+ { in: "query", key: "path" }
14564
+ ]
14565
+ }
14566
+ ]);
14567
+ return (options?.client ?? this.client).get({
14568
+ url: "/file",
14569
+ ...options,
14570
+ ...params
14571
+ });
14572
+ }
14573
+ read(parameters, options) {
14574
+ const params = buildClientParams([parameters], [
14575
+ {
14576
+ args: [
14577
+ { in: "query", key: "directory" },
14578
+ { in: "query", key: "workspace" },
14579
+ { in: "query", key: "path" }
14580
+ ]
14581
+ }
14582
+ ]);
14583
+ return (options?.client ?? this.client).get({
14584
+ url: "/file/content",
14585
+ ...options,
14586
+ ...params
14587
+ });
14588
+ }
14589
+ status(parameters, options) {
14590
+ const params = buildClientParams([parameters], [
14591
+ {
14592
+ args: [
14593
+ { in: "query", key: "directory" },
14594
+ { in: "query", key: "workspace" }
14595
+ ]
14596
+ }
14597
+ ]);
14598
+ return (options?.client ?? this.client).get({
14599
+ url: "/file/status",
14600
+ ...options,
14601
+ ...params
14602
+ });
14603
+ }
14604
+ }
14605
+
14606
+ class Event extends HeyApiClient {
14607
+ subscribe(parameters, options) {
14608
+ const params = buildClientParams([parameters], [
14609
+ {
14610
+ args: [
14611
+ { in: "query", key: "directory" },
14612
+ { in: "query", key: "workspace" }
14613
+ ]
14614
+ }
14615
+ ]);
14616
+ return (options?.client ?? this.client).sse.get({
14617
+ url: "/event",
14618
+ ...options,
14619
+ ...params
14620
+ });
14621
+ }
14622
+ }
14623
+
14624
+ class Auth2 extends HeyApiClient {
14625
+ remove(parameters, options) {
14626
+ const params = buildClientParams([parameters], [
14627
+ {
14628
+ args: [
14629
+ { in: "path", key: "name" },
14630
+ { in: "query", key: "directory" },
14631
+ { in: "query", key: "workspace" }
14632
+ ]
14633
+ }
14634
+ ]);
14635
+ return (options?.client ?? this.client).delete({
14636
+ url: "/mcp/{name}/auth",
14637
+ ...options,
14638
+ ...params
14639
+ });
14640
+ }
14641
+ start(parameters, options) {
14642
+ const params = buildClientParams([parameters], [
14643
+ {
14644
+ args: [
14645
+ { in: "path", key: "name" },
14646
+ { in: "query", key: "directory" },
14647
+ { in: "query", key: "workspace" }
14648
+ ]
14649
+ }
14650
+ ]);
14651
+ return (options?.client ?? this.client).post({
14652
+ url: "/mcp/{name}/auth",
14653
+ ...options,
14654
+ ...params
14655
+ });
14656
+ }
14657
+ callback(parameters, options) {
14658
+ const params = buildClientParams([parameters], [
14659
+ {
14660
+ args: [
14661
+ { in: "path", key: "name" },
14662
+ { in: "query", key: "directory" },
14663
+ { in: "query", key: "workspace" },
14664
+ { in: "body", key: "code" }
14665
+ ]
14666
+ }
14667
+ ]);
14668
+ return (options?.client ?? this.client).post({
14669
+ url: "/mcp/{name}/auth/callback",
14670
+ ...options,
14671
+ ...params,
14672
+ headers: {
14673
+ "Content-Type": "application/json",
14674
+ ...options?.headers,
14675
+ ...params.headers
14676
+ }
14677
+ });
14678
+ }
14679
+ authenticate(parameters, options) {
14680
+ const params = buildClientParams([parameters], [
14681
+ {
14682
+ args: [
14683
+ { in: "path", key: "name" },
14684
+ { in: "query", key: "directory" },
14685
+ { in: "query", key: "workspace" }
14686
+ ]
14687
+ }
14688
+ ]);
14689
+ return (options?.client ?? this.client).post({
14690
+ url: "/mcp/{name}/auth/authenticate",
14691
+ ...options,
14692
+ ...params
14693
+ });
14694
+ }
14695
+ }
14696
+
14697
+ class Mcp extends HeyApiClient {
14698
+ status(parameters, options) {
14699
+ const params = buildClientParams([parameters], [
14700
+ {
14701
+ args: [
14702
+ { in: "query", key: "directory" },
14703
+ { in: "query", key: "workspace" }
14704
+ ]
14705
+ }
14706
+ ]);
14707
+ return (options?.client ?? this.client).get({
14708
+ url: "/mcp",
14709
+ ...options,
14710
+ ...params
14711
+ });
14712
+ }
14713
+ add(parameters, options) {
14714
+ const params = buildClientParams([parameters], [
14715
+ {
14716
+ args: [
14717
+ { in: "query", key: "directory" },
14718
+ { in: "query", key: "workspace" },
14719
+ { in: "body", key: "name" },
14720
+ { in: "body", key: "config" }
14721
+ ]
14722
+ }
14723
+ ]);
14724
+ return (options?.client ?? this.client).post({
14725
+ url: "/mcp",
14726
+ ...options,
14727
+ ...params,
14728
+ headers: {
14729
+ "Content-Type": "application/json",
14730
+ ...options?.headers,
14731
+ ...params.headers
14732
+ }
14733
+ });
14734
+ }
14735
+ connect(parameters, options) {
14736
+ const params = buildClientParams([parameters], [
14737
+ {
14738
+ args: [
14739
+ { in: "path", key: "name" },
14740
+ { in: "query", key: "directory" },
14741
+ { in: "query", key: "workspace" }
14742
+ ]
14743
+ }
14744
+ ]);
14745
+ return (options?.client ?? this.client).post({
14746
+ url: "/mcp/{name}/connect",
14747
+ ...options,
14748
+ ...params
14749
+ });
14750
+ }
14751
+ disconnect(parameters, options) {
14752
+ const params = buildClientParams([parameters], [
14753
+ {
14754
+ args: [
14755
+ { in: "path", key: "name" },
14756
+ { in: "query", key: "directory" },
14757
+ { in: "query", key: "workspace" }
14758
+ ]
14759
+ }
14760
+ ]);
14761
+ return (options?.client ?? this.client).post({
14762
+ url: "/mcp/{name}/disconnect",
14763
+ ...options,
14764
+ ...params
14765
+ });
14766
+ }
14767
+ _auth;
14768
+ get auth() {
14769
+ return this._auth ??= new Auth2({ client: this.client });
14770
+ }
14771
+ }
14772
+
14773
+ class Control extends HeyApiClient {
14774
+ next(parameters, options) {
14775
+ const params = buildClientParams([parameters], [
14776
+ {
14777
+ args: [
14778
+ { in: "query", key: "directory" },
14779
+ { in: "query", key: "workspace" }
14780
+ ]
14781
+ }
14782
+ ]);
14783
+ return (options?.client ?? this.client).get({
14784
+ url: "/tui/control/next",
14785
+ ...options,
14786
+ ...params
14787
+ });
14788
+ }
14789
+ response(parameters, options) {
14790
+ const params = buildClientParams([parameters], [
14791
+ {
14792
+ args: [
14793
+ { in: "query", key: "directory" },
14794
+ { in: "query", key: "workspace" },
14795
+ { key: "body", map: "body" }
14796
+ ]
14797
+ }
14798
+ ]);
14799
+ return (options?.client ?? this.client).post({
14800
+ url: "/tui/control/response",
14801
+ ...options,
14802
+ ...params,
14803
+ headers: {
14804
+ "Content-Type": "application/json",
14805
+ ...options?.headers,
14806
+ ...params.headers
14807
+ }
14808
+ });
14809
+ }
14810
+ }
14811
+
14812
+ class Tui extends HeyApiClient {
14813
+ appendPrompt(parameters, options) {
14814
+ const params = buildClientParams([parameters], [
14815
+ {
14816
+ args: [
14817
+ { in: "query", key: "directory" },
14818
+ { in: "query", key: "workspace" },
14819
+ { in: "body", key: "text" }
14820
+ ]
14821
+ }
14822
+ ]);
14823
+ return (options?.client ?? this.client).post({
14824
+ url: "/tui/append-prompt",
14825
+ ...options,
14826
+ ...params,
14827
+ headers: {
14828
+ "Content-Type": "application/json",
14829
+ ...options?.headers,
14830
+ ...params.headers
14831
+ }
14832
+ });
14833
+ }
14834
+ openHelp(parameters, options) {
14835
+ const params = buildClientParams([parameters], [
14836
+ {
14837
+ args: [
14838
+ { in: "query", key: "directory" },
14839
+ { in: "query", key: "workspace" }
14840
+ ]
14841
+ }
14842
+ ]);
14843
+ return (options?.client ?? this.client).post({
14844
+ url: "/tui/open-help",
14845
+ ...options,
14846
+ ...params
14847
+ });
14848
+ }
14849
+ openSessions(parameters, options) {
14850
+ const params = buildClientParams([parameters], [
14851
+ {
14852
+ args: [
14853
+ { in: "query", key: "directory" },
14854
+ { in: "query", key: "workspace" }
14855
+ ]
14856
+ }
14857
+ ]);
14858
+ return (options?.client ?? this.client).post({
14859
+ url: "/tui/open-sessions",
14860
+ ...options,
14861
+ ...params
14862
+ });
14863
+ }
14864
+ openThemes(parameters, options) {
14865
+ const params = buildClientParams([parameters], [
14866
+ {
14867
+ args: [
14868
+ { in: "query", key: "directory" },
14869
+ { in: "query", key: "workspace" }
14870
+ ]
14871
+ }
14872
+ ]);
14873
+ return (options?.client ?? this.client).post({
14874
+ url: "/tui/open-themes",
14875
+ ...options,
14876
+ ...params
14877
+ });
14878
+ }
14879
+ openModels(parameters, options) {
14880
+ const params = buildClientParams([parameters], [
14881
+ {
14882
+ args: [
14883
+ { in: "query", key: "directory" },
14884
+ { in: "query", key: "workspace" }
14885
+ ]
14886
+ }
14887
+ ]);
14888
+ return (options?.client ?? this.client).post({
14889
+ url: "/tui/open-models",
14890
+ ...options,
14891
+ ...params
14892
+ });
14893
+ }
14894
+ submitPrompt(parameters, options) {
14895
+ const params = buildClientParams([parameters], [
14896
+ {
14897
+ args: [
14898
+ { in: "query", key: "directory" },
14899
+ { in: "query", key: "workspace" }
14900
+ ]
14901
+ }
14902
+ ]);
14903
+ return (options?.client ?? this.client).post({
14904
+ url: "/tui/submit-prompt",
14905
+ ...options,
14906
+ ...params
14907
+ });
14908
+ }
14909
+ clearPrompt(parameters, options) {
14910
+ const params = buildClientParams([parameters], [
14911
+ {
14912
+ args: [
14913
+ { in: "query", key: "directory" },
14914
+ { in: "query", key: "workspace" }
14915
+ ]
14916
+ }
14917
+ ]);
14918
+ return (options?.client ?? this.client).post({
14919
+ url: "/tui/clear-prompt",
14920
+ ...options,
14921
+ ...params
14922
+ });
14923
+ }
14924
+ executeCommand(parameters, options) {
14925
+ const params = buildClientParams([parameters], [
14926
+ {
14927
+ args: [
14928
+ { in: "query", key: "directory" },
14929
+ { in: "query", key: "workspace" },
14930
+ { in: "body", key: "command" }
14931
+ ]
14932
+ }
14933
+ ]);
14934
+ return (options?.client ?? this.client).post({
14935
+ url: "/tui/execute-command",
14936
+ ...options,
14937
+ ...params,
14938
+ headers: {
14939
+ "Content-Type": "application/json",
14940
+ ...options?.headers,
14941
+ ...params.headers
14942
+ }
14943
+ });
14944
+ }
14945
+ showToast(parameters, options) {
14946
+ const params = buildClientParams([parameters], [
14947
+ {
14948
+ args: [
14949
+ { in: "query", key: "directory" },
14950
+ { in: "query", key: "workspace" },
14951
+ { in: "body", key: "title" },
14952
+ { in: "body", key: "message" },
14953
+ { in: "body", key: "variant" },
14954
+ { in: "body", key: "duration" }
14955
+ ]
14956
+ }
14957
+ ]);
14958
+ return (options?.client ?? this.client).post({
14959
+ url: "/tui/show-toast",
14960
+ ...options,
14961
+ ...params,
14962
+ headers: {
14963
+ "Content-Type": "application/json",
14964
+ ...options?.headers,
14965
+ ...params.headers
14966
+ }
14967
+ });
14968
+ }
14969
+ publish(parameters, options) {
14970
+ const params = buildClientParams([parameters], [
14971
+ {
14972
+ args: [
14973
+ { in: "query", key: "directory" },
14974
+ { in: "query", key: "workspace" },
14975
+ { key: "body", map: "body" }
14976
+ ]
14977
+ }
14978
+ ]);
14979
+ return (options?.client ?? this.client).post({
14980
+ url: "/tui/publish",
14981
+ ...options,
14982
+ ...params,
14983
+ headers: {
14984
+ "Content-Type": "application/json",
14985
+ ...options?.headers,
14986
+ ...params.headers
14987
+ }
14988
+ });
14989
+ }
14990
+ selectSession(parameters, options) {
14991
+ const params = buildClientParams([parameters], [
14992
+ {
14993
+ args: [
14994
+ { in: "query", key: "directory" },
14995
+ { in: "query", key: "workspace" },
14996
+ { in: "body", key: "sessionID" }
14997
+ ]
14998
+ }
14999
+ ]);
15000
+ return (options?.client ?? this.client).post({
15001
+ url: "/tui/select-session",
15002
+ ...options,
15003
+ ...params,
15004
+ headers: {
15005
+ "Content-Type": "application/json",
15006
+ ...options?.headers,
15007
+ ...params.headers
15008
+ }
15009
+ });
15010
+ }
15011
+ _control;
15012
+ get control() {
15013
+ return this._control ??= new Control({ client: this.client });
15014
+ }
15015
+ }
15016
+
15017
+ class Instance extends HeyApiClient {
15018
+ dispose(parameters, options) {
15019
+ const params = buildClientParams([parameters], [
15020
+ {
15021
+ args: [
15022
+ { in: "query", key: "directory" },
15023
+ { in: "query", key: "workspace" }
15024
+ ]
15025
+ }
15026
+ ]);
15027
+ return (options?.client ?? this.client).post({
15028
+ url: "/instance/dispose",
15029
+ ...options,
15030
+ ...params
15031
+ });
15032
+ }
15033
+ }
15034
+
15035
+ class Path extends HeyApiClient {
15036
+ get(parameters, options) {
15037
+ const params = buildClientParams([parameters], [
15038
+ {
15039
+ args: [
15040
+ { in: "query", key: "directory" },
15041
+ { in: "query", key: "workspace" }
15042
+ ]
15043
+ }
15044
+ ]);
15045
+ return (options?.client ?? this.client).get({
15046
+ url: "/path",
15047
+ ...options,
15048
+ ...params
15049
+ });
15050
+ }
15051
+ }
15052
+
15053
+ class Vcs extends HeyApiClient {
15054
+ get(parameters, options) {
15055
+ const params = buildClientParams([parameters], [
15056
+ {
15057
+ args: [
15058
+ { in: "query", key: "directory" },
15059
+ { in: "query", key: "workspace" }
15060
+ ]
15061
+ }
15062
+ ]);
15063
+ return (options?.client ?? this.client).get({
15064
+ url: "/vcs",
15065
+ ...options,
15066
+ ...params
15067
+ });
15068
+ }
15069
+ }
15070
+
15071
+ class Command extends HeyApiClient {
15072
+ list(parameters, options) {
15073
+ const params = buildClientParams([parameters], [
15074
+ {
15075
+ args: [
15076
+ { in: "query", key: "directory" },
15077
+ { in: "query", key: "workspace" }
15078
+ ]
15079
+ }
15080
+ ]);
15081
+ return (options?.client ?? this.client).get({
15082
+ url: "/command",
15083
+ ...options,
15084
+ ...params
15085
+ });
15086
+ }
15087
+ }
15088
+
15089
+ class App extends HeyApiClient {
15090
+ log(parameters, options) {
15091
+ const params = buildClientParams([parameters], [
15092
+ {
15093
+ args: [
15094
+ { in: "query", key: "directory" },
15095
+ { in: "query", key: "workspace" },
15096
+ { in: "body", key: "service" },
15097
+ { in: "body", key: "level" },
15098
+ { in: "body", key: "message" },
15099
+ { in: "body", key: "extra" }
15100
+ ]
15101
+ }
15102
+ ]);
15103
+ return (options?.client ?? this.client).post({
15104
+ url: "/log",
15105
+ ...options,
15106
+ ...params,
15107
+ headers: {
15108
+ "Content-Type": "application/json",
15109
+ ...options?.headers,
15110
+ ...params.headers
15111
+ }
15112
+ });
15113
+ }
15114
+ agents(parameters, options) {
15115
+ const params = buildClientParams([parameters], [
15116
+ {
15117
+ args: [
15118
+ { in: "query", key: "directory" },
15119
+ { in: "query", key: "workspace" }
15120
+ ]
15121
+ }
15122
+ ]);
15123
+ return (options?.client ?? this.client).get({
15124
+ url: "/agent",
15125
+ ...options,
15126
+ ...params
15127
+ });
15128
+ }
15129
+ skills(parameters, options) {
15130
+ const params = buildClientParams([parameters], [
15131
+ {
15132
+ args: [
15133
+ { in: "query", key: "directory" },
15134
+ { in: "query", key: "workspace" }
15135
+ ]
15136
+ }
15137
+ ]);
15138
+ return (options?.client ?? this.client).get({
15139
+ url: "/skill",
15140
+ ...options,
15141
+ ...params
15142
+ });
15143
+ }
15144
+ }
15145
+
15146
+ class Lsp extends HeyApiClient {
15147
+ status(parameters, options) {
15148
+ const params = buildClientParams([parameters], [
15149
+ {
15150
+ args: [
15151
+ { in: "query", key: "directory" },
15152
+ { in: "query", key: "workspace" }
15153
+ ]
15154
+ }
15155
+ ]);
15156
+ return (options?.client ?? this.client).get({
15157
+ url: "/lsp",
15158
+ ...options,
15159
+ ...params
15160
+ });
15161
+ }
15162
+ }
15163
+
15164
+ class Formatter extends HeyApiClient {
15165
+ status(parameters, options) {
15166
+ const params = buildClientParams([parameters], [
15167
+ {
15168
+ args: [
15169
+ { in: "query", key: "directory" },
15170
+ { in: "query", key: "workspace" }
15171
+ ]
15172
+ }
15173
+ ]);
15174
+ return (options?.client ?? this.client).get({
15175
+ url: "/formatter",
15176
+ ...options,
15177
+ ...params
15178
+ });
15179
+ }
15180
+ }
15181
+
15182
+ class OpencodeClient extends HeyApiClient {
15183
+ static __registry = new HeyApiRegistry;
15184
+ constructor(args) {
15185
+ super(args);
15186
+ OpencodeClient.__registry.set(this, args?.key);
15187
+ }
15188
+ _global;
15189
+ get global() {
15190
+ return this._global ??= new Global({ client: this.client });
15191
+ }
15192
+ _auth;
15193
+ get auth() {
15194
+ return this._auth ??= new Auth({ client: this.client });
15195
+ }
15196
+ _project;
15197
+ get project() {
15198
+ return this._project ??= new Project({ client: this.client });
15199
+ }
15200
+ _pty;
15201
+ get pty() {
15202
+ return this._pty ??= new Pty({ client: this.client });
15203
+ }
15204
+ _config;
15205
+ get config() {
15206
+ return this._config ??= new Config2({ client: this.client });
15207
+ }
15208
+ _tool;
15209
+ get tool() {
15210
+ return this._tool ??= new Tool({ client: this.client });
15211
+ }
15212
+ _experimental;
15213
+ get experimental() {
15214
+ return this._experimental ??= new Experimental({ client: this.client });
15215
+ }
15216
+ _worktree;
15217
+ get worktree() {
15218
+ return this._worktree ??= new Worktree({ client: this.client });
15219
+ }
15220
+ _session;
15221
+ get session() {
15222
+ return this._session ??= new Session2({ client: this.client });
15223
+ }
15224
+ _part;
15225
+ get part() {
15226
+ return this._part ??= new Part({ client: this.client });
15227
+ }
15228
+ _permission;
15229
+ get permission() {
15230
+ return this._permission ??= new Permission({ client: this.client });
15231
+ }
15232
+ _question;
15233
+ get question() {
15234
+ return this._question ??= new Question({ client: this.client });
15235
+ }
15236
+ _provider;
15237
+ get provider() {
15238
+ return this._provider ??= new Provider({ client: this.client });
15239
+ }
15240
+ _find;
15241
+ get find() {
15242
+ return this._find ??= new Find({ client: this.client });
15243
+ }
15244
+ _file;
15245
+ get file() {
15246
+ return this._file ??= new File2({ client: this.client });
15247
+ }
15248
+ _event;
15249
+ get event() {
15250
+ return this._event ??= new Event({ client: this.client });
15251
+ }
15252
+ _mcp;
15253
+ get mcp() {
15254
+ return this._mcp ??= new Mcp({ client: this.client });
15255
+ }
15256
+ _tui;
15257
+ get tui() {
15258
+ return this._tui ??= new Tui({ client: this.client });
15259
+ }
15260
+ _instance;
15261
+ get instance() {
15262
+ return this._instance ??= new Instance({ client: this.client });
15263
+ }
15264
+ _path;
15265
+ get path() {
15266
+ return this._path ??= new Path({ client: this.client });
15267
+ }
15268
+ _vcs;
15269
+ get vcs() {
15270
+ return this._vcs ??= new Vcs({ client: this.client });
15271
+ }
15272
+ _command;
15273
+ get command() {
15274
+ return this._command ??= new Command({ client: this.client });
15275
+ }
15276
+ _app;
15277
+ get app() {
15278
+ return this._app ??= new App({ client: this.client });
15279
+ }
15280
+ _lsp;
15281
+ get lsp() {
15282
+ return this._lsp ??= new Lsp({ client: this.client });
15283
+ }
15284
+ _formatter;
15285
+ get formatter() {
15286
+ return this._formatter ??= new Formatter({ client: this.client });
15287
+ }
15288
+ }
12337
15289
  // src/index.ts
12338
- import path3 from "path";
15290
+ import path2 from "path";
12339
15291
  import { mkdirSync } from "fs";
12340
15292
 
12341
15293
  // src/db.ts
@@ -12413,7 +15365,8 @@ var MIGRATIONS = [
12413
15365
  `ALTER TABLE team_member ADD COLUMN worktree_dir TEXT;
12414
15366
  ALTER TABLE team_member ADD COLUMN worktree_branch TEXT;`,
12415
15367
  `ALTER TABLE team_member ADD COLUMN plan_approval TEXT NOT NULL DEFAULT 'none'
12416
- CHECK(plan_approval IN ('none', 'pending', 'approved', 'rejected'));`
15368
+ CHECK(plan_approval IN ('none', 'pending', 'approved', 'rejected'));`,
15369
+ `ALTER TABLE team ADD COLUMN lead_agent TEXT;`
12417
15370
  ];
12418
15371
  function applyMigrations(db) {
12419
15372
  const { user_version: current } = db.query("PRAGMA user_version").get();
@@ -12438,6 +15391,43 @@ function createDb(path2) {
12438
15391
  return db;
12439
15392
  }
12440
15393
 
15394
+ // src/client.ts
15395
+ function extractError(err) {
15396
+ if (err && typeof err === "object" && "message" in err)
15397
+ return String(err.message);
15398
+ return String(err);
15399
+ }
15400
+ function throwing(fn) {
15401
+ return async (...args) => {
15402
+ const result = await fn(...args);
15403
+ if (result && typeof result === "object" && "error" in result && result.error !== undefined) {
15404
+ throw new Error(extractError(result.error));
15405
+ }
15406
+ return result;
15407
+ };
15408
+ }
15409
+ function wrapThrowingClient(raw) {
15410
+ const r = raw;
15411
+ return {
15412
+ session: {
15413
+ create: throwing(r.session.create.bind(r.session)),
15414
+ promptAsync: throwing(r.session.promptAsync.bind(r.session)),
15415
+ abort: throwing(r.session.abort.bind(r.session)),
15416
+ status: throwing(r.session.status.bind(r.session))
15417
+ },
15418
+ tui: {
15419
+ showToast: throwing(r.tui.showToast.bind(r.tui)),
15420
+ selectSession: throwing(r.tui.selectSession.bind(r.tui))
15421
+ },
15422
+ worktree: {
15423
+ create: throwing(r.worktree.create.bind(r.worktree)),
15424
+ remove: throwing(r.worktree.remove.bind(r.worktree)),
15425
+ list: throwing(r.worktree.list.bind(r.worktree)),
15426
+ reset: throwing(r.worktree.reset.bind(r.worktree))
15427
+ }
15428
+ };
15429
+ }
15430
+
12441
15431
  // src/util.ts
12442
15432
  var NAME_PATTERN = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
12443
15433
  var counter = 0;
@@ -12490,26 +15480,26 @@ function markDelivered(db, messageId) {
12490
15480
  }
12491
15481
 
12492
15482
  // src/recovery.ts
12493
- async function recoverStaleMembers(db, client) {
15483
+ async function recoverStaleMembers(db, client3) {
12494
15484
  const stale = db.query(`SELECT tm.session_id FROM team_member tm
12495
15485
  JOIN team t ON tm.team_id = t.id
12496
15486
  WHERE tm.status = 'busy' AND t.status = 'active'`).all();
12497
15487
  const result = db.run(`UPDATE team_member SET status = 'error', execution_status = 'idle', time_updated = ?
12498
15488
  WHERE status = 'busy'
12499
15489
  AND team_id IN (SELECT id FROM team WHERE status = 'active')`, [Date.now()]);
12500
- if (client) {
15490
+ if (client3) {
12501
15491
  for (const member of stale) {
12502
15492
  try {
12503
- await client.session.abort({ path: { id: member.session_id } });
15493
+ await client3.session.abort({ sessionID: member.session_id });
12504
15494
  } catch {}
12505
15495
  }
12506
15496
  }
12507
15497
  return { interrupted: result.changes };
12508
15498
  }
12509
- async function recoverOrphanedWorktrees(db, client) {
15499
+ async function recoverOrphanedWorktrees(db, client3) {
12510
15500
  let removed = 0;
12511
15501
  try {
12512
- const worktrees = await client.worktree.list();
15502
+ const worktrees = await client3.worktree.list();
12513
15503
  if (!worktrees.data)
12514
15504
  return { removed: 0 };
12515
15505
  const activeWorktrees = new Set(db.query(`SELECT tm.worktree_dir FROM team_member tm
@@ -12521,14 +15511,14 @@ async function recoverOrphanedWorktrees(db, client) {
12521
15511
  if (activeWorktrees.has(wt.directory))
12522
15512
  continue;
12523
15513
  try {
12524
- await client.worktree.remove({ worktreeRemoveInput: { directory: wt.directory } });
15514
+ await client3.worktree.remove({ worktreeRemoveInput: { directory: wt.directory } });
12525
15515
  removed++;
12526
15516
  } catch {}
12527
15517
  }
12528
15518
  } catch {}
12529
15519
  return { removed };
12530
15520
  }
12531
- async function recoverUndeliveredMessages(db, client, registry2) {
15521
+ async function recoverUndeliveredMessages(db, client3, registry2) {
12532
15522
  const teams = db.query("SELECT id, lead_session_id FROM team WHERE status = 'active'").all();
12533
15523
  let redelivered = 0;
12534
15524
  for (const team of teams) {
@@ -12546,9 +15536,9 @@ async function recoverUndeliveredMessages(db, client, registry2) {
12546
15536
  if (!recipientSessionId)
12547
15537
  continue;
12548
15538
  try {
12549
- await client.session.promptAsync({
12550
- path: { id: recipientSessionId },
12551
- body: { parts: [{ type: "text", text: `[Recovered team message from ${msg.from_name}]: ${msg.content}` }] }
15539
+ await client3.session.promptAsync({
15540
+ sessionID: recipientSessionId,
15541
+ parts: [{ type: "text", text: `[Recovered team message from ${msg.from_name}]: ${msg.content}` }]
12552
15542
  });
12553
15543
  markDelivered(db, msg.id);
12554
15544
  redelivered++;
@@ -12697,10 +15687,10 @@ function formatMessage(type, data) {
12697
15687
  return `${data.memberName} shut down`;
12698
15688
  }
12699
15689
  }
12700
- async function notifyTeamEvent(client, type, data) {
15690
+ async function notifyTeamEvent(client3, type, data) {
12701
15691
  const config2 = TOAST_CONFIG[type];
12702
15692
  try {
12703
- await client.tui.showToast({
15693
+ await client3.tui.showToast({
12704
15694
  title: "Team",
12705
15695
  message: formatMessage(type, data),
12706
15696
  variant: config2.variant,
@@ -12708,14 +15698,14 @@ async function notifyTeamEvent(client, type, data) {
12708
15698
  });
12709
15699
  } catch {}
12710
15700
  }
12711
- async function notifyWorkingProgress(client, db, teamId) {
15701
+ async function notifyWorkingProgress(client3, db, teamId) {
12712
15702
  const members = db.query("SELECT name, status FROM team_member WHERE team_id = ? ORDER BY time_created ASC").all(teamId);
12713
15703
  if (members.length === 0)
12714
15704
  return;
12715
15705
  const busy = members.filter((m) => m.status === "busy");
12716
15706
  try {
12717
15707
  if (busy.length === 0) {
12718
- await client.tui.showToast({
15708
+ await client3.tui.showToast({
12719
15709
  title: "Team",
12720
15710
  message: "All teammates finished",
12721
15711
  variant: "success",
@@ -12723,7 +15713,7 @@ async function notifyWorkingProgress(client, db, teamId) {
12723
15713
  });
12724
15714
  } else {
12725
15715
  const names = busy.map((m) => m.name).join(", ");
12726
- await client.tui.showToast({
15716
+ await client3.tui.showToast({
12727
15717
  title: "Team",
12728
15718
  message: `Working: ${names} (${busy.length}/${members.length})`,
12729
15719
  variant: "info",
@@ -12763,6 +15753,8 @@ function buildLeadSystemPrompt(db, teamId) {
12763
15753
  "",
12764
15754
  "Teammates work asynchronously and message you when done.",
12765
15755
  "Do NOT poll team_status or team_tasks_list repeatedly \u2014 wait for messages.",
15756
+ "Spawn teammates ONE at a time \u2014 do not send multiple team_spawn calls in a single response.",
15757
+ "After each team_spawn, verify the output confirms the spawn succeeded before spawning the next.",
12766
15758
  "After spawning teammates, tell the user what you've set up and wait.",
12767
15759
  "When all teammates finish, summarize results and suggest next steps."
12768
15760
  ].join(`
@@ -12838,7 +15830,6 @@ async function executeTeamCreate(deps, args, sessionId) {
12838
15830
  }
12839
15831
 
12840
15832
  // src/tools/team-spawn.ts
12841
- import path2 from "path";
12842
15833
  async function executeTeamSpawn(deps, args, sessionId) {
12843
15834
  const nameError = validateMemberName(args.name);
12844
15835
  if (nameError)
@@ -12858,7 +15849,7 @@ async function executeTeamSpawn(deps, args, sessionId) {
12858
15849
  if (useWorktree) {
12859
15850
  const worktreeName = `ensemble-${teamInfo.teamName}-${args.name}`;
12860
15851
  try {
12861
- const result = await deps.client.worktree.create({ name: worktreeName });
15852
+ const result = await deps.client.worktree.create({ worktreeCreateInput: { name: worktreeName } });
12862
15853
  if (result.data) {
12863
15854
  worktreeDir = result.data.directory;
12864
15855
  worktreeBranch = result.data.branch;
@@ -12874,15 +15865,21 @@ async function executeTeamSpawn(deps, args, sessionId) {
12874
15865
  } catch {}
12875
15866
  }
12876
15867
  }
12877
- const createOpts = {
12878
- body: { parentID: sessionId, title: `${args.name} (@${args.agent} teammate)` }
12879
- };
12880
- if (worktreeDir) {
12881
- createOpts.directory = worktreeDir;
12882
- }
15868
+ const isReadOnly = args.agent === "plan" || args.agent === "explore";
15869
+ const TEAM_TOOLS = ["team_message", "team_broadcast", "team_tasks_list", "team_tasks_add", "team_tasks_complete", "team_claim"];
15870
+ const permission = isReadOnly ? [
15871
+ { permission: "edit", pattern: "*", action: "deny" },
15872
+ { permission: "bash", pattern: "*", action: "deny" },
15873
+ ...TEAM_TOOLS.map((t) => ({ permission: t, pattern: "*", action: "allow" }))
15874
+ ] : undefined;
12883
15875
  let childSessionId;
12884
15876
  try {
12885
- const createResult = await deps.client.session.create(createOpts);
15877
+ const createResult = await deps.client.session.create({
15878
+ parentID: sessionId,
15879
+ title: `${args.name} (@${args.agent} teammate)`,
15880
+ ...permission ? { permission } : {},
15881
+ ...worktreeDir ? { directory: worktreeDir } : {}
15882
+ });
12886
15883
  childSessionId = createResult.data?.id;
12887
15884
  } catch (err) {
12888
15885
  if (worktreeDir) {
@@ -12916,16 +15913,6 @@ async function executeTeamSpawn(deps, args, sessionId) {
12916
15913
  context.push("", "IMPORTANT: You are in PLAN MODE.", "Read and explore the codebase, then send your implementation plan to the lead via team_message.", "Do NOT write or modify any files until the lead approves your plan.", "Wait for the lead's approval message before proceeding with implementation.");
12917
15914
  }
12918
15915
  context.push("", "Tools available to you:", "- team_message: send a message to the lead or another teammate", "- team_broadcast: send a message to all team members", "- team_tasks_list: view the shared team task board", "- team_tasks_add: add tasks to the shared board", "- team_tasks_complete: mark a task complete on the shared board", "- team_claim: claim a pending task from the shared board", "", "When you finish your task:", "1. If you claimed a task, mark it complete using team_tasks_complete.", "2. Send ONE message to the lead with your findings using team_message.", "3. STOP. Do not send follow-up confirmations, status updates, or 'standing by' messages.", "", "If you are blocked, send ONE message to the lead describing the specific blocker.", "", "Your plain text output is NOT visible to the team. You MUST use team_message to communicate.");
12919
- try {
12920
- const agentsPath = path2.join(deps.directory, "AGENTS.md");
12921
- const file2 = Bun.file(agentsPath);
12922
- if (await file2.exists()) {
12923
- const content = await file2.text();
12924
- const truncated = content.length > 2000 ? content.slice(0, 2000) + `
12925
- ...(truncated)` : content;
12926
- context.push("", "Project guidelines (from AGENTS.md):", truncated);
12927
- }
12928
- } catch {}
12929
15916
  context.push("", "Your task:", args.prompt);
12930
15917
  if (args.claim_task) {
12931
15918
  context.push("", `You have been assigned task ${args.claim_task}. Mark it complete when done.`);
@@ -12934,14 +15921,15 @@ async function executeTeamSpawn(deps, args, sessionId) {
12934
15921
  `);
12935
15922
  try {
12936
15923
  await deps.client.session.promptAsync({
12937
- path: { id: childSessionId },
12938
- body: { parts: [{ type: "text", text: contextStr }] }
15924
+ sessionID: childSessionId,
15925
+ parts: [{ type: "text", text: contextStr }],
15926
+ agent: args.agent
12939
15927
  });
12940
15928
  } catch (err) {
12941
15929
  deps.db.run("DELETE FROM team_member WHERE team_id = ? AND name = ?", [teamInfo.teamId, args.name]);
12942
15930
  deps.registry.unregister(childSessionId);
12943
15931
  try {
12944
- await deps.client.session.abort({ path: { id: childSessionId } });
15932
+ await deps.client.session.abort({ sessionID: childSessionId });
12945
15933
  } catch {}
12946
15934
  if (worktreeDir) {
12947
15935
  try {
@@ -13000,8 +15988,8 @@ async function executeTeamMessage(deps, args, sessionId) {
13000
15988
  deliveryText = `[Team message from ${senderName}]: ${messageText}`;
13001
15989
  }
13002
15990
  await deps.client.session.promptAsync({
13003
- path: { id: recipientSessionId },
13004
- body: { parts: [{ type: "text", text: deliveryText }] }
15991
+ sessionID: recipientSessionId,
15992
+ parts: [{ type: "text", text: deliveryText }]
13005
15993
  });
13006
15994
  markDelivered(deps.db, msgId);
13007
15995
  return `Message sent to ${args.to}.`;
@@ -13034,8 +16022,8 @@ async function executeTeamBroadcast(deps, args, sessionId) {
13034
16022
  for (const recipient of recipients) {
13035
16023
  try {
13036
16024
  await deps.client.session.promptAsync({
13037
- path: { id: recipient.sessionId },
13038
- body: { parts: [{ type: "text", text: `[Team broadcast from ${senderName}]: ${args.text}` }] }
16025
+ sessionID: recipient.sessionId,
16026
+ parts: [{ type: "text", text: `[Team broadcast from ${senderName}]: ${args.text}` }]
13039
16027
  });
13040
16028
  delivered++;
13041
16029
  } catch {}
@@ -13077,13 +16065,11 @@ async function executeTeamShutdown(deps, args, sessionId) {
13077
16065
  }
13078
16066
  try {
13079
16067
  await deps.client.session.promptAsync({
13080
- path: { id: member.session_id },
13081
- body: {
13082
- parts: [{
13083
- type: "text",
13084
- text: `[Shutdown requested]: The lead has requested you shut down. Finish your current task, send your final findings to the lead via team_message, then stop.`
13085
- }]
13086
- }
16068
+ sessionID: member.session_id,
16069
+ parts: [{
16070
+ type: "text",
16071
+ text: `[Shutdown requested]: The lead has requested you shut down. Finish your current task, send your final findings to the lead via team_message, then stop.`
16072
+ }]
13087
16073
  });
13088
16074
  } catch {}
13089
16075
  deps.db.run("UPDATE team_member SET status = 'shutdown_requested', time_updated = ? WHERE team_id = ? AND name = ?", [Date.now(), teamInfo.teamId, args.member]);
@@ -13091,7 +16077,7 @@ async function executeTeamShutdown(deps, args, sessionId) {
13091
16077
  }
13092
16078
  async function abortAndShutdown(deps, teamId, memberName, sessionId) {
13093
16079
  try {
13094
- await deps.client.session.abort({ path: { id: sessionId } });
16080
+ await deps.client.session.abort({ sessionID: sessionId });
13095
16081
  } catch {}
13096
16082
  deps.db.run("UPDATE team_member SET status = 'shutdown', execution_status = 'idle', time_updated = ? WHERE team_id = ? AND name = ?", [Date.now(), teamId, memberName]);
13097
16083
  }
@@ -13112,7 +16098,7 @@ async function executeTeamCleanup(deps, args, sessionId) {
13112
16098
  if (args.force) {
13113
16099
  for (const member of active) {
13114
16100
  try {
13115
- await deps.client.session.abort({ path: { id: member.session_id } });
16101
+ await deps.client.session.abort({ sessionID: member.session_id });
13116
16102
  } catch {}
13117
16103
  }
13118
16104
  }
@@ -13417,7 +16403,7 @@ class Watchdog {
13417
16403
  for (const member of stale) {
13418
16404
  this.db.run("UPDATE team_member SET status = 'error', execution_status = 'timed_out', time_updated = ? WHERE team_id = ? AND name = ?", [Date.now(), member.team_id, member.name]);
13419
16405
  try {
13420
- await this.client.session.abort({ path: { id: member.session_id } });
16406
+ await this.client.session.abort({ sessionID: member.session_id });
13421
16407
  } catch {}
13422
16408
  try {
13423
16409
  await this.client.tui.showToast({
@@ -13455,21 +16441,22 @@ var DEFAULT_WATCHDOG_TTL_MS = 30 * 60 * 1000;
13455
16441
  var DEFAULT_WATCHDOG_CHECK_MS = 60 * 1000;
13456
16442
  var plugin = async (input) => {
13457
16443
  const dbPath = getDbPath();
13458
- mkdirSync(path3.dirname(dbPath), { recursive: true });
16444
+ mkdirSync(path2.dirname(dbPath), { recursive: true });
13459
16445
  const db = createDb(dbPath);
13460
16446
  const registry2 = new MemberRegistry;
13461
16447
  const tracker = new DescendantTracker;
13462
- const client = input.client;
13463
- const deps = { db, registry: registry2, tracker, client, directory: input.directory };
13464
- const recovery = await recoverStaleMembers(db, client);
16448
+ const rawClient = new OpencodeClient({ client: input.client._client });
16449
+ const client3 = wrapThrowingClient(rawClient);
16450
+ const deps = { db, registry: registry2, tracker, client: client3, directory: input.directory };
16451
+ const recovery = await recoverStaleMembers(db, client3);
13465
16452
  if (recovery.interrupted > 0) {
13466
16453
  const members = db.query("SELECT tm.team_id, tm.name, tm.session_id FROM team_member tm JOIN team t ON tm.team_id = t.id WHERE t.status = 'active'").all();
13467
16454
  for (const m of members) {
13468
16455
  registry2.register(m.team_id, m.name, m.session_id);
13469
16456
  }
13470
16457
  }
13471
- recoverUndeliveredMessages(db, client, registry2).catch(() => {});
13472
- recoverOrphanedWorktrees(db, client).catch(() => {});
16458
+ recoverUndeliveredMessages(db, client3, registry2).catch(() => {});
16459
+ recoverOrphanedWorktrees(db, client3).catch(() => {});
13473
16460
  const rateLimitEnv = process.env.OPENCODE_ENSEMBLE_RATE_LIMIT;
13474
16461
  const rateLimitCapacity = rateLimitEnv === "0" ? 0 : parseInt(rateLimitEnv ?? "", 10) || DEFAULT_RATE_LIMIT_CAPACITY;
13475
16462
  const rateLimiter = new TokenBucket({
@@ -13481,7 +16468,7 @@ var plugin = async (input) => {
13481
16468
  const watchdogTtl = timeoutEnv === "0" ? 0 : parseInt(timeoutEnv ?? "", 10) || DEFAULT_WATCHDOG_TTL_MS;
13482
16469
  const watchdog = new Watchdog({
13483
16470
  db,
13484
- client,
16471
+ client: client3,
13485
16472
  registry: registry2,
13486
16473
  ttlMs: watchdogTtl,
13487
16474
  checkIntervalMs: DEFAULT_WATCHDOG_CHECK_MS
@@ -13495,14 +16482,14 @@ var plugin = async (input) => {
13495
16482
  const transition = handleSessionStatusEvent(db, registry2, sessionID, statusType);
13496
16483
  if (transition) {
13497
16484
  if (transition.to === "shutdown") {
13498
- notifyTeamEvent(client, "shutdown", { memberName: transition.memberName });
16485
+ notifyTeamEvent(client3, "shutdown", { memberName: transition.memberName });
13499
16486
  } else if (transition.to === "ready" && transition.from === "busy") {
13500
- notifyTeamEvent(client, "completed", { memberName: transition.memberName });
16487
+ notifyTeamEvent(client3, "completed", { memberName: transition.memberName });
13501
16488
  } else if (transition.to === "error") {
13502
- notifyTeamEvent(client, "error", { memberName: transition.memberName });
16489
+ notifyTeamEvent(client3, "error", { memberName: transition.memberName });
13503
16490
  } else if (transition.to === "retry") {
13504
16491
  try {
13505
- await client.tui.showToast({
16492
+ await client3.tui.showToast({
13506
16493
  title: "Team",
13507
16494
  message: `${transition.memberName} is being rate-limited`,
13508
16495
  variant: "warning",
@@ -13513,11 +16500,11 @@ var plugin = async (input) => {
13513
16500
  const entry = registry2.getBySession(sessionID);
13514
16501
  if (entry) {
13515
16502
  try {
13516
- await client.session.abort({ path: { id: sessionID } });
16503
+ await client3.session.abort({ sessionID });
13517
16504
  } catch {}
13518
16505
  }
13519
16506
  }
13520
- await notifyWorkingProgress(client, db, transition.teamId);
16507
+ await notifyWorkingProgress(client3, db, transition.teamId);
13521
16508
  }
13522
16509
  }
13523
16510
  if (event.type === "session.created") {