@theokit/sdk 4.22.0 → 4.24.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 (63) hide show
  1. package/dist/auth/index.cjs +29 -5
  2. package/dist/auth/index.cjs.map +1 -1
  3. package/dist/auth/index.js +29 -5
  4. package/dist/auth/index.js.map +1 -1
  5. package/dist/compaction.cjs +31 -0
  6. package/dist/compaction.cjs.map +1 -1
  7. package/dist/compaction.d.cts +79 -0
  8. package/dist/compaction.d.ts +79 -0
  9. package/dist/compaction.js +28 -1
  10. package/dist/compaction.js.map +1 -1
  11. package/dist/{cron-Bhdyjl0B.d.ts → cron-B_NkE_VM.d.ts} +15 -1
  12. package/dist/{cron-M2Xz7lq2.d.cts → cron-x3muPNgg.d.cts} +15 -1
  13. package/dist/cron.cjs +467 -337
  14. package/dist/cron.cjs.map +1 -1
  15. package/dist/cron.d.cts +2 -2
  16. package/dist/cron.d.ts +2 -2
  17. package/dist/cron.js +467 -337
  18. package/dist/cron.js.map +1 -1
  19. package/dist/{errors-gE8612p9.d.cts → errors-BdL-buYn.d.cts} +1 -1
  20. package/dist/{errors-CG2RpeW-.d.ts → errors-DHZtSNnj.d.ts} +1 -1
  21. package/dist/errors.d.cts +2 -2
  22. package/dist/eval.cjs +467 -337
  23. package/dist/eval.cjs.map +1 -1
  24. package/dist/eval.js +467 -337
  25. package/dist/eval.js.map +1 -1
  26. package/dist/index.cjs +640 -508
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +21 -12
  29. package/dist/index.d.ts +21 -12
  30. package/dist/index.js +640 -508
  31. package/dist/index.js.map +1 -1
  32. package/dist/internal/auth/credential-store.d.ts +20 -3
  33. package/dist/internal/global-singleton.d.ts +13 -0
  34. package/dist/internal/llm/openai-messages.d.ts +2 -0
  35. package/dist/internal/local-agent/mcp-pool.d.ts +41 -0
  36. package/dist/internal/local-agent/real-local-run.d.ts +2 -0
  37. package/dist/internal/persistence/index.cjs +3 -1
  38. package/dist/internal/persistence/index.cjs.map +1 -1
  39. package/dist/internal/persistence/index.js +3 -1
  40. package/dist/internal/persistence/index.js.map +1 -1
  41. package/dist/internal/providers/registry.d.ts +1 -0
  42. package/dist/internal/runtime/lifecycle/context-budget-event.d.ts +25 -0
  43. package/dist/internal/runtime/lifecycle/goal-marker.d.ts +13 -0
  44. package/dist/internal/runtime/lifecycle/run-until.d.ts +0 -1
  45. package/dist/internal/session/agent-session.d.ts +1 -1
  46. package/dist/internal/session/session-cache.d.ts +20 -0
  47. package/dist/models.cjs +22 -20
  48. package/dist/models.cjs.map +1 -1
  49. package/dist/models.js +22 -20
  50. package/dist/models.js.map +1 -1
  51. package/dist/persistence.cjs +3 -1
  52. package/dist/persistence.cjs.map +1 -1
  53. package/dist/persistence.js +3 -1
  54. package/dist/persistence.js.map +1 -1
  55. package/dist/provider-catalog.json +144 -469
  56. package/dist/{run-DFM1H2jW.d.cts → run-OJbGyweZ.d.cts} +20 -1
  57. package/dist/{run-DFM1H2jW.d.ts → run-OJbGyweZ.d.ts} +20 -1
  58. package/dist/types/agent.d.ts +14 -0
  59. package/dist/types/run-events.d.ts +20 -1
  60. package/dist/workflow.cjs.map +1 -1
  61. package/dist/workflow.js.map +1 -1
  62. package/package.json +2 -2
  63. package/dist/goal-loop.d.ts +0 -35
