@theokit/sdk 4.27.0 → 4.29.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 (99) hide show
  1. package/dist/{cron-DPUZzncH.d.ts → agent-BZz4X8ZM.d.ts} +10 -577
  2. package/dist/{cron-DzZ9TMa2.d.cts → agent-CdjSCbYz.d.cts} +10 -577
  3. package/dist/agent-FBTLZI6V.js +41 -0
  4. package/dist/agent-FBTLZI6V.js.map +1 -0
  5. package/dist/agent-LBCEK6VH.cjs +50 -0
  6. package/dist/agent-LBCEK6VH.cjs.map +1 -0
  7. package/dist/{chunk-WBBYSW3Q.cjs → chunk-54YLX4Q6.cjs} +5 -5
  8. package/dist/{chunk-WBBYSW3Q.cjs.map → chunk-54YLX4Q6.cjs.map} +1 -1
  9. package/dist/{chunk-AKSBP7OO.js → chunk-5IB2UKSN.js} +5 -41
  10. package/dist/chunk-5IB2UKSN.js.map +1 -0
  11. package/dist/chunk-BNIFFFH3.js +129 -0
  12. package/dist/chunk-BNIFFFH3.js.map +1 -0
  13. package/dist/{chunk-LSLPF6OI.cjs → chunk-DHLZIMP6.cjs} +5 -43
  14. package/dist/chunk-DHLZIMP6.cjs.map +1 -0
  15. package/dist/{chunk-OX772BEW.js → chunk-EULKRTB5.js} +3 -3
  16. package/dist/{chunk-OX772BEW.js.map → chunk-EULKRTB5.js.map} +1 -1
  17. package/dist/chunk-FKCC2MED.js +43 -0
  18. package/dist/chunk-FKCC2MED.js.map +1 -0
  19. package/dist/{chunk-QUTUJ6P6.cjs → chunk-HK7ZHSAX.cjs} +25 -16
  20. package/dist/chunk-HK7ZHSAX.cjs.map +1 -0
  21. package/dist/{chunk-MQLCZ4HJ.cjs → chunk-JLMXKTBX.cjs} +4 -4
  22. package/dist/{chunk-MQLCZ4HJ.cjs.map → chunk-JLMXKTBX.cjs.map} +1 -1
  23. package/dist/chunk-LALRCFSN.cjs +46 -0
  24. package/dist/chunk-LALRCFSN.cjs.map +1 -0
  25. package/dist/{chunk-DUK5WMKJ.js → chunk-R6ZP6KNB.js} +25 -16
  26. package/dist/chunk-R6ZP6KNB.js.map +1 -0
  27. package/dist/chunk-RZQ6E5YZ.cjs +131 -0
  28. package/dist/chunk-RZQ6E5YZ.cjs.map +1 -0
  29. package/dist/{chunk-6M76Z3AI.js → chunk-VUJ3NVDC.js} +692 -808
  30. package/dist/chunk-VUJ3NVDC.js.map +1 -0
  31. package/dist/{chunk-G6GO6BXD.js → chunk-XAUBQMQU.js} +3 -3
  32. package/dist/{chunk-G6GO6BXD.js.map → chunk-XAUBQMQU.js.map} +1 -1
  33. package/dist/{chunk-TMNS2LOS.cjs → chunk-YQAPEYUV.cjs} +715 -831
  34. package/dist/chunk-YQAPEYUV.cjs.map +1 -0
  35. package/dist/compact-session-OO2GD76G.js +1 -1
  36. package/dist/compact-session-OO7NVWPB.cjs +1 -1
  37. package/dist/cron-CIIshMs3.d.cts +579 -0
  38. package/dist/cron-dElBjDaL.d.ts +579 -0
  39. package/dist/cron.cjs +13 -11
  40. package/dist/cron.d.cts +2 -1
  41. package/dist/cron.d.ts +2 -1
  42. package/dist/cron.js +12 -10
  43. package/dist/errors.d.ts +3 -424
  44. package/dist/eval.cjs +17 -15
  45. package/dist/eval.cjs.map +1 -1
  46. package/dist/eval.js +13 -11
  47. package/dist/eval.js.map +1 -1
  48. package/dist/{index-manager-CB6I7XFQ.cjs → index-manager-H7HUMW52.cjs} +5 -5
  49. package/dist/{index-manager-CB6I7XFQ.cjs.map → index-manager-H7HUMW52.cjs.map} +1 -1
  50. package/dist/{index-manager-L27Q3QAC.js → index-manager-P7ZUX2RG.js} +4 -4
  51. package/dist/{index-manager-L27Q3QAC.js.map → index-manager-P7ZUX2RG.js.map} +1 -1
  52. package/dist/index.cjs +66 -45
  53. package/dist/index.cjs.map +1 -1
  54. package/dist/index.d.cts +18 -4
  55. package/dist/index.d.ts +18 -4
  56. package/dist/index.js +42 -21
  57. package/dist/index.js.map +1 -1
  58. package/dist/internal/persistence/index.cjs +10 -10
  59. package/dist/internal/persistence/index.js +2 -2
  60. package/dist/internal/persistence/jsonl.d.cts +7 -0
  61. package/dist/internal/persistence/jsonl.d.ts +7 -0
  62. package/dist/internal/persistence/session-writer.d.cts +56 -0
  63. package/dist/internal/persistence/session-writer.d.ts +56 -0
  64. package/dist/internal/persistence/transcript-ops.d.cts +71 -0
  65. package/dist/internal/persistence/transcript-ops.d.ts +71 -0
  66. package/dist/persistence.cjs +115 -12
  67. package/dist/persistence.cjs.map +1 -1
  68. package/dist/persistence.d.cts +2 -0
  69. package/dist/persistence.d.ts +2 -0
  70. package/dist/persistence.js +105 -3
  71. package/dist/persistence.js.map +1 -1
  72. package/dist/{run-until-K7IO7ZPQ.js → run-until-YZ2ODWOF.js} +3 -2
  73. package/dist/run-until-YZ2ODWOF.js.map +1 -0
  74. package/dist/{run-until-ZD4PRLNJ.cjs → run-until-ZZ2JLPJM.cjs} +3 -2
  75. package/dist/run-until-ZZ2JLPJM.cjs.map +1 -0
  76. package/dist/server/auth/index.d.cts +207 -11
  77. package/dist/server/auth/index.d.ts +207 -11
  78. package/dist/server/errors-envelope.d.cts +12 -6
  79. package/dist/server/errors-envelope.d.ts +12 -6
  80. package/dist/skills.cjs +4 -3
  81. package/dist/skills.js +2 -1
  82. package/dist/subagents-loader.cjs +19 -0
  83. package/dist/subagents-loader.cjs.map +1 -0
  84. package/dist/subagents-loader.d.cts +39 -0
  85. package/dist/subagents-loader.d.ts +39 -0
  86. package/dist/subagents-loader.js +16 -0
  87. package/dist/subagents-loader.js.map +1 -0
  88. package/dist/types/goal-events.d.ts +8 -0
  89. package/dist/workflow.cjs +1 -1
  90. package/dist/workflow.js +1 -1
  91. package/package.json +12 -2
  92. package/dist/chunk-6M76Z3AI.js.map +0 -1
  93. package/dist/chunk-AKSBP7OO.js.map +0 -1
  94. package/dist/chunk-DUK5WMKJ.js.map +0 -1
  95. package/dist/chunk-LSLPF6OI.cjs.map +0 -1
  96. package/dist/chunk-QUTUJ6P6.cjs.map +0 -1
  97. package/dist/chunk-TMNS2LOS.cjs.map +0 -1
  98. package/dist/run-until-K7IO7ZPQ.js.map +0 -1
  99. package/dist/run-until-ZD4PRLNJ.cjs.map +0 -1
