@cortexkit/pi-anthropic-auth 2.11.1 → 2.11.2
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/convert.d.ts +2 -0
- package/dist/convert.js +6 -0
- package/dist/stream.js +2 -1
- package/package.json +2 -2
package/dist/convert.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export declare function createClaudeCodeToolNameMap(tools: readonly Tool[]): Rea
|
|
|
40
40
|
* executable host tool.
|
|
41
41
|
*/
|
|
42
42
|
export declare function fromClaudeCodeToolName(name: string, requestedToolNames: ReadonlyMap<string, string>): string;
|
|
43
|
+
/** Replace only the system cache marker, preserving the tool and message markers. */
|
|
44
|
+
export declare function piThreadCacheSlot(body: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
43
45
|
export declare function buildAnthropicRequest(modelId: string, context: Context, options: SimpleStreamOptions | undefined, cache: {
|
|
44
46
|
enabled: boolean;
|
|
45
47
|
mode: Cache1hMode;
|
package/dist/convert.js
CHANGED
|
@@ -479,6 +479,12 @@ function applyCacheMode(body, enabled, mode) {
|
|
|
479
479
|
holder.cache_control.ttl = '1h';
|
|
480
480
|
});
|
|
481
481
|
}
|
|
482
|
+
/** Replace only the system cache marker, preserving the tool and message markers. */
|
|
483
|
+
export function piThreadCacheSlot(body) {
|
|
484
|
+
if (body.cache_control || !Array.isArray(body.system))
|
|
485
|
+
return undefined;
|
|
486
|
+
return body.system.findLast((block) => block && typeof block === 'object' && block.cache_control);
|
|
487
|
+
}
|
|
482
488
|
export async function buildAnthropicRequest(modelId, context, options, cache, fastModeEnabled = false, identity, controls = {}) {
|
|
483
489
|
// Pi 0.86 passes a normalized transcript to providers, and later system
|
|
484
490
|
// messages can change the prompt, its named sections and the tool set. Resolve
|
package/dist/stream.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { applyClaudeCodeHeaders, applyClaudeCodeMetadata, applyCustomHeaders, assertHostAuthorityStable, buildBillingHeaderValue, buildPrimeRequestBody, CACHE_KEEP_EXTENDED_TTL_BETA, CacheKeepSessionRegistry, CLAUDE_CODE_ACCEPT_ENCODING, CLAUDE_CODE_ENTRYPOINT, CLAUDE_CODE_IDENTITY, copyStreamResponseTiming, createAnthropicStreamCompletion, createDumpResponseObserver, createNativeVaultNoRouteResponse, createProviderErrorResponseScope, createQuotaRefusalResponse, createRoutingRelay, createSseFramer, createStickyNoRouteResponse, decideStickyQuotaFailure, decodeSseFrame, dumpDirectRequest, dumpResponseArtifact, effectiveRelayTransport, FAST_MODE_BETA, getCache1hPersistentMode, getCacheKeepRegistryDirectories, getClaudeCodeIdentityForVerifiedAccount, getFallbackReauthLabels, getMaxSameAccountWait, getQuotaCheckIntervalMs, getRequestGzipLatch, getRequestGzipLatchPath, getRoutingMode, getScopedQuotaWindowForModel, getThinkingPrefixMismatchBehavior, hostRetryHeaders, hostRetryResponse, isCache1hPersistentlyEnabled, isCacheKeepHybridActive, isDumpPersistentlyEnabled, isFastModePersistentlyEnabled, isKillswitchEnabled, isNativeTransientAccountError, isOAuthAccount, isPermanentRefreshError, isValidApiBaseURL, killswitchPassesPolicy, LEGACY_STATE_LAYOUT, localMessageThreadCredential, logger, MessageThreadTracker, mergeAnthropicBetas, NativeAccountRefusal, nativeAccountCanServe, orderClaudeCodeBody, PROMPT_CACHE_DEFAULT_TTL_MS, parseSseFrame, prepareMessageThreadRequest, QuotaManager, quotaBackoffActive, quotaExhaustionFromHeaders, quotaRefusalTiming, quotaSnapshotHasStandardWindows, quotaSnapshotModelScopeIsExhausted, quotaSnapshotPassesModelScope, quotaSnapshotPassesPolicy, readSessionCachePolicy, reportRoutingResponse, reportSessionCacheTouch, requestCacheLifetimeMs, resolveNativePoolPaths, routingCandidates, routingChoiceMatches, runWithRequestSignal, STICKY_ROUTING_MAIN_ACCOUNT_ID, StickyQuotaRetryCounter, StickySessionRouter, sendViaRelay, sendWithRequestGzip, sessionCacheActivity, setDumpEnabled, shouldFallbackStatus, signRequestBody, stickyQuotaSnapshotIsFresh, stickyRetryAfterWithJitter, stickyRouteCandidateWeight, stickyRouteFamilyForModel, withAnthropicBilling, } from '@cortexkit/anthropic-auth-core';
|
|
2
2
|
import { calculateCost, createAssistantMessageEventStream, } from '@earendil-works/pi-ai';
|
|
3
3
|
import { PiCacheKeep } from './cachekeep.js';
|
|
4
|
-
import { buildAnthropicRequest, fromClaudeCodeToolName } from './convert.js';
|
|
4
|
+
import { buildAnthropicRequest, fromClaudeCodeToolName, piThreadCacheSlot, } from './convert.js';
|
|
5
5
|
import { getPiNativeRuntime, peekPiNativeSnapshot, piAttemptAccessToken, } from './native.js';
|
|
6
6
|
import { getPiAccountStoragePath } from './paths.js';
|
|
7
7
|
import { registerPiPrimeSender } from './prime.js';
|
|
@@ -716,6 +716,7 @@ async function sendAnthropicRequest(options, deps = {}) {
|
|
|
716
716
|
: localMessageThreadCredential(nextAttempt.admission.binding),
|
|
717
717
|
bodyText,
|
|
718
718
|
replyToolNames: toolNames,
|
|
719
|
+
cacheSlot: piThreadCacheSlot,
|
|
719
720
|
headers,
|
|
720
721
|
signal: init.signal ?? undefined,
|
|
721
722
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/pi-anthropic-auth",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.2",
|
|
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.11.
|
|
39
|
+
"@cortexkit/anthropic-auth-core": "2.11.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@earendil-works/pi-ai": ">=0.86.1 <2",
|