@theokit/sdk 4.41.1 → 4.42.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 +60 -0
- package/dist/{agent-JDJEBJHU.cjs → agent-DRUORJTU.cjs} +8 -7
- package/dist/{agent-JDJEBJHU.cjs.map → agent-DRUORJTU.cjs.map} +1 -1
- package/dist/{agent-LVKAYADR.js → agent-MVYGMWPM.js} +7 -6
- package/dist/{agent-LVKAYADR.js.map → agent-MVYGMWPM.js.map} +1 -1
- package/dist/{chunk-RPL3POFZ.cjs → chunk-4OQXDCMN.cjs} +50 -380
- package/dist/chunk-4OQXDCMN.cjs.map +1 -0
- package/dist/{chunk-ZO2L5U6F.cjs → chunk-FAUKVJCC.cjs} +3 -3
- package/dist/{chunk-ZO2L5U6F.cjs.map → chunk-FAUKVJCC.cjs.map} +1 -1
- package/dist/chunk-GAXYZXYY.cjs +352 -0
- package/dist/chunk-GAXYZXYY.cjs.map +1 -0
- package/dist/{chunk-GTLH2NI2.cjs → chunk-HLGEXZZP.cjs} +5 -5
- package/dist/{chunk-GTLH2NI2.cjs.map → chunk-HLGEXZZP.cjs.map} +1 -1
- package/dist/{chunk-AUMSEL33.js → chunk-O67XODD5.js} +3 -3
- package/dist/{chunk-AUMSEL33.js.map → chunk-O67XODD5.js.map} +1 -1
- package/dist/{chunk-FMIKUGF2.cjs → chunk-QFFNMJAS.cjs} +5 -5
- package/dist/{chunk-FMIKUGF2.cjs.map → chunk-QFFNMJAS.cjs.map} +1 -1
- package/dist/{chunk-UTYCG4RB.js → chunk-TDDRPFO3.js} +3 -3
- package/dist/{chunk-UTYCG4RB.js.map → chunk-TDDRPFO3.js.map} +1 -1
- package/dist/{chunk-IMX5YODO.js → chunk-UJ7HK7BX.js} +3 -3
- package/dist/{chunk-IMX5YODO.js.map → chunk-UJ7HK7BX.js.map} +1 -1
- package/dist/{chunk-DHLVOLUX.js → chunk-V5V5A6B7.js} +12 -342
- package/dist/chunk-V5V5A6B7.js.map +1 -0
- package/dist/chunk-ZZAAQOAZ.js +344 -0
- package/dist/chunk-ZZAAQOAZ.js.map +1 -0
- package/dist/{compact-session-65XCKO6H.js → compact-session-GF2CBKXB.js} +4 -4
- package/dist/{compact-session-65XCKO6H.js.map → compact-session-GF2CBKXB.js.map} +1 -1
- package/dist/{compact-session-OU6SRPVJ.cjs → compact-session-UUCBTBCZ.cjs} +12 -12
- package/dist/{compact-session-OU6SRPVJ.cjs.map → compact-session-UUCBTBCZ.cjs.map} +1 -1
- package/dist/context/index.cjs +35 -0
- package/dist/context/index.cjs.map +1 -0
- package/dist/context/index.d.cts +78 -0
- package/dist/context/index.d.ts +78 -0
- package/dist/context/index.js +18 -0
- package/dist/context/index.js.map +1 -0
- package/dist/cron.cjs +7 -6
- package/dist/cron.js +6 -5
- package/dist/eval.cjs +6 -5
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +5 -4
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +34 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-DDC36KKP.cjs → inject-session-I3HK3AHB.cjs} +4 -4
- package/dist/{inject-session-DDC36KKP.cjs.map → inject-session-I3HK3AHB.cjs.map} +1 -1
- package/dist/{inject-session-UBM4KVSV.js → inject-session-NR64GB3T.js} +3 -3
- package/dist/{inject-session-UBM4KVSV.js.map → inject-session-NR64GB3T.js.map} +1 -1
- package/dist/internal/runtime/context/path-containment.d.ts +24 -0
- package/package.json +23 -12
- package/dist/chunk-DHLVOLUX.js.map +0 -1
- package/dist/chunk-RPL3POFZ.cjs.map +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkFAUKVJCC_cjs = require('./chunk-FAUKVJCC.cjs');
|
|
3
4
|
var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
|
|
4
5
|
var chunkKCQUYQ3V_cjs = require('./chunk-KCQUYQ3V.cjs');
|
|
5
|
-
var chunkZO2L5U6F_cjs = require('./chunk-ZO2L5U6F.cjs');
|
|
6
6
|
var chunkNRA36JKG_cjs = require('./chunk-NRA36JKG.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkQFFNMJAS_cjs = require('./chunk-QFFNMJAS.cjs');
|
|
8
8
|
var chunkGH52NOCL_cjs = require('./chunk-GH52NOCL.cjs');
|
|
9
9
|
var chunkHECR7KF5_cjs = require('./chunk-HECR7KF5.cjs');
|
|
10
10
|
var chunkBBZYXVLZ_cjs = require('./chunk-BBZYXVLZ.cjs');
|
|
11
|
+
var chunkGAXYZXYY_cjs = require('./chunk-GAXYZXYY.cjs');
|
|
11
12
|
var chunk6X2HUT4A_cjs = require('./chunk-6X2HUT4A.cjs');
|
|
12
13
|
var chunk7PESI6YD_cjs = require('./chunk-7PESI6YD.cjs');
|
|
13
14
|
var chunk6JSIEDKL_cjs = require('./chunk-6JSIEDKL.cjs');
|
|
14
15
|
var chunkB4YA6BRS_cjs = require('./chunk-B4YA6BRS.cjs');
|
|
15
16
|
var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
|
|
16
|
-
var chunkYPEPCZHF_cjs = require('./chunk-YPEPCZHF.cjs');
|
|
17
17
|
var chunkVJ26EKGJ_cjs = require('./chunk-VJ26EKGJ.cjs');
|
|
18
18
|
var chunkOEFFPR2S_cjs = require('./chunk-OEFFPR2S.cjs');
|
|
19
19
|
var chunkWCXOKGOQ_cjs = require('./chunk-WCXOKGOQ.cjs');
|
|
@@ -1616,7 +1616,7 @@ function createRealCloudRun(options) {
|
|
|
1616
1616
|
conversation: []
|
|
1617
1617
|
};
|
|
1618
1618
|
const apiKey = resolveApiKey(options.agentOptions.apiKey);
|
|
1619
|
-
const baseUrl =
|
|
1619
|
+
const baseUrl = chunkQFFNMJAS_cjs.getConfiguredBaseUrl();
|
|
1620
1620
|
const handle = new RealCloudRun(
|
|
1621
1621
|
{
|
|
1622
1622
|
id,
|
|
@@ -1699,7 +1699,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1699
1699
|
async consumeStream(response) {
|
|
1700
1700
|
let finalStatus = "finished";
|
|
1701
1701
|
let finalText = "";
|
|
1702
|
-
for await (const record of
|
|
1702
|
+
for await (const record of chunkQFFNMJAS_cjs.parseSseStream(response.body, this.controller.signal)) {
|
|
1703
1703
|
const parsed = safeParse(record.data);
|
|
1704
1704
|
if (parsed === void 0) continue;
|
|
1705
1705
|
const update = this.applyRecord(record.event, parsed);
|
|
@@ -1808,7 +1808,7 @@ var CloudAgent = class {
|
|
|
1808
1808
|
*/
|
|
1809
1809
|
isFixtureMode() {
|
|
1810
1810
|
const apiKey = resolveApiKey(this.options.apiKey);
|
|
1811
|
-
return
|
|
1811
|
+
return chunkQFFNMJAS_cjs.isFixtureApiKey(apiKey) && chunkQFFNMJAS_cjs.getConfiguredBaseUrl() === void 0;
|
|
1812
1812
|
}
|
|
1813
1813
|
// SE9 — integrated structured output; delegates to the shared helper.
|
|
1814
1814
|
generate(message, options) {
|
|
@@ -1859,7 +1859,7 @@ var CloudAgent = class {
|
|
|
1859
1859
|
const userText = typeof message === "string" ? message : message.text;
|
|
1860
1860
|
const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
|
|
1861
1861
|
const apiKey = resolveApiKey(this.options.apiKey);
|
|
1862
|
-
const useRealRuntime = apiKey !== void 0 && !
|
|
1862
|
+
const useRealRuntime = apiKey !== void 0 && !chunkQFFNMJAS_cjs.isFixtureApiKey(apiKey) && chunkQFFNMJAS_cjs.getConfiguredBaseUrl() !== void 0;
|
|
1863
1863
|
return useRealRuntime ? createRealCloudRun({
|
|
1864
1864
|
agentId: this.agentId,
|
|
1865
1865
|
model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
|
|
@@ -2679,7 +2679,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2679
2679
|
try {
|
|
2680
2680
|
const partial = await safeConversation(run);
|
|
2681
2681
|
if (partial !== void 0) {
|
|
2682
|
-
|
|
2682
|
+
chunkFAUKVJCC_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2683
2683
|
userText,
|
|
2684
2684
|
conversation: partial
|
|
2685
2685
|
});
|
|
@@ -2689,11 +2689,11 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2689
2689
|
chunkZHPET3LZ_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2690
2690
|
`);
|
|
2691
2691
|
}
|
|
2692
|
-
await
|
|
2692
|
+
await chunkFAUKVJCC_cjs.flushSessionWrites();
|
|
2693
2693
|
return;
|
|
2694
2694
|
}
|
|
2695
2695
|
if (result.result !== void 0) {
|
|
2696
|
-
|
|
2696
|
+
chunkFAUKVJCC_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2697
2697
|
}
|
|
2698
2698
|
const conversation = await safeConversation(run);
|
|
2699
2699
|
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
@@ -2704,7 +2704,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2704
2704
|
}
|
|
2705
2705
|
const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
|
|
2706
2706
|
const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
|
|
2707
|
-
|
|
2707
|
+
chunkFAUKVJCC_cjs.persistTurnToTranscript(
|
|
2708
2708
|
sessionStore,
|
|
2709
2709
|
{ cwd: workspaceCwd, agentId, model },
|
|
2710
2710
|
agentId,
|
|
@@ -2716,7 +2716,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2716
2716
|
// The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
|
|
2717
2717
|
// `contextWindow` here would budget against a number the clamp already rejected.
|
|
2718
2718
|
contextWindow: effectiveWindow,
|
|
2719
|
-
summarize:
|
|
2719
|
+
summarize: chunkQFFNMJAS_cjs.buildDefaultSummarizer({
|
|
2720
2720
|
agentModel: model,
|
|
2721
2721
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
2722
2722
|
})
|
|
@@ -2758,7 +2758,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2758
2758
|
agentId,
|
|
2759
2759
|
runId: result.id
|
|
2760
2760
|
});
|
|
2761
|
-
await
|
|
2761
|
+
await chunkFAUKVJCC_cjs.flushSessionWrites();
|
|
2762
2762
|
}
|
|
2763
2763
|
async function safeConversation(run) {
|
|
2764
2764
|
try {
|
|
@@ -3345,7 +3345,7 @@ var HISTOGRAM_NAMES = {
|
|
|
3345
3345
|
};
|
|
3346
3346
|
function safeRequire(moduleName) {
|
|
3347
3347
|
try {
|
|
3348
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3348
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-4OQXDCMN.cjs', document.baseURI).href)));
|
|
3349
3349
|
return r(moduleName);
|
|
3350
3350
|
} catch {
|
|
3351
3351
|
return void 0;
|
|
@@ -3570,7 +3570,7 @@ var cachedOtel;
|
|
|
3570
3570
|
function loadOtel() {
|
|
3571
3571
|
if (cachedOtel === void 0) {
|
|
3572
3572
|
try {
|
|
3573
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3573
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-4OQXDCMN.cjs', document.baseURI).href)));
|
|
3574
3574
|
const mod = r("@opentelemetry/api");
|
|
3575
3575
|
cachedOtel = mod;
|
|
3576
3576
|
} catch {
|
|
@@ -3871,52 +3871,6 @@ function splitFrontmatter(raw, source, errorCodePrefix) {
|
|
|
3871
3871
|
body: raw.slice(match[0].length)
|
|
3872
3872
|
};
|
|
3873
3873
|
}
|
|
3874
|
-
var HEAD_RATIO = 0.7;
|
|
3875
|
-
var TAIL_RATIO = 0.2;
|
|
3876
|
-
var MARKER = "\n\n\u2026[truncated by theokit]\n\n";
|
|
3877
|
-
var DEFAULT_MAX_BYTES_PER_FILE = 4e4;
|
|
3878
|
-
function truncateWithMarker(content, max) {
|
|
3879
|
-
if (content.length <= max) {
|
|
3880
|
-
return { truncated: false, finalContent: content };
|
|
3881
|
-
}
|
|
3882
|
-
if (max <= MARKER.length) {
|
|
3883
|
-
return { truncated: true, finalContent: content.slice(0, max) };
|
|
3884
|
-
}
|
|
3885
|
-
const budget = max - MARKER.length;
|
|
3886
|
-
const headBytes = Math.floor(budget * (HEAD_RATIO / (HEAD_RATIO + TAIL_RATIO)));
|
|
3887
|
-
const tailBytes = budget - headBytes;
|
|
3888
|
-
return {
|
|
3889
|
-
truncated: true,
|
|
3890
|
-
finalContent: content.slice(0, headBytes) + MARKER + content.slice(-tailBytes)
|
|
3891
|
-
};
|
|
3892
|
-
}
|
|
3893
|
-
async function loadPlainMarkdown(absPath, opts = {}) {
|
|
3894
|
-
const max = opts.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
|
|
3895
|
-
let content;
|
|
3896
|
-
try {
|
|
3897
|
-
content = await promises.readFile(absPath, "utf8");
|
|
3898
|
-
} catch {
|
|
3899
|
-
return void 0;
|
|
3900
|
-
}
|
|
3901
|
-
const { truncated, finalContent } = truncateWithMarker(content, max);
|
|
3902
|
-
if (truncated) {
|
|
3903
|
-
emitTruncationCounter(absPath);
|
|
3904
|
-
}
|
|
3905
|
-
return {
|
|
3906
|
-
source: absPath,
|
|
3907
|
-
content: finalContent,
|
|
3908
|
-
originalBytes: content.length,
|
|
3909
|
-
truncated
|
|
3910
|
-
};
|
|
3911
|
-
}
|
|
3912
|
-
function emitTruncationCounter(source) {
|
|
3913
|
-
const tracer = globalThis.__theokit_tracer;
|
|
3914
|
-
if (tracer?.inc === void 0) return;
|
|
3915
|
-
try {
|
|
3916
|
-
tracer.inc("context_files_truncated", { file: source });
|
|
3917
|
-
} catch {
|
|
3918
|
-
}
|
|
3919
|
-
}
|
|
3920
3874
|
|
|
3921
3875
|
// src/internal/runtime/context/context-aggregator.ts
|
|
3922
3876
|
var DEFAULT_MAX_BYTES_TOTAL = 12e4;
|
|
@@ -3936,7 +3890,7 @@ function applyAggregateCap(sources, maxTotal) {
|
|
|
3936
3890
|
}
|
|
3937
3891
|
const remaining = maxTotal - totalBytes;
|
|
3938
3892
|
if (remaining > 0) {
|
|
3939
|
-
const { finalContent } = truncateWithMarker(s.content, remaining);
|
|
3893
|
+
const { finalContent } = chunkGAXYZXYY_cjs.truncateWithMarker(s.content, remaining);
|
|
3940
3894
|
kept.push({ ...s, content: finalContent, truncated: true });
|
|
3941
3895
|
totalBytes = maxTotal;
|
|
3942
3896
|
} else {
|
|
@@ -3956,291 +3910,6 @@ function emitTotalDropCounter(droppedSources) {
|
|
|
3956
3910
|
} catch {
|
|
3957
3911
|
}
|
|
3958
3912
|
}
|
|
3959
|
-
var IMPORT_RE = /^@(\S+)\s*$/gm;
|
|
3960
|
-
var MAX_HOPS = 5;
|
|
3961
|
-
function realOrResolved(path) {
|
|
3962
|
-
try {
|
|
3963
|
-
return fs.realpathSync(path);
|
|
3964
|
-
} catch {
|
|
3965
|
-
return path;
|
|
3966
|
-
}
|
|
3967
|
-
}
|
|
3968
|
-
function insideRoot(target, root) {
|
|
3969
|
-
const rel = path.relative(realOrResolved(root), realOrResolved(target));
|
|
3970
|
-
return rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel);
|
|
3971
|
-
}
|
|
3972
|
-
async function resolveImports(content, basePath, opts) {
|
|
3973
|
-
if (opts.depth >= MAX_HOPS) {
|
|
3974
|
-
return `${content}
|
|
3975
|
-
|
|
3976
|
-
\u2026[@import depth limit ${MAX_HOPS} reached]
|
|
3977
|
-
|
|
3978
|
-
`;
|
|
3979
|
-
}
|
|
3980
|
-
const baseDir = path.dirname(basePath);
|
|
3981
|
-
return replaceAsync(content, IMPORT_RE, async (raw) => {
|
|
3982
|
-
const absolute = resolveImportPath(raw, baseDir);
|
|
3983
|
-
if (opts.projectRoot !== void 0 && !insideRoot(absolute, opts.projectRoot)) {
|
|
3984
|
-
return `[@import outside the project root, refused: ${raw}]`;
|
|
3985
|
-
}
|
|
3986
|
-
if (opts.visited.has(absolute)) {
|
|
3987
|
-
return `[@import cycle detected: ${raw}]`;
|
|
3988
|
-
}
|
|
3989
|
-
opts.visited.add(absolute);
|
|
3990
|
-
const loaded = await loadPlainMarkdown(absolute, { maxBytesPerFile: opts.maxBytesPerFile });
|
|
3991
|
-
if (loaded === void 0) {
|
|
3992
|
-
return `[@import not found: ${raw}]`;
|
|
3993
|
-
}
|
|
3994
|
-
return resolveImports(loaded.content, absolute, {
|
|
3995
|
-
visited: opts.visited,
|
|
3996
|
-
depth: opts.depth + 1,
|
|
3997
|
-
maxBytesPerFile: opts.maxBytesPerFile,
|
|
3998
|
-
...opts.projectRoot === void 0 ? {} : { projectRoot: opts.projectRoot }
|
|
3999
|
-
});
|
|
4000
|
-
});
|
|
4001
|
-
}
|
|
4002
|
-
function resolveImportPath(raw, baseDir) {
|
|
4003
|
-
if (raw.startsWith("~/")) {
|
|
4004
|
-
return path.resolve(path.join(os.homedir(), raw.slice(2)));
|
|
4005
|
-
}
|
|
4006
|
-
if (path.isAbsolute(raw)) {
|
|
4007
|
-
return path.resolve(raw);
|
|
4008
|
-
}
|
|
4009
|
-
return path.resolve(path.join(baseDir, raw));
|
|
4010
|
-
}
|
|
4011
|
-
async function replaceAsync(content, re, replacer) {
|
|
4012
|
-
const matches = [];
|
|
4013
|
-
const localRe = new RegExp(re.source, re.flags);
|
|
4014
|
-
let m;
|
|
4015
|
-
while ((m = localRe.exec(content)) !== null) {
|
|
4016
|
-
matches.push({ match: m[0], raw: m[1] ?? "", index: m.index });
|
|
4017
|
-
if (m.index === localRe.lastIndex) localRe.lastIndex += 1;
|
|
4018
|
-
}
|
|
4019
|
-
if (matches.length === 0) return content;
|
|
4020
|
-
let result = "";
|
|
4021
|
-
let cursor = 0;
|
|
4022
|
-
for (const entry of matches) {
|
|
4023
|
-
result += content.slice(cursor, entry.index);
|
|
4024
|
-
result += await replacer(entry.raw);
|
|
4025
|
-
cursor = entry.index + entry.match.length;
|
|
4026
|
-
}
|
|
4027
|
-
result += content.slice(cursor);
|
|
4028
|
-
return result;
|
|
4029
|
-
}
|
|
4030
|
-
|
|
4031
|
-
// src/internal/runtime/context/context-glob.ts
|
|
4032
|
-
function globToRegex(glob) {
|
|
4033
|
-
const compiled = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*\//g, "::GLOBSTAR_SLASH::").replace(/\*\*/g, "::GLOBSTAR::").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/::GLOBSTAR_SLASH::/g, "(?:.*/)?").replace(/::GLOBSTAR::/g, ".*");
|
|
4034
|
-
return new RegExp(`^${compiled}$`);
|
|
4035
|
-
}
|
|
4036
|
-
function anyGlobMatches(patterns, paths) {
|
|
4037
|
-
if (patterns.length === 0 || paths.length === 0) return false;
|
|
4038
|
-
const res = patterns.map(globToRegex);
|
|
4039
|
-
return paths.some((p) => res.some((re) => re.test(p)));
|
|
4040
|
-
}
|
|
4041
|
-
|
|
4042
|
-
// src/internal/runtime/context/context-yaml-lite.ts
|
|
4043
|
-
var FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
|
|
4044
|
-
function splitFrontmatter2(content) {
|
|
4045
|
-
const m = FRONTMATTER_RE.exec(content);
|
|
4046
|
-
if (m === null) return { yaml: void 0, body: content };
|
|
4047
|
-
return { yaml: m[1] ?? "", body: m[2] ?? "" };
|
|
4048
|
-
}
|
|
4049
|
-
function parseSimpleYaml2(yaml) {
|
|
4050
|
-
const out = {};
|
|
4051
|
-
const lines = yaml.split(/\r?\n/);
|
|
4052
|
-
let i = 0;
|
|
4053
|
-
while (i < lines.length) {
|
|
4054
|
-
const line = lines[i];
|
|
4055
|
-
i += 1;
|
|
4056
|
-
if (line === void 0) continue;
|
|
4057
|
-
const trimmed = line.trim();
|
|
4058
|
-
if (trimmed === "" || trimmed.startsWith("#")) continue;
|
|
4059
|
-
const colon = trimmed.indexOf(":");
|
|
4060
|
-
if (colon === -1) throw new Error(`Invalid YAML line: ${trimmed}`);
|
|
4061
|
-
const key = trimmed.slice(0, colon).trim();
|
|
4062
|
-
const rest = trimmed.slice(colon + 1).trim();
|
|
4063
|
-
if (rest === "") {
|
|
4064
|
-
const items = [];
|
|
4065
|
-
while (i < lines.length) {
|
|
4066
|
-
const next = lines[i];
|
|
4067
|
-
if (next === void 0) break;
|
|
4068
|
-
const nextTrim = next.trim();
|
|
4069
|
-
if (nextTrim.startsWith("- ")) {
|
|
4070
|
-
items.push(parseScalar(nextTrim.slice(2).trim()));
|
|
4071
|
-
i += 1;
|
|
4072
|
-
} else if (nextTrim === "") {
|
|
4073
|
-
i += 1;
|
|
4074
|
-
} else {
|
|
4075
|
-
break;
|
|
4076
|
-
}
|
|
4077
|
-
}
|
|
4078
|
-
out[key] = items;
|
|
4079
|
-
} else if (rest.startsWith("[") && rest.endsWith("]")) {
|
|
4080
|
-
const inner = rest.slice(1, -1).trim();
|
|
4081
|
-
out[key] = inner === "" ? [] : inner.split(",").map((s) => parseScalar(s.trim().replace(/^["']|["']$/g, "")));
|
|
4082
|
-
} else {
|
|
4083
|
-
out[key] = parseScalar(rest);
|
|
4084
|
-
}
|
|
4085
|
-
}
|
|
4086
|
-
return out;
|
|
4087
|
-
}
|
|
4088
|
-
function parseScalar(s) {
|
|
4089
|
-
if (s === "true") return true;
|
|
4090
|
-
if (s === "false") return false;
|
|
4091
|
-
if (/^-?\d+$/.test(s)) return parseInt(s, 10);
|
|
4092
|
-
return s.replace(/^["']|["']$/g, "");
|
|
4093
|
-
}
|
|
4094
|
-
|
|
4095
|
-
// src/internal/runtime/context/context-mdc-parser.ts
|
|
4096
|
-
var McdFrontmatterSchema = zod.z.object({
|
|
4097
|
-
description: zod.z.string().optional(),
|
|
4098
|
-
globs: zod.z.array(zod.z.string()).optional(),
|
|
4099
|
-
alwaysApply: zod.z.boolean().optional()
|
|
4100
|
-
});
|
|
4101
|
-
function parseMdc(content) {
|
|
4102
|
-
const { yaml, body } = splitFrontmatter2(content);
|
|
4103
|
-
if (yaml === void 0) {
|
|
4104
|
-
return { frontmatter: { alwaysApply: true }, body: content };
|
|
4105
|
-
}
|
|
4106
|
-
try {
|
|
4107
|
-
const parsed = parseSimpleYaml2(yaml);
|
|
4108
|
-
const validated = McdFrontmatterSchema.safeParse(parsed);
|
|
4109
|
-
if (!validated.success) return void 0;
|
|
4110
|
-
return { frontmatter: validated.data, body };
|
|
4111
|
-
} catch {
|
|
4112
|
-
return void 0;
|
|
4113
|
-
}
|
|
4114
|
-
}
|
|
4115
|
-
function shouldActivate(fm, touchedFiles) {
|
|
4116
|
-
if (fm.alwaysApply === true) return true;
|
|
4117
|
-
if (fm.globs === void 0 || fm.globs.length === 0) return false;
|
|
4118
|
-
return anyGlobMatches(fm.globs, touchedFiles);
|
|
4119
|
-
}
|
|
4120
|
-
var RulesFrontmatterSchema = zod.z.object({
|
|
4121
|
-
description: zod.z.string().optional(),
|
|
4122
|
-
paths: zod.z.array(zod.z.string()).optional(),
|
|
4123
|
-
globs: zod.z.array(zod.z.string()).optional(),
|
|
4124
|
-
alwaysApply: zod.z.boolean().optional(),
|
|
4125
|
-
enabled: zod.z.boolean().optional()
|
|
4126
|
-
});
|
|
4127
|
-
function parseRules(content) {
|
|
4128
|
-
const { yaml, body } = splitFrontmatter2(content);
|
|
4129
|
-
if (yaml === void 0) {
|
|
4130
|
-
return { frontmatter: { alwaysApply: true }, body: content };
|
|
4131
|
-
}
|
|
4132
|
-
try {
|
|
4133
|
-
const parsed = parseSimpleYaml2(yaml);
|
|
4134
|
-
const validated = RulesFrontmatterSchema.safeParse(parsed);
|
|
4135
|
-
if (!validated.success) return void 0;
|
|
4136
|
-
return { frontmatter: validated.data, body };
|
|
4137
|
-
} catch {
|
|
4138
|
-
return void 0;
|
|
4139
|
-
}
|
|
4140
|
-
}
|
|
4141
|
-
function shouldActivateRule(fm, inScopePaths) {
|
|
4142
|
-
if (fm.enabled === false) return false;
|
|
4143
|
-
if (fm.alwaysApply === true) return true;
|
|
4144
|
-
const patterns = [...fm.paths ?? [], ...fm.globs ?? []];
|
|
4145
|
-
if (patterns.length === 0) return false;
|
|
4146
|
-
return anyGlobMatches(patterns, inScopePaths);
|
|
4147
|
-
}
|
|
4148
|
-
|
|
4149
|
-
// src/internal/runtime/context/context-discovery-runner.ts
|
|
4150
|
-
async function runDiscovery(opts) {
|
|
4151
|
-
const gitRoot = chunkYPEPCZHF_cjs.findGitRoot(opts.cwd);
|
|
4152
|
-
const specs = opts.specs ?? chunkYPEPCZHF_cjs.DEFAULT_DISCOVERY_SPECS;
|
|
4153
|
-
const out = [];
|
|
4154
|
-
const seenReal = /* @__PURE__ */ new Set();
|
|
4155
|
-
for (const spec of specs) {
|
|
4156
|
-
if (spec.id === "theokit-context") continue;
|
|
4157
|
-
const paths = await resolvePathsForSpec(spec, opts.cwd, gitRoot);
|
|
4158
|
-
for (const path of paths) {
|
|
4159
|
-
if (seenReal.has(path)) continue;
|
|
4160
|
-
seenReal.add(path);
|
|
4161
|
-
const source = await loadOneSource(spec, path, opts, gitRoot);
|
|
4162
|
-
if (source !== void 0) out.push(source);
|
|
4163
|
-
}
|
|
4164
|
-
}
|
|
4165
|
-
return out;
|
|
4166
|
-
}
|
|
4167
|
-
async function resolvePathsForSpec(spec, cwd, gitRoot) {
|
|
4168
|
-
if (spec.scope === "cwd-only") {
|
|
4169
|
-
return chunkYPEPCZHF_cjs.walkUpForFile(cwd, spec.pattern, cwd);
|
|
4170
|
-
}
|
|
4171
|
-
if (spec.scope === "git-root-walk") {
|
|
4172
|
-
return chunkYPEPCZHF_cjs.walkUpForFile(cwd, spec.pattern, gitRoot ?? cwd);
|
|
4173
|
-
}
|
|
4174
|
-
return chunkYPEPCZHF_cjs.walkUpForGlob(cwd, spec.pattern);
|
|
4175
|
-
}
|
|
4176
|
-
async function loadOneSource(spec, path$1, opts, gitRoot) {
|
|
4177
|
-
const relPath = path.relative(gitRoot ?? opts.cwd, path.dirname(path$1));
|
|
4178
|
-
const needsSuffix = spec.scope !== "cwd-only" && relPath !== "" && relPath !== ".";
|
|
4179
|
-
const id = needsSuffix ? `${spec.id}@${relPath}` : spec.id;
|
|
4180
|
-
if (spec.parser === "mdc") {
|
|
4181
|
-
return loadMdcSource(spec, path$1, id, opts);
|
|
4182
|
-
}
|
|
4183
|
-
if (spec.parser === "rules-frontmatter") {
|
|
4184
|
-
return loadRulesSource(spec, path$1, id, opts);
|
|
4185
|
-
}
|
|
4186
|
-
if (spec.parser === "frontmatter-zod") {
|
|
4187
|
-
return void 0;
|
|
4188
|
-
}
|
|
4189
|
-
return loadPlainMarkdownSource(spec, path$1, id, opts, gitRoot);
|
|
4190
|
-
}
|
|
4191
|
-
async function loadParsedSource(spec, path, id, parse, isActive) {
|
|
4192
|
-
let raw;
|
|
4193
|
-
try {
|
|
4194
|
-
raw = await promises.readFile(path, "utf8");
|
|
4195
|
-
} catch {
|
|
4196
|
-
return void 0;
|
|
4197
|
-
}
|
|
4198
|
-
const parsed = parse(raw);
|
|
4199
|
-
if (parsed === void 0 || !isActive(parsed.frontmatter)) return void 0;
|
|
4200
|
-
return { id, source: path, content: parsed.body, priority: spec.priority, truncated: false };
|
|
4201
|
-
}
|
|
4202
|
-
function loadMdcSource(spec, path, id, opts) {
|
|
4203
|
-
return loadParsedSource(
|
|
4204
|
-
spec,
|
|
4205
|
-
path,
|
|
4206
|
-
id,
|
|
4207
|
-
parseMdc,
|
|
4208
|
-
(fm) => shouldActivate(fm, opts.touchedFiles ?? [])
|
|
4209
|
-
);
|
|
4210
|
-
}
|
|
4211
|
-
function loadRulesSource(spec, path, id, opts) {
|
|
4212
|
-
return loadParsedSource(
|
|
4213
|
-
spec,
|
|
4214
|
-
path,
|
|
4215
|
-
id,
|
|
4216
|
-
parseRules,
|
|
4217
|
-
(fm) => shouldActivateRule(fm, opts.touchedFiles ?? [])
|
|
4218
|
-
);
|
|
4219
|
-
}
|
|
4220
|
-
async function loadPlainMarkdownSource(spec, path, id, opts, gitRoot) {
|
|
4221
|
-
const loaded = await loadPlainMarkdown(path, { maxBytesPerFile: opts.maxBytesPerFile });
|
|
4222
|
-
if (loaded === void 0) return void 0;
|
|
4223
|
-
let content = loaded.content;
|
|
4224
|
-
if (spec.followImports) {
|
|
4225
|
-
content = await resolveImports(content, path, {
|
|
4226
|
-
visited: /* @__PURE__ */ new Set([path]),
|
|
4227
|
-
depth: 0,
|
|
4228
|
-
maxBytesPerFile: opts.maxBytesPerFile,
|
|
4229
|
-
// The document carrying the import is repository-controlled, so the repository is the
|
|
4230
|
-
// boundary it may not cross. Without this, `CLAUDE.md` / `GEMINI.md` — the two specs
|
|
4231
|
-
// with `followImports: true` — could name any absolute or `~/` path and have it
|
|
4232
|
-
// inlined into the system prompt.
|
|
4233
|
-
projectRoot: opts.importRoot ?? gitRoot ?? opts.cwd
|
|
4234
|
-
});
|
|
4235
|
-
}
|
|
4236
|
-
return {
|
|
4237
|
-
id,
|
|
4238
|
-
source: path,
|
|
4239
|
-
content,
|
|
4240
|
-
priority: spec.priority,
|
|
4241
|
-
truncated: loaded.truncated
|
|
4242
|
-
};
|
|
4243
|
-
}
|
|
4244
3913
|
var ContextSourceFrontmatterSchema = zod.z.object({
|
|
4245
3914
|
/** Identifier; defaults to filename slug if omitted. */
|
|
4246
3915
|
name: zod.z.string().min(1).optional(),
|
|
@@ -4295,14 +3964,15 @@ var FileContextManager = class {
|
|
|
4295
3964
|
this.lastScope = [...touchedFiles];
|
|
4296
3965
|
const config = await loadContextConfig(this.cwd);
|
|
4297
3966
|
const legacy = await loadSources(config, this.cwd);
|
|
4298
|
-
const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
|
|
3967
|
+
const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunkGAXYZXYY_cjs.DEFAULT_MAX_BYTES_PER_FILE;
|
|
4299
3968
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
4300
|
-
const discovered = await runDiscovery({
|
|
3969
|
+
const discovered = await chunkGAXYZXYY_cjs.runDiscovery({
|
|
4301
3970
|
cwd: this.cwd,
|
|
4302
3971
|
maxBytesPerFile,
|
|
3972
|
+
skipLegacyTheokitContext: true,
|
|
4303
3973
|
touchedFiles
|
|
4304
3974
|
});
|
|
4305
|
-
const legacyAsAggregator = legacy.map((src) => ({
|
|
3975
|
+
const legacyAsAggregator = legacy.filter((src) => src.status !== "excluded").map((src) => ({
|
|
4306
3976
|
id: src.name,
|
|
4307
3977
|
source: src.path,
|
|
4308
3978
|
content: src.tokens.join(""),
|
|
@@ -4436,7 +4106,7 @@ async function loadSources(config, cwd) {
|
|
|
4436
4106
|
continue;
|
|
4437
4107
|
}
|
|
4438
4108
|
const absolute = path.resolve(cwd, source.path);
|
|
4439
|
-
if (!
|
|
4109
|
+
if (!chunkGAXYZXYY_cjs.insideRoot(absolute, cwd)) {
|
|
4440
4110
|
results.push({ ...source, status: "excluded", tokens: [] });
|
|
4441
4111
|
continue;
|
|
4442
4112
|
}
|
|
@@ -6099,7 +5769,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
6099
5769
|
(p) => (
|
|
6100
5770
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
6101
5771
|
// structured content); image blocks pass through untouched.
|
|
6102
|
-
p.type === "tool_result" ? { ...p, content:
|
|
5772
|
+
p.type === "tool_result" ? { ...p, content: chunkQFFNMJAS_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
6103
5773
|
)
|
|
6104
5774
|
);
|
|
6105
5775
|
}
|
|
@@ -6759,12 +6429,12 @@ var FallbackLlmClient = class {
|
|
|
6759
6429
|
let lastError;
|
|
6760
6430
|
for (const client of this.clients) {
|
|
6761
6431
|
if (signal.aborted) throw abortError(signal);
|
|
6762
|
-
const attempt = await
|
|
6432
|
+
const attempt = await chunkQFFNMJAS_cjs.tryFirstEvent(client, request, signal, true);
|
|
6763
6433
|
if (attempt.kind === "handshake_error") {
|
|
6764
6434
|
lastError = attempt.error;
|
|
6765
6435
|
continue;
|
|
6766
6436
|
}
|
|
6767
|
-
return yield*
|
|
6437
|
+
return yield* chunkQFFNMJAS_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
6768
6438
|
}
|
|
6769
6439
|
if (lastError !== void 0) throw lastError;
|
|
6770
6440
|
throw new chunkYULF6FPB_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
@@ -7345,14 +7015,14 @@ function resolveRunProvider(options) {
|
|
|
7345
7015
|
}
|
|
7346
7016
|
const parsedModel = chunkVYHJZVL5_cjs.parseModelId(options.model?.id);
|
|
7347
7017
|
const modelInferredProvider = parsedModel.provider !== void 0 && chunkGLEKLAUW_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
|
|
7348
|
-
const keyInferredProvider =
|
|
7349
|
-
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ??
|
|
7018
|
+
const keyInferredProvider = chunkQFFNMJAS_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
|
|
7019
|
+
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkQFFNMJAS_cjs.detectPrimaryProvider();
|
|
7350
7020
|
const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
|
|
7351
7021
|
return { primary, effectiveModelId };
|
|
7352
7022
|
}
|
|
7353
7023
|
function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
7354
7024
|
if (apiKey === void 0 || apiKey.length === 0) return pools;
|
|
7355
|
-
if (
|
|
7025
|
+
if (chunkQFFNMJAS_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
|
|
7356
7026
|
const existing = pools?.[primary];
|
|
7357
7027
|
if (existing !== void 0 && existing.length > 0) return pools;
|
|
7358
7028
|
return { ...pools ?? {}, [primary]: [apiKey] };
|
|
@@ -7375,7 +7045,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7375
7045
|
const credentialPoolStrategy = options.agentOptions.providers?.credentialPoolStrategy;
|
|
7376
7046
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7377
7047
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7378
|
-
const chain =
|
|
7048
|
+
const chain = chunkQFFNMJAS_cjs.resolveProviderChain({
|
|
7379
7049
|
primary,
|
|
7380
7050
|
...fallback !== void 0 ? { fallback } : {},
|
|
7381
7051
|
...apiKeys !== void 0 ? { apiKeys } : {},
|
|
@@ -7657,7 +7327,7 @@ function buildRealRunOptions(args) {
|
|
|
7657
7327
|
};
|
|
7658
7328
|
}
|
|
7659
7329
|
async function createFixtureRunHelper(args) {
|
|
7660
|
-
const sessionMessages =
|
|
7330
|
+
const sessionMessages = chunkFAUKVJCC_cjs.getSessionMessages(args.inputs.agentId);
|
|
7661
7331
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7662
7332
|
return createLocalRun({
|
|
7663
7333
|
agentId: args.inputs.agentId,
|
|
@@ -7676,7 +7346,7 @@ async function createFixtureRunHelper(args) {
|
|
|
7676
7346
|
}
|
|
7677
7347
|
async function dispatchLocalRun(args) {
|
|
7678
7348
|
const apiKey = resolveApiKey(args.inputs.options.apiKey);
|
|
7679
|
-
if (
|
|
7349
|
+
if (chunkQFFNMJAS_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
7680
7350
|
return createRealLocalRun(
|
|
7681
7351
|
buildRealRunOptions({
|
|
7682
7352
|
inputs: args.inputs,
|
|
@@ -7932,10 +7602,10 @@ async function disposeLocalAgentSession(agent) {
|
|
|
7932
7602
|
agent.lifecycleAbortController.abort();
|
|
7933
7603
|
await chunkYLQQX5W2_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
|
|
7934
7604
|
disposeSessionMcpClients(agent.agentId);
|
|
7935
|
-
await
|
|
7605
|
+
await chunkFAUKVJCC_cjs.flushSessionWrites();
|
|
7936
7606
|
await flushRegistrySaves(agent.workspaceCwd);
|
|
7937
7607
|
await disposeSessionStore(agent.sessionStore);
|
|
7938
|
-
|
|
7608
|
+
chunkFAUKVJCC_cjs.discardSession(agent.workspaceCwd, agent.agentId);
|
|
7939
7609
|
}
|
|
7940
7610
|
async function reloadLocalAgent(agent) {
|
|
7941
7611
|
if (agent.context !== void 0) await agent.context.refresh();
|
|
@@ -8710,7 +8380,7 @@ var LocalAgentMemory = class {
|
|
|
8710
8380
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
8711
8381
|
const cfg = this.options.memory?.activeRecall;
|
|
8712
8382
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
8713
|
-
if (this.breaker === void 0) this.breaker = new
|
|
8383
|
+
if (this.breaker === void 0) this.breaker = new chunkQFFNMJAS_cjs.CircuitBreaker();
|
|
8714
8384
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
8715
8385
|
const result = await runActiveMemory({
|
|
8716
8386
|
userText,
|
|
@@ -9112,8 +8782,8 @@ async function localAgentUsePersonality(args) {
|
|
|
9112
8782
|
registry,
|
|
9113
8783
|
store: args.personalityStore,
|
|
9114
8784
|
invalidateCache: (reason) => args.invalidateCache(reason),
|
|
9115
|
-
appendSessionMessage: (msg) =>
|
|
9116
|
-
clearSession: () =>
|
|
8785
|
+
appendSessionMessage: (msg) => chunkFAUKVJCC_cjs.appendSessionMessage(args.agentId, msg),
|
|
8786
|
+
clearSession: () => chunkFAUKVJCC_cjs.clearSession(args.agentId),
|
|
9117
8787
|
opts: args.opts ?? {}
|
|
9118
8788
|
})
|
|
9119
8789
|
);
|
|
@@ -9467,7 +9137,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9467
9137
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9468
9138
|
await inputs.options.onBeforeSend({
|
|
9469
9139
|
conversationId: inputs.agentId,
|
|
9470
|
-
previousMessageCount:
|
|
9140
|
+
previousMessageCount: chunkFAUKVJCC_cjs.getSessionMessages(inputs.agentId).length
|
|
9471
9141
|
});
|
|
9472
9142
|
}
|
|
9473
9143
|
await inputs.runPreHook(userText);
|
|
@@ -9479,8 +9149,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9479
9149
|
userText,
|
|
9480
9150
|
sendOptions: options
|
|
9481
9151
|
});
|
|
9482
|
-
const priorMessages = [...
|
|
9483
|
-
|
|
9152
|
+
const priorMessages = [...chunkFAUKVJCC_cjs.getSessionMessages(inputs.agentId)];
|
|
9153
|
+
chunkFAUKVJCC_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9484
9154
|
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9485
9155
|
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
|
|
9486
9156
|
const portPathActive = shouldUsePortMemoryPath();
|
|
@@ -9692,7 +9362,7 @@ var LocalAgent = class {
|
|
|
9692
9362
|
);
|
|
9693
9363
|
await acquireLeaseIfPossible(this.sessionStore, this.agentId);
|
|
9694
9364
|
try {
|
|
9695
|
-
await
|
|
9365
|
+
await chunkFAUKVJCC_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
9696
9366
|
await this.personalityStore.hydrate(this.agentId);
|
|
9697
9367
|
} catch (err) {
|
|
9698
9368
|
await releaseLeaseIfPossible(this.sessionStore, this.agentId);
|
|
@@ -10025,7 +9695,7 @@ async function createLocalAgent(options) {
|
|
|
10025
9695
|
if (apiKey === void 0) {
|
|
10026
9696
|
throw new chunkYULF6FPB_cjs.AuthenticationError("Missing API key", { code: "missing_api_key" });
|
|
10027
9697
|
}
|
|
10028
|
-
const willFlowToProvider = !
|
|
9698
|
+
const willFlowToProvider = !chunkQFFNMJAS_cjs.isFixtureApiKey(apiKey) && !chunkQFFNMJAS_cjs.shouldUseRealLocalRuntime(apiKey);
|
|
10029
9699
|
const shape = validateApiKeyShape(apiKey, {
|
|
10030
9700
|
strict: willFlowToProvider,
|
|
10031
9701
|
// `options.model` is already normalized by `runCreateUnderSpan`; `normalizeModel`
|
|
@@ -10036,7 +9706,7 @@ async function createLocalAgent(options) {
|
|
|
10036
9706
|
if (shape.malformed) {
|
|
10037
9707
|
throw new chunkYULF6FPB_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
10038
9708
|
}
|
|
10039
|
-
if (!
|
|
9709
|
+
if (!chunkQFFNMJAS_cjs.isFixtureApiKey(apiKey) && chunkQFFNMJAS_cjs.getConfiguredBaseUrl() === void 0 && !chunkQFFNMJAS_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
10040
9710
|
throw new chunkYULF6FPB_cjs.AuthenticationError("Invalid API key", {
|
|
10041
9711
|
code: "authentication_error"
|
|
10042
9712
|
});
|
|
@@ -10056,11 +9726,11 @@ async function createCloudAgent(options) {
|
|
|
10056
9726
|
if (shape.malformed) {
|
|
10057
9727
|
throw new chunkYULF6FPB_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
10058
9728
|
}
|
|
10059
|
-
const baseUrl =
|
|
9729
|
+
const baseUrl = chunkQFFNMJAS_cjs.getConfiguredBaseUrl();
|
|
10060
9730
|
if (baseUrl === void 0) {
|
|
10061
9731
|
return new CloudAgent(options);
|
|
10062
9732
|
}
|
|
10063
|
-
const response = await
|
|
9733
|
+
const response = await chunkQFFNMJAS_cjs.httpRequest("/v1/agents", {
|
|
10064
9734
|
apiKey,
|
|
10065
9735
|
method: "POST",
|
|
10066
9736
|
body: {
|
|
@@ -10085,7 +9755,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
10085
9755
|
return process.cwd();
|
|
10086
9756
|
}
|
|
10087
9757
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
10088
|
-
await
|
|
9758
|
+
await chunkQFFNMJAS_cjs.discoverProviderPlugins();
|
|
10089
9759
|
await validateRehydratedAgent(agentId, existing);
|
|
10090
9760
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
10091
9761
|
const mergedOptions = {
|
|
@@ -10213,7 +9883,7 @@ var Agent = class _Agent {
|
|
|
10213
9883
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
10214
9884
|
});
|
|
10215
9885
|
try {
|
|
10216
|
-
await
|
|
9886
|
+
await chunkQFFNMJAS_cjs.discoverProviderPlugins();
|
|
10217
9887
|
const agent = await runCreateUnderSpan(options, span);
|
|
10218
9888
|
return agent;
|
|
10219
9889
|
} catch (err) {
|
|
@@ -10482,9 +10152,9 @@ var Agent = class _Agent {
|
|
|
10482
10152
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10483
10153
|
);
|
|
10484
10154
|
}
|
|
10485
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10155
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-UUCBTBCZ.cjs');
|
|
10486
10156
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10487
|
-
return
|
|
10157
|
+
return chunkFAUKVJCC_cjs.enqueueSessionWrite(
|
|
10488
10158
|
cwd,
|
|
10489
10159
|
agentId,
|
|
10490
10160
|
() => compactSessionTranscript({
|
|
@@ -10518,7 +10188,7 @@ var Agent = class _Agent {
|
|
|
10518
10188
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10519
10189
|
);
|
|
10520
10190
|
}
|
|
10521
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10191
|
+
const { injectSessionTurn } = await import('./inject-session-I3HK3AHB.cjs');
|
|
10522
10192
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10523
10193
|
await injectSessionTurn({
|
|
10524
10194
|
store,
|
|
@@ -10663,5 +10333,5 @@ exports.generateCronId = generateCronId;
|
|
|
10663
10333
|
exports.getPricingEntry = getPricingEntry;
|
|
10664
10334
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
10665
10335
|
exports.resolveApiKey = resolveApiKey;
|
|
10666
|
-
//# sourceMappingURL=chunk-
|
|
10667
|
-
//# sourceMappingURL=chunk-
|
|
10336
|
+
//# sourceMappingURL=chunk-4OQXDCMN.cjs.map
|
|
10337
|
+
//# sourceMappingURL=chunk-4OQXDCMN.cjs.map
|