@theokit/sdk 4.21.1 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/compaction.cjs +31 -0
  2. package/dist/compaction.cjs.map +1 -1
  3. package/dist/compaction.d.cts +79 -0
  4. package/dist/compaction.d.ts +79 -0
  5. package/dist/compaction.js +28 -1
  6. package/dist/compaction.js.map +1 -1
  7. package/dist/{cron-Bhdyjl0B.d.ts → cron-B_NkE_VM.d.ts} +15 -1
  8. package/dist/{cron-M2Xz7lq2.d.cts → cron-x3muPNgg.d.cts} +15 -1
  9. package/dist/cron.cjs +461 -332
  10. package/dist/cron.cjs.map +1 -1
  11. package/dist/cron.d.cts +2 -2
  12. package/dist/cron.d.ts +2 -2
  13. package/dist/cron.js +461 -332
  14. package/dist/cron.js.map +1 -1
  15. package/dist/{errors-gE8612p9.d.cts → errors-BdL-buYn.d.cts} +1 -1
  16. package/dist/{errors-CG2RpeW-.d.ts → errors-DHZtSNnj.d.ts} +1 -1
  17. package/dist/errors.d.cts +2 -2
  18. package/dist/eval.cjs +461 -332
  19. package/dist/eval.cjs.map +1 -1
  20. package/dist/eval.js +461 -332
  21. package/dist/eval.js.map +1 -1
  22. package/dist/index.cjs +634 -503
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +21 -12
  25. package/dist/index.d.ts +21 -12
  26. package/dist/index.js +634 -503
  27. package/dist/index.js.map +1 -1
  28. package/dist/internal/global-singleton.d.ts +13 -0
  29. package/dist/internal/llm/openai-messages.d.ts +2 -0
  30. package/dist/internal/local-agent/mcp-pool.d.ts +41 -0
  31. package/dist/internal/local-agent/real-local-run.d.ts +2 -0
  32. package/dist/internal/persistence/index.cjs +3 -1
  33. package/dist/internal/persistence/index.cjs.map +1 -1
  34. package/dist/internal/persistence/index.js +3 -1
  35. package/dist/internal/persistence/index.js.map +1 -1
  36. package/dist/internal/providers/registry.d.ts +1 -0
  37. package/dist/internal/runtime/lifecycle/context-budget-event.d.ts +25 -0
  38. package/dist/internal/runtime/lifecycle/goal-marker.d.ts +13 -0
  39. package/dist/internal/runtime/lifecycle/run-until.d.ts +0 -1
  40. package/dist/internal/session/agent-session.d.ts +1 -1
  41. package/dist/internal/session/session-cache.d.ts +20 -0
  42. package/dist/models.cjs +11 -15
  43. package/dist/models.cjs.map +1 -1
  44. package/dist/models.js +11 -15
  45. package/dist/models.js.map +1 -1
  46. package/dist/persistence.cjs +3 -1
  47. package/dist/persistence.cjs.map +1 -1
  48. package/dist/persistence.js +3 -1
  49. package/dist/persistence.js.map +1 -1
  50. package/dist/provider-catalog.json +144 -469
  51. package/dist/{run-DFM1H2jW.d.cts → run-OJbGyweZ.d.cts} +20 -1
  52. package/dist/{run-DFM1H2jW.d.ts → run-OJbGyweZ.d.ts} +20 -1
  53. package/dist/sandbox/index.cjs +47 -15
  54. package/dist/sandbox/index.cjs.map +1 -1
  55. package/dist/sandbox/index.js +47 -15
  56. package/dist/sandbox/index.js.map +1 -1
  57. package/dist/sandbox/linux-sandbox.d.cts +16 -6
  58. package/dist/sandbox/linux-sandbox.d.ts +16 -6
  59. package/dist/types/agent.d.ts +14 -0
  60. package/dist/types/run-events.d.ts +20 -1
  61. package/dist/workflow.cjs.map +1 -1
  62. package/dist/workflow.js.map +1 -1
  63. package/package.json +2 -2
  64. package/dist/goal-loop.d.ts +0 -35
@@ -33,6 +33,20 @@ export declare class LinuxSandbox extends LocalSandbox {
33
33
  });
34
34
  /** Extracted for test visibility — delegates to the pure `wrapCommandForSandbox` (M57, single wrap SoT). */
35
35
  wrapCommand(command: string): string | null;
36
+ /**
37
+ * M75 review (arquitetura, HIGH) — sem este override a classe MENTIA.
38
+ *
39
+ * `LinuxSandbox` se documenta como "kernel-enforced sandbox backend", mas sobrescrevia apenas
40
+ * `execute`. `uploadFile` continuava o herdado de `LocalSandbox`, que escreve direto no host via
41
+ * `fs/promises` e aceita caminho ABSOLUTO — sem bwrap, sem seccomp, sem restrição de caminho. E
42
+ * `SandboxBackend.writeFile` delega a ele. O resultado era uma classe incoerente: ler, buscar e
43
+ * listar passavam pelo confinamento; escrever, não.
44
+ *
45
+ * Rotear pelo `execute` embrulhado resolve na raiz: a escrita passa a viver sob a MESMA política
46
+ * do resto — se o bwrap nega o caminho, a escrita falha, como deve. O conteúdo vai por stdin (não
47
+ * por argv) porque argv tem limite de tamanho e conteúdo de arquivo não tem.
48
+ */
49
+ uploadFile(caminho: string, conteudo: string | Buffer): Promise<void>;
36
50
  execute(command: string, opts?: {
37
51
  timeoutMs?: number;
38
52
  }): Promise<import("./types.js").ExecuteResult>;
