@theokit/sdk 4.52.0 → 4.52.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/CHANGELOG.md +35 -17
- package/dist/{agent-HYQGJTIN.js → agent-RDHK6MVT.js} +6 -6
- package/dist/{agent-HYQGJTIN.js.map → agent-RDHK6MVT.js.map} +1 -1
- package/dist/{agent-C66BEJGO.cjs → agent-U2R2R5JP.cjs} +7 -7
- package/dist/{agent-C66BEJGO.cjs.map → agent-U2R2R5JP.cjs.map} +1 -1
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.d.cts +15 -0
- package/dist/auth/index.d.ts +15 -0
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-SPZZSAHV.js → chunk-42PLABFU.js} +3 -3
- package/dist/{chunk-SPZZSAHV.js.map → chunk-42PLABFU.js.map} +1 -1
- package/dist/{chunk-LLK2RS6I.cjs → chunk-6GS7JI64.cjs} +43 -43
- package/dist/{chunk-LLK2RS6I.cjs.map → chunk-6GS7JI64.cjs.map} +1 -1
- package/dist/{chunk-YARJG3GV.cjs → chunk-CY7MIMI4.cjs} +3 -3
- package/dist/{chunk-YARJG3GV.cjs.map → chunk-CY7MIMI4.cjs.map} +1 -1
- package/dist/{chunk-WVDH34LK.cjs → chunk-FRITRLZQ.cjs} +2 -2
- package/dist/chunk-FRITRLZQ.cjs.map +1 -0
- package/dist/{chunk-DU7PBCAM.js → chunk-GNPI5IWZ.js} +3 -3
- package/dist/{chunk-DU7PBCAM.js.map → chunk-GNPI5IWZ.js.map} +1 -1
- package/dist/{chunk-ZFARZBOX.js → chunk-KELIQH7K.js} +6 -6
- package/dist/{chunk-ZFARZBOX.js.map → chunk-KELIQH7K.js.map} +1 -1
- package/dist/{chunk-YBB66SZZ.js → chunk-M5EK7N6R.js} +3 -3
- package/dist/{chunk-YBB66SZZ.js.map → chunk-M5EK7N6R.js.map} +1 -1
- package/dist/{chunk-U3PAW4PL.js → chunk-NAF4L3T6.js} +2 -2
- package/dist/chunk-NAF4L3T6.js.map +1 -0
- package/dist/{chunk-ZNEYQ56O.cjs → chunk-WLESQ3ZQ.cjs} +6 -6
- package/dist/{chunk-ZNEYQ56O.cjs.map → chunk-WLESQ3ZQ.cjs.map} +1 -1
- package/dist/{chunk-2CD5XUAG.cjs → chunk-ZNEE4WWQ.cjs} +5 -5
- package/dist/{chunk-2CD5XUAG.cjs.map → chunk-ZNEE4WWQ.cjs.map} +1 -1
- package/dist/{compact-session-AXKDB6FC.cjs → compact-session-FBVWO6B3.cjs} +12 -12
- package/dist/{compact-session-AXKDB6FC.cjs.map → compact-session-FBVWO6B3.cjs.map} +1 -1
- package/dist/{compact-session-DUAUEFRR.js → compact-session-XLXC2CZN.js} +4 -4
- package/dist/{compact-session-DUAUEFRR.js.map → compact-session-XLXC2CZN.js.map} +1 -1
- package/dist/cron.cjs +6 -6
- package/dist/cron.js +5 -5
- package/dist/eval.cjs +5 -5
- package/dist/eval.js +4 -4
- package/dist/index.cjs +28 -28
- package/dist/index.js +7 -7
- package/dist/{inject-session-TASLP5FA.cjs → inject-session-UBAQ7I3G.cjs} +4 -4
- package/dist/{inject-session-TASLP5FA.cjs.map → inject-session-UBAQ7I3G.cjs.map} +1 -1
- package/dist/{inject-session-RBGOGACE.js → inject-session-UEH5MAKU.js} +3 -3
- package/dist/{inject-session-RBGOGACE.js.map → inject-session-UEH5MAKU.js.map} +1 -1
- package/dist/internal/auth/api-key-prefix.d.ts +7 -1
- package/package.json +1 -1
- package/dist/chunk-U3PAW4PL.js.map +0 -1
- package/dist/chunk-WVDH34LK.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -6,16 +6,16 @@ import './chunk-I732VEDW.js';
|
|
|
6
6
|
import { Workflow, agentStep } from './chunk-6PTCKXD3.js';
|
|
7
7
|
import './chunk-KZBB4YKU.js';
|
|
8
8
|
import './chunk-CAH3G4IS.js';
|
|
9
|
-
export { Cron } from './chunk-
|
|
10
|
-
import { MEMORY_EMBEDDING_ADAPTERS, resolveApiKey, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-
|
|
11
|
-
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-
|
|
12
|
-
import './chunk-
|
|
9
|
+
export { Cron } from './chunk-GNPI5IWZ.js';
|
|
10
|
+
import { MEMORY_EMBEDDING_ADAPTERS, resolveApiKey, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-KELIQH7K.js';
|
|
11
|
+
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-KELIQH7K.js';
|
|
12
|
+
import './chunk-42PLABFU.js';
|
|
13
13
|
import './chunk-2SFBB54R.js';
|
|
14
14
|
import { configure, submit, list, get, cancel, subscribe } from './chunk-7TB5U7RK.js';
|
|
15
15
|
export { emitRunEvent } from './chunk-7TB5U7RK.js';
|
|
16
16
|
import './chunk-K2BQQ445.js';
|
|
17
17
|
import './chunk-J4RY5DTI.js';
|
|
18
|
-
import { discoverProviderPlugins, shouldUseFixtureMode, isFixtureApiKey, httpRequest, mapOllamaTransportError, readErrorResponseBody, mapOllamaHttpError } from './chunk-
|
|
18
|
+
import { discoverProviderPlugins, shouldUseFixtureMode, isFixtureApiKey, httpRequest, mapOllamaTransportError, readErrorResponseBody, mapOllamaHttpError } from './chunk-M5EK7N6R.js';
|
|
19
19
|
import './chunk-4QEC4CCS.js';
|
|
20
20
|
import './chunk-DHVNJYTO.js';
|
|
21
21
|
import './chunk-UJ3SXRZZ.js';
|
|
@@ -29,7 +29,7 @@ import './chunk-OZXPA3ME.js';
|
|
|
29
29
|
import './chunk-OXNYIMZZ.js';
|
|
30
30
|
import './chunk-FD2UT76F.js';
|
|
31
31
|
import './chunk-U54XCYG3.js';
|
|
32
|
-
import './chunk-
|
|
32
|
+
import './chunk-NAF4L3T6.js';
|
|
33
33
|
import './chunk-RP5HQVLD.js';
|
|
34
34
|
import './chunk-6X6ID4MO.js';
|
|
35
35
|
import './chunk-4NAKHID5.js';
|
|
@@ -1840,7 +1840,7 @@ function isBuiltAgent(m) {
|
|
|
1840
1840
|
return typeof m.send === "function";
|
|
1841
1841
|
}
|
|
1842
1842
|
async function materialize(def, index) {
|
|
1843
|
-
const { Agent: Agent2 } = await import('./agent-
|
|
1843
|
+
const { Agent: Agent2 } = await import('./agent-RDHK6MVT.js');
|
|
1844
1844
|
return Agent2.create({
|
|
1845
1845
|
// `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
|
|
1846
1846
|
// here means "declare nothing and let the default apply" — forwarding the literal would create
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkCY7MIMI4_cjs = require('./chunk-CY7MIMI4.cjs');
|
|
4
4
|
var chunk4JBHSLQO_cjs = require('./chunk-4JBHSLQO.cjs');
|
|
5
5
|
require('./chunk-3R4ZCQAZ.cjs');
|
|
6
6
|
var chunkECPL5RV6_cjs = require('./chunk-ECPL5RV6.cjs');
|
|
@@ -9,7 +9,7 @@ require('./chunk-SXSPMRSV.cjs');
|
|
|
9
9
|
|
|
10
10
|
// src/internal/session/inject-session.ts
|
|
11
11
|
async function injectSessionTurn(opts) {
|
|
12
|
-
await
|
|
12
|
+
await chunkCY7MIMI4_cjs.enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {
|
|
13
13
|
const prior = await opts.store.readRecords(opts.loc.agentId);
|
|
14
14
|
const transcript = chunkECPL5RV6_cjs.SessionTranscript.fromRecords(prior, {
|
|
15
15
|
cwd: opts.loc.cwd,
|
|
@@ -24,5 +24,5 @@ async function injectSessionTurn(opts) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
exports.injectSessionTurn = injectSessionTurn;
|
|
27
|
-
//# sourceMappingURL=inject-session-
|
|
28
|
-
//# sourceMappingURL=inject-session-
|
|
27
|
+
//# sourceMappingURL=inject-session-UBAQ7I3G.cjs.map
|
|
28
|
+
//# sourceMappingURL=inject-session-UBAQ7I3G.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/session/inject-session.ts"],"names":["enqueueSessionWrite","SessionTranscript","invalidateSessionCache"],"mappings":";;;;;;;;;;AAWA,eAAsB,kBAAkB,IAAA,EAMtB;AAChB,EAAA,MAAMA,sCAAoB,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,SAAS,YAAY;AACpE,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,MAAM,WAAA,CAAY,IAAA,CAAK,IAAI,OAAO,CAAA;AAC3D,IAAA,MAAM,UAAA,GAAaC,mCAAA,CAAkB,WAAA,CAAY,KAAA,EAAO;AAAA,MACtD,GAAA,EAAK,KAAK,GAAA,CAAI,GAAA;AAAA,MACd,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,KAAA,IAAS;AAAA,KAC1B,CAAA;AACD,IAAA,UAAA,CAAW,cAAA,CAAe,KAAK,QAAQ,CAAA;AACvC,IAAA,UAAA,CAAW,mBAAA,CAAoB,EAAE,IAAA,EAAM,IAAA,CAAK,eAAe,CAAA;AAC3D,IAAA,MAAM,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,OAAA,EAAQ,CAAE,KAAA,CAAM,KAAA,CAAM,MAAM,CAAC,CAAA;AACzF,IAAAC,wCAAA,CAAuB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,IAAI,OAAO,CAAA;AAAA,EACvD,CAAC,CAAA;AACH","file":"inject-session-
|
|
1
|
+
{"version":3,"sources":["../src/internal/session/inject-session.ts"],"names":["enqueueSessionWrite","SessionTranscript","invalidateSessionCache"],"mappings":";;;;;;;;;;AAWA,eAAsB,kBAAkB,IAAA,EAMtB;AAChB,EAAA,MAAMA,sCAAoB,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,SAAS,YAAY;AACpE,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,MAAM,WAAA,CAAY,IAAA,CAAK,IAAI,OAAO,CAAA;AAC3D,IAAA,MAAM,UAAA,GAAaC,mCAAA,CAAkB,WAAA,CAAY,KAAA,EAAO;AAAA,MACtD,GAAA,EAAK,KAAK,GAAA,CAAI,GAAA;AAAA,MACd,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,KAAA,IAAS;AAAA,KAC1B,CAAA;AACD,IAAA,UAAA,CAAW,cAAA,CAAe,KAAK,QAAQ,CAAA;AACvC,IAAA,UAAA,CAAW,mBAAA,CAAoB,EAAE,IAAA,EAAM,IAAA,CAAK,eAAe,CAAA;AAC3D,IAAA,MAAM,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,OAAA,EAAQ,CAAE,KAAA,CAAM,KAAA,CAAM,MAAM,CAAC,CAAA;AACzF,IAAAC,wCAAA,CAAuB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,IAAI,OAAO,CAAA;AAAA,EACvD,CAAC,CAAA;AACH","file":"inject-session-UBAQ7I3G.cjs","sourcesContent":["/**\n * M51 (agent-builder) — inject a SYNTHETIC user+assistant pair into a session's persisted transcript\n * WITHOUT running an LLM turn. This is the Codex review-exit mechanism (`exit_success.xml` appended to\n * the parent thread history so follow-ups like \"fix finding 2\" work): the pair chains onto the DAG\n * leaf (M50 pattern) and the in-memory cache is invalidated so the NEXT send re-hydrates with it.\n */\nimport type { SessionStore } from \"../../types/session-store.js\";\nimport { SessionTranscript } from \"../persistence/session-transcript.js\";\nimport { enqueueSessionWrite, invalidateSessionCache } from \"./agent-session.js\";\nimport type { CompactLocation } from \"./compact-session.js\";\n\nexport async function injectSessionTurn(opts: {\n store: SessionStore;\n loc: CompactLocation;\n sessionId: string;\n userText: string;\n assistantText: string;\n}): Promise<void> {\n await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {\n const prior = await opts.store.readRecords(opts.loc.agentId);\n const transcript = SessionTranscript.fromRecords(prior, {\n cwd: opts.loc.cwd,\n sessionId: opts.sessionId,\n model: opts.loc.model ?? \"unknown\",\n });\n transcript.appendUserTurn(opts.userText);\n transcript.appendAssistantTurn({ text: opts.assistantText });\n await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));\n invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);\n });\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { enqueueSessionWrite } from './chunk-
|
|
1
|
+
import { enqueueSessionWrite } from './chunk-42PLABFU.js';
|
|
2
2
|
import { invalidateSessionCache } from './chunk-4QEC4CCS.js';
|
|
3
3
|
import './chunk-UJ3SXRZZ.js';
|
|
4
4
|
import { SessionTranscript } from './chunk-C4EU627W.js';
|
|
@@ -22,5 +22,5 @@ async function injectSessionTurn(opts) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export { injectSessionTurn };
|
|
25
|
-
//# sourceMappingURL=inject-session-
|
|
26
|
-
//# sourceMappingURL=inject-session-
|
|
25
|
+
//# sourceMappingURL=inject-session-UEH5MAKU.js.map
|
|
26
|
+
//# sourceMappingURL=inject-session-UEH5MAKU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/session/inject-session.ts"],"names":[],"mappings":";;;;;;;;AAWA,eAAsB,kBAAkB,IAAA,EAMtB;AAChB,EAAA,MAAM,oBAAoB,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,SAAS,YAAY;AACpE,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,MAAM,WAAA,CAAY,IAAA,CAAK,IAAI,OAAO,CAAA;AAC3D,IAAA,MAAM,UAAA,GAAa,iBAAA,CAAkB,WAAA,CAAY,KAAA,EAAO;AAAA,MACtD,GAAA,EAAK,KAAK,GAAA,CAAI,GAAA;AAAA,MACd,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,KAAA,IAAS;AAAA,KAC1B,CAAA;AACD,IAAA,UAAA,CAAW,cAAA,CAAe,KAAK,QAAQ,CAAA;AACvC,IAAA,UAAA,CAAW,mBAAA,CAAoB,EAAE,IAAA,EAAM,IAAA,CAAK,eAAe,CAAA;AAC3D,IAAA,MAAM,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,OAAA,EAAQ,CAAE,KAAA,CAAM,KAAA,CAAM,MAAM,CAAC,CAAA;AACzF,IAAA,sBAAA,CAAuB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,IAAI,OAAO,CAAA;AAAA,EACvD,CAAC,CAAA;AACH","file":"inject-session-
|
|
1
|
+
{"version":3,"sources":["../src/internal/session/inject-session.ts"],"names":[],"mappings":";;;;;;;;AAWA,eAAsB,kBAAkB,IAAA,EAMtB;AAChB,EAAA,MAAM,oBAAoB,IAAA,CAAK,GAAA,CAAI,KAAK,IAAA,CAAK,GAAA,CAAI,SAAS,YAAY;AACpE,IAAA,MAAM,QAAQ,MAAM,IAAA,CAAK,MAAM,WAAA,CAAY,IAAA,CAAK,IAAI,OAAO,CAAA;AAC3D,IAAA,MAAM,UAAA,GAAa,iBAAA,CAAkB,WAAA,CAAY,KAAA,EAAO;AAAA,MACtD,GAAA,EAAK,KAAK,GAAA,CAAI,GAAA;AAAA,MACd,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,KAAA,IAAS;AAAA,KAC1B,CAAA;AACD,IAAA,UAAA,CAAW,cAAA,CAAe,KAAK,QAAQ,CAAA;AACvC,IAAA,UAAA,CAAW,mBAAA,CAAoB,EAAE,IAAA,EAAM,IAAA,CAAK,eAAe,CAAA;AAC3D,IAAA,MAAM,IAAA,CAAK,KAAA,CAAM,aAAA,CAAc,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,UAAA,CAAW,OAAA,EAAQ,CAAE,KAAA,CAAM,KAAA,CAAM,MAAM,CAAC,CAAA;AACzF,IAAA,sBAAA,CAAuB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,IAAI,OAAO,CAAA;AAAA,EACvD,CAAC,CAAA;AACH","file":"inject-session-UEH5MAKU.js","sourcesContent":["/**\n * M51 (agent-builder) — inject a SYNTHETIC user+assistant pair into a session's persisted transcript\n * WITHOUT running an LLM turn. This is the Codex review-exit mechanism (`exit_success.xml` appended to\n * the parent thread history so follow-ups like \"fix finding 2\" work): the pair chains onto the DAG\n * leaf (M50 pattern) and the in-memory cache is invalidated so the NEXT send re-hydrates with it.\n */\nimport type { SessionStore } from \"../../types/session-store.js\";\nimport { SessionTranscript } from \"../persistence/session-transcript.js\";\nimport { enqueueSessionWrite, invalidateSessionCache } from \"./agent-session.js\";\nimport type { CompactLocation } from \"./compact-session.js\";\n\nexport async function injectSessionTurn(opts: {\n store: SessionStore;\n loc: CompactLocation;\n sessionId: string;\n userText: string;\n assistantText: string;\n}): Promise<void> {\n await enqueueSessionWrite(opts.loc.cwd, opts.loc.agentId, async () => {\n const prior = await opts.store.readRecords(opts.loc.agentId);\n const transcript = SessionTranscript.fromRecords(prior, {\n cwd: opts.loc.cwd,\n sessionId: opts.sessionId,\n model: opts.loc.model ?? \"unknown\",\n });\n transcript.appendUserTurn(opts.userText);\n transcript.appendAssistantTurn({ text: opts.assistantText });\n await opts.store.appendRecords(opts.loc.agentId, transcript.records().slice(prior.length));\n invalidateSessionCache(opts.loc.cwd, opts.loc.agentId);\n });\n}\n"]}
|
|
@@ -5,7 +5,13 @@
|
|
|
5
5
|
* an auth question. The local-run path additionally refuses a provider it has no profile for; that
|
|
6
6
|
* is its policy, not part of this answer, so it stays there and composes with this.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Lives under `internal/` by FOLDER, and is PUBLIC by contract — re-exported from
|
|
9
|
+
* `@theokit/sdk/auth`.
|
|
10
|
+
*
|
|
11
|
+
* Deliberately NOT tagged `@internal`: `tsconfig.base.json` sets `stripInternal: true`, so that tag
|
|
12
|
+
* deletes the declaration from every emitted `.d.ts`. The symbol then exists at runtime and cannot
|
|
13
|
+
* be imported with types — which is the exact defect this module was published to fix, reintroduced
|
|
14
|
+
* one layer down by a docblock. Measured: usetheodev/theokit-sdk#283.
|
|
9
15
|
*/
|
|
10
16
|
/**
|
|
11
17
|
* The provider whose key prefix matches, or `undefined` when none does.
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/auth/api-key-prefix.ts"],"names":[],"mappings":";AAWA,IAAM,QAAA,GAA6C;AAAA,EACjD,QAAA,EAAU,YAAA;AAAA,EACV,SAAA,EAAW,WAAA;AAAA,EACX,KAAA,EAAO;AACT,CAAA;AAYA,IAAM,SAAA,GAAsD,MAAA,CAAO,OAAA,CAAQ,QAAQ,CAAA,CAAE,IAAA;AAAA,EACnF,CAAC,GAAG,CAAA,KAAM,CAAA,CAAE,CAAC,CAAA,CAAE,MAAA,GAAS,CAAA,CAAE,CAAC,CAAA,CAAE;AAC/B,CAAA;AASO,SAAS,yBAAyB,MAAA,EAAgD;AACvF,EAAA,IAAI,MAAA,KAAW,QAAW,OAAO,MAAA;AACjC,EAAA,MAAM,GAAA,GAAM,OAAO,IAAA,EAAK;AACxB,EAAA,IAAI,GAAA,CAAI,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AAC7B,EAAA,KAAA,MAAW,CAAC,MAAA,EAAQ,QAAQ,CAAA,IAAK,SAAA,EAAW;AAC1C,IAAA,IAAI,GAAA,CAAI,UAAA,CAAW,MAAM,CAAA,EAAG,OAAO,QAAA;AAAA,EACrC;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-U3PAW4PL.js","sourcesContent":["/**\n * \"Which provider issued this key?\" — the pure prefix answer.\n *\n * Lives in `auth/` and not beside the local-run helper that used to own it, because the question is\n * an auth question. The local-run path additionally refuses a provider it has no profile for; that\n * is its policy, not part of this answer, so it stays there and composes with this.\n *\n * @internal — re-exported from the public `@theokit/sdk/auth` entry.\n */\n\n/** Prefix → provider. Order here is irrelevant: the lookup sorts. */\nconst PREFIXES: Readonly<Record<string, string>> = {\n \"sk-or-\": \"openrouter\",\n \"sk-ant-\": \"anthropic\",\n \"sk-\": \"openai\",\n};\n\n/**\n * Longest first, computed once.\n *\n * The ordering IS the correctness property, so it is derived rather than written down: every\n * OpenRouter and Anthropic key also starts with `sk-`, and a shortest-match-first scan resolves\n * them to OpenAI. That failure is invisible locally — it surfaces as a remote 401 from the wrong\n * endpoint, with a message that says nothing about prefixes. The previous implementation was\n * correct only because the entries happened to be written in a workable order; appending a longer\n * prefix, or sorting the table for readability, would have broken it silently.\n */\nconst BY_LENGTH: ReadonlyArray<readonly [string, string]> = Object.entries(PREFIXES).sort(\n (a, b) => b[0].length - a[0].length,\n);\n\n/**\n * The provider whose key prefix matches, or `undefined` when none does.\n *\n * `undefined` means \"cannot tell\" and never a guess: a wrong guess here routes a real credential to\n * the wrong endpoint. Whitespace-only and empty inputs are \"cannot tell\" too — they are what an\n * empty prompt submits, not a key.\n */\nexport function providerFromApiKeyPrefix(apiKey: string | undefined): string | undefined {\n if (apiKey === undefined) return undefined;\n const key = apiKey.trim();\n if (key.length === 0) return undefined;\n for (const [prefix, provider] of BY_LENGTH) {\n if (key.startsWith(prefix)) return provider;\n }\n return undefined;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/auth/api-key-prefix.ts"],"names":[],"mappings":";;;AAWA,IAAM,QAAA,GAA6C;AAAA,EACjD,QAAA,EAAU,YAAA;AAAA,EACV,SAAA,EAAW,WAAA;AAAA,EACX,KAAA,EAAO;AACT,CAAA;AAYA,IAAM,SAAA,GAAsD,MAAA,CAAO,OAAA,CAAQ,QAAQ,CAAA,CAAE,IAAA;AAAA,EACnF,CAAC,GAAG,CAAA,KAAM,CAAA,CAAE,CAAC,CAAA,CAAE,MAAA,GAAS,CAAA,CAAE,CAAC,CAAA,CAAE;AAC/B,CAAA;AASO,SAAS,yBAAyB,MAAA,EAAgD;AACvF,EAAA,IAAI,MAAA,KAAW,QAAW,OAAO,MAAA;AACjC,EAAA,MAAM,GAAA,GAAM,OAAO,IAAA,EAAK;AACxB,EAAA,IAAI,GAAA,CAAI,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AAC7B,EAAA,KAAA,MAAW,CAAC,MAAA,EAAQ,QAAQ,CAAA,IAAK,SAAA,EAAW;AAC1C,IAAA,IAAI,GAAA,CAAI,UAAA,CAAW,MAAM,CAAA,EAAG,OAAO,QAAA;AAAA,EACrC;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-WVDH34LK.cjs","sourcesContent":["/**\n * \"Which provider issued this key?\" — the pure prefix answer.\n *\n * Lives in `auth/` and not beside the local-run helper that used to own it, because the question is\n * an auth question. The local-run path additionally refuses a provider it has no profile for; that\n * is its policy, not part of this answer, so it stays there and composes with this.\n *\n * @internal — re-exported from the public `@theokit/sdk/auth` entry.\n */\n\n/** Prefix → provider. Order here is irrelevant: the lookup sorts. */\nconst PREFIXES: Readonly<Record<string, string>> = {\n \"sk-or-\": \"openrouter\",\n \"sk-ant-\": \"anthropic\",\n \"sk-\": \"openai\",\n};\n\n/**\n * Longest first, computed once.\n *\n * The ordering IS the correctness property, so it is derived rather than written down: every\n * OpenRouter and Anthropic key also starts with `sk-`, and a shortest-match-first scan resolves\n * them to OpenAI. That failure is invisible locally — it surfaces as a remote 401 from the wrong\n * endpoint, with a message that says nothing about prefixes. The previous implementation was\n * correct only because the entries happened to be written in a workable order; appending a longer\n * prefix, or sorting the table for readability, would have broken it silently.\n */\nconst BY_LENGTH: ReadonlyArray<readonly [string, string]> = Object.entries(PREFIXES).sort(\n (a, b) => b[0].length - a[0].length,\n);\n\n/**\n * The provider whose key prefix matches, or `undefined` when none does.\n *\n * `undefined` means \"cannot tell\" and never a guess: a wrong guess here routes a real credential to\n * the wrong endpoint. Whitespace-only and empty inputs are \"cannot tell\" too — they are what an\n * empty prompt submits, not a key.\n */\nexport function providerFromApiKeyPrefix(apiKey: string | undefined): string | undefined {\n if (apiKey === undefined) return undefined;\n const key = apiKey.trim();\n if (key.length === 0) return undefined;\n for (const [prefix, provider] of BY_LENGTH) {\n if (key.startsWith(prefix)) return provider;\n }\n return undefined;\n}\n"]}
|