opencode-telegram-bot 1.0.9 → 1.1.0
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 +53 -1
- package/dist/app.d.ts +28 -14
- package/dist/index.js +2423 -642
- 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",
|
|
17628
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",
|
|
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({
|
|
17969
|
+
url: "/config",
|
|
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({
|
|
17647
17989
|
url: "/config",
|
|
17648
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",
|
|
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",
|
|
17703
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",
|
|
18625
|
+
...options,
|
|
18626
|
+
...params,
|
|
18627
|
+
headers: {
|
|
18628
|
+
"Content-Type": "application/json",
|
|
18629
|
+
...options?.headers,
|
|
18630
|
+
...params.headers,
|
|
18631
|
+
},
|
|
18632
|
+
});
|
|
18633
|
+
}
|
|
18634
|
+
/**
|
|
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",
|
|
17924
18653
|
...options,
|
|
18654
|
+
...params,
|
|
17925
18655
|
headers: {
|
|
17926
18656
|
"Content-Type": "application/json",
|
|
17927
|
-
...options
|
|
18657
|
+
...options?.headers,
|
|
18658
|
+
...params.headers,
|
|
17928
18659
|
},
|
|
17929
18660
|
});
|
|
17930
18661
|
}
|
|
17931
18662
|
/**
|
|
17932
|
-
*
|
|
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",
|
|
18680
|
+
...options,
|
|
18681
|
+
...params,
|
|
18682
|
+
headers: {
|
|
18683
|
+
"Content-Type": "application/json",
|
|
18684
|
+
...options?.headers,
|
|
18685
|
+
...params.headers,
|
|
18686
|
+
},
|
|
18687
|
+
});
|
|
18688
|
+
}
|
|
18689
|
+
/**
|
|
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",
|
|
18705
|
+
...options,
|
|
18706
|
+
...params,
|
|
18707
|
+
});
|
|
18708
|
+
}
|
|
18709
|
+
}
|
|
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
|
+
}
|
|
18731
|
+
/**
|
|
18732
|
+
* Update a part in a message
|
|
17933
18733
|
*/
|
|
17934
|
-
|
|
17935
|
-
|
|
17936
|
-
|
|
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}",
|
|
17937
18748
|
...options,
|
|
18749
|
+
...params,
|
|
17938
18750
|
headers: {
|
|
17939
18751
|
"Content-Type": "application/json",
|
|
17940
|
-
...options
|
|
18752
|
+
...options?.headers,
|
|
18753
|
+
...params.headers,
|
|
17941
18754
|
},
|
|
17942
18755
|
});
|
|
17943
18756
|
}
|
|
18757
|
+
}
|
|
18758
|
+
class Permission extends HeyApiClient {
|
|
17944
18759
|
/**
|
|
17945
|
-
*
|
|
18760
|
+
* Respond to permission
|
|
18761
|
+
*
|
|
18762
|
+
* Approve or deny a permission request from the AI assistant.
|
|
18763
|
+
*
|
|
18764
|
+
* @deprecated
|
|
17946
18765
|
*/
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
|
|
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}",
|
|
17950
18779
|
...options,
|
|
18780
|
+
...params,
|
|
17951
18781
|
headers: {
|
|
17952
18782
|
"Content-Type": "application/json",
|
|
17953
|
-
...options
|
|
18783
|
+
...options?.headers,
|
|
18784
|
+
...params.headers,
|
|
18785
|
+
},
|
|
18786
|
+
});
|
|
18787
|
+
}
|
|
18788
|
+
/**
|
|
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",
|
|
18806
|
+
...options,
|
|
18807
|
+
...params,
|
|
18808
|
+
headers: {
|
|
18809
|
+
"Content-Type": "application/json",
|
|
18810
|
+
...options?.headers,
|
|
18811
|
+
...params.headers,
|
|
17954
18812
|
},
|
|
17955
18813
|
});
|
|
17956
18814
|
}
|
|
17957
18815
|
/**
|
|
17958
|
-
*
|
|
18816
|
+
* List pending permissions
|
|
18817
|
+
*
|
|
18818
|
+
* Get all pending permission requests across all sessions.
|
|
17959
18819
|
*/
|
|
17960
|
-
|
|
17961
|
-
|
|
17962
|
-
|
|
18820
|
+
list(parameters, options) {
|
|
18821
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18822
|
+
return (options?.client ?? this.client).get({
|
|
18823
|
+
url: "/permission",
|
|
17963
18824
|
...options,
|
|
18825
|
+
...params,
|
|
17964
18826
|
});
|
|
17965
18827
|
}
|
|
17966
18828
|
}
|
|
17967
|
-
class
|
|
18829
|
+
class Question extends HeyApiClient {
|
|
17968
18830
|
/**
|
|
17969
|
-
* List
|
|
18831
|
+
* List pending questions
|
|
18832
|
+
*
|
|
18833
|
+
* Get all pending question requests across all sessions.
|
|
17970
18834
|
*/
|
|
17971
|
-
list(options) {
|
|
17972
|
-
|
|
17973
|
-
|
|
18835
|
+
list(parameters, options) {
|
|
18836
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18837
|
+
return (options?.client ?? this.client).get({
|
|
18838
|
+
url: "/question",
|
|
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",
|
|
17974
18885
|
...options,
|
|
18886
|
+
...params,
|
|
17975
18887
|
});
|
|
17976
18888
|
}
|
|
17977
18889
|
}
|
|
17978
|
-
class Oauth extends
|
|
18890
|
+
class Oauth extends HeyApiClient {
|
|
17979
18891
|
/**
|
|
17980
|
-
*
|
|
17981
|
-
|
|
17982
|
-
|
|
17983
|
-
|
|
17984
|
-
|
|
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",
|
|
17985
18908
|
...options,
|
|
18909
|
+
...params,
|
|
17986
18910
|
headers: {
|
|
17987
18911
|
"Content-Type": "application/json",
|
|
17988
|
-
...options
|
|
18912
|
+
...options?.headers,
|
|
18913
|
+
...params.headers,
|
|
17989
18914
|
},
|
|
17990
18915
|
});
|
|
17991
18916
|
}
|
|
17992
18917
|
/**
|
|
17993
|
-
*
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
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",
|
|
17998
18935
|
...options,
|
|
18936
|
+
...params,
|
|
17999
18937
|
headers: {
|
|
18000
18938
|
"Content-Type": "application/json",
|
|
18001
|
-
...options
|
|
18939
|
+
...options?.headers,
|
|
18940
|
+
...params.headers,
|
|
18002
18941
|
},
|
|
18003
18942
|
});
|
|
18004
18943
|
}
|
|
18005
18944
|
}
|
|
18006
|
-
class Provider extends
|
|
18945
|
+
class Provider extends HeyApiClient {
|
|
18007
18946
|
/**
|
|
18008
|
-
* List
|
|
18947
|
+
* List providers
|
|
18948
|
+
*
|
|
18949
|
+
* Get a list of all available AI providers, including both available and connected ones.
|
|
18009
18950
|
*/
|
|
18010
|
-
list(options) {
|
|
18011
|
-
|
|
18951
|
+
list(parameters, options) {
|
|
18952
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18953
|
+
return (options?.client ?? this.client).get({
|
|
18012
18954
|
url: "/provider",
|
|
18013
18955
|
...options,
|
|
18956
|
+
...params,
|
|
18014
18957
|
});
|
|
18015
18958
|
}
|
|
18016
18959
|
/**
|
|
18017
|
-
* Get provider
|
|
18960
|
+
* Get provider auth methods
|
|
18961
|
+
*
|
|
18962
|
+
* Retrieve available authentication methods for all AI providers.
|
|
18018
18963
|
*/
|
|
18019
|
-
auth(options) {
|
|
18020
|
-
|
|
18964
|
+
auth(parameters, options) {
|
|
18965
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
18966
|
+
return (options?.client ?? this.client).get({
|
|
18021
18967
|
url: "/provider/auth",
|
|
18022
18968
|
...options,
|
|
18969
|
+
...params,
|
|
18023
18970
|
});
|
|
18024
18971
|
}
|
|
18025
|
-
|
|
18972
|
+
_oauth;
|
|
18973
|
+
get oauth() {
|
|
18974
|
+
return (this._oauth ??= new Oauth({ client: this.client }));
|
|
18975
|
+
}
|
|
18026
18976
|
}
|
|
18027
|
-
class Find extends
|
|
18977
|
+
class Find extends HeyApiClient {
|
|
18028
18978
|
/**
|
|
18029
|
-
* Find text
|
|
18030
|
-
|
|
18031
|
-
|
|
18032
|
-
|
|
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({
|
|
18033
18993
|
url: "/find",
|
|
18034
18994
|
...options,
|
|
18995
|
+
...params,
|
|
18035
18996
|
});
|
|
18036
18997
|
}
|
|
18037
18998
|
/**
|
|
18038
18999
|
* Find files
|
|
18039
|
-
|
|
18040
|
-
|
|
18041
|
-
|
|
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({
|
|
18042
19016
|
url: "/find/file",
|
|
18043
19017
|
...options,
|
|
19018
|
+
...params,
|
|
18044
19019
|
});
|
|
18045
19020
|
}
|
|
18046
19021
|
/**
|
|
18047
|
-
* Find
|
|
18048
|
-
|
|
18049
|
-
|
|
18050
|
-
|
|
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({
|
|
18051
19036
|
url: "/find/symbol",
|
|
18052
19037
|
...options,
|
|
19038
|
+
...params,
|
|
18053
19039
|
});
|
|
18054
19040
|
}
|
|
18055
19041
|
}
|
|
18056
|
-
class File extends
|
|
19042
|
+
class File extends HeyApiClient {
|
|
18057
19043
|
/**
|
|
18058
|
-
* List files
|
|
18059
|
-
|
|
18060
|
-
|
|
18061
|
-
|
|
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({
|
|
18062
19058
|
url: "/file",
|
|
18063
19059
|
...options,
|
|
19060
|
+
...params,
|
|
18064
19061
|
});
|
|
18065
19062
|
}
|
|
18066
19063
|
/**
|
|
18067
|
-
* Read
|
|
18068
|
-
|
|
18069
|
-
|
|
18070
|
-
|
|
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
|
+
],
|
|
19075
|
+
},
|
|
19076
|
+
]);
|
|
19077
|
+
return (options?.client ?? this.client).get({
|
|
18071
19078
|
url: "/file/content",
|
|
18072
19079
|
...options,
|
|
19080
|
+
...params,
|
|
18073
19081
|
});
|
|
18074
19082
|
}
|
|
18075
19083
|
/**
|
|
18076
19084
|
* Get file status
|
|
19085
|
+
*
|
|
19086
|
+
* Get the git status of all files in the project.
|
|
18077
19087
|
*/
|
|
18078
|
-
status(options) {
|
|
18079
|
-
|
|
19088
|
+
status(parameters, options) {
|
|
19089
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19090
|
+
return (options?.client ?? this.client).get({
|
|
18080
19091
|
url: "/file/status",
|
|
18081
19092
|
...options,
|
|
19093
|
+
...params,
|
|
18082
19094
|
});
|
|
18083
19095
|
}
|
|
18084
19096
|
}
|
|
18085
|
-
class
|
|
19097
|
+
class Auth2 extends HeyApiClient {
|
|
18086
19098
|
/**
|
|
18087
|
-
*
|
|
19099
|
+
* Remove MCP OAuth
|
|
19100
|
+
*
|
|
19101
|
+
* Remove OAuth credentials for an MCP server
|
|
18088
19102
|
*/
|
|
18089
|
-
|
|
18090
|
-
|
|
18091
|
-
|
|
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({
|
|
19113
|
+
url: "/mcp/{name}/auth",
|
|
19114
|
+
...options,
|
|
19115
|
+
...params,
|
|
19116
|
+
});
|
|
19117
|
+
}
|
|
19118
|
+
/**
|
|
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({
|
|
19133
|
+
url: "/mcp/{name}/auth",
|
|
18092
19134
|
...options,
|
|
19135
|
+
...params,
|
|
19136
|
+
});
|
|
19137
|
+
}
|
|
19138
|
+
/**
|
|
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({
|
|
19154
|
+
url: "/mcp/{name}/auth/callback",
|
|
19155
|
+
...options,
|
|
19156
|
+
...params,
|
|
18093
19157
|
headers: {
|
|
18094
19158
|
"Content-Type": "application/json",
|
|
18095
19159
|
...options?.headers,
|
|
19160
|
+
...params.headers,
|
|
18096
19161
|
},
|
|
18097
19162
|
});
|
|
18098
19163
|
}
|
|
18099
19164
|
/**
|
|
18100
|
-
*
|
|
19165
|
+
* Authenticate MCP OAuth
|
|
19166
|
+
*
|
|
19167
|
+
* Start OAuth flow and wait for callback (opens browser)
|
|
18101
19168
|
*/
|
|
18102
|
-
|
|
18103
|
-
|
|
18104
|
-
|
|
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({
|
|
19179
|
+
url: "/mcp/{name}/auth/authenticate",
|
|
18105
19180
|
...options,
|
|
19181
|
+
...params,
|
|
18106
19182
|
});
|
|
18107
19183
|
}
|
|
18108
19184
|
}
|
|
18109
|
-
class
|
|
19185
|
+
class Mcp extends HeyApiClient {
|
|
18110
19186
|
/**
|
|
18111
|
-
*
|
|
19187
|
+
* Get MCP status
|
|
19188
|
+
*
|
|
19189
|
+
* Get the status of all Model Context Protocol (MCP) servers.
|
|
18112
19190
|
*/
|
|
18113
|
-
|
|
18114
|
-
|
|
18115
|
-
|
|
19191
|
+
status(parameters, options) {
|
|
19192
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19193
|
+
return (options?.client ?? this.client).get({
|
|
19194
|
+
url: "/mcp",
|
|
18116
19195
|
...options,
|
|
19196
|
+
...params,
|
|
18117
19197
|
});
|
|
18118
19198
|
}
|
|
18119
19199
|
/**
|
|
18120
|
-
*
|
|
18121
|
-
|
|
18122
|
-
|
|
18123
|
-
|
|
18124
|
-
|
|
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({
|
|
19215
|
+
url: "/mcp",
|
|
18125
19216
|
...options,
|
|
19217
|
+
...params,
|
|
19218
|
+
headers: {
|
|
19219
|
+
"Content-Type": "application/json",
|
|
19220
|
+
...options?.headers,
|
|
19221
|
+
...params.headers,
|
|
19222
|
+
},
|
|
18126
19223
|
});
|
|
18127
19224
|
}
|
|
18128
19225
|
/**
|
|
18129
|
-
*
|
|
19226
|
+
* Connect an MCP server
|
|
18130
19227
|
*/
|
|
18131
|
-
|
|
18132
|
-
|
|
18133
|
-
|
|
18134
|
-
|
|
18135
|
-
|
|
18136
|
-
|
|
18137
|
-
|
|
19228
|
+
connect(parameters, options) {
|
|
19229
|
+
const params = buildClientParams([parameters], [
|
|
19230
|
+
{
|
|
19231
|
+
args: [
|
|
19232
|
+
{ in: "path", key: "name" },
|
|
19233
|
+
{ in: "query", key: "directory" },
|
|
19234
|
+
],
|
|
18138
19235
|
},
|
|
19236
|
+
]);
|
|
19237
|
+
return (options?.client ?? this.client).post({
|
|
19238
|
+
url: "/mcp/{name}/connect",
|
|
19239
|
+
...options,
|
|
19240
|
+
...params,
|
|
18139
19241
|
});
|
|
18140
19242
|
}
|
|
18141
19243
|
/**
|
|
18142
|
-
*
|
|
19244
|
+
* Disconnect an MCP server
|
|
18143
19245
|
*/
|
|
18144
|
-
|
|
18145
|
-
|
|
18146
|
-
|
|
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({
|
|
19256
|
+
url: "/mcp/{name}/disconnect",
|
|
18147
19257
|
...options,
|
|
19258
|
+
...params,
|
|
18148
19259
|
});
|
|
18149
19260
|
}
|
|
19261
|
+
_auth;
|
|
19262
|
+
get auth() {
|
|
19263
|
+
return (this._auth ??= new Auth2({ client: this.client }));
|
|
19264
|
+
}
|
|
19265
|
+
}
|
|
19266
|
+
class Control extends HeyApiClient {
|
|
18150
19267
|
/**
|
|
18151
|
-
*
|
|
19268
|
+
* Get next TUI request
|
|
19269
|
+
*
|
|
19270
|
+
* Retrieve the next TUI (Terminal User Interface) request from the queue for processing.
|
|
18152
19271
|
*/
|
|
18153
|
-
|
|
18154
|
-
|
|
18155
|
-
|
|
19272
|
+
next(parameters, options) {
|
|
19273
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19274
|
+
return (options?.client ?? this.client).get({
|
|
19275
|
+
url: "/tui/control/next",
|
|
18156
19276
|
...options,
|
|
19277
|
+
...params,
|
|
19278
|
+
});
|
|
19279
|
+
}
|
|
19280
|
+
/**
|
|
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({
|
|
19295
|
+
url: "/tui/control/response",
|
|
19296
|
+
...options,
|
|
19297
|
+
...params,
|
|
18157
19298
|
headers: {
|
|
18158
19299
|
"Content-Type": "application/json",
|
|
18159
|
-
...options
|
|
19300
|
+
...options?.headers,
|
|
19301
|
+
...params.headers,
|
|
18160
19302
|
},
|
|
18161
19303
|
});
|
|
18162
19304
|
}
|
|
18163
19305
|
}
|
|
18164
|
-
class
|
|
19306
|
+
class Tui extends HeyApiClient {
|
|
18165
19307
|
/**
|
|
18166
|
-
*
|
|
19308
|
+
* Append TUI prompt
|
|
19309
|
+
*
|
|
19310
|
+
* Append prompt to the TUI
|
|
18167
19311
|
*/
|
|
18168
|
-
|
|
18169
|
-
|
|
18170
|
-
|
|
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({
|
|
19322
|
+
url: "/tui/append-prompt",
|
|
18171
19323
|
...options,
|
|
19324
|
+
...params,
|
|
19325
|
+
headers: {
|
|
19326
|
+
"Content-Type": "application/json",
|
|
19327
|
+
...options?.headers,
|
|
19328
|
+
...params.headers,
|
|
19329
|
+
},
|
|
18172
19330
|
});
|
|
18173
19331
|
}
|
|
18174
19332
|
/**
|
|
18175
|
-
*
|
|
19333
|
+
* Open help dialog
|
|
19334
|
+
*
|
|
19335
|
+
* Open the help dialog in the TUI to display user assistance information.
|
|
18176
19336
|
*/
|
|
18177
|
-
|
|
18178
|
-
|
|
18179
|
-
|
|
19337
|
+
openHelp(parameters, options) {
|
|
19338
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19339
|
+
return (options?.client ?? this.client).post({
|
|
19340
|
+
url: "/tui/open-help",
|
|
18180
19341
|
...options,
|
|
18181
|
-
|
|
18182
|
-
"Content-Type": "application/json",
|
|
18183
|
-
...options?.headers,
|
|
18184
|
-
},
|
|
19342
|
+
...params,
|
|
18185
19343
|
});
|
|
18186
19344
|
}
|
|
18187
19345
|
/**
|
|
18188
|
-
*
|
|
19346
|
+
* Open sessions dialog
|
|
19347
|
+
*
|
|
19348
|
+
* Open the session dialog
|
|
18189
19349
|
*/
|
|
18190
|
-
|
|
18191
|
-
|
|
18192
|
-
|
|
19350
|
+
openSessions(parameters, options) {
|
|
19351
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19352
|
+
return (options?.client ?? this.client).post({
|
|
19353
|
+
url: "/tui/open-sessions",
|
|
18193
19354
|
...options,
|
|
19355
|
+
...params,
|
|
18194
19356
|
});
|
|
18195
19357
|
}
|
|
18196
19358
|
/**
|
|
18197
|
-
*
|
|
19359
|
+
* Open themes dialog
|
|
19360
|
+
*
|
|
19361
|
+
* Open the theme dialog
|
|
18198
19362
|
*/
|
|
18199
|
-
|
|
18200
|
-
|
|
18201
|
-
|
|
19363
|
+
openThemes(parameters, options) {
|
|
19364
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19365
|
+
return (options?.client ?? this.client).post({
|
|
19366
|
+
url: "/tui/open-themes",
|
|
18202
19367
|
...options,
|
|
19368
|
+
...params,
|
|
18203
19369
|
});
|
|
18204
19370
|
}
|
|
18205
|
-
auth = new Auth({ client: this._client });
|
|
18206
|
-
}
|
|
18207
|
-
class Lsp extends _HeyApiClient {
|
|
18208
19371
|
/**
|
|
18209
|
-
*
|
|
19372
|
+
* Open models dialog
|
|
19373
|
+
*
|
|
19374
|
+
* Open the model dialog
|
|
18210
19375
|
*/
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
|
|
19376
|
+
openModels(parameters, options) {
|
|
19377
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19378
|
+
return (options?.client ?? this.client).post({
|
|
19379
|
+
url: "/tui/open-models",
|
|
18214
19380
|
...options,
|
|
19381
|
+
...params,
|
|
18215
19382
|
});
|
|
18216
19383
|
}
|
|
18217
|
-
}
|
|
18218
|
-
class Formatter extends _HeyApiClient {
|
|
18219
19384
|
/**
|
|
18220
|
-
*
|
|
19385
|
+
* Submit TUI prompt
|
|
19386
|
+
*
|
|
19387
|
+
* Submit the prompt
|
|
18221
19388
|
*/
|
|
18222
|
-
|
|
18223
|
-
|
|
18224
|
-
|
|
19389
|
+
submitPrompt(parameters, options) {
|
|
19390
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19391
|
+
return (options?.client ?? this.client).post({
|
|
19392
|
+
url: "/tui/submit-prompt",
|
|
19393
|
+
...options,
|
|
19394
|
+
...params,
|
|
19395
|
+
});
|
|
19396
|
+
}
|
|
19397
|
+
/**
|
|
19398
|
+
* Clear TUI prompt
|
|
19399
|
+
*
|
|
19400
|
+
* Clear the prompt
|
|
19401
|
+
*/
|
|
19402
|
+
clearPrompt(parameters, options) {
|
|
19403
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19404
|
+
return (options?.client ?? this.client).post({
|
|
19405
|
+
url: "/tui/clear-prompt",
|
|
18225
19406
|
...options,
|
|
19407
|
+
...params,
|
|
19408
|
+
});
|
|
19409
|
+
}
|
|
19410
|
+
/**
|
|
19411
|
+
* Execute TUI command
|
|
19412
|
+
*
|
|
19413
|
+
* Execute a TUI command (e.g. agent_cycle)
|
|
19414
|
+
*/
|
|
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({
|
|
19425
|
+
url: "/tui/execute-command",
|
|
19426
|
+
...options,
|
|
19427
|
+
...params,
|
|
19428
|
+
headers: {
|
|
19429
|
+
"Content-Type": "application/json",
|
|
19430
|
+
...options?.headers,
|
|
19431
|
+
...params.headers,
|
|
19432
|
+
},
|
|
18226
19433
|
});
|
|
18227
19434
|
}
|
|
18228
|
-
}
|
|
18229
|
-
class Control extends _HeyApiClient {
|
|
18230
19435
|
/**
|
|
18231
|
-
*
|
|
19436
|
+
* Show TUI toast
|
|
19437
|
+
*
|
|
19438
|
+
* Show a toast notification in the TUI
|
|
18232
19439
|
*/
|
|
18233
|
-
|
|
18234
|
-
|
|
18235
|
-
|
|
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({
|
|
19453
|
+
url: "/tui/show-toast",
|
|
18236
19454
|
...options,
|
|
19455
|
+
...params,
|
|
19456
|
+
headers: {
|
|
19457
|
+
"Content-Type": "application/json",
|
|
19458
|
+
...options?.headers,
|
|
19459
|
+
...params.headers,
|
|
19460
|
+
},
|
|
18237
19461
|
});
|
|
18238
19462
|
}
|
|
18239
19463
|
/**
|
|
18240
|
-
*
|
|
19464
|
+
* Publish TUI event
|
|
19465
|
+
*
|
|
19466
|
+
* Publish a TUI event
|
|
18241
19467
|
*/
|
|
18242
|
-
|
|
18243
|
-
|
|
18244
|
-
|
|
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({
|
|
19478
|
+
url: "/tui/publish",
|
|
18245
19479
|
...options,
|
|
19480
|
+
...params,
|
|
18246
19481
|
headers: {
|
|
18247
19482
|
"Content-Type": "application/json",
|
|
18248
19483
|
...options?.headers,
|
|
19484
|
+
...params.headers,
|
|
18249
19485
|
},
|
|
18250
19486
|
});
|
|
18251
19487
|
}
|
|
18252
|
-
}
|
|
18253
|
-
class Tui extends _HeyApiClient {
|
|
18254
19488
|
/**
|
|
18255
|
-
*
|
|
18256
|
-
|
|
18257
|
-
|
|
18258
|
-
|
|
18259
|
-
|
|
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",
|
|
18260
19504
|
...options,
|
|
19505
|
+
...params,
|
|
18261
19506
|
headers: {
|
|
18262
19507
|
"Content-Type": "application/json",
|
|
18263
19508
|
...options?.headers,
|
|
19509
|
+
...params.headers,
|
|
18264
19510
|
},
|
|
18265
19511
|
});
|
|
18266
19512
|
}
|
|
19513
|
+
_control;
|
|
19514
|
+
get control() {
|
|
19515
|
+
return (this._control ??= new Control({ client: this.client }));
|
|
19516
|
+
}
|
|
19517
|
+
}
|
|
19518
|
+
class Instance extends HeyApiClient {
|
|
18267
19519
|
/**
|
|
18268
|
-
*
|
|
19520
|
+
* Dispose instance
|
|
19521
|
+
*
|
|
19522
|
+
* Clean up and dispose the current OpenCode instance, releasing all resources.
|
|
18269
19523
|
*/
|
|
18270
|
-
|
|
18271
|
-
|
|
18272
|
-
|
|
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",
|
|
18273
19528
|
...options,
|
|
19529
|
+
...params,
|
|
18274
19530
|
});
|
|
18275
19531
|
}
|
|
19532
|
+
}
|
|
19533
|
+
class Path extends HeyApiClient {
|
|
18276
19534
|
/**
|
|
18277
|
-
*
|
|
19535
|
+
* Get paths
|
|
19536
|
+
*
|
|
19537
|
+
* Retrieve the current working directory and related path information for the OpenCode instance.
|
|
18278
19538
|
*/
|
|
18279
|
-
|
|
18280
|
-
|
|
18281
|
-
|
|
19539
|
+
get(parameters, options) {
|
|
19540
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19541
|
+
return (options?.client ?? this.client).get({
|
|
19542
|
+
url: "/path",
|
|
18282
19543
|
...options,
|
|
19544
|
+
...params,
|
|
18283
19545
|
});
|
|
18284
19546
|
}
|
|
19547
|
+
}
|
|
19548
|
+
class Vcs extends HeyApiClient {
|
|
18285
19549
|
/**
|
|
18286
|
-
*
|
|
19550
|
+
* Get VCS info
|
|
19551
|
+
*
|
|
19552
|
+
* Retrieve version control system (VCS) information for the current project, such as git branch.
|
|
18287
19553
|
*/
|
|
18288
|
-
|
|
18289
|
-
|
|
18290
|
-
|
|
19554
|
+
get(parameters, options) {
|
|
19555
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19556
|
+
return (options?.client ?? this.client).get({
|
|
19557
|
+
url: "/vcs",
|
|
18291
19558
|
...options,
|
|
19559
|
+
...params,
|
|
18292
19560
|
});
|
|
18293
19561
|
}
|
|
19562
|
+
}
|
|
19563
|
+
class sdk_gen_Command extends HeyApiClient {
|
|
18294
19564
|
/**
|
|
18295
|
-
*
|
|
19565
|
+
* List commands
|
|
19566
|
+
*
|
|
19567
|
+
* Get a list of all available commands in the OpenCode system.
|
|
18296
19568
|
*/
|
|
18297
|
-
|
|
18298
|
-
|
|
18299
|
-
|
|
19569
|
+
list(parameters, options) {
|
|
19570
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19571
|
+
return (options?.client ?? this.client).get({
|
|
19572
|
+
url: "/command",
|
|
18300
19573
|
...options,
|
|
19574
|
+
...params,
|
|
18301
19575
|
});
|
|
18302
19576
|
}
|
|
19577
|
+
}
|
|
19578
|
+
class App extends HeyApiClient {
|
|
18303
19579
|
/**
|
|
18304
|
-
*
|
|
18305
|
-
|
|
18306
|
-
|
|
18307
|
-
|
|
18308
|
-
|
|
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",
|
|
18309
19598
|
...options,
|
|
19599
|
+
...params,
|
|
19600
|
+
headers: {
|
|
19601
|
+
"Content-Type": "application/json",
|
|
19602
|
+
...options?.headers,
|
|
19603
|
+
...params.headers,
|
|
19604
|
+
},
|
|
18310
19605
|
});
|
|
18311
19606
|
}
|
|
18312
19607
|
/**
|
|
18313
|
-
*
|
|
19608
|
+
* List agents
|
|
19609
|
+
*
|
|
19610
|
+
* Get a list of all available AI agents in the OpenCode system.
|
|
18314
19611
|
*/
|
|
18315
|
-
|
|
18316
|
-
|
|
18317
|
-
|
|
19612
|
+
agents(parameters, options) {
|
|
19613
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19614
|
+
return (options?.client ?? this.client).get({
|
|
19615
|
+
url: "/agent",
|
|
18318
19616
|
...options,
|
|
19617
|
+
...params,
|
|
18319
19618
|
});
|
|
18320
19619
|
}
|
|
18321
19620
|
/**
|
|
18322
|
-
*
|
|
19621
|
+
* List skills
|
|
19622
|
+
*
|
|
19623
|
+
* Get a list of all available skills in the OpenCode system.
|
|
18323
19624
|
*/
|
|
18324
|
-
|
|
18325
|
-
|
|
18326
|
-
|
|
19625
|
+
skills(parameters, options) {
|
|
19626
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19627
|
+
return (options?.client ?? this.client).get({
|
|
19628
|
+
url: "/skill",
|
|
18327
19629
|
...options,
|
|
18328
|
-
|
|
18329
|
-
"Content-Type": "application/json",
|
|
18330
|
-
...options?.headers,
|
|
18331
|
-
},
|
|
19630
|
+
...params,
|
|
18332
19631
|
});
|
|
18333
19632
|
}
|
|
19633
|
+
}
|
|
19634
|
+
class Lsp extends HeyApiClient {
|
|
18334
19635
|
/**
|
|
18335
|
-
*
|
|
19636
|
+
* Get LSP status
|
|
19637
|
+
*
|
|
19638
|
+
* Get LSP server status
|
|
18336
19639
|
*/
|
|
18337
|
-
|
|
18338
|
-
|
|
18339
|
-
|
|
19640
|
+
status(parameters, options) {
|
|
19641
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19642
|
+
return (options?.client ?? this.client).get({
|
|
19643
|
+
url: "/lsp",
|
|
18340
19644
|
...options,
|
|
18341
|
-
|
|
18342
|
-
"Content-Type": "application/json",
|
|
18343
|
-
...options?.headers,
|
|
18344
|
-
},
|
|
19645
|
+
...params,
|
|
18345
19646
|
});
|
|
18346
19647
|
}
|
|
19648
|
+
}
|
|
19649
|
+
class Formatter extends HeyApiClient {
|
|
18347
19650
|
/**
|
|
18348
|
-
*
|
|
19651
|
+
* Get formatter status
|
|
19652
|
+
*
|
|
19653
|
+
* Get formatter status
|
|
18349
19654
|
*/
|
|
18350
|
-
|
|
18351
|
-
|
|
18352
|
-
|
|
19655
|
+
status(parameters, options) {
|
|
19656
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19657
|
+
return (options?.client ?? this.client).get({
|
|
19658
|
+
url: "/formatter",
|
|
18353
19659
|
...options,
|
|
18354
|
-
|
|
18355
|
-
"Content-Type": "application/json",
|
|
18356
|
-
...options?.headers,
|
|
18357
|
-
},
|
|
19660
|
+
...params,
|
|
18358
19661
|
});
|
|
18359
19662
|
}
|
|
18360
|
-
control = new Control({ client: this._client });
|
|
18361
19663
|
}
|
|
18362
|
-
class Event extends
|
|
19664
|
+
class Event extends HeyApiClient {
|
|
18363
19665
|
/**
|
|
19666
|
+
* Subscribe to events
|
|
19667
|
+
*
|
|
18364
19668
|
* Get events
|
|
18365
19669
|
*/
|
|
18366
|
-
subscribe(options) {
|
|
18367
|
-
|
|
19670
|
+
subscribe(parameters, options) {
|
|
19671
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }]);
|
|
19672
|
+
return (options?.client ?? this.client).sse.get({
|
|
18368
19673
|
url: "/event",
|
|
18369
19674
|
...options,
|
|
19675
|
+
...params,
|
|
18370
19676
|
});
|
|
18371
19677
|
}
|
|
18372
19678
|
}
|
|
18373
|
-
class OpencodeClient extends
|
|
18374
|
-
|
|
18375
|
-
|
|
18376
|
-
|
|
18377
|
-
|
|
18378
|
-
|
|
18379
|
-
|
|
18380
|
-
|
|
18381
|
-
|
|
18382
|
-
|
|
18383
|
-
|
|
18384
|
-
|
|
18385
|
-
});
|
|
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 }));
|
|
18386
19784
|
}
|
|
18387
|
-
global = new Global({ client: this._client });
|
|
18388
|
-
project = new Project({ client: this._client });
|
|
18389
|
-
pty = new Pty({ client: this._client });
|
|
18390
|
-
config = new Config({ client: this._client });
|
|
18391
|
-
tool = new Tool({ client: this._client });
|
|
18392
|
-
instance = new Instance({ client: this._client });
|
|
18393
|
-
path = new Path({ client: this._client });
|
|
18394
|
-
vcs = new Vcs({ client: this._client });
|
|
18395
|
-
session = new Session({ client: this._client });
|
|
18396
|
-
command = new sdk_gen_Command({ client: this._client });
|
|
18397
|
-
provider = new Provider({ client: this._client });
|
|
18398
|
-
find = new Find({ client: this._client });
|
|
18399
|
-
file = new File({ client: this._client });
|
|
18400
|
-
app = new App({ client: this._client });
|
|
18401
|
-
mcp = new Mcp({ client: this._client });
|
|
18402
|
-
lsp = new Lsp({ client: this._client });
|
|
18403
|
-
formatter = new Formatter({ client: this._client });
|
|
18404
|
-
tui = new Tui({ client: this._client });
|
|
18405
|
-
auth = new Auth({ client: this._client });
|
|
18406
|
-
event = new Event({ client: this._client });
|
|
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
|
|
|
@@ -18587,6 +19967,8 @@ async function startTelegram(options) {
|
|
|
18587
19967
|
const sessionsFile = options.sessionsFilePath || SESSIONS_FILE;
|
|
18588
19968
|
// Initialize OpenCode client
|
|
18589
19969
|
const client = options.client || client_createOpencodeClient({ baseUrl: url });
|
|
19970
|
+
// Available agents fetched from OpenCode on startup
|
|
19971
|
+
let availableAgents = [];
|
|
18590
19972
|
// Verify connection to the OpenCode server and fetch available commands
|
|
18591
19973
|
const opencodeCommands = new Set();
|
|
18592
19974
|
const opencodeCommandMenu = [];
|
|
@@ -18594,19 +19976,19 @@ async function startTelegram(options) {
|
|
|
18594
19976
|
const isHiddenOpenCodeCommand = (name) => hiddenOpenCodeCommands.has(name.toLowerCase());
|
|
18595
19977
|
let projectDirectory = "";
|
|
18596
19978
|
try {
|
|
18597
|
-
const sessions = await client.session.list();
|
|
19979
|
+
const sessions = await client.session.list({});
|
|
18598
19980
|
if (sessions.error) {
|
|
18599
19981
|
throw new Error(`Server returned error: ${JSON.stringify(sessions.error)}`);
|
|
18600
19982
|
}
|
|
18601
19983
|
console.log(`[Telegram] Connected to OpenCode server at ${url}`);
|
|
18602
19984
|
// Fetch the project directory (needed for SSE event subscription)
|
|
18603
|
-
const pathResult = await client.path.get();
|
|
19985
|
+
const pathResult = await client.path.get({});
|
|
18604
19986
|
if (pathResult.data?.directory) {
|
|
18605
19987
|
projectDirectory = pathResult.data.directory;
|
|
18606
19988
|
console.log(`[Telegram] Project directory: ${projectDirectory}`);
|
|
18607
19989
|
}
|
|
18608
19990
|
// Fetch available OpenCode commands
|
|
18609
|
-
const cmds = await client.command.list();
|
|
19991
|
+
const cmds = await client.command.list({});
|
|
18610
19992
|
if (cmds.data) {
|
|
18611
19993
|
for (const cmd of cmds.data) {
|
|
18612
19994
|
const name = cmd.name;
|
|
@@ -18624,13 +20006,25 @@ async function startTelegram(options) {
|
|
|
18624
20006
|
}
|
|
18625
20007
|
console.log(`[Telegram] Available OpenCode commands: ${[...opencodeCommands].join(", ")}`);
|
|
18626
20008
|
}
|
|
20009
|
+
// Fetch available agents
|
|
20010
|
+
const agentsResult = await client.app.agents({});
|
|
20011
|
+
if (agentsResult.data) {
|
|
20012
|
+
availableAgents = agentsResult.data
|
|
20013
|
+
.filter((a) => !a.hidden)
|
|
20014
|
+
.map((a) => ({
|
|
20015
|
+
name: a.name,
|
|
20016
|
+
description: a.description || "",
|
|
20017
|
+
mode: a.mode || "primary",
|
|
20018
|
+
}));
|
|
20019
|
+
console.log(`[Telegram] Available agents: ${availableAgents.map((a) => `${a.name} (${a.mode})`).join(", ")}`);
|
|
20020
|
+
}
|
|
18627
20021
|
}
|
|
18628
20022
|
catch (err) {
|
|
18629
20023
|
throw new Error(`[Telegram] Failed to connect to OpenCode server at ${url}. Make sure it's running (npm run serve). Error: ${err}`);
|
|
18630
20024
|
}
|
|
18631
20025
|
// Telegram-only commands that should not be forwarded to OpenCode
|
|
18632
20026
|
const telegramCommands = new Set([
|
|
18633
|
-
"start", "help", "new", "sessions", "switch", "title", "delete", "export", "verbose", "model", "usage",
|
|
20027
|
+
"start", "help", "new", "sessions", "switch", "title", "delete", "export", "verbose", "model", "usage", "agent",
|
|
18634
20028
|
]);
|
|
18635
20029
|
const telegramCommandMenu = [
|
|
18636
20030
|
{ command: "new", description: "Start a new conversation" },
|
|
@@ -18639,6 +20033,7 @@ async function startTelegram(options) {
|
|
|
18639
20033
|
{ command: "export", description: "Export session (/export full for details)" },
|
|
18640
20034
|
{ command: "verbose", description: "Toggle verbose mode" },
|
|
18641
20035
|
{ command: "model", description: "Search models (/model <keyword>)" },
|
|
20036
|
+
{ command: "agent", description: "Switch agent (plan, build, ...)" },
|
|
18642
20037
|
{ command: "usage", description: "Show token and cost usage" },
|
|
18643
20038
|
{ command: "help", description: "Show available commands" },
|
|
18644
20039
|
];
|
|
@@ -18651,8 +20046,14 @@ async function startTelegram(options) {
|
|
|
18651
20046
|
const chatVerboseMode = new Set();
|
|
18652
20047
|
// Map of chatId -> model override (provider/model)
|
|
18653
20048
|
const chatModelOverride = new Map();
|
|
20049
|
+
// Map of chatId -> agent override (e.g. "plan", "build")
|
|
20050
|
+
const chatAgentOverride = new Map();
|
|
20051
|
+
// Map of chatId -> pinned status message ID
|
|
20052
|
+
const chatPinnedStatusMsg = new Map();
|
|
18654
20053
|
// Map of chatId -> last search results (in-memory only)
|
|
18655
20054
|
const chatModelSearchResults = new Map();
|
|
20055
|
+
// Map of questionId -> pending question context (for forwarding OpenCode questions to Telegram)
|
|
20056
|
+
const pendingQuestions = new Map();
|
|
18656
20057
|
/**
|
|
18657
20058
|
* Save the chat-to-session mapping and known session IDs to disk.
|
|
18658
20059
|
*/
|
|
@@ -18663,6 +20064,8 @@ async function startTelegram(options) {
|
|
|
18663
20064
|
known: [...knownSessionIds],
|
|
18664
20065
|
verbose: [...chatVerboseMode],
|
|
18665
20066
|
models: Object.fromEntries(chatModelOverride),
|
|
20067
|
+
agents: Object.fromEntries(chatAgentOverride),
|
|
20068
|
+
pinnedStatus: Object.fromEntries(chatPinnedStatusMsg),
|
|
18666
20069
|
};
|
|
18667
20070
|
(0,external_node_fs_.writeFileSync)(sessionsFile, JSON.stringify(data, null, 2));
|
|
18668
20071
|
}
|
|
@@ -18680,6 +20083,8 @@ async function startTelegram(options) {
|
|
|
18680
20083
|
let storedKnown = [];
|
|
18681
20084
|
let storedVerbose = [];
|
|
18682
20085
|
let storedModels = {};
|
|
20086
|
+
let storedAgents = {};
|
|
20087
|
+
let storedPinnedStatus = {};
|
|
18683
20088
|
if ((0,external_node_fs_.existsSync)(sessionsFile)) {
|
|
18684
20089
|
try {
|
|
18685
20090
|
const raw = (0,external_node_fs_.readFileSync)(sessionsFile, "utf-8");
|
|
@@ -18690,6 +20095,8 @@ async function startTelegram(options) {
|
|
|
18690
20095
|
storedKnown = parsed.known || [];
|
|
18691
20096
|
storedVerbose = parsed.verbose || [];
|
|
18692
20097
|
storedModels = parsed.models || {};
|
|
20098
|
+
storedAgents = parsed.agents || {};
|
|
20099
|
+
storedPinnedStatus = parsed.pinnedStatus || {};
|
|
18693
20100
|
}
|
|
18694
20101
|
else {
|
|
18695
20102
|
// Old format: flat { chatId: sessionId }
|
|
@@ -18714,10 +20121,22 @@ async function startTelegram(options) {
|
|
|
18714
20121
|
chatModelOverride.set(chatId, modelId);
|
|
18715
20122
|
}
|
|
18716
20123
|
}
|
|
20124
|
+
// Restore agent overrides
|
|
20125
|
+
for (const [chatId, agentName] of Object.entries(storedAgents)) {
|
|
20126
|
+
if (agentName) {
|
|
20127
|
+
chatAgentOverride.set(chatId, agentName);
|
|
20128
|
+
}
|
|
20129
|
+
}
|
|
20130
|
+
// Restore pinned status message IDs
|
|
20131
|
+
for (const [chatId, msgId] of Object.entries(storedPinnedStatus)) {
|
|
20132
|
+
if (msgId) {
|
|
20133
|
+
chatPinnedStatusMsg.set(chatId, msgId);
|
|
20134
|
+
}
|
|
20135
|
+
}
|
|
18717
20136
|
// Fetch all server sessions once for validation and fallback matching
|
|
18718
20137
|
let serverSessions = [];
|
|
18719
20138
|
try {
|
|
18720
|
-
const list = await client.session.list();
|
|
20139
|
+
const list = await client.session.list({});
|
|
18721
20140
|
if (list.data) {
|
|
18722
20141
|
serverSessions = list.data;
|
|
18723
20142
|
}
|
|
@@ -18771,6 +20190,14 @@ async function startTelegram(options) {
|
|
|
18771
20190
|
}
|
|
18772
20191
|
// Restore sessions from previous runs
|
|
18773
20192
|
await restoreSessions();
|
|
20193
|
+
// Build a reverse lookup: sessionId -> chatId
|
|
20194
|
+
function sessionToChatId(sessionId) {
|
|
20195
|
+
for (const [chatId, sid] of chatSessions) {
|
|
20196
|
+
if (sid === sessionId)
|
|
20197
|
+
return chatId;
|
|
20198
|
+
}
|
|
20199
|
+
return undefined;
|
|
20200
|
+
}
|
|
18774
20201
|
// Track which sessions were just created so we can auto-title them
|
|
18775
20202
|
const newlyCreatedSessions = new Set();
|
|
18776
20203
|
/**
|
|
@@ -18780,7 +20207,7 @@ async function startTelegram(options) {
|
|
|
18780
20207
|
let sessionId = chatSessions.get(chatId);
|
|
18781
20208
|
if (!sessionId) {
|
|
18782
20209
|
const session = await client.session.create({
|
|
18783
|
-
|
|
20210
|
+
title: `Telegram chat ${chatId}`,
|
|
18784
20211
|
});
|
|
18785
20212
|
if (session.error || !session.data) {
|
|
18786
20213
|
throw new Error(`Failed to create session: ${JSON.stringify(session.error)}`);
|
|
@@ -18807,8 +20234,8 @@ async function startTelegram(options) {
|
|
|
18807
20234
|
const title = truncate(userText.replace(/\n/g, " "), 100);
|
|
18808
20235
|
try {
|
|
18809
20236
|
await client.session.update({
|
|
18810
|
-
|
|
18811
|
-
|
|
20237
|
+
sessionID: sessionId,
|
|
20238
|
+
title,
|
|
18812
20239
|
});
|
|
18813
20240
|
console.log(`[Telegram] Auto-titled session ${sessionId}: "${title}"`);
|
|
18814
20241
|
}
|
|
@@ -18824,6 +20251,10 @@ async function startTelegram(options) {
|
|
|
18824
20251
|
const modelID = modelParts.join("/");
|
|
18825
20252
|
promptBody.model = { providerID, modelID };
|
|
18826
20253
|
}
|
|
20254
|
+
const agentOverride = chatAgentOverride.get(chatId);
|
|
20255
|
+
if (agentOverride) {
|
|
20256
|
+
promptBody.agent = agentOverride;
|
|
20257
|
+
}
|
|
18827
20258
|
return promptBody;
|
|
18828
20259
|
}
|
|
18829
20260
|
function getChatIdFromContext(ctx) {
|
|
@@ -18837,10 +20268,27 @@ async function startTelegram(options) {
|
|
|
18837
20268
|
}
|
|
18838
20269
|
async function answerAndEdit(ctx, text) {
|
|
18839
20270
|
if (typeof ctx.answerCbQuery === "function") {
|
|
18840
|
-
|
|
20271
|
+
try {
|
|
20272
|
+
await ctx.answerCbQuery();
|
|
20273
|
+
}
|
|
20274
|
+
catch {
|
|
20275
|
+
// Ignore "query is too old" or other callback query errors —
|
|
20276
|
+
// the callback may have expired but we still want to update the message.
|
|
20277
|
+
}
|
|
18841
20278
|
}
|
|
18842
20279
|
if (typeof ctx.editMessageText === "function") {
|
|
18843
|
-
|
|
20280
|
+
try {
|
|
20281
|
+
await ctx.editMessageText(text);
|
|
20282
|
+
}
|
|
20283
|
+
catch {
|
|
20284
|
+
// If edit fails (message deleted, too old, etc.), fall back to reply
|
|
20285
|
+
try {
|
|
20286
|
+
await ctx.reply(text);
|
|
20287
|
+
}
|
|
20288
|
+
catch {
|
|
20289
|
+
// Give up silently
|
|
20290
|
+
}
|
|
20291
|
+
}
|
|
18844
20292
|
return;
|
|
18845
20293
|
}
|
|
18846
20294
|
await ctx.reply(text);
|
|
@@ -18954,18 +20402,15 @@ async function startTelegram(options) {
|
|
|
18954
20402
|
async function sendPromptStreaming(chatId, sessionId, promptBody, processingMsgId, verbose = false) {
|
|
18955
20403
|
// Subscribe to SSE events before sending the prompt so we don't miss anything
|
|
18956
20404
|
const abortController = new AbortController();
|
|
18957
|
-
|
|
18958
|
-
const subscribeOptions = {
|
|
18959
|
-
signal: abortController.signal,
|
|
18960
|
-
};
|
|
20405
|
+
const subscribeParams = {};
|
|
18961
20406
|
if (projectDirectory) {
|
|
18962
|
-
|
|
20407
|
+
subscribeParams.directory = projectDirectory;
|
|
18963
20408
|
}
|
|
18964
|
-
const { stream } = await client.event.subscribe(
|
|
20409
|
+
const { stream } = await client.event.subscribe(subscribeParams, { signal: abortController.signal });
|
|
18965
20410
|
// Fire the prompt asynchronously (returns immediately)
|
|
18966
20411
|
const asyncResult = await client.session.promptAsync({
|
|
18967
|
-
|
|
18968
|
-
|
|
20412
|
+
sessionID: sessionId,
|
|
20413
|
+
...promptBody,
|
|
18969
20414
|
});
|
|
18970
20415
|
if (asyncResult.error) {
|
|
18971
20416
|
abortController.abort();
|
|
@@ -18987,7 +20432,7 @@ async function startTelegram(options) {
|
|
|
18987
20432
|
async function emitSubagentMessages(taskSessionId) {
|
|
18988
20433
|
try {
|
|
18989
20434
|
const messagesResult = await client.session.messages({
|
|
18990
|
-
|
|
20435
|
+
sessionID: taskSessionId,
|
|
18991
20436
|
});
|
|
18992
20437
|
if (messagesResult.error || !messagesResult.data) {
|
|
18993
20438
|
console.warn(`[Telegram] Failed to fetch subagent messages for ${taskSessionId}: ${JSON.stringify(messagesResult.error)}`);
|
|
@@ -19201,6 +20646,46 @@ async function startTelegram(options) {
|
|
|
19201
20646
|
throw new Error(`Session error: ${errorMsg}`);
|
|
19202
20647
|
}
|
|
19203
20648
|
}
|
|
20649
|
+
else if (ev.type === "question.asked" && ev.properties) {
|
|
20650
|
+
const questionSessionId = ev.properties.sessionID;
|
|
20651
|
+
if (questionSessionId === sessionId) {
|
|
20652
|
+
const questionId = ev.properties.id;
|
|
20653
|
+
const questions = ev.properties.questions;
|
|
20654
|
+
if (questionId && questions?.length > 0) {
|
|
20655
|
+
// Store the pending question
|
|
20656
|
+
pendingQuestions.set(questionId, {
|
|
20657
|
+
chatId: chatId.toString(),
|
|
20658
|
+
sessionId,
|
|
20659
|
+
questions,
|
|
20660
|
+
});
|
|
20661
|
+
console.log(`[Telegram] Sending ${questions.length} question(s) to chat ${chatId} (question ${questionId})`);
|
|
20662
|
+
// Send each question to Telegram with inline buttons
|
|
20663
|
+
for (let qi = 0; qi < questions.length; qi++) {
|
|
20664
|
+
const q = questions[qi];
|
|
20665
|
+
let msg = "";
|
|
20666
|
+
if (q.header)
|
|
20667
|
+
msg += `*${q.header}*\n`;
|
|
20668
|
+
msg += q.question;
|
|
20669
|
+
const keyboard = q.options.map((opt, oi) => [
|
|
20670
|
+
{
|
|
20671
|
+
text: opt.label,
|
|
20672
|
+
callback_data: `qa:${questionId}:${qi}:${oi}`,
|
|
20673
|
+
},
|
|
20674
|
+
]);
|
|
20675
|
+
// Add a dismiss/reject button
|
|
20676
|
+
keyboard.push([
|
|
20677
|
+
{ text: "Dismiss", callback_data: `qa_reject:${questionId}` },
|
|
20678
|
+
]);
|
|
20679
|
+
await bot.telegram.sendMessage(chatId, msg, {
|
|
20680
|
+
parse_mode: "Markdown",
|
|
20681
|
+
reply_markup: {
|
|
20682
|
+
inline_keyboard: keyboard,
|
|
20683
|
+
},
|
|
20684
|
+
});
|
|
20685
|
+
}
|
|
20686
|
+
}
|
|
20687
|
+
}
|
|
20688
|
+
}
|
|
19204
20689
|
}
|
|
19205
20690
|
}
|
|
19206
20691
|
finally {
|
|
@@ -19236,10 +20721,11 @@ async function startTelegram(options) {
|
|
|
19236
20721
|
return true;
|
|
19237
20722
|
});
|
|
19238
20723
|
const cleaned = filtered.join("\n").trim();
|
|
19239
|
-
|
|
19240
|
-
|
|
20724
|
+
// If the cleaned text is non-empty, use it; otherwise keep the
|
|
20725
|
+
// original finalText so the user still sees the agent's conclusion.
|
|
20726
|
+
if (cleaned) {
|
|
20727
|
+
finalText = cleaned;
|
|
19241
20728
|
}
|
|
19242
|
-
finalText = cleaned;
|
|
19243
20729
|
}
|
|
19244
20730
|
const chunks = splitMessage(finalText, 4096);
|
|
19245
20731
|
for (const chunk of chunks) {
|
|
@@ -19272,10 +20758,16 @@ async function startTelegram(options) {
|
|
|
19272
20758
|
}
|
|
19273
20759
|
const promptBody = buildPromptBody(chatId, parts);
|
|
19274
20760
|
const verbose = chatVerboseMode.has(chatId);
|
|
19275
|
-
|
|
20761
|
+
// Fire detached so the handler completes and Telegraf can process
|
|
20762
|
+
// subsequent updates (e.g. callback queries from question buttons).
|
|
20763
|
+
sendPromptStreaming(ctx.chat.id, sessionId, promptBody, processingMsg.message_id, verbose).catch(async (err) => {
|
|
20764
|
+
console.error("[Telegram] Error processing file message:", err);
|
|
20765
|
+
await handleSessionError(chatId);
|
|
20766
|
+
await sendTelegramMessage(ctx.chat.id, "Sorry, there was an error processing your request. Try again or use /new to start a fresh session.");
|
|
20767
|
+
});
|
|
19276
20768
|
}
|
|
19277
20769
|
catch (err) {
|
|
19278
|
-
console.error("[Telegram] Error
|
|
20770
|
+
console.error("[Telegram] Error setting up file message:", err);
|
|
19279
20771
|
await handleSessionError(chatId);
|
|
19280
20772
|
await ctx.reply("Sorry, there was an error processing your request. Try again or use /new to start a fresh session.");
|
|
19281
20773
|
}
|
|
@@ -19288,7 +20780,7 @@ async function startTelegram(options) {
|
|
|
19288
20780
|
if (sessionId) {
|
|
19289
20781
|
try {
|
|
19290
20782
|
const check = await client.session.get({
|
|
19291
|
-
|
|
20783
|
+
sessionID: sessionId,
|
|
19292
20784
|
});
|
|
19293
20785
|
if (check.error) {
|
|
19294
20786
|
chatSessions.delete(chatId);
|
|
@@ -19306,7 +20798,7 @@ async function startTelegram(options) {
|
|
|
19306
20798
|
// Initialize Telegram bot
|
|
19307
20799
|
const bot = options.botFactory
|
|
19308
20800
|
? options.botFactory(token)
|
|
19309
|
-
: new lib.Telegraf(token);
|
|
20801
|
+
: new lib.Telegraf(token, { handlerTimeout: 600_000 });
|
|
19310
20802
|
async function registerCommandMenu() {
|
|
19311
20803
|
const combined = [...telegramCommandMenu, ...opencodeCommandMenu];
|
|
19312
20804
|
const seen = new Set();
|
|
@@ -19326,12 +20818,22 @@ async function startTelegram(options) {
|
|
|
19326
20818
|
console.warn("[Telegram] Failed to register command menu:", err);
|
|
19327
20819
|
}
|
|
19328
20820
|
}
|
|
20821
|
+
// Global error handler — prevents unhandled errors from crashing the process
|
|
20822
|
+
bot.catch((err, ctx) => {
|
|
20823
|
+
const updateType = ctx?.updateType || "unknown";
|
|
20824
|
+
console.error(`[Telegram] Unhandled error in ${updateType} handler:`, err);
|
|
20825
|
+
});
|
|
19329
20826
|
// Middleware to check if the user is authorized
|
|
19330
20827
|
bot.use((ctx, next) => {
|
|
19331
20828
|
if (!authorizedUserId) {
|
|
19332
20829
|
return next();
|
|
19333
20830
|
}
|
|
19334
|
-
|
|
20831
|
+
// Skip auth for service messages without a sender or from the bot itself
|
|
20832
|
+
// (e.g. pin notifications where ctx.from is the bot)
|
|
20833
|
+
if (!ctx.from || ctx.from.is_bot) {
|
|
20834
|
+
return next();
|
|
20835
|
+
}
|
|
20836
|
+
const userId = ctx.from.id.toString();
|
|
19335
20837
|
if (userId === authorizedUserId) {
|
|
19336
20838
|
return next();
|
|
19337
20839
|
}
|
|
@@ -19354,6 +20856,7 @@ async function startTelegram(options) {
|
|
|
19354
20856
|
"/verbose - Toggle verbose mode (show thinking and tool calls)\n" +
|
|
19355
20857
|
"/verbose on|off - Set verbose mode explicitly\n" +
|
|
19356
20858
|
"/model <keyword> - Search available models\n" +
|
|
20859
|
+
"/agent - Switch agent (plan, build, ...)\n" +
|
|
19357
20860
|
"/usage - Show token and cost usage for this session\n" +
|
|
19358
20861
|
"/help - Show this help message\n";
|
|
19359
20862
|
const visibleOpenCodeCommands = getVisibleOpenCodeCommands();
|
|
@@ -19376,6 +20879,7 @@ async function startTelegram(options) {
|
|
|
19376
20879
|
"/verbose - Toggle verbose mode (show thinking and tool calls)\n" +
|
|
19377
20880
|
"/verbose on|off - Set verbose mode explicitly\n" +
|
|
19378
20881
|
"/model <keyword> - Search available models\n" +
|
|
20882
|
+
"/agent - Switch agent (plan, build, ...)\n" +
|
|
19379
20883
|
"/usage - Show token and cost usage for this session\n" +
|
|
19380
20884
|
"/help - Show this help message\n";
|
|
19381
20885
|
const visibleOpenCodeCommands = getVisibleOpenCodeCommands();
|
|
@@ -19398,7 +20902,7 @@ async function startTelegram(options) {
|
|
|
19398
20902
|
* Get the list of known sessions, sorted by most recently updated.
|
|
19399
20903
|
*/
|
|
19400
20904
|
async function getKnownSessions() {
|
|
19401
|
-
const list = await client.session.list();
|
|
20905
|
+
const list = await client.session.list({});
|
|
19402
20906
|
const data = (list.data || []);
|
|
19403
20907
|
if (data.length === 0)
|
|
19404
20908
|
return [];
|
|
@@ -19498,8 +21002,8 @@ async function startTelegram(options) {
|
|
|
19498
21002
|
}
|
|
19499
21003
|
try {
|
|
19500
21004
|
const result = await client.session.update({
|
|
19501
|
-
|
|
19502
|
-
|
|
21005
|
+
sessionID: sessionId,
|
|
21006
|
+
title: newTitle,
|
|
19503
21007
|
});
|
|
19504
21008
|
if (result.error) {
|
|
19505
21009
|
throw new Error(JSON.stringify(result.error));
|
|
@@ -19535,7 +21039,7 @@ async function startTelegram(options) {
|
|
|
19535
21039
|
}
|
|
19536
21040
|
// Delete from the server
|
|
19537
21041
|
const result = await client.session.delete({
|
|
19538
|
-
|
|
21042
|
+
sessionID: match.id,
|
|
19539
21043
|
});
|
|
19540
21044
|
if (result.error) {
|
|
19541
21045
|
throw new Error(JSON.stringify(result.error));
|
|
@@ -19591,7 +21095,7 @@ async function startTelegram(options) {
|
|
|
19591
21095
|
return;
|
|
19592
21096
|
}
|
|
19593
21097
|
const result = await client.session.delete({
|
|
19594
|
-
|
|
21098
|
+
sessionID: match.id,
|
|
19595
21099
|
});
|
|
19596
21100
|
if (result.error) {
|
|
19597
21101
|
throw new Error(JSON.stringify(result.error));
|
|
@@ -19628,15 +21132,13 @@ async function startTelegram(options) {
|
|
|
19628
21132
|
saveSessions();
|
|
19629
21133
|
const enabled = chatVerboseMode.has(chatId);
|
|
19630
21134
|
console.log(`[Telegram] Verbose mode ${enabled ? "enabled" : "disabled"} for chat ${chatId}`);
|
|
19631
|
-
ctx.
|
|
19632
|
-
? "Verbose mode enabled. Responses will include thinking and tool calls."
|
|
19633
|
-
: "Verbose mode disabled. Responses will only show the assistant's text.");
|
|
21135
|
+
updatePinnedStatus(chatId, ctx.chat.id);
|
|
19634
21136
|
});
|
|
19635
21137
|
/**
|
|
19636
21138
|
* Fetch and search available models from connected providers.
|
|
19637
21139
|
*/
|
|
19638
21140
|
async function searchModels(keyword) {
|
|
19639
|
-
const list = await client.provider.list();
|
|
21141
|
+
const list = await client.provider.list({});
|
|
19640
21142
|
if (list.error || !list.data) {
|
|
19641
21143
|
throw new Error(`Failed to list providers: ${JSON.stringify(list.error)}`);
|
|
19642
21144
|
}
|
|
@@ -19730,7 +21232,15 @@ async function startTelegram(options) {
|
|
|
19730
21232
|
const value = `${selection.providerID}/${selection.modelID}`;
|
|
19731
21233
|
chatModelOverride.set(chatId, value);
|
|
19732
21234
|
saveSessions();
|
|
19733
|
-
|
|
21235
|
+
try {
|
|
21236
|
+
await ctx.answerCbQuery();
|
|
21237
|
+
}
|
|
21238
|
+
catch { /* ignore */ }
|
|
21239
|
+
try {
|
|
21240
|
+
await ctx.deleteMessage();
|
|
21241
|
+
}
|
|
21242
|
+
catch { /* ignore */ }
|
|
21243
|
+
updatePinnedStatus(chatId, Number(chatId));
|
|
19734
21244
|
});
|
|
19735
21245
|
bot.action("model_default", async (ctx) => {
|
|
19736
21246
|
const chatId = getChatIdFromContext(ctx);
|
|
@@ -19738,7 +21248,211 @@ async function startTelegram(options) {
|
|
|
19738
21248
|
return;
|
|
19739
21249
|
chatModelOverride.delete(chatId);
|
|
19740
21250
|
saveSessions();
|
|
19741
|
-
|
|
21251
|
+
try {
|
|
21252
|
+
await ctx.answerCbQuery();
|
|
21253
|
+
}
|
|
21254
|
+
catch { /* ignore */ }
|
|
21255
|
+
try {
|
|
21256
|
+
await ctx.deleteMessage();
|
|
21257
|
+
}
|
|
21258
|
+
catch { /* ignore */ }
|
|
21259
|
+
updatePinnedStatus(chatId, Number(chatId));
|
|
21260
|
+
});
|
|
21261
|
+
// --- Agent switching and pinned status message ---
|
|
21262
|
+
function getActiveAgent(chatId) {
|
|
21263
|
+
return chatAgentOverride.get(chatId) || "build";
|
|
21264
|
+
}
|
|
21265
|
+
function getActiveModelDisplay(chatId) {
|
|
21266
|
+
const m = chatModelOverride.get(chatId) || model;
|
|
21267
|
+
if (!m)
|
|
21268
|
+
return "default";
|
|
21269
|
+
const parts = m.split("/");
|
|
21270
|
+
return parts.length > 1 ? parts.slice(1).join("/") : m;
|
|
21271
|
+
}
|
|
21272
|
+
function buildStatusText(chatId) {
|
|
21273
|
+
const agent = getActiveAgent(chatId);
|
|
21274
|
+
const modelDisplay = getActiveModelDisplay(chatId);
|
|
21275
|
+
const verbose = chatVerboseMode.has(chatId) ? "on" : "off";
|
|
21276
|
+
return `Agent: *${agent}* | Model: ${modelDisplay} | Verbose: ${verbose}`;
|
|
21277
|
+
}
|
|
21278
|
+
function buildStatusKeyboard(chatId) {
|
|
21279
|
+
const active = getActiveAgent(chatId);
|
|
21280
|
+
// Show non-hidden agents as buttons, highlight the active one
|
|
21281
|
+
const buttons = availableAgents
|
|
21282
|
+
.filter((a) => a.mode === "primary" || a.mode === "subagent")
|
|
21283
|
+
.map((a) => ({
|
|
21284
|
+
text: a.name === active ? `[${a.name}]` : a.name,
|
|
21285
|
+
callback_data: `agent:${a.name}`,
|
|
21286
|
+
}));
|
|
21287
|
+
// Arrange in rows of 3
|
|
21288
|
+
const keyboard = [];
|
|
21289
|
+
for (let i = 0; i < buttons.length; i += 3) {
|
|
21290
|
+
keyboard.push(buttons.slice(i, i + 3));
|
|
21291
|
+
}
|
|
21292
|
+
return keyboard;
|
|
21293
|
+
}
|
|
21294
|
+
async function updatePinnedStatus(chatId, numericChatId) {
|
|
21295
|
+
const text = buildStatusText(chatId);
|
|
21296
|
+
// Delete the old status message to keep the chat clean
|
|
21297
|
+
const existingMsgId = chatPinnedStatusMsg.get(chatId);
|
|
21298
|
+
if (existingMsgId) {
|
|
21299
|
+
try {
|
|
21300
|
+
await bot.telegram.deleteMessage(numericChatId, existingMsgId);
|
|
21301
|
+
}
|
|
21302
|
+
catch {
|
|
21303
|
+
// Already deleted
|
|
21304
|
+
}
|
|
21305
|
+
chatPinnedStatusMsg.delete(chatId);
|
|
21306
|
+
}
|
|
21307
|
+
// Always send a fresh message and pin it. Editing in place doesn't
|
|
21308
|
+
// refresh the pinned bar on Android, so delete+send+pin is the only
|
|
21309
|
+
// reliable approach. The pinned message itself serves as the
|
|
21310
|
+
// confirmation — no separate reply is needed.
|
|
21311
|
+
try {
|
|
21312
|
+
const msg = await bot.telegram.sendMessage(numericChatId, text, {
|
|
21313
|
+
parse_mode: "Markdown",
|
|
21314
|
+
});
|
|
21315
|
+
const messageId = msg.message_id;
|
|
21316
|
+
if (messageId) {
|
|
21317
|
+
chatPinnedStatusMsg.set(chatId, messageId);
|
|
21318
|
+
saveSessions();
|
|
21319
|
+
try {
|
|
21320
|
+
await bot.telegram.pinChatMessage(numericChatId, messageId, {
|
|
21321
|
+
disable_notification: true,
|
|
21322
|
+
});
|
|
21323
|
+
}
|
|
21324
|
+
catch (pinErr) {
|
|
21325
|
+
console.warn("[Telegram] Failed to pin status message:", pinErr);
|
|
21326
|
+
}
|
|
21327
|
+
}
|
|
21328
|
+
}
|
|
21329
|
+
catch (err) {
|
|
21330
|
+
console.warn("[Telegram] Failed to send status message:", err);
|
|
21331
|
+
}
|
|
21332
|
+
}
|
|
21333
|
+
// Handle /agent command
|
|
21334
|
+
bot.command("agent", async (ctx) => {
|
|
21335
|
+
const chatId = ctx.chat.id.toString();
|
|
21336
|
+
const args = (ctx.message?.text || "").replace(/^\/agent\s*/i, "").trim();
|
|
21337
|
+
if (!args) {
|
|
21338
|
+
// Show current agent and list available ones
|
|
21339
|
+
const current = getActiveAgent(chatId);
|
|
21340
|
+
let msg = `Current agent: *${current}*\n\nAvailable agents:\n`;
|
|
21341
|
+
for (const a of availableAgents) {
|
|
21342
|
+
const marker = a.name === current ? " (active)" : "";
|
|
21343
|
+
const desc = a.description ? ` -- ${truncate(a.description, 80)}` : "";
|
|
21344
|
+
msg += `- *${a.name}*${marker}${desc}\n`;
|
|
21345
|
+
}
|
|
21346
|
+
msg += "\nTap a button or use `/agent <name>` to switch.";
|
|
21347
|
+
const keyboard = buildStatusKeyboard(chatId);
|
|
21348
|
+
await ctx.reply(msg, {
|
|
21349
|
+
parse_mode: "Markdown",
|
|
21350
|
+
reply_markup: { inline_keyboard: keyboard },
|
|
21351
|
+
});
|
|
21352
|
+
return;
|
|
21353
|
+
}
|
|
21354
|
+
// Direct switch by name
|
|
21355
|
+
const target = args.toLowerCase();
|
|
21356
|
+
const match = availableAgents.find((a) => a.name === target);
|
|
21357
|
+
if (!match) {
|
|
21358
|
+
await ctx.reply(`Unknown agent "${args}". Available: ${availableAgents.map((a) => a.name).join(", ")}`);
|
|
21359
|
+
return;
|
|
21360
|
+
}
|
|
21361
|
+
chatAgentOverride.set(chatId, match.name);
|
|
21362
|
+
saveSessions();
|
|
21363
|
+
await updatePinnedStatus(chatId, ctx.chat.id);
|
|
21364
|
+
});
|
|
21365
|
+
// Handle agent switch via inline button
|
|
21366
|
+
bot.action(/^agent:(.+)$/, async (ctx) => {
|
|
21367
|
+
const chatId = getChatIdFromContext(ctx);
|
|
21368
|
+
if (!chatId)
|
|
21369
|
+
return;
|
|
21370
|
+
const agentName = ctx.match?.[1];
|
|
21371
|
+
if (!agentName)
|
|
21372
|
+
return;
|
|
21373
|
+
const match = availableAgents.find((a) => a.name === agentName);
|
|
21374
|
+
if (!match) {
|
|
21375
|
+
await answerAndEdit(ctx, `Unknown agent: ${agentName}`);
|
|
21376
|
+
return;
|
|
21377
|
+
}
|
|
21378
|
+
chatAgentOverride.set(chatId, match.name);
|
|
21379
|
+
saveSessions();
|
|
21380
|
+
try {
|
|
21381
|
+
await ctx.answerCbQuery();
|
|
21382
|
+
}
|
|
21383
|
+
catch { /* ignore */ }
|
|
21384
|
+
try {
|
|
21385
|
+
await ctx.deleteMessage();
|
|
21386
|
+
}
|
|
21387
|
+
catch { /* ignore */ }
|
|
21388
|
+
await updatePinnedStatus(chatId, Number(chatId));
|
|
21389
|
+
});
|
|
21390
|
+
// Handle question answer callback (from OpenCode question.asked events)
|
|
21391
|
+
bot.action(/^qa:([^:]+):(\d+):(\d+)$/, async (ctx) => {
|
|
21392
|
+
console.log("[Telegram] Question answer callback received:", ctx.match?.[0]);
|
|
21393
|
+
const questionId = ctx.match?.[1];
|
|
21394
|
+
const questionIndex = Number.parseInt(ctx.match?.[2] || "0", 10);
|
|
21395
|
+
const optionIndex = Number.parseInt(ctx.match?.[3] || "0", 10);
|
|
21396
|
+
if (!questionId)
|
|
21397
|
+
return;
|
|
21398
|
+
const pending = pendingQuestions.get(questionId);
|
|
21399
|
+
if (!pending) {
|
|
21400
|
+
await answerAndEdit(ctx, "This question has expired or was already answered.");
|
|
21401
|
+
return;
|
|
21402
|
+
}
|
|
21403
|
+
const question = pending.questions[questionIndex];
|
|
21404
|
+
if (!question) {
|
|
21405
|
+
await answerAndEdit(ctx, "Invalid question.");
|
|
21406
|
+
return;
|
|
21407
|
+
}
|
|
21408
|
+
const selectedOption = question.options[optionIndex];
|
|
21409
|
+
if (!selectedOption) {
|
|
21410
|
+
await answerAndEdit(ctx, "Invalid option.");
|
|
21411
|
+
return;
|
|
21412
|
+
}
|
|
21413
|
+
try {
|
|
21414
|
+
// Build answers array: one answer per question, using the selected option label
|
|
21415
|
+
const answers = pending.questions.map((q, i) => {
|
|
21416
|
+
if (i === questionIndex) {
|
|
21417
|
+
return [selectedOption.label];
|
|
21418
|
+
}
|
|
21419
|
+
// For other questions in the same request, auto-select first option
|
|
21420
|
+
return [q.options[0]?.label || ""];
|
|
21421
|
+
});
|
|
21422
|
+
await client.question.reply({
|
|
21423
|
+
requestID: questionId,
|
|
21424
|
+
answers,
|
|
21425
|
+
});
|
|
21426
|
+
pendingQuestions.delete(questionId);
|
|
21427
|
+
await answerAndEdit(ctx, `Answered: ${selectedOption.label}`);
|
|
21428
|
+
}
|
|
21429
|
+
catch (err) {
|
|
21430
|
+
console.error("[Telegram] Error answering question:", err);
|
|
21431
|
+
await answerAndEdit(ctx, "Failed to submit answer.");
|
|
21432
|
+
}
|
|
21433
|
+
});
|
|
21434
|
+
// Handle question reject/dismiss callback
|
|
21435
|
+
bot.action(/^qa_reject:(.+)$/, async (ctx) => {
|
|
21436
|
+
console.log("[Telegram] Question reject callback received:", ctx.match?.[0]);
|
|
21437
|
+
const questionId = ctx.match?.[1];
|
|
21438
|
+
if (!questionId)
|
|
21439
|
+
return;
|
|
21440
|
+
const pending = pendingQuestions.get(questionId);
|
|
21441
|
+
if (!pending) {
|
|
21442
|
+
await answerAndEdit(ctx, "This question has expired or was already answered.");
|
|
21443
|
+
return;
|
|
21444
|
+
}
|
|
21445
|
+
try {
|
|
21446
|
+
await client.question.reject({
|
|
21447
|
+
requestID: questionId,
|
|
21448
|
+
});
|
|
21449
|
+
pendingQuestions.delete(questionId);
|
|
21450
|
+
await answerAndEdit(ctx, "Question dismissed.");
|
|
21451
|
+
}
|
|
21452
|
+
catch (err) {
|
|
21453
|
+
console.error("[Telegram] Error rejecting question:", err);
|
|
21454
|
+
await answerAndEdit(ctx, "Failed to dismiss question.");
|
|
21455
|
+
}
|
|
19742
21456
|
});
|
|
19743
21457
|
// Handle /usage command - show token and cost usage for current session
|
|
19744
21458
|
bot.command("usage", async (ctx) => {
|
|
@@ -19750,7 +21464,7 @@ async function startTelegram(options) {
|
|
|
19750
21464
|
}
|
|
19751
21465
|
try {
|
|
19752
21466
|
const messagesResult = await client.session.messages({
|
|
19753
|
-
|
|
21467
|
+
sessionID: sessionId,
|
|
19754
21468
|
});
|
|
19755
21469
|
if (messagesResult.error || !messagesResult.data) {
|
|
19756
21470
|
throw new Error(`Failed to get messages: ${JSON.stringify(messagesResult.error)}`);
|
|
@@ -19948,9 +21662,9 @@ async function startTelegram(options) {
|
|
|
19948
21662
|
const processingMsg = await ctx.reply(`Exporting session (${modeLabel})...`);
|
|
19949
21663
|
// Fetch session info and messages in parallel
|
|
19950
21664
|
const [sessionResult, messagesResult, pathResult] = await Promise.all([
|
|
19951
|
-
client.session.get({
|
|
19952
|
-
client.session.messages({
|
|
19953
|
-
client.path.get(),
|
|
21665
|
+
client.session.get({ sessionID: sessionId }),
|
|
21666
|
+
client.session.messages({ sessionID: sessionId }),
|
|
21667
|
+
client.path.get({}),
|
|
19954
21668
|
]);
|
|
19955
21669
|
if (sessionResult.error || !sessionResult.data) {
|
|
19956
21670
|
throw new Error(`Failed to get session: ${JSON.stringify(sessionResult.error)}`);
|
|
@@ -20065,12 +21779,10 @@ async function startTelegram(options) {
|
|
|
20065
21779
|
const processingMsg = await ctx.reply("Processing your command...");
|
|
20066
21780
|
const sessionId = await getOrCreateSession(chatId);
|
|
20067
21781
|
const result = await client.session.command({
|
|
20068
|
-
|
|
20069
|
-
|
|
20070
|
-
|
|
20071
|
-
|
|
20072
|
-
agent: "default",
|
|
20073
|
-
},
|
|
21782
|
+
sessionID: sessionId,
|
|
21783
|
+
command: commandName,
|
|
21784
|
+
arguments: commandArgs,
|
|
21785
|
+
agent: "default",
|
|
20074
21786
|
});
|
|
20075
21787
|
if (result.error) {
|
|
20076
21788
|
throw new Error(`Command failed: ${JSON.stringify(result.error)}`);
|
|
@@ -20096,20 +21808,89 @@ async function startTelegram(options) {
|
|
|
20096
21808
|
{ type: "text", text: userText },
|
|
20097
21809
|
]);
|
|
20098
21810
|
const verbose = chatVerboseMode.has(chatId);
|
|
20099
|
-
|
|
21811
|
+
// Fire detached so the handler completes and Telegraf can process
|
|
21812
|
+
// subsequent updates (e.g. callback queries from question buttons).
|
|
21813
|
+
sendPromptStreaming(ctx.chat.id, sessionId, promptBody, processingMsg.message_id, verbose).catch(async (err) => {
|
|
21814
|
+
console.error("[Telegram] Error processing message:", err);
|
|
21815
|
+
await handleSessionError(chatId);
|
|
21816
|
+
await sendTelegramMessage(ctx.chat.id, "Sorry, there was an error processing your request. Try again or use /new to start a fresh session.");
|
|
21817
|
+
});
|
|
20100
21818
|
}
|
|
20101
21819
|
catch (err) {
|
|
20102
|
-
console.error("[Telegram] Error
|
|
21820
|
+
console.error("[Telegram] Error setting up message:", err);
|
|
20103
21821
|
await handleSessionError(chatId);
|
|
20104
21822
|
await ctx.reply("Sorry, there was an error processing your request. Try again or use /new to start a fresh session.");
|
|
20105
21823
|
}
|
|
20106
21824
|
});
|
|
21825
|
+
// Check for pending questions left over from previous bot runs.
|
|
21826
|
+
// If any exist for a session we know about, re-forward them to Telegram
|
|
21827
|
+
// so the user can answer them and unblock the session.
|
|
21828
|
+
try {
|
|
21829
|
+
const pendingResult = await client.question.list({});
|
|
21830
|
+
if (pendingResult.data && pendingResult.data.length > 0) {
|
|
21831
|
+
console.log(`[Telegram] Found ${pendingResult.data.length} pending question(s) from previous run`);
|
|
21832
|
+
for (const pq of pendingResult.data) {
|
|
21833
|
+
const questionId = pq.id;
|
|
21834
|
+
const questionSessionId = pq.sessionID;
|
|
21835
|
+
const questions = pq.questions;
|
|
21836
|
+
const chatId = sessionToChatId(questionSessionId);
|
|
21837
|
+
if (!chatId || !questionId || !questions?.length) {
|
|
21838
|
+
// No matching chat — reject the stale question to unblock the session
|
|
21839
|
+
console.log(`[Telegram] Rejecting orphan pending question ${questionId} (no matching chat)`);
|
|
21840
|
+
try {
|
|
21841
|
+
await client.question.reject({ requestID: questionId });
|
|
21842
|
+
}
|
|
21843
|
+
catch (err) {
|
|
21844
|
+
console.warn(`[Telegram] Failed to reject orphan question ${questionId}:`, err);
|
|
21845
|
+
}
|
|
21846
|
+
continue;
|
|
21847
|
+
}
|
|
21848
|
+
// Store in pendingQuestions and re-send inline keyboard
|
|
21849
|
+
pendingQuestions.set(questionId, {
|
|
21850
|
+
chatId,
|
|
21851
|
+
sessionId: questionSessionId,
|
|
21852
|
+
questions,
|
|
21853
|
+
});
|
|
21854
|
+
const numericChatId = Number(chatId);
|
|
21855
|
+
for (let qi = 0; qi < questions.length; qi++) {
|
|
21856
|
+
const q = questions[qi];
|
|
21857
|
+
let msg = "";
|
|
21858
|
+
if (q.header)
|
|
21859
|
+
msg += `*${q.header}*\n`;
|
|
21860
|
+
msg += q.question;
|
|
21861
|
+
msg += "\n_(resumed from previous session)_";
|
|
21862
|
+
const keyboard = q.options.map((opt, oi) => [
|
|
21863
|
+
{
|
|
21864
|
+
text: opt.label,
|
|
21865
|
+
callback_data: `qa:${questionId}:${qi}:${oi}`,
|
|
21866
|
+
},
|
|
21867
|
+
]);
|
|
21868
|
+
keyboard.push([
|
|
21869
|
+
{ text: "Dismiss", callback_data: `qa_reject:${questionId}` },
|
|
21870
|
+
]);
|
|
21871
|
+
try {
|
|
21872
|
+
await bot.telegram.sendMessage(numericChatId, msg, {
|
|
21873
|
+
parse_mode: "Markdown",
|
|
21874
|
+
reply_markup: { inline_keyboard: keyboard },
|
|
21875
|
+
});
|
|
21876
|
+
}
|
|
21877
|
+
catch (err) {
|
|
21878
|
+
console.warn(`[Telegram] Failed to re-send question to chat ${chatId}:`, err);
|
|
21879
|
+
}
|
|
21880
|
+
}
|
|
21881
|
+
console.log(`[Telegram] Re-forwarded pending question ${questionId} to chat ${chatId}`);
|
|
21882
|
+
}
|
|
21883
|
+
}
|
|
21884
|
+
}
|
|
21885
|
+
catch (err) {
|
|
21886
|
+
console.warn("[Telegram] Failed to check for pending questions:", err);
|
|
21887
|
+
}
|
|
20107
21888
|
if (options.launch !== false) {
|
|
20108
21889
|
try {
|
|
20109
21890
|
// Start the bot — launch() returns a promise that resolves only
|
|
20110
21891
|
// when polling stops, so we log before awaiting it.
|
|
20111
21892
|
console.log("[Telegram] Bot is running (long-polling started)");
|
|
20112
|
-
await bot.launch();
|
|
21893
|
+
await bot.launch({ dropPendingUpdates: true });
|
|
20113
21894
|
// Enable graceful stop
|
|
20114
21895
|
process.once("SIGINT", () => bot.stop("SIGINT"));
|
|
20115
21896
|
process.once("SIGTERM", () => bot.stop("SIGTERM"));
|