@yanlinglabs/winter-provider-runtime 0.0.6 → 0.0.7
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.
|
@@ -12,13 +12,16 @@ import type { CredentialRef } from "../../types.js";
|
|
|
12
12
|
export declare const ANTHROPIC_CONSOLE_PROVIDER_ID = "anthropic";
|
|
13
13
|
/**
|
|
14
14
|
* What survives of the old `CONSOLE_OAUTH` object once its login-only fields are gone: the ONE header
|
|
15
|
-
* value `messages.ts` still sends alongside an
|
|
15
|
+
* value `messages.ts` still sends alongside an Anthropic Console credential's bearer -- an `oauth`-
|
|
16
|
+
* kind one, or (P10a, M5) a `bearer`-kind one from the host-brokered `console-broker.ts` leg, on the
|
|
17
|
+
* `anthropic` provider row only (`isConsoleProvider`).
|
|
16
18
|
*
|
|
17
|
-
* See the file banner for why this is renamed rather than trimmed in place
|
|
18
|
-
*
|
|
19
|
+
* See the file banner for why this is renamed rather than trimmed in place. P10a-1/M3 measured that
|
|
20
|
+
* the header belongs on the `anthropic` row's bearer material too, not only on `oauth`; see
|
|
21
|
+
* `messages.ts`'s `buildHeaders` for the settled gate.
|
|
19
22
|
*/
|
|
20
23
|
export declare const CONSOLE_BEARER: {
|
|
21
|
-
/** The `anthropic-beta` value that accompanies an OAuth bearer on every request. */
|
|
24
|
+
/** The `anthropic-beta` value that accompanies an OAuth or Console bearer on every request. */
|
|
22
25
|
readonly betaHeader: "oauth-2025-04-20";
|
|
23
26
|
};
|
|
24
27
|
/**
|
|
@@ -40996,7 +40996,7 @@ import { CLAUDE_RESERVED_SLOT_NAMES as CLAUDE_RESERVED_SLOT_NAMES2, CURRENCY_RE
|
|
|
40996
40996
|
// package.json
|
|
40997
40997
|
var package_default = {
|
|
40998
40998
|
name: "@yanlinglabs/winter-provider-runtime",
|
|
40999
|
-
version: "0.0.
|
|
40999
|
+
version: "0.0.7",
|
|
41000
41000
|
license: "MIT",
|
|
41001
41001
|
type: "module",
|
|
41002
41002
|
engines: {
|
package/dist/index.js
CHANGED
|
@@ -115,7 +115,7 @@ import {
|
|
|
115
115
|
shouldRequestSummary2,
|
|
116
116
|
createEndpointResolver2,
|
|
117
117
|
endpointFromOrigin2
|
|
118
|
-
} from "./index-
|
|
118
|
+
} from "./index-m3qxyre5.js";
|
|
119
119
|
// src/credentials/env.ts
|
|
120
120
|
var NAME = "env credential store";
|
|
121
121
|
function createEnvCredentialStore(opts) {
|
|
@@ -667,7 +667,7 @@ async function resolveFreshMaterial(ctx) {
|
|
|
667
667
|
}
|
|
668
668
|
async function buildHeaders2(ctx, policy, opts, json, identity = {}) {
|
|
669
669
|
const material = await resolveFreshMaterial(ctx);
|
|
670
|
-
const betas = [...opts.betas ?? [], ...material?.kind === "oauth" && isConsoleProvider(ctx) ? [CONSOLE_BEARER.betaHeader] : []].filter((value, index, all) => all.indexOf(value) === index);
|
|
670
|
+
const betas = [...opts.betas ?? [], ...(material?.kind === "oauth" || material?.kind === "bearer") && isConsoleProvider(ctx) ? [CONSOLE_BEARER.betaHeader] : []].filter((value, index, all) => all.indexOf(value) === index);
|
|
671
671
|
const headers = {
|
|
672
672
|
"user-agent": winterUserAgent2(),
|
|
673
673
|
...identity,
|
|
@@ -1217,7 +1217,12 @@ async function refreshAnthropicBearer(store, options) {
|
|
|
1217
1217
|
if (token.length === 0)
|
|
1218
1218
|
return { ok: false, reason: '"ant auth print-credentials" printed no token' };
|
|
1219
1219
|
const now = options.now ?? Date.now;
|
|
1220
|
-
const
|
|
1220
|
+
const nowValue = now();
|
|
1221
|
+
let expiresAt = await readProfileExpiresAt(options.anthropicConfigDir, profile) ?? nowValue + 3600000;
|
|
1222
|
+
if (expiresAt <= nowValue) {
|
|
1223
|
+
options.onLine?.("refreshAnthropicBearer: profile expiresAt was not in the future; clamped to now+60s");
|
|
1224
|
+
expiresAt = nowValue + 60000;
|
|
1225
|
+
}
|
|
1221
1226
|
const material = { kind: "bearer", token, expiresAt };
|
|
1222
1227
|
const ref = anthropicCredentialRef("default", options.service);
|
|
1223
1228
|
try {
|
|
@@ -1232,11 +1237,23 @@ async function readProfileExpiresAt(anthropicConfigDir, profile) {
|
|
|
1232
1237
|
try {
|
|
1233
1238
|
const raw = await Bun.file(join2(anthropicConfigDir, "credentials", `${profile}.json`)).slice(0, MAX_PROFILE_FILE_BYTES).text();
|
|
1234
1239
|
const parsed = JSON.parse(raw);
|
|
1235
|
-
return
|
|
1240
|
+
return normalizeExpiresAt(parsed.expires_at);
|
|
1236
1241
|
} catch {
|
|
1237
1242
|
return;
|
|
1238
1243
|
}
|
|
1239
1244
|
}
|
|
1245
|
+
function normalizeExpiresAt(value) {
|
|
1246
|
+
if (typeof value === "number") {
|
|
1247
|
+
if (!Number.isFinite(value))
|
|
1248
|
+
return;
|
|
1249
|
+
return value < 1000000000000 ? value * 1000 : value;
|
|
1250
|
+
}
|
|
1251
|
+
if (typeof value === "string") {
|
|
1252
|
+
const parsed = Date.parse(value);
|
|
1253
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
1254
|
+
}
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1240
1257
|
function anthropicConsoleProfileExists(anthropicConfigDir, profile = DEFAULT_ANTHROPIC_CONSOLE_PROFILE) {
|
|
1241
1258
|
return existsSync(join2(anthropicConfigDir, "credentials", `${profile}.json`));
|
|
1242
1259
|
}
|
package/dist/testing.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanlinglabs/winter-provider-runtime",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@yanlinglabs/winter-agent-sdk": "0.0.
|
|
46
|
-
"@yanlinglabs/winter-provider-catalog": "0.0.
|
|
45
|
+
"@yanlinglabs/winter-agent-sdk": "0.0.7",
|
|
46
|
+
"@yanlinglabs/winter-provider-catalog": "0.0.7"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {}
|
|
49
49
|
}
|