@theokit/sdk 4.19.1 → 4.19.3

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 (45) hide show
  1. package/dist/cron-Bhdyjl0B.d.ts +2582 -0
  2. package/dist/cron-M2Xz7lq2.d.cts +2582 -0
  3. package/dist/cron.cjs +19 -8
  4. package/dist/cron.cjs.map +1 -1
  5. package/dist/cron.d.cts +3 -0
  6. package/dist/cron.d.ts +3 -0
  7. package/dist/cron.js +19 -8
  8. package/dist/cron.js.map +1 -1
  9. package/dist/errors-CG2RpeW-.d.ts +516 -0
  10. package/dist/errors-gE8612p9.d.cts +516 -0
  11. package/dist/errors.d.cts +3 -0
  12. package/dist/eval.cjs +19 -8
  13. package/dist/eval.cjs.map +1 -1
  14. package/dist/eval.js +19 -8
  15. package/dist/eval.js.map +1 -1
  16. package/dist/filesystem/index.cjs +2 -1
  17. package/dist/filesystem/index.cjs.map +1 -1
  18. package/dist/filesystem/index.js +2 -1
  19. package/dist/filesystem/index.js.map +1 -1
  20. package/dist/goal-loop.d.ts +35 -0
  21. package/dist/index.cjs +139 -130
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +2309 -0
  24. package/dist/index.d.ts +2309 -0
  25. package/dist/index.js +139 -130
  26. package/dist/index.js.map +1 -1
  27. package/dist/internal/runtime/lifecycle/run-until.d.ts +1 -1
  28. package/dist/internal/security/index.cjs +2 -1
  29. package/dist/internal/security/index.cjs.map +1 -1
  30. package/dist/internal/security/index.js +2 -1
  31. package/dist/internal/security/index.js.map +1 -1
  32. package/dist/path-safety.cjs +2 -1
  33. package/dist/path-safety.cjs.map +1 -1
  34. package/dist/path-safety.js +2 -1
  35. package/dist/path-safety.js.map +1 -1
  36. package/dist/provider-catalog.json +1620 -0
  37. package/dist/run-DFM1H2jW.d.cts +1589 -0
  38. package/dist/run-DFM1H2jW.d.ts +1589 -0
  39. package/dist/skills.cjs +2 -1
  40. package/dist/skills.cjs.map +1 -1
  41. package/dist/skills.js +2 -1
  42. package/dist/skills.js.map +1 -1
  43. package/dist/workflow.cjs.map +1 -1
  44. package/dist/workflow.js.map +1 -1
  45. package/package.json +13 -12
