@theokit/sdk 4.31.0 → 4.31.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 +14 -0
- package/dist/{agent-Ekv8y7_c.d.ts → agent-BJbGi8-R.d.ts} +1 -1
- package/dist/{agent-6GQBOHHA.cjs → agent-BKNJIOEY.cjs} +9 -9
- package/dist/{agent-6GQBOHHA.cjs.map → agent-BKNJIOEY.cjs.map} +1 -1
- package/dist/{agent-Bzg2_uGr.d.cts → agent-CbZPGFfM.d.cts} +1 -1
- package/dist/{agent-DY5LGZ5E.js → agent-HW7OY2W3.js} +8 -8
- package/dist/{agent-DY5LGZ5E.js.map → agent-HW7OY2W3.js.map} +1 -1
- package/dist/{chunk-FZ75EZR5.js → chunk-CCRWSZ2F.js} +35 -28
- package/dist/chunk-CCRWSZ2F.js.map +1 -0
- package/dist/{chunk-WQEQCJTZ.cjs → chunk-CJVMDRQB.cjs} +26 -3
- package/dist/chunk-CJVMDRQB.cjs.map +1 -0
- package/dist/{chunk-XJT5VACT.cjs → chunk-E2YEDATX.cjs} +6 -6
- package/dist/{chunk-XJT5VACT.cjs.map → chunk-E2YEDATX.cjs.map} +1 -1
- package/dist/{chunk-FDGRQQWX.cjs → chunk-GQBXBHZ2.cjs} +5 -5
- package/dist/{chunk-FDGRQQWX.cjs.map → chunk-GQBXBHZ2.cjs.map} +1 -1
- package/dist/{chunk-U447MTG4.cjs → chunk-IOOSAZZH.cjs} +8 -8
- package/dist/chunk-IOOSAZZH.cjs.map +1 -0
- package/dist/{chunk-UKNMWCPZ.cjs → chunk-NZCFLEHO.cjs} +133 -70
- package/dist/chunk-NZCFLEHO.cjs.map +1 -0
- package/dist/{chunk-PORDVVJS.js → chunk-RPKTXBPK.js} +4 -4
- package/dist/chunk-RPKTXBPK.js.map +1 -0
- package/dist/{chunk-CYTAM3E6.cjs → chunk-S6F3FKFR.cjs} +65 -58
- package/dist/chunk-S6F3FKFR.cjs.map +1 -0
- package/dist/{chunk-VUXLNVX7.js → chunk-SJLOIZ4Z.js} +4 -4
- package/dist/{chunk-VUXLNVX7.js.map → chunk-SJLOIZ4Z.js.map} +1 -1
- package/dist/{chunk-4SXHEZIV.cjs → chunk-U2FO3MRG.cjs} +9 -3
- package/dist/chunk-U2FO3MRG.cjs.map +1 -0
- package/dist/{chunk-ICSCKB3N.js → chunk-UAYYNWYJ.js} +27 -4
- package/dist/chunk-UAYYNWYJ.js.map +1 -0
- package/dist/{chunk-ZZWTY3RX.js → chunk-VGUOUAM2.js} +9 -4
- package/dist/chunk-VGUOUAM2.js.map +1 -0
- package/dist/{chunk-4JWZRASX.js → chunk-WYPHQ7NM.js} +3 -3
- package/dist/{chunk-4JWZRASX.js.map → chunk-WYPHQ7NM.js.map} +1 -1
- package/dist/{chunk-TLG444A6.js → chunk-XDNGF5BY.js} +130 -67
- package/dist/chunk-XDNGF5BY.js.map +1 -0
- package/dist/{compact-session-2BFNMENR.cjs → compact-session-42BK7RE3.cjs} +12 -12
- package/dist/{compact-session-2BFNMENR.cjs.map → compact-session-42BK7RE3.cjs.map} +1 -1
- package/dist/{compact-session-2JONXHLR.js → compact-session-QMBOCFVQ.js} +4 -4
- package/dist/{compact-session-2JONXHLR.js.map → compact-session-QMBOCFVQ.js.map} +1 -1
- package/dist/{cron-D0Z29gI-.d.ts → cron-BU9qD5B6.d.ts} +2 -2
- package/dist/{cron-CjzvXGT2.d.cts → cron-BwojPwEs.d.cts} +2 -2
- package/dist/cron.cjs +8 -8
- package/dist/cron.d.cts +3 -3
- package/dist/cron.d.ts +3 -3
- package/dist/cron.js +7 -7
- package/dist/{errors-DHZtSNnj.d.ts → errors-Cua4WC9H.d.ts} +1 -1
- package/dist/{errors-BdL-buYn.d.cts → errors-DyVbXdR4.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/errors.d.ts +2 -2
- package/dist/eval.cjs +11 -11
- package/dist/eval.js +7 -7
- package/dist/fs-session-store-IIP7ZBYE.cjs +17 -0
- package/dist/{fs-session-store-26WVVMC4.cjs.map → fs-session-store-IIP7ZBYE.cjs.map} +1 -1
- package/dist/fs-session-store-T7YPW5A4.js +8 -0
- package/dist/{fs-session-store-7AEI4STY.js.map → fs-session-store-T7YPW5A4.js.map} +1 -1
- package/dist/index.cjs +29 -29
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +9 -9
- package/dist/{inject-session-MIFEKATN.cjs → inject-session-6ZMCA2NE.cjs} +6 -6
- package/dist/{inject-session-MIFEKATN.cjs.map → inject-session-6ZMCA2NE.cjs.map} +1 -1
- package/dist/{inject-session-NNSCCIVP.js → inject-session-YA3GQE4G.js} +4 -4
- package/dist/{inject-session-NNSCCIVP.js.map → inject-session-YA3GQE4G.js.map} +1 -1
- package/dist/internal/llm/abort-error.d.ts +1 -0
- package/dist/internal/llm/retrying-client.d.ts +27 -3
- package/dist/internal/llm/transport-error.d.ts +9 -0
- package/dist/internal/persistence/index.cjs +6 -6
- package/dist/internal/persistence/index.js +1 -1
- package/dist/internal/persistence/session-transcript.d.cts +13 -1
- package/dist/internal/persistence/session-transcript.d.ts +13 -1
- package/dist/internal/runtime/lifecycle/post-run-lifecycle.d.ts +1 -1
- package/dist/persistence.cjs +13 -9
- package/dist/persistence.d.cts +1 -1
- package/dist/persistence.d.ts +1 -1
- package/dist/persistence.js +2 -2
- package/dist/{run-OJbGyweZ.d.ts → run-CwEJtLPE.d.cts} +8 -0
- package/dist/{run-OJbGyweZ.d.cts → run-CwEJtLPE.d.ts} +8 -0
- package/dist/server/errors-envelope.d.cts +3 -3
- package/dist/server/errors-envelope.d.ts +3 -3
- package/dist/{session-transcript-T7LGJUGW.js → session-transcript-5VZUWEJ5.js} +3 -3
- package/dist/{session-transcript-T7LGJUGW.js.map → session-transcript-5VZUWEJ5.js.map} +1 -1
- package/dist/session-transcript-T4SB66I7.cjs +50 -0
- package/dist/{session-transcript-LPNZR3YS.cjs.map → session-transcript-T4SB66I7.cjs.map} +1 -1
- package/dist/subagents-loader.d.cts +2 -2
- package/dist/subagents-loader.d.ts +2 -2
- package/dist/types/agent-prims.d.ts +8 -0
- package/package.json +1 -1
- package/dist/chunk-4SXHEZIV.cjs.map +0 -1
- package/dist/chunk-CYTAM3E6.cjs.map +0 -1
- package/dist/chunk-FZ75EZR5.js.map +0 -1
- package/dist/chunk-ICSCKB3N.js.map +0 -1
- package/dist/chunk-PORDVVJS.js.map +0 -1
- package/dist/chunk-TLG444A6.js.map +0 -1
- package/dist/chunk-U447MTG4.cjs.map +0 -1
- package/dist/chunk-UKNMWCPZ.cjs.map +0 -1
- package/dist/chunk-WQEQCJTZ.cjs.map +0 -1
- package/dist/chunk-ZZWTY3RX.js.map +0 -1
- package/dist/fs-session-store-26WVVMC4.cjs +0 -17
- package/dist/fs-session-store-7AEI4STY.js +0 -8
- package/dist/session-transcript-LPNZR3YS.cjs +0 -46
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withFileLock, appendJsonl } from './chunk-
|
|
2
|
-
import { readTranscript, transcriptPath } from './chunk-
|
|
1
|
+
import { withFileLock, appendJsonl } from './chunk-UAYYNWYJ.js';
|
|
2
|
+
import { readTranscript, transcriptPath } from './chunk-VGUOUAM2.js';
|
|
3
3
|
import { mkdir } from 'fs/promises';
|
|
4
4
|
import { dirname } from 'path';
|
|
5
5
|
|
|
@@ -24,5 +24,5 @@ var FsSessionStore = class {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export { FsSessionStore };
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-RPKTXBPK.js.map
|
|
28
|
+
//# sourceMappingURL=chunk-RPKTXBPK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internal/persistence/fs-session-store.ts"],"names":[],"mappings":";;;;;AAyCO,IAAM,iBAAN,MAA6C;AAAA,EACzC,QAAA;AAAA,EACA,IAAA;AAAA,EAET,YAAY,OAAA,EAAgC;AAC1C,IAAA,IAAA,CAAK,WAAW,OAAA,CAAQ,OAAA;AACxB,IAAA,IAAA,CAAK,OAAO,OAAA,CAAQ,GAAA;AAAA,EACtB;AAAA,EAEA,MAAM,YAAY,OAAA,EAA2C;AAC3D,IAAA,OAAO,eAAe,cAAA,CAAe,IAAA,CAAK,UAAU,IAAA,CAAK,IAAA,EAAM,OAAO,CAAC,CAAA;AAAA,EACzE;AAAA,EAEA,MAAM,aAAA,CAAc,OAAA,EAAiB,OAAA,EAAkD;AAErF,IAAA,IAAI,OAAA,CAAQ,WAAW,CAAA,EAAG;AAC1B,IAAA,MAAM,OAAO,cAAA,CAAe,IAAA,CAAK,QAAA,EAAU,IAAA,CAAK,MAAM,OAAO,CAAA;AAE7D,IAAA,MAAM,MAAM,OAAA,CAAQ,IAAI,GAAG,EAAE,SAAA,EAAW,MAAM,CAAA;AAC9C,IAAA,MAAM,YAAA,CAAa,MAAM,YAAY;AAyBnC,MAAA,KAAA,MAAW,MAAA,IAAU,OAAA,EAAS,WAAA,CAAY,IAAA,EAAM,MAAM,CAAA;AAAA,IACxD,CAAC,CAAA;AAAA,EACH;AACF","file":"chunk-RPKTXBPK.js","sourcesContent":["/**\n * SE41 — `FsSessionStore`, the DEFAULT reference implementation of the pluggable\n * {@link SessionStore} seam. It reads and append-writes the native Claude-shaped\n * `.jsonl` transcript at `<baseDir>/projects/<encoded-cwd>/<agentId>.jsonl` — the\n * exact on-disk format SE40 introduced (the file the Claude Code CLI can\n * `--continue`). Omitting `local.sessionStore` resolves to this store, so the\n * default persistence path is byte-identical to SE40 behavior.\n *\n * `readRecords` is `readTranscript(transcriptPath(...))` (a missing session →\n * `[]`, not an error — a fresh agent has no history). `appendRecords` is a TRUE\n * append: it reads the prior records, concatenates the new-turn delta, and\n * rewrites the whole line set atomically under the SE40 cross-process file lock\n * (`writeTranscript` never shrinks — the native format is an append-only\n * `parentUuid` DAG). The parent dir is created BEFORE acquiring the lock because\n * the lock's companion `<path>.lock` file needs an existing parent dir (the SE40\n * `mkdir(dirname)`-before-lock fix).\n *\n * @internal\n */\n\nimport { mkdir } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nimport type { SessionStore } from \"../../types/session-store.js\";\nimport { withFileLock } from \"./file-lock.js\";\nimport { appendJsonl } from \"./jsonl.js\";\nimport { readTranscript, type SessionRecord, transcriptPath } from \"./session-transcript.js\";\n\n/** Options identifying the on-disk transcript location for the FS default store. */\nexport interface FsSessionStoreOptions {\n /** Transcript base dir (`~/.theokit` default, `~/.claude` for CLI interop) — already `~`-expanded. */\n baseDir: string;\n /** The workspace cwd whose encoded form is the transcript project dir. */\n cwd: string;\n}\n\n/**\n * The default `SessionStore` — reads/append-writes the native `.jsonl` transcript.\n *\n * @internal\n */\nexport class FsSessionStore implements SessionStore {\n readonly #baseDir: string;\n readonly #cwd: string;\n\n constructor(options: FsSessionStoreOptions) {\n this.#baseDir = options.baseDir;\n this.#cwd = options.cwd;\n }\n\n async readRecords(agentId: string): Promise<SessionRecord[]> {\n return readTranscript(transcriptPath(this.#baseDir, this.#cwd, agentId));\n }\n\n async appendRecords(agentId: string, records: readonly SessionRecord[]): Promise<void> {\n // Empty delta → nothing to persist (avoids an unnecessary lock + rewrite).\n if (records.length === 0) return;\n const path = transcriptPath(this.#baseDir, this.#cwd, agentId);\n // mkdir BEFORE the lock: withFileLock's companion `<path>.lock` needs the parent dir.\n await mkdir(dirname(path), { recursive: true });\n await withFileLock(path, async () => {\n // M93 — acrescenta o DELTA em vez de reescrever o arquivo inteiro.\n //\n // Antes: `readTranscript` + `writeTranscript` de tudo, por turno. O(n) de I/O **e** de parse a\n // cada turno, O(n²) por sessão — a nota do consumidor em `agents/lib/session/backtrack.ts`\n // registra 1,4 MB / 3000 linhas em 200 turnos.\n //\n // Correto porque o formato **já é append-only**: o DAG de `parentUuid` não depende da ordem de\n // linha, e cada registro carrega o próprio pai. `appendJsonl` **já existia no pacote** e tinha um\n // único chamador (`eval/runner.ts`) — a primitiva estava lá, o store é que a ignorava (rung 4).\n //\n // O `withFileLock` permanece — mas a afirmação anterior de que \"ele é o que serializa dois\n // `appendRecords` concorrentes\" era forte demais, e a revisão adversarial do M93 mediu isso:\n // removê-lo não reprova nenhum teste. A razão é o próprio parágrafo acima — o DAG de\n // `parentUuid` não depende da ordem de linha, então dois lotes intercalados reconstroem igual.\n // O trabalho que o lock fazia (proteger um read-modify-write) sumiu junto com o rewrite.\n //\n // O que ele ainda cobre é a janela TOCTOU de `precisaDeQuebraAntes` (ler o último byte, depois\n // escrever): sem ele, dois processos podem ambos concluir \"falta \\n\" e produzir uma linha em\n // branco — que o leitor descarta, isto é, benigno. Fica como **defesa declarada, não\n // mecanizada** (a disciplina de `error-handling.md § 4`: enumerar o resíduo em vez de deixar a\n // ausência de teste passar por cobertura).\n //\n // `writeTranscript` continua existindo para **compactação**, a única operação que legitimamente\n // reescreve o arquivo.\n for (const record of records) appendJsonl(path, record);\n });\n }\n}\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
|
|
4
4
|
var chunkMZ5ZRORA_cjs = require('./chunk-MZ5ZRORA.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
5
|
+
var chunkE2YEDATX_cjs = require('./chunk-E2YEDATX.cjs');
|
|
6
|
+
var chunkIOOSAZZH_cjs = require('./chunk-IOOSAZZH.cjs');
|
|
7
|
+
var chunkNZCFLEHO_cjs = require('./chunk-NZCFLEHO.cjs');
|
|
8
8
|
var chunkJLMXKTBX_cjs = require('./chunk-JLMXKTBX.cjs');
|
|
9
9
|
var chunkN24XBYNX_cjs = require('./chunk-N24XBYNX.cjs');
|
|
10
10
|
var chunkWPZTYOUX_cjs = require('./chunk-WPZTYOUX.cjs');
|
|
@@ -15,9 +15,9 @@ var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
|
|
|
15
15
|
var chunkYPEPCZHF_cjs = require('./chunk-YPEPCZHF.cjs');
|
|
16
16
|
var chunkVJ26EKGJ_cjs = require('./chunk-VJ26EKGJ.cjs');
|
|
17
17
|
var chunkGIW4L6HY_cjs = require('./chunk-GIW4L6HY.cjs');
|
|
18
|
-
var
|
|
18
|
+
var chunkCJVMDRQB_cjs = require('./chunk-CJVMDRQB.cjs');
|
|
19
19
|
var chunkYLQQX5W2_cjs = require('./chunk-YLQQX5W2.cjs');
|
|
20
|
-
var
|
|
20
|
+
var chunkU2FO3MRG_cjs = require('./chunk-U2FO3MRG.cjs');
|
|
21
21
|
var chunkWJVHMTKB_cjs = require('./chunk-WJVHMTKB.cjs');
|
|
22
22
|
var chunkTIZ4TS5V_cjs = require('./chunk-TIZ4TS5V.cjs');
|
|
23
23
|
var chunkRZQ6E5YZ_cjs = require('./chunk-RZQ6E5YZ.cjs');
|
|
@@ -1663,7 +1663,7 @@ var RealCloudRun = class extends FixtureRunBase {
|
|
|
1663
1663
|
async consumeStream(response) {
|
|
1664
1664
|
let finalStatus = "finished";
|
|
1665
1665
|
let finalText = "";
|
|
1666
|
-
for await (const record of
|
|
1666
|
+
for await (const record of chunkNZCFLEHO_cjs.parseSseStream(response.body, this.controller.signal)) {
|
|
1667
1667
|
const parsed = safeParse(record.data);
|
|
1668
1668
|
if (parsed === void 0) continue;
|
|
1669
1669
|
const update = this.applyRecord(record.event, parsed);
|
|
@@ -2228,7 +2228,7 @@ var PersonalityStore = class {
|
|
|
2228
2228
|
async #persist(agentId, slug) {
|
|
2229
2229
|
const filePath = this.#filePath();
|
|
2230
2230
|
await promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
2231
|
-
await
|
|
2231
|
+
await chunkCJVMDRQB_cjs.withFileLock(filePath, async () => {
|
|
2232
2232
|
const current = await readState(filePath);
|
|
2233
2233
|
const nextAgents = { ...current.agents };
|
|
2234
2234
|
if (slug === void 0) delete nextAgents[agentId];
|
|
@@ -2703,6 +2703,15 @@ function buildContextBudgetEvent(model, resolved) {
|
|
|
2703
2703
|
}
|
|
2704
2704
|
|
|
2705
2705
|
// src/internal/runtime/lifecycle/post-run-lifecycle.ts
|
|
2706
|
+
function resolveWindowForRun(model, contextWindow) {
|
|
2707
|
+
const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
|
|
2708
|
+
return chunkEVADEGM7_cjs.resolveEffectiveContextWindow({
|
|
2709
|
+
...override !== void 0 ? { override } : {},
|
|
2710
|
+
catalog: chunkD42XHI4O_cjs.getCatalogModelInfo(model)?.limit?.context,
|
|
2711
|
+
margin: chunkEVADEGM7_cjs.CONTEXT_WINDOW_MARGIN,
|
|
2712
|
+
floor: chunkEVADEGM7_cjs.CONTEXT_WINDOW_FLOOR
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2706
2715
|
async function runPostRunLifecycle(inputs) {
|
|
2707
2716
|
const {
|
|
2708
2717
|
run,
|
|
@@ -2711,6 +2720,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2711
2720
|
workspaceCwd,
|
|
2712
2721
|
sessionStore,
|
|
2713
2722
|
model,
|
|
2723
|
+
contextWindow,
|
|
2714
2724
|
onRunEvent,
|
|
2715
2725
|
hooksExecutor,
|
|
2716
2726
|
memoryGlue,
|
|
@@ -2723,40 +2733,32 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2723
2733
|
try {
|
|
2724
2734
|
const parcial = await safeConversation(run);
|
|
2725
2735
|
if (parcial !== void 0) {
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
{ userText, conversation: parcial }
|
|
2731
|
-
);
|
|
2736
|
+
chunkE2YEDATX_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2737
|
+
userText,
|
|
2738
|
+
conversation: parcial
|
|
2739
|
+
});
|
|
2732
2740
|
}
|
|
2733
2741
|
} catch (cause) {
|
|
2734
2742
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
2735
|
-
process.stderr.write(
|
|
2736
|
-
|
|
2737
|
-
`
|
|
2738
|
-
);
|
|
2743
|
+
process.stderr.write(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2744
|
+
`);
|
|
2739
2745
|
}
|
|
2740
|
-
await
|
|
2746
|
+
await chunkE2YEDATX_cjs.flushSessionWrites();
|
|
2741
2747
|
return;
|
|
2742
2748
|
}
|
|
2743
2749
|
if (result.result !== void 0) {
|
|
2744
|
-
|
|
2750
|
+
chunkE2YEDATX_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2745
2751
|
}
|
|
2746
2752
|
const conversation = await safeConversation(run);
|
|
2747
|
-
const resolvedWindow =
|
|
2748
|
-
|
|
2749
|
-
margin: chunkEVADEGM7_cjs.CONTEXT_WINDOW_MARGIN,
|
|
2750
|
-
floor: chunkEVADEGM7_cjs.CONTEXT_WINDOW_FLOOR
|
|
2751
|
-
});
|
|
2752
|
-
const contextWindow = resolvedWindow.window;
|
|
2753
|
+
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
2754
|
+
const janelaEfetiva = resolvedWindow.window;
|
|
2753
2755
|
const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
|
|
2754
2756
|
if (budgetEvent !== void 0 && onRunEvent !== void 0) {
|
|
2755
2757
|
chunkMZ5ZRORA_cjs.emitRunEvent(onRunEvent, budgetEvent);
|
|
2756
2758
|
}
|
|
2757
2759
|
const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
|
|
2758
2760
|
const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
|
|
2759
|
-
|
|
2761
|
+
chunkE2YEDATX_cjs.persistTurnToTranscript(
|
|
2760
2762
|
sessionStore,
|
|
2761
2763
|
{ cwd: workspaceCwd, agentId, model },
|
|
2762
2764
|
agentId,
|
|
@@ -2765,8 +2767,10 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2765
2767
|
conversation,
|
|
2766
2768
|
autoCompact: {
|
|
2767
2769
|
usageTotal: usageForTrigger,
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
+
// A janela EFETIVA (após override, clamp e margem) — não a declarada. Trocar por
|
|
2771
|
+
// `contextWindow` aqui orçaria contra um número que o clamp já rejeitou.
|
|
2772
|
+
contextWindow: janelaEfetiva,
|
|
2773
|
+
summarize: chunkNZCFLEHO_cjs.buildDefaultSummarizer({
|
|
2770
2774
|
agentModel: model,
|
|
2771
2775
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
2772
2776
|
})
|
|
@@ -2810,7 +2814,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2810
2814
|
agentId,
|
|
2811
2815
|
runId: result.id
|
|
2812
2816
|
});
|
|
2813
|
-
await
|
|
2817
|
+
await chunkE2YEDATX_cjs.flushSessionWrites();
|
|
2814
2818
|
}
|
|
2815
2819
|
async function safeConversation(run) {
|
|
2816
2820
|
try {
|
|
@@ -3567,7 +3571,7 @@ var HISTOGRAM_NAMES = {
|
|
|
3567
3571
|
};
|
|
3568
3572
|
function safeRequire(moduleName) {
|
|
3569
3573
|
try {
|
|
3570
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3574
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-S6F3FKFR.cjs', document.baseURI).href)));
|
|
3571
3575
|
return r(moduleName);
|
|
3572
3576
|
} catch {
|
|
3573
3577
|
return void 0;
|
|
@@ -3792,7 +3796,7 @@ var cachedOtel;
|
|
|
3792
3796
|
function loadOtel() {
|
|
3793
3797
|
if (cachedOtel === void 0) {
|
|
3794
3798
|
try {
|
|
3795
|
-
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
3799
|
+
const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-S6F3FKFR.cjs', document.baseURI).href)));
|
|
3796
3800
|
const mod = r("@opentelemetry/api");
|
|
3797
3801
|
cachedOtel = mod;
|
|
3798
3802
|
} catch {
|
|
@@ -6221,7 +6225,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
6221
6225
|
(p) => (
|
|
6222
6226
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
6223
6227
|
// structured content); image blocks pass through untouched.
|
|
6224
|
-
p.type === "tool_result" ? { ...p, content:
|
|
6228
|
+
p.type === "tool_result" ? { ...p, content: chunkNZCFLEHO_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
6225
6229
|
)
|
|
6226
6230
|
);
|
|
6227
6231
|
}
|
|
@@ -6876,12 +6880,12 @@ var FallbackLlmClient = class {
|
|
|
6876
6880
|
let lastError;
|
|
6877
6881
|
for (const client of this.clients) {
|
|
6878
6882
|
if (signal.aborted) throw abortError(signal);
|
|
6879
|
-
const attempt = await
|
|
6883
|
+
const attempt = await chunkNZCFLEHO_cjs.tryFirstEvent(client, request, signal, true);
|
|
6880
6884
|
if (attempt.kind === "handshake_error") {
|
|
6881
6885
|
lastError = attempt.error;
|
|
6882
6886
|
continue;
|
|
6883
6887
|
}
|
|
6884
|
-
return yield*
|
|
6888
|
+
return yield* chunkNZCFLEHO_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
6885
6889
|
}
|
|
6886
6890
|
if (lastError !== void 0) throw lastError;
|
|
6887
6891
|
throw new chunkA44COQJJ_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
@@ -7388,8 +7392,8 @@ function resolveRunProvider(options) {
|
|
|
7388
7392
|
}
|
|
7389
7393
|
const parsedModel = chunkVYHJZVL5_cjs.parseModelId(options.model?.id);
|
|
7390
7394
|
const modelInferredProvider = parsedModel.provider !== void 0 && chunkD42XHI4O_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
|
|
7391
|
-
const keyInferredProvider =
|
|
7392
|
-
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ??
|
|
7395
|
+
const keyInferredProvider = chunkNZCFLEHO_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
|
|
7396
|
+
const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkNZCFLEHO_cjs.detectPrimaryProvider();
|
|
7393
7397
|
const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
|
|
7394
7398
|
return { primary, effectiveModelId };
|
|
7395
7399
|
}
|
|
@@ -7418,7 +7422,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7418
7422
|
const credentialPoolStrategy = options.agentOptions.providers?.credentialPoolStrategy;
|
|
7419
7423
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7420
7424
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7421
|
-
const chain =
|
|
7425
|
+
const chain = chunkNZCFLEHO_cjs.resolveProviderChain({
|
|
7422
7426
|
primary,
|
|
7423
7427
|
...fallback !== void 0 ? { fallback } : {},
|
|
7424
7428
|
...apiKeys !== void 0 ? { apiKeys } : {},
|
|
@@ -7643,7 +7647,7 @@ function buildRealRunOptions(args) {
|
|
|
7643
7647
|
};
|
|
7644
7648
|
}
|
|
7645
7649
|
async function createFixtureRunHelper(args) {
|
|
7646
|
-
const sessionMessages =
|
|
7650
|
+
const sessionMessages = chunkE2YEDATX_cjs.getSessionMessages(args.inputs.agentId);
|
|
7647
7651
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7648
7652
|
return createLocalRun({
|
|
7649
7653
|
agentId: args.inputs.agentId,
|
|
@@ -8092,7 +8096,7 @@ async function embedBatch(opts) {
|
|
|
8092
8096
|
body = JSON.parse(text);
|
|
8093
8097
|
} catch {
|
|
8094
8098
|
}
|
|
8095
|
-
throw
|
|
8099
|
+
throw chunkNZCFLEHO_cjs.mapOpenAICompatibleError({
|
|
8096
8100
|
providerId: opts.providerId,
|
|
8097
8101
|
status: response.status,
|
|
8098
8102
|
body,
|
|
@@ -8643,7 +8647,7 @@ var LocalAgentMemory = class {
|
|
|
8643
8647
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
8644
8648
|
const cfg = this.options.memory?.activeRecall;
|
|
8645
8649
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
8646
|
-
if (this.breaker === void 0) this.breaker = new
|
|
8650
|
+
if (this.breaker === void 0) this.breaker = new chunkNZCFLEHO_cjs.CircuitBreaker();
|
|
8647
8651
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
8648
8652
|
const result = await runActiveMemory({
|
|
8649
8653
|
userText,
|
|
@@ -9047,8 +9051,8 @@ async function localAgentUsePersonality(args) {
|
|
|
9047
9051
|
registry,
|
|
9048
9052
|
store: args.personalityStore,
|
|
9049
9053
|
invalidateCache: (reason) => args.invalidateCache(reason),
|
|
9050
|
-
appendSessionMessage: (msg) =>
|
|
9051
|
-
clearSession: () =>
|
|
9054
|
+
appendSessionMessage: (msg) => chunkE2YEDATX_cjs.appendSessionMessage(args.agentId, msg),
|
|
9055
|
+
clearSession: () => chunkE2YEDATX_cjs.clearSession(args.agentId),
|
|
9052
9056
|
opts: args.opts ?? {}
|
|
9053
9057
|
})
|
|
9054
9058
|
);
|
|
@@ -9396,7 +9400,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9396
9400
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9397
9401
|
await inputs.options.onBeforeSend({
|
|
9398
9402
|
conversationId: inputs.agentId,
|
|
9399
|
-
previousMessageCount:
|
|
9403
|
+
previousMessageCount: chunkE2YEDATX_cjs.getSessionMessages(inputs.agentId).length
|
|
9400
9404
|
});
|
|
9401
9405
|
}
|
|
9402
9406
|
await inputs.runPreHook(userText);
|
|
@@ -9408,8 +9412,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9408
9412
|
userText,
|
|
9409
9413
|
sendOptions: options
|
|
9410
9414
|
});
|
|
9411
|
-
const priorMessages = [...
|
|
9412
|
-
|
|
9415
|
+
const priorMessages = [...chunkE2YEDATX_cjs.getSessionMessages(inputs.agentId)];
|
|
9416
|
+
chunkE2YEDATX_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9413
9417
|
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9414
9418
|
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
|
|
9415
9419
|
const portPathActive = shouldUsePortMemoryPath();
|
|
@@ -9571,7 +9575,7 @@ var LocalAgent = class {
|
|
|
9571
9575
|
this.options = options;
|
|
9572
9576
|
this.workspaceCwd = resolveCwd(options.local?.cwd);
|
|
9573
9577
|
this.transcriptBaseDir = resolveBaseDir(options.local?.baseDir);
|
|
9574
|
-
this.sessionStore = options.local?.sessionStore ?? new
|
|
9578
|
+
this.sessionStore = options.local?.sessionStore ?? new chunkIOOSAZZH_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
|
|
9575
9579
|
this.settingSourcesIncludeProject = includesSetting(options, "project");
|
|
9576
9580
|
this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
|
|
9577
9581
|
const sub = bootstrapSubmanagers({
|
|
@@ -9619,7 +9623,7 @@ var LocalAgent = class {
|
|
|
9619
9623
|
this.settingSourcesIncludeProject,
|
|
9620
9624
|
this.options.agents
|
|
9621
9625
|
);
|
|
9622
|
-
await
|
|
9626
|
+
await chunkE2YEDATX_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
9623
9627
|
await this.personalityStore.hydrate(this.agentId);
|
|
9624
9628
|
}
|
|
9625
9629
|
/** T4.2 — expose PluginManager so agent-loop can fire pre_tool_call hooks. @internal */
|
|
@@ -9677,6 +9681,9 @@ var LocalAgent = class {
|
|
|
9677
9681
|
workspaceCwd: this.workspaceCwd,
|
|
9678
9682
|
sessionStore: this.sessionStore,
|
|
9679
9683
|
model: this.model?.id ?? "unknown",
|
|
9684
|
+
// M94 — a janela declarada atravessa até o orçamento. Sem isto o `override` do resolvedor
|
|
9685
|
+
// existia desde o M77 e nenhum call site de produção o passava.
|
|
9686
|
+
...this.model?.contextWindow !== void 0 ? { contextWindow: this.model.contextWindow } : {},
|
|
9680
9687
|
// M50 — the auto-compaction summarizer resolves credentials like the run itself.
|
|
9681
9688
|
...this.options.apiKey !== void 0 ? { apiKey: this.options.apiKey } : {},
|
|
9682
9689
|
...options.onRunEvent !== void 0 ? { onRunEvent: options.onRunEvent } : {},
|
|
@@ -9799,7 +9806,7 @@ var LocalAgent = class {
|
|
|
9799
9806
|
this.lifecycleAbortController.abort();
|
|
9800
9807
|
await chunkYLQQX5W2_cjs.withCwdMutex(`agent-send:${this.agentId}`, () => Promise.resolve());
|
|
9801
9808
|
disposeSessionMcpClients(this.agentId);
|
|
9802
|
-
await
|
|
9809
|
+
await chunkE2YEDATX_cjs.flushSessionWrites();
|
|
9803
9810
|
await flushRegistrySaves(this.workspaceCwd);
|
|
9804
9811
|
}
|
|
9805
9812
|
[Symbol.asyncDispose]() {
|
|
@@ -9867,7 +9874,7 @@ function resolveCwd(cwd) {
|
|
|
9867
9874
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|
|
9868
9875
|
}
|
|
9869
9876
|
function resolveBaseDir(baseDir) {
|
|
9870
|
-
return baseDir === void 0 ?
|
|
9877
|
+
return baseDir === void 0 ? chunkU2FO3MRG_cjs.defaultBaseDir() : chunkU2FO3MRG_cjs.expandTilde(baseDir);
|
|
9871
9878
|
}
|
|
9872
9879
|
function includesSetting(options, source) {
|
|
9873
9880
|
const sources = options.local?.settingSources;
|
|
@@ -10007,7 +10014,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
10007
10014
|
return process.cwd();
|
|
10008
10015
|
}
|
|
10009
10016
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
10010
|
-
await
|
|
10017
|
+
await chunkNZCFLEHO_cjs.discoverProviderPlugins();
|
|
10011
10018
|
await validateRehydratedAgent(agentId, existing);
|
|
10012
10019
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
10013
10020
|
const mergedOptions = {
|
|
@@ -10135,7 +10142,7 @@ var Agent = class _Agent {
|
|
|
10135
10142
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
10136
10143
|
});
|
|
10137
10144
|
try {
|
|
10138
|
-
await
|
|
10145
|
+
await chunkNZCFLEHO_cjs.discoverProviderPlugins();
|
|
10139
10146
|
const agent = await runCreateUnderSpan(options, span);
|
|
10140
10147
|
return agent;
|
|
10141
10148
|
} catch (err) {
|
|
@@ -10404,9 +10411,9 @@ var Agent = class _Agent {
|
|
|
10404
10411
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10405
10412
|
);
|
|
10406
10413
|
}
|
|
10407
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10414
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-42BK7RE3.cjs');
|
|
10408
10415
|
const { cwd, model, store } = await abrirStoreLocal(reg);
|
|
10409
|
-
return
|
|
10416
|
+
return chunkE2YEDATX_cjs.enqueueSessionWrite(
|
|
10410
10417
|
cwd,
|
|
10411
10418
|
agentId,
|
|
10412
10419
|
() => compactSessionTranscript({
|
|
@@ -10440,7 +10447,7 @@ var Agent = class _Agent {
|
|
|
10440
10447
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10441
10448
|
);
|
|
10442
10449
|
}
|
|
10443
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10450
|
+
const { injectSessionTurn } = await import('./inject-session-6ZMCA2NE.cjs');
|
|
10444
10451
|
const { cwd, model, store } = await abrirStoreLocal(reg);
|
|
10445
10452
|
await injectSessionTurn({
|
|
10446
10453
|
store,
|
|
@@ -10487,8 +10494,8 @@ async function abrirStoreLocal(reg) {
|
|
|
10487
10494
|
const cwd = reg.cwd ?? process.cwd();
|
|
10488
10495
|
const optModel = reg.options.model;
|
|
10489
10496
|
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
10490
|
-
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-
|
|
10491
|
-
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-
|
|
10497
|
+
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-IIP7ZBYE.cjs');
|
|
10498
|
+
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-T4SB66I7.cjs');
|
|
10492
10499
|
const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
|
|
10493
10500
|
return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
|
|
10494
10501
|
}
|
|
@@ -10508,5 +10515,5 @@ exports.isFixtureApiKey = isFixtureApiKey;
|
|
|
10508
10515
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
10509
10516
|
exports.resolveApiKey = resolveApiKey;
|
|
10510
10517
|
exports.shouldUseFixtureMode = shouldUseFixtureMode;
|
|
10511
|
-
//# sourceMappingURL=chunk-
|
|
10512
|
-
//# sourceMappingURL=chunk-
|
|
10518
|
+
//# sourceMappingURL=chunk-S6F3FKFR.cjs.map
|
|
10519
|
+
//# sourceMappingURL=chunk-S6F3FKFR.cjs.map
|