@theokit/sdk 1.8.1 → 2.0.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 (83) hide show
  1. package/CHANGELOG.md +70 -22
  2. package/bin/init-claude.mjs +0 -0
  3. package/dist/a2a/index.cjs +12592 -12884
  4. package/dist/a2a/index.cjs.map +1 -1
  5. package/dist/a2a/index.js +12592 -12884
  6. package/dist/a2a/index.js.map +1 -1
  7. package/dist/{cron-BnywDYLq.d.cts → cron-Bse1MbaE.d.cts} +52 -2
  8. package/dist/{cron-CtZvJD9J.d.ts → cron-Ci_NUkUj.d.ts} +52 -2
  9. package/dist/cron.cjs +8763 -9062
  10. package/dist/cron.cjs.map +1 -1
  11. package/dist/cron.d.cts +1 -1
  12. package/dist/cron.d.ts +1 -1
  13. package/dist/cron.js +8763 -9062
  14. package/dist/cron.js.map +1 -1
  15. package/dist/eval.cjs +8776 -9075
  16. package/dist/eval.cjs.map +1 -1
  17. package/dist/eval.js +8776 -9075
  18. package/dist/eval.js.map +1 -1
  19. package/dist/index.cjs +11217 -10037
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +174 -3
  22. package/dist/index.d.ts +174 -3
  23. package/dist/index.js +11217 -10038
  24. package/dist/index.js.map +1 -1
  25. package/dist/internal/runtime/{cloud-config-serializer.d.ts → cloud/cloud-config-serializer.d.ts} +1 -1
  26. package/dist/internal/runtime/{real-cloud-run.d.ts → cloud/real-cloud-run.d.ts} +1 -1
  27. package/dist/internal/runtime/fixtures/fixture-scripts.d.ts +1 -1
  28. package/dist/internal/runtime/fork-agent.d.ts +1 -1
  29. package/dist/internal/runtime/{local-agent-bootstrap.d.ts → local-agent/local-agent-bootstrap.d.ts} +4 -4
  30. package/dist/internal/runtime/{local-agent-dispatch.d.ts → local-agent/local-agent-dispatch.d.ts} +7 -7
  31. package/dist/internal/runtime/{local-agent-memory-hooks.d.ts → local-agent/local-agent-memory-hooks.d.ts} +2 -2
  32. package/dist/internal/runtime/{local-agent-memory-provider.d.ts → local-agent/local-agent-memory-provider.d.ts} +2 -2
  33. package/dist/internal/runtime/{real-local-run.d.ts → local-agent/real-local-run.d.ts} +1 -1
  34. package/dist/internal/runtime/{memory-path-selector.d.ts → memory/memory-path-selector.d.ts} +1 -1
  35. package/dist/internal/runtime/{memory-provider.d.ts → memory/memory-provider.d.ts} +2 -2
  36. package/dist/internal/runtime/{memory-store.d.ts → memory/memory-store.d.ts} +1 -1
  37. package/dist/internal/runtime/skills/subagents-loader.d.ts +1 -0
  38. package/dist/types/agent.d.ts +3 -3
  39. package/dist/types/fork.d.ts +49 -0
  40. package/dist/types/goal-events.d.ts +1 -1
  41. package/package.json +15 -26
  42. package/dist/rag/index.cjs +0 -136
  43. package/dist/rag/index.cjs.map +0 -1
  44. package/dist/rag/index.d.cts +0 -11
  45. package/dist/rag/index.d.ts +0 -11
  46. package/dist/rag/index.js +0 -129
  47. package/dist/rag/index.js.map +0 -1
  48. package/dist/rag/reranker.d.cts +0 -26
  49. package/dist/rag/reranker.d.ts +0 -26
  50. package/dist/rag/retriever.d.cts +0 -25
  51. package/dist/rag/retriever.d.ts +0 -25
  52. package/dist/rag/text-splitter.d.cts +0 -12
  53. package/dist/rag/text-splitter.d.ts +0 -12
  54. package/dist/rag/types.d.cts +0 -37
  55. package/dist/rag/types.d.ts +0 -37
  56. package/dist/voice/index.d.ts +0 -7
  57. package/dist/voice/openai-realtime.d.ts +0 -21
  58. package/dist/voice/types.d.ts +0 -35
  59. /package/dist/internal/{runtime/cloud-agent.d.ts → agent-loop/budget-gate.d.ts} +0 -0
  60. /package/dist/internal/runtime/{budget-tracker.d.ts → budget/budget-tracker.d.ts} +0 -0
  61. /package/dist/internal/runtime/{budget.d.ts → budget/budget.d.ts} +0 -0
  62. /package/dist/internal/runtime/{cloud-run.d.ts → cloud/cloud-agent.d.ts} +0 -0
  63. /package/dist/internal/runtime/{cloud-payload-types.d.ts → cloud/cloud-payload-types.d.ts} +0 -0
  64. /package/dist/internal/runtime/{cloud-tool-parity.d.ts → cloud/cloud-run.d.ts} +0 -0
  65. /package/dist/internal/runtime/{local-agent-memory.d.ts → cloud/cloud-tool-parity.d.ts} +0 -0
  66. /package/dist/internal/runtime/{hooks-executor.d.ts → hooks/hooks-executor.d.ts} +0 -0
  67. /package/dist/internal/runtime/{hooks-frontmatter.d.ts → hooks/hooks-frontmatter.d.ts} +0 -0
  68. /package/dist/internal/runtime/{hooks-source.d.ts → hooks/hooks-source.d.ts} +0 -0
  69. /package/dist/internal/runtime/{local-agent-invalidate.d.ts → local-agent/local-agent-invalidate.d.ts} +0 -0
  70. /package/dist/internal/runtime/{local-agent-memory-direct.d.ts → local-agent/local-agent-memory-direct.d.ts} +0 -0
  71. /package/dist/internal/runtime/{local-agent-send.d.ts → local-agent/local-agent-memory.d.ts} +0 -0
  72. /package/dist/internal/runtime/{local-agent-personality-extensions.d.ts → local-agent/local-agent-personality-extensions.d.ts} +0 -0
  73. /package/dist/internal/runtime/{local-agent-plugins.d.ts → local-agent/local-agent-plugins.d.ts} +0 -0
  74. /package/dist/internal/runtime/{local-agent-runtime-extensions.d.ts → local-agent/local-agent-runtime-extensions.d.ts} +0 -0
  75. /package/dist/internal/runtime/{local-agent.d.ts → local-agent/local-agent-send.d.ts} +0 -0
  76. /package/dist/internal/runtime/{local-agent-task-wrap.d.ts → local-agent/local-agent-task-wrap.d.ts} +0 -0
  77. /package/dist/internal/runtime/{local-run.d.ts → local-agent/local-agent.d.ts} +0 -0
  78. /package/dist/internal/runtime/{skills-manager.d.ts → local-agent/local-run.d.ts} +0 -0
  79. /package/dist/internal/runtime/{agent-session-store.d.ts → session/agent-session-store.d.ts} +0 -0
  80. /package/dist/internal/runtime/{agent-session.d.ts → session/agent-session.d.ts} +0 -0
  81. /package/dist/internal/runtime/{session-types.d.ts → session/session-types.d.ts} +0 -0
  82. /package/dist/internal/runtime/{skill-frontmatter.d.ts → skills/skill-frontmatter.d.ts} +0 -0
  83. /package/dist/internal/runtime/{subagents-loader.d.ts → skills/skills-manager.d.ts} +0 -0
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-ChqOmFH1.cjs';
2
2
  export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError } from './errors-ChqOmFH1.cjs';
