@liberseek/boft-cli-win32-arm64 0.6.4 → 0.6.5
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 +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/host-runtime.mjs +182 -127
- package/app/plugins/claude-code/plugin.mjs +664 -229
- package/app/plugins/deepseek-harness/plugin.mjs +82 -17
- package/app/plugins/grok/plugin.mjs +6 -0
- package/app/plugins/kiro-cli/plugin.mjs +77 -61
- package/app/plugins/omp/plugin.mjs +6 -0
- package/app/plugins/opencode/plugin.mjs +292 -142
- package/app/plugins/pi/plugin.mjs +1489 -1304
- package/app/renderer-extension.js +17 -23
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
|
@@ -19248,6 +19248,12 @@ function parseHostUsage(value) {
|
|
|
19248
19248
|
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
19249
19249
|
}
|
|
19250
19250
|
}
|
|
19251
|
+
for (const field of ["totalCredits", "contextUsagePercent"]) {
|
|
19252
|
+
const candidate = value[field];
|
|
19253
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
19254
|
+
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
19255
|
+
}
|
|
19256
|
+
}
|
|
19251
19257
|
for (const field of tokenFields) {
|
|
19252
19258
|
const candidate = value[field];
|
|
19253
19259
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
@@ -30826,6 +30832,7 @@ var LiveBuffer = class {
|
|
|
30826
30832
|
import { randomUUID as nodeRandomUUID } from "node:crypto";
|
|
30827
30833
|
import { isDeepStrictEqual as isDeepStrictEqual5 } from "node:util";
|
|
30828
30834
|
var DEEPSEEK_HARNESS_ID2 = harnessIdSchema.parse("deepseek-harness");
|
|
30835
|
+
var NATIVE_CLOSE_TIMEOUT_MS = 5e3;
|
|
30829
30836
|
var MODERN_PROMPT_CORRELATION_GRACE_MS = 5e3;
|
|
30830
30837
|
var MODERN_ACCEPTED_CORRELATION_TIMEOUT_MS = 3e5;
|
|
30831
30838
|
var MAX_TIMER_DELAY_MS2 = 2147483647;
|
|
@@ -30905,8 +30912,11 @@ var ModernHarnessSession = class {
|
|
|
30905
30912
|
#usage;
|
|
30906
30913
|
#historyBytes;
|
|
30907
30914
|
#closed = false;
|
|
30915
|
+
#closing = false;
|
|
30916
|
+
#nativeCloseTerminal;
|
|
30908
30917
|
#closedNotified = false;
|
|
30909
30918
|
#faulted;
|
|
30919
|
+
#faultMayHaveNativeWork = false;
|
|
30910
30920
|
#closePromise;
|
|
30911
30921
|
#pumpPromise;
|
|
30912
30922
|
constructor(options) {
|
|
@@ -30999,14 +31009,14 @@ var ModernHarnessSession = class {
|
|
|
30999
31009
|
this.#pumpPromise = this.#pump();
|
|
31000
31010
|
if (resumedAutonomousBuffer) {
|
|
31001
31011
|
queueMicrotask(() => {
|
|
31002
|
-
if (!this.#closed && this.#buffer === resumedAutonomousBuffer) {
|
|
31012
|
+
if (!this.#closed && !this.#closing && this.#buffer === resumedAutonomousBuffer) {
|
|
31003
31013
|
this.#activateBufferedAutonomous(true);
|
|
31004
31014
|
}
|
|
31005
31015
|
});
|
|
31006
31016
|
}
|
|
31007
31017
|
}
|
|
31008
31018
|
readSnapshot() {
|
|
31009
|
-
if (this.#closed)
|
|
31019
|
+
if (this.#closed || this.#closing)
|
|
31010
31020
|
return Promise.resolve({ ok: false, error: closedError() });
|
|
31011
31021
|
if (this.#reading)
|
|
31012
31022
|
return Promise.resolve({ ok: false, error: busyError("read history") });
|
|
@@ -31028,7 +31038,7 @@ var ModernHarnessSession = class {
|
|
|
31028
31038
|
}
|
|
31029
31039
|
}
|
|
31030
31040
|
execute(command) {
|
|
31031
|
-
if (this.#closed)
|
|
31041
|
+
if (this.#closed || this.#closing)
|
|
31032
31042
|
return Promise.resolve({ ok: false, error: closedError() });
|
|
31033
31043
|
switch (command.type) {
|
|
31034
31044
|
case "turn.start":
|
|
@@ -31046,6 +31056,13 @@ var ModernHarnessSession = class {
|
|
|
31046
31056
|
}
|
|
31047
31057
|
}
|
|
31048
31058
|
close() {
|
|
31059
|
+
const faultCleanup = this.#closePromise;
|
|
31060
|
+
if (this.#faultMayHaveNativeWork && !this.#closing && faultCleanup) {
|
|
31061
|
+
this.#closing = true;
|
|
31062
|
+
this.#closePromise = faultCleanup.then(() => {
|
|
31063
|
+
throw new Error("DeepSeek Harness native execution stop was not confirmed before the Session fault");
|
|
31064
|
+
});
|
|
31065
|
+
}
|
|
31049
31066
|
this.#closePromise ??= this.#performClose();
|
|
31050
31067
|
return this.#closePromise;
|
|
31051
31068
|
}
|
|
@@ -31060,7 +31077,7 @@ var ModernHarnessSession = class {
|
|
|
31060
31077
|
if (this.#queuedDeliveries.has(delivery.eventId) || this.#interactionByEventId.has(delivery.eventId)) {
|
|
31061
31078
|
throw new ModernEventGatewayError("protocolError", "DeepSeek Harness event delivery was duplicated");
|
|
31062
31079
|
}
|
|
31063
|
-
if (this.#closed) {
|
|
31080
|
+
if (this.#closed || this.#closing) {
|
|
31064
31081
|
this.#queuedDeliveries.set(delivery.eventId, delivery);
|
|
31065
31082
|
return;
|
|
31066
31083
|
}
|
|
@@ -31329,14 +31346,14 @@ ${question.detail}` : question.question;
|
|
|
31329
31346
|
this.#operationControllers.add(abort);
|
|
31330
31347
|
try {
|
|
31331
31348
|
const result = await operation(abort.signal);
|
|
31332
|
-
if (this.#closed)
|
|
31349
|
+
if (this.#closed || this.#closing)
|
|
31333
31350
|
return { ok: false, error: closedError() };
|
|
31334
31351
|
this.#publishConfiguration(true);
|
|
31335
31352
|
return { ok: true, value: result.value };
|
|
31336
31353
|
} catch (error51) {
|
|
31337
31354
|
if (this.#faulted)
|
|
31338
31355
|
return { ok: false, error: this.#faulted };
|
|
31339
|
-
if (this.#closed)
|
|
31356
|
+
if (this.#closed || this.#closing)
|
|
31340
31357
|
return { ok: false, error: closedError() };
|
|
31341
31358
|
const failure = configurationOrProtocolError(error51, "DeepSeek Harness configuration failed");
|
|
31342
31359
|
if (configurationFailureRequiresSessionFault(error51))
|
|
@@ -31448,7 +31465,7 @@ ${question.detail}` : question.question;
|
|
|
31448
31465
|
} catch (error51) {
|
|
31449
31466
|
if (this.#faulted)
|
|
31450
31467
|
return { ok: false, error: this.#faulted };
|
|
31451
|
-
if (this.#closed)
|
|
31468
|
+
if (this.#closed || this.#closing)
|
|
31452
31469
|
return { ok: false, error: closedError() };
|
|
31453
31470
|
if (pending.admissionObserved)
|
|
31454
31471
|
return this.#acceptPrompt(pending);
|
|
@@ -31456,7 +31473,7 @@ ${question.detail}` : question.question;
|
|
|
31456
31473
|
if (resolution.kind === "accepted") {
|
|
31457
31474
|
if (this.#faulted)
|
|
31458
31475
|
return { ok: false, error: this.#faulted };
|
|
31459
|
-
if (this.#closed)
|
|
31476
|
+
if (this.#closed || this.#closing)
|
|
31460
31477
|
return { ok: false, error: closedError() };
|
|
31461
31478
|
return this.#acceptPrompt(pending);
|
|
31462
31479
|
}
|
|
@@ -31524,12 +31541,12 @@ ${question.detail}` : question.question;
|
|
|
31524
31541
|
return true;
|
|
31525
31542
|
}
|
|
31526
31543
|
async #listHarnessCommands() {
|
|
31527
|
-
if (this.#closed)
|
|
31544
|
+
if (this.#closed || this.#closing)
|
|
31528
31545
|
return { ok: false, error: closedError() };
|
|
31529
31546
|
return { ok: true, value: deepSeekHarnessCommandCatalog() };
|
|
31530
31547
|
}
|
|
31531
31548
|
async #executeHarnessCommand(command) {
|
|
31532
|
-
if (this.#closed)
|
|
31549
|
+
if (this.#closed || this.#closing)
|
|
31533
31550
|
return { ok: false, error: closedError() };
|
|
31534
31551
|
const parsed = parseDeepSeekHarnessCommand(command);
|
|
31535
31552
|
if (!parsed.ok)
|
|
@@ -31549,7 +31566,7 @@ ${question.detail}` : question.question;
|
|
|
31549
31566
|
const catalog = await this.#listHarnessCommands();
|
|
31550
31567
|
if (!catalog.ok)
|
|
31551
31568
|
return catalog;
|
|
31552
|
-
if (this.#closed)
|
|
31569
|
+
if (this.#closed || this.#closing)
|
|
31553
31570
|
return { ok: false, error: closedError() };
|
|
31554
31571
|
if (admission.cancellationRequested) {
|
|
31555
31572
|
return { ok: false, error: invalidState3("DeepSeek Harness command was cancelled") };
|
|
@@ -31911,13 +31928,13 @@ ${question.detail}` : question.question;
|
|
|
31911
31928
|
}
|
|
31912
31929
|
#scheduleBoundTurn(pending) {
|
|
31913
31930
|
const buffer = pending.buffer;
|
|
31914
|
-
if (!buffer || !pending.admitted || pending.publishScheduled || buffer.active || this.#closed) {
|
|
31931
|
+
if (!buffer || !pending.admitted || pending.publishScheduled || buffer.active || this.#closed || this.#closing) {
|
|
31915
31932
|
return;
|
|
31916
31933
|
}
|
|
31917
31934
|
pending.publishScheduled = true;
|
|
31918
31935
|
queueMicrotask(() => queueMicrotask(() => {
|
|
31919
31936
|
pending.publishScheduled = false;
|
|
31920
|
-
if (!this.#closed && pending.admitted && pending.buffer === buffer && this.#buffer === buffer && !buffer.active) {
|
|
31937
|
+
if (!this.#closed && !this.#closing && pending.admitted && pending.buffer === buffer && this.#buffer === buffer && !buffer.active) {
|
|
31921
31938
|
this.#materialize(buffer, pending.command.turnId, textInputs2(pending.command.input), false, false);
|
|
31922
31939
|
}
|
|
31923
31940
|
}));
|
|
@@ -31933,7 +31950,7 @@ ${question.detail}` : question.question;
|
|
|
31933
31950
|
delete pending.buffer;
|
|
31934
31951
|
if (buffer.reachedCorrelationBoundary || buffer.events.at(-1)?.type === "turn/end") {
|
|
31935
31952
|
queueMicrotask(() => {
|
|
31936
|
-
if (!this.#closed && this.#buffer === buffer && !buffer.active && !buffer.pending) {
|
|
31953
|
+
if (!this.#closed && !this.#closing && this.#buffer === buffer && !buffer.active && !buffer.pending) {
|
|
31937
31954
|
this.#materializeAutonomous(buffer, false);
|
|
31938
31955
|
}
|
|
31939
31956
|
});
|
|
@@ -31948,12 +31965,14 @@ ${question.detail}` : question.question;
|
|
|
31948
31965
|
}
|
|
31949
31966
|
#activateBufferedAutonomous(initialReplay = false) {
|
|
31950
31967
|
const buffer = this.#buffer;
|
|
31951
|
-
if (this.#closed || !buffer || buffer.active || buffer.pending || this.#deferAutonomousTurn() || !this.#resumeNeedsAutonomousTurn(buffer) && !buffer.reachedCorrelationBoundary && buffer.events.at(-1)?.type !== "turn/end") {
|
|
31968
|
+
if (this.#closed || this.#closing || !buffer || buffer.active || buffer.pending || this.#deferAutonomousTurn() || !this.#resumeNeedsAutonomousTurn(buffer) && !buffer.reachedCorrelationBoundary && buffer.events.at(-1)?.type !== "turn/end") {
|
|
31952
31969
|
return;
|
|
31953
31970
|
}
|
|
31954
31971
|
this.#materializeAutonomous(buffer, initialReplay || buffer.initialResume);
|
|
31955
31972
|
}
|
|
31956
31973
|
#materializeAutonomous(buffer, initialReplay) {
|
|
31974
|
+
if (this.#closed || this.#closing)
|
|
31975
|
+
return;
|
|
31957
31976
|
const turnId = hostTurnIdSchema.parse(this.#randomUUID());
|
|
31958
31977
|
this.#emit({
|
|
31959
31978
|
type: "turn.autonomous.started",
|
|
@@ -32222,6 +32241,7 @@ ${question.detail}` : question.question;
|
|
|
32222
32241
|
active.terminal = true;
|
|
32223
32242
|
if (buffer.pending)
|
|
32224
32243
|
buffer.pending.terminal = true;
|
|
32244
|
+
this.#nativeCloseTerminal?.();
|
|
32225
32245
|
const checkpoint = modernCheckpointRef(this.harnessId, this.#sessionId, seq);
|
|
32226
32246
|
this.#emit({
|
|
32227
32247
|
type: "turn.completed",
|
|
@@ -32283,6 +32303,7 @@ ${question.detail}` : question.question;
|
|
|
32283
32303
|
return;
|
|
32284
32304
|
const failure = sanitizedHarnessError(error51);
|
|
32285
32305
|
const acceptedPending = this.#acceptedPending();
|
|
32306
|
+
this.#faultMayHaveNativeWork = Boolean(this.#active && !this.#active.terminal || this.#pendingByRequestId.size > 0 || this.#buffer || this.#commandAdmission || this.#activeCommand);
|
|
32286
32307
|
this.#faulted = failure;
|
|
32287
32308
|
this.#closed = true;
|
|
32288
32309
|
this.#journalLifetime.abort(new Error("DeepSeek Harness Session faulted"));
|
|
@@ -32356,6 +32377,49 @@ ${question.detail}` : question.question;
|
|
|
32356
32377
|
this.#notifyClosed();
|
|
32357
32378
|
}
|
|
32358
32379
|
async #performClose() {
|
|
32380
|
+
this.#closing = true;
|
|
32381
|
+
let stopFailure;
|
|
32382
|
+
const activeAtClose = this.#active;
|
|
32383
|
+
const pendingAtClose = new Set(this.#pendingByRequestId.values());
|
|
32384
|
+
if (this.#buffer?.pending)
|
|
32385
|
+
pendingAtClose.add(this.#buffer.pending);
|
|
32386
|
+
const correlatedPending = activeAtClose && this.#buffer?.active === activeAtClose ? this.#buffer.pending : void 0;
|
|
32387
|
+
const uncorrelatedExecution = [...pendingAtClose].some((pending) => !pending.terminal && pending !== correlatedPending) || !activeAtClose && this.#buffer !== void 0 || this.#commandAdmission !== void 0 || this.#activeCommand !== void 0;
|
|
32388
|
+
if (!this.#closed && (activeAtClose && !activeAtClose.terminal || uncorrelatedExecution)) {
|
|
32389
|
+
let timer;
|
|
32390
|
+
const terminal = new Promise((resolve2) => {
|
|
32391
|
+
this.#nativeCloseTerminal = () => {
|
|
32392
|
+
if (activeAtClose?.terminal)
|
|
32393
|
+
resolve2();
|
|
32394
|
+
};
|
|
32395
|
+
});
|
|
32396
|
+
try {
|
|
32397
|
+
await Promise.race([
|
|
32398
|
+
(async () => {
|
|
32399
|
+
const result = await (activeAtClose?.cancelPromise ?? this.#requestNativeCancel(activeAtClose));
|
|
32400
|
+
if (!result.ok)
|
|
32401
|
+
throw new Error(result.error.message);
|
|
32402
|
+
if (uncorrelatedExecution) {
|
|
32403
|
+
throw new Error("DeepSeek Harness cannot confirm stop before the native Turn is correlated");
|
|
32404
|
+
}
|
|
32405
|
+
await terminal;
|
|
32406
|
+
})(),
|
|
32407
|
+
new Promise((_, reject) => {
|
|
32408
|
+
timer = setTimeout(() => reject(new Error("DeepSeek Harness did not confirm native Turn stop before close")), NATIVE_CLOSE_TIMEOUT_MS);
|
|
32409
|
+
})
|
|
32410
|
+
]);
|
|
32411
|
+
} catch (error51) {
|
|
32412
|
+
stopFailure = error51;
|
|
32413
|
+
} finally {
|
|
32414
|
+
if (timer)
|
|
32415
|
+
clearTimeout(timer);
|
|
32416
|
+
this.#nativeCloseTerminal = void 0;
|
|
32417
|
+
}
|
|
32418
|
+
}
|
|
32419
|
+
if (this.#faulted) {
|
|
32420
|
+
await this.#performFault(this.#faulted, this.#acceptedPending(pendingAtClose));
|
|
32421
|
+
throw stopFailure ?? new Error(this.#faulted.message);
|
|
32422
|
+
}
|
|
32359
32423
|
if (!this.#closed) {
|
|
32360
32424
|
const acceptedPending = this.#acceptedPending();
|
|
32361
32425
|
this.#closed = true;
|
|
@@ -32410,6 +32474,8 @@ ${question.detail}` : question.question;
|
|
|
32410
32474
|
}
|
|
32411
32475
|
await Promise.allSettled([this.#journal.close(), this.#pumpPromise]);
|
|
32412
32476
|
this.#notifyClosed();
|
|
32477
|
+
if (stopFailure)
|
|
32478
|
+
throw stopFailure;
|
|
32413
32479
|
}
|
|
32414
32480
|
#abortOperations() {
|
|
32415
32481
|
for (const controller of this.#operationControllers) {
|
|
@@ -32422,8 +32488,7 @@ ${question.detail}` : question.question;
|
|
|
32422
32488
|
for (const unsubscribe of this.#removeControlSubscriptions.splice(0))
|
|
32423
32489
|
unsubscribe();
|
|
32424
32490
|
}
|
|
32425
|
-
#acceptedPending() {
|
|
32426
|
-
const values = new Set(this.#pendingByRequestId.values());
|
|
32491
|
+
#acceptedPending(values = new Set(this.#pendingByRequestId.values())) {
|
|
32427
32492
|
if (this.#buffer?.pending)
|
|
32428
32493
|
values.add(this.#buffer.pending);
|
|
32429
32494
|
return [...values].filter((pending) => (pending.admitted || pending.admissionObserved || pending.observed) && !pending.terminal);
|
|
@@ -19685,6 +19685,12 @@ function parseHostUsage(value) {
|
|
|
19685
19685
|
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
19686
19686
|
}
|
|
19687
19687
|
}
|
|
19688
|
+
for (const field of ["totalCredits", "contextUsagePercent"]) {
|
|
19689
|
+
const candidate = value[field];
|
|
19690
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
19691
|
+
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
19692
|
+
}
|
|
19693
|
+
}
|
|
19688
19694
|
for (const field of tokenFields) {
|
|
19689
19695
|
const candidate = value[field];
|
|
19690
19696
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
@@ -15524,6 +15524,12 @@ function parseHostUsage(value) {
|
|
|
15524
15524
|
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
15525
15525
|
}
|
|
15526
15526
|
}
|
|
15527
|
+
for (const field of ["totalCredits", "contextUsagePercent"]) {
|
|
15528
|
+
const candidate = value[field];
|
|
15529
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
15530
|
+
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
15531
|
+
}
|
|
15532
|
+
}
|
|
15527
15533
|
for (const field of tokenFields) {
|
|
15528
15534
|
const candidate = value[field];
|
|
15529
15535
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
@@ -20155,12 +20161,14 @@ function classifyStartupError(error51) {
|
|
|
20155
20161
|
}
|
|
20156
20162
|
return new KiroTransportError("unavailable", "Kiro CLI could not start", { cause: error51 });
|
|
20157
20163
|
}
|
|
20164
|
+
var KiroRequestTimeoutError = class extends KiroTransportError {
|
|
20165
|
+
};
|
|
20158
20166
|
function withTimeout(promise2, milliseconds, operation) {
|
|
20159
20167
|
let timeout;
|
|
20160
20168
|
return Promise.race([
|
|
20161
20169
|
promise2,
|
|
20162
20170
|
new Promise((_resolve, reject) => {
|
|
20163
|
-
timeout = setTimeout(() => reject(new
|
|
20171
|
+
timeout = setTimeout(() => reject(new KiroRequestTimeoutError("unavailable", `${operation} timed out`)), milliseconds);
|
|
20164
20172
|
})
|
|
20165
20173
|
]).finally(() => {
|
|
20166
20174
|
if (timeout)
|
|
@@ -20205,6 +20213,7 @@ var KiroAcpTransport = class {
|
|
|
20205
20213
|
#replay = null;
|
|
20206
20214
|
#sessionId = null;
|
|
20207
20215
|
#stderrTail = "";
|
|
20216
|
+
#configUpdates = /* @__PURE__ */ new Set();
|
|
20208
20217
|
constructor(options) {
|
|
20209
20218
|
this.#options = options;
|
|
20210
20219
|
this.#commandTimeoutMs = options.commandTimeoutMs ?? 3e4;
|
|
@@ -20363,17 +20372,38 @@ var KiroAcpTransport = class {
|
|
|
20363
20372
|
};
|
|
20364
20373
|
}
|
|
20365
20374
|
async #setConfigOptionOnSession(connection, sessionId, configId, value) {
|
|
20375
|
+
const confirmation = Promise.withResolvers();
|
|
20376
|
+
const listener = {
|
|
20377
|
+
update: (params) => {
|
|
20378
|
+
if (params.sessionId !== sessionId || params.update.sessionUpdate !== "config_option_update")
|
|
20379
|
+
return;
|
|
20380
|
+
try {
|
|
20381
|
+
confirmation.resolve(confirmedKiroConfig(params.update, configId, value));
|
|
20382
|
+
} catch {
|
|
20383
|
+
}
|
|
20384
|
+
},
|
|
20385
|
+
cancel: () => confirmation.reject(new KiroTransportError("unavailable", "Kiro Session closed during configuration"))
|
|
20386
|
+
};
|
|
20387
|
+
void confirmation.promise.catch(() => void 0);
|
|
20388
|
+
this.#configUpdates.add(listener);
|
|
20366
20389
|
try {
|
|
20367
|
-
|
|
20368
|
-
sessionId,
|
|
20369
|
-
configId
|
|
20370
|
-
|
|
20371
|
-
|
|
20372
|
-
|
|
20390
|
+
return await withTimeout((async () => {
|
|
20391
|
+
const result = await connection.setSessionConfigOption({ sessionId, configId, value });
|
|
20392
|
+
if (configId === "model" && Array.isArray(result.configOptions) && !result.configOptions.some((option) => option.id === "model")) {
|
|
20393
|
+
return confirmation.promise;
|
|
20394
|
+
}
|
|
20395
|
+
return confirmedKiroConfig(result, configId, value);
|
|
20396
|
+
})(), this.#commandTimeoutMs, `Kiro set_config_option (${configId})`);
|
|
20373
20397
|
} catch (error51) {
|
|
20398
|
+
if (error51 instanceof KiroRequestTimeoutError) {
|
|
20399
|
+
this.#fault(error51);
|
|
20400
|
+
await this.close().catch(() => void 0);
|
|
20401
|
+
}
|
|
20374
20402
|
throw new KiroTransportError("unavailable", `Failed to set ${configId} config option`, {
|
|
20375
20403
|
cause: error51
|
|
20376
20404
|
});
|
|
20405
|
+
} finally {
|
|
20406
|
+
this.#configUpdates.delete(listener);
|
|
20377
20407
|
}
|
|
20378
20408
|
}
|
|
20379
20409
|
async #forkSession(params) {
|
|
@@ -20524,6 +20554,8 @@ var KiroAcpTransport = class {
|
|
|
20524
20554
|
return initialize;
|
|
20525
20555
|
}
|
|
20526
20556
|
#handleUpdate(params) {
|
|
20557
|
+
for (const listener of this.#configUpdates)
|
|
20558
|
+
listener.update(params);
|
|
20527
20559
|
const update = params.update;
|
|
20528
20560
|
const meta3 = isRecord4(update) && isRecord4(update._meta) ? update._meta : void 0;
|
|
20529
20561
|
const kiroMeta = meta3 && isRecord4(meta3.kiro) ? meta3.kiro : void 0;
|
|
@@ -20626,6 +20658,9 @@ var KiroAcpTransport = class {
|
|
|
20626
20658
|
return;
|
|
20627
20659
|
this.#closed = true;
|
|
20628
20660
|
this.#closing = true;
|
|
20661
|
+
for (const listener of this.#configUpdates)
|
|
20662
|
+
listener.cancel();
|
|
20663
|
+
this.#configUpdates.clear();
|
|
20629
20664
|
try {
|
|
20630
20665
|
if (this.#child) {
|
|
20631
20666
|
const child = this.#child;
|
|
@@ -22579,7 +22614,7 @@ var KiroSession = class {
|
|
|
22579
22614
|
#currentPermissionModeId;
|
|
22580
22615
|
#thinking;
|
|
22581
22616
|
#modelCatalog;
|
|
22582
|
-
#
|
|
22617
|
+
#pendingInteractions = /* @__PURE__ */ new Map();
|
|
22583
22618
|
#closed = false;
|
|
22584
22619
|
#activeTask = null;
|
|
22585
22620
|
#stopTurn = null;
|
|
@@ -22825,48 +22860,42 @@ var KiroSession = class {
|
|
|
22825
22860
|
const question = projectKiroRequirementQuestion(interactionId, turnId, request);
|
|
22826
22861
|
if (question) {
|
|
22827
22862
|
return new Promise((resolve) => {
|
|
22828
|
-
this.#
|
|
22863
|
+
this.#pendingInteractions.set(question.interaction.interactionId, {
|
|
22829
22864
|
type: "question",
|
|
22830
22865
|
id: question.interaction.interactionId,
|
|
22831
22866
|
interaction: question.interaction,
|
|
22832
22867
|
resolve: (response) => resolve(question.resolve(response))
|
|
22833
|
-
};
|
|
22868
|
+
});
|
|
22834
22869
|
this.#channel.emit({ kind: "interaction", interaction: question.interaction });
|
|
22835
22870
|
});
|
|
22836
22871
|
}
|
|
22837
22872
|
const projected = projectKiroPermission(interactionId, turnId, request);
|
|
22838
|
-
this.#channel.emit({
|
|
22839
|
-
kind: "interaction",
|
|
22840
|
-
interaction: projected.interaction
|
|
22841
|
-
});
|
|
22842
22873
|
return new Promise((resolve) => {
|
|
22843
|
-
this.#
|
|
22874
|
+
this.#pendingInteractions.set(projected.interaction.interactionId, {
|
|
22844
22875
|
type: "approval",
|
|
22845
22876
|
id: projected.interaction.interactionId,
|
|
22846
22877
|
interaction: projected.interaction,
|
|
22847
22878
|
resolve: (actionId, cancelled) => {
|
|
22848
22879
|
resolve(projected.resolve(actionId, cancelled));
|
|
22849
22880
|
}
|
|
22850
|
-
};
|
|
22881
|
+
});
|
|
22882
|
+
this.#channel.emit({ kind: "interaction", interaction: projected.interaction });
|
|
22851
22883
|
});
|
|
22852
22884
|
}, async (params) => {
|
|
22853
22885
|
if (this.#closed || this.#activeTurnId !== turnId)
|
|
22854
22886
|
return { action: "dismissed" };
|
|
22855
22887
|
const interactionId = this.#randomUUID();
|
|
22856
22888
|
const projected = projectKiroUserInput(interactionId, turnId, params);
|
|
22857
|
-
this.#channel.emit({
|
|
22858
|
-
kind: "interaction",
|
|
22859
|
-
interaction: projected.interaction
|
|
22860
|
-
});
|
|
22861
22889
|
return new Promise((resolve) => {
|
|
22862
|
-
this.#
|
|
22890
|
+
this.#pendingInteractions.set(projected.interaction.interactionId, {
|
|
22863
22891
|
type: "question",
|
|
22864
22892
|
id: projected.interaction.interactionId,
|
|
22865
22893
|
interaction: projected.interaction,
|
|
22866
22894
|
resolve: (response) => {
|
|
22867
22895
|
resolve(projected.resolve(response));
|
|
22868
22896
|
}
|
|
22869
|
-
};
|
|
22897
|
+
});
|
|
22898
|
+
this.#channel.emit({ kind: "interaction", interaction: projected.interaction });
|
|
22870
22899
|
});
|
|
22871
22900
|
})
|
|
22872
22901
|
]);
|
|
@@ -22885,23 +22914,7 @@ var KiroSession = class {
|
|
|
22885
22914
|
}
|
|
22886
22915
|
};
|
|
22887
22916
|
} finally {
|
|
22888
|
-
|
|
22889
|
-
const pending = this.#pendingInteraction;
|
|
22890
|
-
this.#pendingInteraction = null;
|
|
22891
|
-
if (pending.type === "approval")
|
|
22892
|
-
pending.resolve("", true);
|
|
22893
|
-
else
|
|
22894
|
-
pending.resolve({ type: "question", cancelled: true, answers: {} });
|
|
22895
|
-
this.#channel.emit({
|
|
22896
|
-
kind: "event",
|
|
22897
|
-
event: {
|
|
22898
|
-
type: "interaction.closed",
|
|
22899
|
-
interactionId: pending.id,
|
|
22900
|
-
turnId,
|
|
22901
|
-
reason: "cancelled"
|
|
22902
|
-
}
|
|
22903
|
-
});
|
|
22904
|
-
}
|
|
22917
|
+
this.#cancelInteractions(turnId);
|
|
22905
22918
|
output.finish(turnOutcome);
|
|
22906
22919
|
const nativeTurnRef = assignedUserMessageId ? nativeTurnRefSchema.parse({
|
|
22907
22920
|
harnessId: this.harnessId,
|
|
@@ -22929,29 +22942,33 @@ var KiroSession = class {
|
|
|
22929
22942
|
async #cancelTurn(command) {
|
|
22930
22943
|
if (this.#activeTurnId !== null && this.#activeTurnId === command.turnId) {
|
|
22931
22944
|
await this.#transport.cancel();
|
|
22932
|
-
if (this.#
|
|
22933
|
-
|
|
22934
|
-
this.#pendingInteraction = null;
|
|
22935
|
-
if (pending.type === "approval") {
|
|
22936
|
-
pending.resolve("", true);
|
|
22937
|
-
} else {
|
|
22938
|
-
pending.resolve({ type: "question", cancelled: true, answers: {} });
|
|
22939
|
-
}
|
|
22940
|
-
this.#channel.emit({
|
|
22941
|
-
kind: "event",
|
|
22942
|
-
event: {
|
|
22943
|
-
type: "interaction.closed",
|
|
22944
|
-
interactionId: pending.id,
|
|
22945
|
-
turnId: command.turnId,
|
|
22946
|
-
reason: "cancelled"
|
|
22947
|
-
}
|
|
22948
|
-
});
|
|
22949
|
-
}
|
|
22945
|
+
if (this.#activeTurnId === command.turnId)
|
|
22946
|
+
this.#cancelInteractions(command.turnId);
|
|
22950
22947
|
}
|
|
22951
22948
|
return { ok: true, value: { cancellationRequested: true } };
|
|
22952
22949
|
}
|
|
22950
|
+
#cancelInteractions(turnId) {
|
|
22951
|
+
const interactions = [...this.#pendingInteractions.values()];
|
|
22952
|
+
this.#pendingInteractions.clear();
|
|
22953
|
+
for (const pending of interactions) {
|
|
22954
|
+
if (pending.type === "approval")
|
|
22955
|
+
pending.resolve("", true);
|
|
22956
|
+
else
|
|
22957
|
+
pending.resolve({ type: "question", cancelled: true, answers: {} });
|
|
22958
|
+
this.#channel.emit({
|
|
22959
|
+
kind: "event",
|
|
22960
|
+
event: {
|
|
22961
|
+
type: "interaction.closed",
|
|
22962
|
+
interactionId: pending.id,
|
|
22963
|
+
turnId,
|
|
22964
|
+
reason: "cancelled"
|
|
22965
|
+
}
|
|
22966
|
+
});
|
|
22967
|
+
}
|
|
22968
|
+
}
|
|
22953
22969
|
async #respondInteraction(command) {
|
|
22954
|
-
|
|
22970
|
+
const pending = this.#pendingInteractions.get(command.interactionId);
|
|
22971
|
+
if (!pending) {
|
|
22955
22972
|
return {
|
|
22956
22973
|
ok: false,
|
|
22957
22974
|
error: {
|
|
@@ -22961,7 +22978,6 @@ var KiroSession = class {
|
|
|
22961
22978
|
}
|
|
22962
22979
|
};
|
|
22963
22980
|
}
|
|
22964
|
-
const pending = this.#pendingInteraction;
|
|
22965
22981
|
if (pending.type === "approval") {
|
|
22966
22982
|
if (command.response.type !== "approval") {
|
|
22967
22983
|
return {
|
|
@@ -22976,7 +22992,7 @@ var KiroSession = class {
|
|
|
22976
22992
|
const error51 = validateHostApprovalResponse(pending.interaction, command.response);
|
|
22977
22993
|
if (error51)
|
|
22978
22994
|
return { ok: false, error: error51 };
|
|
22979
|
-
this.#
|
|
22995
|
+
this.#pendingInteractions.delete(command.interactionId);
|
|
22980
22996
|
pending.resolve(command.response.actionId);
|
|
22981
22997
|
} else {
|
|
22982
22998
|
if (command.response.type !== "question") {
|
|
@@ -22992,7 +23008,7 @@ var KiroSession = class {
|
|
|
22992
23008
|
const error51 = validateHostQuestionResponse(pending.interaction, command.response);
|
|
22993
23009
|
if (error51)
|
|
22994
23010
|
return { ok: false, error: error51 };
|
|
22995
|
-
this.#
|
|
23011
|
+
this.#pendingInteractions.delete(command.interactionId);
|
|
22996
23012
|
pending.resolve(command.response);
|
|
22997
23013
|
}
|
|
22998
23014
|
if (this.#activeTurnId) {
|
|
@@ -16044,6 +16044,12 @@ function parseHostUsage(value) {
|
|
|
16044
16044
|
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
16045
16045
|
}
|
|
16046
16046
|
}
|
|
16047
|
+
for (const field of ["totalCredits", "contextUsagePercent"]) {
|
|
16048
|
+
const candidate = value[field];
|
|
16049
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
16050
|
+
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
16051
|
+
}
|
|
16052
|
+
}
|
|
16047
16053
|
for (const field of tokenFields) {
|
|
16048
16054
|
const candidate = value[field];
|
|
16049
16055
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|