@theokit/sdk 5.15.0 → 5.15.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 +12 -0
- package/dist/{agent-DRDGUU6T.js → agent-66U5QCPF.js} +5 -5
- package/dist/{agent-DRDGUU6T.js.map → agent-66U5QCPF.js.map} +1 -1
- package/dist/{agent-B6FQad6P.d.cts → agent-BL4kxgwq.d.cts} +7 -1
- package/dist/{agent-B6C9i_qu.d.ts → agent-ByDx7K30.d.ts} +7 -1
- package/dist/{agent-VI2HITPT.cjs → agent-CB27KF6O.cjs} +6 -6
- package/dist/{agent-VI2HITPT.cjs.map → agent-CB27KF6O.cjs.map} +1 -1
- package/dist/{chunk-IOBHFP2E.js → chunk-26GI3OYA.js} +71 -4
- package/dist/chunk-26GI3OYA.js.map +1 -0
- package/dist/{chunk-64ECM3XM.cjs → chunk-26UQG242.cjs} +49 -49
- package/dist/{chunk-64ECM3XM.cjs.map → chunk-26UQG242.cjs.map} +1 -1
- package/dist/{chunk-DJKGDLYZ.cjs → chunk-3E3VSMB6.cjs} +73 -6
- package/dist/{chunk-DJKGDLYZ.cjs.map → chunk-3E3VSMB6.cjs.map} +1 -1
- package/dist/{chunk-U7PRI3XM.cjs → chunk-FBIDOOJM.cjs} +3 -3
- package/dist/{chunk-U7PRI3XM.cjs.map → chunk-FBIDOOJM.cjs.map} +1 -1
- package/dist/{chunk-ARC2V7NY.js → chunk-O2RCS3SJ.js} +3 -3
- package/dist/{chunk-ARC2V7NY.js.map → chunk-O2RCS3SJ.js.map} +1 -1
- package/dist/{chunk-KMFBNKCT.cjs → chunk-TRPRTZEH.cjs} +4 -4
- package/dist/{chunk-KMFBNKCT.cjs.map → chunk-TRPRTZEH.cjs.map} +1 -1
- package/dist/{chunk-23SS4ID4.js → chunk-VNRNZ3WI.js} +3 -3
- package/dist/{chunk-23SS4ID4.js.map → chunk-VNRNZ3WI.js.map} +1 -1
- package/dist/{chunk-5M5GQYBM.js → chunk-ZQWRUJHE.js} +6 -6
- package/dist/{chunk-5M5GQYBM.js.map → chunk-ZQWRUJHE.js.map} +1 -1
- package/dist/{compact-session-NX7HUNTB.cjs → compact-session-CHBJOYWP.cjs} +12 -12
- package/dist/{compact-session-NX7HUNTB.cjs.map → compact-session-CHBJOYWP.cjs.map} +1 -1
- package/dist/{compact-session-Q5IGNFPW.js → compact-session-F3J3FMEU.js} +3 -3
- package/dist/{compact-session-Q5IGNFPW.js.map → compact-session-F3J3FMEU.js.map} +1 -1
- package/dist/{cron-Bh3aWgQ2.d.cts → cron-B7KH9sHW.d.cts} +1 -1
- package/dist/{cron-CCDxeeFZ.d.ts → cron-FEO7UAQF.d.ts} +1 -1
- package/dist/cron.cjs +5 -5
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +4 -4
- package/dist/eval.cjs +4 -4
- package/dist/eval.js +3 -3
- package/dist/index.cjs +31 -31
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -7
- package/dist/{inject-session-4ROYLZHY.js → inject-session-LC2TROHM.js} +3 -3
- package/dist/{inject-session-4ROYLZHY.js.map → inject-session-LC2TROHM.js.map} +1 -1
- package/dist/{inject-session-AWKDCGHV.cjs → inject-session-T4RXANG3.cjs} +4 -4
- package/dist/{inject-session-AWKDCGHV.cjs.map → inject-session-T4RXANG3.cjs.map} +1 -1
- package/dist/internal/llm/hermes-tool-extract.d.ts +2 -0
- package/dist/subagents-loader.d.cts +1 -1
- package/dist/subagents-loader.d.ts +1 -1
- package/dist/types/hooks.d.ts +7 -1
- package/package.json +1 -1
- package/dist/chunk-IOBHFP2E.js.map +0 -1
|
@@ -814,7 +814,7 @@ async function resolveBedrockToken(region) {
|
|
|
814
814
|
return cachedToken.value;
|
|
815
815
|
}
|
|
816
816
|
try {
|
|
817
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
817
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-3E3VSMB6.cjs', document.baseURI).href)));
|
|
818
818
|
const gen = r("@aws/bedrock-token-generator");
|
|
819
819
|
if (typeof gen.getToken !== "function") return void 0;
|
|
820
820
|
const providers = r("@aws-sdk/credential-providers");
|
|
@@ -1542,16 +1542,38 @@ function pickString(record, key) {
|
|
|
1542
1542
|
// src/internal/llm/hermes-tool-extract.ts
|
|
1543
1543
|
var HERMES_BLOCK = /<function=\s*([^>\s]+)\s*>([\s\S]*?)<\/tool_call>/g;
|
|
1544
1544
|
var HERMES_PARAM = /<parameter=\s*([^>\s]+)\s*>([\s\S]*?)<\/parameter>/g;
|
|
1545
|
+
var CTRL_CALL_SRC = String.raw`print\(\s*default_api\.([A-Za-z_]\w*)\(([\s\S]*?)\)\s*\)(?=\s*(?:print\(\s*default_api\.|<ctrl\d+>|$))`;
|
|
1546
|
+
var CTRL_BLOCK = new RegExp(`<ctrl42>call\\s*((?:${CTRL_CALL_SRC}\\s*)+)(?=<ctrl\\d+>|$)`, "g");
|
|
1547
|
+
var CTRL_MARKER = "<ctrl42>call";
|
|
1548
|
+
var CTRL_PREFIX = "print(default_api.";
|
|
1545
1549
|
function extractHermesToolCalls(content, makeId, allowedToolNames) {
|
|
1546
1550
|
const isPromoted = (name) => name.length > 0 && (allowedToolNames === void 0 || allowedToolNames.has(name));
|
|
1547
1551
|
const toolCalls = [];
|
|
1548
1552
|
const droppedNames = [];
|
|
1553
|
+
const formats = /* @__PURE__ */ new Set();
|
|
1554
|
+
for (const block of content.matchAll(CTRL_BLOCK)) {
|
|
1555
|
+
for (const call of (block[1] ?? "").matchAll(new RegExp(CTRL_CALL_SRC, "g"))) {
|
|
1556
|
+
const name = call[1] ?? "";
|
|
1557
|
+
if (!isPromoted(name)) {
|
|
1558
|
+
if (allowedToolNames !== void 0) droppedNames.push(name);
|
|
1559
|
+
continue;
|
|
1560
|
+
}
|
|
1561
|
+
toolCalls.push({
|
|
1562
|
+
type: "tool_use",
|
|
1563
|
+
id: makeId(),
|
|
1564
|
+
name,
|
|
1565
|
+
input: parseCtrlArgs(call[2] ?? "")
|
|
1566
|
+
});
|
|
1567
|
+
formats.add("gemini-ctrl42");
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1549
1570
|
for (const block of content.matchAll(HERMES_BLOCK)) {
|
|
1550
1571
|
const name = (block[1] ?? "").trim();
|
|
1551
1572
|
if (!isPromoted(name)) {
|
|
1552
1573
|
if (name.length > 0 && allowedToolNames !== void 0) droppedNames.push(name);
|
|
1553
1574
|
continue;
|
|
1554
1575
|
}
|
|
1576
|
+
formats.add("hermes");
|
|
1555
1577
|
toolCalls.push({
|
|
1556
1578
|
type: "tool_use",
|
|
1557
1579
|
id: makeId(),
|
|
@@ -1560,10 +1582,37 @@ function extractHermesToolCalls(content, makeId, allowedToolNames) {
|
|
|
1560
1582
|
});
|
|
1561
1583
|
}
|
|
1562
1584
|
const residualText = toolCalls.length === 0 ? content : content.replace(
|
|
1585
|
+
CTRL_BLOCK,
|
|
1586
|
+
(_full, calls) => keepUnpromotedCtrl(calls, isPromoted)
|
|
1587
|
+
).replace(
|
|
1563
1588
|
HERMES_BLOCK,
|
|
1564
1589
|
(full, rawName) => isPromoted((rawName ?? "").trim()) ? "" : full
|
|
1565
1590
|
).trim();
|
|
1566
|
-
return { toolCalls, residualText, droppedNames };
|
|
1591
|
+
return { toolCalls, residualText, droppedNames, formats: [...formats] };
|
|
1592
|
+
}
|
|
1593
|
+
function keepUnpromotedCtrl(calls, isPromoted) {
|
|
1594
|
+
const kept = [...calls.matchAll(new RegExp(CTRL_CALL_SRC, "g"))].filter((c) => !isPromoted(c[1] ?? "")).map((c) => c[0]);
|
|
1595
|
+
return kept.length === 0 ? "" : `<ctrl42>call
|
|
1596
|
+
${kept.join("\n")}`;
|
|
1597
|
+
}
|
|
1598
|
+
var CTRL_ARG = /\s*([A-Za-z_]\w*)\s*=\s*("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^,]+)\s*(?:,|$)/y;
|
|
1599
|
+
function parseCtrlArgs(raw) {
|
|
1600
|
+
const input = {};
|
|
1601
|
+
CTRL_ARG.lastIndex = 0;
|
|
1602
|
+
for (let m = CTRL_ARG.exec(raw); m !== null; m = CTRL_ARG.exec(raw)) {
|
|
1603
|
+
input[m[1]] = parseCtrlValue(m[2].trim());
|
|
1604
|
+
}
|
|
1605
|
+
return chunkYSTXFWQE_cjs.sanitizeToolInput(input, { trim: true }).value;
|
|
1606
|
+
}
|
|
1607
|
+
function parseCtrlValue(v) {
|
|
1608
|
+
const q = v[0];
|
|
1609
|
+
if ((q === '"' || q === "'") && v.length >= 2 && v.endsWith(q)) {
|
|
1610
|
+
return v.slice(1, -1).replace(/\\(.)/g, (_, c) => c === "n" ? "\n" : c === "t" ? " " : c);
|
|
1611
|
+
}
|
|
1612
|
+
if (v === "True") return true;
|
|
1613
|
+
if (v === "False") return false;
|
|
1614
|
+
if (v === "None") return null;
|
|
1615
|
+
return /^-?\d+(\.\d+)?$/.test(v) ? Number(v) : v;
|
|
1567
1616
|
}
|
|
1568
1617
|
function parseHermesParams(inner) {
|
|
1569
1618
|
const input = {};
|
|
@@ -1581,6 +1630,10 @@ var isStreamWs = (c) => c === " " || c === " " || c === "\n" || c === "\r";
|
|
|
1581
1630
|
function streamToolCallBufferState(held, allowedToolNames, cap = DEFAULT_STREAM_BUFFER_CAP) {
|
|
1582
1631
|
if (allowedToolNames.size === 0) return "impossible";
|
|
1583
1632
|
const t = held.trimStart();
|
|
1633
|
+
if (t.startsWith("<c")) return ctrlState(t, held.length, allowedToolNames, cap);
|
|
1634
|
+
return functionMarkerState(held, t, allowedToolNames, cap);
|
|
1635
|
+
}
|
|
1636
|
+
function functionMarkerState(held, t, allowedToolNames, cap) {
|
|
1584
1637
|
if (t.length < STREAM_MARKER.length) {
|
|
1585
1638
|
return STREAM_MARKER.startsWith(t) ? "possible" : "impossible";
|
|
1586
1639
|
}
|
|
@@ -1592,6 +1645,20 @@ function streamToolCallBufferState(held, allowedToolNames, cap = DEFAULT_STREAM_
|
|
|
1592
1645
|
if (!nameOk) return "impossible";
|
|
1593
1646
|
return held.length > cap ? "impossible" : "possible";
|
|
1594
1647
|
}
|
|
1648
|
+
function ctrlState(t, heldLength, allowedToolNames, cap) {
|
|
1649
|
+
if (t.length < CTRL_MARKER.length) return CTRL_MARKER.startsWith(t) ? "possible" : "impossible";
|
|
1650
|
+
if (!t.startsWith(CTRL_MARKER)) return "impossible";
|
|
1651
|
+
const rest = t.slice(CTRL_MARKER.length).trimStart();
|
|
1652
|
+
if (rest.length <= CTRL_PREFIX.length)
|
|
1653
|
+
return CTRL_PREFIX.startsWith(rest) ? "possible" : "impossible";
|
|
1654
|
+
if (!rest.startsWith(CTRL_PREFIX)) return "impossible";
|
|
1655
|
+
const afterPrefix = rest.slice(CTRL_PREFIX.length);
|
|
1656
|
+
const paren = afterPrefix.indexOf("(");
|
|
1657
|
+
const name = paren === -1 ? afterPrefix : afterPrefix.slice(0, paren);
|
|
1658
|
+
if (!/^\w*$/.test(name)) return "impossible";
|
|
1659
|
+
const nameOk = paren === -1 ? someToolNameStartsWith(allowedToolNames, name) : allowedToolNames.has(name);
|
|
1660
|
+
return nameOk && heldLength <= cap ? "possible" : "impossible";
|
|
1661
|
+
}
|
|
1595
1662
|
function parseStreamMarkerName(t) {
|
|
1596
1663
|
let cursor = STREAM_MARKER.length;
|
|
1597
1664
|
while (cursor < t.length && isStreamWs(t[cursor])) cursor += 1;
|
|
@@ -1947,7 +2014,7 @@ var OpenAIStreamAccumulator = class {
|
|
|
1947
2014
|
text = recovered.residualText;
|
|
1948
2015
|
stopReason = "tool_use";
|
|
1949
2016
|
chunkRNXXYF22_cjs.diag(
|
|
1950
|
-
`[theokit-sdk] recovered ${recovered.toolCalls.length} leaked tool call(s) from assistant content (provider="${this.providerName}", names=${recovered.toolCalls.map((c) => c.name).join(",")})
|
|
2017
|
+
`[theokit-sdk] recovered ${recovered.toolCalls.length} leaked tool call(s) from assistant content (provider="${this.providerName}", format=${recovered.formats.join(",") || "hermes"}, names=${recovered.toolCalls.map((c) => c.name).join(",")})
|
|
1951
2018
|
`
|
|
1952
2019
|
);
|
|
1953
2020
|
}
|
|
@@ -2708,7 +2775,7 @@ async function resolveVertexAccessToken() {
|
|
|
2708
2775
|
async function getAuthClientOrThrow() {
|
|
2709
2776
|
let mod;
|
|
2710
2777
|
try {
|
|
2711
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
2778
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-3E3VSMB6.cjs', document.baseURI).href)));
|
|
2712
2779
|
mod = r("google-auth-library");
|
|
2713
2780
|
} catch (err) {
|
|
2714
2781
|
const isModuleMissing = err instanceof Error && (err.message.includes("Cannot find module") || err.code === "MODULE_NOT_FOUND");
|
|
@@ -3561,5 +3628,5 @@ exports.shouldUseRealLocalRuntime = shouldUseRealLocalRuntime;
|
|
|
3561
3628
|
exports.trustFilePath = trustFilePath;
|
|
3562
3629
|
exports.tryFirstEvent = tryFirstEvent;
|
|
3563
3630
|
exports.validateApiKeyShape = validateApiKeyShape;
|
|
3564
|
-
//# sourceMappingURL=chunk-
|
|
3565
|
-
//# sourceMappingURL=chunk-
|
|
3631
|
+
//# sourceMappingURL=chunk-3E3VSMB6.cjs.map
|
|
3632
|
+
//# sourceMappingURL=chunk-3E3VSMB6.cjs.map
|