@@ -105,7 +105,7 @@ declare class PermissionEngine {
105
105
  *
106
106
  * @public
107
107
  */
108
- type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunTripwireEvent | RunCompletionCheckEvent;
108
+ type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunCompactionFallbackEvent | RunTripwireEvent | RunCompletionCheckEvent;
109
109
  /**
110
110
  * SE24 — a guardrail processor called `abort()`; the run stops with a tripwire.
111
111
  * Delivered via {@link SendOptions.onRunEvent} (mirrors the `RunResult.tripwire`
@@ -180,6 +180,25 @@ interface RunCompactBoundaryEvent {
180
180
  /** Token count before compaction, when known. */
181
181
  readonly preTokens?: number;
182
182
  }
183
+ /**
184
+ * M77 — auto-compaction is budgeting against a FLOOR, because neither the catalog nor the caller
185
+ * supplied a context window for this model.
186
+ *
187
+ * The prior behaviour was to disable auto-compaction entirely and write one line to stderr per
188
+ * process. That is fail-OPEN: the conversation grows until the provider rejects it. This event exists
189
+ * so a surface can say "I am running without a real budget" instead of the user discovering it at the
190
+ * moment of failure.
191
+ *
192
+ * Not emitted when the window came from the catalog (the normal path) or from an explicit caller
193
+ * override (the caller already knows).
194
+ */
195
+ interface RunCompactionFallbackEvent {
196
+ readonly type: "compaction_fallback";
197
+ /** The model whose window is unknown — what the user needs to fix in configuration. */
198
+ readonly model: string;
199
+ /** The floor being budgeted against, after the safety margin. */
200
+ readonly window: number;
201
+ }
183
202
  /**
184
203
  * SE2 — the opt-in sink for {@link RunEvent}s. Supplied via `SendOptions.onRunEvent`.
185
204
  * Synchronous + best-effort: a throwing sink must never break the run (the emitter
@@ -105,7 +105,7 @@ declare class PermissionEngine {
105
105
  *
106
106
  * @public
107
107
  */
108
- type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunTripwireEvent | RunCompletionCheckEvent;
108
+ type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunCompactionFallbackEvent | RunTripwireEvent | RunCompletionCheckEvent;
109
109
  /**
110
110
  * SE24 — a guardrail processor called `abort()`; the run stops with a tripwire.
111
111
  * Delivered via {@link SendOptions.onRunEvent} (mirrors the `RunResult.tripwire`
@@ -180,6 +180,25 @@ interface RunCompactBoundaryEvent {
180
180
  /** Token count before compaction, when known. */
181
181
  readonly preTokens?: number;
182
182
  }
183
+ /**
184
+ * M77 — auto-compaction is budgeting against a FLOOR, because neither the catalog nor the caller
185
+ * supplied a context window for this model.
186
+ *
187
+ * The prior behaviour was to disable auto-compaction entirely and write one line to stderr per
188
+ * process. That is fail-OPEN: the conversation grows until the provider rejects it. This event exists
189
+ * so a surface can say "I am running without a real budget" instead of the user discovering it at the
190
+ * moment of failure.
191
+ *
192
+ * Not emitted when the window came from the catalog (the normal path) or from an explicit caller
193
+ * override (the caller already knows).
194
+ */
195
+ interface RunCompactionFallbackEvent {
196
+ readonly type: "compaction_fallback";
197
+ /** The model whose window is unknown — what the user needs to fix in configuration. */
198
+ readonly model: string;
199
+ /** The floor being budgeted against, after the safety margin. */
200
+ readonly window: number;
201
+ }
183
202
  /**
184
203
  * SE2 — the opt-in sink for {@link RunEvent}s. Supplied via `SendOptions.onRunEvent`.
185
204
  * Synchronous + best-effort: a throwing sink must never break the run (the emitter
@@ -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