@@ -1,6 +1,5 @@
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-OJbGyweZ.cjs';
1
2
  import * as zod from 'zod';
2
- import { ZodType } from 'zod';
3
- 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, u as MessageOrigin } from './run-OJbGyweZ.cjs';
4
3
 
5
4
  /**
6
5
  * `SessionRecord` — the native on-disk transcript record shape (SE40).
@@ -674,6 +673,14 @@ interface GoalOptions {
674
673
  judgeModel?: string;
675
674
  /** Override env for the judge auxiliary agent. Default `OPENROUTER_API_KEY` (EC-A). */
676
675
  judgeApiKey?: string;
676
+ /**
677
+ * M80 — o modelo do agente CONDUZIDO, base da derivação do judge quando `judgeModel` é omitido.
678
+ *
679
+ * Existe porque o default fixo (`openai/gpt-4o-mini`) só resolve em OpenRouter: com chave
680
+ * Anthropic dá 404, com bearer OAuth dá 401, e o goal queimava 3 turnos antes de falhar com razão
681
+ * enganosa. Um judge que roda no mesmo modelo do chat funciona onde o chat funciona.
682
+ */
683
+ agentModel?: string;
677
684
  /** Optional subgoals fed to the judge prompt. */
678
685
  subgoals?: string[];