@@ -102,14 +116,10 @@ export interface InteractiveWrapOptions {
102
116
  *
103
117
  * `createSandboxBackend` resolve isto para o caminho não-interativo devolvendo um BACKEND pronto. O
104
118
  * PTY não aceita um backend: ele é dono do spawn e só admite transformar o comando. Esta função
105
- * entrega a MESMA decisão na forma que o PTY aceita — `(command, cwd) => string | null` —, pronta
106
- * para `new PtyInteractiveBackend({ wrapCommand: interactiveWrapCommand({ mode }) })`.
119
+ * entrega a MESMA decisão na forma que o PTY aceita — `(command, cwd) => string | null`.
107
120
  *
108
121
  * A detecção é consultada **a cada wrap**, não congelada na construção: uma sessão interativa vive
109
122
  * por horas, e uma detecção positiva obsoleta continuaria afirmando confinamento depois de o binário
110
- * sumir (a revalidação por `existsSync` vive dentro de `detectBwrapMemoizado`).
111
- *
112
- * As duas rotas que devolvem `null` são semanticamente diferentes e o código não as funde:
113
- * `danger-full-access` é opt-out explícito e NÃO avisa; bwrap indisponível é falha e avisa uma vez.
123
+ * sumir.
114
124
  */
115
125
  export declare function interactiveWrapCommand(opts: InteractiveWrapOptions): (command: string, cwd: string) => string | null;
@@ -332,6 +332,20 @@ export interface AgentOptions {
332
332
  local?: LocalOptions;
333
333
  cloud?: CloudOptions;
334
334
  mcpServers?: Record<string, McpServerConfig>;
335
+ /**
336
+ * M77 — how long an MCP client lives.
337
+ *
338
+ * `'run'` (DEFAULT, and the historical behaviour) spawns a client per `send` and drops it when the
339
+ * run ends. `'session'` pools clients per `(agentId, server, config)` and keeps them across turns,
340
+ * which is what the reference does — Codex holds its connection manager in `SessionServices`
341
+ * (`core/src/state/service.rs:116`). Measured cost of the per-run path: 193 / 138 / 134 ms of
342
+ * spawn + handshake on every turn.
343
+ *
344
+ * Opt-in rather than default because it changes the FAILURE model: a server that dies mid-session
345
+ * becomes a reachable state. One-shot and cron runs gain nothing from pooling and would pay that
346
+ * risk, so they keep `'run'` unless they ask otherwise.
347
+ */
348
+ mcpLifecycle?: "run" | "session";
335
349
  agents?: Record<string, AgentDefinition>;
336
350
  agentId?: string;
337
351
  /** Context manager configuration. See `agent.context`. */
@@ -16,7 +16,7 @@
16
16
  *
17
17
  * @public
18
18
  */
19
- export type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunTripwireEvent | RunCompletionCheckEvent;
19
+ export type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunCompactionFallbackEvent | RunTripwireEvent | RunCompletionCheckEvent;
20
20
  /**
21
21
  * SE24 — a guardrail processor called `abort()`; the run stops with a tripwire.
22
22
  * Delivered via {@link SendOptions.onRunEvent} (mirrors the `RunResult.tripwire`
@@ -91,6 +91,25 @@ export interface RunCompactBoundaryEvent {
91
91
  /** Token count before compaction, when known. */
92
92
  readonly preTokens?: number;
93
93
  }
94
+ /**
95
+ * M77 — auto-compaction is budgeting against a FLOOR, because neither the catalog nor the caller
96
+ * supplied a context window for this model.
97
+ *
98
+ * The prior behaviour was to disable auto-compaction entirely and write one line to stderr per
99
+ * process. That is fail-OPEN: the conversation grows until the provider rejects it. This event exists
100
+ * so a surface can say "I am running without a real budget" instead of the user discovering it at the
101
+ * moment of failure.
102
+ *
103
+ * Not emitted when the window came from the catalog (the normal path) or from an explicit caller
104
+ * override (the caller already knows).
105
+ */
106
+ export interface RunCompactionFallbackEvent {
107
+ readonly type: "compaction_fallback";
108
+ /** The model whose window is unknown — what the user needs to fix in configuration. */
109
+ readonly model: string;
110
+ /** The floor being budgeted against, after the safety margin. */
111
+ readonly window: number;
112
+ }
94
113
  /**
95
114
  * SE2 — the opt-in sink for {@link RunEvent}s. Supplied via `SendOptions.onRunEvent`.
96
115
  * Synchronous + best-effort: a throwing sink must never break the run (the emitter