3
- import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as ConversationStorageAdapter, m as StoredMessage, n as MemoryContext, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-BnywDYLq.cjs';
4
- export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-BnywDYLq.cjs';
3
+ import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as ConversationStorageAdapter, m as StoredMessage, n as MemoryContext, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-Bse1MbaE.cjs';
4
+ export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-Bse1MbaE.cjs';
5
5
  import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-DrwUpFxZ.cjs';
6
6
  export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as SDKAssistantMessage, s as SDKImage, t as SDKImageDimension, u as SDKObjectDelta, v as SDKRequestMessage, w as SDKStatusMessage, x as SDKSystemMessage, y as SDKTaskMessage, z as SDKThinkingMessage, B as SDKToolUseMessage, D as SDKUserMessage, E as SDKUserMessageEvent, F as SendOptions, G as ShellCommand, H as ShellConversationTurn, J as ShellOutput, K as ShellOutputDeltaUpdate, L as StepCompletedUpdate, N as StepStartedUpdate, O as SummaryCompletedUpdate, Q as SummaryStartedUpdate, T as SummaryUpdate, U as TextBlock, V as TextDeltaUpdate, W as ThinkingCompletedUpdate, X as ThinkingDeltaUpdate, Y as ThinkingMessage, Z as TokenDeltaUpdate, _ as TokenUsage, $ as ToolCall, a0 as ToolCallCompletedUpdate, a1 as ToolCallStartedUpdate, a2 as ToolResult, a3 as ToolUseBlock, a4 as TurnEndedUpdate, a5 as UserMessage, a6 as UserMessageAppendedUpdate } from './run-DrwUpFxZ.cjs';
