@theokit/sdk 2.15.1 → 2.18.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 (75) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/dist/a2a/index.cjs +981 -208
  3. package/dist/a2a/index.cjs.map +1 -1
  4. package/dist/a2a/index.js +982 -209
  5. package/dist/a2a/index.js.map +1 -1
  6. package/dist/{cron-BxLSz1UH.d.cts → cron-Bbg0mBOv.d.ts} +33 -3
  7. package/dist/{cron-DcaoP7aW.d.ts → cron-ZLSKbDbB.d.cts} +33 -3
  8. package/dist/cron.cjs +945 -196
  9. package/dist/cron.cjs.map +1 -1
  10. package/dist/cron.d.cts +2 -2
  11. package/dist/cron.d.ts +2 -2
  12. package/dist/cron.js +945 -196
  13. package/dist/cron.js.map +1 -1
  14. package/dist/define-tool.d.ts +9 -2
  15. package/dist/{errors-Bart0ptP.d.cts → errors-1tVcX3Fq.d.cts} +1 -1
  16. package/dist/{errors-DJuuubJK.d.ts → errors-qyVYfk9H.d.ts} +1 -1
  17. package/dist/errors.d.cts +2 -2
  18. package/dist/eval.cjs +951 -198
  19. package/dist/eval.cjs.map +1 -1
  20. package/dist/eval.js +951 -198
  21. package/dist/eval.js.map +1 -1
  22. package/dist/event-bus.d.ts +3 -0
  23. package/dist/index.cjs +1082 -224
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +122 -27
  26. package/dist/index.d.ts +122 -27
  27. package/dist/index.js +1082 -226
  28. package/dist/index.js.map +1 -1
  29. package/dist/internal/agent-loop/tool-dispatch.d.ts +3 -1
  30. package/dist/internal/agent-loop/tool-result-guard.d.ts +24 -0
  31. package/dist/internal/agent-loop/tool-timeout.d.ts +23 -0
  32. package/dist/internal/llm/openai.d.ts +13 -0
  33. package/dist/internal/llm/sse.d.ts +13 -1
  34. package/dist/internal/mcp/client.d.ts +1 -1
  35. package/dist/internal/memory/active-memory.d.ts +1 -1
  36. package/dist/internal/persistence/conversation-storage-fs.d.cts +7 -1
  37. package/dist/internal/persistence/conversation-storage-fs.d.ts +7 -1
  38. package/dist/internal/persistence/conversation-storage-memory.d.cts +7 -1
  39. package/dist/internal/persistence/conversation-storage-memory.d.ts +7 -1
  40. package/dist/internal/persistence/pagination.d.cts +8 -0
  41. package/dist/internal/persistence/pagination.d.ts +8 -0
  42. package/dist/internal/plugins/index.cjs +135 -0
  43. package/dist/internal/plugins/index.cjs.map +1 -1
  44. package/dist/internal/plugins/index.js +135 -0
  45. package/dist/internal/plugins/index.js.map +1 -1
  46. package/dist/internal/plugins/manager.d.cts +21 -1
  47. package/dist/internal/plugins/manager.d.ts +21 -1
  48. package/dist/internal/plugins/types.d.cts +40 -0
  49. package/dist/internal/plugins/types.d.ts +40 -0
  50. package/dist/internal/{memory → resilience}/circuit-breaker.d.ts +5 -1
  51. package/dist/internal/runtime/hooks/hooks-frontmatter.d.ts +1 -1
  52. package/dist/internal/runtime/lifecycle/env-policy.d.ts +30 -0
  53. package/dist/internal/runtime/session/agent-session-store.d.ts +1 -0
  54. package/dist/internal/telemetry/span-names.d.ts +7 -1
  55. package/dist/job-queue.d.ts +29 -7
  56. package/dist/permission-engine.d.ts +32 -7
  57. package/dist/{run-DXy_MVwz.d.cts → run-pE-34AAo.d.cts} +64 -3
  58. package/dist/{run-DXy_MVwz.d.ts → run-pE-34AAo.d.ts} +64 -3
  59. package/dist/sandbox/index.cjs +53 -2
  60. package/dist/sandbox/index.cjs.map +1 -1
  61. package/dist/sandbox/index.js +53 -2
  62. package/dist/sandbox/index.js.map +1 -1
  63. package/dist/sandbox/local-sandbox.d.cts +11 -3
  64. package/dist/sandbox/local-sandbox.d.ts +11 -3
  65. package/dist/sandbox/types.d.cts +7 -0
  66. package/dist/sandbox/types.d.ts +7 -0
  67. package/dist/types/agent-prims.d.ts +6 -2
  68. package/dist/types/conversation-storage.d.ts +32 -2
  69. package/dist/types/mcp.d.ts +20 -0
  70. package/dist/types/run.d.ts +17 -0
  71. package/dist/workflow.cjs +6 -3
  72. package/dist/workflow.cjs.map +1 -1
  73. package/dist/workflow.js +6 -3
  74. package/dist/workflow.js.map +1 -1
  75. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { C as CustomTool, M as ModelSelection, G as SDKUserMessage, J as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, U as StreamToCompletionResult, a as McpServerConfig } from './run-DXy_MVwz.cjs';
