@liberseek/boft-cli-win32-arm64 0.6.4 → 0.6.6

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.
@@ -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)) {
@@ -19998,8 +20004,13 @@ function resolveGrokExecutable(input = {}) {
19998
20004
  throw new GrokExecutableError("Grok CLI is not installed");
19999
20005
  return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path3.resolve(resolution.executable);
20000
20006
  }
20001
- function grokInvocation(command, platform = process.platform) {
20002
- return commandInvocation(command, ["agent", "--no-leader", "stdio"], process.env, platform);
20007
+ function grokInvocation(command, platform = process.platform, modelId) {
20008
+ const arguments_ = ["agent", "--no-leader"];
20009
+ const trimmed = modelId?.trim();
20010
+ if (trimmed)
20011
+ arguments_.push("--model", trimmed);
20012
+ arguments_.push("stdio");
20013
+ return commandInvocation(command, arguments_, process.env, platform);
20003
20014
  }
20004
20015
 
20005
20016
  // dist/grok-fork.js
@@ -21487,7 +21498,9 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
21487
21498
  retryable: false
21488
21499
  }
21489
21500
  } : { status: "succeeded" };
21490
- settleWatchedSubagents(tool.type === "toolExecution" ? tool.toolName : tool.command, tool.type === "toolExecution" ? tool.arguments : void 0, content, rawOutput);
21501
+ if (status === "completed") {
21502
+ settleWatchedSubagents(tool.type === "toolExecution" ? tool.toolName : tool.command, tool.type === "toolExecution" ? tool.arguments : void 0, content, rawOutput);
21503
+ }
21491
21504
  items.push({ item: tool, outcome });
21492
21505
  if (status !== "completed")
21493
21506
  return;
