@ycodium-ai/agent-grok 0.2.3024 → 0.2.3034

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.
Files changed (2) hide show
  1. package/dist/index.js +96 -42
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -25375,6 +25375,62 @@ function findAcpEffortConfig(configOptions) {
25375
25375
  };
25376
25376
  }
25377
25377
 
25378
+ // ../../packages/ycodium-acp-executor/src/apply-effort.ts
25379
+ var applyRequestedEffort = async (input2) => {
25380
+ const requested = input2.requestedEffort?.trim();
25381
+ if (!requested) return;
25382
+ const effort = findAcpEffortConfig(input2.configOptions);
25383
+ if (effort === void 0) return;
25384
+ const matched = effort.choices.find((choice) => choice.value === requested);
25385
+ if (matched === void 0) {
25386
+ input2.log?.info("requested effort is not in the agent catalog; keeping its own", {
25387
+ requestedEffort: requested,
25388
+ advertised: effort.choices.map((choice) => choice.value)
25389
+ });
25390
+ return;
25391
+ }
25392
+ if (matched.isDefault === true) return;
25393
+ if (!input2.isLive(input2.expectedGeneration)) return;
25394
+ try {
25395
+ await input2.connection.request("session/set_config_option", {
25396
+ sessionId: input2.acpSessionId,
25397
+ configId: effort.configId,
25398
+ value: requested
25399
+ });
25400
+ } catch (error62) {
25401
+ input2.log?.info("setting the effort level failed; the session keeps its own", {
25402
+ requestedEffort: requested,
25403
+ configId: effort.configId,
25404
+ error: error62 instanceof Error ? error62.message : String(error62)
25405
+ });
25406
+ }
25407
+ };
25408
+
25409
+ // ../../packages/ycodium-acp-executor/src/failureCategory.ts
25410
+ var ACP_FAILURE_CATEGORIES = [
25411
+ "quota",
25412
+ "rate-limit",
25413
+ "context-limit",
25414
+ "auth",
25415
+ "model-unavailable",
25416
+ "transport",
25417
+ "unknown"
25418
+ ];
25419
+ var isAcpFailureCategory = (value) => ACP_FAILURE_CATEGORIES.some((category) => category === value);
25420
+ var readAcpFailureCategory = (error62) => {
25421
+ if (typeof error62 !== "object" || error62 === null) return void 0;
25422
+ const value = error62.failureCategory;
25423
+ return isAcpFailureCategory(value) ? value : void 0;
25424
+ };
25425
+ var withFailureCategory = (error62, category) => category === void 0 ? error62 : Object.assign(error62, { failureCategory: category });
25426
+ var failureCategoryField = (category) => category === void 0 ? {} : { failureCategory: category };
25427
+ var acpTransportIfEstablished = (sessionEstablished, disposed) => sessionEstablished && !disposed ? "transport" : void 0;
25428
+ var acpPromptFailureCategory = (error62, input2) => {
25429
+ const signaled = readAcpFailureCategory(error62);
25430
+ if (signaled !== void 0) return signaled;
25431
+ return error62 instanceof AcpConnectionClosedError ? acpTransportIfEstablished(input2.sessionEstablished, input2.disposed) : void 0;
25432
+ };
25433
+
25378
25434
  // ../../packages/ycodium-acp-executor/src/runtime-mode.ts
25379
25435
  function isRecord5(value) {
25380
25436
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -25424,7 +25480,7 @@ var ACP_CONFIG_CATEGORY_HANDLING = {
25424
25480
  },
25425
25481
  thought_level: {
25426
25482
  consumed: true,
25427
- via: "config-options.ts:findAcpEffortConfig \u2192 executor.ts:applyRequestedEffort"
25483
+ via: "config-options.ts:findAcpEffortConfig \u2192 apply-effort.ts:applyRequestedEffort"
25428
25484
  },
25429
25485
  model_option: {
25430
25486
  consumed: true,
@@ -25912,11 +25968,16 @@ function createAcpExecutor(options) {
25912
25968
  payload: { answers }
25913
25969
  });
25914
25970
  };
