alink-cli 0.12.2 → 0.12.4

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/bin.mjs CHANGED
@@ -20689,6 +20689,7 @@ const DEFAULT_CLIENT_LANGUAGE = "system";
20689
20689
  const FontFamilyPreference = String$1.check(isMaxLength(200));
20690
20690
  const DEFAULT_CLIENT_SETTINGS = decodeSync(Struct({
20691
20691
  autoOpenPlanSidebar: Boolean$1.pipe(withDecodingDefault(succeed$1(false))),
20692
+ threadCompletionNotifications: Boolean$1.pipe(withDecodingDefault(succeed$1(false))),
20692
20693
  language: ClientLanguage.pipe(withDecodingDefault(succeed$1(DEFAULT_CLIENT_LANGUAGE))),
20693
20694
  confirmThreadArchive: Boolean$1.pipe(withDecodingDefault(succeed$1(false))),
20694
20695
  confirmThreadDelete: Boolean$1.pipe(withDecodingDefault(succeed$1(true))),
@@ -21006,6 +21007,7 @@ const ServerSettingsPatch = Struct({
21006
21007
  });
21007
21008
  Struct({
21008
21009
  autoOpenPlanSidebar: optionalKey(Boolean$1),
21010
+ threadCompletionNotifications: optionalKey(Boolean$1),
21009
21011
  language: optionalKey(ClientLanguage),
21010
21012
  confirmThreadArchive: optionalKey(Boolean$1),
21011
21013
  confirmThreadDelete: optionalKey(Boolean$1),
@@ -50409,13 +50411,13 @@ const makeProviderMaintenanceCommandCoordinator = fn("makeProviderMaintenanceCom
50409
50411
  return [lock, next];
50410
50412
  });
50411
50413
  });
50412
- const withCommandLock = ({ targetKey, lockKey, onQueued, run }) => gen(function* () {
50414
+ const withCommandLock = ({ targetKey, lockKey, onQueued, onInterrupted, run }) => gen(function* () {
50413
50415
  if (!(yield* acquireTarget(targetKey))) return yield* fail(input.makeAlreadyRunningError(targetKey));
50414
50416
  return yield* gen(function* () {
50415
50417
  const lock = yield* getLock(lockKey);
50416
50418
  if (onQueued) yield* onQueued;
50417
50419
  return yield* lock.withPermits(1)(run);
50418
- }).pipe(ensuring(releaseTarget(targetKey)));
50420
+ }).pipe(onInterrupt(() => onInterrupted ?? void_$1), ensuring(releaseTarget(targetKey)));
50419
50421
  });
50420
50422
  return { withCommandLock };
50421
50423
  });
@@ -50889,6 +50891,15 @@ const layer$14 = effect(ProviderMaintenanceRunner, fn("ProviderMaintenanceRunner
50889
50891
  action: "update",
50890
50892
  state
50891
50893
  });