@@ -0,0 +1,516 @@
1
+ import { Q as RunOperation } from './run-DFM1H2jW.cjs';
2
+
3
+ /**
4
+ * Public type contract for the Budget enforcement primitive
5
+ * (ADRs D375, D382-D387). The runtime facade lives in `budget.ts`.
6
+ *
7
+ * @public
8
+ */
9
+ /**
10
+ * Scope of a budget — where the charge is attributed. v1 supports
11
+ * `process` (shared global) only; `agent` and `call` reserved for
12
+ * v0.2 multi-tenant scenarios.
13
+ */
14
+ type BudgetScope = "agent" | "call" | "process";
15
+ /**
16
+ * Time window for a budget limit (D382 — UTC calendar-aligned).
17
+ * - `1h` is relative (last 60 minutes).
18
+ * - `1d` / `1w` / `30d` / `365d` are aligned to UTC calendar
19
+ * boundaries (UTC midnight / monday 00:00 UTC / 1st 00:00 UTC).
20
+ */
21
+ type BudgetWindow = "1h" | "1d" | "1w" | "30d" | "365d";
22
+ /**
23
+ * Enforcement mode (D383).
24
+ * - `audit`: log only, never throw, never block.
25
+ * - `warn`: callbacks fire at 80/95/100% thresholds; no throw.
26
+ * - `block`: preflightCheck throws `BudgetExceededError` BEFORE LLM call
27
+ * when would-exceed.
28
+ */
29
+ type BudgetMode = "audit" | "warn" | "block";
30
+ /** A single limit; stacked in an array (D384, ANY exceeded blocks). */
31
+ interface BudgetLimit {
32
+ readonly window: BudgetWindow;
33
+ readonly limitUsd: number;
34
+ }
35
+ /** Threshold event emitted at 80% and 95% in `warn` and `block` modes. */
36
+ interface BudgetThresholdEvent {
37
+ readonly budgetName: string;
38
+ readonly window: BudgetWindow;
39
+ readonly threshold: 0.8 | 0.95;
40
+ readonly spentUsd: number;
41
+ readonly limitUsd: number;
42
+ }
43
+ /** Exceed event emitted at 100% across all modes. */
44
+ interface BudgetExceedEvent {
45
+ readonly budgetName: string;
46
+ readonly window: BudgetWindow;
47
+ readonly spentUsd: number;
48
+ readonly limitUsd: number;
49
+ readonly mode: BudgetMode;
50
+ }
51
+ /** Options for `Budget.create`. */
52
+ interface BudgetOptions {
53
+ /**
54
+ * Identifier. Must match grammar `^[a-z0-9][a-z0-9_-]*$` (EC-7);
55
+ * empty/invalid → `ConfigurationError({ code: "invalid_budget_name" })`.
56
+ */
57
+ readonly name: string;
58
+ readonly scope: BudgetScope;
59
+ /**
60
+ * Stacked limits — at least one is expected for `warn`/`block`. Empty
61
+ * array (EC-19) is allowed → registry-only tracking, callbacks never
62
+ * fire.
63
+ */
64
+ readonly limits: ReadonlyArray<BudgetLimit>;
65
+ /** Default `warn` (D383). */
66
+ readonly mode?: BudgetMode;
67
+ /** Fires at 80% and 95% of any limit. Caller throws are isolated (EC-8). */
68
+ readonly onThreshold?: (event: BudgetThresholdEvent) => void | Promise<void>;
69
+ /** Fires at 100%. Caller throws are isolated (EC-8). */
70
+ readonly onExceed?: (event: BudgetExceedEvent) => void | Promise<void>;
71
+ }
72
+ /** Returned by `Budget.create` and `Budget.get` — read-only view. */
73
+ interface BudgetHandle {
74
+ readonly name: string;
75
+ readonly mode: BudgetMode;
76
+ readonly scope: BudgetScope;
77
+ readonly limits: ReadonlyArray<BudgetLimit>;
78
+ /** Snapshot spend for the given window. */
79
+ spentIn(window: BudgetWindow): number;
80
+ /** Remaining USD before the given window's limit is reached. */
81
+ remainingIn(window: BudgetWindow): number;
82
+ }
83
+ /** Per-window snapshot returned by `Budget.snapshot()`. */
84
+ interface BudgetSnapshot {
85
+ readonly name: string;
86
+ readonly window: BudgetWindow;
87
+ readonly spentUsd: number;
88
+ readonly limitUsd: number;
89
+ readonly ratio: number;
90
+ }
91
+
92
+ /**
93
+ * Finite, machine-readable error codes for provider-originated errors
94
+ * (ADR D66). Consumers can `switch (err.metadata?.code)` exhaustively
95
+ * — adding a new variant is an explicit decision + test coverage.
96
+ *
97
+ * @public
98
+ */
99
+ type ErrorCode = "rate_limit" | "auth_failed" | "invalid_request" | "timeout" | "server_error" | "context_too_long" | "content_filtered" | "model_unavailable" | "network" | "quota_exceeded" | "unknown";
100
+ /**
101
+ * Codes used by {@link AgentRunError} (Production-Readiness #3, ADR D311).
102
+ *
103
+ * Superset of {@link ErrorCode} extended with codes that do NOT originate
104
+ * from a provider HTTP response:
105
+ *
106
+ * - `quota_exceeded` — billing limit hit (provider 402 or signalled error)
107
+ * - `tool_runtime_error` — custom tool handler threw inside dispatch
108
+ * - `aborted` — caller's `AbortSignal` fired (Phase 4)
109
+ * - `invalid_model` — model id rejected by provider (400 "model not found")
110
+ * - `safety_blocked` — provider safety filter blocked req or resp
111
+ * - `provider_unreachable` — DNS/TCP/timeout/5xx at transport boundary
112
+ *
113
+ * The `& {}` tail keeps the literal-union ergonomics (autocomplete) while
114
+ * accepting any string for forward compatibility with constructor calls
115
+ * that pass arbitrary code values (legacy callers).
116
+ *
117
+ * @public
118
+ */
119
+ /**
120
+ * T1.1 — closed literal union for `AgentRunError.code`. The previous
121
+ * `(string & {})` escape hatch let arbitrary strings slip into the type
122
+ * surface and defeated exhaustive `switch (code)` discrimination. This is
123
+ * the canonical closed form. `AgentRunErrorCode` is re-aliased below for
124
+ * source-level back-compat.
125
+ *
126
+ * Adding a new code: append the literal here AND audit every `switch (err.code)`
127
+ * in callers. Type-checker enforces the audit via the `default: assertNever(code)`
128
+ * convention.
129
+ *
130
+ * @public
131
+ */
132
+ type KnownAgentRunErrorCode = ErrorCode | "quota_exceeded" | "tool_runtime_error" | "aborted" | "invalid_model" | "safety_blocked" | "provider_unreachable";
133
+ /**
134
+ * Back-compat alias of {@link KnownAgentRunErrorCode}. Pre-T1.1 callers that
135
+ * imported `AgentRunErrorCode` keep working; new code SHOULD prefer
136
+ * `KnownAgentRunErrorCode` to make the closed-union intent explicit.
137
+ *
138
+ * @public
139
+ */
140
+ type AgentRunErrorCode = KnownAgentRunErrorCode;
141
+ /**
142
+ * Structured context for errors that originated from a provider HTTP
143
+ * call (ADR D65). Lets callers retry with the right backoff (`retryAfter`),
144
+ * surface actionable diagnostics (`provider`, `endpoint`), and inspect the
145
+ * raw response body when needed (`raw`, capped at ~2KB by the mapper).
146
+ *
147
+ * @public
148
+ */
149
+ interface ErrorMetadata {
150
+ /** Provider canonical name (e.g., `"anthropic"`, `"openai"`, `"openrouter"`, `"gemini"`). */
151
+ provider: string;
152
+ /** HTTP endpoint that failed (e.g., `"/v1/messages"`, `"/v1/chat/completions"`). */
153
+ endpoint: string;
154
+ /** Machine-readable error code (finite enum). */
155
+ code: ErrorCode;
156
+ /** HTTP status code if applicable. */
157
+ statusCode?: number;
158
+ /** Seconds to wait before retry, per provider's `retry-after` header (numeric form only). */
159
+ retryAfter?: number;
160
+ /** Raw response body for debugging (truncated to ~2KB by the mapper). */
161
+ raw?: unknown;
162
+ }
163
+ /**
164
+ * Base class for all errors thrown by `@theokit/sdk`.
165
+ *
166
+ * Use `isRetryable` to drive retry/backoff logic. `code` and `protoErrorCode`
167
+ * are populated for server-originated errors when available. `metadata`
168
+ * (ADR D65) carries structured `{ provider, endpoint, code, ... }` when
169
+ * the error originated from a provider HTTP call.
170
+ *
171
+ * @public
172
+ */
173
+ declare class TheokitAgentError extends Error {
174
+ readonly name: string;
175
+ readonly isRetryable: boolean;
176
+ readonly code?: string;
177
+ readonly protoErrorCode?: string;
178
+ readonly metadata?: ErrorMetadata;
179
+ constructor(message: string, options?: {
180
+ isRetryable?: boolean;
181
+ code?: string;
182
+ protoErrorCode?: string;
183
+ cause?: unknown;
184
+ metadata?: ErrorMetadata;
185
+ });
186
+ }
187
+ /**
188
+ * Invalid API key, not logged in, insufficient permissions.
189
+ *
190
+ * @public
191
+ */
192
+ declare class AuthenticationError extends TheokitAgentError {
193
+ readonly name: string;
194
+ constructor(message: string, options?: {
195
+ code?: string;
196
+ cause?: unknown;
197
+ metadata?: ErrorMetadata;
198
+ });
199
+ }
200
+ /**
201
+ * Too many requests or usage limits exceeded.
202
+ *
203
+ * @public
204
+ */
205
+ declare class RateLimitError extends TheokitAgentError {
206
+ readonly name: string;
207
+ constructor(message: string, options?: {
208
+ code?: string;
209
+ cause?: unknown;
210
+ metadata?: ErrorMetadata;
211
+ });
212
+ }
213
+ /**
214
+ * Invalid model, bad request parameters, malformed options.
215
+ *
216
+ * @public
217
+ */
218
+ declare class ConfigurationError extends TheokitAgentError {
219
+ readonly name: string;
220
+ constructor(message: string, options?: {
221
+ code?: string;
222
+ cause?: unknown;
223
+ metadata?: ErrorMetadata;
224
+ });
225
+ }
226
+ /**
227
+ * Thrown when creating a cloud agent for a repo whose SCM provider is not
228
+ * connected. Use `helpUrl` to point the user at the right reconnect flow.
229
+ *
230
+ * @public
231
+ */
232
+ declare class IntegrationNotConnectedError extends ConfigurationError {
233
+ readonly name: string;
234
+ readonly provider: string;
235
+ readonly helpUrl: string;
236
+ constructor(message: string, options: {
237
+ provider: string;
238
+ helpUrl: string;
239
+ code?: string;
240
+ cause?: unknown;
241
+ metadata?: ErrorMetadata;
242
+ });
243
+ }
244
+ /**
245
+ * Service unavailable, timeout, transport-level failure.
246
+ *
247
+ * @public
248
+ */
249
+ declare class NetworkError extends TheokitAgentError {
250
+ readonly name: string;
251
+ constructor(message: string, options?: {
252
+ code?: string;
253
+ cause?: unknown;
254
+ metadata?: ErrorMetadata;
255
+ });
256
+ }
257
+ /**
258
+ * Catch-all for unclassified server or runtime errors.
259
+ *
260
+ * @public
261
+ */
262
+ declare class UnknownAgentError extends TheokitAgentError {
263
+ readonly name: string;
264
+ constructor(message: string, options?: {
265
+ code?: string;
266
+ cause?: unknown;
267
+ metadata?: ErrorMetadata;
268
+ });
269
+ }
270
+ /**
271
+ * Thrown by `Agent.prompt` (and helpers that go through `run.wait()`) when
272
+ * the option `{ throwOnError: true }` is set and the run terminates with
273
+ * `status: 'error'`. Carries the structured `RunResult.error` fields so
274
+ * callers can `catch` once and branch on `code` / `provider` instead of
275
+ * unwrapping the run.
276
+ *
277
+ * Extends {@link TheokitAgentError} per ADR D65 — no new hierarchy.
278
+ *
279
+ * @example
280
+ * try {
281
+ * await Agent.prompt(msg, { apiKey, model, throwOnError: true });
282
+ * } catch (err) {
283
+ * if (err instanceof AgentRunError && err.code === 'auth_failed') {
284
+ * // bad key
285
+ * }
286
+ * }
287
+ *
288
+ * @public
289
+ */
290
+ declare class AgentRunError extends TheokitAgentError {
291
+ readonly name: string;
292
+ readonly provider?: string;
293
+ readonly raw?: string;
294
+ /** Provider's request id (`x-request-id` / `request-id` header). Useful for support tickets. */
295
+ readonly requestId?: string;
296
+ /** SDK conversation id this error was raised inside. */
297
+ readonly conversationId?: string;
298
+ constructor(message: string, options: {
299
+ code: AgentRunErrorCode;
300
+ provider?: string;
301
+ raw?: string;
302
+ requestId?: string;
303
+ conversationId?: string;
304
+ retriable?: boolean;
305
+ cause?: unknown;
306
+ metadata?: ErrorMetadata;
307
+ });
308
+ /**
309
+ * Production-Readiness #3 (ADR D311): alias for `isRetryable` exposed as
310
+ * `retriable` to match the handoff contract. Future v2 will deprecate
311
+ * `isRetryable` in favor of this.
312
+ */
313
+ get retriable(): boolean;
314
+ /**
315
+ * D312: provider's `Retry-After` header in **milliseconds**. Mappers store
316
+ * the header value (seconds) in `metadata.retryAfter`; this getter
317
+ * multiplies by 1000 so the result composes with `Date.now()`/`setTimeout`.
318
+ *
319
+ * Returns `undefined` when no hint was provided. `0` is a legitimate value
320
+ * — use `=== undefined` check rather than truthy check.
321
+ */
322
+ get retryAfterMs(): number | undefined;
323
+ /**
324
+ * D313 + T1.5: alias for `metadata.raw`. Provider response body for
325
+ * debugging. T1.5 wraps the value in `redactSecrets` at the getter
326
+ * boundary so secret-shaped substrings (`sk-...`, Bearer JWTs, etc.) are
327
+ * stripped before reaching the caller. Available but NEVER serialized
328
+ * into `.message` (anti-leak invariant).
329
+ */
330
+ get providerError(): unknown;
331
+ /**
332
+ * T1.5 — sanitized JSON form. `metadata.raw` is OMITTED by default; opt
333
+ * in via `THEOKIT_DEBUG_RAW_ERRORS=1` to surface the (redacted) raw
334
+ * payload for diagnostics. Every other field stays accessible.
335
+ *
336
+ * The single env-var gate is read each call so operators can toggle at
337
+ * runtime without restarting the process.
338
+ */
339
+ toJSON(): Record<string, unknown>;
340
+ }
341
+ /**
342
+ * Is this error transient (worth retrying)?
343
+ *
344
+ * Returns the SDK's own retryability verdict: every {@link TheokitAgentError}
345
+ * subclass computes `isRetryable` at construction (rate-limit / network /
346
+ * credential-pool-exhausted are retryable; auth / configuration / unsupported
347
+ * are not), so this predicate is a single source of truth rather than a
348
+ * re-derivation. Non-SDK errors return `false` conservatively — wrap a foreign
349
+ * error in the appropriate SDK error first if you want it considered transient.
350
+ * It never inspects `err.message`.
351
+ *
352
+ * @example
353
+ * try {
354
+ * await agent.send(message, { throwOnError: true });
355
+ * } catch (err) {
356
+ * if (isTransientError(err)) return retryWithBackoff();
357
+ * throw err;
358
+ * }
359
+ *
360
+ * @public
361
+ */
362
+ declare function isTransientError(err: unknown): boolean;
363
+ /**
364
+ * Thrown when a {@link Run} or agent operation is not available on the current
365
+ * runtime. Check first with `run.supports(operation)`.
366
+ *
367
+ * Extends {@link TheokitAgentError} (so error-catching code that branches on
368
+ * `instanceof TheokitAgentError` continues to work) but is never retryable —
369
+ * an unsupported operation will not become supported on retry.
370
+ *
371
+ * @public
372
+ */
373
+ declare class UnsupportedRunOperationError extends TheokitAgentError {
374
+ readonly name: string;
375
+ readonly operation: RunOperation;
376
+ constructor(message: string, operation: RunOperation, options?: {
377
+ code?: string;
378
+ cause?: unknown;
379
+ });
380
+ }
381
+ /**
382
+ * Thrown when every credential in a per-provider pool is in cooldown
383
+ * and no healthy key is available (ADR D133). The caller's
384
+ * {@link import("./internal/llm/fallback-client.js").FallbackLlmClient}
385
+ * catches this and tries the next provider in the fallback chain.
386
+ *
387
+ * `metadata.nextRetryAt` (epoch ms) tells callers when the soonest
388
+ * pool entry resumes — useful for manual retry scheduling.
389
+ *
390
+ * @public
391
+ */
392
+ declare class CredentialPoolExhaustedError extends TheokitAgentError {
393
+ readonly name: string;
394
+ readonly provider: string;
395
+ readonly nextRetryAt: number | undefined;
396
+ constructor(message: string, options: {
397
+ provider: string;
398
+ nextRetryAt?: number;
399
+ code?: string;
400
+ cause?: unknown;
401
+ metadata?: ErrorMetadata;
402
+ });
403
+ }
404
+ /**
405
+ * Finite error codes specific to memory adapter operations (ADR D141).
406
+ *
407
+ * @public
408
+ */
409
+ type MemoryAdapterErrorCode = "auth_failed" | "rate_limited" | "not_found" | "network" | "invalid_input" | "unknown";
410
+ /**
411
+ * Error raised by `@theokit-memory-*` adapters. Carries `adapterId`
412
+ * so callers can branch on which provider failed (ADR D141).
413
+ *
414
+ * @public
415
+ */
416
+ declare class MemoryAdapterError extends TheokitAgentError {
417
+ readonly name: string;
418
+ readonly adapterId: string;
419
+ constructor(message: string, options: {
420
+ adapterId: string;
421
+ code: MemoryAdapterErrorCode;
422
+ cause?: unknown;
423
+ metadata?: ErrorMetadata;
424
+ });
425
+ }
426
+ /**
427
+ * Thrown when a user-supplied task ID violates the grammar
428
+ * `^[a-z0-9][a-z0-9_-]*$` (D368) OR starts with a reserved adapter
429
+ * prefix (`wf-` / `b-` / `cron-`, EC-5).
430
+ *
431
+ * @public
432
+ */
433
+ declare class InvalidTaskIdError extends TheokitAgentError {
434
+ readonly name: string;
435
+ readonly taskId: string;
436
+ constructor(message: string, taskId: string, options?: {
437
+ cause?: unknown;
438
+ });
439
+ }
440
+ /**
441
+ * Thrown when `Task.subscribe(id)` is called for a task that has been
442
+ * evicted, never submitted, or evicted after retention (D373).
443
+ *
444
+ * @public
445
+ */
446
+ declare class TaskNotFoundError extends TheokitAgentError {
447
+ readonly name: string;
448
+ readonly taskId: string;
449
+ constructor(taskId: string, options?: {
450
+ cause?: unknown;
451
+ });
452
+ }
453
+ /**
454
+ * Thrown when `CloudAgent` is asked to wrap a task (D370). Cloud
455
+ * task observability is deferred until Theo PaaS GA.
456
+ *
457
+ * @public
458
+ */
459
+ declare class UnsupportedTaskOperationError extends TheokitAgentError {
460
+ readonly name: string;
461
+ readonly operation: string;
462
+ constructor(operation: string, options?: {
463
+ cause?: unknown;
464
+ });
465
+ }
466
+ /**
467
+ * Thrown by `Budget` enforcement (ADR D386) when a `mode: "block"`
468
+ * budget would be exceeded by the upcoming LLM call. Caller pega
469
+ * tipado para retry-after-window-reset or surface to the user.
470
+ *
471
+ * @public
472
+ */
473
+ declare class BudgetExceededError extends TheokitAgentError {
474
+ readonly name: string;
475
+ readonly budgetName: string;
476
+ readonly window: BudgetWindow;
477
+ readonly spentUsd: number;
478
+ readonly limitUsd: number;
479
+ readonly mode: BudgetMode;
480
+ constructor(args: {
481
+ budgetName: string;
482
+ window: BudgetWindow;
483
+ spentUsd: number;
484
+ limitUsd: number;
485
+ mode: BudgetMode;
486
+ cause?: unknown;
487
+ });
488
+ }
489
+ /**
490
+ * Thrown when `CloudAgent.send({ budget })` is invoked (D388). Cloud
491
+ * budget surface waits for Theo PaaS GA.
492
+ *
493
+ * @public
494
+ */
495
+ /**
496
+ * T1.6 — Thrown when a consumer calls `agent.send()` or any method
497
+ * on an agent that has already been `dispose()`d. Pre-T1.6 this was
498
+ * a generic `new Error("Agent has been disposed")` — consumers
499
+ * couldn't catch it without string-matching the message.
500
+ *
501
+ * @public
502
+ */
503
+ declare class AgentDisposedError extends TheokitAgentError {
504
+ readonly name: string;
505
+ readonly agentId: string;
506
+ constructor(agentId: string);
507
+ }
508
+ declare class UnsupportedBudgetOperationError extends TheokitAgentError {
509
+ readonly name: string;
510
+ readonly operation: string;
511
+ constructor(operation: string, options?: {
512
+ cause?: unknown;
513
+ });
514
+ }
515
+
516
+ export { AgentDisposedError as A, type BudgetOptions as B, ConfigurationError as C, type ErrorMetadata as E, IntegrationNotConnectedError as I, type KnownAgentRunErrorCode as K, MemoryAdapterError as M, NetworkError as N, RateLimitError as R, TheokitAgentError as T, UnknownAgentError as U, type BudgetHandle as a, type BudgetSnapshot as b, AgentRunError as c, type AgentRunErrorCode as d, AuthenticationError as e, type BudgetExceedEvent as f, BudgetExceededError as g, type BudgetLimit as h, type BudgetMode as i, type BudgetScope as j, type BudgetThresholdEvent as k, type BudgetWindow as l, type ErrorCode as m, InvalidTaskIdError as n, type MemoryAdapterErrorCode as o, TaskNotFoundError as p, UnsupportedBudgetOperationError as q, UnsupportedRunOperationError as r, UnsupportedTaskOperationError as s, isTransientError as t, CredentialPoolExhaustedError as u };
@@ -0,0 +1,3 @@
1
+ export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, g as BudgetExceededError, C as ConfigurationError, u as CredentialPoolExhaustedError, m as ErrorCode, E as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, K as KnownAgentRunErrorCode, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, T as TheokitAgentError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-gE8612p9.cjs';
2
+ import './run-DFM1H2jW.cjs';
3
+ import 'zod';
package/dist/eval.cjs CHANGED
@@ -860,7 +860,8 @@ function safePathJoin(base, ...parts) {
860
860
  }
