@theokit/sdk 5.9.2 → 5.11.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 +104 -0
- package/dist/{agent-WQ4LLTSY.cjs → agent-5DOR5T3E.cjs} +12 -10
- package/dist/{agent-WQ4LLTSY.cjs.map → agent-5DOR5T3E.cjs.map} +1 -1
- package/dist/{agent-enXXu447.d.ts → agent-CmKwSyyD.d.ts} +27 -0
- package/dist/{agent-GZVZXKME.js → agent-GWKRARAL.js} +11 -9
- package/dist/{agent-GZVZXKME.js.map → agent-GWKRARAL.js.map} +1 -1
- package/dist/{agent-Dh2YHSLj.d.cts → agent-XMkGzff_.d.cts} +27 -0
- package/dist/{chunk-PEIV7LOU.js → chunk-4PHSVR2R.js} +68 -37
- package/dist/chunk-4PHSVR2R.js.map +1 -0
- package/dist/{chunk-KXKT3HSD.cjs → chunk-5H2GJXGC.cjs} +4 -4
- package/dist/{chunk-KXKT3HSD.cjs.map → chunk-5H2GJXGC.cjs.map} +1 -1
- package/dist/{chunk-JU76WCW7.cjs → chunk-5OHB5HJF.cjs} +123 -92
- package/dist/chunk-5OHB5HJF.cjs.map +1 -0
- package/dist/{chunk-EVH3OUMY.js → chunk-74OA5DIM.js} +189 -43
- package/dist/chunk-74OA5DIM.js.map +1 -0
- package/dist/chunk-7KIN3L2S.js +103 -0
- package/dist/chunk-7KIN3L2S.js.map +1 -0
- package/dist/{chunk-EXI7EHDN.js → chunk-7Y23B7XX.js} +3 -3
- package/dist/{chunk-EXI7EHDN.js.map → chunk-7Y23B7XX.js.map} +1 -1
- package/dist/chunk-ASK2OQM5.cjs +84 -0
- package/dist/chunk-ASK2OQM5.cjs.map +1 -0
- package/dist/{chunk-QY3CIMUV.cjs → chunk-BZKF7TXX.cjs} +192 -44
- package/dist/chunk-BZKF7TXX.cjs.map +1 -0
- package/dist/{chunk-ZDF2IJKC.js → chunk-DPY2M74T.js} +3 -3
- package/dist/{chunk-ZDF2IJKC.js.map → chunk-DPY2M74T.js.map} +1 -1
- package/dist/{chunk-X7Z2FEI7.cjs → chunk-FYEHYQ7T.cjs} +8 -8
- package/dist/{chunk-X7Z2FEI7.cjs.map → chunk-FYEHYQ7T.cjs.map} +1 -1
- package/dist/{chunk-OZLQ6ZFM.js → chunk-IZDDSLL2.js} +4 -3
- package/dist/chunk-IZDDSLL2.js.map +1 -0
- package/dist/{chunk-DLUCTZ56.cjs → chunk-L3C6CCBG.cjs} +15 -15
- package/dist/{chunk-DLUCTZ56.cjs.map → chunk-L3C6CCBG.cjs.map} +1 -1
- package/dist/chunk-LZJXEPEQ.js +58 -0
- package/dist/chunk-LZJXEPEQ.js.map +1 -0
- package/dist/{chunk-FR6COQXZ.cjs → chunk-N7ZIPW2N.cjs} +3 -3
- package/dist/{chunk-FR6COQXZ.cjs.map → chunk-N7ZIPW2N.cjs.map} +1 -1
- package/dist/{chunk-RX3CFWQ2.cjs → chunk-NQVWSSX2.cjs} +6 -5
- package/dist/chunk-NQVWSSX2.cjs.map +1 -0
- package/dist/chunk-NWS2CS3Y.cjs +61 -0
- package/dist/chunk-NWS2CS3Y.cjs.map +1 -0
- package/dist/chunk-R5YPDAKD.cjs +108 -0
- package/dist/chunk-R5YPDAKD.cjs.map +1 -0
- package/dist/chunk-RGQICWFU.js +82 -0
- package/dist/chunk-RGQICWFU.js.map +1 -0
- package/dist/{chunk-N7KYUNFO.js → chunk-W2ZVTEOD.js} +3 -3
- package/dist/{chunk-N7KYUNFO.js.map → chunk-W2ZVTEOD.js.map} +1 -1
- package/dist/{chunk-47Z6LP3I.js → chunk-X3LOJJMO.js} +88 -28
- package/dist/chunk-X3LOJJMO.js.map +1 -0
- package/dist/{chunk-M2CCHC66.js → chunk-Z5BAFHPU.js} +3 -3
- package/dist/{chunk-M2CCHC66.js.map → chunk-Z5BAFHPU.js.map} +1 -1
- package/dist/{chunk-VZ2JZ2EH.cjs → chunk-ZD66GFH5.cjs} +89 -27
- package/dist/chunk-ZD66GFH5.cjs.map +1 -0
- package/dist/{compact-session-4QHBBGEY.cjs → compact-session-2AETONOS.cjs} +12 -12
- package/dist/{compact-session-4QHBBGEY.cjs.map → compact-session-2AETONOS.cjs.map} +1 -1
- package/dist/{compact-session-PVAWTKKL.js → compact-session-F2UDGZCN.js} +3 -3
- package/dist/{compact-session-PVAWTKKL.js.map → compact-session-F2UDGZCN.js.map} +1 -1
- package/dist/{cron-DTuaPMVI.d.ts → cron-BPccQCO8.d.ts} +1 -1
- package/dist/{cron-QTgcwcZt.d.cts → cron-Blj6wMYg.d.cts} +1 -1
- package/dist/cron.cjs +11 -9
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +10 -8
- package/dist/eval.cjs +14 -12
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +10 -8
- package/dist/eval.js.map +1 -1
- package/dist/fs-session-store-3VI4CPTX.js +11 -0
- package/dist/{fs-session-store-LCZBM3LT.js.map → fs-session-store-3VI4CPTX.js.map} +1 -1
- package/dist/fs-session-store-IQ6PEHYF.cjs +20 -0
- package/dist/{fs-session-store-SVEMRE4K.cjs.map → fs-session-store-IQ6PEHYF.cjs.map} +1 -1
- package/dist/{index-manager-6B2UF5S3.js → index-manager-JVYIVTZG.js} +5 -4
- package/dist/{index-manager-6B2UF5S3.js.map → index-manager-JVYIVTZG.js.map} +1 -1
- package/dist/{index-manager-M3FHJCHQ.cjs → index-manager-YGXRFJMZ.cjs} +6 -5
- package/dist/{index-manager-M3FHJCHQ.cjs.map → index-manager-YGXRFJMZ.cjs.map} +1 -1
- package/dist/index.cjs +62 -145
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +27 -115
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-O24XGRR6.js → inject-session-E5UDFVLI.js} +3 -3
- package/dist/{inject-session-O24XGRR6.js.map → inject-session-E5UDFVLI.js.map} +1 -1
- package/dist/{inject-session-OMLFL2V3.cjs → inject-session-W4UKACYJ.cjs} +4 -4
- package/dist/{inject-session-OMLFL2V3.cjs.map → inject-session-W4UKACYJ.cjs.map} +1 -1
- package/dist/internal/budget/normalize-usage.d.ts +81 -0
- package/dist/internal/llm/anthropic-shared.d.ts +6 -0
- package/dist/internal/llm/openai.d.ts +3 -5
- package/dist/internal/llm/openrouter-system.d.ts +1 -0
- package/dist/internal/llm/types.d.ts +10 -5
- package/dist/internal/memory/dreaming/phases.d.ts +2 -0
- package/dist/internal/memory/dreaming/run.d.ts +5 -0
- package/dist/internal/memory/sdk-memory-peer-loader.d.ts +2 -0
- package/dist/internal/memory/storage/fact-ceiling.d.cts +19 -0
- package/dist/internal/memory/storage/fact-ceiling.d.ts +19 -0
- package/dist/internal/memory/storage/index.cjs +40 -31
- package/dist/internal/memory/storage/index.d.cts +1 -0
- package/dist/internal/memory/storage/index.d.ts +1 -0
- package/dist/internal/memory/storage/index.js +3 -2
- package/dist/internal/memory/storage/markdown-store.d.cts +3 -1
- package/dist/internal/memory/storage/markdown-store.d.ts +3 -1
- package/dist/internal/memory/types.d.ts +6 -0
- package/dist/internal/persistence/index.cjs +7 -6
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.js +2 -1
- package/dist/internal/persistence/index.js.map +1 -1
- package/dist/internal/runtime/registry/agent-registry-store.d.ts +2 -0
- package/dist/models.cjs +5 -50
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +3 -51
- package/dist/models.js.map +1 -1
- package/dist/persistence.cjs +7 -6
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +2 -1
- package/dist/persistence.js.map +1 -1
- package/dist/subagents-loader.d.cts +1 -1
- package/dist/subagents-loader.d.ts +1 -1
- package/dist/types/agent.d.ts +27 -0
- package/docs/error-codes.md +29 -26
- package/docs/harness-capability-map.md +6 -1
- package/package.json +1 -1
- package/dist/chunk-47Z6LP3I.js.map +0 -1
- package/dist/chunk-BKMDRBJ7.js +0 -180
- package/dist/chunk-BKMDRBJ7.js.map +0 -1
- package/dist/chunk-EVH3OUMY.js.map +0 -1
- package/dist/chunk-JU76WCW7.cjs.map +0 -1
- package/dist/chunk-OF2CLCTH.cjs +0 -186
- package/dist/chunk-OF2CLCTH.cjs.map +0 -1
- package/dist/chunk-OZLQ6ZFM.js.map +0 -1
- package/dist/chunk-PEIV7LOU.js.map +0 -1
- package/dist/chunk-QY3CIMUV.cjs.map +0 -1
- package/dist/chunk-RX3CFWQ2.cjs.map +0 -1
- package/dist/chunk-VZ2JZ2EH.cjs.map +0 -1
- package/dist/fs-session-store-LCZBM3LT.js +0 -10
- package/dist/fs-session-store-SVEMRE4K.cjs +0 -19
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkJ6GXS5A2_cjs = require('./chunk-J6GXS5A2.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkN7ZIPW2N_cjs = require('./chunk-N7ZIPW2N.cjs');
|
|
5
|
+
var chunkL3C6CCBG_cjs = require('./chunk-L3C6CCBG.cjs');
|
|
6
6
|
var chunkKIKKTW5O_cjs = require('./chunk-KIKKTW5O.cjs');
|
|
7
7
|
var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
|
|
8
8
|
var chunkYEHQ3SIC_cjs = require('./chunk-YEHQ3SIC.cjs');
|
|
9
9
|
var chunkTMKTSYDS_cjs = require('./chunk-TMKTSYDS.cjs');
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
10
|
+
var chunkZD66GFH5_cjs = require('./chunk-ZD66GFH5.cjs');
|
|
11
|
+
var chunkNQVWSSX2_cjs = require('./chunk-NQVWSSX2.cjs');
|
|
12
|
+
var chunkBZKF7TXX_cjs = require('./chunk-BZKF7TXX.cjs');
|
|
13
13
|
var chunk2ZPEDVLM_cjs = require('./chunk-2ZPEDVLM.cjs');
|
|
14
14
|
var chunkXKZFIP7Z_cjs = require('./chunk-XKZFIP7Z.cjs');
|
|
15
15
|
var chunkN6OEX5TN_cjs = require('./chunk-N6OEX5TN.cjs');
|
|
@@ -24,13 +24,14 @@ var chunkGM54F4FE_cjs = require('./chunk-GM54F4FE.cjs');
|
|
|
24
24
|
var chunkSA6K24NB_cjs = require('./chunk-SA6K24NB.cjs');
|
|
25
25
|
var chunkIIYJMXYW_cjs = require('./chunk-IIYJMXYW.cjs');
|
|
26
26
|
var chunkZWACQM5U_cjs = require('./chunk-ZWACQM5U.cjs');
|
|
27
|
-
var
|
|
27
|
+
var chunkASK2OQM5_cjs = require('./chunk-ASK2OQM5.cjs');
|
|
28
28
|
var chunkZF2LDKQQ_cjs = require('./chunk-ZF2LDKQQ.cjs');
|
|
29
29
|
var chunkJLRLCBJ4_cjs = require('./chunk-JLRLCBJ4.cjs');
|
|
30
30
|
var chunkC7GKRGKN_cjs = require('./chunk-C7GKRGKN.cjs');
|
|
31
31
|
var chunkTY56BKSK_cjs = require('./chunk-TY56BKSK.cjs');
|
|
32
32
|
var chunkMPR2ISL2_cjs = require('./chunk-MPR2ISL2.cjs');
|
|
33
33
|
var chunkJ5623RIV_cjs = require('./chunk-J5623RIV.cjs');
|
|
34
|
+
var chunkNWS2CS3Y_cjs = require('./chunk-NWS2CS3Y.cjs');
|
|
34
35
|
var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
|
|
35
36
|
var chunkSGC7LSHF_cjs = require('./chunk-SGC7LSHF.cjs');
|
|
36
37
|
var chunkHU666T3Q_cjs = require('./chunk-HU666T3Q.cjs');
|
|
@@ -338,6 +339,8 @@ function serializeMemory(memory) {
|
|
|
338
339
|
if (memory.scope !== void 0) out.scope = memory.scope;
|
|
339
340
|
if (memory.activeRecall !== void 0) out.activeRecall = { ...memory.activeRecall };
|
|
340
341
|
if (memory.index !== void 0) out.index = serializeMemoryIndex(memory.index);
|
|
342
|
+
if (memory.maxFacts !== void 0) out.maxFacts = memory.maxFacts;
|
|
343
|
+
if (memory.directory !== void 0) out.directory = memory.directory;
|
|
341
344
|
return out;
|
|
342
345
|
}
|
|
343
346
|
function serializeMemoryIndex(index) {
|
|
@@ -821,7 +824,7 @@ async function readLegacyFacts(jsonPath) {
|
|
|
821
824
|
}
|
|
822
825
|
async function writeMigratedFacts(cwd, jsonPath, facts) {
|
|
823
826
|
try {
|
|
824
|
-
for (const fact of facts) await
|
|
827
|
+
for (const fact of facts) await chunkZD66GFH5_cjs.appendFactToMarkdown(cwd, fact);
|
|
825
828
|
await promises.unlink(jsonPath).catch(() => void 0);
|
|
826
829
|
chunk6LHQPOMI_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
|
|
827
830
|
`);
|
|
@@ -838,11 +841,11 @@ async function migrateLegacyJson(cwd, config) {
|
|
|
838
841
|
const key = `${cwd}::${config.namespace ?? "default"}::${config.scope ?? "agent"}::${config.userId ?? "default"}`;
|
|
839
842
|
if (migrationRun.has(key)) return { migrated: false, factCount: 0, reason: "already-migrated" };
|
|
840
843
|
migrationRun.add(key);
|
|
841
|
-
const jsonPath =
|
|
844
|
+
const jsonPath = chunkZD66GFH5_cjs.legacyMemoryJsonPath(cwd, config);
|
|
842
845
|
if (!await fileExists(jsonPath)) {
|
|
843
846
|
return { migrated: false, factCount: 0, reason: "no-legacy-json" };
|
|
844
847
|
}
|
|
845
|
-
if (await fileExists(
|
|
848
|
+
if (await fileExists(chunkZD66GFH5_cjs.memoryMdPath(chunkZD66GFH5_cjs.resolveMemoryRoot(cwd, config)))) {
|
|
846
849
|
chunk6LHQPOMI_cjs.diag(
|
|
847
850
|
`[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
|
|
848
851
|
`
|
|
@@ -871,28 +874,29 @@ function unstoredRememberWarning(message) {
|
|
|
871
874
|
if (isMemoryWritePrompt(message) && extractMemoryFact(message).length > 0) return void 0;
|
|
872
875
|
const trimmed = message.trim();
|
|
873
876
|
const quoted = trimmed.length > QUOTED_MESSAGE_MAX ? `${trimmed.slice(0, QUOTED_MESSAGE_MAX)}\u2026` : trimmed;
|
|
874
|
-
return `[theokit-sdk] NOTHING WAS STORED \u2014 this message does not match the memory capture pattern: ${JSON.stringify(quoted)}. Supported: "Remember: <fact>" or "Remember (${
|
|
877
|
+
return `[theokit-sdk] NOTHING WAS STORED \u2014 this message does not match the memory capture pattern: ${JSON.stringify(quoted)}. Supported: "Remember: <fact>" or "Remember (${chunkZD66GFH5_cjs.MEMORY_KINDS.join("|")}): <fact>". It still reaches the session transcript, so a follow-up may answer from it \u2014 that is search over transcripts, not a durable memory.`;
|
|
875
878
|
}
|
|
876
879
|
function extractMemoryKind(message) {
|
|
877
880
|
const match = REMEMBER_PATTERN.exec(message);
|
|
878
881
|
const declared = match?.[1];
|
|
879
882
|
if (declared === void 0) return void 0;
|
|
880
883
|
const lowered = declared.toLowerCase();
|
|
881
|
-
return
|
|
884
|
+
return chunkZD66GFH5_cjs.MEMORY_KINDS.includes(lowered) ? lowered : void 0;
|
|
882
885
|
}
|
|
883
886
|
async function readMemoryFacts(cwd, config) {
|
|
884
887
|
if (!config.enabled) return [];
|
|
885
888
|
await migrateLegacyJson(cwd, config);
|
|
886
|
-
return
|
|
889
|
+
return chunkZD66GFH5_cjs.readFacts(cwd, config);
|
|
887
890
|
}
|
|
888
891
|
async function appendMemoryFact(cwd, config, fact) {
|
|
889
892
|
if (!config.enabled) return;
|
|
893
|
+
chunkZD66GFH5_cjs.resolveMaxFacts(config.maxFacts);
|
|
890
894
|
await migrateLegacyJson(cwd, config);
|
|
891
895
|
const sanitized = {
|
|
892
896
|
text: chunk6LHQPOMI_cjs.redactSecrets(fact.text),
|
|
893
897
|
...fact.kind === void 0 ? {} : { kind: fact.kind }
|
|
894
898
|
};
|
|
895
|
-
await
|
|
899
|
+
await chunkZD66GFH5_cjs.appendFact(cwd, config, sanitized);
|
|
896
900
|
}
|
|
897
901
|
|
|
898
902
|
// src/internal/runtime/fixtures/fixture-scripts.ts
|
|
@@ -1563,7 +1567,7 @@ function createRealCloudRun(options) {
|
|
|
1563
1567
|
conversation: []
|
|
1564
1568
|
};
|
|
1565
1569
|
const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(options.agentOptions.apiKey);
|
|
1566
|
-
const baseUrl =
|
|
1570
|
+
const baseUrl = chunkBZKF7TXX_cjs.getConfiguredBaseUrl();
|
|
1567
1571
|
const handle = new RealCloudRun(
|
|
1568
1572
|
{
|
|
1569
1573
|
id,
|
|
@@ -1646,7 +1650,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1646
1650
|
async consumeStream(response) {
|
|
1647
1651
|
let finalStatus = "finished";
|
|
1648
1652
|
let finalText = "";
|
|
1649
|
-
for await (const record of
|
|
1653
|
+
for await (const record of chunkBZKF7TXX_cjs.parseSseStream(response.body, this.controller.signal)) {
|
|
1650
1654
|
const parsed = safeParse(record.data);
|
|
1651
1655
|
if (parsed === void 0) continue;
|
|
1652
1656
|
const update = this.applyRecord(record.event, parsed);
|
|
@@ -1813,7 +1817,7 @@ var CloudAgent = class _CloudAgent {
|
|
|
1813
1817
|
*/
|
|
1814
1818
|
isFixtureMode() {
|
|
1815
1819
|
const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(this.options.apiKey);
|
|
1816
|
-
return
|
|
1820
|
+
return chunkBZKF7TXX_cjs.isFixtureApiKey(apiKey) && chunkBZKF7TXX_cjs.getConfiguredBaseUrl() === void 0;
|
|
1817
1821
|
}
|
|
1818
1822
|
// SE9 — integrated structured output; delegates to the shared helper.
|
|
1819
1823
|
generate(message, options) {
|
|
@@ -1865,7 +1869,7 @@ var CloudAgent = class _CloudAgent {
|
|
|
1865
1869
|
const userText = typeof message === "string" ? message : message.text;
|
|
1866
1870
|
const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
|
|
1867
1871
|
const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(this.options.apiKey);
|
|
1868
|
-
const useRealRuntime = apiKey !== void 0 && !
|
|
1872
|
+
const useRealRuntime = apiKey !== void 0 && !chunkBZKF7TXX_cjs.isFixtureApiKey(apiKey) && chunkBZKF7TXX_cjs.getConfiguredBaseUrl() !== void 0;
|
|
1869
1873
|
return useRealRuntime ? createRealCloudRun({
|
|
1870
1874
|
agentId: this.agentId,
|
|
1871
1875
|
model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
|
|
@@ -2199,7 +2203,7 @@ var PersonalityStore = class {
|
|
|
2199
2203
|
async #persist(agentId, slug) {
|
|
2200
2204
|
const filePath = this.#filePath();
|
|
2201
2205
|
await promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
2202
|
-
await
|
|
2206
|
+
await chunkASK2OQM5_cjs.withFileLock(filePath, async () => {
|
|
2203
2207
|
const current = await readState(filePath);
|
|
2204
2208
|
const nextAgents = { ...current.agents };
|
|
2205
2209
|
if (slug === void 0) delete nextAgents[agentId];
|
|
@@ -2930,7 +2934,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2930
2934
|
try {
|
|
2931
2935
|
const partial = await safeConversation(run);
|
|
2932
2936
|
if (partial !== void 0) {
|
|
2933
|
-
|
|
2937
|
+
chunkN7ZIPW2N_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2934
2938
|
userText,
|
|
2935
2939
|
conversation: partial
|
|
2936
2940
|
});
|
|
@@ -2940,11 +2944,11 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2940
2944
|
chunk6LHQPOMI_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2941
2945
|
`);
|
|
2942
2946
|
}
|
|
2943
|
-
await
|
|
2947
|
+
await chunkN7ZIPW2N_cjs.flushSessionWrites();
|
|
2944
2948
|
return;
|
|
2945
2949
|
}
|
|
2946
2950
|
if (result.result !== void 0) {
|
|
2947
|
-
|
|
2951
|
+
chunkN7ZIPW2N_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2948
2952
|
}
|
|
2949
2953
|
const conversation = await safeConversation(run);
|
|
2950
2954
|
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
@@ -2955,7 +2959,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2955
2959
|
}
|
|
2956
2960
|
const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
|
|
2957
2961
|
const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
|
|
2958
|
-
|
|
2962
|
+
chunkN7ZIPW2N_cjs.persistTurnToTranscript(
|
|
2959
2963
|
sessionStore,
|
|
2960
2964
|
{ cwd: workspaceCwd, agentId, model },
|
|
2961
2965
|
agentId,
|
|
@@ -2967,7 +2971,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2967
2971
|
// The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
|
|
2968
2972
|
// `contextWindow` here would budget against a number the clamp already rejected.
|
|
2969
2973
|
contextWindow: effectiveWindow,
|
|
2970
|
-
summarize:
|
|
2974
|
+
summarize: chunkBZKF7TXX_cjs.buildDefaultSummarizer({
|
|
2971
2975
|
agentModel: model,
|
|
2972
2976
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
2973
2977
|
})
|
|
@@ -2980,7 +2984,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2980
2984
|
cwd: workspaceCwd,
|
|
2981
2985
|
// Resolved once, here, and handed to both writers. Recomputing it inside either one is how
|
|
2982
2986
|
// the summary ended up in a directory the indexer never scanned (#463).
|
|
2983
|
-
memoryRoot:
|
|
2987
|
+
memoryRoot: chunkZD66GFH5_cjs.resolveMemoryRoot(workspaceCwd, inputs.memory),
|
|
2984
2988
|
runId: result.id,
|
|
2985
2989
|
agentId,
|
|
2986
2990
|
userText,
|
|
@@ -2992,7 +2996,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2992
2996
|
if (memoryProvider?.recordSessionSummary !== void 0) {
|
|
2993
2997
|
await memoryProvider.recordSessionSummary(summaryArgs);
|
|
2994
2998
|
} else {
|
|
2995
|
-
await
|
|
2999
|
+
await chunkZD66GFH5_cjs.writeSessionSummary(summaryArgs);
|
|
2996
3000
|
}
|
|
2997
3001
|
} catch (cause) {
|
|
2998
3002
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
@@ -3009,7 +3013,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
3009
3013
|
agentId,
|
|
3010
3014
|
runId: result.id
|
|
3011
3015
|
});
|
|
3012
|
-
await
|
|
3016
|
+
await chunkN7ZIPW2N_cjs.flushSessionWrites();
|
|
3013
3017
|
}
|
|
3014
3018
|
async function safeConversation(run) {
|
|
3015
3019
|
try {
|
|
@@ -3614,6 +3618,7 @@ function validateToolSchema(tool) {
|
|
|
3614
3618
|
}
|
|
3615
3619
|
function validateMemory(options) {
|
|
3616
3620
|
const memory = options.memory;
|
|
3621
|
+
chunkZD66GFH5_cjs.resolveMaxFacts(memory?.maxFacts);
|
|
3617
3622
|
if (memory?.storePath === void 0) return;
|
|
3618
3623
|
const storePath = memory.storePath;
|
|
3619
3624
|
if (storePath.includes("..") || storePath.startsWith("/") || /^[A-Z]:/i.test(storePath)) {
|
|
@@ -3639,7 +3644,7 @@ var HISTOGRAM_NAMES = {
|
|
|
3639
3644
|
};
|
|
3640
3645
|
function safeRequire(moduleName) {
|
|
3641
3646
|
try {
|
|
3642
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3647
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-5OHB5HJF.cjs', document.baseURI).href)));
|
|
3643
3648
|
return r(moduleName);
|
|
3644
3649
|
} catch {
|
|
3645
3650
|
return void 0;
|
|
@@ -3882,7 +3887,7 @@ var cachedOtel;
|
|
|
3882
3887
|
function loadOtel() {
|
|
3883
3888
|
if (cachedOtel === void 0) {
|
|
3884
3889
|
try {
|
|
3885
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3890
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-5OHB5HJF.cjs', document.baseURI).href)));
|
|
3886
3891
|
const mod = r("@opentelemetry/api");
|
|
3887
3892
|
cachedOtel = mod;
|
|
3888
3893
|
} catch {
|
|
@@ -5803,14 +5808,27 @@ function stripThinkBlocks(content) {
|
|
|
5803
5808
|
// src/internal/agent-loop/loop-llm-stream.ts
|
|
5804
5809
|
function resolveSystemPromptWithMemoryAdditions(systemPrompt, additions) {
|
|
5805
5810
|
if (additions === void 0 || additions.length === 0) return systemPrompt;
|
|
5806
|
-
const block =
|
|
5807
|
-
${chunkHG5LKFG7_cjs.escapeBlockBody(additions)}
|
|
5808
|
-
</active-memory>`;
|
|
5811
|
+
const block = activeMemoryBlock(additions);
|
|
5809
5812
|
if (systemPrompt === void 0 || systemPrompt.length === 0) return block;
|
|
5810
5813
|
return `${block}
|
|
5811
5814
|
|
|
5812
5815
|
${systemPrompt}`;
|
|
5813
5816
|
}
|
|
5817
|
+
function activeMemoryBlock(additions) {
|
|
5818
|
+
return `<active-memory>
|
|
5819
|
+
${chunkHG5LKFG7_cjs.escapeBlockBody(additions)}
|
|
5820
|
+
</active-memory>`;
|
|
5821
|
+
}
|
|
5822
|
+
function buildLoopSystem(systemPrompt, additions, modelId) {
|
|
5823
|
+
if (!chunkNWS2CS3Y_cjs.isAnthropicFamilyModel(modelId) || systemPrompt === void 0 || systemPrompt.length === 0) {
|
|
5824
|
+
return resolveSystemPromptWithMemoryAdditions(systemPrompt, additions);
|
|
5825
|
+
}
|
|
5826
|
+
const blocks = [{ text: systemPrompt, cacheable: true }];
|
|
5827
|
+
if (additions !== void 0 && additions.length > 0) {
|
|
5828
|
+
blocks.push({ text: activeMemoryBlock(additions) });
|
|
5829
|
+
}
|
|
5830
|
+
return blocks;
|
|
5831
|
+
}
|
|
5814
5832
|
function toLlmTool(tool) {
|
|
5815
5833
|
return { name: tool.name, description: tool.description, inputSchema: tool.inputSchema };
|
|
5816
5834
|
}
|
|
@@ -5849,9 +5867,10 @@ async function streamLlmTurn(inputs, ctx) {
|
|
|
5849
5867
|
{
|
|
5850
5868
|
model: inputs.model.id ?? "auto",
|
|
5851
5869
|
...(() => {
|
|
5852
|
-
const effective =
|
|
5870
|
+
const effective = buildLoopSystem(
|
|
5853
5871
|
inputs.systemPrompt,
|
|
5854
|
-
ctx.memorySystemPromptAdditions
|
|
5872
|
+
ctx.memorySystemPromptAdditions,
|
|
5873
|
+
inputs.model.id
|
|
5855
5874
|
);
|
|
5856
5875
|
return effective !== void 0 ? { system: effective } : {};
|
|
5857
5876
|
})(),
|
|
@@ -6650,7 +6669,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
6650
6669
|
(p) => (
|
|
6651
6670
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
6652
6671
|
// structured content); image blocks pass through untouched.
|
|
6653
|
-
p.type === "tool_result" ? { ...p, content:
|
|
6672
|
+
p.type === "tool_result" ? { ...p, content: chunkBZKF7TXX_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
6654
6673
|
)
|
|
6655
6674
|
);
|
|
6656
6675
|
}
|
|
@@ -6838,29 +6857,32 @@ async function runIteration(inputs, ctx) {
|
|
|
6838
6857
|
const llmOutput = await streamLlmTurn(inputs, ctx);
|
|
6839
6858
|
await inputs.pluginManager?.runPostLlmCallHooks(hookCtx);
|
|
6840
6859
|
accumulateUsage(ctx.usage, llmOutput);
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
type: "output"
|
|
6858
|
-
});
|
|
6859
|
-
}
|
|
6860
|
-
} catch {
|
|
6860
|
+
trackTurnUsage(inputs, llmOutput);
|
|
6861
|
+
return continueOrTerminate(inputs, ctx, llmOutput);
|
|
6862
|
+
}
|
|
6863
|
+
function trackTurnUsage(inputs, llmOutput) {
|
|
6864
|
+
const tracker = inputs.budgetTracker;
|
|
6865
|
+
if (tracker === void 0) return;
|
|
6866
|
+
const modelId = inputs.model.id ?? "auto";
|
|
6867
|
+
const inputT = (llmOutput.inputTokens ?? 0) + (llmOutput.cacheReadTokens ?? 0) + (llmOutput.cacheWriteTokens ?? 0);
|
|
6868
|
+
const outputT = llmOutput.outputTokens ?? 0;
|
|
6869
|
+
try {
|
|
6870
|
+
if (inputT > 0) {
|
|
6871
|
+
tracker.track({
|
|
6872
|
+
tokens: inputT,
|
|
6873
|
+
model: modelId,
|
|
6874
|
+
type: "input"
|
|
6875
|
+
});
|
|
6861
6876
|
}
|
|
6877
|
+
if (outputT > 0) {
|
|
6878
|
+
tracker.track({
|
|
6879
|
+
tokens: outputT,
|
|
6880
|
+
model: modelId,
|
|
6881
|
+
type: "output"
|
|
6882
|
+
});
|
|
6883
|
+
}
|
|
6884
|
+
} catch {
|
|
6862
6885
|
}
|
|
6863
|
-
return continueOrTerminate(inputs, ctx, llmOutput);
|
|
6864
6886
|
}
|
|
6865
6887
|
async function transformLlmOutputText(inputs, text, ctx) {
|
|
6866
6888
|
return inputs.pluginManager !== void 0 ? inputs.pluginManager.runTransformLlmOutputHooks(text, ctx) : text;
|
|
@@ -6942,13 +6964,13 @@ var FallbackLlmClient = class {
|
|
|
6942
6964
|
async *stream(request, signal) {
|
|
6943
6965
|
let lastError;
|
|
6944
6966
|
for (const client of this.clients) {
|
|
6945
|
-
if (signal.aborted) throw
|
|
6946
|
-
const attempt = await
|
|
6967
|
+
if (signal.aborted) throw chunkBZKF7TXX_cjs.abortError(signal);
|
|
6968
|
+
const attempt = await chunkBZKF7TXX_cjs.tryFirstEvent(client, request, signal, true);
|
|
6947
6969
|
if (attempt.kind === "handshake_error") {
|
|
6948
6970
|
lastError = attempt.error;
|
|
6949
6971
|
continue;
|
|
6950
6972
|
}
|
|
6951
|
-
return yield*
|
|
6973
|
+
return yield* chunkBZKF7TXX_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
6952
6974
|
}
|
|
6953
6975
|
if (lastError !== void 0) throw lastError;
|
|
6954
6976
|
throw new chunkUNFBHV46_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
@@ -7584,9 +7606,9 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7584
7606
|
{ code: "invalid_max_iterations" }
|
|
7585
7607
|
);
|
|
7586
7608
|
}
|
|
7587
|
-
const { primary, effectiveModelId } =
|
|
7609
|
+
const { primary, effectiveModelId } = chunkBZKF7TXX_cjs.resolveRunProvider(options);
|
|
7588
7610
|
const fallback = options.agentOptions.providers?.fallback;
|
|
7589
|
-
const apiKeys =
|
|
7611
|
+
const apiKeys = chunkBZKF7TXX_cjs.mergeExplicitApiKey(
|
|
7590
7612
|
options.agentOptions.providers?.apiKeys,
|
|
7591
7613
|
primary,
|
|
7592
7614
|
options.agentOptions.apiKey
|
|
@@ -7595,7 +7617,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7595
7617
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7596
7618
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7597
7619
|
const modelBaseUrl = options.model?.url;
|
|
7598
|
-
const chain =
|
|
7620
|
+
const chain = chunkBZKF7TXX_cjs.resolveProviderChain({
|
|
7599
7621
|
primary,
|
|
7600
7622
|
...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
|
|
7601
7623
|
...fallback !== void 0 ? { fallback } : {},
|
|
@@ -7855,7 +7877,7 @@ function buildRealRunOptions(args) {
|
|
|
7855
7877
|
};
|
|
7856
7878
|
}
|
|
7857
7879
|
async function createFixtureRunHelper(args) {
|
|
7858
|
-
const sessionMessages =
|
|
7880
|
+
const sessionMessages = chunkN7ZIPW2N_cjs.getSessionMessages(args.inputs.agentId);
|
|
7859
7881
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7860
7882
|
return createLocalRun({
|
|
7861
7883
|
agentId: args.inputs.agentId,
|
|
@@ -7874,7 +7896,7 @@ async function createFixtureRunHelper(args) {
|
|
|
7874
7896
|
}
|
|
7875
7897
|
async function dispatchLocalRun(args) {
|
|
7876
7898
|
const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(args.inputs.options.apiKey);
|
|
7877
|
-
if (
|
|
7899
|
+
if (chunkBZKF7TXX_cjs.shouldUseRealLocalRuntime(apiKey)) {
|
|
7878
7900
|
return createRealLocalRun(
|
|
7879
7901
|
buildRealRunOptions({
|
|
7880
7902
|
inputs: args.inputs,
|
|
@@ -8130,10 +8152,10 @@ async function disposeLocalAgentSession(agent) {
|
|
|
8130
8152
|
agent.lifecycleAbortController.abort();
|
|
8131
8153
|
await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
|
|
8132
8154
|
disposeSessionMcpClients(agent.agentId);
|
|
8133
|
-
await
|
|
8155
|
+
await chunkN7ZIPW2N_cjs.flushSessionWrites();
|
|
8134
8156
|
await flushRegistrySaves(agent.workspaceCwd);
|
|
8135
8157
|
await disposeSessionStore(agent.sessionStore);
|
|
8136
|
-
|
|
8158
|
+
chunkN7ZIPW2N_cjs.discardSession(agent.workspaceCwd, agent.agentId);
|
|
8137
8159
|
}
|
|
8138
8160
|
async function reloadLocalAgent(agent) {
|
|
8139
8161
|
if (agent.context !== void 0) await agent.context.refresh();
|
|
@@ -8385,7 +8407,7 @@ async function finalize(args, queryMode, result) {
|
|
|
8385
8407
|
};
|
|
8386
8408
|
args.cache?.set(args.userText, queryMode, result, tenantCtx);
|
|
8387
8409
|
if (args.persistTranscripts === true && args.cwd !== void 0) {
|
|
8388
|
-
await chunkTMKTSYDS_cjs.persistActiveMemoryTranscript(args.memoryRoot ??
|
|
8410
|
+
await chunkTMKTSYDS_cjs.persistActiveMemoryTranscript(args.memoryRoot ?? chunkZD66GFH5_cjs.resolveMemoryRoot(args.cwd), {
|
|
8389
8411
|
runId: args.runId ?? `run-${Date.now()}`,
|
|
8390
8412
|
startedAtMs: Date.now() - result.durationMs,
|
|
8391
8413
|
userText: args.userText,
|
|
@@ -8976,7 +8998,7 @@ var LocalAgentMemory = class {
|
|
|
8976
8998
|
const openOpts = { cwd: this.workspaceCwd, memoryRoot };
|
|
8977
8999
|
if (embedding !== void 0) openOpts.embedding = embedding;
|
|
8978
9000
|
if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
|
|
8979
|
-
this.index = await
|
|
9001
|
+
this.index = await chunkL3C6CCBG_cjs.IndexManager.open(openOpts);
|
|
8980
9002
|
await this.index.sync();
|
|
8981
9003
|
this.toolsCache = [
|
|
8982
9004
|
createMemorySearchTool({ index: this.index }),
|
|
@@ -8997,7 +9019,7 @@ var LocalAgentMemory = class {
|
|
|
8997
9019
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
8998
9020
|
const cfg = this.options.memory?.activeRecall;
|
|
8999
9021
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
9000
|
-
if (this.breaker === void 0) this.breaker = new
|
|
9022
|
+
if (this.breaker === void 0) this.breaker = new chunkBZKF7TXX_cjs.CircuitBreaker();
|
|
9001
9023
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
9002
9024
|
const result = await runActiveMemory({
|
|
9003
9025
|
userText,
|
|
@@ -9020,7 +9042,7 @@ var LocalAgentMemory = class {
|
|
|
9020
9042
|
* and the active-memory transcript writer. Three separate resolutions is how they drifted (#463).
|
|
9021
9043
|
*/
|
|
9022
9044
|
memoryRoot() {
|
|
9023
|
-
this.memoryRootCache ??=
|
|
9045
|
+
this.memoryRootCache ??= chunkZD66GFH5_cjs.resolveMemoryRoot(this.workspaceCwd, this.options.memory);
|
|
9024
9046
|
return this.memoryRootCache;
|
|
9025
9047
|
}
|
|
9026
9048
|
buildActiveMemoryOptions(cfg) {
|
|
@@ -9135,7 +9157,7 @@ function createLocalAgentMemoryProvider(opts) {
|
|
|
9135
9157
|
return { facts: [], systemPromptAdditions: summary };
|
|
9136
9158
|
},
|
|
9137
9159
|
async recordSessionSummary(args) {
|
|
9138
|
-
await
|
|
9160
|
+
await chunkZD66GFH5_cjs.writeSessionSummary(args);
|
|
9139
9161
|
},
|
|
9140
9162
|
async sync(handle) {
|
|
9141
9163
|
const state = handle[INTERNAL_LAM_KEY];
|
|
@@ -9312,8 +9334,8 @@ async function localAgentUsePersonality(agent, name, opts) {
|
|
|
9312
9334
|
registry,
|
|
9313
9335
|
store: agent.personalityStore,
|
|
9314
9336
|
invalidateCache: (reason) => agent.invalidateCache(reason),
|
|
9315
|
-
appendSessionMessage: (msg) =>
|
|
9316
|
-
clearSession: () =>
|
|
9337
|
+
appendSessionMessage: (msg) => chunkN7ZIPW2N_cjs.appendSessionMessage(agent.agentId, msg),
|
|
9338
|
+
clearSession: () => chunkN7ZIPW2N_cjs.clearSession(agent.agentId),
|
|
9317
9339
|
opts: opts ?? {}
|
|
9318
9340
|
})
|
|
9319
9341
|
);
|
|
@@ -9867,7 +9889,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9867
9889
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9868
9890
|
await inputs.options.onBeforeSend({
|
|
9869
9891
|
conversationId: inputs.agentId,
|
|
9870
|
-
previousMessageCount:
|
|
9892
|
+
previousMessageCount: chunkN7ZIPW2N_cjs.getSessionMessages(inputs.agentId).length
|
|
9871
9893
|
});
|
|
9872
9894
|
}
|
|
9873
9895
|
await inputs.runPreHook(userText);
|
|
@@ -9879,8 +9901,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9879
9901
|
userText,
|
|
9880
9902
|
sendOptions: options
|
|
9881
9903
|
});
|
|
9882
|
-
const priorMessages = [...
|
|
9883
|
-
|
|
9904
|
+
const priorMessages = [...chunkN7ZIPW2N_cjs.getSessionMessages(inputs.agentId)];
|
|
9905
|
+
chunkN7ZIPW2N_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9884
9906
|
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9885
9907
|
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9886
9908
|
const memoryTools = void 0;
|
|
@@ -10133,7 +10155,7 @@ var LocalAgent = class {
|
|
|
10133
10155
|
this.options = options;
|
|
10134
10156
|
this.workspaceCwd = resolveCwd(options.local?.cwd);
|
|
10135
10157
|
this.transcriptBaseDir = resolveSessionDir(options.local);
|
|
10136
|
-
this.sessionStore = options.local?.sessionStore ?? new
|
|
10158
|
+
this.sessionStore = options.local?.sessionStore ?? new chunkNQVWSSX2_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
|
|
10137
10159
|
this.settingSourcesIncludeProject = includesSetting(options, "project");
|
|
10138
10160
|
this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
|
|
10139
10161
|
const sub = bootstrapSubmanagers({
|
|
@@ -10186,7 +10208,7 @@ var LocalAgent = class {
|
|
|
10186
10208
|
);
|
|
10187
10209
|
await acquireLeaseIfPossible(this.sessionStore, this.agentId);
|
|
10188
10210
|
try {
|
|
10189
|
-
await
|
|
10211
|
+
await chunkN7ZIPW2N_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
10190
10212
|
await this.personalityStore.hydrate(this.agentId);
|
|
10191
10213
|
} catch (err) {
|
|
10192
10214
|
await releaseLeaseIfPossible(this.sessionStore, this.agentId);
|
|
@@ -10527,15 +10549,15 @@ async function maybeInjectHandoffTools(options) {
|
|
|
10527
10549
|
};
|
|
10528
10550
|
}
|
|
10529
10551
|
function keyWillFlowToProvider(apiKey, provider) {
|
|
10530
|
-
if (
|
|
10531
|
-
if (
|
|
10552
|
+
if (chunkBZKF7TXX_cjs.isFixtureApiKey(apiKey)) return false;
|
|
10553
|
+
if (chunkBZKF7TXX_cjs.getConfiguredBaseUrl() !== void 0) return false;
|
|
10532
10554
|
if (provider === void 0) return false;
|
|
10533
10555
|
const profile = chunkSGC7LSHF_cjs.getProviderProfile(provider);
|
|
10534
10556
|
if (profile === void 0) return false;
|
|
10535
10557
|
return profile.authType !== "none";
|
|
10536
10558
|
}
|
|
10537
10559
|
function missingApiKeyMessage() {
|
|
10538
|
-
const present =
|
|
10560
|
+
const present = chunkBZKF7TXX_cjs.presentProviderCredentialEnvVars();
|
|
10539
10561
|
const base = `Missing API key \u2014 set ${chunk6LHQPOMI_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
|
|
10540
10562
|
if (present.length === 0) return `${base}.`;
|
|
10541
10563
|
return `${base}. ${present.join(" and ")} ${present.length === 1 ? "is" : "are"} set, but a provider credential is not read from the environment automatically \u2014 pass it explicitly, e.g. \`Agent.create({ apiKey: process.env.${present[0]}, ... })\`.`;
|
|
@@ -10555,7 +10577,7 @@ async function createLocalAgent(options) {
|
|
|
10555
10577
|
}
|
|
10556
10578
|
} else {
|
|
10557
10579
|
const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
|
|
10558
|
-
const shape =
|
|
10580
|
+
const shape = chunkBZKF7TXX_cjs.validateApiKeyShape(apiKey, {
|
|
10559
10581
|
strict: willFlowToProvider,
|
|
10560
10582
|
...willFlowToProvider ? { provider } : {}
|
|
10561
10583
|
});
|
|
@@ -10574,15 +10596,15 @@ async function createCloudAgent(options) {
|
|
|
10574
10596
|
code: "missing_api_key"
|
|
10575
10597
|
});
|
|
10576
10598
|
}
|
|
10577
|
-
const shape =
|
|
10599
|
+
const shape = chunkBZKF7TXX_cjs.validateApiKeyShape(apiKey);
|
|
10578
10600
|
if (shape.malformed) {
|
|
10579
10601
|
throw new chunkUNFBHV46_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
|
|
10580
10602
|
}
|
|
10581
|
-
const baseUrl =
|
|
10603
|
+
const baseUrl = chunkBZKF7TXX_cjs.getConfiguredBaseUrl();
|
|
10582
10604
|
if (baseUrl === void 0) {
|
|
10583
10605
|
return new CloudAgent(options);
|
|
10584
10606
|
}
|
|
10585
|
-
const response = await
|
|
10607
|
+
const response = await chunkBZKF7TXX_cjs.httpRequest("/v1/agents", {
|
|
10586
10608
|
apiKey,
|
|
10587
10609
|
method: "POST",
|
|
10588
10610
|
body: {
|
|
@@ -10607,13 +10629,15 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
10607
10629
|
return process.cwd();
|
|
10608
10630
|
}
|
|
10609
10631
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
10610
|
-
await
|
|
10632
|
+
await chunkBZKF7TXX_cjs.discoverProviderPlugins();
|
|
10611
10633
|
await validateRehydratedAgent(agentId, existing);
|
|
10612
10634
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
10635
|
+
const mergedMemory = mergeResumedMemory(existing.options.memory, options.memory);
|
|
10613
10636
|
const mergedOptions = {
|
|
10614
10637
|
...existing.options,
|
|
10615
10638
|
...options,
|
|
10616
10639
|
...mergedLocal !== void 0 ? { local: mergedLocal } : {},
|
|
10640
|
+
...mergedMemory !== void 0 ? { memory: mergedMemory } : {},
|
|
10617
10641
|
// SE8 — normalize a caller-supplied bare-string model override at this resume
|
|
10618
10642
|
// boundary (Agent.resume never flows through runCreateUnderSpan). Cloud resume
|
|
10619
10643
|
// honors it; local resume forces the persisted model below.
|
|
@@ -10621,6 +10645,7 @@ async function rehydrateExistingAgent(agentId, existing, options) {
|
|
|
10621
10645
|
mcpServers: void 0,
|
|
10622
10646
|
agentId
|
|
10623
10647
|
};
|
|
10648
|
+
chunkZD66GFH5_cjs.resolveMaxFacts(mergedOptions.memory?.maxFacts);
|
|
10624
10649
|
if (existing.runtime === "cloud") {
|
|
10625
10650
|
return new CloudAgent(mergedOptions, agentId);
|
|
10626
10651
|
}
|
|
@@ -10628,6 +10653,12 @@ async function rehydrateExistingAgent(agentId, existing, options) {
|
|
|
10628
10653
|
await agent.initialize();
|
|
10629
10654
|
return agent;
|
|
10630
10655
|
}
|
|
10656
|
+
function mergeResumedMemory(persisted, override) {
|
|
10657
|
+
if (override === void 0) return persisted;
|
|
10658
|
+
if (persisted === void 0) return override;
|
|
10659
|
+
const named = Object.entries(override).filter(([, value]) => value !== void 0);
|
|
10660
|
+
return { ...persisted, ...Object.fromEntries(named) };
|
|
10661
|
+
}
|
|
10631
10662
|
async function validateRehydratedAgent(agentId, entry) {
|
|
10632
10663
|
if (entry.runtime !== "local") return;
|
|
10633
10664
|
const candidate = entry.options.local?.cwd ?? entry.cwd;
|
|
@@ -10758,7 +10789,7 @@ var Agent = class _Agent {
|
|
|
10758
10789
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
10759
10790
|
});
|
|
10760
10791
|
try {
|
|
10761
|
-
await
|
|
10792
|
+
await chunkBZKF7TXX_cjs.discoverProviderPlugins();
|
|
10762
10793
|
const agent = await runCreateUnderSpan(options, span);
|
|
10763
10794
|
return agent;
|
|
10764
10795
|
} catch (err) {
|
|
@@ -11056,9 +11087,9 @@ var Agent = class _Agent {
|
|
|
11056
11087
|
*/
|
|
11057
11088
|
static async compact(agentId, options = {}) {
|
|
11058
11089
|
const reg = await requireLocalAgent(agentId, "compact");
|
|
11059
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
11090
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-2AETONOS.cjs');
|
|
11060
11091
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
11061
|
-
return
|
|
11092
|
+
return chunkN7ZIPW2N_cjs.enqueueSessionWrite(
|
|
11062
11093
|
cwd,
|
|
11063
11094
|
agentId,
|
|
11064
11095
|
() => compactSessionTranscript({
|
|
@@ -11086,7 +11117,7 @@ var Agent = class _Agent {
|
|
|
11086
11117
|
*/
|
|
11087
11118
|
static async injectSessionTurn(agentId, turn) {
|
|
11088
11119
|
const reg = await requireLocalAgent(agentId, "injectSessionTurn");
|
|
11089
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
11120
|
+
const { injectSessionTurn } = await import('./inject-session-W4UKACYJ.cjs');
|
|
11090
11121
|
const { cwd, model, store } = await openLocalStore(reg);
|
|
11091
11122
|
await injectSessionTurn({
|
|
11092
11123
|
store,
|
|
@@ -11236,7 +11267,7 @@ async function openLocalStore(reg) {
|
|
|
11236
11267
|
const cwd = reg.cwd ?? process.cwd();
|
|
11237
11268
|
const optModel = reg.options.model;
|
|
11238
11269
|
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
11239
|
-
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-
|
|
11270
|
+
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-IQ6PEHYF.cjs');
|
|
11240
11271
|
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-RACG7BK2.cjs');
|
|
11241
11272
|
const configuredSessionDir = reg.options.local?.sessionDir ?? reg.options.local?.baseDir;
|
|
11242
11273
|
const baseDir = configuredSessionDir !== void 0 ? expandTilde2(configuredSessionDir) : defaultBaseDir2();
|
|
@@ -11257,5 +11288,5 @@ exports.managedSettingsPathFor = managedSettingsPathFor;
|
|
|
11257
11288
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
11258
11289
|
exports.readManagedSettings = readManagedSettings;
|
|
11259
11290
|
exports.resolveSessionDir = resolveSessionDir;
|
|
11260
|
-
//# sourceMappingURL=chunk-
|
|
11261
|
-
//# sourceMappingURL=chunk-
|
|
11291
|
+
//# sourceMappingURL=chunk-5OHB5HJF.cjs.map
|
|
11292
|
+
//# sourceMappingURL=chunk-5OHB5HJF.cjs.map
|