7
7
  import * as zod from 'zod';
@@ -1430,6 +1430,177 @@ declare class Security {
1430
1430
  static addPattern(re: RegExp): void;
1431
1431
  }
1432
1432
 
1433
+ /**
1434
+ * Public type contract for `Workflow.create / .run / .resume` (Adoption
1435
+ * Roadmap #5; ADRs D230-D248).
1436
+ *
1437
+ * Step types form a discriminated union by `kind`. Helper factory functions
1438
+ * (`fn()`, `agentStep()`) live in `workflow.ts` and hide the discriminator
1439
+ * from end users.
1440
+ *
1441
+ * @public
1442
+ */
1443
+
1444
+ type Step = FnStep | AgentStep | ParallelStep | BranchStep | ForeachStep | DowhileStep | SleepStep | SuspendStep;
1445
+ /** A pure function step. */
1446
+ interface FnStep {
1447
+ readonly kind: "fn";
1448
+ readonly id: string;
1449
+ readonly fn: (input: unknown, ctx: StepContext) => Promise<unknown> | unknown;
1450
+ readonly inputSchema?: ZodType;
1451
+ readonly outputSchema?: ZodType;
1452
+ readonly retry?: RetryPolicy;
1453
+ /** D238 — slot reserved; runtime throws if engine not yet implemented. */
1454
+ readonly compensate?: (input: unknown, output: unknown, error: Error) => Promise<void> | void;
1455
+ }
1456
+ /** An agent.send-driven step. */
1457
+ interface AgentStep {
1458
+ readonly kind: "agent";
1459
+ readonly id: string;
1460
+ readonly agent: SDKAgent;
1461
+ readonly promptTemplate: string | ((input: unknown) => string);
1462
+ readonly retry?: RetryPolicy;
1463
+ }
1464
+ /** N concurrent branches, each its own mini-step-list. */
1465
+ interface ParallelStep {
1466
+ readonly kind: "parallel";
1467
+ readonly id: string;
1468
+ readonly branches: ReadonlyArray<ReadonlyArray<Step>>;
1469
+ readonly concurrency?: number;
1470
+ readonly errorPolicy?: "fail-fast" | "collect";
1471
+ }
1472
+ /** First-match-wins predicates + optional fallback. */
1473
+ interface BranchStep {
1474
+ readonly kind: "branch";
1475
+ readonly id: string;
1476
+ readonly predicates: ReadonlyArray<readonly [(input: unknown) => boolean | Promise<boolean>, ReadonlyArray<Step>]>;
1477
+ readonly fallback?: ReadonlyArray<Step>;
1478
+ }
1479
+ /** Map a step over an upstream array output. */
1480
+ interface ForeachStep {
1481
+ readonly kind: "foreach";
1482
+ readonly id: string;
1483
+ /** ID of an upstream top-level step whose output is iterable. */
1484
+ readonly iterableFrom: string;
1485
+ readonly step: Step;
1486
+ readonly concurrency?: number;
1487
+ }
1488
+ /** Loop a step until condFn returns false. */
1489
+ interface DowhileStep {
1490
+ readonly kind: "dowhile";
1491
+ readonly id: string;
1492
+ readonly step: Step;
1493
+ readonly condFn: (output: unknown, iteration: number) => boolean | Promise<boolean>;
1494
+ readonly maxIterations?: number;
1495
+ }
1496
+ /** Pause for a fixed duration. */
1497
+ interface SleepStep {
1498
+ readonly kind: "sleep";
1499
+ readonly id: string;
1500
+ readonly durationMs: number;
1501
+ }
1502
+ /** Standalone explicit suspend point. */
1503
+ interface SuspendStep {
1504
+ readonly kind: "suspend";
1505
+ readonly id: string;
1506
+ readonly payloadSchema?: ZodType;
1507
+ }
1508
+ /** D237 — retry policy applied per fn/agent step. */
1509
+ interface RetryPolicy {
1510
+ /** Total attempts (MIN 1, MAX 20). `1` = no retry. */
1511
+ readonly maxAttempts: number;
1512
+ readonly initialBackoffMs?: number;
1513
+ readonly backoffCoefficient?: number;
1514
+ readonly maximumBackoffMs?: number;
1515
+ readonly nonRetryableErrors?: ReadonlyArray<string>;
1516
+ }
1517
+ /** D247 — context handed to every step.fn. */
1518
+ interface StepContext {
1519
+ readonly runId: string;
1520
+ readonly signal: AbortSignal;
1521
+ readonly log: {
1522
+ debug: (msg: string, attrs?: Record<string, unknown>) => void;
1523
+ info: (msg: string, attrs?: Record<string, unknown>) => void;
1524
+ warn: (msg: string, attrs?: Record<string, unknown>) => void;
1525
+ };
1526
+ /** Pause the workflow; resume via `Workflow.resume({...})`. */
1527
+ readonly suspend: (payload?: unknown) => Promise<never>;
1528
+ }
1529
+ interface StepResult {
1530
+ readonly stepId: string;
1531
+ readonly kind: Step["kind"];
1532
+ readonly status: "completed" | "failed" | "skipped" | "suspended";
1533
+ readonly attempts: number;
1534
+ readonly durationMs: number;
1535
+ readonly output?: unknown;
1536
+ readonly error?: {
1537
+ name: string;
1538
+ message: string;
1539
+ };
1540
+ }
1541
+
1542
+ /**
1543
+ * `createSquad` — a sequential team of agents.
1544
+ *
1545
+ * A Squad is a thin convenience that COMPOSES `Workflow` + `agentStep` — it
1546
+ * adds NO new orchestration logic. Agents run in array order; each agent's
1547
+ * output is threaded into the next agent's prompt. For branching/parallel/
1548
+ * foreach teams use `Workflow` directly; for manager→worker delegation use
1549
+ * subagents or `@theokit/sdk-handoff`.
1550
+ *
1551
+ * Mirrors the `createAgentFactory` composition-LEGO precedent (a factory over
1552
+ * existing primitives, not a new subsystem).
1553
+ *
1554
+ * @public
1555
+ */
1556
+
1557
+ /**
1558
+ * Options for {@link createSquad}.
1559
+ *
1560
+ * @public
1561
+ */
1562
+ interface SquadOptions {
1563
+ /** Agents run in array order (sequential pipeline). Must be non-empty. */
1564
+ agents: ReadonlyArray<SDKAgent>;
1565
+ /**
1566
+ * Orchestration process. Only `"sequential"` is supported (the default).
1567
+ * `"hierarchical"` is accepted by the type but rejected at runtime with
1568
+ * guidance — use subagents or `@theokit/sdk-handoff` for manager→worker
1569
+ * delegation (those already cover it).
1570
+ */
1571
+ process?: "sequential" | "hierarchical";
1572
+ /** Optional squad name (surfaced on the underlying workflow). Default `"squad"`. */
1573
+ name?: string;
1574
+ }
1575
+ /**
1576
+ * Result of a {@link Squad.run}. `result` is the final (last agent's) output;
1577
+ * `steps` is the per-agent trace from the underlying workflow run.
1578
+ *
1579
+ * @public
1580
+ */
1581
+ interface SquadRun {
1582
+ readonly result: unknown;
1583
+ readonly status: "running" | "completed" | "failed" | "suspended" | "cancelled";
1584
+ readonly steps: ReadonlyArray<StepResult>;
1585
+ }
1586
+ /**
1587
+ * A sequential agent team produced by {@link createSquad}.
1588
+ *
1589
+ * @public
1590
+ */
1591
+ interface Squad {
1592
+ /** Run the team over `input`, threading each agent's output to the next. */
1593
+ run(input: unknown): Promise<SquadRun>;
1594
+ }
1595
+ /**
1596
+ * Build a sequential agent team. The returned {@link Squad} composes a
1597
+ * `Workflow` of `agentStep`s under the hood — all orchestration is delegated
1598
+ * to the workflow engine.
1599
+ *
1600
+ * @public
1601
+ */
1602
+ declare function createSquad(options: SquadOptions): Squad;
1603
+
1433
1604
  /**
1434
1605
  * Public type contract for the Task observability registry (ADRs D361-D374).
1435
1606
  *
@@ -1895,4 +2066,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
1895
2066
  model?: string;
1896
2067
  }): ShareGptTrajectory | null;
1897
2068
 
1898
- export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, PermissionEngine, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, definePlugin, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
2069
+ export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, PermissionEngine, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createSquad, definePlugin, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-DV9e0rcp.js';
2
2
  export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError } from './errors-DV9e0rcp.js';
3
- import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as ConversationStorageAdapter, m as StoredMessage, n as MemoryContext, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-CtZvJD9J.js';
4
- export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-CtZvJD9J.js';
3
+ import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as ConversationStorageAdapter, m as StoredMessage, n as MemoryContext, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-Ci_NUkUj.js';
4
+ export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-Ci_NUkUj.js';
5
5
  import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-DrwUpFxZ.js';
6
6
  export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as SDKAssistantMessage, s as SDKImage, t as SDKImageDimension, u as SDKObjectDelta, v as SDKRequestMessage, w as SDKStatusMessage, x as SDKSystemMessage, y as SDKTaskMessage, z as SDKThinkingMessage, B as SDKToolUseMessage, D as SDKUserMessage, E as SDKUserMessageEvent, F as SendOptions, G as ShellCommand, H as ShellConversationTurn, J as ShellOutput, K as ShellOutputDeltaUpdate, L as StepCompletedUpdate, N as StepStartedUpdate, O as SummaryCompletedUpdate, Q as SummaryStartedUpdate, T as SummaryUpdate, U as TextBlock, V as TextDeltaUpdate, W as ThinkingCompletedUpdate, X as ThinkingDeltaUpdate, Y as ThinkingMessage, Z as TokenDeltaUpdate, _ as TokenUsage, $ as ToolCall, a0 as ToolCallCompletedUpdate, a1 as ToolCallStartedUpdate, a2 as ToolResult, a3 as ToolUseBlock, a4 as TurnEndedUpdate, a5 as UserMessage, a6 as UserMessageAppendedUpdate } from './run-DrwUpFxZ.js';
7
7
  import * as zod from 'zod';
@@ -1430,6 +1430,177 @@ declare class Security {
1430
1430
  static addPattern(re: RegExp): void;
1431
1431
  }
1432
1432
 
1433
+ /**
1434
+ * Public type contract for `Workflow.create / .run / .resume` (Adoption
1435
+ * Roadmap #5; ADRs D230-D248).
1436
+ *
1437
+ * Step types form a discriminated union by `kind`. Helper factory functions
1438
+ * (`fn()`, `agentStep()`) live in `workflow.ts` and hide the discriminator
1439
+ * from end users.
1440
+ *
1441
+ * @public
1442
+ */
1443
+
1444
+ type Step = FnStep | AgentStep | ParallelStep | BranchStep | ForeachStep | DowhileStep | SleepStep | SuspendStep;
1445
+ /** A pure function step. */
1446
+ interface FnStep {
1447
+ readonly kind: "fn";
1448
+ readonly id: string;
1449
+ readonly fn: (input: unknown, ctx: StepContext) => Promise<unknown> | unknown;
1450
+ readonly inputSchema?: ZodType;
1451
+ readonly outputSchema?: ZodType;
1452
+ readonly retry?: RetryPolicy;
1453
+ /** D238 — slot reserved; runtime throws if engine not yet implemented. */
1454
+ readonly compensate?: (input: unknown, output: unknown, error: Error) => Promise<void> | void;
1455
+ }
1456
+ /** An agent.send-driven step. */
1457
+ interface AgentStep {
1458
+ readonly kind: "agent";
1459
+ readonly id: string;
1460
+ readonly agent: SDKAgent;
1461
+ readonly promptTemplate: string | ((input: unknown) => string);
1462
+ readonly retry?: RetryPolicy;
1463
+ }
1464
+ /** N concurrent branches, each its own mini-step-list. */
1465
+ interface ParallelStep {
1466
+ readonly kind: "parallel";
1467
+ readonly id: string;
1468
+ readonly branches: ReadonlyArray<ReadonlyArray<Step>>;
1469
+ readonly concurrency?: number;
1470
+ readonly errorPolicy?: "fail-fast" | "collect";
1471
+ }
1472
+ /** First-match-wins predicates + optional fallback. */
1473
+ interface BranchStep {
1474
+ readonly kind: "branch";
1475
+ readonly id: string;
1476
+ readonly predicates: ReadonlyArray<readonly [(input: unknown) => boolean | Promise<boolean>, ReadonlyArray<Step>]>;
1477
+ readonly fallback?: ReadonlyArray<Step>;
1478
+ }
1479
+ /** Map a step over an upstream array output. */
1480
+ interface ForeachStep {
1481
+ readonly kind: "foreach";
1482
+ readonly id: string;
1483
+ /** ID of an upstream top-level step whose output is iterable. */
1484
+ readonly iterableFrom: string;
1485
+ readonly step: Step;
1486
+ readonly concurrency?: number;
1487
+ }
1488
+ /** Loop a step until condFn returns false. */
1489
+ interface DowhileStep {
1490
+ readonly kind: "dowhile";
1491
+ readonly id: string;
1492
+ readonly step: Step;
1493
+ readonly condFn: (output: unknown, iteration: number) => boolean | Promise<boolean>;
1494
+ readonly maxIterations?: number;
1495
+ }
1496
+ /** Pause for a fixed duration. */
1497
+ interface SleepStep {
1498
+ readonly kind: "sleep";
1499
+ readonly id: string;
1500
+ readonly durationMs: number;
1501
+ }
1502
+ /** Standalone explicit suspend point. */
1503
+ interface SuspendStep {
1504
+ readonly kind: "suspend";
1505
+ readonly id: string;
1506
+ readonly payloadSchema?: ZodType;
1507
+ }
1508
+ /** D237 — retry policy applied per fn/agent step. */
1509
+ interface RetryPolicy {
1510
+ /** Total attempts (MIN 1, MAX 20). `1` = no retry. */
1511
+ readonly maxAttempts: number;
1512
+ readonly initialBackoffMs?: number;
1513
+ readonly backoffCoefficient?: number;
1514
+ readonly maximumBackoffMs?: number;
1515
+ readonly nonRetryableErrors?: ReadonlyArray<string>;
1516
+ }
1517
+ /** D247 — context handed to every step.fn. */
1518
+ interface StepContext {
1519
+ readonly runId: string;
1520
+ readonly signal: AbortSignal;
1521
+ readonly log: {
1522
+ debug: (msg: string, attrs?: Record<string, unknown>) => void;
1523
+ info: (msg: string, attrs?: Record<string, unknown>) => void;
1524
+ warn: (msg: string, attrs?: Record<string, unknown>) => void;
1525
+ };
1526
+ /** Pause the workflow; resume via `Workflow.resume({...})`. */
1527
+ readonly suspend: (payload?: unknown) => Promise<never>;
1528
+ }
1529
+ interface StepResult {
1530
+ readonly stepId: string;
1531
+ readonly kind: Step["kind"];
1532
+ readonly status: "completed" | "failed" | "skipped" | "suspended";
1533
+ readonly attempts: number;
1534
+ readonly durationMs: number;
1535
+ readonly output?: unknown;
1536
+ readonly error?: {
1537
+ name: string;
1538
+ message: string;
1539
+ };
1540
+ }
1541
+
1542
+ /**
1543
+ * `createSquad` — a sequential team of agents.
1544
+ *
1545
+ * A Squad is a thin convenience that COMPOSES `Workflow` + `agentStep` — it
1546
+ * adds NO new orchestration logic. Agents run in array order; each agent's
1547
+ * output is threaded into the next agent's prompt. For branching/parallel/
1548
+ * foreach teams use `Workflow` directly; for manager→worker delegation use
1549
+ * subagents or `@theokit/sdk-handoff`.
1550
+ *
1551
+ * Mirrors the `createAgentFactory` composition-LEGO precedent (a factory over
1552
+ * existing primitives, not a new subsystem).
1553
+ *
1554
+ * @public
1555
+ */
1556
+
1557
+ /**
1558
+ * Options for {@link createSquad}.
1559
+ *
1560
+ * @public
1561
+ */
1562
+ interface SquadOptions {
1563
+ /** Agents run in array order (sequential pipeline). Must be non-empty. */
1564
+ agents: ReadonlyArray<SDKAgent>;
1565
+ /**
1566
+ * Orchestration process. Only `"sequential"` is supported (the default).
1567
+ * `"hierarchical"` is accepted by the type but rejected at runtime with
1568
+ * guidance — use subagents or `@theokit/sdk-handoff` for manager→worker
1569
+ * delegation (those already cover it).
1570
+ */
1571
+ process?: "sequential" | "hierarchical";
1572
+ /** Optional squad name (surfaced on the underlying workflow). Default `"squad"`. */
1573
+ name?: string;
1574
+ }
1575
+ /**
1576
+ * Result of a {@link Squad.run}. `result` is the final (last agent's) output;
1577
+ * `steps` is the per-agent trace from the underlying workflow run.
1578
+ *
1579
+ * @public
1580
+ */
1581
+ interface SquadRun {
1582
+ readonly result: unknown;
1583
+ readonly status: "running" | "completed" | "failed" | "suspended" | "cancelled";
1584
+ readonly steps: ReadonlyArray<StepResult>;
1585
+ }
1586
+ /**
1587
+ * A sequential agent team produced by {@link createSquad}.
1588
+ *
1589
+ * @public
1590
+ */
1591
+ interface Squad {
1592
+ /** Run the team over `input`, threading each agent's output to the next. */
1593
+ run(input: unknown): Promise<SquadRun>;
1594
+ }
1595
+ /**
1596
+ * Build a sequential agent team. The returned {@link Squad} composes a
1597
+ * `Workflow` of `agentStep`s under the hood — all orchestration is delegated
1598
+ * to the workflow engine.
1599
+ *
1600
+ * @public
1601
+ */
1602
+ declare function createSquad(options: SquadOptions): Squad;
1603
+
1433
1604
  /**
1434
1605
  * Public type contract for the Task observability registry (ADRs D361-D374).
1435
1606
  *
@@ -1895,4 +2066,4 @@ declare function toShareGptTrajectory(result: BatchResult, options?: {
1895
2066
  model?: string;
1896
2067
  }): ShareGptTrajectory | null;
1897
2068
 
1898
- export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, PermissionEngine, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, definePlugin, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };
2069
+ export { Agent, AgentBuilder, AgentDefinition, type AgentFactory, AgentOperationOptions, AgentOptions, type AgentPromptResult, type AgentRegistryOptions, type BatchItem, type BatchOptions, type BatchProgress, type BatchResult, Budget, BudgetHandle, BudgetOptions, BudgetSnapshot, BudgetTracker, CloudOptions, ContextSettings, ConversationStorageAdapter, type CounterBudgetTrackerOptions, CustomTool, type DeepPartial, type DefineToolSpec, type DreamingSweepOptions, type DreamingSweepResult, EventBus, type EvictReason, FileSystemConversationStorage, GenerateObjectError, type GenerateObjectOptions, type GenerateObjectResult, GetAgentOptions, GetRunOptions, type HookName, InMemoryConversationStorage, JobQueue, ListAgentsOptions, ListResult, ListRunsOptions, LiveAgentRegistry, LocalOptions, McpServerConfig, Memory, MemoryContext, MemoryId, MemoryProvider, MemorySettings, type MigrateOptions, type MigrateResult, type ModelListItem, type ModelParameterDefinition, ModelSelection, type ModelVariant, PermissionEngine, type Plugin, type PluginContext, PluginsSettings, type PostAssistantReplyContext, type PreToolCallContext, type PreToolCallDecision, type PreUserSendContext, type PreUserSendResult, type ProviderProfile, ProviderRoutingSettings, Run, RunResult, SDKAgent, SDKAgentInfo, SDKMessage, type SDKModel, SDKProvider, type SDKRepository, type SDKUser, Security, type ShareGptMessage, type ShareGptTrajectory, SkillsSettings, type Squad, type SquadOptions, type SquadRun, StoredMessage, StreamObjectError, type StreamObjectEvent, type StreamObjectOptions, SystemPromptResolver, TASK_RESERVED_PREFIXES, Task, type TaskCancelResult, type TaskConfigureOptions, type TaskEvent, type TaskFilter, type TaskHandle, type TaskKind, type TaskState, type TaskStoreOptions, type TaskSubmitOptions, type TaskWorkContext, type TaskWorkFn, Theokit, TheokitAgentError, type TheokitRequestOptions, UsageAccumulator, chargeAndCheckThresholds, computeCost, createAgentFactory, createCounterBudgetTracker, createNoopMemoryProvider, createSquad, definePlugin, defineTool, extractRawId, getPricingEntry, inferApiMode, isValidTaskId, migrateSqliteToLance, mkMemoryId, normalizeUsage, preflightCheck, toShareGptTrajectory, withCwdMutex };