861
861
  const baseResolved = path.resolve(base);
862
862
  const target = path.resolve(base, ...parts);
863
- if (target !== baseResolved && !target.startsWith(baseResolved + path.sep)) {
863
+ const prefix = baseResolved.endsWith(path.sep) ? baseResolved : baseResolved + path.sep;
864
+ if (target !== baseResolved && !target.startsWith(prefix)) {
864
865
  throw new PathTraversalError(parts.join("/"), target);
865
866
  }
866
867
  return target;
@@ -6005,7 +6006,9 @@ function isCompactSummary(content) {
6005
6006
  function plainText(content) {
6006
6007
  if (typeof content === "string") return content;
6007
6008
  if (!Array.isArray(content)) return void 0;
6008
- const texts = content.filter((p) => p !== null && typeof p === "object" && p.type === "text" && typeof p.text === "string").map((p) => p.text);
6009
+ const texts = content.filter(
6010
+ (p) => p !== null && typeof p === "object" && p.type === "text" && typeof p.text === "string"
6011
+ ).map((p) => p.text);
6009
6012
  return texts.length > 0 ? texts.join("\n") : void 0;
6010
6013
  }
6011
6014
  async function compactSessionTranscript(opts) {
@@ -6126,8 +6129,10 @@ async function autoCompactIfNeeded(opts) {
6126
6129
  return true;
6127
6130
  } catch (cause) {
6128
6131
  const msg = cause instanceof Error ? cause.message : String(cause);
6129
- process.stderr.write(`[theokit-sdk] auto-compaction failed (left transcript untouched): ${msg}
6130
- `);
6132
+ process.stderr.write(
6133
+ `[theokit-sdk] auto-compaction failed (left transcript untouched): ${msg}
6134
+ `
6135
+ );
6131
6136
  return false;
6132
6137
  }
6133
6138
  }
@@ -6137,11 +6142,11 @@ var init_compact_session = __esm({
6137
6142
  init_compaction();
6138
6143
  init_router();
6139
6144
  init_real_local_run_provider();
6145
+ init_session_transcript();
6140
6146
  init_providers();
6141
6147
  init_compression_model_registry();
6142
6148
  init_compression_summarizer();
6143
6149
  init_agent_session();
6144
- init_session_transcript();
6145
6150
  COMPACT_SUMMARY_MARKER = "[[theokit:compact-summary]]";
6146
6151
  COMPACT_USER_MESSAGE_MAX_TOKENS = 2e4;
6147
6152
  autoCompactAttempts = (() => {
@@ -6246,10 +6251,17 @@ var init_context = __esm({
6246
6251
  }
6247
6252
  });
6248
6253
 
6254
+ // src/goal-loop.ts
6255
+ var GOAL_CONTINUATION_MARKER;
6256
+ var init_goal_loop = __esm({
6257
+ "src/goal-loop.ts"() {
6258
+ GOAL_CONTINUATION_MARKER = "[[theokit:goal-continuation]]";
6259
+ }
6260
+ });
6261
+
6249
6262
  // src/internal/runtime/lifecycle/run-until.ts
6250
6263
  var run_until_exports = {};
6251
6264
  __export(run_until_exports, {
6252
- GOAL_CONTINUATION_MARKER: () => GOAL_CONTINUATION_MARKER,
6253
6265
  composeContinuation: () => composeContinuation,
6254
6266
  runUntilImpl: () => runUntilImpl
6255
6267
  });
@@ -6414,10 +6426,9 @@ ${goal}
6414
6426
  ${lastResponse.slice(-1e3)}`
6415
6427
  ].join("\n");
6416
6428
  }
6417
- var GOAL_CONTINUATION_MARKER;
6418
6429
  var init_run_until = __esm({
6419
6430
  "src/internal/runtime/lifecycle/run-until.ts"() {
6420
- GOAL_CONTINUATION_MARKER = "[[theokit:goal-continuation]]";
6431
+ init_goal_loop();
6421
6432
  }
6422
6433
  });
6423
6434