@theokit/sdk 4.30.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 +57 -0
- package/dist/{agent-Ekv8y7_c.d.ts → agent-BJbGi8-R.d.ts} +1 -1
- package/dist/{agent-LD76RI74.cjs → agent-BKNJIOEY.cjs} +9 -9
- package/dist/{agent-LD76RI74.cjs.map → agent-BKNJIOEY.cjs.map} +1 -1
- package/dist/{agent-Bzg2_uGr.d.cts → agent-CbZPGFfM.d.cts} +1 -1
- package/dist/{agent-7YUGJJTU.js → agent-HW7OY2W3.js} +8 -8
- package/dist/{agent-7YUGJJTU.js.map → agent-HW7OY2W3.js.map} +1 -1
- package/dist/agent.d.ts +15 -2
- package/dist/{chunk-ISZ3MBUD.js → chunk-CCRWSZ2F.js} +57 -20
- package/dist/chunk-CCRWSZ2F.js.map +1 -0
- package/dist/chunk-CJVMDRQB.cjs +169 -0
- package/dist/chunk-CJVMDRQB.cjs.map +1 -0
- package/dist/{chunk-YU6KON2I.cjs → chunk-E2YEDATX.cjs} +6 -6
- package/dist/{chunk-YU6KON2I.cjs.map → chunk-E2YEDATX.cjs.map} +1 -1
- package/dist/{chunk-NG6B2PMA.cjs → chunk-GQBXBHZ2.cjs} +5 -5
- package/dist/{chunk-NG6B2PMA.cjs.map → chunk-GQBXBHZ2.cjs.map} +1 -1
- package/dist/{chunk-2HRYBRD7.cjs → chunk-IOOSAZZH.cjs} +8 -9
- package/dist/chunk-IOOSAZZH.cjs.map +1 -0
- package/dist/{chunk-2MF3IE2D.cjs → chunk-NZCFLEHO.cjs} +136 -25
- package/dist/chunk-NZCFLEHO.cjs.map +1 -0
- package/dist/{chunk-U6QGZHPN.js → chunk-RPKTXBPK.js} +5 -6
- package/dist/chunk-RPKTXBPK.js.map +1 -0
- package/dist/{chunk-GWMQ5CS3.cjs → chunk-S6F3FKFR.cjs} +87 -50
- package/dist/chunk-S6F3FKFR.cjs.map +1 -0
- package/dist/{chunk-SQLZ7ONU.js → chunk-SJLOIZ4Z.js} +4 -4
- package/dist/{chunk-SQLZ7ONU.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-UAYYNWYJ.js +163 -0
- 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-5YCAR23S.js → chunk-WYPHQ7NM.js} +3 -3
- package/dist/{chunk-5YCAR23S.js.map → chunk-WYPHQ7NM.js.map} +1 -1
- package/dist/{chunk-NRSH7RJY.js → chunk-XDNGF5BY.js} +133 -22
- package/dist/chunk-XDNGF5BY.js.map +1 -0
- package/dist/{compact-session-OO7NVWPB.cjs → compact-session-42BK7RE3.cjs} +12 -12
- package/dist/{compact-session-OO7NVWPB.cjs.map → compact-session-42BK7RE3.cjs.map} +1 -1
- package/dist/{compact-session-OO2GD76G.js → compact-session-QMBOCFVQ.js} +4 -4
- package/dist/{compact-session-OO2GD76G.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 -12
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +7 -8
- package/dist/eval.js.map +1 -1
- package/dist/fs-session-store-IIP7ZBYE.cjs +17 -0
- package/dist/{fs-session-store-KAUQYSGI.cjs.map → fs-session-store-IIP7ZBYE.cjs.map} +1 -1
- package/dist/fs-session-store-T7YPW5A4.js +8 -0
- package/dist/{fs-session-store-ZKB5NN37.js.map → fs-session-store-T7YPW5A4.js.map} +1 -1
- package/dist/index.cjs +29 -29
- package/dist/index.d.cts +23 -10
- package/dist/index.d.ts +23 -10
- package/dist/index.js +9 -9
- package/dist/{inject-session-6MJUSGZP.cjs → inject-session-6ZMCA2NE.cjs} +6 -6
- package/dist/{inject-session-6MJUSGZP.cjs.map → inject-session-6ZMCA2NE.cjs.map} +1 -1
- package/dist/{inject-session-KOFHS5K3.js → inject-session-YA3GQE4G.js} +4 -4
- package/dist/{inject-session-KOFHS5K3.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 +53 -0
- package/dist/internal/llm/transport-error.d.ts +9 -0
- package/dist/internal/persistence/index.cjs +18 -19
- package/dist/internal/persistence/index.cjs.map +1 -1
- package/dist/internal/persistence/index.js +1 -2
- package/dist/internal/persistence/index.js.map +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 +17 -14
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.d.cts +1 -1
- package/dist/persistence.d.ts +1 -1
- package/dist/persistence.js +2 -3
- package/dist/persistence.js.map +1 -1
- package/dist/{run-OJbGyweZ.d.cts → run-CwEJtLPE.d.cts} +8 -0
- package/dist/{run-OJbGyweZ.d.ts → 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-2HRYBRD7.cjs.map +0 -1
- package/dist/chunk-2MF3IE2D.cjs.map +0 -1
- package/dist/chunk-4SXHEZIV.cjs.map +0 -1
- package/dist/chunk-C7PICHRF.cjs +0 -68
- package/dist/chunk-C7PICHRF.cjs.map +0 -1
- package/dist/chunk-GWMQ5CS3.cjs.map +0 -1
- package/dist/chunk-HK7ZHSAX.cjs +0 -85
- package/dist/chunk-HK7ZHSAX.cjs.map +0 -1
- package/dist/chunk-HZQEDNF6.js +0 -66
- package/dist/chunk-HZQEDNF6.js.map +0 -1
- package/dist/chunk-ISZ3MBUD.js.map +0 -1
- package/dist/chunk-NRSH7RJY.js.map +0 -1
- package/dist/chunk-R6ZP6KNB.js +0 -80
- package/dist/chunk-R6ZP6KNB.js.map +0 -1
- package/dist/chunk-U6QGZHPN.js.map +0 -1
- package/dist/chunk-ZZWTY3RX.js.map +0 -1
- package/dist/fs-session-store-KAUQYSGI.cjs +0 -17
- package/dist/fs-session-store-ZKB5NN37.js +0 -8
- package/dist/session-transcript-LPNZR3YS.cjs +0 -46
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { withFileLock } from './chunk-
|
|
2
|
-
import { readTranscript, transcriptPath
|
|
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
|
|
|
@@ -18,12 +18,11 @@ var FsSessionStore = class {
|
|
|
18
18
|
const path = transcriptPath(this.#baseDir, this.#cwd, agentId);
|
|
19
19
|
await mkdir(dirname(path), { recursive: true });
|
|
20
20
|
await withFileLock(path, async () => {
|
|
21
|
-
const
|
|
22
|
-
await writeTranscript(path, [...prior, ...records]);
|
|
21
|
+
for (const record of records) appendJsonl(path, record);
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
25
|
|
|
27
26
|
export { FsSessionStore };
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
29
|
-
//# 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,
|
|
@@ -2720,26 +2730,35 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2720
2730
|
try {
|
|
2721
2731
|
result = await run.wait();
|
|
2722
2732
|
} catch {
|
|
2723
|
-
|
|
2733
|
+
try {
|
|
2734
|
+
const parcial = await safeConversation(run);
|
|
2735
|
+
if (parcial !== void 0) {
|
|
2736
|
+
chunkE2YEDATX_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2737
|
+
userText,
|
|
2738
|
+
conversation: parcial
|
|
2739
|
+
});
|
|
2740
|
+
}
|
|
2741
|
+
} catch (cause) {
|
|
2742
|
+
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
2743
|
+
process.stderr.write(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2744
|
+
`);
|
|
2745
|
+
}
|
|
2746
|
+
await chunkE2YEDATX_cjs.flushSessionWrites();
|
|
2724
2747
|
return;
|
|
2725
2748
|
}
|
|
2726
2749
|
if (result.result !== void 0) {
|
|
2727
|
-
|
|
2750
|
+
chunkE2YEDATX_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2728
2751
|
}
|
|
2729
2752
|
const conversation = await safeConversation(run);
|
|
2730
|
-
const resolvedWindow =
|
|
2731
|
-
|
|
2732
|
-
margin: chunkEVADEGM7_cjs.CONTEXT_WINDOW_MARGIN,
|
|
2733
|
-
floor: chunkEVADEGM7_cjs.CONTEXT_WINDOW_FLOOR
|
|
2734
|
-
});
|
|
2735
|
-
const contextWindow = resolvedWindow.window;
|
|
2753
|
+
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
2754
|
+
const janelaEfetiva = resolvedWindow.window;
|
|
2736
2755
|
const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
|
|
2737
2756
|
if (budgetEvent !== void 0 && onRunEvent !== void 0) {
|
|
2738
2757
|
chunkMZ5ZRORA_cjs.emitRunEvent(onRunEvent, budgetEvent);
|
|
2739
2758
|
}
|
|
2740
2759
|
const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
|
|
2741
2760
|
const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
|
|
2742
|
-
|
|
2761
|
+
chunkE2YEDATX_cjs.persistTurnToTranscript(
|
|
2743
2762
|
sessionStore,
|
|
2744
2763
|
{ cwd: workspaceCwd, agentId, model },
|
|
2745
2764
|
agentId,
|
|
@@ -2748,8 +2767,10 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2748
2767
|
conversation,
|
|
2749
2768
|
autoCompact: {
|
|
2750
2769
|
usageTotal: usageForTrigger,
|
|
2751
|
-
|
|
2752
|
-
|
|
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({
|
|
2753
2774
|
agentModel: model,
|
|
2754
2775
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
2755
2776
|
})
|
|
@@ -2793,7 +2814,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2793
2814
|
agentId,
|
|
2794
2815
|
runId: result.id
|
|
2795
2816
|
});
|
|
2796
|
-
await
|
|
2817
|
+
await chunkE2YEDATX_cjs.flushSessionWrites();
|
|
2797
2818
|
}
|
|
2798
2819
|
async function safeConversation(run) {
|
|
2799
2820
|
try {
|
|
@@ -3550,7 +3571,7 @@ var HISTOGRAM_NAMES = {
|
|
|
3550
3571
|
};
|
|
3551
3572
|
function safeRequire(moduleName) {
|
|
3552
3573
|
try {
|
|
3553
|
-
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)));
|
|
3554
3575
|
return r(moduleName);
|
|
3555
3576
|
} catch {
|
|
3556
3577
|
return void 0;
|
|
@@ -3775,7 +3796,7 @@ var cachedOtel;
|
|
|
3775
3796
|
function loadOtel() {
|
|
3776
3797
|
if (cachedOtel === void 0) {
|
|
3777
3798
|
try {
|
|
3778
|
-
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)));
|
|
3779
3800
|
const mod = r("@opentelemetry/api");
|
|
3780
3801
|
cachedOtel = mod;
|
|
3781
3802
|
} catch {
|
|
@@ -6204,7 +6225,7 @@ function applyToolResultGuard(parts, opts) {
|
|
|
6204
6225
|
(p) => (
|
|
6205
6226
|
// SE7 — guard the TEXT of a tool result (string or the text blocks of a
|
|
6206
6227
|
// structured content); image blocks pass through untouched.
|
|
6207
|
-
p.type === "tool_result" ? { ...p, content:
|
|
6228
|
+
p.type === "tool_result" ? { ...p, content: chunkNZCFLEHO_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
|
|
6208
6229
|
)
|
|
6209
6230
|
);
|
|
6210
6231
|
}
|
|
@@ -6859,12 +6880,12 @@ var FallbackLlmClient = class {
|
|
|
6859
6880
|
let lastError;
|
|
6860
6881
|
for (const client of this.clients) {
|
|
6861
6882
|
if (signal.aborted) throw abortError(signal);
|
|
6862
|
-
const attempt = await
|
|
6883
|
+
const attempt = await chunkNZCFLEHO_cjs.tryFirstEvent(client, request, signal, true);
|
|
6863
6884
|
if (attempt.kind === "handshake_error") {
|
|
6864
6885
|
lastError = attempt.error;
|
|
6865
6886
|
continue;
|
|
6866
6887
|
}
|
|
6867
|
-
return yield*
|
|
6888
|
+
return yield* chunkNZCFLEHO_cjs.relayStream(attempt.generator, attempt.firstResult);
|
|
6868
6889
|
}
|
|
6869
6890
|
if (lastError !== void 0) throw lastError;
|
|
6870
6891
|
throw new chunkA44COQJJ_cjs.NetworkError("FallbackLlmClient has no providers configured", {
|
|
@@ -7371,8 +7392,8 @@ function resolveRunProvider(options) {
|
|
|
7371
7392
|
}
|
|
7372
7393
|
const parsedModel = chunkVYHJZVL5_cjs.parseModelId(options.model?.id);
|
|
7373
7394
|
const modelInferredProvider = parsedModel.provider !== void 0 && chunkD42XHI4O_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
|
|
7374
|
-
const keyInferredProvider =
|
|
7375
|
-
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();
|
|
7376
7397
|
const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
|
|
7377
7398
|
return { primary, effectiveModelId };
|
|
7378
7399
|
}
|
|
@@ -7401,7 +7422,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
|
|
|
7401
7422
|
const credentialPoolStrategy = options.agentOptions.providers?.credentialPoolStrategy;
|
|
7402
7423
|
const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
|
|
7403
7424
|
const rateLimitSink = options.sendOptions.onRunEvent;
|
|
7404
|
-
const chain =
|
|
7425
|
+
const chain = chunkNZCFLEHO_cjs.resolveProviderChain({
|
|
7405
7426
|
primary,
|
|
7406
7427
|
...fallback !== void 0 ? { fallback } : {},
|
|
7407
7428
|
...apiKeys !== void 0 ? { apiKeys } : {},
|
|
@@ -7626,7 +7647,7 @@ function buildRealRunOptions(args) {
|
|
|
7626
7647
|
};
|
|
7627
7648
|
}
|
|
7628
7649
|
async function createFixtureRunHelper(args) {
|
|
7629
|
-
const sessionMessages =
|
|
7650
|
+
const sessionMessages = chunkE2YEDATX_cjs.getSessionMessages(args.inputs.agentId);
|
|
7630
7651
|
const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
|
|
7631
7652
|
return createLocalRun({
|
|
7632
7653
|
agentId: args.inputs.agentId,
|
|
@@ -8075,7 +8096,7 @@ async function embedBatch(opts) {
|
|
|
8075
8096
|
body = JSON.parse(text);
|
|
8076
8097
|
} catch {
|
|
8077
8098
|
}
|
|
8078
|
-
throw
|
|
8099
|
+
throw chunkNZCFLEHO_cjs.mapOpenAICompatibleError({
|
|
8079
8100
|
providerId: opts.providerId,
|
|
8080
8101
|
status: response.status,
|
|
8081
8102
|
body,
|
|
@@ -8626,7 +8647,7 @@ var LocalAgentMemory = class {
|
|
|
8626
8647
|
async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
|
|
8627
8648
|
const cfg = this.options.memory?.activeRecall;
|
|
8628
8649
|
if (cfg?.enabled !== true || this.index === void 0) return void 0;
|
|
8629
|
-
if (this.breaker === void 0) this.breaker = new
|
|
8650
|
+
if (this.breaker === void 0) this.breaker = new chunkNZCFLEHO_cjs.CircuitBreaker();
|
|
8630
8651
|
if (this.cache === void 0) this.cache = new ActiveMemoryCache();
|
|
8631
8652
|
const result = await runActiveMemory({
|
|
8632
8653
|
userText,
|
|
@@ -9030,8 +9051,8 @@ async function localAgentUsePersonality(args) {
|
|
|
9030
9051
|
registry,
|
|
9031
9052
|
store: args.personalityStore,
|
|
9032
9053
|
invalidateCache: (reason) => args.invalidateCache(reason),
|
|
9033
|
-
appendSessionMessage: (msg) =>
|
|
9034
|
-
clearSession: () =>
|
|
9054
|
+
appendSessionMessage: (msg) => chunkE2YEDATX_cjs.appendSessionMessage(args.agentId, msg),
|
|
9055
|
+
clearSession: () => chunkE2YEDATX_cjs.clearSession(args.agentId),
|
|
9035
9056
|
opts: args.opts ?? {}
|
|
9036
9057
|
})
|
|
9037
9058
|
);
|
|
@@ -9379,7 +9400,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9379
9400
|
if (inputs.options.onBeforeSend !== void 0) {
|
|
9380
9401
|
await inputs.options.onBeforeSend({
|
|
9381
9402
|
conversationId: inputs.agentId,
|
|
9382
|
-
previousMessageCount:
|
|
9403
|
+
previousMessageCount: chunkE2YEDATX_cjs.getSessionMessages(inputs.agentId).length
|
|
9383
9404
|
});
|
|
9384
9405
|
}
|
|
9385
9406
|
await inputs.runPreHook(userText);
|
|
@@ -9391,8 +9412,8 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9391
9412
|
userText,
|
|
9392
9413
|
sendOptions: options
|
|
9393
9414
|
});
|
|
9394
|
-
const priorMessages = [...
|
|
9395
|
-
|
|
9415
|
+
const priorMessages = [...chunkE2YEDATX_cjs.getSessionMessages(inputs.agentId)];
|
|
9416
|
+
chunkE2YEDATX_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
|
|
9396
9417
|
await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
|
|
9397
9418
|
const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
|
|
9398
9419
|
const portPathActive = shouldUsePortMemoryPath();
|
|
@@ -9554,7 +9575,7 @@ var LocalAgent = class {
|
|
|
9554
9575
|
this.options = options;
|
|
9555
9576
|
this.workspaceCwd = resolveCwd(options.local?.cwd);
|
|
9556
9577
|
this.transcriptBaseDir = resolveBaseDir(options.local?.baseDir);
|
|
9557
|
-
this.sessionStore = options.local?.sessionStore ?? new
|
|
9578
|
+
this.sessionStore = options.local?.sessionStore ?? new chunkIOOSAZZH_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
|
|
9558
9579
|
this.settingSourcesIncludeProject = includesSetting(options, "project");
|
|
9559
9580
|
this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
|
|
9560
9581
|
const sub = bootstrapSubmanagers({
|
|
@@ -9602,7 +9623,7 @@ var LocalAgent = class {
|
|
|
9602
9623
|
this.settingSourcesIncludeProject,
|
|
9603
9624
|
this.options.agents
|
|
9604
9625
|
);
|
|
9605
|
-
await
|
|
9626
|
+
await chunkE2YEDATX_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
|
|
9606
9627
|
await this.personalityStore.hydrate(this.agentId);
|
|
9607
9628
|
}
|
|
9608
9629
|
/** T4.2 — expose PluginManager so agent-loop can fire pre_tool_call hooks. @internal */
|
|
@@ -9660,6 +9681,9 @@ var LocalAgent = class {
|
|
|
9660
9681
|
workspaceCwd: this.workspaceCwd,
|
|
9661
9682
|
sessionStore: this.sessionStore,
|
|
9662
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 } : {},
|
|
9663
9687
|
// M50 — the auto-compaction summarizer resolves credentials like the run itself.
|
|
9664
9688
|
...this.options.apiKey !== void 0 ? { apiKey: this.options.apiKey } : {},
|
|
9665
9689
|
...options.onRunEvent !== void 0 ? { onRunEvent: options.onRunEvent } : {},
|
|
@@ -9782,7 +9806,7 @@ var LocalAgent = class {
|
|
|
9782
9806
|
this.lifecycleAbortController.abort();
|
|
9783
9807
|
await chunkYLQQX5W2_cjs.withCwdMutex(`agent-send:${this.agentId}`, () => Promise.resolve());
|
|
9784
9808
|
disposeSessionMcpClients(this.agentId);
|
|
9785
|
-
await
|
|
9809
|
+
await chunkE2YEDATX_cjs.flushSessionWrites();
|
|
9786
9810
|
await flushRegistrySaves(this.workspaceCwd);
|
|
9787
9811
|
}
|
|
9788
9812
|
[Symbol.asyncDispose]() {
|
|
@@ -9850,7 +9874,7 @@ function resolveCwd(cwd) {
|
|
|
9850
9874
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|
|
9851
9875
|
}
|
|
9852
9876
|
function resolveBaseDir(baseDir) {
|
|
9853
|
-
return baseDir === void 0 ?
|
|
9877
|
+
return baseDir === void 0 ? chunkU2FO3MRG_cjs.defaultBaseDir() : chunkU2FO3MRG_cjs.expandTilde(baseDir);
|
|
9854
9878
|
}
|
|
9855
9879
|
function includesSetting(options, source) {
|
|
9856
9880
|
const sources = options.local?.settingSources;
|
|
@@ -9990,7 +10014,7 @@ function resolveAgentPersistenceCwd(options) {
|
|
|
9990
10014
|
return process.cwd();
|
|
9991
10015
|
}
|
|
9992
10016
|
async function rehydrateExistingAgent(agentId, existing, options) {
|
|
9993
|
-
await
|
|
10017
|
+
await chunkNZCFLEHO_cjs.discoverProviderPlugins();
|
|
9994
10018
|
await validateRehydratedAgent(agentId, existing);
|
|
9995
10019
|
const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
|
|
9996
10020
|
const mergedOptions = {
|
|
@@ -10118,7 +10142,7 @@ var Agent = class _Agent {
|
|
|
10118
10142
|
pluginCount: enabledPluginNames(options.plugins).length
|
|
10119
10143
|
});
|
|
10120
10144
|
try {
|
|
10121
|
-
await
|
|
10145
|
+
await chunkNZCFLEHO_cjs.discoverProviderPlugins();
|
|
10122
10146
|
const agent = await runCreateUnderSpan(options, span);
|
|
10123
10147
|
return agent;
|
|
10124
10148
|
} catch (err) {
|
|
@@ -10267,8 +10291,21 @@ var Agent = class _Agent {
|
|
|
10267
10291
|
* Caveats:
|
|
10268
10292
|
* - The function-level `agentId` always wins over `options.agentId`.
|
|
10269
10293
|
* - Options differ between calls? Last-call-wins for this handle (matches `Agent.resume`).
|
|
10270
|
-
* -
|
|
10271
|
-
*
|
|
10294
|
+
* - A DISPOSED agent is replaced automatically. `dispose()` evicts the id from the
|
|
10295
|
+
* live cache (`liveAgentRegistry.forget`), so the next `getOrCreate(id)` builds a
|
|
10296
|
+
* fresh handle — no `Agent.delete(agentId)` needed.
|
|
10297
|
+
*
|
|
10298
|
+
* This bullet used to say the opposite ("Disposed agents are NOT auto-deleted...
|
|
10299
|
+
* call `Agent.delete(agentId)` first"). It was measured false in M91:
|
|
10300
|
+
* `tests/m91-getorcreate-apos-dispose.test.ts` builds an agent, disposes it, and
|
|
10301
|
+
* gets a different instance back. The claim was about the PERSISTENT registry and
|
|
10302
|
+
* read as being about the live cache — and consumers built around the wrong half.
|
|
10303
|
+
* The agent-builder's M85 interrupt rotates the session id to work around a
|
|
10304
|
+
* constraint that does not exist.
|
|
10305
|
+
*
|
|
10306
|
+
* - `close()` marks the handle disposed WITHOUT evicting the cache entry. It is
|
|
10307
|
+
* internal and unused today; if it becomes reachable, this bullet stops being true
|
|
10308
|
+
* for that path.
|
|
10272
10309
|
*
|
|
10273
10310
|
* @public
|
|
10274
10311
|
*/
|
|
@@ -10374,9 +10411,9 @@ var Agent = class _Agent {
|
|
|
10374
10411
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10375
10412
|
);
|
|
10376
10413
|
}
|
|
10377
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10414
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-42BK7RE3.cjs');
|
|
10378
10415
|
const { cwd, model, store } = await abrirStoreLocal(reg);
|
|
10379
|
-
return
|
|
10416
|
+
return chunkE2YEDATX_cjs.enqueueSessionWrite(
|
|
10380
10417
|
cwd,
|
|
10381
10418
|
agentId,
|
|
10382
10419
|
() => compactSessionTranscript({
|
|
@@ -10410,7 +10447,7 @@ var Agent = class _Agent {
|
|
|
10410
10447
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10411
10448
|
);
|
|
10412
10449
|
}
|
|
10413
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10450
|
+
const { injectSessionTurn } = await import('./inject-session-6ZMCA2NE.cjs');
|
|
10414
10451
|
const { cwd, model, store } = await abrirStoreLocal(reg);
|
|
10415
10452
|
await injectSessionTurn({
|
|
10416
10453
|
store,
|
|
@@ -10457,8 +10494,8 @@ async function abrirStoreLocal(reg) {
|
|
|
10457
10494
|
const cwd = reg.cwd ?? process.cwd();
|
|
10458
10495
|
const optModel = reg.options.model;
|
|
10459
10496
|
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
10460
|
-
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-
|
|
10461
|
-
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');
|
|
10462
10499
|
const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
|
|
10463
10500
|
return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
|
|
10464
10501
|
}
|
|
@@ -10478,5 +10515,5 @@ exports.isFixtureApiKey = isFixtureApiKey;
|
|
|
10478
10515
|
exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
|
|
10479
10516
|
exports.resolveApiKey = resolveApiKey;
|
|
10480
10517
|
exports.shouldUseFixtureMode = shouldUseFixtureMode;
|
|
10481
|
-
//# sourceMappingURL=chunk-
|
|
10482
|
-
//# sourceMappingURL=chunk-
|
|
10518
|
+
//# sourceMappingURL=chunk-S6F3FKFR.cjs.map
|
|
10519
|
+
//# sourceMappingURL=chunk-S6F3FKFR.cjs.map
|