679
686
  /**
@@ -2052,578 +2059,4 @@ interface ListResult<T> {
2052
2059
  nextCursor?: string;
2053
2060
  }
2054
2061
 
2055
- /**
2056
- * Public type contract for `Workflow.create / .run / .resume` (Adoption
2057
- * Roadmap #5; ADRs D230-D248).
2058
- *
2059
- * Step types form a discriminated union by `kind`. Helper factory functions
2060
- * (`fn()`, `agentStep()`) live in `workflow.ts` and hide the discriminator
2061
- * from end users.
2062
- *
2063
- * @public
2064
- */
2065
-
2066
- type Step = FnStep | AgentStep | ParallelStep | BranchStep | ForeachStep | DowhileStep | SleepStep | SuspendStep;
2067
- /** A pure function step. */
2068
- interface FnStep {
2069
- readonly kind: "fn";
2070
- readonly id: string;
2071
- readonly fn: (input: unknown, ctx: StepContext) => Promise<unknown> | unknown;
2072
- readonly inputSchema?: ZodType;
2073
- readonly outputSchema?: ZodType;
2074
- readonly retry?: RetryPolicy;
2075
- /** D238 — slot reserved; runtime throws if engine not yet implemented. */
2076
- readonly compensate?: (input: unknown, output: unknown, error: Error) => Promise<void> | void;
2077
- }
2078
- /** An agent.send-driven step. */
2079
- interface AgentStep {
2080
- readonly kind: "agent";
2081
- readonly id: string;
2082
- readonly agent: SDKAgent;
2083
- readonly promptTemplate: string | ((input: unknown) => string);
2084
- readonly retry?: RetryPolicy;
2085
- /**
2086
- * SE3 — provenance stamped onto this step's `agent.send()` (forwarded to
2087
- * `RunResult.origin`). Squad sets `{ kind: "peer", from: "agent-<i-1>" }` on
2088
- * every step after the first so a peer-driven turn is attributable.
2089
- */
2090
- readonly origin?: MessageOrigin;
2091
- }
2092
- /** N concurrent branches, each its own mini-step-list. */
2093
- interface ParallelStep {
2094
- readonly kind: "parallel";
2095
- readonly id: string;
2096
- readonly branches: ReadonlyArray<ReadonlyArray<Step>>;
2097
- readonly concurrency?: number;
2098
- readonly errorPolicy?: "fail-fast" | "collect";
2099
- }
2100
- /** First-match-wins predicates + optional fallback. */
2101
- interface BranchStep {
2102
- readonly kind: "branch";
2103
- readonly id: string;
2104
- readonly predicates: ReadonlyArray<readonly [(input: unknown) => boolean | Promise<boolean>, ReadonlyArray<Step>]>;
2105
- readonly fallback?: ReadonlyArray<Step>;
2106
- }
2107
- /** Map a step over an upstream array output. */
2108
- interface ForeachStep {
2109
- readonly kind: "foreach";
2110
- readonly id: string;
2111
- /** ID of an upstream top-level step whose output is iterable. */
2112
- readonly iterableFrom: string;
2113
- readonly step: Step;
2114
- readonly concurrency?: number;
2115
- }
2116
- /** Loop a step until condFn returns false. */
2117
- interface DowhileStep {
2118
- readonly kind: "dowhile";
2119
- readonly id: string;
2120
- readonly step: Step;
2121
- readonly condFn: (output: unknown, iteration: number) => boolean | Promise<boolean>;
2122
- readonly maxIterations?: number;
2123
- }
2124
- /** Pause for a fixed duration. */
2125
- interface SleepStep {
2126
- readonly kind: "sleep";
2127
- readonly id: string;
2128
- readonly durationMs: number;
2129
- }
2130
- /** Standalone explicit suspend point. */
2131
- interface SuspendStep {
2132
- readonly kind: "suspend";
2133
- readonly id: string;
2134
- readonly payloadSchema?: ZodType;
2135
- }
2136
- /** D237 — retry policy applied per fn/agent step. */
2137
- interface RetryPolicy {
2138
- /** Total attempts (MIN 1, MAX 20). `1` = no retry. */
2139
- readonly maxAttempts: number;
2140
- readonly initialBackoffMs?: number;
2141
- readonly backoffCoefficient?: number;
2142
- readonly maximumBackoffMs?: number;
2143
- readonly nonRetryableErrors?: ReadonlyArray<string>;
2144
- }
2145
- /** D247 — context handed to every step.fn. */
2146
- interface StepContext {
2147
- readonly runId: string;
2148
- readonly signal: AbortSignal;
2149
- readonly log: {
2150
- debug: (msg: string, attrs?: Record<string, unknown>) => void;
2151
- info: (msg: string, attrs?: Record<string, unknown>) => void;
2152
- warn: (msg: string, attrs?: Record<string, unknown>) => void;
2153
- };
2154
- /** Pause the workflow; resume via `Workflow.resume({...})`. */
2155
- readonly suspend: (payload?: unknown) => Promise<never>;
2156
- /**
2157
- * SE29 — the workflow's shared state (from `WorkflowOptions.initialState`,
2158
- * mutated by {@link setState}), visible to every subsequent step in the run.
2159
- * `undefined` when no `initialState`/`setState` has run. Persisted across
2160
- * suspend/resume.
2161
- */
2162
- readonly state: unknown;
2163
- /**
2164
- * SE29 — update the shared state for subsequent steps. Validated against
2165
- * `WorkflowOptions.stateSchema` when set (a mismatch throws
2166
- * {@link WorkflowStateError}, which fails the step/run — Rule 8).
2167
- */
2168
- readonly setState: (next: unknown) => void;
2169
- }
2170
- interface StepResult {
2171
- readonly stepId: string;
2172
- readonly kind: Step["kind"];
2173
- readonly status: "completed" | "failed" | "skipped" | "suspended";
2174
- readonly attempts: number;
2175
- readonly durationMs: number;
2176
- readonly output?: unknown;
2177
- readonly error?: {
2178
- name: string;
2179
- message: string;
2180
- };
2181
- }
2182
- interface WorkflowRun<TOutput = unknown> {
2183
- readonly id: string;
2184
- readonly name: string;
2185
- readonly status: "running" | "completed" | "failed" | "suspended" | "cancelled";
2186
- readonly output?: TOutput;
2187
- readonly error?: {
2188
- name: string;
2189
- message: string;
2190
- };
2191
- readonly startedAt: number;
2192
- readonly endedAt?: number;
2193
- readonly stepResults: ReadonlyArray<StepResult>;
2194
- }
2195
- /**
2196
- * SE28 — a step-level workflow event emitted by `Workflow.stream()` as top-level
2197
- * steps run. Coarse-grained (one event per top-level step; nested
2198
- * parallel/branch/foreach emit as their single wrapping step), distinct from the
2199
- * token-delta agent stream. Discriminate on `type`.
2200
- *
2201
- * @public
2202
- */
2203
- type WorkflowEvent = {
2204
- readonly type: "step_started";
2205
- readonly stepId: string;
2206
- } | {
2207
- readonly type: "step_completed";
2208
- readonly stepId: string;
2209
- readonly output: unknown;
2210
- } | {
2211
- readonly type: "step_failed";
2212
- readonly stepId: string;
2213
- readonly error: {
2214
- readonly name: string;
2215
- readonly message: string;
2216
- };
2217
- } | {
2218
- readonly type: "workflow_suspended";
2219
- readonly stepId: string;
2220
- } | {
2221
- readonly type: "workflow_completed";
2222
- };
2223
- /**
2224
- * SE28 — the async iterator returned by `Workflow.stream()`. Yields
2225
- * {@link WorkflowEvent}s in execution order; `result` resolves to the same
2226
- * terminal {@link WorkflowRun} the `run()` path returns (the authoritative
2227
- * outcome — the stream ends when the run terminates).
2228
- *
2229
- * @public
2230
- */
2231
- type WorkflowStream<TOutput = unknown> = AsyncIterableIterator<WorkflowEvent> & {
2232
- readonly result: Promise<WorkflowRun<TOutput>>;
2233
- };
2234
- interface WorkflowPersistenceOptions {
2235
- readonly backend: "memory" | "json";
2236
- /** Required for `backend: "json"`. */
2237
- readonly dir?: string;
2238
- }
2239
- interface WorkflowOptions {
2240
- readonly name: string;
2241
- readonly persistence?: WorkflowPersistenceOptions;
2242
- /**
2243
- * SE27 — Zod schema for the WHOLE workflow's input. When set, `run(input)`
2244
- * validates `input` BEFORE step 1; a mismatch yields `status: "failed"` with a
2245
- * typed {@link WorkflowInputError} in `error` (fail-fast, no step runs, no
2246
- * silent coerce). Absent ⇒ no whole-workflow input validation (unchanged).
2247
- */
2248
- readonly inputSchema?: ZodType;
2249
- /**
2250
- * SE27 — Zod schema for the workflow's final output. When set, the terminal
2251
- * `completed` output is validated before `WorkflowRun.output` is populated; a
2252
- * mismatch yields `status: "failed"` with a typed {@link WorkflowOutputError}.
2253
- * Only validated on the `completed` path (suspended/failed runs skip it).
2254
- */
2255
- readonly outputSchema?: ZodType;
2256
- /**
2257
- * SE29 — Zod schema for the workflow's shared state (see `StepContext.state` /
2258
- * `setState`). When set, `initialState` and every `setState(next)` are
2259
- * validated against it (a mismatch throws {@link WorkflowStateError}). When
2260
- * `initialState` is absent, `state` starts as `undefined` and validation fires
2261
- * on the first `setState` call.
2262
- */
2263
- readonly stateSchema?: ZodType;
2264
- /**
2265
- * SE29 — the initial shared state, seeded onto `StepContext.state` before
2266
- * step 1. Validated against `stateSchema` when both are set. Persisted across
2267
- * suspend/resume.
2268
- */
2269
- readonly initialState?: unknown;
2270
- /** Internal — minted at `.commit()`. Not user-facing. */
2271
- readonly workflowId?: string;
2272
- }
2273
- interface WorkflowRunOptions {
2274
- readonly signal?: AbortSignal;
2275
- /** Override run ID for deterministic resume (advanced; default = mintRunId). */
2276
- readonly runId?: string;
2277
- /**
2278
- * Opt-in Task wrapping (ADRs D363, D374). Registers the workflow run
2279
- * as a `Task` (kind="workflow") with a `wf-` namespaced id (D368,
2280
- * EC-5). The task transitions terminal when `Workflow.run` resolves.
2281
- *
2282
- * Auto-id: `wf-{runId}`.
2283
- *
2284
- * @public
2285
- */
2286
- readonly task?: true | {
2287
- id?: string;
2288
- meta?: Record<string, unknown>;
2289
- };
2290
- }
2291
- interface WorkflowResumeOptions<TI = unknown> {
2292
- readonly runId: string;
2293
- readonly workflow: {
2294
- run: (input: TI, opts?: WorkflowRunOptions) => Promise<WorkflowRun>;
2295
- };
2296
- readonly payload?: unknown;
2297
- readonly signal?: AbortSignal;
2298
- }
2299
-
2300
- /**
2301
- * Public `Workflow` class — declarative multi-step orchestration over
2302
- * `Agent.send`, `Handoff`, `Agent.batch` and friends (Adoption Roadmap #5;
2303
- * ADRs D230-D248).
2304
- *
2305
- * Usage:
2306
- *
2307
- * import { Agent } from "@theokit/sdk";
2308
- * import { Workflow, fn, agentStep } from "@theokit/sdk/workflow";
2309
- *
2310
- * const classifier = await Agent.create({ ... });
2311
- * const wf = Workflow.create({ name: "demo" })
2312
- * .then(fn("validate", (input: { id: string }) => {
2313
- * if (!input.id) throw new Error("missing id");
2314
- * return input;
2315
- * }))
2316
- * .then(agentStep("classify", classifier, (i) => `Classify: ${JSON.stringify(i)}`))
2317
- * .commit();
2318
- *
2319
- * const run = await wf.run({ id: "x" });
2320
- * console.log(run.status, run.output);
2321
- *
2322
- * @public
2323
- */
2324
-
2325
- declare class WorkflowBuilder<TInput = unknown, TOutput = unknown> {
2326
- private readonly options;
2327
- private readonly _steps;
2328
- private _committed;
2329
- then<TO = unknown>(step: Step): WorkflowBuilder<TInput, TO>;
2330
- parallel(branches: ReadonlyArray<ReadonlyArray<Step>>, opts?: {
2331
- id?: string;
2332
- concurrency?: number;
2333
- errorPolicy?: "fail-fast" | "collect";
2334
- }): WorkflowBuilder<TInput, unknown[]>;
2335
- branch(predicates: BranchStep["predicates"], opts?: {
2336
- id?: string;
2337
- fallback?: ReadonlyArray<Step>;
2338
- }): WorkflowBuilder<TInput, unknown>;
2339
- foreach(iterableFrom: string, step: Step, opts?: {
2340
- id?: string;
2341
- concurrency?: number;
2342
- }): WorkflowBuilder<TInput, unknown[]>;
2343
- dowhile(step: Step, condFn: DowhileStep["condFn"], opts?: {
2344
- id?: string;
2345
- maxIterations?: number;
2346
- }): WorkflowBuilder<TInput, unknown>;
2347
- sleep(durationMs: number, id?: string): WorkflowBuilder<TInput, TOutput>;
2348
- suspend(opts?: {
2349
- id?: string;
2350
- payloadSchema?: ZodType;
2351
- }): WorkflowBuilder<TInput, unknown>;
2352
- commit(): Workflow<TInput, TOutput>;
2353
- private validateUniqueIds;
2354
- private assertNotCommitted;
2355
- }
2356
- declare class Workflow<TInput = unknown, TOutput = unknown> {
2357
- private readonly _options;
2358
- private readonly _steps;
2359
- /**
2360
- * Construct a workflow builder. Validate options via Zod and return a
2361
- * `WorkflowBuilder` for fluent chaining. Call `.commit()` to obtain the
2362
- * immutable `Workflow`.
2363
- */
2364
- static create<TI = unknown, TO = unknown>(options: WorkflowOptions): WorkflowBuilder<TI, TO>;
2365
- /**
2366
- * Run this workflow with the given input. Returns a populated
2367
- * `WorkflowRun`. Errors inside a step DO NOT throw — they propagate via
2368
- * `run.status === "failed"`.
2369
- */
2370
- run(input: TInput, opts?: WorkflowRunOptions): Promise<WorkflowRun<TOutput>>;
2371
- /**
2372
- * SE28 — run the workflow and STREAM step-level events as they happen. Returns
2373
- * an async iterator of {@link WorkflowEvent}s (`step_started` / `step_completed`
2374
- * / `step_failed` / `workflow_suspended` / `workflow_completed`, top-level
2375
- * steps) plus a `result` promise resolving to the same terminal
2376
- * {@link WorkflowRun} `run()` returns. Iterate for progress; await `result` for
2377
- * the outcome. The stream ends when the run terminates.
2378
- *
2379
- * `result` is the AUTHORITATIVE terminal status. Not every terminal state has a
2380
- * closing event: a step failure emits `step_failed`, but an `outputSchema`
2381
- * rejection (SE27) or an abort ends the stream WITHOUT `workflow_completed` —
2382
- * always `await result` to read the final `status`. Consuming order is free:
2383
- * awaiting `result` without draining, or draining without awaiting `result`,
2384
- * both work (breaking out of `for await` stops the buffering early).
2385
- */
2386
- stream(input: TInput, opts?: WorkflowRunOptions): WorkflowStream<TOutput>;
2387
- /**
2388
- * Resume a suspended workflow from its snapshot. Throws
2389
- * `WorkflowSnapshotNotFoundError` if `runId` is unknown.
2390
- */
2391
- static resume<TO = unknown>(opts: WorkflowResumeOptions): Promise<WorkflowRun<TO>>;
2392
- }
2393
-
2394
- /**
2395
- * Runtime hosting a cron job. Mirrors the agent runtime split.
2396
- *
2397
- * - `local` — the in-process scheduler activated via `Cron.start()` fires the
2398
- * job while the host process is alive.
2399
- * - `cloud` — Theo PaaS schedules the job server-side; fires independent of
2400
- * any SDK process.
2401
- *
2402
- * @public
2403
- */
2404
- type CronRuntime = "local" | "cloud";
2405
- /**
2406
- * Lifecycle state reported by `Cron.list()` / `Cron.get()`.
2407
- *
2408
- * @public
2409
- */
2410
- type CronJobStatus = "scheduled" | "running" | "paused" | "errored";
2411
- /**
2412
- * Persistent cron-scheduled invocation of the Theo agent or a workflow.
2413
- *
2414
- * Exactly one target is set: {@link CronJob.agent} (ephemeral agent created on
2415
- * each fire), {@link CronJob.agentId} (bound to an existing agent for context
2416
- * continuity), or {@link CronJob.workflow} (a committed workflow run per fire;
2417
- * SE35). Agent targets carry a `message`; a workflow target carries `inputData`.
2418
- *
2419
- * @public
2420
- */
2421
- interface CronJob {
2422
- id: string;
2423
- name?: string;
2424
- /** Standard 5-field POSIX cron expression or shorthand (`@hourly`, `@daily`, ...). */
2425
- cron: string;
2426
- /** IANA timezone identifier. Defaults to `"UTC"`. */
2427
- timezone?: string;
2428
- /** Message sent to the agent on each fire. Present for agent targets; absent for a workflow target. */
2429
- message?: string | SDKUserMessage;
2430
- /** Ephemeral agent options. Mutually exclusive with `agentId`/`workflow`. */
2431
- agent?: AgentOptions;
2432
- /** ID of an existing agent to reuse for context continuity. Mutually exclusive with `agent`/`workflow`. */
2433
- agentId?: string;
2434
- /**
2435
- * SE35 — a committed {@link Workflow} run on each fire (`workflow.run(inputData)`).
2436
- * Mutually exclusive with `agent`/`agentId`. Held in-memory (local runtime only —
2437
- * a workflow instance cannot cross the cloud process boundary). ADR 0014.
2438
- */
2439
- workflow?: Workflow;
2440
- /** SE35 — input passed to `workflow.run(inputData)` on each fire. Workflow targets only. */
2441
- inputData?: unknown;
2442
- /** Whether the scheduler will fire this job on schedule. */
2443
- enabled: boolean;
2444
- /** Current status. */
2445
- status: CronJobStatus;
2446
- /** Runtime that hosts this job. Inferred from `agent`/`agentId`/`workflow` at create time (a `workflow` target is always `local`). */
2447
- runtime: CronRuntime;
2448
- /** Unix ms of the last successful fire, if any. */
2449
- lastRunAt?: number;
2450
- /** Unix ms of the next scheduled fire, computed by the scheduler. */
2451
- nextRunAt?: number;
2452
- /** Unix ms when the job was created. */
2453
- createdAt: number;
2454
- }
2455
- /**
2456
- * Options for `Cron.create()`.
2457
- *
2458
- * Pass exactly ONE target: `agent` (ephemeral agent fresh per fire), `agentId`
2459
- * (reuse an existing agent — preserves conversation context), or `workflow`
2460
- * (SE35 — run a committed workflow per fire). Agent targets REQUIRE `message`;
2461
- * a workflow target takes `inputData` and MUST NOT set `message`. Violations are
2462
- * a `ConfigurationError`.
2463
- *
2464
- * @public
2465
- */
2466
- interface CronCreateOptions {
2467
- cron: string;
2468
- /** Message for an agent target. Required with `agent`/`agentId`; forbidden with `workflow`. */
2469
- message?: string | SDKUserMessage;
2470
- agent?: AgentOptions;
2471
- agentId?: string;
2472
- /** SE35 — a committed {@link Workflow} to run per fire. Mutually exclusive with `agent`/`agentId`. */
2473
- workflow?: Workflow;
2474
- /** SE35 — input for `workflow.run(inputData)`. Workflow targets only. */
2475
- inputData?: unknown;
2476
- name?: string;
2477
- timezone?: string;
2478
- /** Defaults to `true`. */
2479
- enabled?: boolean;
2480
- /** Falls back to `THEOKIT_API_KEY`. */
2481
- apiKey?: string;
2482
- }
2483
- /**
2484
- * Options for `Cron.list()`.
2485
- *
2486
- * @public
2487
- */
2488
- type CronListOptions = {
2489
- limit?: number;
2490
- cursor?: string;
2491
- } & ({
2492
- runtime?: undefined;
2493
- } | {
2494
- runtime: "local";
2495
- cwd?: string;
2496
- } | {
2497
- runtime: "cloud";
2498
- apiKey?: string;
2499
- });
2500
- /**
2501
- * Options for `Cron.get()`.
2502
- *
2503
- * @public
2504
- */
2505
- interface CronGetOptions {
2506
- cwd?: string;
2507
- apiKey?: string;
2508
- }
2509
- /**
2510
- * Options for `Cron.delete()` / `Cron.enable()` / `Cron.disable()`.
2511
- *
2512
- * @public
2513
- */
2514
- interface CronOperationOptions {
2515
- cwd?: string;
2516
- apiKey?: string;
2517
- }
2518
- /**
2519
- * Options for `Cron.run()` — manually trigger a job off-schedule.
2520
- *
2521
- * @public
2522
- */
2523
- interface CronRunOptions {
2524
- cwd?: string;
2525
- apiKey?: string;
2526
- }
2527
- /**
2528
- * Options for `Cron.start()` — activates the in-process scheduler for local
2529
- * jobs.
2530
- *
2531
- * @public
2532
- */
2533
- interface CronStartOptions {
2534
- /** Local workspace whose `.theokit/cron/jobs.json` to load. Defaults to `process.cwd()`. */
2535
- cwd?: string;
2536
- /** Override the env API key. */
2537
- apiKey?: string;
2538
- }
2539
- /**
2540
- * Snapshot of the local scheduler returned by `Cron.status()`.
2541
- *
2542
- * @public
2543
- */
2544
- interface CronSchedulerStatus {
2545
- /** Whether the in-process scheduler is currently running. */
2546
- running: boolean;
2547
- /** Number of jobs loaded into the scheduler. */
2548
- jobCount: number;
2549
- /** Unix ms of the next scheduled fire across all jobs, if any. */
2550
- nextFireAt?: number;
2551
- /** Last error observed in the scheduler, if any. */
2552
- lastError?: {
2553
- jobId: string;
2554
- message: string;
2555
- at: number;
2556
- };
2557
- }
2558
-
2559
- /**
2560
- * Static façade for scheduling Theo agent runs on a cron expression.
2561
- *
2562
- * @public
2563
- */
2564
- declare class Cron {
2565
- private constructor();
2566
- /**
2567
- * Create and persist a cron job.
2568
- *
2569
- * @public
2570
- */
2571
- static create(options: CronCreateOptions): Promise<CronJob>;
2572
- /**
2573
- * List cron jobs (local, cloud, or both).
2574
- *
2575
- * @public
2576
- */
2577
- static list(options?: CronListOptions): Promise<ListResult<CronJob>>;
2578
- /**
2579
- * Get a single cron job by ID.
2580
- *
2581
- * @public
2582
- */
2583
- static get(jobId: string, _options?: CronGetOptions): Promise<CronJob>;
2584
- /**
2585
- * Delete a cron job permanently.
2586
- *
2587
- * @public
2588
- */
2589
- static delete(jobId: string, _options?: CronOperationOptions): Promise<void>;
2590
- /**
2591
- * Re-enable a paused cron job.
2592
- *
2593
- * @public
2594
- */
2595
- static enable(jobId: string, _options?: CronOperationOptions): Promise<CronJob>;
2596
- /**
2597
- * Pause a cron job without deleting it.
2598
- *
2599
- * @public
2600
- */
2601
- static disable(jobId: string, _options?: CronOperationOptions): Promise<CronJob>;
2602
- /**
2603
- * Manually trigger a cron job off-schedule. Returns the resulting `Run`
2604
- * (agent target) or `WorkflowRun` (workflow target — SE35).
2605
- *
2606
- * @public
2607
- */
2608
- static run(jobId: string, _options?: CronRunOptions): Promise<Run | WorkflowRun>;
2609
- /**
2610
- * Activate the in-process scheduler for local cron jobs.
2611
- *
2612
- * @public
2613
- */
2614
- static start(options?: CronStartOptions): Promise<void>;
2615
- /**
2616
- * Stop the in-process scheduler. Jobs are preserved.
2617
- *
2618
- * @public
2619
- */
2620
- static stop(): Promise<void>;
2621
- /**
2622
- * Snapshot of the local scheduler.
2623
- *
2624
- * @public
2625
- */
2626
- static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
2627
- }
2628
-
2629
- export { type CronRuntime as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type BudgetUsageEvent as D, type CloudEnv as E, type CloudRepo as F, type GetAgentOptions as G, type ContextBudget as H, type InlineSkill as I, type JudgeResult as J, type ContextManagerKind as K, type LocalOptions as L, type MemorySettings as M, type ContextSnapshot as N, type ContextSource as O, type ProviderRoutingSettings as P, type ContextSourceStatus as Q, type CreateSkillSpec as R, type SystemPromptResolver as S, Cron as T, type CronCreateOptions as U, type CronGetOptions as V, type CronJob as W, type CronJobStatus as X, type CronListOptions as Y, type CronOperationOptions as Z, type CronRunOptions as _, type AgentDefinition as a, type CronSchedulerStatus as a0, type CronStartOptions as a1, type HookName as a2, type InvalidateCacheOptions as a3, type MemoryAdapter as a4, type MemoryAdapterCapabilities as a5, type MemoryContext as a6, type MemoryFact as a7, type MemoryProviderHandle as a8, type MemoryProviderInitOptions as a9, Skill as aA, type SkillsResolver as aB, type SkillsResolverContext as aC, type SystemPromptContext as aD, type SystemPromptMemoryFact as aE, type SystemPromptSkillRef as aF, type TelemetrySettings as aG, type Verdict as aH, type MemoryRevision as aa, type MemoryToolSchema as ab, type MemoryTurnMessage as ac, type PersonalityPreset as ad, type PluginContext as ae, type PostAssistantReplyContext as af, type PreToolCallContext as ag, type PreUserSendContext as ah, type PreUserSendResult as ai, type ProviderCapability as aj, type ProviderRoute as ak, type ProviderTransform as al, type ProviderTransformContext as am, type RecordSessionSummaryArgs as an, type ResolvedProviderRoute as ao, type RunUntilIterator as ap, type SDKAgentPlugins as aq, type SDKAgentSkillDetail as ar, type SDKAgentSkills as as, type SDKArtifact as at, type SDKContextManager as au, type SDKPluginMetadata as av, type SDKProvidersManager as aw, type SessionRecord as ax, type SessionStore as ay, type SettingSource as az, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type Plugin as l, type ProviderProfile as m, type GoalOptions as n, type GoalEvent as o, type GoalResult as p, type MemoryProvider as q, type MemoryId as r, type PreToolCallDecision as s, type StepResult as t, type SDKProvider as u, type ActiveMemoryPassArgs as v, type ActiveMemoryPassResult as w, type AgentMemory as x, type BudgetCheck as y, type BudgetTotal as z };
2062
+ export { type MemoryToolSchema as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type CloudEnv as D, type CloudRepo as E, type ContextBudget as F, type GetAgentOptions as G, type ContextManagerKind as H, type InlineSkill as I, type JudgeResult as J, type ContextSnapshot as K, type LocalOptions as L, type MemorySettings as M, type ContextSource as N, type ContextSourceStatus as O, type ProviderRoutingSettings as P, type CreateSkillSpec as Q, type HookName as R, type SystemPromptResolver as S, type InvalidateCacheOptions as T, type MemoryAdapter as U, type MemoryAdapterCapabilities as V, type MemoryContext as W, type MemoryFact as X, type MemoryProviderHandle as Y, type MemoryProviderInitOptions as Z, type MemoryRevision as _, type AgentDefinition as a, type MemoryTurnMessage as a0, type PersonalityPreset as a1, type PluginContext as a2, type PostAssistantReplyContext as a3, type PreToolCallContext as a4, type PreUserSendContext as a5, type PreUserSendResult as a6, type ProviderCapability as a7, type ProviderRoute as a8, type ProviderTransform as a9, type ProviderTransformContext as aa, type RecordSessionSummaryArgs as ab, type ResolvedProviderRoute as ac, type RunUntilIterator as ad, type SDKAgentPlugins as ae, type SDKAgentSkillDetail as af, type SDKAgentSkills as ag, type SDKArtifact as ah, type SDKContextManager as ai, type SDKPluginMetadata as aj, type SDKProvidersManager as ak, type SessionRecord as al, type SessionStore as am, type SettingSource as an, Skill as ao, type SkillsResolver as ap, type SkillsResolverContext as aq, type SystemPromptContext as ar, type SystemPromptMemoryFact as as, type SystemPromptSkillRef as at, type TelemetrySettings as au, type Verdict as av, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type Plugin as l, type ProviderProfile as m, type GoalOptions as n, type GoalEvent as o, type GoalResult as p, type MemoryProvider as q, type MemoryId as r, type PreToolCallDecision as s, type SDKProvider as t, type ActiveMemoryPassArgs as u, type ActiveMemoryPassResult as v, type AgentMemory as w, type BudgetCheck as x, type BudgetTotal as y, type BudgetUsageEvent as z };
@@ -0,0 +1,41 @@
1
+ export { Agent } from './chunk-VUJ3NVDC.js';
2
+ import './chunk-2SFBB54R.js';
3
+ import './chunk-HRA3CPGG.js';
4
+ import './chunk-SQLZ7ONU.js';
5
+ import './chunk-K2BQQ445.js';
6
+ import './chunk-U6QGZHPN.js';
7
+ import './chunk-NRSH7RJY.js';
8
+ import './chunk-6CLRANZA.js';
9
+ import './chunk-EEZ7CFMM.js';
10
+ import './chunk-XAUBQMQU.js';
11
+ import './chunk-XIG2IE3L.js';
12
+ import './chunk-7GFX45DD.js';
13
+ import './chunk-DGRZNMTU.js';
14
+ import './chunk-FD2UT76F.js';
15
+ import './chunk-U54XCYG3.js';
16
+ import './chunk-FV3YEMQ7.js';
17
+ import './chunk-6X6ID4MO.js';
18
+ import './chunk-UJ7IQJAG.js';
19
+ import './chunk-7AD3ZTZL.js';
20
+ import './chunk-V4XRLPEF.js';
21
+ import './chunk-5PZMMF4H.js';
22
+ import './chunk-HZQEDNF6.js';
23
+ import './chunk-77FOZCOT.js';
24
+ import './chunk-2XLKLVVR.js';
25
+ import './chunk-ZZWTY3RX.js';
26
+ import './chunk-BXV2QUIC.js';
27
+ import './chunk-4VPXM6UU.js';
28
+ import './chunk-S2BBRVQX.js';
29
+ import './chunk-BNIFFFH3.js';
30
+ import './chunk-WA3FO4R7.js';
31
+ import './chunk-X2FR4OIT.js';
32
+ import './chunk-KAP4GJHO.js';
33
+ import './chunk-LU7VALW5.js';
34
+ import './chunk-5NBUH3NO.js';
35
+ import './chunk-5IB2UKSN.js';
36
+ import './chunk-POQT2OIF.js';
37
+ import './chunk-FKCC2MED.js';
38
+ import './chunk-WLKFWQSJ.js';
39
+ import './chunk-JTFYYKDT.js';
40
+ //# sourceMappingURL=agent-FBTLZI6V.js.map
41
+ //# sourceMappingURL=agent-FBTLZI6V.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-FBTLZI6V.js"}