opencode-tbot 0.1.27 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugin.js +22 -1
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -295,7 +295,12 @@ var OpenCodeClient = class {
|
|
|
295
295
|
return unwrapSdkData(input.parameters === void 0 ? await handler.call(target, options) : await handler.call(target, input.parameters, options));
|
|
296
296
|
}
|
|
297
297
|
async getHealth() {
|
|
298
|
-
|
|
298
|
+
try {
|
|
299
|
+
return await this.callScopedSdkMethod("global", "health", {});
|
|
300
|
+
} catch (error) {
|
|
301
|
+
if (!isMissingScopedSdkMethodError(error, "global", "health")) throw error;
|
|
302
|
+
return this.callRawSdkGet("/global/health");
|
|
303
|
+
}
|
|
299
304
|
}
|
|
300
305
|
async abortSession(sessionId) {
|
|
301
306
|
return this.callScopedSdkMethod("session", "abort", { parameters: { sessionID: sessionId } });
|
|
@@ -618,6 +623,15 @@ var OpenCodeClient = class {
|
|
|
618
623
|
parameters: void 0
|
|
619
624
|
});
|
|
620
625
|
}
|
|
626
|
+
async callRawSdkGet(url, signal) {
|
|
627
|
+
const rawClient = getRawSdkRequestClient(this.client);
|
|
628
|
+
if (typeof rawClient?.get !== "function") throw new Error(`OpenCode SDK client does not expose a compatible raw GET endpoint for ${url}.`);
|
|
629
|
+
return unwrapSdkData(await rawClient.get({
|
|
630
|
+
...SDK_OPTIONS,
|
|
631
|
+
...signal ? { signal } : {},
|
|
632
|
+
url
|
|
633
|
+
}));
|
|
634
|
+
}
|
|
621
635
|
async runPromptRequestWithTimeout(input, operation, signal) {
|
|
622
636
|
const startedAt = Date.now();
|
|
623
637
|
const controller = new AbortController();
|
|
@@ -959,6 +973,13 @@ function unwrapSdkData(response) {
|
|
|
959
973
|
if (response && typeof response === "object" && "data" in response) return response.data;
|
|
960
974
|
return response;
|
|
961
975
|
}
|
|
976
|
+
function getRawSdkRequestClient(client) {
|
|
977
|
+
const compatibleClient = client;
|
|
978
|
+
return compatibleClient.client ?? compatibleClient._client ?? null;
|
|
979
|
+
}
|
|
980
|
+
function isMissingScopedSdkMethodError(error, scope, method) {
|
|
981
|
+
return error instanceof Error && error.message === `OpenCode SDK client does not expose a compatible ${scope}.${method} method.`;
|
|
982
|
+
}
|
|
962
983
|
function resolvePromptTimeoutPolicy(input) {
|
|
963
984
|
return {
|
|
964
985
|
pollRequestTimeoutMs: input.pollRequestTimeoutMs ?? DEFAULT_OPENCODE_PROMPT_TIMEOUT_POLICY.pollRequestTimeoutMs,
|