@codetelemetry/connect 0.1.1 → 0.1.3
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/LICENSE +1 -1
- package/README.md +8 -24
- package/dist/agent.d.ts +699 -0
- package/dist/agent.js +435 -0
- package/dist/assistants.d.ts +4 -0
- package/dist/assistants.js +5 -0
- package/dist/bin.js +3 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +567 -0
- package/dist/clients.d.ts +34 -0
- package/dist/clients.js +74 -0
- package/dist/{src/codexConfig.d.ts → codexConfig.d.ts} +1 -0
- package/dist/{src/codexConfig.js → codexConfig.js} +5 -0
- package/dist/{src/config.d.ts → config.d.ts} +16 -0
- package/dist/{src/config.js → config.js} +16 -0
- package/dist/connectivity.d.ts +51 -0
- package/dist/connectivity.js +118 -0
- package/dist/{src/deviceClient.d.ts → deviceClient.d.ts} +9 -2
- package/dist/{src/deviceClient.js → deviceClient.js} +45 -13
- package/dist/graderSeed.d.ts +50 -0
- package/dist/graderSeed.js +289 -0
- package/dist/hostMetrics.d.ts +54 -0
- package/dist/hostMetrics.js +425 -0
- package/dist/import/browser.d.ts +30 -0
- package/dist/import/browser.js +157 -0
- package/dist/import/convert.d.ts +20 -0
- package/dist/import/convert.js +165 -0
- package/dist/import/core.d.ts +143 -0
- package/dist/import/core.js +441 -0
- package/dist/import/ledger.d.ts +52 -0
- package/dist/import/ledger.js +161 -0
- package/dist/import/model.d.ts +70 -0
- package/dist/import/model.js +42 -0
- package/dist/import/options.d.ts +24 -0
- package/dist/import/options.js +71 -0
- package/dist/import/otlpImport.d.ts +7 -0
- package/dist/import/otlpImport.js +81 -0
- package/dist/import/protocol.d.ts +35 -0
- package/dist/import/protocol.js +51 -0
- package/dist/import/run.d.ts +30 -0
- package/dist/import/run.js +127 -0
- package/dist/import/sources/claudeCodeText.d.ts +19 -0
- package/dist/import/sources/claudeCodeText.js +214 -0
- package/dist/import/sources/codexText.d.ts +20 -0
- package/dist/import/sources/codexText.js +319 -0
- package/dist/import/sources/files.d.ts +24 -0
- package/dist/import/sources/files.js +129 -0
- package/dist/import/transport.d.ts +76 -0
- package/dist/import/transport.js +141 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +19 -0
- package/dist/kiro/collector.d.ts +88 -0
- package/dist/kiro/collector.js +577 -0
- package/dist/kiro/command.d.ts +3 -0
- package/dist/kiro/command.js +109 -0
- package/dist/kiro/config.d.ts +39 -0
- package/dist/kiro/config.js +107 -0
- package/dist/kiro/records.d.ts +52 -0
- package/dist/kiro/records.js +206 -0
- package/dist/kiro/service.d.ts +21 -0
- package/dist/kiro/service.js +183 -0
- package/dist/kiro/state.d.ts +45 -0
- package/dist/kiro/state.js +205 -0
- package/dist/kiro/transport.d.ts +9 -0
- package/dist/kiro/transport.js +90 -0
- package/dist/{src/onboard.d.ts → onboard.d.ts} +8 -2
- package/dist/onboard.js +116 -0
- package/dist/piConfig.d.ts +29 -0
- package/dist/piConfig.js +112 -0
- package/dist/plan.d.ts +53 -0
- package/dist/plan.js +113 -0
- package/dist/{src/repositoryHook.d.ts → repositoryHook.d.ts} +0 -1
- package/dist/{src/repositoryHook.js → repositoryHook.js} +5 -38
- package/dist/{src/settings.d.ts → settings.d.ts} +4 -0
- package/dist/{src/settings.js → settings.js} +17 -0
- package/dist/yaml.d.ts +5 -0
- package/dist/yaml.js +72 -0
- package/package.json +27 -18
- package/dist/bin/connect.js +0 -6
- package/dist/src/cli.d.ts +0 -10
- package/dist/src/cli.js +0 -172
- package/dist/src/connectivity.d.ts +0 -27
- package/dist/src/connectivity.js +0 -54
- package/dist/src/index.d.ts +0 -8
- package/dist/src/index.js +0 -8
- package/dist/src/onboard.js +0 -84
- /package/dist/{bin/connect.d.ts → bin.d.ts} +0 -0
- /package/dist/{src/keys.d.ts → keys.d.ts} +0 -0
- /package/dist/{src/keys.js → keys.js} +0 -0
- /package/dist/{src/otlp.d.ts → otlp.d.ts} +0 -0
- /package/dist/{src/otlp.js → otlp.js} +0 -0
package/dist/agent.js
ADDED
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { assertKey } from "./keys.js";
|
|
2
|
+
function parseDiagnosis(raw) {
|
|
3
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
4
|
+
return null;
|
|
5
|
+
const d = raw;
|
|
6
|
+
if (typeof d.stage !== "string" || !d.stage)
|
|
7
|
+
return null;
|
|
8
|
+
const str = (v) => (typeof v === "string" && v ? v : null);
|
|
9
|
+
const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
|
|
10
|
+
return {
|
|
11
|
+
stage: d.stage,
|
|
12
|
+
detail: str(d.detail) ?? "",
|
|
13
|
+
hostFeedLastSeen: str(d.hostFeedLastSeen),
|
|
14
|
+
hostFeedLastSeenAgeSec: num(d.hostFeedLastSeenAgeSec),
|
|
15
|
+
otherFeedsLastSeen: str(d.otherFeedsLastSeen),
|
|
16
|
+
otherFeedsLastSeenAgeSec: num(d.otherFeedsLastSeenAgeSec),
|
|
17
|
+
horizonDays: num(d.horizonDays),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async function postAgent(opts) {
|
|
21
|
+
const key = assertKey(opts.key);
|
|
22
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
23
|
+
const ac = new AbortController();
|
|
24
|
+
const timer = setTimeout(() => ac.abort(), opts.timeoutMs ?? 10_000);
|
|
25
|
+
try {
|
|
26
|
+
let res;
|
|
27
|
+
try {
|
|
28
|
+
res = await fetchImpl(opts.url, {
|
|
29
|
+
method: "POST",
|
|
30
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
|
|
31
|
+
body: JSON.stringify(opts.body),
|
|
32
|
+
signal: ac.signal,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (!ac.signal.aborted)
|
|
37
|
+
throw error;
|
|
38
|
+
return {
|
|
39
|
+
ok: false,
|
|
40
|
+
value: null,
|
|
41
|
+
httpStatus: 0,
|
|
42
|
+
error: "read_timeout",
|
|
43
|
+
message: "Telemetry read timed out before the server responded.",
|
|
44
|
+
bodyError: null,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
let value = null;
|
|
48
|
+
let error = null;
|
|
49
|
+
let message = null;
|
|
50
|
+
let bodyError = null;
|
|
51
|
+
try {
|
|
52
|
+
const decoded = await res.json();
|
|
53
|
+
value = decoded;
|
|
54
|
+
error = typeof decoded?.error === "string" ? decoded.error : null;
|
|
55
|
+
message = typeof decoded?.message === "string" ? decoded.message : null;
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
bodyError = err instanceof SyntaxError
|
|
59
|
+
? null
|
|
60
|
+
: ac.signal.aborted ? "read_timeout" : "read_unavailable";
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
bodyError,
|
|
64
|
+
ok: res.status >= 200 && res.status < 300,
|
|
65
|
+
value,
|
|
66
|
+
httpStatus: res.status,
|
|
67
|
+
error,
|
|
68
|
+
message,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
clearTimeout(timer);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export async function getCostSignal(opts) {
|
|
76
|
+
const key = assertKey(opts.key);
|
|
77
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
78
|
+
const ac = new AbortController();
|
|
79
|
+
const timer = setTimeout(() => ac.abort(), opts.timeoutMs ?? 10_000);
|
|
80
|
+
try {
|
|
81
|
+
const res = await fetchImpl(opts.url, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
|
|
84
|
+
body: "{}",
|
|
85
|
+
signal: ac.signal,
|
|
86
|
+
});
|
|
87
|
+
let cost = null;
|
|
88
|
+
try {
|
|
89
|
+
const json = (await res.json());
|
|
90
|
+
cost = json?.cost ?? null;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
}
|
|
94
|
+
return { ok: res.status >= 200 && res.status < 300, cost, httpStatus: res.status };
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
clearTimeout(timer);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export function normalizeSessionPerformanceService(value) {
|
|
101
|
+
if (value === undefined)
|
|
102
|
+
return undefined;
|
|
103
|
+
if (typeof value !== "string" || /[\u0000-\u001f]/.test(value))
|
|
104
|
+
return null;
|
|
105
|
+
const service = value.trim();
|
|
106
|
+
return service && Buffer.byteLength(service, "utf8") <= 128 ? service : null;
|
|
107
|
+
}
|
|
108
|
+
export async function getSessionPerformance(opts) {
|
|
109
|
+
const service = normalizeSessionPerformanceService(opts.service);
|
|
110
|
+
if (service === null)
|
|
111
|
+
return { ok: false, report: null, httpStatus: 0, error: "bad_input", message: "service must contain 1-128 UTF-8 bytes without C0 controls" };
|
|
112
|
+
const result = await postAgent({
|
|
113
|
+
...opts,
|
|
114
|
+
timeoutMs: opts.timeoutMs ?? 120_000,
|
|
115
|
+
body: {
|
|
116
|
+
sessionId: opts.sessionId,
|
|
117
|
+
...(service === undefined ? {} : { service }),
|
|
118
|
+
...(opts.includeFresh === undefined ? {} : { includeFresh: opts.includeFresh }),
|
|
119
|
+
...(opts.cacheSamples === undefined ? {} : { cacheSamples: opts.cacheSamples }),
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
return {
|
|
123
|
+
ok: result.ok,
|
|
124
|
+
report: result.value?.report ?? null,
|
|
125
|
+
httpStatus: result.httpStatus,
|
|
126
|
+
error: result.error,
|
|
127
|
+
message: result.message,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export async function findSimilarSessionErrors(opts) {
|
|
131
|
+
const result = await postAgent({
|
|
132
|
+
...opts,
|
|
133
|
+
timeoutMs: opts.timeoutMs ?? 25_000,
|
|
134
|
+
body: {
|
|
135
|
+
sessionId: opts.sessionId,
|
|
136
|
+
...(opts.lookbackDays === undefined ? {} : { lookbackDays: opts.lookbackDays }),
|
|
137
|
+
...(opts.limit === undefined ? {} : { limit: opts.limit }),
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
ok: result.ok,
|
|
142
|
+
report: result.value?.report ?? null,
|
|
143
|
+
performance: result.value?.performance ?? null,
|
|
144
|
+
httpStatus: result.httpStatus,
|
|
145
|
+
error: result.error,
|
|
146
|
+
message: result.message,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export const SESSION_SEARCH_REQUEST_TIMEOUT_MS = 65_000;
|
|
150
|
+
export async function searchCodingSessions(opts) {
|
|
151
|
+
const result = await postAgent({
|
|
152
|
+
key: opts.key,
|
|
153
|
+
url: opts.url,
|
|
154
|
+
fetchImpl: opts.fetchImpl,
|
|
155
|
+
timeoutMs: opts.timeoutMs ?? SESSION_SEARCH_REQUEST_TIMEOUT_MS,
|
|
156
|
+
body: opts.query,
|
|
157
|
+
});
|
|
158
|
+
if (result.bodyError) {
|
|
159
|
+
return {
|
|
160
|
+
ok: false,
|
|
161
|
+
report: null,
|
|
162
|
+
httpStatus: result.httpStatus,
|
|
163
|
+
error: result.bodyError,
|
|
164
|
+
message: `Session-search response headers arrived but its body did not (${result.bodyError}).`,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const report = result.value?.report;
|
|
168
|
+
if (result.ok && (!report || typeof report !== "object" || Array.isArray(report))) {
|
|
169
|
+
return {
|
|
170
|
+
ok: false,
|
|
171
|
+
report: null,
|
|
172
|
+
httpStatus: result.httpStatus,
|
|
173
|
+
error: "read_unusable",
|
|
174
|
+
message: "Session-search response did not contain a usable report.",
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
ok: result.ok,
|
|
179
|
+
report: result.ok ? report ?? null : null,
|
|
180
|
+
httpStatus: result.httpStatus,
|
|
181
|
+
error: result.error,
|
|
182
|
+
message: result.message,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
export async function countReplyPhrases(opts) {
|
|
186
|
+
const result = await postAgent({
|
|
187
|
+
key: opts.key, url: opts.url, fetchImpl: opts.fetchImpl, timeoutMs: opts.timeoutMs ?? 20_000, body: opts.query,
|
|
188
|
+
});
|
|
189
|
+
if (result.bodyError) {
|
|
190
|
+
return { ok: false, trends: null, httpStatus: result.httpStatus, error: result.bodyError, message: `Reply-phrase response headers arrived but its body did not (${result.bodyError}).` };
|
|
191
|
+
}
|
|
192
|
+
const trends = result.value?.trends;
|
|
193
|
+
if (result.ok && (!trends || typeof trends !== "object" || Array.isArray(trends))) {
|
|
194
|
+
return { ok: false, trends: null, httpStatus: result.httpStatus, error: "read_unusable", message: "Reply-phrase response did not contain usable counts." };
|
|
195
|
+
}
|
|
196
|
+
return { ok: result.ok, trends: result.ok ? trends ?? null : null, httpStatus: result.httpStatus, error: result.error, message: result.message };
|
|
197
|
+
}
|
|
198
|
+
export async function estimateTaskSize(opts) {
|
|
199
|
+
const result = await postAgent({
|
|
200
|
+
...opts,
|
|
201
|
+
timeoutMs: opts.timeoutMs ?? 60_000,
|
|
202
|
+
body: {
|
|
203
|
+
...(opts.taskText === undefined ? {} : { taskText: opts.taskText }),
|
|
204
|
+
...(opts.issue === undefined ? {} : { issue: opts.issue }),
|
|
205
|
+
...(opts.issueKey === undefined ? {} : { issueKey: opts.issueKey }),
|
|
206
|
+
...(opts.repo === undefined ? {} : { repo: opts.repo }),
|
|
207
|
+
...(opts.linearScale === undefined ? {} : { linearScale: opts.linearScale }),
|
|
208
|
+
...(opts.linearScaleExtended === undefined ? {} : { linearScaleExtended: opts.linearScaleExtended }),
|
|
209
|
+
...(opts.lookbackDays === undefined ? {} : { lookbackDays: opts.lookbackDays }),
|
|
210
|
+
...(opts.limit === undefined ? {} : { limit: opts.limit }),
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
return {
|
|
214
|
+
ok: result.ok,
|
|
215
|
+
estimate: result.value?.estimate ?? null,
|
|
216
|
+
performance: result.value?.performance ?? null,
|
|
217
|
+
httpStatus: result.httpStatus,
|
|
218
|
+
error: result.error,
|
|
219
|
+
message: result.message,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
export async function getHostHealth(opts) {
|
|
223
|
+
assertKey(opts.key);
|
|
224
|
+
let result;
|
|
225
|
+
try {
|
|
226
|
+
result = await postAgent({
|
|
227
|
+
...opts,
|
|
228
|
+
timeoutMs: opts.timeoutMs ?? 25_000,
|
|
229
|
+
body: {
|
|
230
|
+
...(opts.lookbackMinutes === undefined ? {} : { lookbackMinutes: opts.lookbackMinutes }),
|
|
231
|
+
...(opts.thresholds === undefined ? {} : { thresholds: opts.thresholds }),
|
|
232
|
+
...(opts.diagnose === undefined ? {} : { diagnose: opts.diagnose }),
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
catch (err) {
|
|
237
|
+
return {
|
|
238
|
+
ok: false,
|
|
239
|
+
report: null,
|
|
240
|
+
status: null,
|
|
241
|
+
diagnosis: null,
|
|
242
|
+
serverVersion: null,
|
|
243
|
+
reportUnusable: null,
|
|
244
|
+
httpStatus: 0,
|
|
245
|
+
error: "read_unavailable",
|
|
246
|
+
message: `Host-health read could not reach the control plane: ${err.message}`,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (result.bodyError) {
|
|
250
|
+
return {
|
|
251
|
+
ok: false,
|
|
252
|
+
report: null,
|
|
253
|
+
status: null,
|
|
254
|
+
diagnosis: null,
|
|
255
|
+
serverVersion: null,
|
|
256
|
+
reportUnusable: null,
|
|
257
|
+
httpStatus: result.httpStatus,
|
|
258
|
+
error: result.bodyError,
|
|
259
|
+
message: `Host-health response headers arrived but its body did not (${result.bodyError}).`,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
const decoded = result.ok ? result.value : null;
|
|
263
|
+
const reportUnusable = (() => {
|
|
264
|
+
if (!result.ok)
|
|
265
|
+
return null;
|
|
266
|
+
if (decoded === null || typeof decoded !== "object") {
|
|
267
|
+
return "the response body could not be read as JSON";
|
|
268
|
+
}
|
|
269
|
+
if (!("report" in decoded))
|
|
270
|
+
return "the response carried no report member";
|
|
271
|
+
if (decoded.report === null)
|
|
272
|
+
return null;
|
|
273
|
+
if (typeof decoded.report !== "object" || Array.isArray(decoded.report)) {
|
|
274
|
+
return "the response report is not an object";
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
})();
|
|
278
|
+
return {
|
|
279
|
+
ok: result.ok,
|
|
280
|
+
report: result.ok && reportUnusable === null ? result.value?.report ?? null : null,
|
|
281
|
+
status: result.ok && typeof result.value?.status === "string" ? result.value.status : null,
|
|
282
|
+
diagnosis: parseDiagnosis(result.value?.diagnosis),
|
|
283
|
+
serverVersion: typeof result.value?.serverVersion === "string" && result.value.serverVersion.trim()
|
|
284
|
+
? result.value.serverVersion.trim()
|
|
285
|
+
: null,
|
|
286
|
+
reportUnusable,
|
|
287
|
+
httpStatus: result.httpStatus,
|
|
288
|
+
error: result.error,
|
|
289
|
+
message: result.message,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
export async function estimateLinearIssue(opts) {
|
|
293
|
+
const result = await postAgent({
|
|
294
|
+
...opts,
|
|
295
|
+
timeoutMs: opts.timeoutMs ?? 60_000,
|
|
296
|
+
body: {
|
|
297
|
+
reference: opts.reference,
|
|
298
|
+
...(opts.connectionId === undefined ? {} : { connectionId: opts.connectionId }),
|
|
299
|
+
...(opts.workspace === undefined ? {} : { workspace: opts.workspace }),
|
|
300
|
+
...(opts.repo === undefined ? {} : { repo: opts.repo }),
|
|
301
|
+
...(opts.linearScale === undefined ? {} : { linearScale: opts.linearScale }),
|
|
302
|
+
...(opts.linearScaleExtended === undefined ? {} : { linearScaleExtended: opts.linearScaleExtended }),
|
|
303
|
+
...(opts.lookbackDays === undefined ? {} : { lookbackDays: opts.lookbackDays }),
|
|
304
|
+
...(opts.limit === undefined ? {} : { limit: opts.limit }),
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
return {
|
|
308
|
+
ok: result.ok,
|
|
309
|
+
estimate: result.value?.estimate ?? null,
|
|
310
|
+
source: result.value?.source ?? null,
|
|
311
|
+
connections: result.value?.connections ?? null,
|
|
312
|
+
performance: result.value?.performance ?? null,
|
|
313
|
+
httpStatus: result.httpStatus,
|
|
314
|
+
error: result.error,
|
|
315
|
+
message: result.message,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
export async function interpretSession(opts) {
|
|
319
|
+
const result = await postAgent({
|
|
320
|
+
...opts,
|
|
321
|
+
timeoutMs: opts.timeoutMs ?? 15_000,
|
|
322
|
+
body: {
|
|
323
|
+
sessionId: opts.sessionId,
|
|
324
|
+
...(opts.service === undefined ? {} : { service: opts.service }),
|
|
325
|
+
...(opts.evidenceIds === undefined ? {} : { evidenceIds: opts.evidenceIds }),
|
|
326
|
+
...(opts.snapshot === undefined ? {} : { snapshot: opts.snapshot }),
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
return {
|
|
330
|
+
ok: result.ok,
|
|
331
|
+
value: result.value ?? null,
|
|
332
|
+
httpStatus: result.httpStatus,
|
|
333
|
+
error: result.error,
|
|
334
|
+
message: result.message,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
export async function readSessionEvents(opts) {
|
|
338
|
+
const result = await postAgent({ ...opts, timeoutMs: opts.timeoutMs ?? 15_000, body: opts.input });
|
|
339
|
+
return {
|
|
340
|
+
ok: result.ok,
|
|
341
|
+
value: result.value ?? null,
|
|
342
|
+
httpStatus: result.httpStatus,
|
|
343
|
+
error: result.error,
|
|
344
|
+
message: result.message,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
export async function readGitHubGate(opts) {
|
|
348
|
+
const result = await postAgent({ ...opts, body: {} });
|
|
349
|
+
return {
|
|
350
|
+
ok: result.ok,
|
|
351
|
+
gate: result.ok ? result.value?.gate ?? null : null,
|
|
352
|
+
httpStatus: result.httpStatus,
|
|
353
|
+
error: result.error,
|
|
354
|
+
message: result.message,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
export async function configureGitHubGate(opts) {
|
|
358
|
+
const result = await postAgent({ ...opts, body: opts.change });
|
|
359
|
+
return {
|
|
360
|
+
ok: result.ok,
|
|
361
|
+
gate: result.ok ? result.value?.gate ?? null : null,
|
|
362
|
+
httpStatus: result.httpStatus,
|
|
363
|
+
error: result.error,
|
|
364
|
+
message: result.message,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
export async function compareSessions(opts) {
|
|
368
|
+
const result = await postAgent({
|
|
369
|
+
...opts,
|
|
370
|
+
timeoutMs: opts.timeoutMs ?? 10_000,
|
|
371
|
+
body: { sessions: opts.sessions },
|
|
372
|
+
});
|
|
373
|
+
return {
|
|
374
|
+
ok: result.ok,
|
|
375
|
+
value: result.value ?? null,
|
|
376
|
+
httpStatus: result.httpStatus,
|
|
377
|
+
error: result.error,
|
|
378
|
+
message: result.message,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
export async function planNextSession(opts) {
|
|
382
|
+
const result = await postAgent({
|
|
383
|
+
...opts,
|
|
384
|
+
timeoutMs: opts.timeoutMs ?? 10_000,
|
|
385
|
+
body: {
|
|
386
|
+
...(opts.taskText === undefined ? {} : { taskText: opts.taskText }),
|
|
387
|
+
...(opts.draftPlan === undefined ? {} : { draftPlan: opts.draftPlan }),
|
|
388
|
+
...(opts.repo === undefined ? {} : { repo: opts.repo }),
|
|
389
|
+
...(opts.model === undefined ? {} : { model: opts.model }),
|
|
390
|
+
...(opts.environment === undefined ? {} : { environment: opts.environment }),
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
return { ok: result.ok, value: result.value ?? null, httpStatus: result.httpStatus, error: result.error, message: result.message };
|
|
394
|
+
}
|
|
395
|
+
export async function graderConfigRequest(opts) {
|
|
396
|
+
const key = assertKey(opts.key);
|
|
397
|
+
const response = await (opts.fetchImpl ?? fetch)(opts.url, {
|
|
398
|
+
method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
|
|
399
|
+
body: JSON.stringify(opts.body), signal: AbortSignal.timeout(10_000),
|
|
400
|
+
});
|
|
401
|
+
const reader = response.body?.getReader();
|
|
402
|
+
const chunks = [];
|
|
403
|
+
let bytes = 0;
|
|
404
|
+
if (reader)
|
|
405
|
+
try {
|
|
406
|
+
while (true) {
|
|
407
|
+
const chunk = await reader.read();
|
|
408
|
+
if (chunk.done)
|
|
409
|
+
break;
|
|
410
|
+
bytes += chunk.value.byteLength;
|
|
411
|
+
if (bytes > 64 * 1024)
|
|
412
|
+
throw new Error("Grader response exceeds 64 KiB");
|
|
413
|
+
chunks.push(chunk.value);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
finally {
|
|
417
|
+
await reader.cancel().catch(() => { });
|
|
418
|
+
reader.releaseLock();
|
|
419
|
+
}
|
|
420
|
+
let decoded;
|
|
421
|
+
try {
|
|
422
|
+
decoded = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
423
|
+
}
|
|
424
|
+
catch {
|
|
425
|
+
decoded = null;
|
|
426
|
+
}
|
|
427
|
+
const config = decoded?.config;
|
|
428
|
+
return {
|
|
429
|
+
ok: response.ok && decoded?.ok === true && !!config && typeof config === "object" && !Array.isArray(config),
|
|
430
|
+
config,
|
|
431
|
+
httpStatus: response.status,
|
|
432
|
+
error: typeof decoded?.error === "string" ? decoded.error : null,
|
|
433
|
+
message: typeof decoded?.message === "string" ? decoded.message : null,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const ONBOARD_CLIENTS: readonly ["claude", "codex", "pi", "kiro"];
|
|
2
|
+
export type OnboardClient = (typeof ONBOARD_CLIENTS)[number];
|
|
3
|
+
export declare function isOnboardClient(value: unknown): value is OnboardClient;
|
|
4
|
+
export declare const SESSION_FILTER_ASSISTANTS: readonly ["claude", "codex", "kiro"];
|
package/dist/bin.js
ADDED
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function run(argv: string[]): Promise<number>;
|