1
+ import { C as CustomTool, M as ModelSelection, G as SDKUserMessage, J as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, U as StreamToCompletionResult, a as McpServerConfig } from './run-pE-34AAo.js';
2
2
 
3
3
  /**
4
4
  * Fork primitive public type contracts (T1.2, ADRs D110-D114).
@@ -616,20 +616,50 @@ interface StoredMessage {
616
616
  */
617
617
  interface ConversationStorageAdapter {
618
618
  /**
619
- * Return the full message history for a conversation, in insertion order.
619
+ * Return the message history for a conversation, in insertion order.
620
620
  * MUST return `[]` (not throw) when the conversation does not exist.
621
+ *
622
+ * M2 #63 — an optional `{ offset, limit }` window paginates the result so a
623
+ * caller hydrating a long history is not forced to materialize the whole log.
624
+ * Omitting `opts` returns the full history (backward-compatible). `offset`
625
+ * counts from the oldest message; `limit` bounds the returned count.
621
626
  */
622
- getMessages(conversationId: string): Promise<readonly StoredMessage[]>;
627
+ getMessages(conversationId: string, opts?: {
628
+ offset?: number;
629
+ limit?: number;
630
+ }): Promise<readonly StoredMessage[]>;
623
631
  /**
624
632
  * Append a single message to the conversation.
625
633
  * MUST be atomic — concurrent appends MUST NOT corrupt the log.
626
634
  * MUST create the conversation lazily if it does not exist.
627
635
  */
628
636
  appendMessage(conversationId: string, message: StoredMessage): Promise<void>;
637
+ /**
638
+ * M2 #63 — optional batch append: write a whole conversation turn
639
+ * (user + assistant + N tool results) in ONE atomic operation. The default FS
640
+ * adapter uses a single locked `appendFile` (one open per turn instead of N).
641
+ * Adapters that do not implement it fall back to looping `appendMessage`.
642
+ * MUST be atomic as a unit — a partial batch MUST NOT be observable.
643
+ */
644
+ appendMessages?(conversationId: string, messages: readonly StoredMessage[]): Promise<void>;
645
+ /**
646
+ * M3 #67 — revert a conversation back to its first `keepCount` messages
647
+ * ("undo the last turn(s)"). Atomic rewrite; `keepCount <= 0` empties it,
648
+ * `keepCount >= length` is a no-op. Returns the number of messages kept.
649
+ * Transcript-only; adapters that cannot truncate MAY omit it.
650
+ */
651
+ truncateConversation?(conversationId: string, keepCount: number): Promise<number>;
629
652
  /**
630
653
  * Delete the entire conversation. MUST be idempotent (delete-of-missing = ok).
631
654
  */
632
655
  deleteConversation(conversationId: string): Promise<void>;
656
+ /**
657
+ * M3 #62 — delete every conversation whose id starts with `prefix`
658
+ * (e.g. `"temp__"` from {@link sessionScopePrefix}) so a whole session scope
659
+ * can be pruned in one call. Returns the number deleted. Optional — adapters
660
+ * that cannot enumerate MAY omit it.
661
+ */
662
+ deleteScope?(prefix: string): Promise<number>;
633
663
  /**
634
664
  * Optional: list conversation ids. Used by housekeeping flows.
635
665
  * Implementations that cannot enumerate (e.g., wildcards too expensive on
@@ -1,4 +1,4 @@
1
- import { C as CustomTool, M as ModelSelection, G as SDKUserMessage, J as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, U as StreamToCompletionResult, a as McpServerConfig } from './run-DXy_MVwz.js';
1
+ import { C as CustomTool, M as ModelSelection, G as SDKUserMessage, J as SendOptions, b as Run, r as RunToCompletionOptions, s as RunToCompletionResult, S as SDKMessage, U as StreamToCompletionResult, a as McpServerConfig } from './run-pE-34AAo.cjs';
2
2
 
3
3
  /**
4
4
  * Fork primitive public type contracts (T1.2, ADRs D110-D114).
@@ -616,20 +616,50 @@ interface StoredMessage {
616
616
  */
617
617
  interface ConversationStorageAdapter {
618
618
  /**
619
- * Return the full message history for a conversation, in insertion order.
619
+ * Return the message history for a conversation, in insertion order.
620
620
  * MUST return `[]` (not throw) when the conversation does not exist.
621
+ *
622
+ * M2 #63 — an optional `{ offset, limit }` window paginates the result so a
623
+ * caller hydrating a long history is not forced to materialize the whole log.
624
+ * Omitting `opts` returns the full history (backward-compatible). `offset`
625
+ * counts from the oldest message; `limit` bounds the returned count.
621
626
  */
622
- getMessages(conversationId: string): Promise<readonly StoredMessage[]>;
627
+ getMessages(conversationId: string, opts?: {
628
+ offset?: number;
629
+ limit?: number;
630
+ }): Promise<readonly StoredMessage[]>;
623
631
  /**
624
632
  * Append a single message to the conversation.
625
633
  * MUST be atomic — concurrent appends MUST NOT corrupt the log.
626
634
  * MUST create the conversation lazily if it does not exist.
627
635
  */
628
636
  appendMessage(conversationId: string, message: StoredMessage): Promise<void>;
637
+ /**
638
+ * M2 #63 — optional batch append: write a whole conversation turn
639
+ * (user + assistant + N tool results) in ONE atomic operation. The default FS
640
+ * adapter uses a single locked `appendFile` (one open per turn instead of N).
641
+ * Adapters that do not implement it fall back to looping `appendMessage`.
642
+ * MUST be atomic as a unit — a partial batch MUST NOT be observable.
643
+ */
644
+ appendMessages?(conversationId: string, messages: readonly StoredMessage[]): Promise<void>;
645
+ /**
646
+ * M3 #67 — revert a conversation back to its first `keepCount` messages
647
+ * ("undo the last turn(s)"). Atomic rewrite; `keepCount <= 0` empties it,
648
+ * `keepCount >= length` is a no-op. Returns the number of messages kept.
649
+ * Transcript-only; adapters that cannot truncate MAY omit it.
650
+ */
651
+ truncateConversation?(conversationId: string, keepCount: number): Promise<number>;
629
652
  /**
630
653
  * Delete the entire conversation. MUST be idempotent (delete-of-missing = ok).
631
654
  */
632
655
  deleteConversation(conversationId: string): Promise<void>;
656
+ /**
657
+ * M3 #62 — delete every conversation whose id starts with `prefix`
658
+ * (e.g. `"temp__"` from {@link sessionScopePrefix}) so a whole session scope
659
+ * can be pruned in one call. Returns the number deleted. Optional — adapters
660
+ * that cannot enumerate MAY omit it.
661
+ */
662
+ deleteScope?(prefix: string): Promise<number>;
633
663
  /**
634
664
  * Optional: list conversation ids. Used by housekeeping flows.
635
665
  * Implementations that cannot enumerate (e.g., wildcards too expensive on