@theokit/sdk 4.41.0 → 4.42.0
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 +55 -0
- package/dist/{agent-6C2ODKFU.cjs → agent-HGDXQEQQ.cjs} +8 -7
- package/dist/{agent-6C2ODKFU.cjs.map → agent-HGDXQEQQ.cjs.map} +1 -1
- package/dist/{agent-35MGOZVH.js → agent-WUVYXIFX.js} +7 -6
- package/dist/{agent-35MGOZVH.js.map → agent-WUVYXIFX.js.map} +1 -1
- package/dist/chunk-22EMHGBO.cjs +351 -0
- package/dist/chunk-22EMHGBO.cjs.map +1 -0
- package/dist/{chunk-Y33IGXCJ.cjs → chunk-EYEZDADP.cjs} +5 -5
- package/dist/{chunk-Y33IGXCJ.cjs.map → chunk-EYEZDADP.cjs.map} +1 -1
- 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-DCKIS53K.js → chunk-KO5V6L3E.js} +9 -319
- package/dist/chunk-KO5V6L3E.js.map +1 -0
- package/dist/{chunk-BHWHE453.js → chunk-MPD5EGJ6.js} +3 -3
- package/dist/{chunk-BHWHE453.js.map → chunk-MPD5EGJ6.js.map} +1 -1
- package/dist/chunk-Q2PPSHBS.js +344 -0
- package/dist/chunk-Q2PPSHBS.js.map +1 -0
- 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-F5DSDDBY.cjs → chunk-YHQ3DG24.cjs} +48 -358
- package/dist/chunk-YHQ3DG24.cjs.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/context-discovery-runner.d.ts +9 -0
- package/dist/internal/runtime/context/context-import-resolver.d.ts +17 -0
- package/dist/server/auth/index.d.cts +11 -207
- package/dist/server/auth/index.d.ts +11 -207
- package/dist/server/errors-envelope.d.cts +6 -12
- package/dist/server/errors-envelope.d.ts +6 -12
- package/package.json +11 -1
- package/dist/chunk-DCKIS53K.js.map +0 -1
- package/dist/chunk-F5DSDDBY.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 chunk22EMHGBO_cjs = require('./chunk-22EMHGBO.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-YHQ3DG24.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-YHQ3DG24.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 } = chunk22EMHGBO_cjs.truncateWithMarker(s.content, remaining);
|
|
3940
3894
|
kept.push({ ...s, content: finalContent, truncated: true });
|
|
3941
3895
|
totalBytes = maxTotal;
|
|
3942
3896
|
} else {
|
|
@@ -3956,271 +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
|
-
async function resolveImports(content, basePath, opts) {
|
|
3962
|
-
if (opts.depth >= MAX_HOPS) {
|
|
3963
|
-
return `${content}
|
|
3964
|
-
|
|
3965
|
-
\u2026[@import depth limit ${MAX_HOPS} reached]
|
|
3966
|
-
|
|
3967
|
-
`;
|
|
3968
|
-
}
|
|
3969
|
-
const baseDir = path.dirname(basePath);
|
|
3970
|
-
return replaceAsync(content, IMPORT_RE, async (raw) => {
|
|
3971
|
-
const absolute = resolveImportPath(raw, baseDir);
|
|
3972
|
-
if (opts.visited.has(absolute)) {
|
|
3973
|
-
return `[@import cycle detected: ${raw}]`;
|
|
3974
|
-
}
|
|
3975
|
-
opts.visited.add(absolute);
|
|
3976
|
-
const loaded = await loadPlainMarkdown(absolute, { maxBytesPerFile: opts.maxBytesPerFile });
|
|
3977
|
-
if (loaded === void 0) {
|
|
3978
|
-
return `[@import not found: ${raw}]`;
|
|
3979
|
-
}
|
|
3980
|
-
return resolveImports(loaded.content, absolute, {
|
|
3981
|
-
visited: opts.visited,
|
|
3982
|
-
depth: opts.depth + 1,
|
|
3983
|
-
maxBytesPerFile: opts.maxBytesPerFile
|
|
3984
|
-
});
|
|
3985
|
-
});
|
|
3986
|
-
}
|
|
3987
|
-
function resolveImportPath(raw, baseDir) {
|
|
3988
|
-
if (raw.startsWith("~/")) {
|
|
3989
|
-
return path.resolve(path.join(os.homedir(), raw.slice(2)));
|
|
3990
|
-
}
|
|
3991
|
-
if (path.isAbsolute(raw)) {
|
|
3992
|
-
return path.resolve(raw);
|
|
3993
|
-
}
|
|
3994
|
-
return path.resolve(path.join(baseDir, raw));
|
|
3995
|
-
}
|
|
3996
|
-
async function replaceAsync(content, re, replacer) {
|
|
3997
|
-
const matches = [];
|
|
3998
|
-
const localRe = new RegExp(re.source, re.flags);
|
|
3999
|
-
let m;
|
|
4000
|
-
while ((m = localRe.exec(content)) !== null) {
|
|
4001
|
-
matches.push({ match: m[0], raw: m[1] ?? "", index: m.index });
|
|
4002
|
-
if (m.index === localRe.lastIndex) localRe.lastIndex += 1;
|
|
4003
|
-
}
|
|
4004
|
-
if (matches.length === 0) return content;
|
|
4005
|
-
let result = "";
|
|
4006
|
-
let cursor = 0;
|
|
4007
|
-
for (const entry of matches) {
|
|
4008
|
-
result += content.slice(cursor, entry.index);
|
|
4009
|
-
result += await replacer(entry.raw);
|
|
4010
|
-
cursor = entry.index + entry.match.length;
|
|
4011
|
-
}
|
|
4012
|
-
result += content.slice(cursor);
|
|
4013
|
-
return result;
|
|
4014
|
-
}
|
|
4015
|
-
|
|
4016
|
-
// src/internal/runtime/context/context-glob.ts
|
|
4017
|
-
function globToRegex(glob) {
|
|
4018
|
-
const compiled = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*\//g, "::GLOBSTAR_SLASH::").replace(/\*\*/g, "::GLOBSTAR::").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/::GLOBSTAR_SLASH::/g, "(?:.*/)?").replace(/::GLOBSTAR::/g, ".*");
|
|
4019
|
-
return new RegExp(`^${compiled}$`);
|
|
4020
|
-
}
|
|
4021
|
-
function anyGlobMatches(patterns, paths) {
|
|
4022
|
-
if (patterns.length === 0 || paths.length === 0) return false;
|
|
4023
|
-
const res = patterns.map(globToRegex);
|
|
4024
|
-
return paths.some((p) => res.some((re) => re.test(p)));
|
|
4025
|
-
}
|
|
4026
|
-
|
|
4027
|
-
// src/internal/runtime/context/context-yaml-lite.ts
|
|
4028
|
-
var FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
|
|
4029
|
-
function splitFrontmatter2(content) {
|
|
4030
|
-
const m = FRONTMATTER_RE.exec(content);
|
|
4031
|
-
if (m === null) return { yaml: void 0, body: content };
|
|
4032
|
-
return { yaml: m[1] ?? "", body: m[2] ?? "" };
|
|
4033
|
-
}
|
|
4034
|
-
function parseSimpleYaml2(yaml) {
|
|
4035
|
-
const out = {};
|
|
4036
|
-
const lines = yaml.split(/\r?\n/);
|
|
4037
|
-
let i = 0;
|
|
4038
|
-
while (i < lines.length) {
|
|
4039
|
-
const line = lines[i];
|
|
4040
|
-
i += 1;
|
|
4041
|
-
if (line === void 0) continue;
|
|
4042
|
-
const trimmed = line.trim();
|
|
4043
|
-
if (trimmed === "" || trimmed.startsWith("#")) continue;
|
|
4044
|
-
const colon = trimmed.indexOf(":");
|
|
4045
|
-
if (colon === -1) throw new Error(`Invalid YAML line: ${trimmed}`);
|
|
4046
|
-
const key = trimmed.slice(0, colon).trim();
|
|
4047
|
-
const rest = trimmed.slice(colon + 1).trim();
|
|
4048
|
-
if (rest === "") {
|
|
4049
|
-
const items = [];
|
|
4050
|
-
while (i < lines.length) {
|
|
4051
|
-
const next = lines[i];
|
|
4052
|
-
if (next === void 0) break;
|
|
4053
|
-
const nextTrim = next.trim();
|
|
4054
|
-
if (nextTrim.startsWith("- ")) {
|
|
4055
|
-
items.push(parseScalar(nextTrim.slice(2).trim()));
|
|
4056
|
-
i += 1;
|
|
4057
|
-
} else if (nextTrim === "") {
|
|
4058
|
-
i += 1;
|
|
4059
|
-
} else {
|
|
4060
|
-
break;
|
|
4061
|
-
}
|
|
4062
|
-
}
|
|
4063
|
-
out[key] = items;
|
|
4064
|
-
} else if (rest.startsWith("[") && rest.endsWith("]")) {
|
|
4065
|
-
const inner = rest.slice(1, -1).trim();
|
|
4066
|
-
out[key] = inner === "" ? [] : inner.split(",").map((s) => parseScalar(s.trim().replace(/^["']|["']$/g, "")));
|
|
4067
|
-
} else {
|
|
4068
|
-
out[key] = parseScalar(rest);
|
|
4069
|
-
}
|
|
4070
|
-
}
|
|
4071
|
-
return out;
|
|
4072
|
-
}
|
|
4073
|
-
function parseScalar(s) {
|
|
4074
|
-
if (s === "true") return true;
|
|
4075
|
-
if (s === "false") return false;
|
|
4076
|
-
if (/^-?\d+$/.test(s)) return parseInt(s, 10);
|
|
4077
|
-
return s.replace(/^["']|["']$/g, "");
|
|
4078
|
-
}
|
|
4079
|
-
|
|
4080
|
-
// src/internal/runtime/context/context-mdc-parser.ts
|
|
4081
|
-
var McdFrontmatterSchema = zod.z.object({
|
|
4082
|
-
description: zod.z.string().optional(),
|
|
4083
|
-
globs: zod.z.array(zod.z.string()).optional(),
|
|
4084
|
-
alwaysApply: zod.z.boolean().optional()
|
|
4085
|
-
});
|
|
4086
|
-
function parseMdc(content) {
|
|
4087
|
-
const { yaml, body } = splitFrontmatter2(content);
|
|
4088
|
-
if (yaml === void 0) {
|
|
4089
|
-
return { frontmatter: { alwaysApply: true }, body: content };
|
|
4090
|
-
}
|
|
4091
|
-
try {
|
|
4092
|
-
const parsed = parseSimpleYaml2(yaml);
|
|
4093
|
-
const validated = McdFrontmatterSchema.safeParse(parsed);
|
|
4094
|
-
if (!validated.success) return void 0;
|
|
4095
|
-
return { frontmatter: validated.data, body };
|
|
4096
|
-
} catch {
|
|
4097
|
-
return void 0;
|
|
4098
|
-
}
|
|
4099
|
-
}
|
|
4100
|
-
function shouldActivate(fm, touchedFiles) {
|
|
4101
|
-
if (fm.alwaysApply === true) return true;
|
|
4102
|
-
if (fm.globs === void 0 || fm.globs.length === 0) return false;
|
|
4103
|
-
return anyGlobMatches(fm.globs, touchedFiles);
|
|
4104
|
-
}
|
|
4105
|
-
var RulesFrontmatterSchema = zod.z.object({
|
|
4106
|
-
description: zod.z.string().optional(),
|
|
4107
|
-
paths: zod.z.array(zod.z.string()).optional(),
|
|
4108
|
-
globs: zod.z.array(zod.z.string()).optional(),
|
|
4109
|
-
alwaysApply: zod.z.boolean().optional(),
|
|
4110
|
-
enabled: zod.z.boolean().optional()
|
|
4111
|
-
});
|
|
4112
|
-
function parseRules(content) {
|
|
4113
|
-
const { yaml, body } = splitFrontmatter2(content);
|
|
4114
|
-
if (yaml === void 0) {
|
|
4115
|
-
return { frontmatter: { alwaysApply: true }, body: content };
|
|
4116
|
-
}
|
|
4117
|
-
try {
|
|
4118
|
-
const parsed = parseSimpleYaml2(yaml);
|
|
4119
|
-
const validated = RulesFrontmatterSchema.safeParse(parsed);
|
|
4120
|
-
if (!validated.success) return void 0;
|
|
4121
|
-
return { frontmatter: validated.data, body };
|
|
4122
|
-
} catch {
|
|
4123
|
-
return void 0;
|
|
4124
|
-
}
|
|
4125
|
-
}
|
|
4126
|
-
function shouldActivateRule(fm, inScopePaths) {
|
|
4127
|
-
if (fm.enabled === false) return false;
|
|
4128
|
-
if (fm.alwaysApply === true) return true;
|
|
4129
|
-
const patterns = [...fm.paths ?? [], ...fm.globs ?? []];
|
|
4130
|
-
if (patterns.length === 0) return false;
|
|
4131
|
-
return anyGlobMatches(patterns, inScopePaths);
|
|
4132
|
-
}
|
|
4133
|
-
|
|
4134
|
-
// src/internal/runtime/context/context-discovery-runner.ts
|
|
4135
|
-
async function runDiscovery(opts) {
|
|
4136
|
-
const gitRoot = chunkYPEPCZHF_cjs.findGitRoot(opts.cwd);
|
|
4137
|
-
const specs = opts.specs ?? chunkYPEPCZHF_cjs.DEFAULT_DISCOVERY_SPECS;
|
|
4138
|
-
const out = [];
|
|
4139
|
-
const seenReal = /* @__PURE__ */ new Set();
|
|
4140
|
-
for (const spec of specs) {
|
|
4141
|
-
if (spec.id === "theokit-context") continue;
|
|
4142
|
-
const paths = await resolvePathsForSpec(spec, opts.cwd, gitRoot);
|
|
4143
|
-
for (const path of paths) {
|
|
4144
|
-
if (seenReal.has(path)) continue;
|
|
4145
|
-
seenReal.add(path);
|
|
4146
|
-
const source = await loadOneSource(spec, path, opts, gitRoot);
|
|
4147
|
-
if (source !== void 0) out.push(source);
|
|
4148
|
-
}
|
|
4149
|
-
}
|
|
4150
|
-
return out;
|
|
4151
|
-
}
|
|
4152
|
-
async function resolvePathsForSpec(spec, cwd, gitRoot) {
|
|
4153
|
-
if (spec.scope === "cwd-only") {
|
|
4154
|
-
return chunkYPEPCZHF_cjs.walkUpForFile(cwd, spec.pattern, cwd);
|
|
4155
|
-
}
|
|
4156
|
-
if (spec.scope === "git-root-walk") {
|
|
4157
|
-
return chunkYPEPCZHF_cjs.walkUpForFile(cwd, spec.pattern, gitRoot ?? cwd);
|
|
4158
|
-
}
|
|
4159
|
-
return chunkYPEPCZHF_cjs.walkUpForGlob(cwd, spec.pattern);
|
|
4160
|
-
}
|
|
4161
|
-
async function loadOneSource(spec, path$1, opts, gitRoot) {
|
|
4162
|
-
const relPath = path.relative(gitRoot ?? opts.cwd, path.dirname(path$1));
|
|
4163
|
-
const needsSuffix = spec.scope !== "cwd-only" && relPath !== "" && relPath !== ".";
|
|
4164
|
-
const id = needsSuffix ? `${spec.id}@${relPath}` : spec.id;
|
|
4165
|
-
if (spec.parser === "mdc") {
|
|
4166
|
-
return loadMdcSource(spec, path$1, id, opts);
|
|
4167
|
-
}
|
|
4168
|
-
if (spec.parser === "rules-frontmatter") {
|
|
4169
|
-
return loadRulesSource(spec, path$1, id, opts);
|
|
4170
|
-
}
|
|
4171
|
-
if (spec.parser === "frontmatter-zod") {
|
|
4172
|
-
return void 0;
|
|
4173
|
-
}
|
|
4174
|
-
return loadPlainMarkdownSource(spec, path$1, id, opts);
|
|
4175
|
-
}
|
|
4176
|
-
async function loadParsedSource(spec, path, id, parse, isActive) {
|
|
4177
|
-
let raw;
|
|
4178
|
-
try {
|
|
4179
|
-
raw = await promises.readFile(path, "utf8");
|
|
4180
|
-
} catch {
|
|
4181
|
-
return void 0;
|
|
4182
|
-
}
|
|
4183
|
-
const parsed = parse(raw);
|
|
4184
|
-
if (parsed === void 0 || !isActive(parsed.frontmatter)) return void 0;
|
|
4185
|
-
return { id, source: path, content: parsed.body, priority: spec.priority, truncated: false };
|
|
4186
|
-
}
|
|
4187
|
-
function loadMdcSource(spec, path, id, opts) {
|
|
4188
|
-
return loadParsedSource(
|
|
4189
|
-
spec,
|
|
4190
|
-
path,
|
|
4191
|
-
id,
|
|
4192
|
-
parseMdc,
|
|
4193
|
-
(fm) => shouldActivate(fm, opts.touchedFiles ?? [])
|
|
4194
|
-
);
|
|
4195
|
-
}
|
|
4196
|
-
function loadRulesSource(spec, path, id, opts) {
|
|
4197
|
-
return loadParsedSource(
|
|
4198
|
-
spec,
|
|
4199
|
-
path,
|
|
4200
|
-
id,
|
|
4201
|
-
parseRules,
|
|
4202
|
-
(fm) => shouldActivateRule(fm, opts.touchedFiles ?? [])
|
|
4203
|
-
);
|
|
4204
|
-
}
|
|
4205
|
-
async function loadPlainMarkdownSource(spec, path, id, opts) {
|
|
4206
|
-
const loaded = await loadPlainMarkdown(path, { maxBytesPerFile: opts.maxBytesPerFile });
|
|
4207
|
-
if (loaded === void 0) return void 0;
|
|
4208
|
-
let content = loaded.content;
|
|
4209
|
-
if (spec.followImports) {
|
|
4210
|
-
content = await resolveImports(content, path, {
|
|
4211
|
-
visited: /* @__PURE__ */ new Set([path]),
|
|
4212
|
-
depth: 0,
|
|
4213
|
-
maxBytesPerFile: opts.maxBytesPerFile
|
|
4214
|
-
});
|
|
4215
|
-
}
|
|
4216
|
-
return {
|
|
4217
|
-
id,
|
|
4218
|
-
source: path,
|
|
4219
|
-
content,
|
|
4220
|
-
priority: spec.priority,
|
|
4221
|
-
truncated: loaded.truncated
|
|
4222
|
-
};
|
|
4223
|
-
}
|
|
4224
3913
|
var ContextSourceFrontmatterSchema = zod.z.object({
|
|
4225
3914
|
/** Identifier; defaults to filename slug if omitted. */
|
|
4226
3915
|
name: zod.z.string().min(1).optional(),
|
|
@@ -4275,11 +3964,12 @@ var FileContextManager = class {
|
|
|
4275
3964
|
this.lastScope = [...touchedFiles];
|
|
4276
3965
|
const config = await loadContextConfig(this.cwd);
|
|
4277
3966
|
const legacy = await loadSources(config, this.cwd);
|
|
4278
|
-
const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
|
|
3967
|
+
const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunk22EMHGBO_cjs.DEFAULT_MAX_BYTES_PER_FILE;
|
|
4279
3968
|
const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
|
|
4280
|
-
const discovered = await runDiscovery({
|
|
3969
|
+
const discovered = await chunk22EMHGBO_cjs.runDiscovery({
|
|
4281
3970
|
cwd: this.cwd,
|
|
4282
3971
|
maxBytesPerFile,
|
|
3972
|
+
skipLegacyTheokitContext: true,
|
|
4283
3973
|
touchedFiles
|
|
4284
3974
|
});
|
|
4285
3975
|
const legacyAsAggregator = legacy.map((src) => ({
|
|
@@ -6079,7 +5769,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
6079
5769
|
(p) => (
|
|
6080
5770
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
6081
5771
|
// structured content); image blocks pass through untouched.
|
|
6082
|
-
p.type === "tool_result" ? { ...p, content:
|
|
5772
|
+
p.type === "tool_result" ? { ...p, content: chunkQFFNMJAS_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
6083
5773
|
)
|
|
6084
5774
|
);
|
|
6085
5775
|
}
|
|
@@ -6739,12 +6429,12 @@ var FallbackLlmClient = class {
|
|
|
6739
6429
|
let lastError;
|
|
6740
6430
|
for (const client of this.clients) {
|
|
6741
6431
|
if (signal.aborted) throw abortError(signal);
|
|
6742
|
-
const attempt = await
|
|
6432
|
+
const attempt = await chunkQFFNMJAS_cjs.tryFirstEvent(client, request, signal, true);
|
|
6743
6433
|
if (attempt.kind === "handshake_error") {
|
|
6744
6434
|
lastError = attempt.error;
|
|
6745
6435
|
continue;
|
|
6746
6436
|
}
|
|
6747
|
-
return yield*
|
|
6437
|
+
return yield* chunkQFFNMJAS_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
6748
6438
|
}
|
|
6749
6439
|
if (lastError !== void 0) throw lastError;
|
|
6750
6440
|
throw new chunkYULF6FPB_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
@@ -7325,14 +7015,14 @@ function resolveRunProvider(options) {
|
|
|
7325
7015
|
}
|
|
7326
7016
|
const parsedModel = chunkVYHJZVL5_cjs.parseModelId(options.model?.id);
|
|
7327
7017
|
const modelInferredProvider = parsedModel.provider !== void 0 && chunkGLEKLAUW_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
|
|
7328
|
-
const keyInferredProvider =
|
|
7329
|
-
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();
|
|
7330
7020
|
const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
|
|
7331
7021
|
return { primary, effectiveModelId };
|
|
7332
7022
|
}
|
|
7333
7023
|
function mergeExplicitApiKey(pools, primary, apiKey) {
|
|
7334
7024
|
if (apiKey === void 0 || apiKey.length === 0) return pools;
|
|
7335
|
-
if (
|
|
7025
|
+
if (chunkQFFNMJAS_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
|
|
7336
7026
|
const existing = pools?.[primary];
|
|
7337
7027
|
if (existing !== void 0 && existing.length > 0) return pools;
|
|
7338
7028
|
return { ...pools ?? {}, [primary]: [apiKey] };
|
|
@@ -7355,7 +7045,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7355
7045
|
const credentialPoolStrategy = options.agentOptions.providers?.credentialPoolStrategy;
|
|
7356
7046
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7357
7047
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7358
|
-
const chain =
|
|
7048
|
+
const chain = chunkQFFNMJAS_cjs.resolveProviderChain({
|
|
7359
7049
|
primary,
|
|
7360
7050
|
...fallback !== void 0 ? { fallback } : {},
|
|
7361
7051
|
...apiKeys !== void 0 ? { apiKeys } : {},
|
|
@@ -7637,7 +7327,7 @@ function buildRealRunOptions(args) {
|
|
|
7637
7327
|
};
|
|
7638
7328
|
}
|
|
7639
7329
|
async function createFixtureRunHelper(args) {
|
|
7640
|
-
const sessionMessages =
|
|
7330
|
+
const sessionMessages = chunkFAUKVJCC_cjs.getSessionMessages(args.inputs.agentId);
|
|
7641
7331
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7642
7332
|
return createLocalRun({
|
|
7643
7333
|
agentId: args.inputs.agentId,
|
|
@@ -7656,7 +7346,7 @@ async function createFixtureRunHelper(args) {
|
|
|
7656
7346
|
}
|
|
7657
7347
|
async function dispatchLocalRun(args) {
|
|
7658
7348
|
const apiKey = resolveApiKey(args.inputs.options.apiKey);
|
|
7659
|
-
if (
|
|
7349
|
+
if (chunkQFFNMJAS_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
7660
7350
|
return createRealLocalRun(
|
|
7661
7351
|
buildRealRunOptions({
|
|
7662
7352
|
inputs: args.inputs,
|
|
@@ -7912,10 +7602,10 @@ async function disposeLocalAgentSession(agent) {
|
|
|
7912
7602
|
agent.lifecycleAbortController.abort();
|
|
7913
7603
|
await chunkYLQQX5W2_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
|
|
7914
7604
|
disposeSessionMcpClients(agent.agentId);
|
|
7915
|
-
await
|
|
7605
|
+
await chunkFAUKVJCC_cjs.flushSessionWrites();
|
|
7916
7606
|
await flushRegistrySaves(agent.workspaceCwd);
|
|
7917
7607
|
await disposeSessionStore(agent.sessionStore);
|
|
7918
|
-
|
|
7608
|
+
chunkFAUKVJCC_cjs.discardSession(agent.workspaceCwd, agent.agentId);
|
|
7919
7609
|
}
|
|
7920
7610
|
async function reloadLocalAgent(agent) {
|
|
7921
7611
|
if (agent.context !== void 0) await agent.context.refresh();
|
|
@@ -8690,7 +8380,7 @@ var LocalAgentMemory = class {
|
|
|
8690
8380
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
8691
8381
|
const cfg = this.options.memory?.activeRecall;
|
|
8692
8382
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
8693
|
-
if (this.breaker === void 0) this.breaker = new
|
|
8383
|
+
if (this.breaker === void 0) this.breaker = new chunkQFFNMJAS_cjs.CircuitBreaker();
|
|
8694
8384
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
8695
8385
|
const result = await runActiveMemory({
|
|
8696
8386
|
userText,
|
|
@@ -9092,8 +8782,8 @@ async function localAgentUsePersonality(args) {
|
|
|
9092
8782
|
registry,
|
|
9093
8783
|
store: args.personalityStore,
|
|
9094
8784
|
invalidateCache: (reason) => args.invalidateCache(reason),
|
|
9095
|
-
appendSessionMessage: (msg) =>
|
|
9096
|
-
clearSession: () =>
|
|
8785
|
+
appendSessionMessage: (msg) => chunkFAUKVJCC_cjs.appendSessionMessage(args.agentId, msg),
|
|
8786
|
+
clearSession: () => chunkFAUKVJCC_cjs.clearSession(args.agentId),
|
|
9097
8787
|
opts: args.opts ?? {}
|
|
9098
8788
|
})
|
|
9099
8789
|
);
|
|
@@ -9447,7 +9137,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9447
9137
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9448
9138
|
await inputs.options.onBeforeSend({
|
|
9449
9139
|
conversationId: inputs.agentId,
|
|
9450
|
-
previousMessageCount:
|
|
9140
|
+
previousMessageCount: chunkFAUKVJCC_cjs.getSessionMessages(inputs.agentId).length
|
|
9451
9141
|
});
|
|
9452
9142
|
}
|
|
9453
9143
|
await inputs.runPreHook(userText);
|
|
@@ -9459,8 +9149,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9459
9149
|
userText,
|
|
9460
9150
|
sendOptions: options
|
|
9461
9151
|
});
|
|
9462
|
-
const priorMessages = [...
|
|
9463
|
-
|
|
9152
|
+
const priorMessages = [...chunkFAUKVJCC_cjs.getSessionMessages(inputs.agentId)];
|
|
9153
|
+
chunkFAUKVJCC_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9464
9154
|
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9465
9155
|
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
|
|
9466
9156
|
const portPathActive = shouldUsePortMemoryPath();
|
|
@@ -9672,7 +9362,7 @@ var LocalAgent = class {
|
|
|
9672
9362
|
);
|
|
9673
9363
|
await acquireLeaseIfPossible(this.sessionStore, this.agentId);
|
|
9674
9364
|
try {
|
|
9675
|
-
await
|
|
9365
|
+
await chunkFAUKVJCC_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
9676
9366
|
await this.personalityStore.hydrate(this.agentId);
|
|
9677
9367
|
} catch (err) {
|
|
9678
9368
|
await releaseLeaseIfPossible(this.sessionStore, this.agentId);
|
|
@@ -10005,7 +9695,7 @@ async function createLocalAgent(options) {
|
|
|
10005
9695
|
if (apiKey === void 0) {
|
|
10006
9696
|
throw new chunkYULF6FPB_cjs.AuthenticationError("Missing API key", { code: "missing_api_key" });
|
|
10007
9697
|
}
|
|
10008
|
-
const willFlowToProvider = !
|
|
9698
|
+
const willFlowToProvider = !chunkQFFNMJAS_cjs.isFixtureApiKey(apiKey) && !chunkQFFNMJAS_cjs.shouldUseRealLocalRuntime(apiKey);
|
|
10009
9699
|
const shape = validateApiKeyShape(apiKey, {
|
|
10010
9700
|
strict: willFlowToProvider,
|
|
10011
9701
|
// `options.model` is already normalized by `runCreateUnderSpan`; `normalizeModel`
|
|
@@ -10016,7 +9706,7 @@ async function createLocalAgent(options) {
|
|
|
10016
9706
|
if (shape.malformed) {
|
|
10017
9707
|
throw new chunkYULF6FPB_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
10018
9708
|
}
|
|
10019
|
-
if (!
|
|
9709
|
+
if (!chunkQFFNMJAS_cjs.isFixtureApiKey(apiKey) && chunkQFFNMJAS_cjs.getConfiguredBaseUrl() === void 0 && !chunkQFFNMJAS_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
10020
9710
|
throw new chunkYULF6FPB_cjs.AuthenticationError("Invalid API key", {
|
|
10021
9711
|
code: "authentication_error"
|
|
10022
9712
|
});
|
|
@@ -10036,11 +9726,11 @@ async function createCloudAgent(options) {
|
|
|
10036
9726
|
if (shape.malformed) {
|
|
10037
9727
|
throw new chunkYULF6FPB_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
10038
9728
|
}
|
|
10039
|
-
const baseUrl =
|
|
9729
|
+
const baseUrl = chunkQFFNMJAS_cjs.getConfiguredBaseUrl();
|
|
10040
9730
|
if (baseUrl === void 0) {
|
|
10041
9731
|
return new CloudAgent(options);
|
|
10042
9732
|
}
|
|
10043
|
-
const response = await
|
|
9733
|
+
const response = await chunkQFFNMJAS_cjs.httpRequest("/v1/agents", {
|
|
10044
9734
|
apiKey,
|
|
10045
9735
|
method: "POST",
|
|
10046
9736
|
body: {
|
|
@@ -10065,7 +9755,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
10065
9755
|
return process.cwd();
|
|
10066
9756
|
}
|
|
10067
9757
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
10068
|
-
await
|
|
9758
|
+
await chunkQFFNMJAS_cjs.discoverProviderPlugins();
|
|
10069
9759
|
await validateRehydratedAgent(agentId, existing);
|
|
10070
9760
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
10071
9761
|
const mergedOptions = {
|
|
@@ -10193,7 +9883,7 @@ var Agent = class _Agent {
|
|
|
10193
9883
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
10194
9884
|
});
|
|
10195
9885
|
try {
|
|
10196
|
-
await
|
|
9886
|
+
await chunkQFFNMJAS_cjs.discoverProviderPlugins();
|
|
10197
9887
|
const agent = await runCreateUnderSpan(options, span);
|
|
10198
9888
|
return agent;
|
|
10199
9889
|
} catch (err) {
|
|
@@ -10462,9 +10152,9 @@ var Agent = class _Agent {
|
|
|
10462
10152
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10463
10153
|
);
|
|
10464
10154
|
}
|
|
10465
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10155
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-UUCBTBCZ.cjs');
|
|
10466
10156
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10467
|
-
return
|
|
10157
|
+
return chunkFAUKVJCC_cjs.enqueueSessionWrite(
|
|
10468
10158
|
cwd,
|
|
10469
10159
|
agentId,
|
|
10470
10160
|
() => compactSessionTranscript({
|
|
@@ -10498,7 +10188,7 @@ var Agent = class _Agent {
|
|
|
10498
10188
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10499
10189
|
);
|
|
10500
10190
|
}
|
|
10501
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10191
|
+
const { injectSessionTurn } = await import('./inject-session-I3HK3AHB.cjs');
|
|
10502
10192
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
10503
10193
|
await injectSessionTurn({
|
|
10504
10194
|
store,
|
|
@@ -10643,5 +10333,5 @@ exports.generateCronId = generateCronId;
|
|
|
10643
10333
|
exports.getPricingEntry = getPricingEntry;
|
|
10644
10334
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
10645
10335
|
exports.resolveApiKey = resolveApiKey;
|
|
10646
|
-
//# sourceMappingURL=chunk-
|
|
10647
|
-
//# sourceMappingURL=chunk-
|
|
10336
|
+
//# sourceMappingURL=chunk-YHQ3DG24.cjs.map
|
|
10337
|
+
//# sourceMappingURL=chunk-YHQ3DG24.cjs.map
|