alink-cli 0.12.2 → 0.12.3
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 +44 -0
- package/dist/bin.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -58636,6 +58636,28 @@ function isInterruptedResult(result) {
|
|
|
58636
58636
|
if (errors.includes("interrupt")) return true;
|
|
58637
58637
|
return result.subtype === "error_during_execution" && result.is_error === false && (errors.includes("request was aborted") || errors.includes("interrupted by user") || errors.includes("aborted"));
|
|
58638
58638
|
}
|
|
58639
|
+
const CLAUDE_USAGE_LIMIT_WINDOWS = {
|
|
58640
|
+
five_hour: "5-hour",
|
|
58641
|
+
seven_day: "7-day",
|
|
58642
|
+
seven_day_opus: "7-day Opus",
|
|
58643
|
+
seven_day_sonnet: "7-day Sonnet",
|
|
58644
|
+
overage: "overage"
|
|
58645
|
+
};
|
|
58646
|
+
const CLAUDE_USAGE_LIMIT_MAX_WAIT_MS = 720 * 60 * 60 * 1e3;
|
|
58647
|
+
function describeClaudeUsageLimit(info, nowMs) {
|
|
58648
|
+
const label = info.rateLimitType ? CLAUDE_USAGE_LIMIT_WINDOWS[info.rateLimitType] : void 0;
|
|
58649
|
+
const resetsAtMs = info.resetsAt === void 0 ? void 0 : info.resetsAt * 1e3;
|
|
58650
|
+
const waitMs = resetsAtMs === void 0 ? void 0 : resetsAtMs - nowMs;
|
|
58651
|
+
const wait = waitMs !== void 0 && Number.isFinite(waitMs) && waitMs > 0 && waitMs <= CLAUDE_USAGE_LIMIT_MAX_WAIT_MS ? formatClaudeUsageLimitWait(waitMs) : void 0;
|
|
58652
|
+
return `Claude usage limit reached. This turn is paused until the ${label ? `${label} ` : ""}limit resets${wait ? ` in ${wait}` : ""}.`;
|
|
58653
|
+
}
|
|
58654
|
+
function formatClaudeUsageLimitWait(waitMs) {
|
|
58655
|
+
const totalMinutes = Math.ceil(waitMs / 6e4);
|
|
58656
|
+
const hours = Math.floor(totalMinutes / 60);
|
|
58657
|
+
const minutes = totalMinutes % 60;
|
|
58658
|
+
if (hours === 0) return `${totalMinutes}m`;
|
|
58659
|
+
return minutes === 0 ? `${hours}h` : `${hours}h ${minutes}m`;
|
|
58660
|
+
}
|
|
58639
58661
|
function asRuntimeItemId$1(value) {
|
|
58640
58662
|
return RuntimeItemId.make(value);
|
|
58641
58663
|
}
|
|
@@ -60533,6 +60555,19 @@ const makeClaudeAdapter = fn("makeClaudeAdapter")(function* (claudeSettings, opt
|
|
|
60533
60555
|
type: "account.rate-limits.updated",
|
|
60534
60556
|
payload: { rateLimits: message }
|
|
60535
60557
|
});
|
|
60558
|
+
const rateLimitInfo = message.rate_limit_info;
|
|
60559
|
+
if (rateLimitInfo !== void 0 && rateLimitInfo.status === "rejected" && rateLimitInfo.overageStatus !== "allowed" && rateLimitInfo.isUsingOverage !== true && rateLimitInfo.overageInUse !== true && context.turnState !== void 0) {
|
|
60560
|
+
const turnId = context.turnState.turnId;
|
|
60561
|
+
if (context.announcedUsageLimits?.turnId !== turnId) context.announcedUsageLimits = {
|
|
60562
|
+
turnId,
|
|
60563
|
+
keys: /* @__PURE__ */ new Set()
|
|
60564
|
+
};
|
|
60565
|
+
const limitKey = `${rateLimitInfo.rateLimitType ?? "unknown"}:${rateLimitInfo.resetsAt ?? "unknown"}`;
|
|
60566
|
+
if (!context.announcedUsageLimits.keys.has(limitKey)) {
|
|
60567
|
+
context.announcedUsageLimits.keys.add(limitKey);
|
|
60568
|
+
yield* emitRuntimeWarning(context, describeClaudeUsageLimit(rateLimitInfo, Date.parse(stamp.createdAt)), rateLimitInfo);
|
|
60569
|
+
}
|
|
60570
|
+
}
|
|
60536
60571
|
return;
|
|
60537
60572
|
}
|
|
60538
60573
|
});
|
|
@@ -61017,6 +61052,7 @@ const makeClaudeAdapter = fn("makeClaudeAdapter")(function* (claudeSettings, opt
|
|
|
61017
61052
|
lastKnownTotalProcessedTokens: void 0,
|
|
61018
61053
|
lastAssistantUuid: resumeState?.resumeSessionAt,
|
|
61019
61054
|
lastThreadStartedId: void 0,
|
|
61055
|
+
announcedUsageLimits: void 0,
|
|
61020
61056
|
stopped: false
|
|
61021
61057
|
};
|
|
61022
61058
|
yield* set$2(contextRef, context$1);
|
|
@@ -82283,6 +82319,14 @@ function mapToRuntimeEvents(event, canonicalThreadId) {
|
|
|
82283
82319
|
const payload = readPayload(V2ErrorNotification, event.payload);
|
|
82284
82320
|
const message = payload?.error.message ?? event.message ?? "Provider runtime error";
|
|
82285
82321
|
const willRetry = payload?.willRetry === true;
|
|
82322
|
+
if (payload?.error.codexErrorInfo === "usageLimitExceeded") return [{
|
|
82323
|
+
type: "runtime.warning",
|
|
82324
|
+
...runtimeEventBase(event, canonicalThreadId),
|
|
82325
|
+
payload: {
|
|
82326
|
+
message,
|
|
82327
|
+
...event.payload !== void 0 ? { detail: event.payload } : {}
|
|
82328
|
+
}
|
|
82329
|
+
}];
|
|
82286
82330
|
return [{
|
|
82287
82331
|
type: willRetry ? "runtime.warning" : "runtime.error",
|
|
82288
82332
|
...runtimeEventBase(event, canonicalThreadId),
|