@hadoku/resume-bot 3.15.96 → 3.15.98
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/worker/constants.d.ts.map +1 -1
- package/dist/worker/llm.d.ts +18 -0
- package/dist/worker/llm.d.ts.map +1 -1
- package/dist/worker.js +50 -47
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../worker/src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;CAGb,CAAA;AA0DV;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GACtB,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,qBAAqB,GACrB,iBAAiB,CAAA;AAErB,eAAO,MAAM,aAAa,EAAE;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,cAAc,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../worker/src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;CAGb,CAAA;AA0DV;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GACtB,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,qBAAqB,GACrB,iBAAiB,CAAA;AAErB,eAAO,MAAM,aAAa,EAAE;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,cAAc,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,EA4ES,CAAA;AAEV,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAA;AAEV,eAAO,MAAM,sBAAsB;;;CASzB,CAAA;AAUV,eAAO,MAAM,gBAAgB;;;;CAanB,CAAA;AAEV,eAAO,MAAM,mBAAmB,OAAO,CAAA;AAMvC,eAAO,MAAM,yBAAyB,OAAO,CAAA;AAwB7C,eAAO,MAAM,mBAAmB,SAAU,CAAA;AAM1C,eAAO,MAAM,cAAc,OAAQ,CAAA"}
|
package/dist/worker/llm.d.ts
CHANGED
|
@@ -59,6 +59,24 @@ export type LLMEnv = Partial<Record<ProviderEnvKey, string>> & {
|
|
|
59
59
|
/** Substituted into Cloudflare's base URL, which carries it in the path. */
|
|
60
60
|
CLOUDFLARE_ACCOUNT_ID?: string;
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* The fetch every provider client uses. Two jobs:
|
|
64
|
+
*
|
|
65
|
+
* 1. A provider that names an `authHeader` wants its key THERE and NOWHERE
|
|
66
|
+
* ELSE, so the SDK's `Authorization: Bearer` is deleted from the outgoing
|
|
67
|
+
* Headers (a null defaultHeader is not reliably dropped on workerd).
|
|
68
|
+
*
|
|
69
|
+
* 2. An error body that is not shaped `{error: {...}}` is reshaped so it is.
|
|
70
|
+
* The openai SDK reads ONLY `body.error`, and when that key is missing it
|
|
71
|
+
* reports "400 status code (no body)" even though the body was there.
|
|
72
|
+
* Google's OpenAI-compatible surface answers errors as a JSON ARRAY,
|
|
73
|
+
* `[{"error": {...}}]`, so every Gemini refusal arrived as "(no body)" and
|
|
74
|
+
* its actual reason was thrown away. That blind spot is how a Gemini
|
|
75
|
+
* failure was misread as a header problem on 2026-09-15 and stayed broken.
|
|
76
|
+
*/
|
|
77
|
+
export declare function providerFetch(apiKey: string, authHeader?: string): (url: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
78
|
+
/** Rebuild a failed response so its body carries a top-level `error` the SDK can read. */
|
|
79
|
+
export declare function normalizeErrorBody(res: Response): Promise<Response>;
|
|
62
80
|
/**
|
|
63
81
|
* Build the provider chain from whatever keys are configured, in LLM_PROVIDERS
|
|
64
82
|
* order. Every provider speaks an OpenAI-compatible API, so a request can fall
|
package/dist/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;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,IACjD,KAAK,WAAW,GAAG,GAAG,EAAE,OAAO,WAAW,KAAG,OAAO,CAAC,QAAQ,CAAC,CAU7E;AAED,0FAA0F;AAC1F,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuBzE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAqCrD;AA6FD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAyBvB"}
|
package/dist/worker.js
CHANGED
|
@@ -15003,25 +15003,15 @@ const LLM_PROVIDERS = [
|
|
|
15003
15003
|
name: "gemini",
|
|
15004
15004
|
envKey: "GEMINI_API_KEY",
|
|
15005
15005
|
baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai/",
|
|
15006
|
-
model: "gemini-3.8-flash"
|
|
15007
|
-
// The key rides in `
|
|
15006
|
+
model: "gemini-3.8-flash"
|
|
15007
|
+
// The key rides in `Authorization: Bearer`, the OpenAI way. No authHeader.
|
|
15008
15008
|
//
|
|
15009
|
-
// Measured
|
|
15010
|
-
//
|
|
15011
|
-
//
|
|
15012
|
-
//
|
|
15013
|
-
//
|
|
15014
|
-
//
|
|
15015
|
-
// is not accepted as a Bearer token on this surface. 403 vs 400 is the tell:
|
|
15016
|
-
// one never got past auth, the other did.
|
|
15017
|
-
//
|
|
15018
|
-
// The 400 that remains is the documented "Multiple authentication
|
|
15019
|
-
// credentials received" — the endpoint reads its own header AND still sees
|
|
15020
|
-
// an Authorization, so the SDK's header has to be genuinely removed rather
|
|
15021
|
-
// than merely set to null. llm.ts does that in a fetch wrapper now; a null
|
|
15022
|
-
// defaultHeader is dropped by openai 6.32 in Node but was evidently not
|
|
15023
|
-
// reaching the wire that way on workerd.
|
|
15024
|
-
authHeader: "x-goog-api-key"
|
|
15009
|
+
// Measured 2026-11-20, once llm.ts stopped hiding Google's error bodies
|
|
15010
|
+
// (they come as a JSON array the openai SDK reported as "(no body)"):
|
|
15011
|
+
// with the key in `x-goog-api-key` and Authorization deleted, the answer
|
|
15012
|
+
// is `400 Missing or invalid Authorization header.` That is the 400 every
|
|
15013
|
+
// Gemini call returned since 2026-09-15. Its earlier diagnosis ("Multiple
|
|
15014
|
+
// authentication credentials received") was read off a bare status code.
|
|
15025
15015
|
},
|
|
15026
15016
|
{
|
|
15027
15017
|
// A SECOND Gemini key, and the only reason it is worth a slot is that free
|
|
@@ -15034,8 +15024,7 @@ const LLM_PROVIDERS = [
|
|
|
15034
15024
|
name: "gemini-2",
|
|
15035
15025
|
envKey: "GEMINI_API_KEY_2",
|
|
15036
15026
|
baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai/",
|
|
15037
|
-
model: "gemini-3.8-flash"
|
|
15038
|
-
authHeader: "x-goog-api-key"
|
|
15027
|
+
model: "gemini-3.8-flash"
|
|
15039
15028
|
},
|
|
15040
15029
|
{
|
|
15041
15030
|
// Cloudflare Workers AI. 10,000 neurons/day, no card, and this ecosystem
|
|
@@ -41499,6 +41488,37 @@ function remainingMs(deadline) {
|
|
|
41499
41488
|
return deadline === void 0 ? Number.POSITIVE_INFINITY : deadline - Date.now();
|
|
41500
41489
|
}
|
|
41501
41490
|
const REQUEST_TIMEOUT_MS = 2e4;
|
|
41491
|
+
function providerFetch(apiKey, authHeader) {
|
|
41492
|
+
return async (url2, init) => {
|
|
41493
|
+
const headers = new Headers(init?.headers);
|
|
41494
|
+
if (authHeader) {
|
|
41495
|
+
headers.delete("authorization");
|
|
41496
|
+
headers.set(authHeader, apiKey);
|
|
41497
|
+
}
|
|
41498
|
+
const res = await fetch(url2, { ...init, headers });
|
|
41499
|
+
if (res.ok) return res;
|
|
41500
|
+
return normalizeErrorBody(res);
|
|
41501
|
+
};
|
|
41502
|
+
}
|
|
41503
|
+
async function normalizeErrorBody(res) {
|
|
41504
|
+
const text = await res.text();
|
|
41505
|
+
let body = text;
|
|
41506
|
+
let parsed;
|
|
41507
|
+
try {
|
|
41508
|
+
parsed = JSON.parse(text);
|
|
41509
|
+
} catch {
|
|
41510
|
+
parsed = void 0;
|
|
41511
|
+
}
|
|
41512
|
+
if (Array.isArray(parsed) && parsed.length > 0 && parsed[0] && typeof parsed[0] === "object") {
|
|
41513
|
+
body = JSON.stringify(parsed[0]);
|
|
41514
|
+
} else if (parsed !== void 0 && (typeof parsed !== "object" || parsed === null || !("error" in parsed))) {
|
|
41515
|
+
body = JSON.stringify({ error: { message: text.slice(0, 500) } });
|
|
41516
|
+
}
|
|
41517
|
+
const outHeaders = new Headers(res.headers);
|
|
41518
|
+
outHeaders.delete("content-encoding");
|
|
41519
|
+
outHeaders.delete("content-length");
|
|
41520
|
+
return new Response(body, { status: res.status, statusText: res.statusText, headers: outHeaders });
|
|
41521
|
+
}
|
|
41502
41522
|
function createLLMClient(env) {
|
|
41503
41523
|
const chain = [];
|
|
41504
41524
|
for (const p of LLM_PROVIDERS) {
|
|
@@ -41513,28 +41533,10 @@ function createLLMClient(env) {
|
|
|
41513
41533
|
client: new OpenAI({
|
|
41514
41534
|
apiKey,
|
|
41515
41535
|
baseURL: baseUrl,
|
|
41516
|
-
//
|
|
41517
|
-
//
|
|
41518
|
-
//
|
|
41519
|
-
|
|
41520
|
-
// bad request.
|
|
41521
|
-
//
|
|
41522
|
-
// Done in a fetch wrapper rather than `defaultHeaders: {Authorization:
|
|
41523
|
-
// null}`. The null form drops the header under openai 6.32 on Node, and
|
|
41524
|
-
// that is how it was verified, but the 400 persisted on workerd — so
|
|
41525
|
-
// the header was still reaching the wire. Deleting it from the outgoing
|
|
41526
|
-
// Headers is the only form that cannot be runtime-dependent.
|
|
41527
|
-
// Captured BEFORE the closure: narrowing `p.authHeader` at the `?:` does
|
|
41528
|
-
// not survive into a callback TypeScript must assume runs later, so the
|
|
41529
|
-
// header name has to be a plain string by the time it is used.
|
|
41530
|
-
...authHeader ? {
|
|
41531
|
-
fetch: (url2, init) => {
|
|
41532
|
-
const headers = new Headers(init?.headers);
|
|
41533
|
-
headers.delete("authorization");
|
|
41534
|
-
headers.set(authHeader, apiKey);
|
|
41535
|
-
return fetch(url2, { ...init, headers });
|
|
41536
|
-
}
|
|
41537
|
-
} : {},
|
|
41536
|
+
// Every provider goes through providerFetch: it moves the key for a
|
|
41537
|
+
// provider that names an `authHeader`, and unwraps an error body the SDK
|
|
41538
|
+
// would otherwise report as "(no body)". See providerFetch.
|
|
41539
|
+
fetch: providerFetch(apiKey, authHeader),
|
|
41538
41540
|
// Both of these MUST be set explicitly. The SDK defaults are a 10-minute
|
|
41539
41541
|
// timeout and 2 internal retries, which is catastrophic here: a hung
|
|
41540
41542
|
// provider would burn 30 minutes inside a request the edge gives 120s,
|
|
@@ -41612,18 +41614,19 @@ async function sendChatCompletion(chain, messages2, options) {
|
|
|
41612
41614
|
if (chain.length === 0) {
|
|
41613
41615
|
throw new Error("No LLM providers configured (set GROQ_API_KEY or GEMINI_API_KEY)");
|
|
41614
41616
|
}
|
|
41615
|
-
|
|
41617
|
+
const failures = [];
|
|
41616
41618
|
for (let i = 0; i < chain.length; i++) {
|
|
41617
41619
|
const isLast = i === chain.length - 1;
|
|
41618
41620
|
try {
|
|
41619
41621
|
return await callProvider(chain[i], messages2, options, isLast);
|
|
41620
41622
|
} catch (err) {
|
|
41621
|
-
|
|
41622
|
-
if (err instanceof DeadlineExceededError)
|
|
41623
|
-
|
|
41623
|
+
failures.push(`${chain[i].name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
41624
|
+
if (err instanceof DeadlineExceededError) {
|
|
41625
|
+
throw new DeadlineExceededError(failures.join("; "));
|
|
41626
|
+
}
|
|
41624
41627
|
}
|
|
41625
41628
|
}
|
|
41626
|
-
throw
|
|
41629
|
+
throw new Error(`All LLM providers failed: ${failures.join("; ")}`);
|
|
41627
41630
|
}
|
|
41628
41631
|
const CACHE_TTL_SECONDS$2 = 2592e3;
|
|
41629
41632
|
function stripCodeFence(text) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/resume-bot",
|
|
3
|
-
"version": "3.15.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "3.15.98",
|
|
4
|
+
"gitHead": "7e28f02e6e2783ab9f72cdee4e6b8455578ced5a",
|
|
5
5
|
"description": "AI-powered conversational interface for interactive resume exploration",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|