@liberseek/boft-cli-win32-arm64 0.6.3 → 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.
@@ -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 KiroTransportError("unavailable", `${operation} timed out`)), milliseconds);
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
- const result = await withTimeout(connection.setSessionConfigOption({
20368
- sessionId,
20369
- configId,
20370
- value
20371
- }), this.#commandTimeoutMs, `Kiro set_config_option (${configId})`);
20372
- return confirmedKiroConfig(result, configId, value);
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
- #pendingInteraction = null;
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.#pendingInteraction = {
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.#pendingInteraction = {
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.#pendingInteraction = {
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
- if (this.#pendingInteraction) {
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.#pendingInteraction) {
22933
- const pending = this.#pendingInteraction;
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
- if (!this.#pendingInteraction || this.#pendingInteraction.id !== command.interactionId) {
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.#pendingInteraction = null;
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.#pendingInteraction = null;
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)) {