25915
- const abortPendingSettlement = (reason) => {
25971
+ const abortPendingSettlement = (reason, failureCategory) => {
25916
25972
  const waiting = pendingSettlement;
25917
25973
  if (waiting === void 0) return;
25918
25974
  pendingSettlement = void 0;
25919
- waiting.settle({ error: new AcpExecutorRequestError("session/prompt", reason) });
25975
+ waiting.settle({
25976
+ error: withFailureCategory(
25977
+ new AcpExecutorRequestError("session/prompt", reason),
25978
+ failureCategory
25979
+ )
25980
+ });
25920
25981
  };
25921
25982
  const settleAllUserInputs = () => {
25922
25983
  for (const pending of pendingUserInputs.values()) {
@@ -25940,9 +26001,12 @@ function createAcpExecutor(options) {
25940
26001
  rememberSettledPromptKey(waiting.promptKey);
25941
26002
  if (signal.outcome === "error") {
25942
26003
  waiting.settle({
25943
- error: new AcpExecutorRequestError(
25944
- "session/prompt",
25945
- signal.detail ?? "prompt failed without an error detail"
26004
+ error: withFailureCategory(
26005
+ new AcpExecutorRequestError(
26006
+ "session/prompt",
26007
+ signal.detail ?? "prompt failed without an error detail"
26008
+ ),
26009
+ signal.failureCategory
25946
26010
  )
25947
26011
  });
25948
26012
  } else {
@@ -26097,7 +26161,10 @@ function createAcpExecutor(options) {
26097
26161
  }
26098
26162
  settleAllApprovals("cancel");
26099
26163
  settleAllUserInputs();
26100
- abortPendingSettlement("connection closed");
26164
+ abortPendingSettlement(
26165
+ "connection closed",
26166
+ acpTransportIfEstablished(startResult !== void 0, disposed)
26167
+ );
26101
26168
  promptWaiters.splice(0).forEach((wake) => wake());
26102
26169
  },
26103
26170
  () => {
@@ -26152,35 +26219,6 @@ function createAcpExecutor(options) {
26152
26219
  }
26153
26220
  return { ...input2.state, currentModelId: value, configOptions };
26154
26221
  };
26155
- const applyRequestedEffort = async (input2) => {
26156
- const requested = input2.requestedEffort?.trim();
26157
- if (!requested) return;
26158
- const effort = findAcpEffortConfig(input2.configOptions);
26159
- if (effort === void 0) return;
26160
- const matched = effort.choices.find((choice) => choice.value === requested);
26161
- if (matched === void 0) {
26162
- options.log?.info("requested effort is not in the agent catalog; keeping its own", {
26163
- requestedEffort: requested,
26164
- advertised: effort.choices.map((choice) => choice.value)
26165
- });
26166
- return;
26167
- }
26168
- if (matched.isDefault === true) return;
26169
- if (!isLive(input2.expectedGeneration)) return;
26170
- try {
26171
- await connection.request("session/set_config_option", {
26172
- sessionId: input2.acpSessionId,
26173
- configId: effort.configId,
26174
- value: requested
26175
- });
26176
- } catch (error62) {
26177
- options.log?.info("setting the effort level failed; the session keeps its own", {
26178
- requestedEffort: requested,
26179
- configId: effort.configId,
26180
- error: error62 instanceof Error ? error62.message : String(error62)
26181
- });
26182
- }
26183
- };
26184
26222
  const startOnce = async (expectedGeneration) => {
26185
26223
  const initializePayload = acpInitializePayload(options.clientInfo, options.clientCapabilities);
26186
26224
  const initialized = await connection.request(
@@ -26255,6 +26293,9 @@ function createAcpExecutor(options) {
26255
26293
  expectedGeneration
26256
26294
  });
26257
26295
  await applyRequestedEffort({
26296
+ connection,
26297
+ log: options.log,
26298
+ isLive,
26258
26299
  configOptions: nextModelSelectionState.configOptions,
26259
26300
  acpSessionId: nextSessionId,
26260
26301
  requestedEffort: options.requestedEffort,
@@ -26377,7 +26418,8 @@ function createAcpExecutor(options) {
26377
26418
  payload: {
26378
26419
  state: input2.state,
26379
26420
  stopReason: input2.stopReason,
26380
- ...input2.errorMessage === void 0 ? {} : { errorMessage: input2.errorMessage }
26421
+ ...input2.errorMessage === void 0 ? {} : { errorMessage: input2.errorMessage },
26422
+ ...input2.state === "failed" ? failureCategoryField(input2.failureCategory) : {}
26381
26423
  }
26382
26424
  });
26383
26425
  interruptedTurnIds.delete(input2.turnId);
@@ -26474,15 +26516,25 @@ function createAcpExecutor(options) {
26474
26516
  if (disposed) {
26475
26517
  throw new AcpExecutorDisposedError();
26476
26518
  }
26519
+ const failureCategory = acpPromptFailureCategory(error62, {
26520
+ sessionEstablished: startResult !== void 0,
26521
+ disposed
26522
+ });
26477
26523
  if (written && input2.onDispatched !== void 0 && !interruptedTurnIds.has(turnId)) {
26478
26524
  const errorMessage = error62 instanceof Error && error62.message.trim() || "ACP prompt failed";
26479
- if (settle2({ turnId, stopReason: "error", state: "failed", errorMessage }))
26525
+ if (settle2({
26526
+ turnId,
26527
+ stopReason: "error",
26528
+ state: "failed",
26529
+ errorMessage,
26530
+ ...failureCategory === void 0 ? {} : { failureCategory }
26531
+ }))
26480
26532
  options.log?.warn?.("turn failed after dispatch", {
26481
26533
  threadId: options.threadId,
26482
26534
  failure: errorMessage
26483
26535
  });
26484
26536
  }
26485
- throw error62;
26537
+ throw error62 instanceof Error ? withFailureCategory(error62, failureCategory) : error62;
26486
26538
  }
26487
26539
  await connection.awaitInboundIdle();
26488
26540
  if (options.beforeApplyResult) {
@@ -27910,14 +27962,16 @@ var grokPromptSettlement = {
27910
27962
  const sessionId = params["sessionId"];
27911
27963
  if (typeof sessionId !== "string") return void 0;
27912
27964
  const stopReason = trimmed2(params["stopReason"]);
27913
- const failed = stopReason === "error" || stopReason === "rate_limit";
27914
- const detail = stopReason === "rate_limit" ? GROK_RATE_LIMIT_MESSAGE : grokAgentResultMessage(params["agentResult"]);
27965
+ const rateLimited = stopReason === "rate_limit";
27966
+ const failed = stopReason === "error" || rateLimited;
27967
+ const detail = rateLimited ? GROK_RATE_LIMIT_MESSAGE : grokAgentResultMessage(params["agentResult"]);
27915
27968
  return {
27916
27969
  sessionId,
27917
27970
  ...typeof params["promptId"] === "string" ? { promptKey: params["promptId"] } : {},
27918
27971
  outcome: failed ? "error" : "completed",
27919
27972
  ...stopReason === void 0 ? {} : { stopReason },
27920
- ...detail === void 0 ? {} : { detail }
27973
+ ...detail === void 0 ? {} : { detail },
27974
+ ...rateLimited ? { failureCategory: "rate-limit" } : {}
27921
27975
  };
27922
27976
  }
27923
27977
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-grok",
3
- "version": "0.2.3024",
3
+ "version": "0.2.3034",
4
4
  "description": "Grok executor: grok CLI over Agent Client Protocol stdio.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -21,9 +21,9 @@
21
21
  "@types/node": "24.12.4",
22
22
  "esbuild": "0.28.1",
23
23
  "vite-plus": "0.2.2",
24
- "@ycodium-ai/plugin-api": "0.2.3024",
25
- "ycodium-acp-executor": "0.2.0",
26
- "ycodium-executor-testing": "0.0.0"
24
+ "ycodium-acp-executor": "0.2.3034",
25
+ "ycodium-executor-testing": "0.0.0",
26
+ "@ycodium-ai/plugin-api": "0.2.3034"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",