@cortexkit/pi-anthropic-auth 2.16.0 → 2.16.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/native-commands.js +20 -2
- package/dist/stream.js +7 -1
- package/package.json +2 -2
package/dist/native-commands.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { authorize, buildClaudeQuotaSummary, buildPrimeAccountStatuses, claudeGatewayStatusNotes, DEFAULT_KILLSWITCH_THRESHOLDS, exchange, executeCacheKeepCommand, executePrimeCommand, formatEnrollmentStatus, formatNativeAccountState, formatOAuthAccountTier, getCache1hPersistentMode, getCacheKeepWindow, getMaxSameAccountWait, getPersistedLogLevel, getRoutingMode, isCache1hPersistentlyEnabled, isCacheKeepAlways, isCacheKeepHybridActive, isCacheKeepPersistentlyEnabled, isDumpPersistentlyEnabled, isFastModePersistentlyEnabled, isKillswitchEnabled, isPrimePersistentlyEnabled, isVaultHosted, nativeAccountCanServe, setDumpEnabled, VAULT_HOST_CONNECT_REFUSAL, VAULT_HOST_STATUS, } from '@cortexkit/anthropic-auth-core';
|
|
2
|
+
import { authorize, buildClaudeQuotaSummary, buildPrimeAccountStatuses, claudeGatewayStatusNotes, DEFAULT_KILLSWITCH_THRESHOLDS, exchange, executeCacheKeepCommand, executePrimeCommand, formatEnrollmentStatus, formatNativeAccountState, formatOAuthAccountTier, getCache1hPersistentMode, getCacheKeepWindow, getMaxSameAccountWait, getPersistedLogLevel, getRoutingMode, isCache1hPersistentlyEnabled, isCacheKeepAlways, isCacheKeepHybridActive, isCacheKeepPersistentlyEnabled, isDumpPersistentlyEnabled, isFastModePersistentlyEnabled, isKillswitchEnabled, isNativeTransientAccountError, isPrimePersistentlyEnabled, isVaultHosted, logger, nativeAccountCanServe, setDumpEnabled, VAULT_HOST_CONNECT_REFUSAL, VAULT_HOST_STATUS, } from '@cortexkit/anthropic-auth-core';
|
|
3
3
|
import { createPiCustodyCommands } from './custody.js';
|
|
4
4
|
import { getPiNativeRuntime } from './native.js';
|
|
5
5
|
import { getPiAccountStoragePath } from './paths.js';
|
|
@@ -7,6 +7,8 @@ import { clearPiStickyRoutingSession, getPiTrackedCacheKeepSessions, } from './s
|
|
|
7
7
|
import { fetchPiOAuth } from './transport.js';
|
|
8
8
|
export function createPiNativeCommands(storagePath = getPiAccountStoragePath()) {
|
|
9
9
|
const native = getPiNativeRuntime(storagePath);
|
|
10
|
+
let lastStatusSnapshot;
|
|
11
|
+
let statusReadContended = false;
|
|
10
12
|
const custody = createPiCustodyCommands();
|
|
11
13
|
const pending = new Map();
|
|
12
14
|
const written = (result, text) => result.outcome === 'refused' || result.outcome === 'failed'
|
|
@@ -285,7 +287,23 @@ export function createPiNativeCommands(storagePath = getPiAccountStoragePath())
|
|
|
285
287
|
async readStatus(command) {
|
|
286
288
|
const runtime = await native.service();
|
|
287
289
|
await runtime.prepareSettingsAction?.();
|
|
288
|
-
|
|
290
|
+
let snapshot;
|
|
291
|
+
try {
|
|
292
|
+
snapshot = await runtime.read();
|
|
293
|
+
lastStatusSnapshot = snapshot;
|
|
294
|
+
statusReadContended = false;
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
if (!isNativeTransientAccountError(error) || !error.poolRead)
|
|
298
|
+
throw error;
|
|
299
|
+
if (!statusReadContended) {
|
|
300
|
+
statusReadContended = true;
|
|
301
|
+
logger.warn('native-auth', 'Account update in progress; keeping status display');
|
|
302
|
+
}
|
|
303
|
+
if (!lastStatusSnapshot)
|
|
304
|
+
return 'Anthropic account update in progress; try status again shortly.';
|
|
305
|
+
snapshot = lastStatusSnapshot;
|
|
306
|
+
}
|
|
289
307
|
if ((command === 'account' || command === 'quota') &&
|
|
290
308
|
snapshot.mode === 'claustrum' &&
|
|
291
309
|
!(await runtime.vault.read()))
|
package/dist/stream.js
CHANGED
|
@@ -2254,7 +2254,13 @@ export function streamCortexKitAnthropic(model, context, options, effortTransiti
|
|
|
2254
2254
|
delete block.index;
|
|
2255
2255
|
output.stopReason = options?.signal?.aborted ? 'aborted' : 'error';
|
|
2256
2256
|
output.errorMessage =
|
|
2257
|
-
|
|
2257
|
+
output.stopReason === 'error' &&
|
|
2258
|
+
isNativeTransientAccountError(error) &&
|
|
2259
|
+
error.poolRead
|
|
2260
|
+
? 'Anthropic account service unavailable while an update is in progress; retry the request'
|
|
2261
|
+
: error instanceof Error
|
|
2262
|
+
? error.message
|
|
2263
|
+
: String(error);
|
|
2258
2264
|
stream.push({ type: 'error', reason: output.stopReason, error: output });
|
|
2259
2265
|
stream.end();
|
|
2260
2266
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/pi-anthropic-auth",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prepublishOnly": "bun run build"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@cortexkit/anthropic-auth-core": "2.16.
|
|
39
|
+
"@cortexkit/anthropic-auth-core": "2.16.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@earendil-works/pi-ai": ">=0.86.1 <2",
|