@gitterm/sdk 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/direct/index.js +46 -31
- package/package.json +2 -2
package/dist/direct/index.js
CHANGED
|
@@ -30,7 +30,7 @@ function normalizeQuestion(question) {
|
|
|
30
30
|
}
|
|
31
31
|
return changed ? { ...question, options, custom } : question;
|
|
32
32
|
}
|
|
33
|
-
// ../../node_modules/.bun/@opencode+client@2.2.
|
|
33
|
+
// ../../node_modules/.bun/@opencode+client@2.2.6+307d8a970cbb91e6/node_modules/@opencode/client/dist/chunks/contract-9rqn6x4v.js
|
|
34
34
|
var __defProp = Object.defineProperty;
|
|
35
35
|
var __returnValue = (v) => v;
|
|
36
36
|
function __exportSetter(name, newValue) {
|
|
@@ -46,7 +46,7 @@ var __export = (target, all) => {
|
|
|
46
46
|
});
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
// ../../node_modules/.bun/@opencode+client@2.2.
|
|
49
|
+
// ../../node_modules/.bun/@opencode+client@2.2.6+307d8a970cbb91e6/node_modules/@opencode/client/dist/chunks/contract-gecjxyvt.js
|
|
50
50
|
var exports_shared_events = {};
|
|
51
51
|
__export(exports_shared_events, {
|
|
52
52
|
SharedEvents: () => exports_shared_events,
|
|
@@ -190,8 +190,8 @@ function make7(connect) {
|
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
// ../../node_modules/.bun/@opencode+client@2.2.
|
|
194
|
-
class
|
|
193
|
+
// ../../node_modules/.bun/@opencode+client@2.2.6+307d8a970cbb91e6/node_modules/@opencode/client/dist/chunks/contract-nwcpakzx.js
|
|
194
|
+
class ClientError3 extends Error {
|
|
195
195
|
reason;
|
|
196
196
|
name = "ClientError";
|
|
197
197
|
constructor(reason, options) {
|
|
@@ -201,13 +201,13 @@ class ClientError2 extends Error {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
// ../../node_modules/.bun/@opencode+client@2.2.
|
|
205
|
-
var
|
|
206
|
-
__export(
|
|
207
|
-
make: () =>
|
|
204
|
+
// ../../node_modules/.bun/@opencode+client@2.2.6+307d8a970cbb91e6/node_modules/@opencode/client/dist/chunks/contract-vxrn9xjg.js
|
|
205
|
+
var exports_client4 = {};
|
|
206
|
+
__export(exports_client4, {
|
|
207
|
+
make: () => make6
|
|
208
208
|
});
|
|
209
209
|
var maxSseEventBytes = 16 * 1024 * 1024;
|
|
210
|
-
function
|
|
210
|
+
function make6(options) {
|
|
211
211
|
const fetch2 = options.fetch ?? globalThis.fetch;
|
|
212
212
|
const prepare = (descriptor, requestOptions) => {
|
|
213
213
|
const baseUrl = new URL(options.baseUrl);
|
|
@@ -240,7 +240,7 @@ function make3(options) {
|
|
|
240
240
|
const prepared = prepare(descriptor, requestOptions);
|
|
241
241
|
return await fetch2(prepared.url, prepared.init);
|
|
242
242
|
} catch (cause) {
|
|
243
|
-
throw new
|
|
243
|
+
throw new ClientError3("Transport", { cause });
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
246
|
const responseError = async (response, descriptor) => {
|
|
@@ -249,7 +249,7 @@ function make3(options) {
|
|
|
249
249
|
try {
|
|
250
250
|
await response.body?.cancel();
|
|
251
251
|
} catch {}
|
|
252
|
-
throw new
|
|
252
|
+
throw new ClientError3("UnexpectedStatus", { cause: { status: response.status }, detail: String(response.status) });
|
|
253
253
|
};
|
|
254
254
|
const request = async (descriptor, requestOptions) => {
|
|
255
255
|
const response = await execute(descriptor, requestOptions);
|
|
@@ -274,10 +274,10 @@ function make3(options) {
|
|
|
274
274
|
try {
|
|
275
275
|
await response.body?.cancel();
|
|
276
276
|
} catch {}
|
|
277
|
-
throw new
|
|
277
|
+
throw new ClientError3("UnsupportedContentType", { detail: response.headers.get("content-type") });
|
|
278
278
|
}
|
|
279
279
|
if (response.body === null)
|
|
280
|
-
throw new
|
|
280
|
+
throw new ClientError3("MalformedResponse");
|
|
281
281
|
const reader = response.body.getReader();
|
|
282
282
|
const decoder = new TextDecoder;
|
|
283
283
|
let buffer = "";
|
|
@@ -287,13 +287,13 @@ function make3(options) {
|
|
|
287
287
|
try {
|
|
288
288
|
next = await reader.read();
|
|
289
289
|
} catch (cause) {
|
|
290
|
-
throw new
|
|
290
|
+
throw new ClientError3("Transport", { cause });
|
|
291
291
|
}
|
|
292
292
|
if (!next.done)
|
|
293
293
|
requestOptions?.onActivity?.();
|
|
294
294
|
buffer += decoder.decode(next.value, { stream: !next.done });
|
|
295
295
|
if (buffer.length > maxSseEventBytes)
|
|
296
|
-
throw new
|
|
296
|
+
throw new ClientError3("SseEventTooLarge");
|
|
297
297
|
const trailingCarriageReturn = !next.done && buffer.endsWith("\r");
|
|
298
298
|
if (trailingCarriageReturn)
|
|
299
299
|
buffer = buffer.slice(0, -1);
|
|
@@ -320,7 +320,7 @@ function make3(options) {
|
|
|
320
320
|
try {
|
|
321
321
|
yield JSON.parse(data);
|
|
322
322
|
} catch (cause) {
|
|
323
|
-
throw new
|
|
323
|
+
throw new ClientError3("MalformedResponse", { cause });
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
boundary = buffer.indexOf(`
|
|
@@ -1178,6 +1178,21 @@ function make3(options) {
|
|
|
1178
1178
|
binary: true
|
|
1179
1179
|
}, requestOptions)
|
|
1180
1180
|
},
|
|
1181
|
+
job: {
|
|
1182
|
+
list: (input, requestOptions) => request({
|
|
1183
|
+
method: "GET",
|
|
1184
|
+
path: `/api/experimental/job`,
|
|
1185
|
+
query: {
|
|
1186
|
+
sessionID: input?.["sessionID"],
|
|
1187
|
+
kind: input?.["kind"],
|
|
1188
|
+
status: input?.["status"],
|
|
1189
|
+
descendants: input?.["descendants"]
|
|
1190
|
+
},
|
|
1191
|
+
successStatus: 200,
|
|
1192
|
+
declaredStatuses: [400, 401, 404],
|
|
1193
|
+
empty: false
|
|
1194
|
+
}, requestOptions).then((value) => value.data)
|
|
1195
|
+
},
|
|
1181
1196
|
migration: {
|
|
1182
1197
|
v1: {
|
|
1183
1198
|
status: (requestOptions) => request({
|
|
@@ -1963,20 +1978,20 @@ async function json(response) {
|
|
|
1963
1978
|
try {
|
|
1964
1979
|
await response.body?.cancel();
|
|
1965
1980
|
} catch {}
|
|
1966
|
-
throw new
|
|
1981
|
+
throw new ClientError3("UnsupportedContentType", { detail: response.headers.get("content-type") });
|
|
1967
1982
|
}
|
|
1968
1983
|
let text;
|
|
1969
1984
|
try {
|
|
1970
1985
|
text = await response.text();
|
|
1971
1986
|
} catch (cause) {
|
|
1972
|
-
throw new
|
|
1987
|
+
throw new ClientError3("Transport", { cause });
|
|
1973
1988
|
}
|
|
1974
1989
|
if (text === "")
|
|
1975
|
-
throw new
|
|
1990
|
+
throw new ClientError3("MalformedResponse");
|
|
1976
1991
|
try {
|
|
1977
1992
|
return JSON.parse(text);
|
|
1978
1993
|
} catch (cause) {
|
|
1979
|
-
throw new
|
|
1994
|
+
throw new ClientError3("MalformedResponse", { cause });
|
|
1980
1995
|
}
|
|
1981
1996
|
}
|
|
1982
1997
|
function declared(body) {
|
|
@@ -1989,11 +2004,11 @@ function isContentType(response, expected) {
|
|
|
1989
2004
|
return response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() === expected;
|
|
1990
2005
|
}
|
|
1991
2006
|
|
|
1992
|
-
// ../../node_modules/.bun/@opencode+client@2.2.
|
|
2007
|
+
// ../../node_modules/.bun/@opencode+client@2.2.6+307d8a970cbb91e6/node_modules/@opencode/client/dist/chunks/contract-sdjh9vmn.js
|
|
1993
2008
|
var isRpcError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "RpcError";
|
|
1994
2009
|
var isRpcInternalError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "RpcInternalError";
|
|
1995
2010
|
|
|
1996
|
-
// ../../node_modules/.bun/@opencode+client@2.2.
|
|
2011
|
+
// ../../node_modules/.bun/@opencode+client@2.2.6+307d8a970cbb91e6/node_modules/@opencode/client/dist/chunks/contract-xqwq6bgr.js
|
|
1997
2012
|
function makeRpc2(raw, events) {
|
|
1998
2013
|
return (definition) => {
|
|
1999
2014
|
const subscribe = (name, options) => {
|
|
@@ -2068,14 +2083,14 @@ function eventType(definition, name) {
|
|
|
2068
2083
|
return `rpc.${definition.id}.${name}`;
|
|
2069
2084
|
}
|
|
2070
2085
|
|
|
2071
|
-
// ../../node_modules/.bun/@opencode+client@2.2.
|
|
2072
|
-
var
|
|
2073
|
-
__export(
|
|
2074
|
-
OpenCode: () =>
|
|
2075
|
-
make: () =>
|
|
2086
|
+
// ../../node_modules/.bun/@opencode+client@2.2.6+307d8a970cbb91e6/node_modules/@opencode/client/dist/chunks/contract-xby11z3y.js
|
|
2087
|
+
var exports_client3 = {};
|
|
2088
|
+
__export(exports_client3, {
|
|
2089
|
+
OpenCode: () => exports_client3,
|
|
2090
|
+
make: () => make5
|
|
2076
2091
|
});
|
|
2077
|
-
function
|
|
2078
|
-
const raw =
|
|
2092
|
+
function make5(options) {
|
|
2093
|
+
const raw = make6(options);
|
|
2079
2094
|
const events = make7((signal, onActivity) => raw.event.subscribe(undefined, { signal, onActivity }));
|
|
2080
2095
|
return {
|
|
2081
2096
|
...raw,
|
|
@@ -2103,7 +2118,7 @@ function authorizationHeader(password) {
|
|
|
2103
2118
|
}
|
|
2104
2119
|
function createOpencodeClient(target) {
|
|
2105
2120
|
const send = target.fetch ?? fetch;
|
|
2106
|
-
return
|
|
2121
|
+
return exports_client3.make({
|
|
2107
2122
|
baseUrl: target.url,
|
|
2108
2123
|
headers: { ...target.headers, ...authorizationHeader(target.password) },
|
|
2109
2124
|
fetch: async (input, init) => {
|
|
@@ -2116,7 +2131,7 @@ function createOpencodeClient(target) {
|
|
|
2116
2131
|
});
|
|
2117
2132
|
}
|
|
2118
2133
|
function unwrapClientError(error) {
|
|
2119
|
-
return error instanceof
|
|
2134
|
+
return error instanceof ClientError3 && error.reason === "Transport" && error.cause !== undefined ? error.cause : error;
|
|
2120
2135
|
}
|
|
2121
2136
|
async function call(operation) {
|
|
2122
2137
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitterm/sdk",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@gitterm/agent-runtime": "workspace:*",
|
|
54
54
|
"@gitterm/api": "workspace:*",
|
|
55
|
-
"@opencode/client": "2.2.
|
|
55
|
+
"@opencode/client": "2.2.6",
|
|
56
56
|
"@trpc/server": "catalog:",
|
|
57
57
|
"@types/bun": "^1.2.6",
|
|
58
58
|
"typescript": "^5.8.2"
|