50894
+ const startedAtRef = yield* make$65(null);
50895
+ const recordInterruptedUpdate = gen(function* () {
50896
+ yield* setUpdateState(makeUpdateState({
50897
+ status: "failed",
50898
+ startedAt: yield* get$3(startedAtRef),
50899
+ finishedAt: yield* nowIso$3,
50900
+ message: "Provider update was interrupted. Try updating again."
50901
+ }));
50902
+ });
50892
50903
  const setQueuedState = setUpdateState(makeUpdateState({
50893
50904
  status: "queued",
50894
50905
  startedAt: null,
@@ -50897,7 +50908,6 @@ const layer$14 = effect(ProviderMaintenanceRunner, fn("ProviderMaintenanceRunner
50897
50908
  })).pipe(asVoid);
50898
50909
  const runProviderUpdate = fn("ProviderMaintenanceRunner.runProviderUpdate")(function* () {
50899
50910
  const finish = (state) => setUpdateState(state).pipe(map$4((providers) => ({ providers })));
50900
- const startedAtRef = yield* make$65(null);
50901
50911
  const runCommandAndVerify = fn("ProviderMaintenanceRunner.runCommandAndVerify")(function* () {
50902
50912
  const startedAt = yield* nowIso$3;
50903
50913
  yield* set$2(startedAtRef, startedAt);
@@ -50944,6 +50954,7 @@ const layer$14 = effect(ProviderMaintenanceRunner, fn("ProviderMaintenanceRunner
50944
50954
  targetKey,
50945
50955
  lockKey: update.lockKey,
50946
50956
  onQueued: setQueuedState,
50957
+ onInterrupted: recordInterruptedUpdate,
50947
50958
  run: runProviderUpdate()
50948
50959
  }).pipe(mapError((error) => isServerProviderUpdateError(error) ? new ServerProviderUpdateError({
50949
50960
  provider,
@@ -58636,6 +58647,28 @@ function isInterruptedResult(result) {
58636
58647
  if (errors.includes("interrupt")) return true;
58637
58648
  return result.subtype === "error_during_execution" && result.is_error === false && (errors.includes("request was aborted") || errors.includes("interrupted by user") || errors.includes("aborted"));
58638
58649
  }
58650
+ const CLAUDE_USAGE_LIMIT_WINDOWS = {
58651
+ five_hour: "5-hour",
58652
+ seven_day: "7-day",
58653
+ seven_day_opus: "7-day Opus",
58654
+ seven_day_sonnet: "7-day Sonnet",
58655
+ overage: "overage"
58656
+ };
58657
+ const CLAUDE_USAGE_LIMIT_MAX_WAIT_MS = 720 * 60 * 60 * 1e3;
58658
+ function describeClaudeUsageLimit(info, nowMs) {
58659
+ const label = info.rateLimitType ? CLAUDE_USAGE_LIMIT_WINDOWS[info.rateLimitType] : void 0;
58660
+ const resetsAtMs = info.resetsAt === void 0 ? void 0 : info.resetsAt * 1e3;
58661
+ const waitMs = resetsAtMs === void 0 ? void 0 : resetsAtMs - nowMs;
58662
+ const wait = waitMs !== void 0 && Number.isFinite(waitMs) && waitMs > 0 && waitMs <= CLAUDE_USAGE_LIMIT_MAX_WAIT_MS ? formatClaudeUsageLimitWait(waitMs) : void 0;
58663
+ return `Claude usage limit reached. This turn is paused until the ${label ? `${label} ` : ""}limit resets${wait ? ` in ${wait}` : ""}.`;
58664
+ }
58665
+ function formatClaudeUsageLimitWait(waitMs) {
58666
+ const totalMinutes = Math.ceil(waitMs / 6e4);
58667
+ const hours = Math.floor(totalMinutes / 60);
58668
+ const minutes = totalMinutes % 60;
58669
+ if (hours === 0) return `${totalMinutes}m`;
58670
+ return minutes === 0 ? `${hours}h` : `${hours}h ${minutes}m`;
58671
+ }
58639
58672
  function asRuntimeItemId$1(value) {
58640
58673
  return RuntimeItemId.make(value);
58641
58674
  }
@@ -60533,6 +60566,19 @@ const makeClaudeAdapter = fn("makeClaudeAdapter")(function* (claudeSettings, opt
60533
60566
  type: "account.rate-limits.updated",
60534
60567
  payload: { rateLimits: message }
60535
60568
  });
60569
+ const rateLimitInfo = message.rate_limit_info;
60570
+ if (rateLimitInfo !== void 0 && rateLimitInfo.status === "rejected" && rateLimitInfo.overageStatus !== "allowed" && rateLimitInfo.isUsingOverage !== true && rateLimitInfo.overageInUse !== true && context.turnState !== void 0) {
60571
+ const turnId = context.turnState.turnId;
60572
+ if (context.announcedUsageLimits?.turnId !== turnId) context.announcedUsageLimits = {
60573
+ turnId,
60574
+ keys: /* @__PURE__ */ new Set()
60575
+ };
60576
+ const limitKey = `${rateLimitInfo.rateLimitType ?? "unknown"}:${rateLimitInfo.resetsAt ?? "unknown"}`;
60577
+ if (!context.announcedUsageLimits.keys.has(limitKey)) {
60578
+ context.announcedUsageLimits.keys.add(limitKey);
60579
+ yield* emitRuntimeWarning(context, describeClaudeUsageLimit(rateLimitInfo, Date.parse(stamp.createdAt)), rateLimitInfo);
60580
+ }
60581
+ }
60536
60582
  return;
60537
60583
  }
60538
60584
  });
@@ -61017,6 +61063,7 @@ const makeClaudeAdapter = fn("makeClaudeAdapter")(function* (claudeSettings, opt
61017
61063
  lastKnownTotalProcessedTokens: void 0,
61018
61064
  lastAssistantUuid: resumeState?.resumeSessionAt,
61019
61065
  lastThreadStartedId: void 0,
61066
+ announcedUsageLimits: void 0,
61020
61067
  stopped: false
61021
61068
  };
61022
61069
  yield* set$2(contextRef, context$1);
@@ -82283,6 +82330,14 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
82283
82330
  const payload = readPayload(V2ErrorNotification, event.payload);
82284
82331
  const message = payload?.error.message ?? event.message ?? "Provider runtime error";
82285
82332
  const willRetry = payload?.willRetry === true;
82333
+ if (payload?.error.codexErrorInfo === "usageLimitExceeded") return [{
82334
+ type: "runtime.warning",
82335
+ ...runtimeEventBase(event, canonicalThreadId),
82336
+ payload: {
82337
+ message,
82338
+ ...event.payload !== void 0 ? { detail: event.payload } : {}
82339
+ }
82340
+ }];
82286
82341
  return [{
82287
82342
  type: willRetry ? "runtime.warning" : "runtime.error",
82288
82343
  ...runtimeEventBase(event, canonicalThreadId),