lunel-cli 0.1.58 → 0.1.59
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/ai/opencode.d.ts +1 -0
- package/dist/ai/opencode.js +41 -17
- package/package.json +1 -1
package/dist/ai/opencode.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare class OpenCodeProvider implements AIProvider {
|
|
|
51
51
|
private refreshSessionsMetadata;
|
|
52
52
|
private refreshPendingPermissions;
|
|
53
53
|
private refreshPendingQuestions;
|
|
54
|
+
private fetchOpenCodeJson;
|
|
54
55
|
private refreshSessionStatuses;
|
|
55
56
|
private trackPermissionEvent;
|
|
56
57
|
private asRecord;
|
package/dist/ai/opencode.js
CHANGED
|
@@ -244,21 +244,18 @@ export class OpenCodeProvider {
|
|
|
244
244
|
return {};
|
|
245
245
|
}
|
|
246
246
|
async questionReply(sessionId, questionId, answers) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
await questionApi.reply({ requestID: questionId, answers });
|
|
247
|
+
await this.fetchOpenCodeJson(`/question/${encodeURIComponent(questionId)}/reply`, {
|
|
248
|
+
method: "POST",
|
|
249
|
+
body: { answers },
|
|
250
|
+
});
|
|
252
251
|
this.knownPendingQuestionIds.delete(questionId);
|
|
253
252
|
this.emitter?.({ type: "question.replied", properties: { sessionID: sessionId, requestID: questionId, answers } });
|
|
254
253
|
return {};
|
|
255
254
|
}
|
|
256
255
|
async questionReject(sessionId, questionId) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
await questionApi.reject({ requestID: questionId });
|
|
256
|
+
await this.fetchOpenCodeJson(`/question/${encodeURIComponent(questionId)}/reject`, {
|
|
257
|
+
method: "POST",
|
|
258
|
+
});
|
|
262
259
|
this.knownPendingQuestionIds.delete(questionId);
|
|
263
260
|
this.emitter?.({ type: "question.rejected", properties: { sessionID: sessionId, requestID: questionId } });
|
|
264
261
|
return {};
|
|
@@ -433,14 +430,12 @@ export class OpenCodeProvider {
|
|
|
433
430
|
}
|
|
434
431
|
}
|
|
435
432
|
async refreshPendingQuestions() {
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
const response = await questionApi.list();
|
|
441
|
-
const data = Array.isArray(response.data) ? response.data : [];
|
|
433
|
+
const data = await this.fetchOpenCodeJson("/question", {
|
|
434
|
+
method: "GET",
|
|
435
|
+
});
|
|
436
|
+
const questions = Array.isArray(data) ? data : [];
|
|
442
437
|
const nextIds = new Set();
|
|
443
|
-
for (const entry of
|
|
438
|
+
for (const entry of questions) {
|
|
444
439
|
const question = this.asRecord(entry);
|
|
445
440
|
const id = this.readString(question.id);
|
|
446
441
|
const sessionID = this.readString(question.sessionID) ?? this.readString(question.sessionId);
|
|
@@ -467,6 +462,35 @@ export class OpenCodeProvider {
|
|
|
467
462
|
this.knownPendingQuestionIds.delete(id);
|
|
468
463
|
}
|
|
469
464
|
}
|
|
465
|
+
async fetchOpenCodeJson(pathname, options = {}) {
|
|
466
|
+
const server = this.server;
|
|
467
|
+
const authHeader = this.authHeader;
|
|
468
|
+
if (!server || !authHeader) {
|
|
469
|
+
throw new Error("OpenCode server is not ready");
|
|
470
|
+
}
|
|
471
|
+
const url = new URL(pathname, server.url);
|
|
472
|
+
const response = await fetch(url, {
|
|
473
|
+
method: options.method ?? "GET",
|
|
474
|
+
headers: {
|
|
475
|
+
Authorization: authHeader,
|
|
476
|
+
accept: "application/json",
|
|
477
|
+
...(options.body ? { "content-type": "application/json" } : {}),
|
|
478
|
+
},
|
|
479
|
+
...(options.body ? { body: JSON.stringify(options.body) } : {}),
|
|
480
|
+
});
|
|
481
|
+
if (!response.ok) {
|
|
482
|
+
let detail = "";
|
|
483
|
+
try {
|
|
484
|
+
detail = await response.text();
|
|
485
|
+
}
|
|
486
|
+
catch {
|
|
487
|
+
// ignore detail read failures
|
|
488
|
+
}
|
|
489
|
+
const suffix = detail.trim().length > 0 ? `: ${detail.trim()}` : "";
|
|
490
|
+
throw new Error(`OpenCode request failed (${response.status})${suffix}`);
|
|
491
|
+
}
|
|
492
|
+
return response.json().catch(() => null);
|
|
493
|
+
}
|
|
470
494
|
async refreshSessionStatuses() {
|
|
471
495
|
const server = this.server;
|
|
472
496
|
const authHeader = this.authHeader;
|