@nick3/copilot-api 1.7.0 → 1.7.1
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/{accounts-manager-BNVadA3o.js → accounts-manager-Ca9IG0Fv.js} +10 -3
- package/dist/accounts-manager-Ca9IG0Fv.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{server-D4_KW4V9.js → server-DT8b_Z5j.js} +15 -4
- package/dist/{server-D4_KW4V9.js.map → server-DT8b_Z5j.js.map} +1 -1
- package/dist/{start-C45MX44a.js → start-Dayo0B2n.js} +3 -3
- package/dist/{start-C45MX44a.js.map → start-Dayo0B2n.js.map} +1 -1
- package/package.json +1 -1
- package/dist/accounts-manager-BNVadA3o.js.map +0 -1
|
@@ -3,7 +3,7 @@ import { _ as DEFAULT_IDENTITY_ENTERPRISE_DOMAIN, a as getAccountClientIdentityB
|
|
|
3
3
|
import { r as ensurePaths, t as PATHS } from "./paths-DGlr310R.js";
|
|
4
4
|
import "./get-copilot-token-COIPGosP.js";
|
|
5
5
|
import { i as getRequestOutboundStore, r as getRedactedHeaderKeys } from "./request-outbound-qyTeXbzy.js";
|
|
6
|
-
import { A as isMessageStartInputTokensFallbackEnabled, C as getModelAliasesInfo, D as getSmallModel, E as getReasoningEffortForModel, F as resolveModelAlias, I as shouldCompactUseSmallModel, M as isResponsesApiContextManagementModel, N as isResponsesApiWebSearchEnabled, O as isAccountAffinityEnabled, P as mergeConfigWithDefaults, S as getModelAliases, T as getProviderConfig, _ as getAnthropicApiKey, a as getClientIpInfo, b as getExtraPromptForModel, c as normalizeChatCompletionsUsage, d as toLocalDateString, f as copilotFetch, g as getAliasTargetSet, h as PROVIDER_TYPE_ANTHROPIC, i as extractResponsesUsageFromStreamEvent, j as isMessagesApiEnabled, k as isForceAgentEnabled, l as normalizeEmbeddingsUsage, m as isDevModeEnabled, n as applySharedSessionAffinityRetention, o as getRequestHistoryStore, p as flushPendingCapture, r as extractResponsesUsageFromResult, s as getStatsStore, t as accountsManager, u as normalizeMessagesUsage, v as getClaudeTokenMultiplier, w as getModelRefreshIntervalMs, x as getLogLevel, y as getConfig } from "./accounts-manager-
|
|
6
|
+
import { A as isMessageStartInputTokensFallbackEnabled, C as getModelAliasesInfo, D as getSmallModel, E as getReasoningEffortForModel, F as resolveModelAlias, I as shouldCompactUseSmallModel, M as isResponsesApiContextManagementModel, N as isResponsesApiWebSearchEnabled, O as isAccountAffinityEnabled, P as mergeConfigWithDefaults, S as getModelAliases, T as getProviderConfig, _ as getAnthropicApiKey, a as getClientIpInfo, b as getExtraPromptForModel, c as normalizeChatCompletionsUsage, d as toLocalDateString, f as copilotFetch, g as getAliasTargetSet, h as PROVIDER_TYPE_ANTHROPIC, i as extractResponsesUsageFromStreamEvent, j as isMessagesApiEnabled, k as isForceAgentEnabled, l as normalizeEmbeddingsUsage, m as isDevModeEnabled, n as applySharedSessionAffinityRetention, o as getRequestHistoryStore, p as flushPendingCapture, r as extractResponsesUsageFromResult, s as getStatsStore, t as accountsManager, u as normalizeMessagesUsage, v as getClaudeTokenMultiplier, w as getModelRefreshIntervalMs, x as getLogLevel, y as getConfig } from "./accounts-manager-Ca9IG0Fv.js";
|
|
7
7
|
import consola from "consola";
|
|
8
8
|
import fs, { readFile } from "node:fs/promises";
|
|
9
9
|
import { randomUUID, timingSafeEqual } from "node:crypto";
|
|
@@ -6313,10 +6313,14 @@ async function streamChatCompletionsAndLog(params) {
|
|
|
6313
6313
|
});
|
|
6314
6314
|
}
|
|
6315
6315
|
}
|
|
6316
|
+
function invalidateAffinityOnOwnershipMismatch(ownershipMismatch, instr) {
|
|
6317
|
+
if (ownershipMismatch && instr.affinityHit && instr.affinityCacheKey) accountsManager.invalidateAffinity(instr.affinityCacheKey);
|
|
6318
|
+
}
|
|
6316
6319
|
async function handleResponsesCreateError(params) {
|
|
6317
6320
|
const { error, instr, stream } = params;
|
|
6318
6321
|
const finishedAtMs = Date.now();
|
|
6319
6322
|
const details = await extractErrorObservability(error);
|
|
6323
|
+
invalidateAffinityOnOwnershipMismatch(details.ownershipMismatch, instr);
|
|
6320
6324
|
if (shouldMarkAccountFailed(details)) accountsManager.markAccountFailed(instr.account.id, "Unauthorized (401)");
|
|
6321
6325
|
const { premiumRemainingAfter, premiumUnlimitedAfter, premiumRemainingDiff } = await finalizeQuotaAndGetPremiumSnapshot(instr);
|
|
6322
6326
|
insertRequestLog$1(instr, {
|
|
@@ -6457,6 +6461,7 @@ async function streamResponsesAndLog$1(params) {
|
|
|
6457
6461
|
errorMessage = details.errorMessage;
|
|
6458
6462
|
upstreamErrorMessageRaw = details.upstreamErrorMessageRaw;
|
|
6459
6463
|
logger$5.warn("Streaming error:", error);
|
|
6464
|
+
invalidateAffinityOnOwnershipMismatch(details.ownershipMismatch, instr);
|
|
6460
6465
|
if (shouldMarkAccountFailed(details)) accountsManager.markAccountFailed(instr.account.id, "Unauthorized (401)");
|
|
6461
6466
|
await writeAnthropicStreamError(stream, getUserVisibleErrorMessage(details));
|
|
6462
6467
|
} finally {
|
|
@@ -7080,8 +7085,9 @@ const handleResponses = async (c) => {
|
|
|
7080
7085
|
premiumUnlimitedBefore
|
|
7081
7086
|
});
|
|
7082
7087
|
};
|
|
7083
|
-
async function observeRequestError(accountId, error) {
|
|
7088
|
+
async function observeRequestError(accountId, error, affinity) {
|
|
7084
7089
|
const details = await extractErrorObservability(error);
|
|
7090
|
+
if (details.ownershipMismatch && affinity?.affinityHit && affinity.affinityCacheKey) accountsManager.invalidateAffinity(affinity.affinityCacheKey);
|
|
7085
7091
|
if (shouldMarkAccountFailed(details)) accountsManager.markAccountFailed(accountId, "Unauthorized (401)");
|
|
7086
7092
|
return {
|
|
7087
7093
|
httpStatus: details.httpStatus,
|
|
@@ -7235,6 +7241,7 @@ async function handleUpstreamCreateError(params) {
|
|
|
7235
7241
|
const { account, reservation, selectedModel, endpoint, costUnits } = selection;
|
|
7236
7242
|
const finishedAtMs = Date.now();
|
|
7237
7243
|
const details = await extractErrorObservability(error);
|
|
7244
|
+
if (details.ownershipMismatch && request.affinityHit && request.affinityCacheKey) accountsManager.invalidateAffinity(request.affinityCacheKey);
|
|
7238
7245
|
if (shouldMarkAccountFailed(details)) accountsManager.markAccountFailed(account.id, "Unauthorized (401)");
|
|
7239
7246
|
await accountsManager.finalizeQuota(account, reservation);
|
|
7240
7247
|
const premiumRemainingAfter = account.premiumRemaining;
|
|
@@ -7345,6 +7352,7 @@ async function streamResponsesAndLog(params) {
|
|
|
7345
7352
|
errorMessage = details.errorMessage;
|
|
7346
7353
|
upstreamErrorMessageRaw = details.upstreamErrorMessageRaw;
|
|
7347
7354
|
logger$1.warn("Responses streaming error:", error);
|
|
7355
|
+
if (details.ownershipMismatch && request.affinityHit && request.affinityCacheKey) accountsManager.invalidateAffinity(request.affinityCacheKey);
|
|
7348
7356
|
if (shouldMarkAccountFailed(details)) accountsManager.markAccountFailed(account.id, "Unauthorized (401)");
|
|
7349
7357
|
await writeResponsesStreamError(stream, getUserVisibleErrorMessage(details));
|
|
7350
7358
|
} finally {
|
|
@@ -7403,7 +7411,10 @@ async function handleNonStreamingResponses(params) {
|
|
|
7403
7411
|
return c.json(result);
|
|
7404
7412
|
} catch (error) {
|
|
7405
7413
|
finishedAtMs = Date.now();
|
|
7406
|
-
errorState = await observeRequestError(account.id, error
|
|
7414
|
+
errorState = await observeRequestError(account.id, error, {
|
|
7415
|
+
affinityHit: request.affinityHit,
|
|
7416
|
+
affinityCacheKey: request.affinityCacheKey
|
|
7417
|
+
});
|
|
7407
7418
|
throw error;
|
|
7408
7419
|
} finally {
|
|
7409
7420
|
const finishedAtMsFinal = finishedAtMs ?? Date.now();
|
|
@@ -7541,4 +7552,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
|
|
|
7541
7552
|
|
|
7542
7553
|
//#endregion
|
|
7543
7554
|
export { server };
|
|
7544
|
-
//# sourceMappingURL=server-
|
|
7555
|
+
//# sourceMappingURL=server-DT8b_Z5j.js.map
|