@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.31.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- M93 — oito correções da revisão adversarial.
|
|
8
|
+
|
|
9
|
+
- **O retry deixa de reexecutar um stream já parcialmente consumido.** Uma falha depois do primeiro evento reexecutava o turno inteiro, duplicando texto e blocos `tool_use` — exatamente no cenário que motivou o retry (429 depois de várias tool calls).
|
|
10
|
+
- **O transcript volta a nascer `0600`.** A troca para append incremental perdeu o modo explícito e, sob `umask 022`, o arquivo — que carrega conteúdo em trânsito — nascia legível por outros.
|
|
11
|
+
- **Um append sobre arquivo truncado por crash não engole mais o registro novo.**
|
|
12
|
+
- **Erro transitório passa a ser decidido pelo status estruturado, não pelo texto da mensagem.** A heurística anterior classificava `ECONNREFUSED …:443` como não-transitório porque a porta casava o padrão de "4xx": o retry ficava desligado justamente para falha de rede.
|
|
13
|
+
- **Falha de socket passa a ser tipada nos transportes Anthropic e OpenAI.** Sem isso, o erro cru escapava e nenhuma política de retry o reconhecia.
|
|
14
|
+
- **`CredentialPoolExhaustedError` e circuito aberto deixam de ser reexecutados.** O pool já gastou o próprio orçamento; reexecutar por cima triplicava a espera e desfazia o fail-fast do circuit breaker.
|
|
15
|
+
- Cancelamento (`AbortError`) nunca é confundido com falha de rede.
|
|
16
|
+
|
|
17
|
+
## 4.31.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- d8412b6: **Um erro transitório de provider deixa de destruir o turno inteiro.**
|
|
22
|
+
|
|
23
|
+
Três defeitos que, combinados, tornavam a perda total:
|
|
24
|
+
|
|
25
|
+
- **O caminho de chave única não tinha retry.** `buildPoolOrSingle` dava `PoolAwareLlmClient` — circuit
|
|
26
|
+
breaker, backoff de jitter total, `Retry-After`, rotação — com **≥ 2** chaves, e o transporte **cru**
|
|
27
|
+
com uma. Um consumidor que resolve exatamente uma credencial (o caso comum) caía sempre no braço sem
|
|
28
|
+
resiliência. A assimetria não tem justificativa de domínio: **um pool de 1 chave é um pool de tamanho
|
|
29
|
+
1**. `RetryingLlmClient` é composição — `computeBackoffMs` e `sleepWithAbort` já eram módulos
|
|
30
|
+
independentes — e aplica-se aos **três** braços (o do pool ambiente também estava de fora).
|
|
31
|
+
|
|
32
|
+
- **O caminho de erro não persistia nada.** O `catch` de `run.wait()` chamava `flushSessionWrites()` e
|
|
33
|
+
retornava; `persistTurnToTranscript` é chamado só depois, e é o único chamador do repositório. O
|
|
34
|
+
flush drenava um conjunto **vazio**. Agora persiste o **parcial** — user + tool calls concluídas —
|
|
35
|
+
sem reconstruir o que não aconteceu.
|
|
36
|
+
|
|
37
|
+
- **`appendRecords` reescrevia o arquivo inteiro por turno.** O(n) de I/O **e** de parse a cada turno,
|
|
38
|
+
O(n²) por sessão. Correto porque o formato **já é append-only** (o DAG de `parentUuid` não depende da
|
|
39
|
+
ordem de linha), e `appendJsonl` **já existia** no pacote com um único chamador. O `withFileLock`
|
|
40
|
+
permanece — é ele que serializa appends concorrentes.
|
|
41
|
+
|
|
42
|
+
Só erro **transitório** reexecuta: 402 (billing) não é, porque cota não se resolve em milissegundos, e
|
|
43
|
+
401 falha na primeira. Teto de 3 tentativas, ciente de `AbortSignal`.
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- f76ed61: Corrige o docstring de `Agent.getOrCreate`, que afirmava o oposto do comportamento real.
|
|
48
|
+
|
|
49
|
+
Ele dizia: _"Disposed agents are NOT auto-deleted from the registry. To force a fresh agent, call
|
|
50
|
+
`Agent.delete(agentId)` first."_ Medido, é falso — `dispose()` chama `liveAgentRegistry.forget(id)`,
|
|
51
|
+
então o próximo `getOrCreate(id)` constrói um handle novo, sem `Agent.delete`.
|
|
52
|
+
|
|
53
|
+
A afirmação era sobre o registro **persistente** e foi lida como sendo sobre o **cache vivo**; um
|
|
54
|
+
consumidor construiu em cima da metade errada. Travado por `tests/m91-getorcreate-apos-dispose.test.ts`.
|
|
55
|
+
|
|
56
|
+
O bullet novo também registra o que continua verdadeiro: `close()` marca o handle descartado **sem**
|
|
57
|
+
evictar a entrada do cache. É interno e sem chamador hoje; se voltar a ser alcançável, o bullet deixa
|
|
58
|
+
de valer para aquele caminho — e está escrito para que a próxima pessoa não precise redescobrir.
|
|
59
|
+
|
|
3
60
|
## 4.17.1
|
|
4
61
|
|
|
5
62
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as ModelSelection, ac as SDKUserMessage, ae as SendOptions, b as Run, G as GenerateOptions, n as GenerateRunResult, _ as RunToCompletionOptions, $ as RunToCompletionResult, S as SDKMessage, al as StreamToCompletionResult, C as CustomTool, c as PermissionMode, a as McpServerConfig, P as Processor } from './run-
|
|
1
|
+
import { M as ModelSelection, ac as SDKUserMessage, ae as SendOptions, b as Run, G as GenerateOptions, n as GenerateRunResult, _ as RunToCompletionOptions, $ as RunToCompletionResult, S as SDKMessage, al as StreamToCompletionResult, C as CustomTool, c as PermissionMode, a as McpServerConfig, P as Processor } from './run-CwEJtLPE.js';
|
|
2
2
|
import * as zod from 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkS6F3FKFR_cjs = require('./chunk-S6F3FKFR.cjs');
|
|
4
4
|
require('./chunk-BV2MWEMV.cjs');
|
|
5
5
|
require('./chunk-MZ5ZRORA.cjs');
|
|
6
|
-
require('./chunk-
|
|
6
|
+
require('./chunk-E2YEDATX.cjs');
|
|
7
7
|
require('./chunk-BUUUWQMB.cjs');
|
|
8
|
-
require('./chunk-
|
|
9
|
-
require('./chunk-
|
|
8
|
+
require('./chunk-IOOSAZZH.cjs');
|
|
9
|
+
require('./chunk-NZCFLEHO.cjs');
|
|
10
10
|
require('./chunk-LUSXDZPV.cjs');
|
|
11
11
|
require('./chunk-IT3PWBW4.cjs');
|
|
12
12
|
require('./chunk-JLMXKTBX.cjs');
|
|
@@ -21,10 +21,10 @@ require('./chunk-YPEPCZHF.cjs');
|
|
|
21
21
|
require('./chunk-VJ26EKGJ.cjs');
|
|
22
22
|
require('./chunk-GIW4L6HY.cjs');
|
|
23
23
|
require('./chunk-7S7KKUO6.cjs');
|
|
24
|
-
require('./chunk-
|
|
24
|
+
require('./chunk-CJVMDRQB.cjs');
|
|
25
25
|
require('./chunk-JD74LN7R.cjs');
|
|
26
26
|
require('./chunk-YLQQX5W2.cjs');
|
|
27
|
-
require('./chunk-
|
|
27
|
+
require('./chunk-U2FO3MRG.cjs');
|
|
28
28
|
require('./chunk-ANIZEWTU.cjs');
|
|
29
29
|
require('./chunk-WJVHMTKB.cjs');
|
|
30
30
|
require('./chunk-TIZ4TS5V.cjs');
|
|
@@ -44,7 +44,7 @@ require('./chunk-BEURCLDV.cjs');
|
|
|
44
44
|
|
|
45
45
|
Object.defineProperty(exports, "Agent", {
|
|
46
46
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
47
|
+
get: function () { return chunkS6F3FKFR_cjs.Agent; }
|
|
48
48
|
});
|
|
49
|
-
//# sourceMappingURL=agent-
|
|
50
|
-
//# sourceMappingURL=agent-
|
|
49
|
+
//# sourceMappingURL=agent-BKNJIOEY.cjs.map
|
|
50
|
+
//# sourceMappingURL=agent-BKNJIOEY.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"agent-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"agent-BKNJIOEY.cjs"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as ModelSelection, ac as SDKUserMessage, ae as SendOptions, b as Run, G as GenerateOptions, n as GenerateRunResult, _ as RunToCompletionOptions, $ as RunToCompletionResult, S as SDKMessage, al as StreamToCompletionResult, C as CustomTool, c as PermissionMode, a as McpServerConfig, P as Processor } from './run-
|
|
1
|
+
import { M as ModelSelection, ac as SDKUserMessage, ae as SendOptions, b as Run, G as GenerateOptions, n as GenerateRunResult, _ as RunToCompletionOptions, $ as RunToCompletionResult, S as SDKMessage, al as StreamToCompletionResult, C as CustomTool, c as PermissionMode, a as McpServerConfig, P as Processor } from './run-CwEJtLPE.cjs';
|
|
2
2
|
import * as zod from 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { Agent } from './chunk-
|
|
1
|
+
export { Agent } from './chunk-CCRWSZ2F.js';
|
|
2
2
|
import './chunk-2SFBB54R.js';
|
|
3
3
|
import './chunk-HRA3CPGG.js';
|
|
4
|
-
import './chunk-
|
|
4
|
+
import './chunk-SJLOIZ4Z.js';
|
|
5
5
|
import './chunk-K2BQQ445.js';
|
|
6
|
-
import './chunk-
|
|
7
|
-
import './chunk-
|
|
6
|
+
import './chunk-RPKTXBPK.js';
|
|
7
|
+
import './chunk-XDNGF5BY.js';
|
|
8
8
|
import './chunk-6CLRANZA.js';
|
|
9
9
|
import './chunk-EEZ7CFMM.js';
|
|
10
10
|
import './chunk-XAUBQMQU.js';
|
|
@@ -19,10 +19,10 @@ import './chunk-UJ7IQJAG.js';
|
|
|
19
19
|
import './chunk-7AD3ZTZL.js';
|
|
20
20
|
import './chunk-V4XRLPEF.js';
|
|
21
21
|
import './chunk-5PZMMF4H.js';
|
|
22
|
-
import './chunk-
|
|
22
|
+
import './chunk-UAYYNWYJ.js';
|
|
23
23
|
import './chunk-77FOZCOT.js';
|
|
24
24
|
import './chunk-2XLKLVVR.js';
|
|
25
|
-
import './chunk-
|
|
25
|
+
import './chunk-VGUOUAM2.js';
|
|
26
26
|
import './chunk-BXV2QUIC.js';
|
|
27
27
|
import './chunk-4VPXM6UU.js';
|
|
28
28
|
import './chunk-S2BBRVQX.js';
|
|
@@ -37,5 +37,5 @@ import './chunk-POQT2OIF.js';
|
|
|
37
37
|
import './chunk-FKCC2MED.js';
|
|
38
38
|
import './chunk-WLKFWQSJ.js';
|
|
39
39
|
import './chunk-JTFYYKDT.js';
|
|
40
|
-
//# sourceMappingURL=agent-
|
|
41
|
-
//# sourceMappingURL=agent-
|
|
40
|
+
//# sourceMappingURL=agent-HW7OY2W3.js.map
|
|
41
|
+
//# sourceMappingURL=agent-HW7OY2W3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"agent-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"agent-HW7OY2W3.js"}
|
package/dist/agent.d.ts
CHANGED
|
@@ -124,8 +124,21 @@ export declare class Agent {
|
|
|
124
124
|
* Caveats:
|
|
125
125
|
* - The function-level `agentId` always wins over `options.agentId`.
|
|
126
126
|
* - Options differ between calls? Last-call-wins for this handle (matches `Agent.resume`).
|
|
127
|
-
* -
|
|
128
|
-
*
|
|
127
|
+
* - A DISPOSED agent is replaced automatically. `dispose()` evicts the id from the
|
|
128
|
+
* live cache (`liveAgentRegistry.forget`), so the next `getOrCreate(id)` builds a
|
|
129
|
+
* fresh handle — no `Agent.delete(agentId)` needed.
|
|
130
|
+
*
|
|
131
|
+
* This bullet used to say the opposite ("Disposed agents are NOT auto-deleted...
|
|
132
|
+
* call `Agent.delete(agentId)` first"). It was measured false in M91:
|
|
133
|
+
* `tests/m91-getorcreate-apos-dispose.test.ts` builds an agent, disposes it, and
|
|
134
|
+
* gets a different instance back. The claim was about the PERSISTENT registry and
|
|
135
|
+
* read as being about the live cache — and consumers built around the wrong half.
|
|
136
|
+
* The agent-builder's M85 interrupt rotates the session id to work around a
|
|
137
|
+
* constraint that does not exist.
|
|
138
|
+
*
|
|
139
|
+
* - `close()` marks the handle disposed WITHOUT evicting the cache entry. It is
|
|
140
|
+
* internal and unused today; if it becomes reachable, this bullet stops being true
|
|
141
|
+
* for that path.
|
|
129
142
|
*
|
|
130
143
|
* @public
|
|
131
144
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { extractCodePlugins } from './chunk-2SFBB54R.js';
|
|
2
2
|
import { submit, emitRunEvent } from './chunk-HRA3CPGG.js';
|
|
3
|
-
import { enqueueSessionWrite, hydrateSession, flushSessionWrites,
|
|
4
|
-
import { FsSessionStore } from './chunk-
|
|
5
|
-
import { discoverProviderPlugins, CircuitBreaker, buildDefaultSummarizer, parseSseStream, resolveProviderChain, inferProviderFromApiKey, detectPrimaryProvider, tryFirstEvent, relayStream, mapOpenAICompatibleError, renderToolResultContentText } from './chunk-
|
|
3
|
+
import { enqueueSessionWrite, hydrateSession, flushSessionWrites, persistTurnToTranscript, appendSessionMessage, getSessionMessages, clearSession } from './chunk-SJLOIZ4Z.js';
|
|
4
|
+
import { FsSessionStore } from './chunk-RPKTXBPK.js';
|
|
5
|
+
import { discoverProviderPlugins, CircuitBreaker, buildDefaultSummarizer, parseSseStream, resolveProviderChain, inferProviderFromApiKey, detectPrimaryProvider, tryFirstEvent, relayStream, mapOpenAICompatibleError, renderToolResultContentText } from './chunk-XDNGF5BY.js';
|
|
6
6
|
import { IndexManager, writeSessionSummary, memoryDir, globalEmbeddingCache, appendFact, readFacts, legacyMemoryJsonPath, memoryMdPath, appendFactToMarkdown } from './chunk-XAUBQMQU.js';
|
|
7
7
|
import { loadHookConfig, warnOnce, currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-XIG2IE3L.js';
|
|
8
8
|
import { resolveChildEnv } from './chunk-7GFX45DD.js';
|
|
@@ -13,9 +13,9 @@ import { setAgentFacade } from './chunk-6X6ID4MO.js';
|
|
|
13
13
|
import { findGitRoot, DEFAULT_DISCOVERY_SPECS, walkUpForFile, walkUpForGlob } from './chunk-UJ7IQJAG.js';
|
|
14
14
|
import { withToolWhitelist, checkToolWhitelist } from './chunk-7AD3ZTZL.js';
|
|
15
15
|
import { mapWithConcurrency } from './chunk-V4XRLPEF.js';
|
|
16
|
-
import { withFileLock } from './chunk-
|
|
16
|
+
import { withFileLock } from './chunk-UAYYNWYJ.js';
|
|
17
17
|
import { withCwdMutex } from './chunk-2XLKLVVR.js';
|
|
18
|
-
import { defaultBaseDir, expandTilde } from './chunk-
|
|
18
|
+
import { defaultBaseDir, expandTilde } from './chunk-VGUOUAM2.js';
|
|
19
19
|
import { toJsonSchema } from './chunk-4VPXM6UU.js';
|
|
20
20
|
import { atomicWriteJson } from './chunk-S2BBRVQX.js';
|
|
21
21
|
import { loadSubagents } from './chunk-BNIFFFH3.js';
|
|
@@ -2700,6 +2700,15 @@ function buildContextBudgetEvent(model, resolved) {
|
|
|
2700
2700
|
}
|
|
2701
2701
|
|
|
2702
2702
|
// src/internal/runtime/lifecycle/post-run-lifecycle.ts
|
|
2703
|
+
function resolveWindowForRun(model, contextWindow) {
|
|
2704
|
+
const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
|
|
2705
|
+
return resolveEffectiveContextWindow({
|
|
2706
|
+
...override !== void 0 ? { override } : {},
|
|
2707
|
+
catalog: getCatalogModelInfo(model)?.limit?.context,
|
|
2708
|
+
margin: CONTEXT_WINDOW_MARGIN,
|
|
2709
|
+
floor: CONTEXT_WINDOW_FLOOR
|
|
2710
|
+
});
|
|
2711
|
+
}
|
|
2703
2712
|
async function runPostRunLifecycle(inputs) {
|
|
2704
2713
|
const {
|
|
2705
2714
|
run,
|
|
@@ -2708,6 +2717,7 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2708
2717
|
workspaceCwd,
|
|
2709
2718
|
sessionStore,
|
|
2710
2719
|
model,
|
|
2720
|
+
contextWindow,
|
|
2711
2721
|
onRunEvent,
|
|
2712
2722
|
hooksExecutor,
|
|
2713
2723
|
memoryGlue,
|
|
@@ -2717,6 +2727,19 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2717
2727
|
try {
|
|
2718
2728
|
result = await run.wait();
|
|
2719
2729
|
} catch {
|
|
2730
|
+
try {
|
|
2731
|
+
const parcial = await safeConversation(run);
|
|
2732
|
+
if (parcial !== void 0) {
|
|
2733
|
+
persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
|
|
2734
|
+
userText,
|
|
2735
|
+
conversation: parcial
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
} catch (cause) {
|
|
2739
|
+
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
2740
|
+
process.stderr.write(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
|
|
2741
|
+
`);
|
|
2742
|
+
}
|
|
2720
2743
|
await flushSessionWrites();
|
|
2721
2744
|
return;
|
|
2722
2745
|
}
|
|
@@ -2724,12 +2747,8 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2724
2747
|
appendSessionMessage(agentId, { role: "assistant", text: result.result });
|
|
2725
2748
|
}
|
|
2726
2749
|
const conversation = await safeConversation(run);
|
|
2727
|
-
const resolvedWindow =
|
|
2728
|
-
|
|
2729
|
-
margin: CONTEXT_WINDOW_MARGIN,
|
|
2730
|
-
floor: CONTEXT_WINDOW_FLOOR
|
|
2731
|
-
});
|
|
2732
|
-
const contextWindow = resolvedWindow.window;
|
|
2750
|
+
const resolvedWindow = resolveWindowForRun(model, contextWindow);
|
|
2751
|
+
const janelaEfetiva = resolvedWindow.window;
|
|
2733
2752
|
const budgetEvent = buildContextBudgetEvent(model, resolvedWindow);
|
|
2734
2753
|
if (budgetEvent !== void 0 && onRunEvent !== void 0) {
|
|
2735
2754
|
emitRunEvent(onRunEvent, budgetEvent);
|
|
@@ -2745,7 +2764,9 @@ async function runPostRunLifecycle(inputs) {
|
|
|
2745
2764
|
conversation,
|
|
2746
2765
|
autoCompact: {
|
|
2747
2766
|
usageTotal: usageForTrigger,
|
|
2748
|
-
|
|
2767
|
+
// A janela EFETIVA (após override, clamp e margem) — não a declarada. Trocar por
|
|
2768
|
+
// `contextWindow` aqui orçaria contra um número que o clamp já rejeitou.
|
|
2769
|
+
contextWindow: janelaEfetiva,
|
|
2749
2770
|
summarize: buildDefaultSummarizer({
|
|
2750
2771
|
agentModel: model,
|
|
2751
2772
|
...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
|
|
@@ -9657,6 +9678,9 @@ var LocalAgent = class {
|
|
|
9657
9678
|
workspaceCwd: this.workspaceCwd,
|
|
9658
9679
|
sessionStore: this.sessionStore,
|
|
9659
9680
|
model: this.model?.id ?? "unknown",
|
|
9681
|
+
// M94 — a janela declarada atravessa até o orçamento. Sem isto o `override` do resolvedor
|
|
9682
|
+
// existia desde o M77 e nenhum call site de produção o passava.
|
|
9683
|
+
...this.model?.contextWindow !== void 0 ? { contextWindow: this.model.contextWindow } : {},
|
|
9660
9684
|
// M50 — the auto-compaction summarizer resolves credentials like the run itself.
|
|
9661
9685
|
...this.options.apiKey !== void 0 ? { apiKey: this.options.apiKey } : {},
|
|
9662
9686
|
...options.onRunEvent !== void 0 ? { onRunEvent: options.onRunEvent } : {},
|
|
@@ -10264,8 +10288,21 @@ var Agent = class _Agent {
|
|
|
10264
10288
|
* Caveats:
|
|
10265
10289
|
* - The function-level `agentId` always wins over `options.agentId`.
|
|
10266
10290
|
* - Options differ between calls? Last-call-wins for this handle (matches `Agent.resume`).
|
|
10267
|
-
* -
|
|
10268
|
-
*
|
|
10291
|
+
* - A DISPOSED agent is replaced automatically. `dispose()` evicts the id from the
|
|
10292
|
+
* live cache (`liveAgentRegistry.forget`), so the next `getOrCreate(id)` builds a
|
|
10293
|
+
* fresh handle — no `Agent.delete(agentId)` needed.
|
|
10294
|
+
*
|
|
10295
|
+
* This bullet used to say the opposite ("Disposed agents are NOT auto-deleted...
|
|
10296
|
+
* call `Agent.delete(agentId)` first"). It was measured false in M91:
|
|
10297
|
+
* `tests/m91-getorcreate-apos-dispose.test.ts` builds an agent, disposes it, and
|
|
10298
|
+
* gets a different instance back. The claim was about the PERSISTENT registry and
|
|
10299
|
+
* read as being about the live cache — and consumers built around the wrong half.
|
|
10300
|
+
* The agent-builder's M85 interrupt rotates the session id to work around a
|
|
10301
|
+
* constraint that does not exist.
|
|
10302
|
+
*
|
|
10303
|
+
* - `close()` marks the handle disposed WITHOUT evicting the cache entry. It is
|
|
10304
|
+
* internal and unused today; if it becomes reachable, this bullet stops being true
|
|
10305
|
+
* for that path.
|
|
10269
10306
|
*
|
|
10270
10307
|
* @public
|
|
10271
10308
|
*/
|
|
@@ -10371,7 +10408,7 @@ var Agent = class _Agent {
|
|
|
10371
10408
|
`No local agent "${agentId}" registered \u2014 compact targets local sessions.`
|
|
10372
10409
|
);
|
|
10373
10410
|
}
|
|
10374
|
-
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-
|
|
10411
|
+
const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-QMBOCFVQ.js');
|
|
10375
10412
|
const { cwd, model, store } = await abrirStoreLocal(reg);
|
|
10376
10413
|
return enqueueSessionWrite(
|
|
10377
10414
|
cwd,
|
|
@@ -10407,7 +10444,7 @@ var Agent = class _Agent {
|
|
|
10407
10444
|
`No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
|
|
10408
10445
|
);
|
|
10409
10446
|
}
|
|
10410
|
-
const { injectSessionTurn } = await import('./inject-session-
|
|
10447
|
+
const { injectSessionTurn } = await import('./inject-session-YA3GQE4G.js');
|
|
10411
10448
|
const { cwd, model, store } = await abrirStoreLocal(reg);
|
|
10412
10449
|
await injectSessionTurn({
|
|
10413
10450
|
store,
|
|
@@ -10454,12 +10491,12 @@ async function abrirStoreLocal(reg) {
|
|
|
10454
10491
|
const cwd = reg.cwd ?? process.cwd();
|
|
10455
10492
|
const optModel = reg.options.model;
|
|
10456
10493
|
const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
|
|
10457
|
-
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-
|
|
10458
|
-
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-
|
|
10494
|
+
const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-T7YPW5A4.js');
|
|
10495
|
+
const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-5VZUWEJ5.js');
|
|
10459
10496
|
const baseDir = reg.options.local?.baseDir !== void 0 ? expandTilde2(reg.options.local.baseDir) : defaultBaseDir2();
|
|
10460
10497
|
return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
|
|
10461
10498
|
}
|
|
10462
10499
|
|
|
10463
10500
|
export { Agent, AgentBuilder, DEFAULT_AGENTIC_MODEL_ID, MEMORY_EMBEDDING_ADAPTERS, Tool, ToolError, UsageAccumulator, computeCost, generateCronId, getPricingEntry, httpRequest, isFixtureApiKey, openRouterMemoryEmbeddingProviderAdapter, resolveApiKey, shouldUseFixtureMode };
|
|
10464
|
-
//# sourceMappingURL=chunk-
|
|
10465
|
-
//# sourceMappingURL=chunk-
|
|
10501
|
+
//# sourceMappingURL=chunk-CCRWSZ2F.js.map
|
|
10502
|
+
//# sourceMappingURL=chunk-CCRWSZ2F.js.map
|