opencode-telegram-bot 1.0.8 → 1.0.10
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/README.md +24 -1
- package/dist/app.d.ts +21 -13
- package/dist/index.js +2207 -614
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16650,9 +16650,9 @@ const {
|
|
|
16650
16650
|
|
|
16651
16651
|
// EXTERNAL MODULE: ./node_modules/telegraf/lib/index.js
|
|
16652
16652
|
var lib = __nccwpck_require__(5879);
|
|
16653
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/gen/core/serverSentEvents.gen.js
|
|
16653
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js
|
|
16654
16654
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
16655
|
-
const createSseClient = ({ onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
|
|
16655
|
+
const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
|
|
16656
16656
|
let lastEventId;
|
|
16657
16657
|
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
16658
16658
|
const createStream = async function* () {
|
|
@@ -16670,7 +16670,21 @@ const createSseClient = ({ onSseError, onSseEvent, responseTransformer, response
|
|
|
16670
16670
|
headers.set("Last-Event-ID", lastEventId);
|
|
16671
16671
|
}
|
|
16672
16672
|
try {
|
|
16673
|
-
const
|
|
16673
|
+
const requestInit = {
|
|
16674
|
+
redirect: "follow",
|
|
16675
|
+
...options,
|
|
16676
|
+
body: options.serializedBody,
|
|
16677
|
+
headers,
|
|
16678
|
+
signal,
|
|
16679
|
+
};
|
|
16680
|
+
let request = new Request(url, requestInit);
|
|
16681
|
+
if (onRequest) {
|
|
16682
|
+
request = await onRequest(url, requestInit);
|
|
16683
|
+
}
|
|
16684
|
+
// fetch must be assigned here, otherwise it would throw the error:
|
|
16685
|
+
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
16686
|
+
const _fetch = options.fetch ?? globalThis.fetch;
|
|
16687
|
+
const response = await _fetch(request);
|
|
16674
16688
|
if (!response.ok)
|
|
16675
16689
|
throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
16676
16690
|
if (!response.body)
|
|
@@ -16692,6 +16706,8 @@ const createSseClient = ({ onSseError, onSseEvent, responseTransformer, response
|
|
|
16692
16706
|
if (done)
|
|
16693
16707
|
break;
|
|
16694
16708
|
buffer += value;
|
|
16709
|
+
// Normalize line endings: CRLF -> LF, then CR -> LF
|
|
16710
|
+
buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
16695
16711
|
const chunks = buffer.split("\n\n");
|
|
16696
16712
|
buffer = chunks.pop() ?? "";
|
|
16697
16713
|
for (const chunk of chunks) {
|
|
@@ -16769,82 +16785,7 @@ const createSseClient = ({ onSseError, onSseEvent, responseTransformer, response
|
|
|
16769
16785
|
return { stream };
|
|
16770
16786
|
};
|
|
16771
16787
|
|
|
16772
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/gen/core/
|
|
16773
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
16774
|
-
const getAuthToken = async (auth, callback) => {
|
|
16775
|
-
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
16776
|
-
if (!token) {
|
|
16777
|
-
return;
|
|
16778
|
-
}
|
|
16779
|
-
if (auth.scheme === "bearer") {
|
|
16780
|
-
return `Bearer ${token}`;
|
|
16781
|
-
}
|
|
16782
|
-
if (auth.scheme === "basic") {
|
|
16783
|
-
return `Basic ${btoa(token)}`;
|
|
16784
|
-
}
|
|
16785
|
-
return token;
|
|
16786
|
-
};
|
|
16787
|
-
|
|
16788
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/gen/core/bodySerializer.gen.js
|
|
16789
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
16790
|
-
const serializeFormDataPair = (data, key, value) => {
|
|
16791
|
-
if (typeof value === "string" || value instanceof Blob) {
|
|
16792
|
-
data.append(key, value);
|
|
16793
|
-
}
|
|
16794
|
-
else if (value instanceof Date) {
|
|
16795
|
-
data.append(key, value.toISOString());
|
|
16796
|
-
}
|
|
16797
|
-
else {
|
|
16798
|
-
data.append(key, JSON.stringify(value));
|
|
16799
|
-
}
|
|
16800
|
-
};
|
|
16801
|
-
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
16802
|
-
if (typeof value === "string") {
|
|
16803
|
-
data.append(key, value);
|
|
16804
|
-
}
|
|
16805
|
-
else {
|
|
16806
|
-
data.append(key, JSON.stringify(value));
|
|
16807
|
-
}
|
|
16808
|
-
};
|
|
16809
|
-
const formDataBodySerializer = {
|
|
16810
|
-
bodySerializer: (body) => {
|
|
16811
|
-
const data = new FormData();
|
|
16812
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
16813
|
-
if (value === undefined || value === null) {
|
|
16814
|
-
return;
|
|
16815
|
-
}
|
|
16816
|
-
if (Array.isArray(value)) {
|
|
16817
|
-
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
16818
|
-
}
|
|
16819
|
-
else {
|
|
16820
|
-
serializeFormDataPair(data, key, value);
|
|
16821
|
-
}
|
|
16822
|
-
});
|
|
16823
|
-
return data;
|
|
16824
|
-
},
|
|
16825
|
-
};
|
|
16826
|
-
const jsonBodySerializer = {
|
|
16827
|
-
bodySerializer: (body) => JSON.stringify(body, (_key, value) => (typeof value === "bigint" ? value.toString() : value)),
|
|
16828
|
-
};
|
|
16829
|
-
const urlSearchParamsBodySerializer = {
|
|
16830
|
-
bodySerializer: (body) => {
|
|
16831
|
-
const data = new URLSearchParams();
|
|
16832
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
16833
|
-
if (value === undefined || value === null) {
|
|
16834
|
-
return;
|
|
16835
|
-
}
|
|
16836
|
-
if (Array.isArray(value)) {
|
|
16837
|
-
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
16838
|
-
}
|
|
16839
|
-
else {
|
|
16840
|
-
serializeUrlSearchParamsPair(data, key, value);
|
|
16841
|
-
}
|
|
16842
|
-
});
|
|
16843
|
-
return data.toString();
|
|
16844
|
-
},
|
|
16845
|
-
};
|
|
16846
|
-
|
|
16847
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/gen/core/pathSerializer.gen.js
|
|
16788
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/gen/core/pathSerializer.gen.js
|
|
16848
16789
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
16849
16790
|
const separatorArrayExplode = (style) => {
|
|
16850
16791
|
switch (style) {
|
|
@@ -16952,7 +16893,7 @@ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valu
|
|
|
16952
16893
|
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
16953
16894
|
};
|
|
16954
16895
|
|
|
16955
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/gen/core/utils.gen.js
|
|
16896
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/gen/core/utils.gen.js
|
|
16956
16897
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
16957
16898
|
|
|
16958
16899
|
const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
@@ -17022,14 +16963,107 @@ const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
|
17022
16963
|
}
|
|
17023
16964
|
return url;
|
|
17024
16965
|
};
|
|
16966
|
+
function getValidRequestBody(options) {
|
|
16967
|
+
const hasBody = options.body !== undefined;
|
|
16968
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
16969
|
+
if (isSerializedBody) {
|
|
16970
|
+
if ("serializedBody" in options) {
|
|
16971
|
+
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== "";
|
|
16972
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
16973
|
+
}
|
|
16974
|
+
// not all clients implement a serializedBody property (i.e. client-axios)
|
|
16975
|
+
return options.body !== "" ? options.body : null;
|
|
16976
|
+
}
|
|
16977
|
+
// plain/text body
|
|
16978
|
+
if (hasBody) {
|
|
16979
|
+
return options.body;
|
|
16980
|
+
}
|
|
16981
|
+
// no body was provided
|
|
16982
|
+
return undefined;
|
|
16983
|
+
}
|
|
16984
|
+
|
|
16985
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/gen/core/auth.gen.js
|
|
16986
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
16987
|
+
const getAuthToken = async (auth, callback) => {
|
|
16988
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
16989
|
+
if (!token) {
|
|
16990
|
+
return;
|
|
16991
|
+
}
|
|
16992
|
+
if (auth.scheme === "bearer") {
|
|
16993
|
+
return `Bearer ${token}`;
|
|
16994
|
+
}
|
|
16995
|
+
if (auth.scheme === "basic") {
|
|
16996
|
+
return `Basic ${btoa(token)}`;
|
|
16997
|
+
}
|
|
16998
|
+
return token;
|
|
16999
|
+
};
|
|
17000
|
+
|
|
17001
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/gen/core/bodySerializer.gen.js
|
|
17002
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
17003
|
+
const serializeFormDataPair = (data, key, value) => {
|
|
17004
|
+
if (typeof value === "string" || value instanceof Blob) {
|
|
17005
|
+
data.append(key, value);
|
|
17006
|
+
}
|
|
17007
|
+
else if (value instanceof Date) {
|
|
17008
|
+
data.append(key, value.toISOString());
|
|
17009
|
+
}
|
|
17010
|
+
else {
|
|
17011
|
+
data.append(key, JSON.stringify(value));
|
|
17012
|
+
}
|
|
17013
|
+
};
|
|
17014
|
+
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
17015
|
+
if (typeof value === "string") {
|
|
17016
|
+
data.append(key, value);
|
|
17017
|
+
}
|
|
17018
|
+
else {
|
|
17019
|
+
data.append(key, JSON.stringify(value));
|
|
17020
|
+
}
|
|
17021
|
+
};
|
|
17022
|
+
const formDataBodySerializer = {
|
|
17023
|
+
bodySerializer: (body) => {
|
|
17024
|
+
const data = new FormData();
|
|
17025
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
17026
|
+
if (value === undefined || value === null) {
|
|
17027
|
+
return;
|
|
17028
|
+
}
|
|
17029
|
+
if (Array.isArray(value)) {
|
|
17030
|
+
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
17031
|
+
}
|
|
17032
|
+
else {
|
|
17033
|
+
serializeFormDataPair(data, key, value);
|
|
17034
|
+
}
|
|
17035
|
+
});
|
|
17036
|
+
return data;
|
|
17037
|
+
},
|
|
17038
|
+
};
|
|
17039
|
+
const jsonBodySerializer = {
|
|
17040
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => (typeof value === "bigint" ? value.toString() : value)),
|
|
17041
|
+
};
|
|
17042
|
+
const urlSearchParamsBodySerializer = {
|
|
17043
|
+
bodySerializer: (body) => {
|
|
17044
|
+
const data = new URLSearchParams();
|
|
17045
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
17046
|
+
if (value === undefined || value === null) {
|
|
17047
|
+
return;
|
|
17048
|
+
}
|
|
17049
|
+
if (Array.isArray(value)) {
|
|
17050
|
+
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
17051
|
+
}
|
|
17052
|
+
else {
|
|
17053
|
+
serializeUrlSearchParamsPair(data, key, value);
|
|
17054
|
+
}
|
|
17055
|
+
});
|
|
17056
|
+
return data.toString();
|
|
17057
|
+
},
|
|
17058
|
+
};
|
|
17025
17059
|
|
|
17026
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/gen/client/utils.gen.js
|
|
17060
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/gen/client/utils.gen.js
|
|
17027
17061
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
17028
17062
|
|
|
17029
17063
|
|
|
17030
17064
|
|
|
17031
17065
|
|
|
17032
|
-
const createQuerySerializer = ({
|
|
17066
|
+
const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
17033
17067
|
const querySerializer = (queryParams) => {
|
|
17034
17068
|
const search = [];
|
|
17035
17069
|
if (queryParams && typeof queryParams === "object") {
|
|
@@ -17038,33 +17072,34 @@ const createQuerySerializer = ({ allowReserved, array, object } = {}) => {
|
|
|
17038
17072
|
if (value === undefined || value === null) {
|
|
17039
17073
|
continue;
|
|
17040
17074
|
}
|
|
17075
|
+
const options = parameters[name] || args;
|
|
17041
17076
|
if (Array.isArray(value)) {
|
|
17042
17077
|
const serializedArray = serializeArrayParam({
|
|
17043
|
-
allowReserved,
|
|
17078
|
+
allowReserved: options.allowReserved,
|
|
17044
17079
|
explode: true,
|
|
17045
17080
|
name,
|
|
17046
17081
|
style: "form",
|
|
17047
17082
|
value,
|
|
17048
|
-
...array,
|
|
17083
|
+
...options.array,
|
|
17049
17084
|
});
|
|
17050
17085
|
if (serializedArray)
|
|
17051
17086
|
search.push(serializedArray);
|
|
17052
17087
|
}
|
|
17053
17088
|
else if (typeof value === "object") {
|
|
17054
17089
|
const serializedObject = serializeObjectParam({
|
|
17055
|
-
allowReserved,
|
|
17090
|
+
allowReserved: options.allowReserved,
|
|
17056
17091
|
explode: true,
|
|
17057
17092
|
name,
|
|
17058
17093
|
style: "deepObject",
|
|
17059
17094
|
value: value,
|
|
17060
|
-
...object,
|
|
17095
|
+
...options.object,
|
|
17061
17096
|
});
|
|
17062
17097
|
if (serializedObject)
|
|
17063
17098
|
search.push(serializedObject);
|
|
17064
17099
|
}
|
|
17065
17100
|
else {
|
|
17066
17101
|
const serializedPrimitive = serializePrimitiveParam({
|
|
17067
|
-
allowReserved,
|
|
17102
|
+
allowReserved: options.allowReserved,
|
|
17068
17103
|
name,
|
|
17069
17104
|
value: value,
|
|
17070
17105
|
});
|
|
@@ -17157,13 +17192,20 @@ const mergeConfigs = (a, b) => {
|
|
|
17157
17192
|
config.headers = mergeHeaders(a.headers, b.headers);
|
|
17158
17193
|
return config;
|
|
17159
17194
|
};
|
|
17195
|
+
const headersEntries = (headers) => {
|
|
17196
|
+
const entries = [];
|
|
17197
|
+
headers.forEach((value, key) => {
|
|
17198
|
+
entries.push([key, value]);
|
|
17199
|
+
});
|
|
17200
|
+
return entries;
|
|
17201
|
+
};
|
|
17160
17202
|
const mergeHeaders = (...headers) => {
|
|
17161
17203
|
const mergedHeaders = new Headers();
|
|
17162
17204
|
for (const header of headers) {
|
|
17163
|
-
if (!header
|
|
17205
|
+
if (!header) {
|
|
17164
17206
|
continue;
|
|
17165
17207
|
}
|
|
17166
|
-
const iterator = header instanceof Headers ? header
|
|
17208
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
17167
17209
|
for (const [key, value] of iterator) {
|
|
17168
17210
|
if (value === null) {
|
|
17169
17211
|
mergedHeaders.delete(key);
|
|
@@ -17183,47 +17225,39 @@ const mergeHeaders = (...headers) => {
|
|
|
17183
17225
|
return mergedHeaders;
|
|
17184
17226
|
};
|
|
17185
17227
|
class Interceptors {
|
|
17186
|
-
|
|
17187
|
-
constructor() {
|
|
17188
|
-
this._fns = [];
|
|
17189
|
-
}
|
|
17228
|
+
fns = [];
|
|
17190
17229
|
clear() {
|
|
17191
|
-
this.
|
|
17230
|
+
this.fns = [];
|
|
17192
17231
|
}
|
|
17193
|
-
|
|
17194
|
-
|
|
17195
|
-
|
|
17196
|
-
|
|
17197
|
-
else {
|
|
17198
|
-
return this._fns.indexOf(id);
|
|
17232
|
+
eject(id) {
|
|
17233
|
+
const index = this.getInterceptorIndex(id);
|
|
17234
|
+
if (this.fns[index]) {
|
|
17235
|
+
this.fns[index] = null;
|
|
17199
17236
|
}
|
|
17200
17237
|
}
|
|
17201
17238
|
exists(id) {
|
|
17202
17239
|
const index = this.getInterceptorIndex(id);
|
|
17203
|
-
return
|
|
17240
|
+
return Boolean(this.fns[index]);
|
|
17204
17241
|
}
|
|
17205
|
-
|
|
17206
|
-
|
|
17207
|
-
|
|
17208
|
-
this._fns[index] = null;
|
|
17242
|
+
getInterceptorIndex(id) {
|
|
17243
|
+
if (typeof id === "number") {
|
|
17244
|
+
return this.fns[id] ? id : -1;
|
|
17209
17245
|
}
|
|
17246
|
+
return this.fns.indexOf(id);
|
|
17210
17247
|
}
|
|
17211
17248
|
update(id, fn) {
|
|
17212
17249
|
const index = this.getInterceptorIndex(id);
|
|
17213
|
-
if (this.
|
|
17214
|
-
this.
|
|
17250
|
+
if (this.fns[index]) {
|
|
17251
|
+
this.fns[index] = fn;
|
|
17215
17252
|
return id;
|
|
17216
17253
|
}
|
|
17217
|
-
|
|
17218
|
-
return false;
|
|
17219
|
-
}
|
|
17254
|
+
return false;
|
|
17220
17255
|
}
|
|
17221
17256
|
use(fn) {
|
|
17222
|
-
this.
|
|
17223
|
-
return this.
|
|
17257
|
+
this.fns.push(fn);
|
|
17258
|
+
return this.fns.length - 1;
|
|
17224
17259
|
}
|
|
17225
17260
|
}
|
|
17226
|
-
// do not add `Middleware` as return type so we can use _fns internally
|
|
17227
17261
|
const createInterceptors = () => ({
|
|
17228
17262
|
error: new Interceptors(),
|
|
17229
17263
|
request: new Interceptors(),
|
|
@@ -17251,10 +17285,11 @@ const createConfig = (override = {}) => ({
|
|
|
17251
17285
|
...override,
|
|
17252
17286
|
});
|
|
17253
17287
|
|
|
17254
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/gen/client/client.gen.js
|
|
17288
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/gen/client/client.gen.js
|
|
17255
17289
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
17256
17290
|
|
|
17257
17291
|
|
|
17292
|
+
|
|
17258
17293
|
const createClient = (config = {}) => {
|
|
17259
17294
|
let _config = mergeConfigs(createConfig(), config);
|
|
17260
17295
|
const getConfig = () => ({ ..._config });
|
|
@@ -17280,11 +17315,11 @@ const createClient = (config = {}) => {
|
|
|
17280
17315
|
if (opts.requestValidator) {
|
|
17281
17316
|
await opts.requestValidator(opts);
|
|
17282
17317
|
}
|
|
17283
|
-
if (opts.body && opts.bodySerializer) {
|
|
17318
|
+
if (opts.body !== undefined && opts.bodySerializer) {
|
|
17284
17319
|
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
17285
17320
|
}
|
|
17286
17321
|
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
17287
|
-
if (opts.
|
|
17322
|
+
if (opts.body === undefined || opts.serializedBody === "") {
|
|
17288
17323
|
opts.headers.delete("Content-Type");
|
|
17289
17324
|
}
|
|
17290
17325
|
const url = buildUrl(opts);
|
|
@@ -17296,10 +17331,10 @@ const createClient = (config = {}) => {
|
|
|
17296
17331
|
const requestInit = {
|
|
17297
17332
|
redirect: "follow",
|
|
17298
17333
|
...opts,
|
|
17299
|
-
body: opts
|
|
17334
|
+
body: getValidRequestBody(opts),
|
|
17300
17335
|
};
|
|
17301
17336
|
let request = new Request(url, requestInit);
|
|
17302
|
-
for (const fn of interceptors.request.
|
|
17337
|
+
for (const fn of interceptors.request.fns) {
|
|
17303
17338
|
if (fn) {
|
|
17304
17339
|
request = await fn(request, opts);
|
|
17305
17340
|
}
|
|
@@ -17307,8 +17342,32 @@ const createClient = (config = {}) => {
|
|
|
17307
17342
|
// fetch must be assigned here, otherwise it would throw the error:
|
|
17308
17343
|
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
17309
17344
|
const _fetch = opts.fetch;
|
|
17310
|
-
let response
|
|
17311
|
-
|
|
17345
|
+
let response;
|
|
17346
|
+
try {
|
|
17347
|
+
response = await _fetch(request);
|
|
17348
|
+
}
|
|
17349
|
+
catch (error) {
|
|
17350
|
+
// Handle fetch exceptions (AbortError, network errors, etc.)
|
|
17351
|
+
let finalError = error;
|
|
17352
|
+
for (const fn of interceptors.error.fns) {
|
|
17353
|
+
if (fn) {
|
|
17354
|
+
finalError = (await fn(error, undefined, request, opts));
|
|
17355
|
+
}
|
|
17356
|
+
}
|
|
17357
|
+
finalError = finalError || {};
|
|
17358
|
+
if (opts.throwOnError) {
|
|
17359
|
+
throw finalError;
|
|
17360
|
+
}
|
|
17361
|
+
// Return error response
|
|
17362
|
+
return opts.responseStyle === "data"
|
|
17363
|
+
? undefined
|
|
17364
|
+
: {
|
|
17365
|
+
error: finalError,
|
|
17366
|
+
request,
|
|
17367
|
+
response: undefined,
|
|
17368
|
+
};
|
|
17369
|
+
}
|
|
17370
|
+
for (const fn of interceptors.response.fns) {
|
|
17312
17371
|
if (fn) {
|
|
17313
17372
|
response = await fn(response, request, opts);
|
|
17314
17373
|
}
|
|
@@ -17318,24 +17377,48 @@ const createClient = (config = {}) => {
|
|
|
17318
17377
|
response,
|
|
17319
17378
|
};
|
|
17320
17379
|
if (response.ok) {
|
|
17380
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
17321
17381
|
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
17382
|
+
let emptyData;
|
|
17383
|
+
switch (parseAs) {
|
|
17384
|
+
case "arrayBuffer":
|
|
17385
|
+
case "blob":
|
|
17386
|
+
case "text":
|
|
17387
|
+
emptyData = await response[parseAs]();
|
|
17388
|
+
break;
|
|
17389
|
+
case "formData":
|
|
17390
|
+
emptyData = new FormData();
|
|
17391
|
+
break;
|
|
17392
|
+
case "stream":
|
|
17393
|
+
emptyData = response.body;
|
|
17394
|
+
break;
|
|
17395
|
+
case "json":
|
|
17396
|
+
default:
|
|
17397
|
+
emptyData = {};
|
|
17398
|
+
break;
|
|
17399
|
+
}
|
|
17322
17400
|
return opts.responseStyle === "data"
|
|
17323
|
-
?
|
|
17401
|
+
? emptyData
|
|
17324
17402
|
: {
|
|
17325
|
-
data:
|
|
17403
|
+
data: emptyData,
|
|
17326
17404
|
...result,
|
|
17327
17405
|
};
|
|
17328
17406
|
}
|
|
17329
|
-
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
17330
17407
|
let data;
|
|
17331
17408
|
switch (parseAs) {
|
|
17332
17409
|
case "arrayBuffer":
|
|
17333
17410
|
case "blob":
|
|
17334
17411
|
case "formData":
|
|
17335
|
-
case "json":
|
|
17336
17412
|
case "text":
|
|
17337
17413
|
data = await response[parseAs]();
|
|
17338
17414
|
break;
|
|
17415
|
+
case "json": {
|
|
17416
|
+
// Some servers return 200 with no Content-Length and empty body.
|
|
17417
|
+
// response.json() would throw; read as text and parse if non-empty.
|
|
17418
|
+
const text = await response.text();
|
|
17419
|
+
data = text ? JSON.parse(text) : {};
|
|
17420
|
+
break;
|
|
17421
|
+
}
|
|
17339
17422
|
case "stream":
|
|
17340
17423
|
return opts.responseStyle === "data"
|
|
17341
17424
|
? response.body
|
|
@@ -17369,7 +17452,7 @@ const createClient = (config = {}) => {
|
|
|
17369
17452
|
}
|
|
17370
17453
|
const error = jsonError ?? textError;
|
|
17371
17454
|
let finalError = error;
|
|
17372
|
-
for (const fn of interceptors.error.
|
|
17455
|
+
for (const fn of interceptors.error.fns) {
|
|
17373
17456
|
if (fn) {
|
|
17374
17457
|
finalError = (await fn(error, response, request, opts));
|
|
17375
17458
|
}
|
|
@@ -17386,39 +17469,57 @@ const createClient = (config = {}) => {
|
|
|
17386
17469
|
...result,
|
|
17387
17470
|
};
|
|
17388
17471
|
};
|
|
17389
|
-
const
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
|
|
17393
|
-
|
|
17394
|
-
|
|
17395
|
-
|
|
17396
|
-
|
|
17397
|
-
|
|
17398
|
-
url,
|
|
17399
|
-
|
|
17400
|
-
|
|
17401
|
-
|
|
17472
|
+
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
17473
|
+
const makeSseFn = (method) => async (options) => {
|
|
17474
|
+
const { opts, url } = await beforeRequest(options);
|
|
17475
|
+
return createSseClient({
|
|
17476
|
+
...opts,
|
|
17477
|
+
body: opts.body,
|
|
17478
|
+
headers: opts.headers,
|
|
17479
|
+
method,
|
|
17480
|
+
onRequest: async (url, init) => {
|
|
17481
|
+
let request = new Request(url, init);
|
|
17482
|
+
for (const fn of interceptors.request.fns) {
|
|
17483
|
+
if (fn) {
|
|
17484
|
+
request = await fn(request, opts);
|
|
17485
|
+
}
|
|
17486
|
+
}
|
|
17487
|
+
return request;
|
|
17488
|
+
},
|
|
17489
|
+
serializedBody: getValidRequestBody(opts),
|
|
17490
|
+
url,
|
|
17491
|
+
});
|
|
17402
17492
|
};
|
|
17403
17493
|
return {
|
|
17404
17494
|
buildUrl: buildUrl,
|
|
17405
|
-
connect:
|
|
17406
|
-
delete:
|
|
17407
|
-
get:
|
|
17495
|
+
connect: makeMethodFn("CONNECT"),
|
|
17496
|
+
delete: makeMethodFn("DELETE"),
|
|
17497
|
+
get: makeMethodFn("GET"),
|
|
17408
17498
|
getConfig,
|
|
17409
|
-
head:
|
|
17499
|
+
head: makeMethodFn("HEAD"),
|
|
17410
17500
|
interceptors,
|
|
17411
|
-
options:
|
|
17412
|
-
patch:
|
|
17413
|
-
post:
|
|
17414
|
-
put:
|
|
17501
|
+
options: makeMethodFn("OPTIONS"),
|
|
17502
|
+
patch: makeMethodFn("PATCH"),
|
|
17503
|
+
post: makeMethodFn("POST"),
|
|
17504
|
+
put: makeMethodFn("PUT"),
|
|
17415
17505
|
request,
|
|
17416
17506
|
setConfig,
|
|
17417
|
-
|
|
17507
|
+
sse: {
|
|
17508
|
+
connect: makeSseFn("CONNECT"),
|
|
17509
|
+
delete: makeSseFn("DELETE"),
|
|
17510
|
+
get: makeSseFn("GET"),
|
|
17511
|
+
head: makeSseFn("HEAD"),
|
|
17512
|
+
options: makeSseFn("OPTIONS"),
|
|
17513
|
+
patch: makeSseFn("PATCH"),
|
|
17514
|
+
post: makeSseFn("POST"),
|
|
17515
|
+
put: makeSseFn("PUT"),
|
|
17516
|
+
trace: makeSseFn("TRACE"),
|
|
17517
|
+
},
|
|
17518
|
+
trace: makeMethodFn("TRACE"),
|
|
17418
17519
|
};
|
|
17419
17520
|
};
|
|
17420
17521
|
|
|
17421
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/gen/core/params.gen.js
|
|
17522
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/gen/core/params.gen.js
|
|
17422
17523
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
17423
17524
|
const extraPrefixesMap = {
|
|
17424
17525
|
$body_: "body",
|
|
@@ -17440,6 +17541,11 @@ const buildKeyMap = (fields, map) => {
|
|
|
17440
17541
|
});
|
|
17441
17542
|
}
|
|
17442
17543
|
}
|
|
17544
|
+
else if ("key" in config) {
|
|
17545
|
+
map.set(config.key, {
|
|
17546
|
+
map: config.map,
|
|
17547
|
+
});
|
|
17548
|
+
}
|
|
17443
17549
|
else if (config.args) {
|
|
17444
17550
|
buildKeyMap(config.args, map);
|
|
17445
17551
|
}
|
|
@@ -17473,7 +17579,10 @@ const buildClientParams = (args, fields) => {
|
|
|
17473
17579
|
if (config.key) {
|
|
17474
17580
|
const field = map.get(config.key);
|
|
17475
17581
|
const name = field.map || config.key;
|
|
17476
|
-
|
|
17582
|
+
if (field.in) {
|
|
17583
|
+
;
|
|
17584
|
+
params[field.in][name] = arg;
|
|
17585
|
+
}
|
|
17477
17586
|
}
|
|
17478
17587
|
else {
|
|
17479
17588
|
params.body = arg;
|
|
@@ -17483,8 +17592,13 @@ const buildClientParams = (args, fields) => {
|
|
|
17483
17592
|
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
17484
17593
|
const field = map.get(key);
|
|
17485
17594
|
if (field) {
|
|
17486
|
-
|
|
17487
|
-
|
|
17595
|
+
if (field.in) {
|
|
17596
|
+
const name = field.map || key;
|
|
17597
|
+
params[field.in][name] = value;
|
|
17598
|
+
}
|
|
17599
|
+
else {
|
|
17600
|
+
params[field.map] = value;
|
|
17601
|
+
}
|
|
17488
17602
|
}
|
|
17489
17603
|
else {
|
|
17490
17604
|
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
@@ -17492,8 +17606,8 @@ const buildClientParams = (args, fields) => {
|
|
|
17492
17606
|
const [prefix, slot] = extra;
|
|
17493
17607
|
params[slot][key.slice(prefix.length)] = value;
|
|
17494
17608
|
}
|
|
17495
|
-
else {
|
|
17496
|
-
for (const [slot, allowed] of Object.entries(config.allowExtra
|
|
17609
|
+
else if ("allowExtra" in config && config.allowExtra) {
|
|
17610
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
17497
17611
|
if (allowed) {
|
|
17498
17612
|
;
|
|
17499
17613
|
params[slot][key] = value;
|
|
@@ -17509,904 +17623,2168 @@ const buildClientParams = (args, fields) => {
|
|
|
17509
17623
|
return params;
|
|
17510
17624
|
};
|
|
17511
17625
|
|
|
17512
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/gen/client/index.js
|
|
17626
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/gen/client/index.js
|
|
17513
17627
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
17514
17628
|
|
|
17515
17629
|
|
|
17516
17630
|
|
|
17517
17631
|
|
|
17518
17632
|
|
|
17519
|
-
|
|
17633
|
+
|
|
17634
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/gen/client.gen.js
|
|
17520
17635
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
17521
17636
|
|
|
17522
|
-
const client = createClient(createConfig({
|
|
17523
|
-
baseUrl: "http://localhost:4096",
|
|
17524
|
-
}));
|
|
17637
|
+
const client = createClient(createConfig({ baseUrl: "http://localhost:4096" }));
|
|
17525
17638
|
|
|
17526
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/gen/sdk.gen.js
|
|
17639
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/gen/sdk.gen.js
|
|
17527
17640
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
17528
17641
|
|
|
17529
|
-
|
|
17530
|
-
|
|
17642
|
+
|
|
17643
|
+
class HeyApiClient {
|
|
17644
|
+
client;
|
|
17531
17645
|
constructor(args) {
|
|
17532
|
-
|
|
17533
|
-
this._client = args.client;
|
|
17534
|
-
}
|
|
17646
|
+
this.client = args?.client ?? client;
|
|
17535
17647
|
}
|
|
17536
17648
|
}
|
|
17537
|
-
class
|
|
17538
|
-
|
|
17539
|
-
|
|
17540
|
-
|
|
17541
|
-
|
|
17542
|
-
|
|
17543
|
-
|
|
17544
|
-
|
|
17545
|
-
|
|
17649
|
+
class HeyApiRegistry {
|
|
17650
|
+
defaultKey = "default";
|
|
17651
|
+
instances = new Map();
|
|
17652
|
+
get(key) {
|
|
17653
|
+
const instance = this.instances.get(key ?? this.defaultKey);
|
|
17654
|
+
if (!instance) {
|
|
17655
|
+
throw new Error(`No SDK client found. Create one with "new OpencodeClient()" to fix this error.`);
|
|
17656
|
+
}
|
|
17657
|
+
return instance;
|
|
17658
|
+
}
|
|
17659
|
+
set(value, key) {
|
|
17660
|
+
this.instances.set(key ?? this.defaultKey, value);
|
|
17546
17661
|
}
|
|
17547
17662
|
}
|
|
17548
|
-
class
|
|
17663
|
+
class Config extends HeyApiClient {
|
|
17549
17664
|
/**
|
|
17550
|
-
*
|
|
17665
|
+
* Get global configuration
|
|
17666
|
+
*
|
|
17667
|
+
* Retrieve the current global OpenCode configuration settings and preferences.
|
|
17551
17668
|
*/
|
|
17552
|
-
|
|
17553
|
-
return (options?.client ?? this.
|
|
17554
|
-
url: "/
|
|
17669
|
+
get(options) {
|
|
17670
|
+
return (options?.client ?? this.client).get({
|
|
17671
|
+
url: "/global/config",
|
|
17555
17672
|
...options,
|
|
17556
17673
|
});
|
|
17557
17674
|
}
|
|
17558
17675
|
/**
|
|
17559
|
-
*
|
|
17676
|
+
* Update global configuration
|
|
17677
|
+
*
|
|
17678
|
+
* Update global OpenCode configuration settings and preferences.
|
|
17560
17679
|
*/
|
|
17561
|
-
|
|
17562
|
-
|
|
17563
|
-
|
|
17680
|
+
update(parameters, options) {
|
|
17681
|
+
const params = buildClientParams([parameters], [{ args: [{ key: "config", map: "body" }] }]);
|
|
17682
|
+
return (options?.client ?? this.client).patch({
|
|
17683
|
+
url: "/global/config",
|
|
17564
17684
|
...options,
|
|
17685
|
+
...params,
|
|
17686
|
+
headers: {
|
|
17687
|
+
"Content-Type": "application/json",
|
|
17688
|
+
...options?.headers,
|
|
17689
|
+
...params.headers,
|
|
17690
|
+
},
|
|
17565
17691
|
});
|
|
17566
17692
|
}
|
|
17567
17693
|
}
|
|
17568
|
-
class
|
|
17694
|
+
class Global extends HeyApiClient {
|
|
17569
17695
|
/**
|
|
17570
|
-
*
|
|
17696
|
+
* Get health
|
|
17697
|
+
*
|
|
17698
|
+
* Get health information about the OpenCode server.
|
|
17571
17699
|
*/
|
|
17572
|
-
|
|
17573
|
-
return (options?.client ?? this.
|
|
17574
|
-
url: "/
|
|
17700
|
+
health(options) {
|
|
17701
|
+
return (options?.client ?? this.client).get({
|
|
17702
|
+
url: "/global/health",
|
|
17575
17703
|
...options,
|
|
17576
17704
|
});
|
|
17577
17705
|
}
|
|
17578
17706
|
/**
|
|
17579
|
-
*
|
|
17707
|
+
* Get global events
|
|
17708
|
+
*
|
|
17709
|
+
* Subscribe to global events from the OpenCode system using server-sent events.
|
|
17580
17710
|
*/
|
|
17581
|
-
|
|
17582
|
-
return (options?.client ?? this.
|
|
17583
|
-
url: "/
|
|
17711
|
+
event(options) {
|
|
17712
|
+
return (options?.client ?? this.client).sse.get({
|
|
17713
|
+
url: "/global/event",
|
|
17584
17714
|
...options,
|
|
17585
|
-
headers: {
|
|
17586
|
-
"Content-Type": "application/json",
|
|
17587
|
-
...options?.headers,
|
|
17588
|
-
},
|
|
17589
17715
|
});
|
|
17590
17716
|
}
|
|
17591
17717
|
/**
|
|
17592
|
-
*
|
|
17718
|
+
* Dispose instance
|
|
17719
|
+
*
|
|
17720
|
+
* Clean up and dispose all OpenCode instances, releasing all resources.
|
|
17593
17721
|
*/
|
|
17594
|
-
|
|
17595
|
-
return (options
|
|
17596
|
-
url: "/
|
|
17722
|
+
dispose(options) {
|
|
17723
|
+
return (options?.client ?? this.client).post({
|
|
17724
|
+
url: "/global/dispose",
|
|
17597
17725
|
...options,
|
|
17598
17726
|
});
|
|
17599
17727
|
}
|
|
17728
|
+
_config;
|
|
17729
|
+
get config() {
|
|
17730
|
+
return (this._config ??= new Config({ client: this.client }));
|
|
17731
|
+
}
|
|
17732
|
+
}
|
|
17733
|
+
class Auth extends HeyApiClient {
|
|
17600
17734
|
/**
|
|
17601
|
-
*
|
|
17735
|
+
* Remove auth credentials
|
|
17736
|
+
*
|
|
17737
|
+
* Remove authentication credentials
|
|
17602
17738
|
*/
|
|
17603
|
-
|
|
17604
|
-
|
|
17605
|
-
|
|
17739
|
+
remove(parameters, options) {
|
|
17740
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "providerID" }] }]);
|
|
17741
|
+
return (options?.client ?? this.client).delete({
|
|
17742
|
+
url: "/auth/{providerID}",
|
|
17606
17743
|
...options,
|
|
17744
|
+
...params,
|
|
17607
17745
|
});
|
|
17608
17746
|
}
|
|
17609
17747
|
/**
|
|
17610
|
-
*
|
|
17748
|
+
* Set auth credentials
|
|
17749
|
+
*
|
|
17750
|
+
* Set authentication credentials
|
|
17611
17751
|
*/
|
|
17612
|
-
|
|
17613
|
-
|
|
17614
|
-
|
|
17752
|
+
set(parameters, options) {
|
|
17753
|
+
const params = buildClientParams([parameters], [
|
|
17754
|
+
{
|
|
17755
|
+
args: [
|
|
17756
|
+
{ in: "path", key: "providerID" },
|
|
17757
|
+
{ key: "auth", map: "body" },
|
|
17758
|
+
],
|
|
17759
|
+
},
|
|
17760
|
+
]);
|
|
17761
|
+
return (options?.client ?? this.client).put({
|
|
17762
|
+
url: "/auth/{providerID}",
|
|
17615
17763
|
...options,
|
|
17764
|
+
...params,
|
|
17616
17765
|
headers: {
|
|
17617
17766
|
"Content-Type": "application/json",
|
|
17618
|
-
...options
|
|
17767
|
+
...options?.headers,
|
|
17768
|
+
...params.headers,
|
|
17619
17769
|
},
|
|
17620
17770
|
});
|
|
17621
17771
|
}
|
|
17772
|
+
}
|
|
17773
|
+
class Project extends HeyApiClient {
|
|
17622
17774
|
/**
|
|
17623
|
-
*
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
17775
|
+
* List all projects
|
|
17776
|
+
*
|
|
17777
|
+
* Get a list of projects that have been opened with OpenCode.
|
|
17778
|
+
*/
|
|
17779
|
+
list(parameters, options) {
|
|
17780
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
17781
|
+
return (options?.client ?? this.client).get({
|
|
17782
|
+
url: "/project",
|
|
17783
|
+
...options,
|
|
17784
|
+
...params,
|
|
17785
|
+
});
|
|
17786
|
+
}
|
|
17787
|
+
/**
|
|
17788
|
+
* Get current project
|
|
17789
|
+
*
|
|
17790
|
+
* Retrieve the currently active project that OpenCode is working with.
|
|
17791
|
+
*/
|
|
17792
|
+
current(parameters, options) {
|
|
17793
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
17794
|
+
return (options?.client ?? this.client).get({
|
|
17795
|
+
url: "/project/current",
|
|
17628
17796
|
...options,
|
|
17797
|
+
...params,
|
|
17798
|
+
});
|
|
17799
|
+
}
|
|
17800
|
+
/**
|
|
17801
|
+
* Update project
|
|
17802
|
+
*
|
|
17803
|
+
* Update project properties such as name, icon, and commands.
|
|
17804
|
+
*/
|
|
17805
|
+
update(parameters, options) {
|
|
17806
|
+
const params = buildClientParams([parameters], [
|
|
17807
|
+
{
|
|
17808
|
+
args: [
|
|
17809
|
+
{ in: "path", key: "projectID" },
|
|
17810
|
+
{ in: "query", key: "directory" },
|
|
17811
|
+
{ in: "body", key: "name" },
|
|
17812
|
+
{ in: "body", key: "icon" },
|
|
17813
|
+
{ in: "body", key: "commands" },
|
|
17814
|
+
],
|
|
17815
|
+
},
|
|
17816
|
+
]);
|
|
17817
|
+
return (options?.client ?? this.client).patch({
|
|
17818
|
+
url: "/project/{projectID}",
|
|
17819
|
+
...options,
|
|
17820
|
+
...params,
|
|
17821
|
+
headers: {
|
|
17822
|
+
"Content-Type": "application/json",
|
|
17823
|
+
...options?.headers,
|
|
17824
|
+
...params.headers,
|
|
17825
|
+
},
|
|
17629
17826
|
});
|
|
17630
17827
|
}
|
|
17631
17828
|
}
|
|
17632
|
-
class
|
|
17829
|
+
class Pty extends HeyApiClient {
|
|
17633
17830
|
/**
|
|
17634
|
-
*
|
|
17831
|
+
* List PTY sessions
|
|
17832
|
+
*
|
|
17833
|
+
* Get a list of all active pseudo-terminal (PTY) sessions managed by OpenCode.
|
|
17635
17834
|
*/
|
|
17636
|
-
|
|
17637
|
-
|
|
17638
|
-
|
|
17835
|
+
list(parameters, options) {
|
|
17836
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
17837
|
+
return (options?.client ?? this.client).get({
|
|
17838
|
+
url: "/pty",
|
|
17839
|
+
...options,
|
|
17840
|
+
...params,
|
|
17841
|
+
});
|
|
17842
|
+
}
|
|
17843
|
+
/**
|
|
17844
|
+
* Create PTY session
|
|
17845
|
+
*
|
|
17846
|
+
* Create a new pseudo-terminal (PTY) session for running shell commands and processes.
|
|
17847
|
+
*/
|
|
17848
|
+
create(parameters, options) {
|
|
17849
|
+
const params = buildClientParams([parameters], [
|
|
17850
|
+
{
|
|
17851
|
+
args: [
|
|
17852
|
+
{ in: "query", key: "directory" },
|
|
17853
|
+
{ in: "body", key: "command" },
|
|
17854
|
+
{ in: "body", key: "args" },
|
|
17855
|
+
{ in: "body", key: "cwd" },
|
|
17856
|
+
{ in: "body", key: "title" },
|
|
17857
|
+
{ in: "body", key: "env" },
|
|
17858
|
+
],
|
|
17859
|
+
},
|
|
17860
|
+
]);
|
|
17861
|
+
return (options?.client ?? this.client).post({
|
|
17862
|
+
url: "/pty",
|
|
17863
|
+
...options,
|
|
17864
|
+
...params,
|
|
17865
|
+
headers: {
|
|
17866
|
+
"Content-Type": "application/json",
|
|
17867
|
+
...options?.headers,
|
|
17868
|
+
...params.headers,
|
|
17869
|
+
},
|
|
17870
|
+
});
|
|
17871
|
+
}
|
|
17872
|
+
/**
|
|
17873
|
+
* Remove PTY session
|
|
17874
|
+
*
|
|
17875
|
+
* Remove and terminate a specific pseudo-terminal (PTY) session.
|
|
17876
|
+
*/
|
|
17877
|
+
remove(parameters, options) {
|
|
17878
|
+
const params = buildClientParams([parameters], [
|
|
17879
|
+
{
|
|
17880
|
+
args: [
|
|
17881
|
+
{ in: "path", key: "ptyID" },
|
|
17882
|
+
{ in: "query", key: "directory" },
|
|
17883
|
+
],
|
|
17884
|
+
},
|
|
17885
|
+
]);
|
|
17886
|
+
return (options?.client ?? this.client).delete({
|
|
17887
|
+
url: "/pty/{ptyID}",
|
|
17888
|
+
...options,
|
|
17889
|
+
...params,
|
|
17890
|
+
});
|
|
17891
|
+
}
|
|
17892
|
+
/**
|
|
17893
|
+
* Get PTY session
|
|
17894
|
+
*
|
|
17895
|
+
* Retrieve detailed information about a specific pseudo-terminal (PTY) session.
|
|
17896
|
+
*/
|
|
17897
|
+
get(parameters, options) {
|
|
17898
|
+
const params = buildClientParams([parameters], [
|
|
17899
|
+
{
|
|
17900
|
+
args: [
|
|
17901
|
+
{ in: "path", key: "ptyID" },
|
|
17902
|
+
{ in: "query", key: "directory" },
|
|
17903
|
+
],
|
|
17904
|
+
},
|
|
17905
|
+
]);
|
|
17906
|
+
return (options?.client ?? this.client).get({
|
|
17907
|
+
url: "/pty/{ptyID}",
|
|
17908
|
+
...options,
|
|
17909
|
+
...params,
|
|
17910
|
+
});
|
|
17911
|
+
}
|
|
17912
|
+
/**
|
|
17913
|
+
* Update PTY session
|
|
17914
|
+
*
|
|
17915
|
+
* Update properties of an existing pseudo-terminal (PTY) session.
|
|
17916
|
+
*/
|
|
17917
|
+
update(parameters, options) {
|
|
17918
|
+
const params = buildClientParams([parameters], [
|
|
17919
|
+
{
|
|
17920
|
+
args: [
|
|
17921
|
+
{ in: "path", key: "ptyID" },
|
|
17922
|
+
{ in: "query", key: "directory" },
|
|
17923
|
+
{ in: "body", key: "title" },
|
|
17924
|
+
{ in: "body", key: "size" },
|
|
17925
|
+
],
|
|
17926
|
+
},
|
|
17927
|
+
]);
|
|
17928
|
+
return (options?.client ?? this.client).put({
|
|
17929
|
+
url: "/pty/{ptyID}",
|
|
17639
17930
|
...options,
|
|
17931
|
+
...params,
|
|
17932
|
+
headers: {
|
|
17933
|
+
"Content-Type": "application/json",
|
|
17934
|
+
...options?.headers,
|
|
17935
|
+
...params.headers,
|
|
17936
|
+
},
|
|
17640
17937
|
});
|
|
17641
17938
|
}
|
|
17642
17939
|
/**
|
|
17643
|
-
*
|
|
17940
|
+
* Connect to PTY session
|
|
17941
|
+
*
|
|
17942
|
+
* Establish a WebSocket connection to interact with a pseudo-terminal (PTY) session in real-time.
|
|
17943
|
+
*/
|
|
17944
|
+
connect(parameters, options) {
|
|
17945
|
+
const params = buildClientParams([parameters], [
|
|
17946
|
+
{
|
|
17947
|
+
args: [
|
|
17948
|
+
{ in: "path", key: "ptyID" },
|
|
17949
|
+
{ in: "query", key: "directory" },
|
|
17950
|
+
],
|
|
17951
|
+
},
|
|
17952
|
+
]);
|
|
17953
|
+
return (options?.client ?? this.client).get({
|
|
17954
|
+
url: "/pty/{ptyID}/connect",
|
|
17955
|
+
...options,
|
|
17956
|
+
...params,
|
|
17957
|
+
});
|
|
17958
|
+
}
|
|
17959
|
+
}
|
|
17960
|
+
class Config2 extends HeyApiClient {
|
|
17961
|
+
/**
|
|
17962
|
+
* Get configuration
|
|
17963
|
+
*
|
|
17964
|
+
* Retrieve the current OpenCode configuration settings and preferences.
|
|
17644
17965
|
*/
|
|
17645
|
-
|
|
17646
|
-
|
|
17966
|
+
get(parameters, options) {
|
|
17967
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
17968
|
+
return (options?.client ?? this.client).get({
|
|
17647
17969
|
url: "/config",
|
|
17648
17970
|
...options,
|
|
17971
|
+
...params,
|
|
17972
|
+
});
|
|
17973
|
+
}
|
|
17974
|
+
/**
|
|
17975
|
+
* Update configuration
|
|
17976
|
+
*
|
|
17977
|
+
* Update OpenCode configuration settings and preferences.
|
|
17978
|
+
*/
|
|
17979
|
+
update(parameters, options) {
|
|
17980
|
+
const params = buildClientParams([parameters], [
|
|
17981
|
+
{
|
|
17982
|
+
args: [
|
|
17983
|
+
{ in: "query", key: "directory" },
|
|
17984
|
+
{ key: "config", map: "body" },
|
|
17985
|
+
],
|
|
17986
|
+
},
|
|
17987
|
+
]);
|
|
17988
|
+
return (options?.client ?? this.client).patch({
|
|
17989
|
+
url: "/config",
|
|
17990
|
+
...options,
|
|
17991
|
+
...params,
|
|
17649
17992
|
headers: {
|
|
17650
17993
|
"Content-Type": "application/json",
|
|
17651
17994
|
...options?.headers,
|
|
17995
|
+
...params.headers,
|
|
17652
17996
|
},
|
|
17653
17997
|
});
|
|
17654
17998
|
}
|
|
17655
17999
|
/**
|
|
17656
|
-
* List
|
|
18000
|
+
* List config providers
|
|
18001
|
+
*
|
|
18002
|
+
* Get a list of all configured AI providers and their default models.
|
|
17657
18003
|
*/
|
|
17658
|
-
providers(options) {
|
|
17659
|
-
|
|
18004
|
+
providers(parameters, options) {
|
|
18005
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18006
|
+
return (options?.client ?? this.client).get({
|
|
17660
18007
|
url: "/config/providers",
|
|
17661
18008
|
...options,
|
|
18009
|
+
...params,
|
|
17662
18010
|
});
|
|
17663
18011
|
}
|
|
17664
18012
|
}
|
|
17665
|
-
class Tool extends
|
|
18013
|
+
class Tool extends HeyApiClient {
|
|
17666
18014
|
/**
|
|
17667
|
-
* List
|
|
18015
|
+
* List tool IDs
|
|
18016
|
+
*
|
|
18017
|
+
* Get a list of all available tool IDs, including both built-in tools and dynamically registered tools.
|
|
17668
18018
|
*/
|
|
17669
|
-
ids(options) {
|
|
17670
|
-
|
|
18019
|
+
ids(parameters, options) {
|
|
18020
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18021
|
+
return (options?.client ?? this.client).get({
|
|
17671
18022
|
url: "/experimental/tool/ids",
|
|
17672
18023
|
...options,
|
|
18024
|
+
...params,
|
|
17673
18025
|
});
|
|
17674
18026
|
}
|
|
17675
18027
|
/**
|
|
17676
|
-
* List tools
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
18028
|
+
* List tools
|
|
18029
|
+
*
|
|
18030
|
+
* Get a list of available tools with their JSON schema parameters for a specific provider and model combination.
|
|
18031
|
+
*/
|
|
18032
|
+
list(parameters, options) {
|
|
18033
|
+
const params = buildClientParams([parameters], [
|
|
18034
|
+
{
|
|
18035
|
+
args: [
|
|
18036
|
+
{ in: "query", key: "directory" },
|
|
18037
|
+
{ in: "query", key: "provider" },
|
|
18038
|
+
{ in: "query", key: "model" },
|
|
18039
|
+
],
|
|
18040
|
+
},
|
|
18041
|
+
]);
|
|
18042
|
+
return (options?.client ?? this.client).get({
|
|
17680
18043
|
url: "/experimental/tool",
|
|
17681
18044
|
...options,
|
|
18045
|
+
...params,
|
|
17682
18046
|
});
|
|
17683
18047
|
}
|
|
17684
18048
|
}
|
|
17685
|
-
class
|
|
18049
|
+
class Worktree extends HeyApiClient {
|
|
17686
18050
|
/**
|
|
17687
|
-
*
|
|
17688
|
-
|
|
17689
|
-
|
|
17690
|
-
|
|
17691
|
-
|
|
18051
|
+
* Remove worktree
|
|
18052
|
+
*
|
|
18053
|
+
* Remove a git worktree and delete its branch.
|
|
18054
|
+
*/
|
|
18055
|
+
remove(parameters, options) {
|
|
18056
|
+
const params = buildClientParams([parameters], [
|
|
18057
|
+
{
|
|
18058
|
+
args: [
|
|
18059
|
+
{ in: "query", key: "directory" },
|
|
18060
|
+
{ key: "worktreeRemoveInput", map: "body" },
|
|
18061
|
+
],
|
|
18062
|
+
},
|
|
18063
|
+
]);
|
|
18064
|
+
return (options?.client ?? this.client).delete({
|
|
18065
|
+
url: "/experimental/worktree",
|
|
17692
18066
|
...options,
|
|
18067
|
+
...params,
|
|
18068
|
+
headers: {
|
|
18069
|
+
"Content-Type": "application/json",
|
|
18070
|
+
...options?.headers,
|
|
18071
|
+
...params.headers,
|
|
18072
|
+
},
|
|
17693
18073
|
});
|
|
17694
18074
|
}
|
|
17695
|
-
}
|
|
17696
|
-
class Path extends _HeyApiClient {
|
|
17697
18075
|
/**
|
|
17698
|
-
*
|
|
18076
|
+
* List worktrees
|
|
18077
|
+
*
|
|
18078
|
+
* List all sandbox worktrees for the current project.
|
|
17699
18079
|
*/
|
|
17700
|
-
|
|
17701
|
-
|
|
17702
|
-
|
|
18080
|
+
list(parameters, options) {
|
|
18081
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18082
|
+
return (options?.client ?? this.client).get({
|
|
18083
|
+
url: "/experimental/worktree",
|
|
17703
18084
|
...options,
|
|
18085
|
+
...params,
|
|
18086
|
+
});
|
|
18087
|
+
}
|
|
18088
|
+
/**
|
|
18089
|
+
* Create worktree
|
|
18090
|
+
*
|
|
18091
|
+
* Create a new git worktree for the current project and run any configured startup scripts.
|
|
18092
|
+
*/
|
|
18093
|
+
create(parameters, options) {
|
|
18094
|
+
const params = buildClientParams([parameters], [
|
|
18095
|
+
{
|
|
18096
|
+
args: [
|
|
18097
|
+
{ in: "query", key: "directory" },
|
|
18098
|
+
{ key: "worktreeCreateInput", map: "body" },
|
|
18099
|
+
],
|
|
18100
|
+
},
|
|
18101
|
+
]);
|
|
18102
|
+
return (options?.client ?? this.client).post({
|
|
18103
|
+
url: "/experimental/worktree",
|
|
18104
|
+
...options,
|
|
18105
|
+
...params,
|
|
18106
|
+
headers: {
|
|
18107
|
+
"Content-Type": "application/json",
|
|
18108
|
+
...options?.headers,
|
|
18109
|
+
...params.headers,
|
|
18110
|
+
},
|
|
18111
|
+
});
|
|
18112
|
+
}
|
|
18113
|
+
/**
|
|
18114
|
+
* Reset worktree
|
|
18115
|
+
*
|
|
18116
|
+
* Reset a worktree branch to the primary default branch.
|
|
18117
|
+
*/
|
|
18118
|
+
reset(parameters, options) {
|
|
18119
|
+
const params = buildClientParams([parameters], [
|
|
18120
|
+
{
|
|
18121
|
+
args: [
|
|
18122
|
+
{ in: "query", key: "directory" },
|
|
18123
|
+
{ key: "worktreeResetInput", map: "body" },
|
|
18124
|
+
],
|
|
18125
|
+
},
|
|
18126
|
+
]);
|
|
18127
|
+
return (options?.client ?? this.client).post({
|
|
18128
|
+
url: "/experimental/worktree/reset",
|
|
18129
|
+
...options,
|
|
18130
|
+
...params,
|
|
18131
|
+
headers: {
|
|
18132
|
+
"Content-Type": "application/json",
|
|
18133
|
+
...options?.headers,
|
|
18134
|
+
...params.headers,
|
|
18135
|
+
},
|
|
17704
18136
|
});
|
|
17705
18137
|
}
|
|
17706
18138
|
}
|
|
17707
|
-
class
|
|
18139
|
+
class Resource extends HeyApiClient {
|
|
17708
18140
|
/**
|
|
17709
|
-
* Get
|
|
18141
|
+
* Get MCP resources
|
|
18142
|
+
*
|
|
18143
|
+
* Get all available MCP resources from connected servers. Optionally filter by name.
|
|
17710
18144
|
*/
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
|
|
18145
|
+
list(parameters, options) {
|
|
18146
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18147
|
+
return (options?.client ?? this.client).get({
|
|
18148
|
+
url: "/experimental/resource",
|
|
17714
18149
|
...options,
|
|
18150
|
+
...params,
|
|
17715
18151
|
});
|
|
17716
18152
|
}
|
|
17717
18153
|
}
|
|
17718
|
-
class
|
|
18154
|
+
class Experimental extends HeyApiClient {
|
|
18155
|
+
_resource;
|
|
18156
|
+
get resource() {
|
|
18157
|
+
return (this._resource ??= new Resource({ client: this.client }));
|
|
18158
|
+
}
|
|
18159
|
+
}
|
|
18160
|
+
class Session extends HeyApiClient {
|
|
17719
18161
|
/**
|
|
17720
|
-
* List
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
18162
|
+
* List sessions
|
|
18163
|
+
*
|
|
18164
|
+
* Get a list of all OpenCode sessions, sorted by most recently updated.
|
|
18165
|
+
*/
|
|
18166
|
+
list(parameters, options) {
|
|
18167
|
+
const params = buildClientParams([parameters], [
|
|
18168
|
+
{
|
|
18169
|
+
args: [
|
|
18170
|
+
{ in: "query", key: "directory" },
|
|
18171
|
+
{ in: "query", key: "roots" },
|
|
18172
|
+
{ in: "query", key: "start" },
|
|
18173
|
+
{ in: "query", key: "search" },
|
|
18174
|
+
{ in: "query", key: "limit" },
|
|
18175
|
+
],
|
|
18176
|
+
},
|
|
18177
|
+
]);
|
|
18178
|
+
return (options?.client ?? this.client).get({
|
|
17724
18179
|
url: "/session",
|
|
17725
18180
|
...options,
|
|
18181
|
+
...params,
|
|
17726
18182
|
});
|
|
17727
18183
|
}
|
|
17728
18184
|
/**
|
|
17729
|
-
* Create
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
18185
|
+
* Create session
|
|
18186
|
+
*
|
|
18187
|
+
* Create a new OpenCode session for interacting with AI assistants and managing conversations.
|
|
18188
|
+
*/
|
|
18189
|
+
create(parameters, options) {
|
|
18190
|
+
const params = buildClientParams([parameters], [
|
|
18191
|
+
{
|
|
18192
|
+
args: [
|
|
18193
|
+
{ in: "query", key: "directory" },
|
|
18194
|
+
{ in: "body", key: "parentID" },
|
|
18195
|
+
{ in: "body", key: "title" },
|
|
18196
|
+
{ in: "body", key: "permission" },
|
|
18197
|
+
],
|
|
18198
|
+
},
|
|
18199
|
+
]);
|
|
18200
|
+
return (options?.client ?? this.client).post({
|
|
17733
18201
|
url: "/session",
|
|
17734
18202
|
...options,
|
|
18203
|
+
...params,
|
|
17735
18204
|
headers: {
|
|
17736
18205
|
"Content-Type": "application/json",
|
|
17737
18206
|
...options?.headers,
|
|
18207
|
+
...params.headers,
|
|
17738
18208
|
},
|
|
17739
18209
|
});
|
|
17740
18210
|
}
|
|
17741
18211
|
/**
|
|
17742
18212
|
* Get session status
|
|
18213
|
+
*
|
|
18214
|
+
* Retrieve the current status of all sessions, including active, idle, and completed states.
|
|
17743
18215
|
*/
|
|
17744
|
-
status(options) {
|
|
17745
|
-
|
|
18216
|
+
status(parameters, options) {
|
|
18217
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18218
|
+
return (options?.client ?? this.client).get({
|
|
17746
18219
|
url: "/session/status",
|
|
17747
18220
|
...options,
|
|
18221
|
+
...params,
|
|
17748
18222
|
});
|
|
17749
18223
|
}
|
|
17750
18224
|
/**
|
|
17751
|
-
* Delete
|
|
17752
|
-
|
|
17753
|
-
|
|
17754
|
-
|
|
17755
|
-
|
|
18225
|
+
* Delete session
|
|
18226
|
+
*
|
|
18227
|
+
* Delete a session and permanently remove all associated data, including messages and history.
|
|
18228
|
+
*/
|
|
18229
|
+
delete(parameters, options) {
|
|
18230
|
+
const params = buildClientParams([parameters], [
|
|
18231
|
+
{
|
|
18232
|
+
args: [
|
|
18233
|
+
{ in: "path", key: "sessionID" },
|
|
18234
|
+
{ in: "query", key: "directory" },
|
|
18235
|
+
],
|
|
18236
|
+
},
|
|
18237
|
+
]);
|
|
18238
|
+
return (options?.client ?? this.client).delete({
|
|
18239
|
+
url: "/session/{sessionID}",
|
|
17756
18240
|
...options,
|
|
18241
|
+
...params,
|
|
17757
18242
|
});
|
|
17758
18243
|
}
|
|
17759
18244
|
/**
|
|
17760
18245
|
* Get session
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
-
|
|
18246
|
+
*
|
|
18247
|
+
* Retrieve detailed information about a specific OpenCode session.
|
|
18248
|
+
*/
|
|
18249
|
+
get(parameters, options) {
|
|
18250
|
+
const params = buildClientParams([parameters], [
|
|
18251
|
+
{
|
|
18252
|
+
args: [
|
|
18253
|
+
{ in: "path", key: "sessionID" },
|
|
18254
|
+
{ in: "query", key: "directory" },
|
|
18255
|
+
],
|
|
18256
|
+
},
|
|
18257
|
+
]);
|
|
18258
|
+
return (options?.client ?? this.client).get({
|
|
18259
|
+
url: "/session/{sessionID}",
|
|
17765
18260
|
...options,
|
|
18261
|
+
...params,
|
|
17766
18262
|
});
|
|
17767
18263
|
}
|
|
17768
18264
|
/**
|
|
17769
|
-
* Update session
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
|
|
18265
|
+
* Update session
|
|
18266
|
+
*
|
|
18267
|
+
* Update properties of an existing session, such as title or other metadata.
|
|
18268
|
+
*/
|
|
18269
|
+
update(parameters, options) {
|
|
18270
|
+
const params = buildClientParams([parameters], [
|
|
18271
|
+
{
|
|
18272
|
+
args: [
|
|
18273
|
+
{ in: "path", key: "sessionID" },
|
|
18274
|
+
{ in: "query", key: "directory" },
|
|
18275
|
+
{ in: "body", key: "title" },
|
|
18276
|
+
{ in: "body", key: "time" },
|
|
18277
|
+
],
|
|
18278
|
+
},
|
|
18279
|
+
]);
|
|
18280
|
+
return (options?.client ?? this.client).patch({
|
|
18281
|
+
url: "/session/{sessionID}",
|
|
17774
18282
|
...options,
|
|
18283
|
+
...params,
|
|
17775
18284
|
headers: {
|
|
17776
18285
|
"Content-Type": "application/json",
|
|
17777
|
-
...options
|
|
18286
|
+
...options?.headers,
|
|
18287
|
+
...params.headers,
|
|
17778
18288
|
},
|
|
17779
18289
|
});
|
|
17780
18290
|
}
|
|
17781
18291
|
/**
|
|
17782
|
-
* Get
|
|
17783
|
-
|
|
17784
|
-
|
|
17785
|
-
|
|
17786
|
-
|
|
18292
|
+
* Get session children
|
|
18293
|
+
*
|
|
18294
|
+
* Retrieve all child sessions that were forked from the specified parent session.
|
|
18295
|
+
*/
|
|
18296
|
+
children(parameters, options) {
|
|
18297
|
+
const params = buildClientParams([parameters], [
|
|
18298
|
+
{
|
|
18299
|
+
args: [
|
|
18300
|
+
{ in: "path", key: "sessionID" },
|
|
18301
|
+
{ in: "query", key: "directory" },
|
|
18302
|
+
],
|
|
18303
|
+
},
|
|
18304
|
+
]);
|
|
18305
|
+
return (options?.client ?? this.client).get({
|
|
18306
|
+
url: "/session/{sessionID}/children",
|
|
17787
18307
|
...options,
|
|
18308
|
+
...params,
|
|
17788
18309
|
});
|
|
17789
18310
|
}
|
|
17790
18311
|
/**
|
|
17791
|
-
* Get
|
|
17792
|
-
|
|
17793
|
-
|
|
17794
|
-
|
|
17795
|
-
|
|
18312
|
+
* Get session todos
|
|
18313
|
+
*
|
|
18314
|
+
* Retrieve the todo list associated with a specific session, showing tasks and action items.
|
|
18315
|
+
*/
|
|
18316
|
+
todo(parameters, options) {
|
|
18317
|
+
const params = buildClientParams([parameters], [
|
|
18318
|
+
{
|
|
18319
|
+
args: [
|
|
18320
|
+
{ in: "path", key: "sessionID" },
|
|
18321
|
+
{ in: "query", key: "directory" },
|
|
18322
|
+
],
|
|
18323
|
+
},
|
|
18324
|
+
]);
|
|
18325
|
+
return (options?.client ?? this.client).get({
|
|
18326
|
+
url: "/session/{sessionID}/todo",
|
|
17796
18327
|
...options,
|
|
18328
|
+
...params,
|
|
17797
18329
|
});
|
|
17798
18330
|
}
|
|
17799
18331
|
/**
|
|
17800
|
-
*
|
|
17801
|
-
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
18332
|
+
* Initialize session
|
|
18333
|
+
*
|
|
18334
|
+
* Analyze the current application and create an AGENTS.md file with project-specific agent configurations.
|
|
18335
|
+
*/
|
|
18336
|
+
init(parameters, options) {
|
|
18337
|
+
const params = buildClientParams([parameters], [
|
|
18338
|
+
{
|
|
18339
|
+
args: [
|
|
18340
|
+
{ in: "path", key: "sessionID" },
|
|
18341
|
+
{ in: "query", key: "directory" },
|
|
18342
|
+
{ in: "body", key: "modelID" },
|
|
18343
|
+
{ in: "body", key: "providerID" },
|
|
18344
|
+
{ in: "body", key: "messageID" },
|
|
18345
|
+
],
|
|
18346
|
+
},
|
|
18347
|
+
]);
|
|
18348
|
+
return (options?.client ?? this.client).post({
|
|
18349
|
+
url: "/session/{sessionID}/init",
|
|
17805
18350
|
...options,
|
|
18351
|
+
...params,
|
|
17806
18352
|
headers: {
|
|
17807
18353
|
"Content-Type": "application/json",
|
|
17808
|
-
...options
|
|
18354
|
+
...options?.headers,
|
|
18355
|
+
...params.headers,
|
|
17809
18356
|
},
|
|
17810
18357
|
});
|
|
17811
18358
|
}
|
|
17812
18359
|
/**
|
|
17813
|
-
* Fork
|
|
17814
|
-
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
|
|
18360
|
+
* Fork session
|
|
18361
|
+
*
|
|
18362
|
+
* Create a new session by forking an existing session at a specific message point.
|
|
18363
|
+
*/
|
|
18364
|
+
fork(parameters, options) {
|
|
18365
|
+
const params = buildClientParams([parameters], [
|
|
18366
|
+
{
|
|
18367
|
+
args: [
|
|
18368
|
+
{ in: "path", key: "sessionID" },
|
|
18369
|
+
{ in: "query", key: "directory" },
|
|
18370
|
+
{ in: "body", key: "messageID" },
|
|
18371
|
+
],
|
|
18372
|
+
},
|
|
18373
|
+
]);
|
|
18374
|
+
return (options?.client ?? this.client).post({
|
|
18375
|
+
url: "/session/{sessionID}/fork",
|
|
17818
18376
|
...options,
|
|
18377
|
+
...params,
|
|
17819
18378
|
headers: {
|
|
17820
18379
|
"Content-Type": "application/json",
|
|
17821
|
-
...options
|
|
18380
|
+
...options?.headers,
|
|
18381
|
+
...params.headers,
|
|
17822
18382
|
},
|
|
17823
18383
|
});
|
|
17824
18384
|
}
|
|
17825
18385
|
/**
|
|
17826
|
-
* Abort
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
18386
|
+
* Abort session
|
|
18387
|
+
*
|
|
18388
|
+
* Abort an active session and stop any ongoing AI processing or command execution.
|
|
18389
|
+
*/
|
|
18390
|
+
abort(parameters, options) {
|
|
18391
|
+
const params = buildClientParams([parameters], [
|
|
18392
|
+
{
|
|
18393
|
+
args: [
|
|
18394
|
+
{ in: "path", key: "sessionID" },
|
|
18395
|
+
{ in: "query", key: "directory" },
|
|
18396
|
+
],
|
|
18397
|
+
},
|
|
18398
|
+
]);
|
|
18399
|
+
return (options?.client ?? this.client).post({
|
|
18400
|
+
url: "/session/{sessionID}/abort",
|
|
17831
18401
|
...options,
|
|
18402
|
+
...params,
|
|
17832
18403
|
});
|
|
17833
18404
|
}
|
|
17834
18405
|
/**
|
|
17835
|
-
* Unshare
|
|
17836
|
-
|
|
17837
|
-
|
|
17838
|
-
|
|
17839
|
-
|
|
18406
|
+
* Unshare session
|
|
18407
|
+
*
|
|
18408
|
+
* Remove the shareable link for a session, making it private again.
|
|
18409
|
+
*/
|
|
18410
|
+
unshare(parameters, options) {
|
|
18411
|
+
const params = buildClientParams([parameters], [
|
|
18412
|
+
{
|
|
18413
|
+
args: [
|
|
18414
|
+
{ in: "path", key: "sessionID" },
|
|
18415
|
+
{ in: "query", key: "directory" },
|
|
18416
|
+
],
|
|
18417
|
+
},
|
|
18418
|
+
]);
|
|
18419
|
+
return (options?.client ?? this.client).delete({
|
|
18420
|
+
url: "/session/{sessionID}/share",
|
|
17840
18421
|
...options,
|
|
18422
|
+
...params,
|
|
17841
18423
|
});
|
|
17842
18424
|
}
|
|
17843
18425
|
/**
|
|
17844
|
-
* Share
|
|
17845
|
-
|
|
17846
|
-
|
|
17847
|
-
|
|
17848
|
-
|
|
18426
|
+
* Share session
|
|
18427
|
+
*
|
|
18428
|
+
* Create a shareable link for a session, allowing others to view the conversation.
|
|
18429
|
+
*/
|
|
18430
|
+
share(parameters, options) {
|
|
18431
|
+
const params = buildClientParams([parameters], [
|
|
18432
|
+
{
|
|
18433
|
+
args: [
|
|
18434
|
+
{ in: "path", key: "sessionID" },
|
|
18435
|
+
{ in: "query", key: "directory" },
|
|
18436
|
+
],
|
|
18437
|
+
},
|
|
18438
|
+
]);
|
|
18439
|
+
return (options?.client ?? this.client).post({
|
|
18440
|
+
url: "/session/{sessionID}/share",
|
|
17849
18441
|
...options,
|
|
18442
|
+
...params,
|
|
17850
18443
|
});
|
|
17851
18444
|
}
|
|
17852
18445
|
/**
|
|
17853
|
-
* Get
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
|
|
17857
|
-
|
|
18446
|
+
* Get message diff
|
|
18447
|
+
*
|
|
18448
|
+
* Get the file changes (diff) that resulted from a specific user message in the session.
|
|
18449
|
+
*/
|
|
18450
|
+
diff(parameters, options) {
|
|
18451
|
+
const params = buildClientParams([parameters], [
|
|
18452
|
+
{
|
|
18453
|
+
args: [
|
|
18454
|
+
{ in: "path", key: "sessionID" },
|
|
18455
|
+
{ in: "query", key: "directory" },
|
|
18456
|
+
{ in: "query", key: "messageID" },
|
|
18457
|
+
],
|
|
18458
|
+
},
|
|
18459
|
+
]);
|
|
18460
|
+
return (options?.client ?? this.client).get({
|
|
18461
|
+
url: "/session/{sessionID}/diff",
|
|
17858
18462
|
...options,
|
|
18463
|
+
...params,
|
|
17859
18464
|
});
|
|
17860
18465
|
}
|
|
17861
18466
|
/**
|
|
17862
|
-
* Summarize
|
|
17863
|
-
|
|
17864
|
-
|
|
17865
|
-
|
|
17866
|
-
|
|
18467
|
+
* Summarize session
|
|
18468
|
+
*
|
|
18469
|
+
* Generate a concise summary of the session using AI compaction to preserve key information.
|
|
18470
|
+
*/
|
|
18471
|
+
summarize(parameters, options) {
|
|
18472
|
+
const params = buildClientParams([parameters], [
|
|
18473
|
+
{
|
|
18474
|
+
args: [
|
|
18475
|
+
{ in: "path", key: "sessionID" },
|
|
18476
|
+
{ in: "query", key: "directory" },
|
|
18477
|
+
{ in: "body", key: "providerID" },
|
|
18478
|
+
{ in: "body", key: "modelID" },
|
|
18479
|
+
{ in: "body", key: "auto" },
|
|
18480
|
+
],
|
|
18481
|
+
},
|
|
18482
|
+
]);
|
|
18483
|
+
return (options?.client ?? this.client).post({
|
|
18484
|
+
url: "/session/{sessionID}/summarize",
|
|
17867
18485
|
...options,
|
|
18486
|
+
...params,
|
|
17868
18487
|
headers: {
|
|
17869
18488
|
"Content-Type": "application/json",
|
|
17870
|
-
...options
|
|
18489
|
+
...options?.headers,
|
|
18490
|
+
...params.headers,
|
|
17871
18491
|
},
|
|
17872
18492
|
});
|
|
17873
18493
|
}
|
|
17874
18494
|
/**
|
|
17875
|
-
*
|
|
17876
|
-
|
|
17877
|
-
|
|
17878
|
-
|
|
17879
|
-
|
|
18495
|
+
* Get session messages
|
|
18496
|
+
*
|
|
18497
|
+
* Retrieve all messages in a session, including user prompts and AI responses.
|
|
18498
|
+
*/
|
|
18499
|
+
messages(parameters, options) {
|
|
18500
|
+
const params = buildClientParams([parameters], [
|
|
18501
|
+
{
|
|
18502
|
+
args: [
|
|
18503
|
+
{ in: "path", key: "sessionID" },
|
|
18504
|
+
{ in: "query", key: "directory" },
|
|
18505
|
+
{ in: "query", key: "limit" },
|
|
18506
|
+
],
|
|
18507
|
+
},
|
|
18508
|
+
]);
|
|
18509
|
+
return (options?.client ?? this.client).get({
|
|
18510
|
+
url: "/session/{sessionID}/message",
|
|
17880
18511
|
...options,
|
|
18512
|
+
...params,
|
|
17881
18513
|
});
|
|
17882
18514
|
}
|
|
17883
18515
|
/**
|
|
17884
|
-
*
|
|
17885
|
-
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
18516
|
+
* Send message
|
|
18517
|
+
*
|
|
18518
|
+
* Create and send a new message to a session, streaming the AI response.
|
|
18519
|
+
*/
|
|
18520
|
+
prompt(parameters, options) {
|
|
18521
|
+
const params = buildClientParams([parameters], [
|
|
18522
|
+
{
|
|
18523
|
+
args: [
|
|
18524
|
+
{ in: "path", key: "sessionID" },
|
|
18525
|
+
{ in: "query", key: "directory" },
|
|
18526
|
+
{ in: "body", key: "messageID" },
|
|
18527
|
+
{ in: "body", key: "model" },
|
|
18528
|
+
{ in: "body", key: "agent" },
|
|
18529
|
+
{ in: "body", key: "noReply" },
|
|
18530
|
+
{ in: "body", key: "tools" },
|
|
18531
|
+
{ in: "body", key: "system" },
|
|
18532
|
+
{ in: "body", key: "variant" },
|
|
18533
|
+
{ in: "body", key: "parts" },
|
|
18534
|
+
],
|
|
18535
|
+
},
|
|
18536
|
+
]);
|
|
18537
|
+
return (options?.client ?? this.client).post({
|
|
18538
|
+
url: "/session/{sessionID}/message",
|
|
17889
18539
|
...options,
|
|
18540
|
+
...params,
|
|
17890
18541
|
headers: {
|
|
17891
18542
|
"Content-Type": "application/json",
|
|
17892
|
-
...options
|
|
18543
|
+
...options?.headers,
|
|
18544
|
+
...params.headers,
|
|
17893
18545
|
},
|
|
17894
18546
|
});
|
|
17895
18547
|
}
|
|
17896
18548
|
/**
|
|
17897
|
-
* Get
|
|
17898
|
-
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
|
|
18549
|
+
* Get message
|
|
18550
|
+
*
|
|
18551
|
+
* Retrieve a specific message from a session by its message ID.
|
|
18552
|
+
*/
|
|
18553
|
+
message(parameters, options) {
|
|
18554
|
+
const params = buildClientParams([parameters], [
|
|
18555
|
+
{
|
|
18556
|
+
args: [
|
|
18557
|
+
{ in: "path", key: "sessionID" },
|
|
18558
|
+
{ in: "path", key: "messageID" },
|
|
18559
|
+
{ in: "query", key: "directory" },
|
|
18560
|
+
],
|
|
18561
|
+
},
|
|
18562
|
+
]);
|
|
18563
|
+
return (options?.client ?? this.client).get({
|
|
18564
|
+
url: "/session/{sessionID}/message/{messageID}",
|
|
17902
18565
|
...options,
|
|
18566
|
+
...params,
|
|
17903
18567
|
});
|
|
17904
18568
|
}
|
|
17905
18569
|
/**
|
|
17906
|
-
*
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
18570
|
+
* Send async message
|
|
18571
|
+
*
|
|
18572
|
+
* Create and send a new message to a session asynchronously, starting the session if needed and returning immediately.
|
|
18573
|
+
*/
|
|
18574
|
+
promptAsync(parameters, options) {
|
|
18575
|
+
const params = buildClientParams([parameters], [
|
|
18576
|
+
{
|
|
18577
|
+
args: [
|
|
18578
|
+
{ in: "path", key: "sessionID" },
|
|
18579
|
+
{ in: "query", key: "directory" },
|
|
18580
|
+
{ in: "body", key: "messageID" },
|
|
18581
|
+
{ in: "body", key: "model" },
|
|
18582
|
+
{ in: "body", key: "agent" },
|
|
18583
|
+
{ in: "body", key: "noReply" },
|
|
18584
|
+
{ in: "body", key: "tools" },
|
|
18585
|
+
{ in: "body", key: "system" },
|
|
18586
|
+
{ in: "body", key: "variant" },
|
|
18587
|
+
{ in: "body", key: "parts" },
|
|
18588
|
+
],
|
|
18589
|
+
},
|
|
18590
|
+
]);
|
|
18591
|
+
return (options?.client ?? this.client).post({
|
|
18592
|
+
url: "/session/{sessionID}/prompt_async",
|
|
17911
18593
|
...options,
|
|
18594
|
+
...params,
|
|
17912
18595
|
headers: {
|
|
17913
18596
|
"Content-Type": "application/json",
|
|
17914
|
-
...options
|
|
18597
|
+
...options?.headers,
|
|
18598
|
+
...params.headers,
|
|
17915
18599
|
},
|
|
17916
18600
|
});
|
|
17917
18601
|
}
|
|
17918
18602
|
/**
|
|
17919
|
-
* Send
|
|
17920
|
-
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
18603
|
+
* Send command
|
|
18604
|
+
*
|
|
18605
|
+
* Send a new command to a session for execution by the AI assistant.
|
|
18606
|
+
*/
|
|
18607
|
+
command(parameters, options) {
|
|
18608
|
+
const params = buildClientParams([parameters], [
|
|
18609
|
+
{
|
|
18610
|
+
args: [
|
|
18611
|
+
{ in: "path", key: "sessionID" },
|
|
18612
|
+
{ in: "query", key: "directory" },
|
|
18613
|
+
{ in: "body", key: "messageID" },
|
|
18614
|
+
{ in: "body", key: "agent" },
|
|
18615
|
+
{ in: "body", key: "model" },
|
|
18616
|
+
{ in: "body", key: "arguments" },
|
|
18617
|
+
{ in: "body", key: "command" },
|
|
18618
|
+
{ in: "body", key: "variant" },
|
|
18619
|
+
{ in: "body", key: "parts" },
|
|
18620
|
+
],
|
|
18621
|
+
},
|
|
18622
|
+
]);
|
|
18623
|
+
return (options?.client ?? this.client).post({
|
|
18624
|
+
url: "/session/{sessionID}/command",
|
|
17924
18625
|
...options,
|
|
18626
|
+
...params,
|
|
17925
18627
|
headers: {
|
|
17926
18628
|
"Content-Type": "application/json",
|
|
17927
|
-
...options
|
|
18629
|
+
...options?.headers,
|
|
18630
|
+
...params.headers,
|
|
17928
18631
|
},
|
|
17929
18632
|
});
|
|
17930
18633
|
}
|
|
17931
18634
|
/**
|
|
17932
|
-
* Run
|
|
17933
|
-
|
|
17934
|
-
|
|
17935
|
-
|
|
17936
|
-
|
|
18635
|
+
* Run shell command
|
|
18636
|
+
*
|
|
18637
|
+
* Execute a shell command within the session context and return the AI's response.
|
|
18638
|
+
*/
|
|
18639
|
+
shell(parameters, options) {
|
|
18640
|
+
const params = buildClientParams([parameters], [
|
|
18641
|
+
{
|
|
18642
|
+
args: [
|
|
18643
|
+
{ in: "path", key: "sessionID" },
|
|
18644
|
+
{ in: "query", key: "directory" },
|
|
18645
|
+
{ in: "body", key: "agent" },
|
|
18646
|
+
{ in: "body", key: "model" },
|
|
18647
|
+
{ in: "body", key: "command" },
|
|
18648
|
+
],
|
|
18649
|
+
},
|
|
18650
|
+
]);
|
|
18651
|
+
return (options?.client ?? this.client).post({
|
|
18652
|
+
url: "/session/{sessionID}/shell",
|
|
17937
18653
|
...options,
|
|
18654
|
+
...params,
|
|
17938
18655
|
headers: {
|
|
17939
18656
|
"Content-Type": "application/json",
|
|
17940
|
-
...options
|
|
18657
|
+
...options?.headers,
|
|
18658
|
+
...params.headers,
|
|
17941
18659
|
},
|
|
17942
18660
|
});
|
|
17943
18661
|
}
|
|
17944
18662
|
/**
|
|
17945
|
-
* Revert
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
|
|
18663
|
+
* Revert message
|
|
18664
|
+
*
|
|
18665
|
+
* Revert a specific message in a session, undoing its effects and restoring the previous state.
|
|
18666
|
+
*/
|
|
18667
|
+
revert(parameters, options) {
|
|
18668
|
+
const params = buildClientParams([parameters], [
|
|
18669
|
+
{
|
|
18670
|
+
args: [
|
|
18671
|
+
{ in: "path", key: "sessionID" },
|
|
18672
|
+
{ in: "query", key: "directory" },
|
|
18673
|
+
{ in: "body", key: "messageID" },
|
|
18674
|
+
{ in: "body", key: "partID" },
|
|
18675
|
+
],
|
|
18676
|
+
},
|
|
18677
|
+
]);
|
|
18678
|
+
return (options?.client ?? this.client).post({
|
|
18679
|
+
url: "/session/{sessionID}/revert",
|
|
17950
18680
|
...options,
|
|
18681
|
+
...params,
|
|
17951
18682
|
headers: {
|
|
17952
18683
|
"Content-Type": "application/json",
|
|
17953
|
-
...options
|
|
18684
|
+
...options?.headers,
|
|
18685
|
+
...params.headers,
|
|
17954
18686
|
},
|
|
17955
18687
|
});
|
|
17956
18688
|
}
|
|
17957
18689
|
/**
|
|
17958
|
-
* Restore
|
|
17959
|
-
|
|
17960
|
-
|
|
17961
|
-
|
|
17962
|
-
|
|
18690
|
+
* Restore reverted messages
|
|
18691
|
+
*
|
|
18692
|
+
* Restore all previously reverted messages in a session.
|
|
18693
|
+
*/
|
|
18694
|
+
unrevert(parameters, options) {
|
|
18695
|
+
const params = buildClientParams([parameters], [
|
|
18696
|
+
{
|
|
18697
|
+
args: [
|
|
18698
|
+
{ in: "path", key: "sessionID" },
|
|
18699
|
+
{ in: "query", key: "directory" },
|
|
18700
|
+
],
|
|
18701
|
+
},
|
|
18702
|
+
]);
|
|
18703
|
+
return (options?.client ?? this.client).post({
|
|
18704
|
+
url: "/session/{sessionID}/unrevert",
|
|
17963
18705
|
...options,
|
|
18706
|
+
...params,
|
|
17964
18707
|
});
|
|
17965
18708
|
}
|
|
17966
18709
|
}
|
|
17967
|
-
class
|
|
18710
|
+
class Part extends HeyApiClient {
|
|
18711
|
+
/**
|
|
18712
|
+
* Delete a part from a message
|
|
18713
|
+
*/
|
|
18714
|
+
delete(parameters, options) {
|
|
18715
|
+
const params = buildClientParams([parameters], [
|
|
18716
|
+
{
|
|
18717
|
+
args: [
|
|
18718
|
+
{ in: "path", key: "sessionID" },
|
|
18719
|
+
{ in: "path", key: "messageID" },
|
|
18720
|
+
{ in: "path", key: "partID" },
|
|
18721
|
+
{ in: "query", key: "directory" },
|
|
18722
|
+
],
|
|
18723
|
+
},
|
|
18724
|
+
]);
|
|
18725
|
+
return (options?.client ?? this.client).delete({
|
|
18726
|
+
url: "/session/{sessionID}/message/{messageID}/part/{partID}",
|
|
18727
|
+
...options,
|
|
18728
|
+
...params,
|
|
18729
|
+
});
|
|
18730
|
+
}
|
|
17968
18731
|
/**
|
|
17969
|
-
*
|
|
18732
|
+
* Update a part in a message
|
|
17970
18733
|
*/
|
|
17971
|
-
|
|
17972
|
-
|
|
17973
|
-
|
|
18734
|
+
update(parameters, options) {
|
|
18735
|
+
const params = buildClientParams([parameters], [
|
|
18736
|
+
{
|
|
18737
|
+
args: [
|
|
18738
|
+
{ in: "path", key: "sessionID" },
|
|
18739
|
+
{ in: "path", key: "messageID" },
|
|
18740
|
+
{ in: "path", key: "partID" },
|
|
18741
|
+
{ in: "query", key: "directory" },
|
|
18742
|
+
{ key: "part", map: "body" },
|
|
18743
|
+
],
|
|
18744
|
+
},
|
|
18745
|
+
]);
|
|
18746
|
+
return (options?.client ?? this.client).patch({
|
|
18747
|
+
url: "/session/{sessionID}/message/{messageID}/part/{partID}",
|
|
17974
18748
|
...options,
|
|
18749
|
+
...params,
|
|
18750
|
+
headers: {
|
|
18751
|
+
"Content-Type": "application/json",
|
|
18752
|
+
...options?.headers,
|
|
18753
|
+
...params.headers,
|
|
18754
|
+
},
|
|
17975
18755
|
});
|
|
17976
18756
|
}
|
|
17977
18757
|
}
|
|
17978
|
-
class
|
|
18758
|
+
class Permission extends HeyApiClient {
|
|
17979
18759
|
/**
|
|
17980
|
-
*
|
|
18760
|
+
* Respond to permission
|
|
18761
|
+
*
|
|
18762
|
+
* Approve or deny a permission request from the AI assistant.
|
|
18763
|
+
*
|
|
18764
|
+
* @deprecated
|
|
17981
18765
|
*/
|
|
17982
|
-
|
|
17983
|
-
|
|
17984
|
-
|
|
18766
|
+
respond(parameters, options) {
|
|
18767
|
+
const params = buildClientParams([parameters], [
|
|
18768
|
+
{
|
|
18769
|
+
args: [
|
|
18770
|
+
{ in: "path", key: "sessionID" },
|
|
18771
|
+
{ in: "path", key: "permissionID" },
|
|
18772
|
+
{ in: "query", key: "directory" },
|
|
18773
|
+
{ in: "body", key: "response" },
|
|
18774
|
+
],
|
|
18775
|
+
},
|
|
18776
|
+
]);
|
|
18777
|
+
return (options?.client ?? this.client).post({
|
|
18778
|
+
url: "/session/{sessionID}/permissions/{permissionID}",
|
|
17985
18779
|
...options,
|
|
18780
|
+
...params,
|
|
17986
18781
|
headers: {
|
|
17987
18782
|
"Content-Type": "application/json",
|
|
17988
|
-
...options
|
|
18783
|
+
...options?.headers,
|
|
18784
|
+
...params.headers,
|
|
17989
18785
|
},
|
|
17990
18786
|
});
|
|
17991
18787
|
}
|
|
17992
18788
|
/**
|
|
17993
|
-
*
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
18789
|
+
* Respond to permission request
|
|
18790
|
+
*
|
|
18791
|
+
* Approve or deny a permission request from the AI assistant.
|
|
18792
|
+
*/
|
|
18793
|
+
reply(parameters, options) {
|
|
18794
|
+
const params = buildClientParams([parameters], [
|
|
18795
|
+
{
|
|
18796
|
+
args: [
|
|
18797
|
+
{ in: "path", key: "requestID" },
|
|
18798
|
+
{ in: "query", key: "directory" },
|
|
18799
|
+
{ in: "body", key: "reply" },
|
|
18800
|
+
{ in: "body", key: "message" },
|
|
18801
|
+
],
|
|
18802
|
+
},
|
|
18803
|
+
]);
|
|
18804
|
+
return (options?.client ?? this.client).post({
|
|
18805
|
+
url: "/permission/{requestID}/reply",
|
|
17998
18806
|
...options,
|
|
18807
|
+
...params,
|
|
17999
18808
|
headers: {
|
|
18000
18809
|
"Content-Type": "application/json",
|
|
18001
|
-
...options
|
|
18810
|
+
...options?.headers,
|
|
18811
|
+
...params.headers,
|
|
18002
18812
|
},
|
|
18003
18813
|
});
|
|
18004
18814
|
}
|
|
18005
|
-
}
|
|
18006
|
-
class Provider extends _HeyApiClient {
|
|
18007
18815
|
/**
|
|
18008
|
-
* List
|
|
18816
|
+
* List pending permissions
|
|
18817
|
+
*
|
|
18818
|
+
* Get all pending permission requests across all sessions.
|
|
18009
18819
|
*/
|
|
18010
|
-
list(options) {
|
|
18011
|
-
|
|
18012
|
-
|
|
18820
|
+
list(parameters, options) {
|
|
18821
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18822
|
+
return (options?.client ?? this.client).get({
|
|
18823
|
+
url: "/permission",
|
|
18013
18824
|
...options,
|
|
18825
|
+
...params,
|
|
18014
18826
|
});
|
|
18015
18827
|
}
|
|
18828
|
+
}
|
|
18829
|
+
class Question extends HeyApiClient {
|
|
18016
18830
|
/**
|
|
18017
|
-
*
|
|
18831
|
+
* List pending questions
|
|
18832
|
+
*
|
|
18833
|
+
* Get all pending question requests across all sessions.
|
|
18018
18834
|
*/
|
|
18019
|
-
|
|
18020
|
-
|
|
18021
|
-
|
|
18835
|
+
list(parameters, options) {
|
|
18836
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18837
|
+
return (options?.client ?? this.client).get({
|
|
18838
|
+
url: "/question",
|
|
18022
18839
|
...options,
|
|
18840
|
+
...params,
|
|
18841
|
+
});
|
|
18842
|
+
}
|
|
18843
|
+
/**
|
|
18844
|
+
* Reply to question request
|
|
18845
|
+
*
|
|
18846
|
+
* Provide answers to a question request from the AI assistant.
|
|
18847
|
+
*/
|
|
18848
|
+
reply(parameters, options) {
|
|
18849
|
+
const params = buildClientParams([parameters], [
|
|
18850
|
+
{
|
|
18851
|
+
args: [
|
|
18852
|
+
{ in: "path", key: "requestID" },
|
|
18853
|
+
{ in: "query", key: "directory" },
|
|
18854
|
+
{ in: "body", key: "answers" },
|
|
18855
|
+
],
|
|
18856
|
+
},
|
|
18857
|
+
]);
|
|
18858
|
+
return (options?.client ?? this.client).post({
|
|
18859
|
+
url: "/question/{requestID}/reply",
|
|
18860
|
+
...options,
|
|
18861
|
+
...params,
|
|
18862
|
+
headers: {
|
|
18863
|
+
"Content-Type": "application/json",
|
|
18864
|
+
...options?.headers,
|
|
18865
|
+
...params.headers,
|
|
18866
|
+
},
|
|
18867
|
+
});
|
|
18868
|
+
}
|
|
18869
|
+
/**
|
|
18870
|
+
* Reject question request
|
|
18871
|
+
*
|
|
18872
|
+
* Reject a question request from the AI assistant.
|
|
18873
|
+
*/
|
|
18874
|
+
reject(parameters, options) {
|
|
18875
|
+
const params = buildClientParams([parameters], [
|
|
18876
|
+
{
|
|
18877
|
+
args: [
|
|
18878
|
+
{ in: "path", key: "requestID" },
|
|
18879
|
+
{ in: "query", key: "directory" },
|
|
18880
|
+
],
|
|
18881
|
+
},
|
|
18882
|
+
]);
|
|
18883
|
+
return (options?.client ?? this.client).post({
|
|
18884
|
+
url: "/question/{requestID}/reject",
|
|
18885
|
+
...options,
|
|
18886
|
+
...params,
|
|
18023
18887
|
});
|
|
18024
18888
|
}
|
|
18025
|
-
oauth = new Oauth({ client: this._client });
|
|
18026
18889
|
}
|
|
18027
|
-
class
|
|
18890
|
+
class Oauth extends HeyApiClient {
|
|
18028
18891
|
/**
|
|
18029
|
-
*
|
|
18030
|
-
|
|
18031
|
-
|
|
18032
|
-
|
|
18033
|
-
|
|
18892
|
+
* OAuth authorize
|
|
18893
|
+
*
|
|
18894
|
+
* Initiate OAuth authorization for a specific AI provider to get an authorization URL.
|
|
18895
|
+
*/
|
|
18896
|
+
authorize(parameters, options) {
|
|
18897
|
+
const params = buildClientParams([parameters], [
|
|
18898
|
+
{
|
|
18899
|
+
args: [
|
|
18900
|
+
{ in: "path", key: "providerID" },
|
|
18901
|
+
{ in: "query", key: "directory" },
|
|
18902
|
+
{ in: "body", key: "method" },
|
|
18903
|
+
],
|
|
18904
|
+
},
|
|
18905
|
+
]);
|
|
18906
|
+
return (options?.client ?? this.client).post({
|
|
18907
|
+
url: "/provider/{providerID}/oauth/authorize",
|
|
18034
18908
|
...options,
|
|
18909
|
+
...params,
|
|
18910
|
+
headers: {
|
|
18911
|
+
"Content-Type": "application/json",
|
|
18912
|
+
...options?.headers,
|
|
18913
|
+
...params.headers,
|
|
18914
|
+
},
|
|
18035
18915
|
});
|
|
18036
18916
|
}
|
|
18037
18917
|
/**
|
|
18038
|
-
*
|
|
18918
|
+
* OAuth callback
|
|
18919
|
+
*
|
|
18920
|
+
* Handle the OAuth callback from a provider after user authorization.
|
|
18921
|
+
*/
|
|
18922
|
+
callback(parameters, options) {
|
|
18923
|
+
const params = buildClientParams([parameters], [
|
|
18924
|
+
{
|
|
18925
|
+
args: [
|
|
18926
|
+
{ in: "path", key: "providerID" },
|
|
18927
|
+
{ in: "query", key: "directory" },
|
|
18928
|
+
{ in: "body", key: "method" },
|
|
18929
|
+
{ in: "body", key: "code" },
|
|
18930
|
+
],
|
|
18931
|
+
},
|
|
18932
|
+
]);
|
|
18933
|
+
return (options?.client ?? this.client).post({
|
|
18934
|
+
url: "/provider/{providerID}/oauth/callback",
|
|
18935
|
+
...options,
|
|
18936
|
+
...params,
|
|
18937
|
+
headers: {
|
|
18938
|
+
"Content-Type": "application/json",
|
|
18939
|
+
...options?.headers,
|
|
18940
|
+
...params.headers,
|
|
18941
|
+
},
|
|
18942
|
+
});
|
|
18943
|
+
}
|
|
18944
|
+
}
|
|
18945
|
+
class Provider extends HeyApiClient {
|
|
18946
|
+
/**
|
|
18947
|
+
* List providers
|
|
18948
|
+
*
|
|
18949
|
+
* Get a list of all available AI providers, including both available and connected ones.
|
|
18039
18950
|
*/
|
|
18040
|
-
|
|
18041
|
-
|
|
18042
|
-
|
|
18951
|
+
list(parameters, options) {
|
|
18952
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18953
|
+
return (options?.client ?? this.client).get({
|
|
18954
|
+
url: "/provider",
|
|
18043
18955
|
...options,
|
|
18956
|
+
...params,
|
|
18044
18957
|
});
|
|
18045
18958
|
}
|
|
18046
18959
|
/**
|
|
18047
|
-
*
|
|
18960
|
+
* Get provider auth methods
|
|
18961
|
+
*
|
|
18962
|
+
* Retrieve available authentication methods for all AI providers.
|
|
18048
18963
|
*/
|
|
18049
|
-
|
|
18050
|
-
|
|
18051
|
-
|
|
18964
|
+
auth(parameters, options) {
|
|
18965
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18966
|
+
return (options?.client ?? this.client).get({
|
|
18967
|
+
url: "/provider/auth",
|
|
18052
18968
|
...options,
|
|
18969
|
+
...params,
|
|
18053
18970
|
});
|
|
18054
18971
|
}
|
|
18972
|
+
_oauth;
|
|
18973
|
+
get oauth() {
|
|
18974
|
+
return (this._oauth ??= new Oauth({ client: this.client }));
|
|
18975
|
+
}
|
|
18055
18976
|
}
|
|
18056
|
-
class
|
|
18977
|
+
class Find extends HeyApiClient {
|
|
18057
18978
|
/**
|
|
18058
|
-
*
|
|
18059
|
-
|
|
18060
|
-
|
|
18061
|
-
|
|
18062
|
-
|
|
18979
|
+
* Find text
|
|
18980
|
+
*
|
|
18981
|
+
* Search for text patterns across files in the project using ripgrep.
|
|
18982
|
+
*/
|
|
18983
|
+
text(parameters, options) {
|
|
18984
|
+
const params = buildClientParams([parameters], [
|
|
18985
|
+
{
|
|
18986
|
+
args: [
|
|
18987
|
+
{ in: "query", key: "directory" },
|
|
18988
|
+
{ in: "query", key: "pattern" },
|
|
18989
|
+
],
|
|
18990
|
+
},
|
|
18991
|
+
]);
|
|
18992
|
+
return (options?.client ?? this.client).get({
|
|
18993
|
+
url: "/find",
|
|
18063
18994
|
...options,
|
|
18995
|
+
...params,
|
|
18064
18996
|
});
|
|
18065
18997
|
}
|
|
18066
18998
|
/**
|
|
18067
|
-
*
|
|
18068
|
-
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
|
|
18999
|
+
* Find files
|
|
19000
|
+
*
|
|
19001
|
+
* Search for files or directories by name or pattern in the project directory.
|
|
19002
|
+
*/
|
|
19003
|
+
files(parameters, options) {
|
|
19004
|
+
const params = buildClientParams([parameters], [
|
|
19005
|
+
{
|
|
19006
|
+
args: [
|
|
19007
|
+
{ in: "query", key: "directory" },
|
|
19008
|
+
{ in: "query", key: "query" },
|
|
19009
|
+
{ in: "query", key: "dirs" },
|
|
19010
|
+
{ in: "query", key: "type" },
|
|
19011
|
+
{ in: "query", key: "limit" },
|
|
19012
|
+
],
|
|
19013
|
+
},
|
|
19014
|
+
]);
|
|
19015
|
+
return (options?.client ?? this.client).get({
|
|
19016
|
+
url: "/find/file",
|
|
18072
19017
|
...options,
|
|
19018
|
+
...params,
|
|
18073
19019
|
});
|
|
18074
19020
|
}
|
|
18075
19021
|
/**
|
|
18076
|
-
*
|
|
18077
|
-
|
|
18078
|
-
|
|
18079
|
-
|
|
18080
|
-
|
|
19022
|
+
* Find symbols
|
|
19023
|
+
*
|
|
19024
|
+
* Search for workspace symbols like functions, classes, and variables using LSP.
|
|
19025
|
+
*/
|
|
19026
|
+
symbols(parameters, options) {
|
|
19027
|
+
const params = buildClientParams([parameters], [
|
|
19028
|
+
{
|
|
19029
|
+
args: [
|
|
19030
|
+
{ in: "query", key: "directory" },
|
|
19031
|
+
{ in: "query", key: "query" },
|
|
19032
|
+
],
|
|
19033
|
+
},
|
|
19034
|
+
]);
|
|
19035
|
+
return (options?.client ?? this.client).get({
|
|
19036
|
+
url: "/find/symbol",
|
|
18081
19037
|
...options,
|
|
19038
|
+
...params,
|
|
18082
19039
|
});
|
|
18083
19040
|
}
|
|
18084
19041
|
}
|
|
18085
|
-
class
|
|
19042
|
+
class File extends HeyApiClient {
|
|
18086
19043
|
/**
|
|
18087
|
-
*
|
|
18088
|
-
|
|
18089
|
-
|
|
18090
|
-
|
|
18091
|
-
|
|
19044
|
+
* List files
|
|
19045
|
+
*
|
|
19046
|
+
* List files and directories in a specified path.
|
|
19047
|
+
*/
|
|
19048
|
+
list(parameters, options) {
|
|
19049
|
+
const params = buildClientParams([parameters], [
|
|
19050
|
+
{
|
|
19051
|
+
args: [
|
|
19052
|
+
{ in: "query", key: "directory" },
|
|
19053
|
+
{ in: "query", key: "path" },
|
|
19054
|
+
],
|
|
19055
|
+
},
|
|
19056
|
+
]);
|
|
19057
|
+
return (options?.client ?? this.client).get({
|
|
19058
|
+
url: "/file",
|
|
18092
19059
|
...options,
|
|
18093
|
-
|
|
18094
|
-
|
|
18095
|
-
|
|
19060
|
+
...params,
|
|
19061
|
+
});
|
|
19062
|
+
}
|
|
19063
|
+
/**
|
|
19064
|
+
* Read file
|
|
19065
|
+
*
|
|
19066
|
+
* Read the content of a specified file.
|
|
19067
|
+
*/
|
|
19068
|
+
read(parameters, options) {
|
|
19069
|
+
const params = buildClientParams([parameters], [
|
|
19070
|
+
{
|
|
19071
|
+
args: [
|
|
19072
|
+
{ in: "query", key: "directory" },
|
|
19073
|
+
{ in: "query", key: "path" },
|
|
19074
|
+
],
|
|
18096
19075
|
},
|
|
19076
|
+
]);
|
|
19077
|
+
return (options?.client ?? this.client).get({
|
|
19078
|
+
url: "/file/content",
|
|
19079
|
+
...options,
|
|
19080
|
+
...params,
|
|
18097
19081
|
});
|
|
18098
19082
|
}
|
|
18099
19083
|
/**
|
|
18100
|
-
*
|
|
19084
|
+
* Get file status
|
|
19085
|
+
*
|
|
19086
|
+
* Get the git status of all files in the project.
|
|
18101
19087
|
*/
|
|
18102
|
-
|
|
18103
|
-
|
|
18104
|
-
|
|
19088
|
+
status(parameters, options) {
|
|
19089
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19090
|
+
return (options?.client ?? this.client).get({
|
|
19091
|
+
url: "/file/status",
|
|
18105
19092
|
...options,
|
|
19093
|
+
...params,
|
|
18106
19094
|
});
|
|
18107
19095
|
}
|
|
18108
19096
|
}
|
|
18109
|
-
class
|
|
19097
|
+
class Auth2 extends HeyApiClient {
|
|
18110
19098
|
/**
|
|
19099
|
+
* Remove MCP OAuth
|
|
19100
|
+
*
|
|
18111
19101
|
* Remove OAuth credentials for an MCP server
|
|
18112
19102
|
*/
|
|
18113
|
-
remove(options) {
|
|
18114
|
-
|
|
19103
|
+
remove(parameters, options) {
|
|
19104
|
+
const params = buildClientParams([parameters], [
|
|
19105
|
+
{
|
|
19106
|
+
args: [
|
|
19107
|
+
{ in: "path", key: "name" },
|
|
19108
|
+
{ in: "query", key: "directory" },
|
|
19109
|
+
],
|
|
19110
|
+
},
|
|
19111
|
+
]);
|
|
19112
|
+
return (options?.client ?? this.client).delete({
|
|
18115
19113
|
url: "/mcp/{name}/auth",
|
|
18116
19114
|
...options,
|
|
19115
|
+
...params,
|
|
18117
19116
|
});
|
|
18118
19117
|
}
|
|
18119
19118
|
/**
|
|
18120
|
-
* Start
|
|
18121
|
-
|
|
18122
|
-
|
|
18123
|
-
|
|
19119
|
+
* Start MCP OAuth
|
|
19120
|
+
*
|
|
19121
|
+
* Start OAuth authentication flow for a Model Context Protocol (MCP) server.
|
|
19122
|
+
*/
|
|
19123
|
+
start(parameters, options) {
|
|
19124
|
+
const params = buildClientParams([parameters], [
|
|
19125
|
+
{
|
|
19126
|
+
args: [
|
|
19127
|
+
{ in: "path", key: "name" },
|
|
19128
|
+
{ in: "query", key: "directory" },
|
|
19129
|
+
],
|
|
19130
|
+
},
|
|
19131
|
+
]);
|
|
19132
|
+
return (options?.client ?? this.client).post({
|
|
18124
19133
|
url: "/mcp/{name}/auth",
|
|
18125
19134
|
...options,
|
|
19135
|
+
...params,
|
|
18126
19136
|
});
|
|
18127
19137
|
}
|
|
18128
19138
|
/**
|
|
18129
|
-
* Complete OAuth
|
|
18130
|
-
|
|
18131
|
-
|
|
18132
|
-
|
|
19139
|
+
* Complete MCP OAuth
|
|
19140
|
+
*
|
|
19141
|
+
* Complete OAuth authentication for a Model Context Protocol (MCP) server using the authorization code.
|
|
19142
|
+
*/
|
|
19143
|
+
callback(parameters, options) {
|
|
19144
|
+
const params = buildClientParams([parameters], [
|
|
19145
|
+
{
|
|
19146
|
+
args: [
|
|
19147
|
+
{ in: "path", key: "name" },
|
|
19148
|
+
{ in: "query", key: "directory" },
|
|
19149
|
+
{ in: "body", key: "code" },
|
|
19150
|
+
],
|
|
19151
|
+
},
|
|
19152
|
+
]);
|
|
19153
|
+
return (options?.client ?? this.client).post({
|
|
18133
19154
|
url: "/mcp/{name}/auth/callback",
|
|
18134
19155
|
...options,
|
|
19156
|
+
...params,
|
|
18135
19157
|
headers: {
|
|
18136
19158
|
"Content-Type": "application/json",
|
|
18137
|
-
...options
|
|
19159
|
+
...options?.headers,
|
|
19160
|
+
...params.headers,
|
|
18138
19161
|
},
|
|
18139
19162
|
});
|
|
18140
19163
|
}
|
|
18141
19164
|
/**
|
|
19165
|
+
* Authenticate MCP OAuth
|
|
19166
|
+
*
|
|
18142
19167
|
* Start OAuth flow and wait for callback (opens browser)
|
|
18143
19168
|
*/
|
|
18144
|
-
authenticate(options) {
|
|
18145
|
-
|
|
19169
|
+
authenticate(parameters, options) {
|
|
19170
|
+
const params = buildClientParams([parameters], [
|
|
19171
|
+
{
|
|
19172
|
+
args: [
|
|
19173
|
+
{ in: "path", key: "name" },
|
|
19174
|
+
{ in: "query", key: "directory" },
|
|
19175
|
+
],
|
|
19176
|
+
},
|
|
19177
|
+
]);
|
|
19178
|
+
return (options?.client ?? this.client).post({
|
|
18146
19179
|
url: "/mcp/{name}/auth/authenticate",
|
|
18147
19180
|
...options,
|
|
18148
|
-
|
|
18149
|
-
}
|
|
18150
|
-
/**
|
|
18151
|
-
* Set authentication credentials
|
|
18152
|
-
*/
|
|
18153
|
-
set(options) {
|
|
18154
|
-
return (options.client ?? this._client).put({
|
|
18155
|
-
url: "/auth/{id}",
|
|
18156
|
-
...options,
|
|
18157
|
-
headers: {
|
|
18158
|
-
"Content-Type": "application/json",
|
|
18159
|
-
...options.headers,
|
|
18160
|
-
},
|
|
19181
|
+
...params,
|
|
18161
19182
|
});
|
|
18162
19183
|
}
|
|
18163
19184
|
}
|
|
18164
|
-
class Mcp extends
|
|
19185
|
+
class Mcp extends HeyApiClient {
|
|
18165
19186
|
/**
|
|
18166
|
-
* Get MCP
|
|
19187
|
+
* Get MCP status
|
|
19188
|
+
*
|
|
19189
|
+
* Get the status of all Model Context Protocol (MCP) servers.
|
|
18167
19190
|
*/
|
|
18168
|
-
status(options) {
|
|
18169
|
-
|
|
19191
|
+
status(parameters, options) {
|
|
19192
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19193
|
+
return (options?.client ?? this.client).get({
|
|
18170
19194
|
url: "/mcp",
|
|
18171
19195
|
...options,
|
|
19196
|
+
...params,
|
|
18172
19197
|
});
|
|
18173
19198
|
}
|
|
18174
19199
|
/**
|
|
18175
|
-
* Add MCP server
|
|
18176
|
-
|
|
18177
|
-
|
|
18178
|
-
|
|
19200
|
+
* Add MCP server
|
|
19201
|
+
*
|
|
19202
|
+
* Dynamically add a new Model Context Protocol (MCP) server to the system.
|
|
19203
|
+
*/
|
|
19204
|
+
add(parameters, options) {
|
|
19205
|
+
const params = buildClientParams([parameters], [
|
|
19206
|
+
{
|
|
19207
|
+
args: [
|
|
19208
|
+
{ in: "query", key: "directory" },
|
|
19209
|
+
{ in: "body", key: "name" },
|
|
19210
|
+
{ in: "body", key: "config" },
|
|
19211
|
+
],
|
|
19212
|
+
},
|
|
19213
|
+
]);
|
|
19214
|
+
return (options?.client ?? this.client).post({
|
|
18179
19215
|
url: "/mcp",
|
|
18180
19216
|
...options,
|
|
19217
|
+
...params,
|
|
18181
19218
|
headers: {
|
|
18182
19219
|
"Content-Type": "application/json",
|
|
18183
19220
|
...options?.headers,
|
|
19221
|
+
...params.headers,
|
|
18184
19222
|
},
|
|
18185
19223
|
});
|
|
18186
19224
|
}
|
|
18187
19225
|
/**
|
|
18188
19226
|
* Connect an MCP server
|
|
18189
19227
|
*/
|
|
18190
|
-
connect(options) {
|
|
18191
|
-
|
|
19228
|
+
connect(parameters, options) {
|
|
19229
|
+
const params = buildClientParams([parameters], [
|
|
19230
|
+
{
|
|
19231
|
+
args: [
|
|
19232
|
+
{ in: "path", key: "name" },
|
|
19233
|
+
{ in: "query", key: "directory" },
|
|
19234
|
+
],
|
|
19235
|
+
},
|
|
19236
|
+
]);
|
|
19237
|
+
return (options?.client ?? this.client).post({
|
|
18192
19238
|
url: "/mcp/{name}/connect",
|
|
18193
19239
|
...options,
|
|
19240
|
+
...params,
|
|
18194
19241
|
});
|
|
18195
19242
|
}
|
|
18196
19243
|
/**
|
|
18197
19244
|
* Disconnect an MCP server
|
|
18198
19245
|
*/
|
|
18199
|
-
disconnect(options) {
|
|
18200
|
-
|
|
19246
|
+
disconnect(parameters, options) {
|
|
19247
|
+
const params = buildClientParams([parameters], [
|
|
19248
|
+
{
|
|
19249
|
+
args: [
|
|
19250
|
+
{ in: "path", key: "name" },
|
|
19251
|
+
{ in: "query", key: "directory" },
|
|
19252
|
+
],
|
|
19253
|
+
},
|
|
19254
|
+
]);
|
|
19255
|
+
return (options?.client ?? this.client).post({
|
|
18201
19256
|
url: "/mcp/{name}/disconnect",
|
|
18202
19257
|
...options,
|
|
19258
|
+
...params,
|
|
18203
19259
|
});
|
|
18204
19260
|
}
|
|
18205
|
-
|
|
18206
|
-
|
|
18207
|
-
|
|
18208
|
-
/**
|
|
18209
|
-
* Get LSP server status
|
|
18210
|
-
*/
|
|
18211
|
-
status(options) {
|
|
18212
|
-
return (options?.client ?? this._client).get({
|
|
18213
|
-
url: "/lsp",
|
|
18214
|
-
...options,
|
|
18215
|
-
});
|
|
18216
|
-
}
|
|
18217
|
-
}
|
|
18218
|
-
class Formatter extends _HeyApiClient {
|
|
18219
|
-
/**
|
|
18220
|
-
* Get formatter status
|
|
18221
|
-
*/
|
|
18222
|
-
status(options) {
|
|
18223
|
-
return (options?.client ?? this._client).get({
|
|
18224
|
-
url: "/formatter",
|
|
18225
|
-
...options,
|
|
18226
|
-
});
|
|
19261
|
+
_auth;
|
|
19262
|
+
get auth() {
|
|
19263
|
+
return (this._auth ??= new Auth2({ client: this.client }));
|
|
18227
19264
|
}
|
|
18228
19265
|
}
|
|
18229
|
-
class Control extends
|
|
19266
|
+
class Control extends HeyApiClient {
|
|
18230
19267
|
/**
|
|
18231
|
-
* Get
|
|
19268
|
+
* Get next TUI request
|
|
19269
|
+
*
|
|
19270
|
+
* Retrieve the next TUI (Terminal User Interface) request from the queue for processing.
|
|
18232
19271
|
*/
|
|
18233
|
-
next(options) {
|
|
18234
|
-
|
|
19272
|
+
next(parameters, options) {
|
|
19273
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19274
|
+
return (options?.client ?? this.client).get({
|
|
18235
19275
|
url: "/tui/control/next",
|
|
18236
19276
|
...options,
|
|
19277
|
+
...params,
|
|
18237
19278
|
});
|
|
18238
19279
|
}
|
|
18239
19280
|
/**
|
|
18240
|
-
* Submit
|
|
18241
|
-
|
|
18242
|
-
|
|
18243
|
-
|
|
19281
|
+
* Submit TUI response
|
|
19282
|
+
*
|
|
19283
|
+
* Submit a response to the TUI request queue to complete a pending request.
|
|
19284
|
+
*/
|
|
19285
|
+
response(parameters, options) {
|
|
19286
|
+
const params = buildClientParams([parameters], [
|
|
19287
|
+
{
|
|
19288
|
+
args: [
|
|
19289
|
+
{ in: "query", key: "directory" },
|
|
19290
|
+
{ key: "body", map: "body" },
|
|
19291
|
+
],
|
|
19292
|
+
},
|
|
19293
|
+
]);
|
|
19294
|
+
return (options?.client ?? this.client).post({
|
|
18244
19295
|
url: "/tui/control/response",
|
|
18245
19296
|
...options,
|
|
19297
|
+
...params,
|
|
18246
19298
|
headers: {
|
|
18247
19299
|
"Content-Type": "application/json",
|
|
18248
19300
|
...options?.headers,
|
|
19301
|
+
...params.headers,
|
|
18249
19302
|
},
|
|
18250
19303
|
});
|
|
18251
19304
|
}
|
|
18252
19305
|
}
|
|
18253
|
-
class Tui extends
|
|
19306
|
+
class Tui extends HeyApiClient {
|
|
18254
19307
|
/**
|
|
19308
|
+
* Append TUI prompt
|
|
19309
|
+
*
|
|
18255
19310
|
* Append prompt to the TUI
|
|
18256
19311
|
*/
|
|
18257
|
-
appendPrompt(options) {
|
|
18258
|
-
|
|
19312
|
+
appendPrompt(parameters, options) {
|
|
19313
|
+
const params = buildClientParams([parameters], [
|
|
19314
|
+
{
|
|
19315
|
+
args: [
|
|
19316
|
+
{ in: "query", key: "directory" },
|
|
19317
|
+
{ in: "body", key: "text" },
|
|
19318
|
+
],
|
|
19319
|
+
},
|
|
19320
|
+
]);
|
|
19321
|
+
return (options?.client ?? this.client).post({
|
|
18259
19322
|
url: "/tui/append-prompt",
|
|
18260
19323
|
...options,
|
|
19324
|
+
...params,
|
|
18261
19325
|
headers: {
|
|
18262
19326
|
"Content-Type": "application/json",
|
|
18263
19327
|
...options?.headers,
|
|
19328
|
+
...params.headers,
|
|
18264
19329
|
},
|
|
18265
19330
|
});
|
|
18266
19331
|
}
|
|
18267
19332
|
/**
|
|
18268
|
-
* Open
|
|
19333
|
+
* Open help dialog
|
|
19334
|
+
*
|
|
19335
|
+
* Open the help dialog in the TUI to display user assistance information.
|
|
18269
19336
|
*/
|
|
18270
|
-
openHelp(options) {
|
|
18271
|
-
|
|
19337
|
+
openHelp(parameters, options) {
|
|
19338
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19339
|
+
return (options?.client ?? this.client).post({
|
|
18272
19340
|
url: "/tui/open-help",
|
|
18273
19341
|
...options,
|
|
19342
|
+
...params,
|
|
18274
19343
|
});
|
|
18275
19344
|
}
|
|
18276
19345
|
/**
|
|
19346
|
+
* Open sessions dialog
|
|
19347
|
+
*
|
|
18277
19348
|
* Open the session dialog
|
|
18278
19349
|
*/
|
|
18279
|
-
openSessions(options) {
|
|
18280
|
-
|
|
19350
|
+
openSessions(parameters, options) {
|
|
19351
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19352
|
+
return (options?.client ?? this.client).post({
|
|
18281
19353
|
url: "/tui/open-sessions",
|
|
18282
19354
|
...options,
|
|
19355
|
+
...params,
|
|
18283
19356
|
});
|
|
18284
19357
|
}
|
|
18285
19358
|
/**
|
|
19359
|
+
* Open themes dialog
|
|
19360
|
+
*
|
|
18286
19361
|
* Open the theme dialog
|
|
18287
19362
|
*/
|
|
18288
|
-
openThemes(options) {
|
|
18289
|
-
|
|
19363
|
+
openThemes(parameters, options) {
|
|
19364
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19365
|
+
return (options?.client ?? this.client).post({
|
|
18290
19366
|
url: "/tui/open-themes",
|
|
18291
19367
|
...options,
|
|
19368
|
+
...params,
|
|
18292
19369
|
});
|
|
18293
19370
|
}
|
|
18294
19371
|
/**
|
|
19372
|
+
* Open models dialog
|
|
19373
|
+
*
|
|
18295
19374
|
* Open the model dialog
|
|
18296
19375
|
*/
|
|
18297
|
-
openModels(options) {
|
|
18298
|
-
|
|
19376
|
+
openModels(parameters, options) {
|
|
19377
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19378
|
+
return (options?.client ?? this.client).post({
|
|
18299
19379
|
url: "/tui/open-models",
|
|
18300
19380
|
...options,
|
|
19381
|
+
...params,
|
|
18301
19382
|
});
|
|
18302
19383
|
}
|
|
18303
19384
|
/**
|
|
19385
|
+
* Submit TUI prompt
|
|
19386
|
+
*
|
|
18304
19387
|
* Submit the prompt
|
|
18305
19388
|
*/
|
|
18306
|
-
submitPrompt(options) {
|
|
18307
|
-
|
|
19389
|
+
submitPrompt(parameters, options) {
|
|
19390
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19391
|
+
return (options?.client ?? this.client).post({
|
|
18308
19392
|
url: "/tui/submit-prompt",
|
|
18309
19393
|
...options,
|
|
19394
|
+
...params,
|
|
18310
19395
|
});
|
|
18311
19396
|
}
|
|
18312
19397
|
/**
|
|
19398
|
+
* Clear TUI prompt
|
|
19399
|
+
*
|
|
18313
19400
|
* Clear the prompt
|
|
18314
19401
|
*/
|
|
18315
|
-
clearPrompt(options) {
|
|
18316
|
-
|
|
19402
|
+
clearPrompt(parameters, options) {
|
|
19403
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19404
|
+
return (options?.client ?? this.client).post({
|
|
18317
19405
|
url: "/tui/clear-prompt",
|
|
18318
19406
|
...options,
|
|
19407
|
+
...params,
|
|
18319
19408
|
});
|
|
18320
19409
|
}
|
|
18321
19410
|
/**
|
|
19411
|
+
* Execute TUI command
|
|
19412
|
+
*
|
|
18322
19413
|
* Execute a TUI command (e.g. agent_cycle)
|
|
18323
19414
|
*/
|
|
18324
|
-
executeCommand(options) {
|
|
18325
|
-
|
|
19415
|
+
executeCommand(parameters, options) {
|
|
19416
|
+
const params = buildClientParams([parameters], [
|
|
19417
|
+
{
|
|
19418
|
+
args: [
|
|
19419
|
+
{ in: "query", key: "directory" },
|
|
19420
|
+
{ in: "body", key: "command" },
|
|
19421
|
+
],
|
|
19422
|
+
},
|
|
19423
|
+
]);
|
|
19424
|
+
return (options?.client ?? this.client).post({
|
|
18326
19425
|
url: "/tui/execute-command",
|
|
18327
19426
|
...options,
|
|
19427
|
+
...params,
|
|
18328
19428
|
headers: {
|
|
18329
19429
|
"Content-Type": "application/json",
|
|
18330
19430
|
...options?.headers,
|
|
19431
|
+
...params.headers,
|
|
18331
19432
|
},
|
|
18332
19433
|
});
|
|
18333
19434
|
}
|
|
18334
19435
|
/**
|
|
19436
|
+
* Show TUI toast
|
|
19437
|
+
*
|
|
18335
19438
|
* Show a toast notification in the TUI
|
|
18336
19439
|
*/
|
|
18337
|
-
showToast(options) {
|
|
18338
|
-
|
|
19440
|
+
showToast(parameters, options) {
|
|
19441
|
+
const params = buildClientParams([parameters], [
|
|
19442
|
+
{
|
|
19443
|
+
args: [
|
|
19444
|
+
{ in: "query", key: "directory" },
|
|
19445
|
+
{ in: "body", key: "title" },
|
|
19446
|
+
{ in: "body", key: "message" },
|
|
19447
|
+
{ in: "body", key: "variant" },
|
|
19448
|
+
{ in: "body", key: "duration" },
|
|
19449
|
+
],
|
|
19450
|
+
},
|
|
19451
|
+
]);
|
|
19452
|
+
return (options?.client ?? this.client).post({
|
|
18339
19453
|
url: "/tui/show-toast",
|
|
18340
19454
|
...options,
|
|
19455
|
+
...params,
|
|
18341
19456
|
headers: {
|
|
18342
19457
|
"Content-Type": "application/json",
|
|
18343
19458
|
...options?.headers,
|
|
19459
|
+
...params.headers,
|
|
18344
19460
|
},
|
|
18345
19461
|
});
|
|
18346
19462
|
}
|
|
18347
19463
|
/**
|
|
19464
|
+
* Publish TUI event
|
|
19465
|
+
*
|
|
18348
19466
|
* Publish a TUI event
|
|
18349
19467
|
*/
|
|
18350
|
-
publish(options) {
|
|
18351
|
-
|
|
19468
|
+
publish(parameters, options) {
|
|
19469
|
+
const params = buildClientParams([parameters], [
|
|
19470
|
+
{
|
|
19471
|
+
args: [
|
|
19472
|
+
{ in: "query", key: "directory" },
|
|
19473
|
+
{ key: "body", map: "body" },
|
|
19474
|
+
],
|
|
19475
|
+
},
|
|
19476
|
+
]);
|
|
19477
|
+
return (options?.client ?? this.client).post({
|
|
18352
19478
|
url: "/tui/publish",
|
|
18353
19479
|
...options,
|
|
19480
|
+
...params,
|
|
19481
|
+
headers: {
|
|
19482
|
+
"Content-Type": "application/json",
|
|
19483
|
+
...options?.headers,
|
|
19484
|
+
...params.headers,
|
|
19485
|
+
},
|
|
19486
|
+
});
|
|
19487
|
+
}
|
|
19488
|
+
/**
|
|
19489
|
+
* Select session
|
|
19490
|
+
*
|
|
19491
|
+
* Navigate the TUI to display the specified session.
|
|
19492
|
+
*/
|
|
19493
|
+
selectSession(parameters, options) {
|
|
19494
|
+
const params = buildClientParams([parameters], [
|
|
19495
|
+
{
|
|
19496
|
+
args: [
|
|
19497
|
+
{ in: "query", key: "directory" },
|
|
19498
|
+
{ in: "body", key: "sessionID" },
|
|
19499
|
+
],
|
|
19500
|
+
},
|
|
19501
|
+
]);
|
|
19502
|
+
return (options?.client ?? this.client).post({
|
|
19503
|
+
url: "/tui/select-session",
|
|
19504
|
+
...options,
|
|
19505
|
+
...params,
|
|
18354
19506
|
headers: {
|
|
18355
19507
|
"Content-Type": "application/json",
|
|
18356
19508
|
...options?.headers,
|
|
19509
|
+
...params.headers,
|
|
18357
19510
|
},
|
|
18358
19511
|
});
|
|
18359
19512
|
}
|
|
18360
|
-
|
|
19513
|
+
_control;
|
|
19514
|
+
get control() {
|
|
19515
|
+
return (this._control ??= new Control({ client: this.client }));
|
|
19516
|
+
}
|
|
18361
19517
|
}
|
|
18362
|
-
class
|
|
19518
|
+
class Instance extends HeyApiClient {
|
|
18363
19519
|
/**
|
|
18364
|
-
*
|
|
19520
|
+
* Dispose instance
|
|
19521
|
+
*
|
|
19522
|
+
* Clean up and dispose the current OpenCode instance, releasing all resources.
|
|
18365
19523
|
*/
|
|
18366
|
-
|
|
18367
|
-
|
|
18368
|
-
|
|
19524
|
+
dispose(parameters, options) {
|
|
19525
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19526
|
+
return (options?.client ?? this.client).post({
|
|
19527
|
+
url: "/instance/dispose",
|
|
19528
|
+
...options,
|
|
19529
|
+
...params,
|
|
19530
|
+
});
|
|
19531
|
+
}
|
|
19532
|
+
}
|
|
19533
|
+
class Path extends HeyApiClient {
|
|
19534
|
+
/**
|
|
19535
|
+
* Get paths
|
|
19536
|
+
*
|
|
19537
|
+
* Retrieve the current working directory and related path information for the OpenCode instance.
|
|
19538
|
+
*/
|
|
19539
|
+
get(parameters, options) {
|
|
19540
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19541
|
+
return (options?.client ?? this.client).get({
|
|
19542
|
+
url: "/path",
|
|
18369
19543
|
...options,
|
|
19544
|
+
...params,
|
|
18370
19545
|
});
|
|
18371
19546
|
}
|
|
18372
19547
|
}
|
|
18373
|
-
class
|
|
19548
|
+
class Vcs extends HeyApiClient {
|
|
18374
19549
|
/**
|
|
18375
|
-
*
|
|
19550
|
+
* Get VCS info
|
|
19551
|
+
*
|
|
19552
|
+
* Retrieve version control system (VCS) information for the current project, such as git branch.
|
|
19553
|
+
*/
|
|
19554
|
+
get(parameters, options) {
|
|
19555
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19556
|
+
return (options?.client ?? this.client).get({
|
|
19557
|
+
url: "/vcs",
|
|
19558
|
+
...options,
|
|
19559
|
+
...params,
|
|
19560
|
+
});
|
|
19561
|
+
}
|
|
19562
|
+
}
|
|
19563
|
+
class sdk_gen_Command extends HeyApiClient {
|
|
19564
|
+
/**
|
|
19565
|
+
* List commands
|
|
19566
|
+
*
|
|
19567
|
+
* Get a list of all available commands in the OpenCode system.
|
|
18376
19568
|
*/
|
|
18377
|
-
|
|
18378
|
-
|
|
18379
|
-
|
|
19569
|
+
list(parameters, options) {
|
|
19570
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19571
|
+
return (options?.client ?? this.client).get({
|
|
19572
|
+
url: "/command",
|
|
19573
|
+
...options,
|
|
19574
|
+
...params,
|
|
19575
|
+
});
|
|
19576
|
+
}
|
|
19577
|
+
}
|
|
19578
|
+
class App extends HeyApiClient {
|
|
19579
|
+
/**
|
|
19580
|
+
* Write log
|
|
19581
|
+
*
|
|
19582
|
+
* Write a log entry to the server logs with specified level and metadata.
|
|
19583
|
+
*/
|
|
19584
|
+
log(parameters, options) {
|
|
19585
|
+
const params = buildClientParams([parameters], [
|
|
19586
|
+
{
|
|
19587
|
+
args: [
|
|
19588
|
+
{ in: "query", key: "directory" },
|
|
19589
|
+
{ in: "body", key: "service" },
|
|
19590
|
+
{ in: "body", key: "level" },
|
|
19591
|
+
{ in: "body", key: "message" },
|
|
19592
|
+
{ in: "body", key: "extra" },
|
|
19593
|
+
],
|
|
19594
|
+
},
|
|
19595
|
+
]);
|
|
19596
|
+
return (options?.client ?? this.client).post({
|
|
19597
|
+
url: "/log",
|
|
18380
19598
|
...options,
|
|
19599
|
+
...params,
|
|
18381
19600
|
headers: {
|
|
18382
19601
|
"Content-Type": "application/json",
|
|
18383
|
-
...options
|
|
19602
|
+
...options?.headers,
|
|
19603
|
+
...params.headers,
|
|
18384
19604
|
},
|
|
18385
19605
|
});
|
|
18386
19606
|
}
|
|
18387
|
-
|
|
18388
|
-
|
|
18389
|
-
|
|
18390
|
-
|
|
18391
|
-
|
|
18392
|
-
|
|
18393
|
-
|
|
18394
|
-
|
|
18395
|
-
|
|
18396
|
-
|
|
18397
|
-
|
|
18398
|
-
|
|
18399
|
-
|
|
18400
|
-
|
|
18401
|
-
|
|
18402
|
-
|
|
18403
|
-
|
|
18404
|
-
|
|
18405
|
-
|
|
18406
|
-
|
|
19607
|
+
/**
|
|
19608
|
+
* List agents
|
|
19609
|
+
*
|
|
19610
|
+
* Get a list of all available AI agents in the OpenCode system.
|
|
19611
|
+
*/
|
|
19612
|
+
agents(parameters, options) {
|
|
19613
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19614
|
+
return (options?.client ?? this.client).get({
|
|
19615
|
+
url: "/agent",
|
|
19616
|
+
...options,
|
|
19617
|
+
...params,
|
|
19618
|
+
});
|
|
19619
|
+
}
|
|
19620
|
+
/**
|
|
19621
|
+
* List skills
|
|
19622
|
+
*
|
|
19623
|
+
* Get a list of all available skills in the OpenCode system.
|
|
19624
|
+
*/
|
|
19625
|
+
skills(parameters, options) {
|
|
19626
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19627
|
+
return (options?.client ?? this.client).get({
|
|
19628
|
+
url: "/skill",
|
|
19629
|
+
...options,
|
|
19630
|
+
...params,
|
|
19631
|
+
});
|
|
19632
|
+
}
|
|
19633
|
+
}
|
|
19634
|
+
class Lsp extends HeyApiClient {
|
|
19635
|
+
/**
|
|
19636
|
+
* Get LSP status
|
|
19637
|
+
*
|
|
19638
|
+
* Get LSP server status
|
|
19639
|
+
*/
|
|
19640
|
+
status(parameters, options) {
|
|
19641
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19642
|
+
return (options?.client ?? this.client).get({
|
|
19643
|
+
url: "/lsp",
|
|
19644
|
+
...options,
|
|
19645
|
+
...params,
|
|
19646
|
+
});
|
|
19647
|
+
}
|
|
19648
|
+
}
|
|
19649
|
+
class Formatter extends HeyApiClient {
|
|
19650
|
+
/**
|
|
19651
|
+
* Get formatter status
|
|
19652
|
+
*
|
|
19653
|
+
* Get formatter status
|
|
19654
|
+
*/
|
|
19655
|
+
status(parameters, options) {
|
|
19656
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19657
|
+
return (options?.client ?? this.client).get({
|
|
19658
|
+
url: "/formatter",
|
|
19659
|
+
...options,
|
|
19660
|
+
...params,
|
|
19661
|
+
});
|
|
19662
|
+
}
|
|
19663
|
+
}
|
|
19664
|
+
class Event extends HeyApiClient {
|
|
19665
|
+
/**
|
|
19666
|
+
* Subscribe to events
|
|
19667
|
+
*
|
|
19668
|
+
* Get events
|
|
19669
|
+
*/
|
|
19670
|
+
subscribe(parameters, options) {
|
|
19671
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19672
|
+
return (options?.client ?? this.client).sse.get({
|
|
19673
|
+
url: "/event",
|
|
19674
|
+
...options,
|
|
19675
|
+
...params,
|
|
19676
|
+
});
|
|
19677
|
+
}
|
|
19678
|
+
}
|
|
19679
|
+
class OpencodeClient extends HeyApiClient {
|
|
19680
|
+
static __registry = new HeyApiRegistry();
|
|
19681
|
+
constructor(args) {
|
|
19682
|
+
super(args);
|
|
19683
|
+
OpencodeClient.__registry.set(this, args?.key);
|
|
19684
|
+
}
|
|
19685
|
+
_global;
|
|
19686
|
+
get global() {
|
|
19687
|
+
return (this._global ??= new Global({ client: this.client }));
|
|
19688
|
+
}
|
|
19689
|
+
_auth;
|
|
19690
|
+
get auth() {
|
|
19691
|
+
return (this._auth ??= new Auth({ client: this.client }));
|
|
19692
|
+
}
|
|
19693
|
+
_project;
|
|
19694
|
+
get project() {
|
|
19695
|
+
return (this._project ??= new Project({ client: this.client }));
|
|
19696
|
+
}
|
|
19697
|
+
_pty;
|
|
19698
|
+
get pty() {
|
|
19699
|
+
return (this._pty ??= new Pty({ client: this.client }));
|
|
19700
|
+
}
|
|
19701
|
+
_config;
|
|
19702
|
+
get config() {
|
|
19703
|
+
return (this._config ??= new Config2({ client: this.client }));
|
|
19704
|
+
}
|
|
19705
|
+
_tool;
|
|
19706
|
+
get tool() {
|
|
19707
|
+
return (this._tool ??= new Tool({ client: this.client }));
|
|
19708
|
+
}
|
|
19709
|
+
_worktree;
|
|
19710
|
+
get worktree() {
|
|
19711
|
+
return (this._worktree ??= new Worktree({ client: this.client }));
|
|
19712
|
+
}
|
|
19713
|
+
_experimental;
|
|
19714
|
+
get experimental() {
|
|
19715
|
+
return (this._experimental ??= new Experimental({ client: this.client }));
|
|
19716
|
+
}
|
|
19717
|
+
_session;
|
|
19718
|
+
get session() {
|
|
19719
|
+
return (this._session ??= new Session({ client: this.client }));
|
|
19720
|
+
}
|
|
19721
|
+
_part;
|
|
19722
|
+
get part() {
|
|
19723
|
+
return (this._part ??= new Part({ client: this.client }));
|
|
19724
|
+
}
|
|
19725
|
+
_permission;
|
|
19726
|
+
get permission() {
|
|
19727
|
+
return (this._permission ??= new Permission({ client: this.client }));
|
|
19728
|
+
}
|
|
19729
|
+
_question;
|
|
19730
|
+
get question() {
|
|
19731
|
+
return (this._question ??= new Question({ client: this.client }));
|
|
19732
|
+
}
|
|
19733
|
+
_provider;
|
|
19734
|
+
get provider() {
|
|
19735
|
+
return (this._provider ??= new Provider({ client: this.client }));
|
|
19736
|
+
}
|
|
19737
|
+
_find;
|
|
19738
|
+
get find() {
|
|
19739
|
+
return (this._find ??= new Find({ client: this.client }));
|
|
19740
|
+
}
|
|
19741
|
+
_file;
|
|
19742
|
+
get file() {
|
|
19743
|
+
return (this._file ??= new File({ client: this.client }));
|
|
19744
|
+
}
|
|
19745
|
+
_mcp;
|
|
19746
|
+
get mcp() {
|
|
19747
|
+
return (this._mcp ??= new Mcp({ client: this.client }));
|
|
19748
|
+
}
|
|
19749
|
+
_tui;
|
|
19750
|
+
get tui() {
|
|
19751
|
+
return (this._tui ??= new Tui({ client: this.client }));
|
|
19752
|
+
}
|
|
19753
|
+
_instance;
|
|
19754
|
+
get instance() {
|
|
19755
|
+
return (this._instance ??= new Instance({ client: this.client }));
|
|
19756
|
+
}
|
|
19757
|
+
_path;
|
|
19758
|
+
get path() {
|
|
19759
|
+
return (this._path ??= new Path({ client: this.client }));
|
|
19760
|
+
}
|
|
19761
|
+
_vcs;
|
|
19762
|
+
get vcs() {
|
|
19763
|
+
return (this._vcs ??= new Vcs({ client: this.client }));
|
|
19764
|
+
}
|
|
19765
|
+
_command;
|
|
19766
|
+
get command() {
|
|
19767
|
+
return (this._command ??= new sdk_gen_Command({ client: this.client }));
|
|
19768
|
+
}
|
|
19769
|
+
_app;
|
|
19770
|
+
get app() {
|
|
19771
|
+
return (this._app ??= new App({ client: this.client }));
|
|
19772
|
+
}
|
|
19773
|
+
_lsp;
|
|
19774
|
+
get lsp() {
|
|
19775
|
+
return (this._lsp ??= new Lsp({ client: this.client }));
|
|
19776
|
+
}
|
|
19777
|
+
_formatter;
|
|
19778
|
+
get formatter() {
|
|
19779
|
+
return (this._formatter ??= new Formatter({ client: this.client }));
|
|
19780
|
+
}
|
|
19781
|
+
_event;
|
|
19782
|
+
get event() {
|
|
19783
|
+
return (this._event ??= new Event({ client: this.client }));
|
|
19784
|
+
}
|
|
18407
19785
|
}
|
|
18408
19786
|
|
|
18409
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/client.js
|
|
19787
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/client.js
|
|
18410
19788
|
|
|
18411
19789
|
|
|
18412
19790
|
|
|
@@ -18424,9 +19802,11 @@ function client_createOpencodeClient(config) {
|
|
|
18424
19802
|
};
|
|
18425
19803
|
}
|
|
18426
19804
|
if (config?.directory) {
|
|
19805
|
+
const isNonASCII = /[^\x00-\x7F]/.test(config.directory);
|
|
19806
|
+
const encodedDirectory = isNonASCII ? encodeURIComponent(config.directory) : config.directory;
|
|
18427
19807
|
config.headers = {
|
|
18428
19808
|
...config.headers,
|
|
18429
|
-
"x-opencode-directory":
|
|
19809
|
+
"x-opencode-directory": encodedDirectory,
|
|
18430
19810
|
};
|
|
18431
19811
|
}
|
|
18432
19812
|
const client = createClient(config);
|
|
@@ -18435,7 +19815,7 @@ function client_createOpencodeClient(config) {
|
|
|
18435
19815
|
|
|
18436
19816
|
// EXTERNAL MODULE: external "node:child_process"
|
|
18437
19817
|
var external_node_child_process_ = __nccwpck_require__(1421);
|
|
18438
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/server.js
|
|
19818
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/server.js
|
|
18439
19819
|
|
|
18440
19820
|
async function server_createOpencodeServer(options) {
|
|
18441
19821
|
options = Object.assign({
|
|
@@ -18531,7 +19911,7 @@ function createOpencodeTui(options) {
|
|
|
18531
19911
|
};
|
|
18532
19912
|
}
|
|
18533
19913
|
|
|
18534
|
-
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/index.js
|
|
19914
|
+
;// CONCATENATED MODULE: ./node_modules/@opencode-ai/sdk/dist/v2/index.js
|
|
18535
19915
|
|
|
18536
19916
|
|
|
18537
19917
|
|
|
@@ -18594,29 +19974,31 @@ async function startTelegram(options) {
|
|
|
18594
19974
|
const isHiddenOpenCodeCommand = (name) => hiddenOpenCodeCommands.has(name.toLowerCase());
|
|
18595
19975
|
let projectDirectory = "";
|
|
18596
19976
|
try {
|
|
18597
|
-
const sessions = await client.session.list();
|
|
19977
|
+
const sessions = await client.session.list({});
|
|
18598
19978
|
if (sessions.error) {
|
|
18599
19979
|
throw new Error(`Server returned error: ${JSON.stringify(sessions.error)}`);
|
|
18600
19980
|
}
|
|
18601
19981
|
console.log(`[Telegram] Connected to OpenCode server at ${url}`);
|
|
18602
19982
|
// Fetch the project directory (needed for SSE event subscription)
|
|
18603
|
-
const pathResult = await client.path.get();
|
|
19983
|
+
const pathResult = await client.path.get({});
|
|
18604
19984
|
if (pathResult.data?.directory) {
|
|
18605
19985
|
projectDirectory = pathResult.data.directory;
|
|
18606
19986
|
console.log(`[Telegram] Project directory: ${projectDirectory}`);
|
|
18607
19987
|
}
|
|
18608
19988
|
// Fetch available OpenCode commands
|
|
18609
|
-
const cmds = await client.command.list();
|
|
19989
|
+
const cmds = await client.command.list({});
|
|
18610
19990
|
if (cmds.data) {
|
|
18611
19991
|
for (const cmd of cmds.data) {
|
|
18612
19992
|
const name = cmd.name;
|
|
18613
19993
|
if (!name)
|
|
18614
19994
|
continue;
|
|
18615
19995
|
opencodeCommands.add(name);
|
|
18616
|
-
|
|
19996
|
+
console.log(`[Telegram] Found OpenCode command: ${name}`);
|
|
19997
|
+
if (!isHiddenOpenCodeCommand(name) && /^[a-z0-9_]{1,32}$/.test(name)) {
|
|
19998
|
+
const desc = cmd.description || "OpenCode command";
|
|
18617
19999
|
opencodeCommandMenu.push({
|
|
18618
20000
|
command: name,
|
|
18619
|
-
description:
|
|
20001
|
+
description: desc.length > 256 ? desc.slice(0, 253) + "..." : desc,
|
|
18620
20002
|
});
|
|
18621
20003
|
}
|
|
18622
20004
|
}
|
|
@@ -18651,6 +20033,8 @@ async function startTelegram(options) {
|
|
|
18651
20033
|
const chatModelOverride = new Map();
|
|
18652
20034
|
// Map of chatId -> last search results (in-memory only)
|
|
18653
20035
|
const chatModelSearchResults = new Map();
|
|
20036
|
+
// Map of questionId -> pending question context (for forwarding OpenCode questions to Telegram)
|
|
20037
|
+
const pendingQuestions = new Map();
|
|
18654
20038
|
/**
|
|
18655
20039
|
* Save the chat-to-session mapping and known session IDs to disk.
|
|
18656
20040
|
*/
|
|
@@ -18715,7 +20099,7 @@ async function startTelegram(options) {
|
|
|
18715
20099
|
// Fetch all server sessions once for validation and fallback matching
|
|
18716
20100
|
let serverSessions = [];
|
|
18717
20101
|
try {
|
|
18718
|
-
const list = await client.session.list();
|
|
20102
|
+
const list = await client.session.list({});
|
|
18719
20103
|
if (list.data) {
|
|
18720
20104
|
serverSessions = list.data;
|
|
18721
20105
|
}
|
|
@@ -18769,6 +20153,14 @@ async function startTelegram(options) {
|
|
|
18769
20153
|
}
|
|
18770
20154
|
// Restore sessions from previous runs
|
|
18771
20155
|
await restoreSessions();
|
|
20156
|
+
// Build a reverse lookup: sessionId -> chatId
|
|
20157
|
+
function sessionToChatId(sessionId) {
|
|
20158
|
+
for (const [chatId, sid] of chatSessions) {
|
|
20159
|
+
if (sid === sessionId)
|
|
20160
|
+
return chatId;
|
|
20161
|
+
}
|
|
20162
|
+
return undefined;
|
|
20163
|
+
}
|
|
18772
20164
|
// Track which sessions were just created so we can auto-title them
|
|
18773
20165
|
const newlyCreatedSessions = new Set();
|
|
18774
20166
|
/**
|
|
@@ -18778,7 +20170,7 @@ async function startTelegram(options) {
|
|
|
18778
20170
|
let sessionId = chatSessions.get(chatId);
|
|
18779
20171
|
if (!sessionId) {
|
|
18780
20172
|
const session = await client.session.create({
|
|
18781
|
-
|
|
20173
|
+
title: `Telegram chat ${chatId}`,
|
|
18782
20174
|
});
|
|
18783
20175
|
if (session.error || !session.data) {
|
|
18784
20176
|
throw new Error(`Failed to create session: ${JSON.stringify(session.error)}`);
|
|
@@ -18805,8 +20197,8 @@ async function startTelegram(options) {
|
|
|
18805
20197
|
const title = truncate(userText.replace(/\n/g, " "), 100);
|
|
18806
20198
|
try {
|
|
18807
20199
|
await client.session.update({
|
|
18808
|
-
|
|
18809
|
-
|
|
20200
|
+
sessionID: sessionId,
|
|
20201
|
+
title,
|
|
18810
20202
|
});
|
|
18811
20203
|
console.log(`[Telegram] Auto-titled session ${sessionId}: "${title}"`);
|
|
18812
20204
|
}
|
|
@@ -18835,10 +20227,27 @@ async function startTelegram(options) {
|
|
|
18835
20227
|
}
|
|
18836
20228
|
async function answerAndEdit(ctx, text) {
|
|
18837
20229
|
if (typeof ctx.answerCbQuery === "function") {
|
|
18838
|
-
|
|
20230
|
+
try {
|
|
20231
|
+
await ctx.answerCbQuery();
|
|
20232
|
+
}
|
|
20233
|
+
catch {
|
|
20234
|
+
// Ignore "query is too old" or other callback query errors —
|
|
20235
|
+
// the callback may have expired but we still want to update the message.
|
|
20236
|
+
}
|
|
18839
20237
|
}
|
|
18840
20238
|
if (typeof ctx.editMessageText === "function") {
|
|
18841
|
-
|
|
20239
|
+
try {
|
|
20240
|
+
await ctx.editMessageText(text);
|
|
20241
|
+
}
|
|
20242
|
+
catch {
|
|
20243
|
+
// If edit fails (message deleted, too old, etc.), fall back to reply
|
|
20244
|
+
try {
|
|
20245
|
+
await ctx.reply(text);
|
|
20246
|
+
}
|
|
20247
|
+
catch {
|
|
20248
|
+
// Give up silently
|
|
20249
|
+
}
|
|
20250
|
+
}
|
|
18842
20251
|
return;
|
|
18843
20252
|
}
|
|
18844
20253
|
await ctx.reply(text);
|
|
@@ -18952,18 +20361,15 @@ async function startTelegram(options) {
|
|
|
18952
20361
|
async function sendPromptStreaming(chatId, sessionId, promptBody, processingMsgId, verbose = false) {
|
|
18953
20362
|
// Subscribe to SSE events before sending the prompt so we don't miss anything
|
|
18954
20363
|
const abortController = new AbortController();
|
|
18955
|
-
|
|
18956
|
-
const subscribeOptions = {
|
|
18957
|
-
signal: abortController.signal,
|
|
18958
|
-
};
|
|
20364
|
+
const subscribeParams = {};
|
|
18959
20365
|
if (projectDirectory) {
|
|
18960
|
-
|
|
20366
|
+
subscribeParams.directory = projectDirectory;
|
|
18961
20367
|
}
|
|
18962
|
-
const { stream } = await client.event.subscribe(
|
|
20368
|
+
const { stream } = await client.event.subscribe(subscribeParams, { signal: abortController.signal });
|
|
18963
20369
|
// Fire the prompt asynchronously (returns immediately)
|
|
18964
20370
|
const asyncResult = await client.session.promptAsync({
|
|
18965
|
-
|
|
18966
|
-
|
|
20371
|
+
sessionID: sessionId,
|
|
20372
|
+
...promptBody,
|
|
18967
20373
|
});
|
|
18968
20374
|
if (asyncResult.error) {
|
|
18969
20375
|
abortController.abort();
|
|
@@ -18985,7 +20391,7 @@ async function startTelegram(options) {
|
|
|
18985
20391
|
async function emitSubagentMessages(taskSessionId) {
|
|
18986
20392
|
try {
|
|
18987
20393
|
const messagesResult = await client.session.messages({
|
|
18988
|
-
|
|
20394
|
+
sessionID: taskSessionId,
|
|
18989
20395
|
});
|
|
18990
20396
|
if (messagesResult.error || !messagesResult.data) {
|
|
18991
20397
|
console.warn(`[Telegram] Failed to fetch subagent messages for ${taskSessionId}: ${JSON.stringify(messagesResult.error)}`);
|
|
@@ -19199,6 +20605,46 @@ async function startTelegram(options) {
|
|
|
19199
20605
|
throw new Error(`Session error: ${errorMsg}`);
|
|
19200
20606
|
}
|
|
19201
20607
|
}
|
|
20608
|
+
else if (ev.type === "question.asked" && ev.properties) {
|
|
20609
|
+
const questionSessionId = ev.properties.sessionID;
|
|
20610
|
+
if (questionSessionId === sessionId) {
|
|
20611
|
+
const questionId = ev.properties.id;
|
|
20612
|
+
const questions = ev.properties.questions;
|
|
20613
|
+
if (questionId && questions?.length > 0) {
|
|
20614
|
+
// Store the pending question
|
|
20615
|
+
pendingQuestions.set(questionId, {
|
|
20616
|
+
chatId: chatId.toString(),
|
|
20617
|
+
sessionId,
|
|
20618
|
+
questions,
|
|
20619
|
+
});
|
|
20620
|
+
console.log(`[Telegram] Sending ${questions.length} question(s) to chat ${chatId} (question ${questionId})`);
|
|
20621
|
+
// Send each question to Telegram with inline buttons
|
|
20622
|
+
for (let qi = 0; qi < questions.length; qi++) {
|
|
20623
|
+
const q = questions[qi];
|
|
20624
|
+
let msg = "";
|
|
20625
|
+
if (q.header)
|
|
20626
|
+
msg += `*${q.header}*\n`;
|
|
20627
|
+
msg += q.question;
|
|
20628
|
+
const keyboard = q.options.map((opt, oi) => [
|
|
20629
|
+
{
|
|
20630
|
+
text: opt.label,
|
|
20631
|
+
callback_data: `qa:${questionId}:${qi}:${oi}`,
|
|
20632
|
+
},
|
|
20633
|
+
]);
|
|
20634
|
+
// Add a dismiss/reject button
|
|
20635
|
+
keyboard.push([
|
|
20636
|
+
{ text: "Dismiss", callback_data: `qa_reject:${questionId}` },
|
|
20637
|
+
]);
|
|
20638
|
+
await bot.telegram.sendMessage(chatId, msg, {
|
|
20639
|
+
parse_mode: "Markdown",
|
|
20640
|
+
reply_markup: {
|
|
20641
|
+
inline_keyboard: keyboard,
|
|
20642
|
+
},
|
|
20643
|
+
});
|
|
20644
|
+
}
|
|
20645
|
+
}
|
|
20646
|
+
}
|
|
20647
|
+
}
|
|
19202
20648
|
}
|
|
19203
20649
|
}
|
|
19204
20650
|
finally {
|
|
@@ -19234,10 +20680,11 @@ async function startTelegram(options) {
|
|
|
19234
20680
|
return true;
|
|
19235
20681
|
});
|
|
19236
20682
|
const cleaned = filtered.join("\n").trim();
|
|
19237
|
-
|
|
19238
|
-
|
|
20683
|
+
// If the cleaned text is non-empty, use it; otherwise keep the
|
|
20684
|
+
// original finalText so the user still sees the agent's conclusion.
|
|
20685
|
+
if (cleaned) {
|
|
20686
|
+
finalText = cleaned;
|
|
19239
20687
|
}
|
|
19240
|
-
finalText = cleaned;
|
|
19241
20688
|
}
|
|
19242
20689
|
const chunks = splitMessage(finalText, 4096);
|
|
19243
20690
|
for (const chunk of chunks) {
|
|
@@ -19270,10 +20717,16 @@ async function startTelegram(options) {
|
|
|
19270
20717
|
}
|
|
19271
20718
|
const promptBody = buildPromptBody(chatId, parts);
|
|
19272
20719
|
const verbose = chatVerboseMode.has(chatId);
|
|
19273
|
-
|
|
20720
|
+
// Fire detached so the handler completes and Telegraf can process
|
|
20721
|
+
// subsequent updates (e.g. callback queries from question buttons).
|
|
20722
|
+
sendPromptStreaming(ctx.chat.id, sessionId, promptBody, processingMsg.message_id, verbose).catch(async (err) => {
|
|
20723
|
+
console.error("[Telegram] Error processing file message:", err);
|
|
20724
|
+
await handleSessionError(chatId);
|
|
20725
|
+
await sendTelegramMessage(ctx.chat.id, "Sorry, there was an error processing your request. Try again or use /new to start a fresh session.");
|
|
20726
|
+
});
|
|
19274
20727
|
}
|
|
19275
20728
|
catch (err) {
|
|
19276
|
-
console.error("[Telegram] Error
|
|
20729
|
+
console.error("[Telegram] Error setting up file message:", err);
|
|
19277
20730
|
await handleSessionError(chatId);
|
|
19278
20731
|
await ctx.reply("Sorry, there was an error processing your request. Try again or use /new to start a fresh session.");
|
|
19279
20732
|
}
|
|
@@ -19286,7 +20739,7 @@ async function startTelegram(options) {
|
|
|
19286
20739
|
if (sessionId) {
|
|
19287
20740
|
try {
|
|
19288
20741
|
const check = await client.session.get({
|
|
19289
|
-
|
|
20742
|
+
sessionID: sessionId,
|
|
19290
20743
|
});
|
|
19291
20744
|
if (check.error) {
|
|
19292
20745
|
chatSessions.delete(chatId);
|
|
@@ -19304,7 +20757,7 @@ async function startTelegram(options) {
|
|
|
19304
20757
|
// Initialize Telegram bot
|
|
19305
20758
|
const bot = options.botFactory
|
|
19306
20759
|
? options.botFactory(token)
|
|
19307
|
-
: new lib.Telegraf(token);
|
|
20760
|
+
: new lib.Telegraf(token, { handlerTimeout: 600_000 });
|
|
19308
20761
|
async function registerCommandMenu() {
|
|
19309
20762
|
const combined = [...telegramCommandMenu, ...opencodeCommandMenu];
|
|
19310
20763
|
const seen = new Set();
|
|
@@ -19324,6 +20777,11 @@ async function startTelegram(options) {
|
|
|
19324
20777
|
console.warn("[Telegram] Failed to register command menu:", err);
|
|
19325
20778
|
}
|
|
19326
20779
|
}
|
|
20780
|
+
// Global error handler — prevents unhandled errors from crashing the process
|
|
20781
|
+
bot.catch((err, ctx) => {
|
|
20782
|
+
const updateType = ctx?.updateType || "unknown";
|
|
20783
|
+
console.error(`[Telegram] Unhandled error in ${updateType} handler:`, err);
|
|
20784
|
+
});
|
|
19327
20785
|
// Middleware to check if the user is authorized
|
|
19328
20786
|
bot.use((ctx, next) => {
|
|
19329
20787
|
if (!authorizedUserId) {
|
|
@@ -19396,7 +20854,7 @@ async function startTelegram(options) {
|
|
|
19396
20854
|
* Get the list of known sessions, sorted by most recently updated.
|
|
19397
20855
|
*/
|
|
19398
20856
|
async function getKnownSessions() {
|
|
19399
|
-
const list = await client.session.list();
|
|
20857
|
+
const list = await client.session.list({});
|
|
19400
20858
|
const data = (list.data || []);
|
|
19401
20859
|
if (data.length === 0)
|
|
19402
20860
|
return [];
|
|
@@ -19496,8 +20954,8 @@ async function startTelegram(options) {
|
|
|
19496
20954
|
}
|
|
19497
20955
|
try {
|
|
19498
20956
|
const result = await client.session.update({
|
|
19499
|
-
|
|
19500
|
-
|
|
20957
|
+
sessionID: sessionId,
|
|
20958
|
+
title: newTitle,
|
|
19501
20959
|
});
|
|
19502
20960
|
if (result.error) {
|
|
19503
20961
|
throw new Error(JSON.stringify(result.error));
|
|
@@ -19533,7 +20991,7 @@ async function startTelegram(options) {
|
|
|
19533
20991
|
}
|
|
19534
20992
|
// Delete from the server
|
|
19535
20993
|
const result = await client.session.delete({
|
|
19536
|
-
|
|
20994
|
+
sessionID: match.id,
|
|
19537
20995
|
});
|
|
19538
20996
|
if (result.error) {
|
|
19539
20997
|
throw new Error(JSON.stringify(result.error));
|
|
@@ -19589,7 +21047,7 @@ async function startTelegram(options) {
|
|
|
19589
21047
|
return;
|
|
19590
21048
|
}
|
|
19591
21049
|
const result = await client.session.delete({
|
|
19592
|
-
|
|
21050
|
+
sessionID: match.id,
|
|
19593
21051
|
});
|
|
19594
21052
|
if (result.error) {
|
|
19595
21053
|
throw new Error(JSON.stringify(result.error));
|
|
@@ -19634,7 +21092,7 @@ async function startTelegram(options) {
|
|
|
19634
21092
|
* Fetch and search available models from connected providers.
|
|
19635
21093
|
*/
|
|
19636
21094
|
async function searchModels(keyword) {
|
|
19637
|
-
const list = await client.provider.list();
|
|
21095
|
+
const list = await client.provider.list({});
|
|
19638
21096
|
if (list.error || !list.data) {
|
|
19639
21097
|
throw new Error(`Failed to list providers: ${JSON.stringify(list.error)}`);
|
|
19640
21098
|
}
|
|
@@ -19738,6 +21196,73 @@ async function startTelegram(options) {
|
|
|
19738
21196
|
saveSessions();
|
|
19739
21197
|
await answerAndEdit(ctx, "Model reset to the default model.");
|
|
19740
21198
|
});
|
|
21199
|
+
// Handle question answer callback (from OpenCode question.asked events)
|
|
21200
|
+
bot.action(/^qa:([^:]+):(\d+):(\d+)$/, async (ctx) => {
|
|
21201
|
+
console.log("[Telegram] Question answer callback received:", ctx.match?.[0]);
|
|
21202
|
+
const questionId = ctx.match?.[1];
|
|
21203
|
+
const questionIndex = Number.parseInt(ctx.match?.[2] || "0", 10);
|
|
21204
|
+
const optionIndex = Number.parseInt(ctx.match?.[3] || "0", 10);
|
|
21205
|
+
if (!questionId)
|
|
21206
|
+
return;
|
|
21207
|
+
const pending = pendingQuestions.get(questionId);
|
|
21208
|
+
if (!pending) {
|
|
21209
|
+
await answerAndEdit(ctx, "This question has expired or was already answered.");
|
|
21210
|
+
return;
|
|
21211
|
+
}
|
|
21212
|
+
const question = pending.questions[questionIndex];
|
|
21213
|
+
if (!question) {
|
|
21214
|
+
await answerAndEdit(ctx, "Invalid question.");
|
|
21215
|
+
return;
|
|
21216
|
+
}
|
|
21217
|
+
const selectedOption = question.options[optionIndex];
|
|
21218
|
+
if (!selectedOption) {
|
|
21219
|
+
await answerAndEdit(ctx, "Invalid option.");
|
|
21220
|
+
return;
|
|
21221
|
+
}
|
|
21222
|
+
try {
|
|
21223
|
+
// Build answers array: one answer per question, using the selected option label
|
|
21224
|
+
const answers = pending.questions.map((q, i) => {
|
|
21225
|
+
if (i === questionIndex) {
|
|
21226
|
+
return [selectedOption.label];
|
|
21227
|
+
}
|
|
21228
|
+
// For other questions in the same request, auto-select first option
|
|
21229
|
+
return [q.options[0]?.label || ""];
|
|
21230
|
+
});
|
|
21231
|
+
await client.question.reply({
|
|
21232
|
+
requestID: questionId,
|
|
21233
|
+
answers,
|
|
21234
|
+
});
|
|
21235
|
+
pendingQuestions.delete(questionId);
|
|
21236
|
+
await answerAndEdit(ctx, `Answered: ${selectedOption.label}`);
|
|
21237
|
+
}
|
|
21238
|
+
catch (err) {
|
|
21239
|
+
console.error("[Telegram] Error answering question:", err);
|
|
21240
|
+
await answerAndEdit(ctx, "Failed to submit answer.");
|
|
21241
|
+
}
|
|
21242
|
+
});
|
|
21243
|
+
// Handle question reject/dismiss callback
|
|
21244
|
+
bot.action(/^qa_reject:(.+)$/, async (ctx) => {
|
|
21245
|
+
console.log("[Telegram] Question reject callback received:", ctx.match?.[0]);
|
|
21246
|
+
const questionId = ctx.match?.[1];
|
|
21247
|
+
if (!questionId)
|
|
21248
|
+
return;
|
|
21249
|
+
const pending = pendingQuestions.get(questionId);
|
|
21250
|
+
if (!pending) {
|
|
21251
|
+
await answerAndEdit(ctx, "This question has expired or was already answered.");
|
|
21252
|
+
return;
|
|
21253
|
+
}
|
|
21254
|
+
try {
|
|
21255
|
+
await client.question.reject({
|
|
21256
|
+
requestID: questionId,
|
|
21257
|
+
});
|
|
21258
|
+
pendingQuestions.delete(questionId);
|
|
21259
|
+
await answerAndEdit(ctx, "Question dismissed.");
|
|
21260
|
+
}
|
|
21261
|
+
catch (err) {
|
|
21262
|
+
console.error("[Telegram] Error rejecting question:", err);
|
|
21263
|
+
await answerAndEdit(ctx, "Failed to dismiss question.");
|
|
21264
|
+
}
|
|
21265
|
+
});
|
|
19741
21266
|
// Handle /usage command - show token and cost usage for current session
|
|
19742
21267
|
bot.command("usage", async (ctx) => {
|
|
19743
21268
|
const chatId = ctx.chat.id.toString();
|
|
@@ -19748,7 +21273,7 @@ async function startTelegram(options) {
|
|
|
19748
21273
|
}
|
|
19749
21274
|
try {
|
|
19750
21275
|
const messagesResult = await client.session.messages({
|
|
19751
|
-
|
|
21276
|
+
sessionID: sessionId,
|
|
19752
21277
|
});
|
|
19753
21278
|
if (messagesResult.error || !messagesResult.data) {
|
|
19754
21279
|
throw new Error(`Failed to get messages: ${JSON.stringify(messagesResult.error)}`);
|
|
@@ -19946,9 +21471,9 @@ async function startTelegram(options) {
|
|
|
19946
21471
|
const processingMsg = await ctx.reply(`Exporting session (${modeLabel})...`);
|
|
19947
21472
|
// Fetch session info and messages in parallel
|
|
19948
21473
|
const [sessionResult, messagesResult, pathResult] = await Promise.all([
|
|
19949
|
-
client.session.get({
|
|
19950
|
-
client.session.messages({
|
|
19951
|
-
client.path.get(),
|
|
21474
|
+
client.session.get({ sessionID: sessionId }),
|
|
21475
|
+
client.session.messages({ sessionID: sessionId }),
|
|
21476
|
+
client.path.get({}),
|
|
19952
21477
|
]);
|
|
19953
21478
|
if (sessionResult.error || !sessionResult.data) {
|
|
19954
21479
|
throw new Error(`Failed to get session: ${JSON.stringify(sessionResult.error)}`);
|
|
@@ -20063,12 +21588,10 @@ async function startTelegram(options) {
|
|
|
20063
21588
|
const processingMsg = await ctx.reply("Processing your command...");
|
|
20064
21589
|
const sessionId = await getOrCreateSession(chatId);
|
|
20065
21590
|
const result = await client.session.command({
|
|
20066
|
-
|
|
20067
|
-
|
|
20068
|
-
|
|
20069
|
-
|
|
20070
|
-
agent: "default",
|
|
20071
|
-
},
|
|
21591
|
+
sessionID: sessionId,
|
|
21592
|
+
command: commandName,
|
|
21593
|
+
arguments: commandArgs,
|
|
21594
|
+
agent: "default",
|
|
20072
21595
|
});
|
|
20073
21596
|
if (result.error) {
|
|
20074
21597
|
throw new Error(`Command failed: ${JSON.stringify(result.error)}`);
|
|
@@ -20094,19 +21617,89 @@ async function startTelegram(options) {
|
|
|
20094
21617
|
{ type: "text", text: userText },
|
|
20095
21618
|
]);
|
|
20096
21619
|
const verbose = chatVerboseMode.has(chatId);
|
|
20097
|
-
|
|
21620
|
+
// Fire detached so the handler completes and Telegraf can process
|
|
21621
|
+
// subsequent updates (e.g. callback queries from question buttons).
|
|
21622
|
+
sendPromptStreaming(ctx.chat.id, sessionId, promptBody, processingMsg.message_id, verbose).catch(async (err) => {
|
|
21623
|
+
console.error("[Telegram] Error processing message:", err);
|
|
21624
|
+
await handleSessionError(chatId);
|
|
21625
|
+
await sendTelegramMessage(ctx.chat.id, "Sorry, there was an error processing your request. Try again or use /new to start a fresh session.");
|
|
21626
|
+
});
|
|
20098
21627
|
}
|
|
20099
21628
|
catch (err) {
|
|
20100
|
-
console.error("[Telegram] Error
|
|
21629
|
+
console.error("[Telegram] Error setting up message:", err);
|
|
20101
21630
|
await handleSessionError(chatId);
|
|
20102
21631
|
await ctx.reply("Sorry, there was an error processing your request. Try again or use /new to start a fresh session.");
|
|
20103
21632
|
}
|
|
20104
21633
|
});
|
|
21634
|
+
// Check for pending questions left over from previous bot runs.
|
|
21635
|
+
// If any exist for a session we know about, re-forward them to Telegram
|
|
21636
|
+
// so the user can answer them and unblock the session.
|
|
21637
|
+
try {
|
|
21638
|
+
const pendingResult = await client.question.list({});
|
|
21639
|
+
if (pendingResult.data && pendingResult.data.length > 0) {
|
|
21640
|
+
console.log(`[Telegram] Found ${pendingResult.data.length} pending question(s) from previous run`);
|
|
21641
|
+
for (const pq of pendingResult.data) {
|
|
21642
|
+
const questionId = pq.id;
|
|
21643
|
+
const questionSessionId = pq.sessionID;
|
|
21644
|
+
const questions = pq.questions;
|
|
21645
|
+
const chatId = sessionToChatId(questionSessionId);
|
|
21646
|
+
if (!chatId || !questionId || !questions?.length) {
|
|
21647
|
+
// No matching chat — reject the stale question to unblock the session
|
|
21648
|
+
console.log(`[Telegram] Rejecting orphan pending question ${questionId} (no matching chat)`);
|
|
21649
|
+
try {
|
|
21650
|
+
await client.question.reject({ requestID: questionId });
|
|
21651
|
+
}
|
|
21652
|
+
catch (err) {
|
|
21653
|
+
console.warn(`[Telegram] Failed to reject orphan question ${questionId}:`, err);
|
|
21654
|
+
}
|
|
21655
|
+
continue;
|
|
21656
|
+
}
|
|
21657
|
+
// Store in pendingQuestions and re-send inline keyboard
|
|
21658
|
+
pendingQuestions.set(questionId, {
|
|
21659
|
+
chatId,
|
|
21660
|
+
sessionId: questionSessionId,
|
|
21661
|
+
questions,
|
|
21662
|
+
});
|
|
21663
|
+
const numericChatId = Number(chatId);
|
|
21664
|
+
for (let qi = 0; qi < questions.length; qi++) {
|
|
21665
|
+
const q = questions[qi];
|
|
21666
|
+
let msg = "";
|
|
21667
|
+
if (q.header)
|
|
21668
|
+
msg += `*${q.header}*\n`;
|
|
21669
|
+
msg += q.question;
|
|
21670
|
+
msg += "\n_(resumed from previous session)_";
|
|
21671
|
+
const keyboard = q.options.map((opt, oi) => [
|
|
21672
|
+
{
|
|
21673
|
+
text: opt.label,
|
|
21674
|
+
callback_data: `qa:${questionId}:${qi}:${oi}`,
|
|
21675
|
+
},
|
|
21676
|
+
]);
|
|
21677
|
+
keyboard.push([
|
|
21678
|
+
{ text: "Dismiss", callback_data: `qa_reject:${questionId}` },
|
|
21679
|
+
]);
|
|
21680
|
+
try {
|
|
21681
|
+
await bot.telegram.sendMessage(numericChatId, msg, {
|
|
21682
|
+
parse_mode: "Markdown",
|
|
21683
|
+
reply_markup: { inline_keyboard: keyboard },
|
|
21684
|
+
});
|
|
21685
|
+
}
|
|
21686
|
+
catch (err) {
|
|
21687
|
+
console.warn(`[Telegram] Failed to re-send question to chat ${chatId}:`, err);
|
|
21688
|
+
}
|
|
21689
|
+
}
|
|
21690
|
+
console.log(`[Telegram] Re-forwarded pending question ${questionId} to chat ${chatId}`);
|
|
21691
|
+
}
|
|
21692
|
+
}
|
|
21693
|
+
}
|
|
21694
|
+
catch (err) {
|
|
21695
|
+
console.warn("[Telegram] Failed to check for pending questions:", err);
|
|
21696
|
+
}
|
|
20105
21697
|
if (options.launch !== false) {
|
|
20106
21698
|
try {
|
|
20107
|
-
// Start the bot
|
|
20108
|
-
|
|
20109
|
-
console.log("[Telegram] Bot is running");
|
|
21699
|
+
// Start the bot — launch() returns a promise that resolves only
|
|
21700
|
+
// when polling stops, so we log before awaiting it.
|
|
21701
|
+
console.log("[Telegram] Bot is running (long-polling started)");
|
|
21702
|
+
await bot.launch({ dropPendingUpdates: true });
|
|
20110
21703
|
// Enable graceful stop
|
|
20111
21704
|
process.once("SIGINT", () => bot.stop("SIGINT"));
|
|
20112
21705
|
process.once("SIGTERM", () => bot.stop("SIGTERM"));
|