@@ -22698,6 +22711,7 @@ var GrokAcpTransport = class {
22698
22711
  #initialize = null;
22699
22712
  #replay = null;
22700
22713
  #sessionId = null;
22714
+ #startupModelId;
22701
22715
  #stderrTail = "";
22702
22716
  constructor(options) {
22703
22717
  this.#options = {
@@ -22754,6 +22768,8 @@ var GrokAcpTransport = class {
22754
22768
  if (this.#sessionId || this.#closed)
22755
22769
  throw new Error("Grok ACP Transport cannot be opened twice");
22756
22770
  try {
22771
+ if (input.kind === "create")
22772
+ this.#startupModelId = input.modelId;
22757
22773
  const initialize = await this.#ensureInitialized();
22758
22774
  const connection = this.#connection;
22759
22775
  if (!connection)
@@ -22879,7 +22895,7 @@ var GrokAcpTransport = class {
22879
22895
  ...this.#options.command ? { command: this.#options.command } : {},
22880
22896
  environment: this.#options.environment ?? process.env
22881
22897
  });
22882
- const invocation = grokInvocation(executable);
22898
+ const invocation = grokInvocation(executable, process.platform, this.#startupModelId);
22883
22899
  const child = spawn(invocation.command, invocation.arguments, {
22884
22900
  cwd: this.#options.cwd,
22885
22901
  env: { ...process.env, ...this.#options.environment },
@@ -23370,10 +23386,13 @@ function finitePercent(value) {
23370
23386
  return void 0;
23371
23387
  return Math.min(100, Math.max(0, value));
23372
23388
  }
23373
- function nonNegativeNumber(value) {
23374
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0)
23389
+ function nonNegativeCentValue(value) {
23390
+ if (!isRecord14(value))
23375
23391
  return void 0;
23376
- return value;
23392
+ const amount = value.val === void 0 ? 0 : value.val;
23393
+ if (typeof amount !== "number" || !Number.isFinite(amount) || amount < 0)
23394
+ return void 0;
23395
+ return amount;
23377
23396
  }
23378
23397
  function grokHome(environment) {
23379
23398
  return environment.GROK_HOME ?? path9.join(environment.HOME ?? environment.USERPROFILE ?? os4.homedir(), ".grok");
@@ -23404,16 +23423,26 @@ function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()
23404
23423
  return null;
23405
23424
  const config2 = value.config;
23406
23425
  const period = isRecord14(config2.currentPeriod) ? config2.currentPeriod : void 0;
23426
+ const periodType = periodTypeFrom(period?.type);
23407
23427
  const resetsAt = (typeof period?.end === "string" && period.end.length > 0 ? period.end : void 0) ?? (typeof config2.billingPeriodEnd === "string" && config2.billingPeriodEnd.length > 0 ? config2.billingPeriodEnd : void 0);
23408
- const onDemandCap = isRecord14(config2.onDemandCap) ? nonNegativeNumber(config2.onDemandCap.val) : void 0;
23409
- const onDemandUsed = isRecord14(config2.onDemandUsed) ? nonNegativeNumber(config2.onDemandUsed.val) : void 0;
23410
- const usedPercent = finitePercent(config2.creditUsagePercent) ?? (onDemandCap !== void 0 && onDemandCap > 0 && onDemandUsed !== void 0 ? Math.min(100, Math.max(0, onDemandUsed / onDemandCap * 100)) : void 0);
23428
+ let usedPercent = finitePercent(config2.creditUsagePercent);
23429
+ if (config2.creditUsagePercent === void 0) {
23430
+ const monthlyLimit = nonNegativeCentValue(config2.monthlyLimit);
23431
+ const used = nonNegativeCentValue(config2.used);
23432
+ if (config2.monthlyLimit !== void 0 && monthlyLimit === void 0 || config2.used !== void 0 && used === void 0)
23433
+ return null;
23434
+ if (monthlyLimit !== void 0 && monthlyLimit > 0) {
23435
+ usedPercent = Math.min(100, (used ?? 0) / monthlyLimit * 100);
23436
+ } else if (periodType !== "unknown" && resetsAt !== void 0 && Number.isFinite(Date.parse(resetsAt))) {
23437
+ usedPercent = 0;
23438
+ }
23439
+ }
23411
23440
  if (usedPercent === void 0)
23412
23441
  return null;
23413
23442
  const productUsage = productUsageFrom(config2.productUsage);
23414
23443
  return {
23415
23444
  usedPercent,
23416
- periodType: periodTypeFrom(period?.type),
23445
+ periodType,
23417
23446
  fetchedAt,
23418
23447
  ...resetsAt ? { resetsAt } : {},
23419
23448
  ...productUsage ? { productUsage } : {}
@@ -24404,12 +24433,6 @@ var GrokHarnessSession = class {
24404
24433
  emit: (event) => this.#event(event)
24405
24434
  });
24406
24435
  }
24407
- #subagentModelLabel(modelId) {
24408
- const id = modelId ?? this.#state.effectiveModel?.id;
24409
- if (!id)
24410
- return void 0;
24411
- return this.#modelState.catalog.models.find((model) => model.ref.id === id)?.label ?? id;
24412
- }
24413
24436
  #startTool(active, event) {
24414
24437
  this.#completeReasoning(active, { status: "succeeded" });
24415
24438
  this.#completeAgent(active, { status: "succeeded" });
@@ -24418,8 +24441,7 @@ var GrokHarnessSession = class {
24418
24441
  const prompt = grokSubagentPrompt(event.rawInput);
24419
24442
  const role = grokSubagentRole(event.rawInput);
24420
24443
  const nativeSubagentId = grokNativeSubagentId(event.rawInput);
24421
- const model = this.#subagentModelLabel(grokSubagentModel(event.rawInput));
24422
- const reasoningEffort = this.#state.effectiveThinkingOptionId;
24444
+ const model = grokSubagentModel(event.rawInput);
24423
24445
  active.subagents.start(active.command.turnId, {
24424
24446
  callId: event.callId,
24425
24447
  operation,
@@ -24427,7 +24449,6 @@ var GrokHarnessSession = class {
24427
24449
  ...prompt ? { prompt } : {},
24428
24450
  ...role ? { role } : {},
24429
24451
  ...model ? { model } : {},
24430
- ...reasoningEffort ? { reasoningEffort } : {},
24431
24452
  background: grokSubagentBackground(event.rawInput),
24432
24453
  ...nativeSubagentId ? { nativeSubagentId } : {}
24433
24454
  });
@@ -24535,9 +24556,9 @@ var GrokHarnessSession = class {
24535
24556
  }
24536
24557
  } : { status: "succeeded" };
24537
24558
  this.#completeItem(active, tool.item, outcome);
24538
- this.#completeWatchedSubagents(active, tool.item, content, rawOutput);
24539
24559
  if (status !== "completed")
24540
24560
  return;
24561
+ this.#completeWatchedSubagents(active, tool.item, content, rawOutput);
24541
24562
  const changes = projectGrokFileChanges(content, this.#cwd);
24542
24563
  if (!changes)
24543
24564
  return;
@@ -24579,12 +24600,11 @@ var GrokHarnessSession = class {
24579
24600
  }
24580
24601
  }
24581
24602
  #bindSpawnedSubagent(active, event) {
24582
- const model = event.model ? this.#subagentModelLabel(event.model) : void 0;
24583
24603
  active.subagents.bindNativeId(active.command.turnId, {
24584
24604
  nativeSubagentId: event.nativeSubagentId,
24585
24605
  ...event.description ? { description: event.description } : {},
24586
24606
  ...event.role ? { role: event.role } : {},
24587
- ...model ? { model } : {}
24607
+ ...event.model ? { model: event.model } : {}
24588
24608
  });
24589
24609
  }
24590
24610
  #finishNativeSubagent(active, event) {
@@ -24978,7 +24998,11 @@ var GrokAdapter = class {
24978
24998
  kind: "resume",
24979
24999
  sessionId: parsedRef.data.nativeSessionId,
24980
25000
  permissionModeId: requestedPermissionModeId
24981
- } : { kind: "create", permissionModeId: requestedPermissionModeId });
25001
+ } : {
25002
+ kind: "create",
25003
+ permissionModeId: requestedPermissionModeId,
25004
+ ...input.kind === "create" && input.model ? { modelId: input.model.id } : {}
25005
+ });
24982
25006
  }
24983
25007
  if (!opened) {
24984
25008
  await transport.close().catch(() => void 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 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)) {