@combycode/llm-sdk 1.0.0-rc.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 (228) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +21 -0
  3. package/README.md +103 -0
  4. package/dist/agent/approval-types.d.ts +49 -0
  5. package/dist/agent/context-registry/layers.d.ts +39 -0
  6. package/dist/agent/context-registry/registry-internal.d.ts +14 -0
  7. package/dist/agent/context-registry/registry.d.ts +104 -0
  8. package/dist/agent/context-registry/types.d.ts +110 -0
  9. package/dist/agent/guardrail-types.d.ts +58 -0
  10. package/dist/agent/history-types.d.ts +40 -0
  11. package/dist/agent/history.d.ts +111 -0
  12. package/dist/agent/loop-config.d.ts +67 -0
  13. package/dist/agent/loop-internals.d.ts +46 -0
  14. package/dist/agent/loop-step-state.d.ts +20 -0
  15. package/dist/agent/loop.d.ts +133 -0
  16. package/dist/agent/tool-key.d.ts +3 -0
  17. package/dist/agent/types.d.ts +138 -0
  18. package/dist/bus/agent-bus.d.ts +99 -0
  19. package/dist/bus/async-context.browser.d.ts +13 -0
  20. package/dist/bus/async-context.d.ts +11 -0
  21. package/dist/bus/async-context.types.d.ts +14 -0
  22. package/dist/bus/hook-bus.d.ts +43 -0
  23. package/dist/bus/hook-map.d.ts +592 -0
  24. package/dist/helpers/agent.d.ts +32 -0
  25. package/dist/helpers/batch.d.ts +74 -0
  26. package/dist/helpers/calibration-store.d.ts +27 -0
  27. package/dist/helpers/calibration-types.d.ts +64 -0
  28. package/dist/helpers/chain.d.ts +30 -0
  29. package/dist/helpers/client-pool.d.ts +15 -0
  30. package/dist/helpers/client-resolver.d.ts +62 -0
  31. package/dist/helpers/collection.d.ts +19 -0
  32. package/dist/helpers/consolidate.d.ts +66 -0
  33. package/dist/helpers/content.d.ts +25 -0
  34. package/dist/helpers/conversation-export.d.ts +14 -0
  35. package/dist/helpers/conversation-zip.d.ts +28 -0
  36. package/dist/helpers/count-tokens.d.ts +26 -0
  37. package/dist/helpers/define-tool.d.ts +66 -0
  38. package/dist/helpers/delegate.d.ts +6 -0
  39. package/dist/helpers/embed.d.ts +24 -0
  40. package/dist/helpers/engine.d.ts +121 -0
  41. package/dist/helpers/estimate-types.d.ts +67 -0
  42. package/dist/helpers/estimate.d.ts +45 -0
  43. package/dist/helpers/estimator.d.ts +48 -0
  44. package/dist/helpers/handoff-types.d.ts +18 -0
  45. package/dist/helpers/handoff.d.ts +14 -0
  46. package/dist/helpers/llm.d.ts +24 -0
  47. package/dist/helpers/mcp.d.ts +82 -0
  48. package/dist/helpers/media.d.ts +58 -0
  49. package/dist/helpers/models.d.ts +36 -0
  50. package/dist/helpers/moderate-types.d.ts +73 -0
  51. package/dist/helpers/moderate.d.ts +13 -0
  52. package/dist/helpers/moderation-guardrail.d.ts +29 -0
  53. package/dist/helpers/observer.d.ts +36 -0
  54. package/dist/helpers/one-shot.d.ts +86 -0
  55. package/dist/helpers/parallel.d.ts +16 -0
  56. package/dist/helpers/realtime.d.ts +25 -0
  57. package/dist/helpers/route.d.ts +29 -0
  58. package/dist/helpers/select-model.d.ts +41 -0
  59. package/dist/helpers/server.d.ts +32 -0
  60. package/dist/helpers/transcribe.d.ts +36 -0
  61. package/dist/index.browser.js +38047 -0
  62. package/dist/index.d.ts +275 -0
  63. package/dist/index.js +37974 -0
  64. package/dist/llm/audio/voices.d.ts +7 -0
  65. package/dist/llm/client-config.d.ts +37 -0
  66. package/dist/llm/client-internal.d.ts +28 -0
  67. package/dist/llm/client.d.ts +68 -0
  68. package/dist/llm/providers/_shared/constants.d.ts +5 -0
  69. package/dist/llm/providers/_shared/response-utils.d.ts +8 -0
  70. package/dist/llm/providers/anthropic/batch.d.ts +19 -0
  71. package/dist/llm/providers/anthropic/constants.d.ts +13 -0
  72. package/dist/llm/providers/anthropic/files.d.ts +23 -0
  73. package/dist/llm/providers/anthropic/messages.d.ts +30 -0
  74. package/dist/llm/providers/google/batch.d.ts +20 -0
  75. package/dist/llm/providers/google/constants.d.ts +6 -0
  76. package/dist/llm/providers/google/embeddings.d.ts +15 -0
  77. package/dist/llm/providers/google/files.d.ts +22 -0
  78. package/dist/llm/providers/google/generate.d.ts +27 -0
  79. package/dist/llm/providers/google/interactions.d.ts +30 -0
  80. package/dist/llm/providers/google/media.d.ts +27 -0
  81. package/dist/llm/providers/google/realtime.d.ts +27 -0
  82. package/dist/llm/providers/openai/batch.d.ts +19 -0
  83. package/dist/llm/providers/openai/completions.d.ts +25 -0
  84. package/dist/llm/providers/openai/embeddings.d.ts +16 -0
  85. package/dist/llm/providers/openai/files.d.ts +23 -0
  86. package/dist/llm/providers/openai/media.d.ts +28 -0
  87. package/dist/llm/providers/openai/moderations.d.ts +19 -0
  88. package/dist/llm/providers/openai/realtime.d.ts +24 -0
  89. package/dist/llm/providers/openai/responses.d.ts +29 -0
  90. package/dist/llm/providers/openai/tiers.d.ts +13 -0
  91. package/dist/llm/providers/openai/transcription.d.ts +20 -0
  92. package/dist/llm/providers/openrouter/completions.d.ts +15 -0
  93. package/dist/llm/providers/openrouter/embeddings.d.ts +7 -0
  94. package/dist/llm/providers/openrouter/media.d.ts +25 -0
  95. package/dist/llm/providers/openrouter/responses.d.ts +17 -0
  96. package/dist/llm/providers/xai/batch.d.ts +19 -0
  97. package/dist/llm/providers/xai/completions.d.ts +24 -0
  98. package/dist/llm/providers/xai/files.d.ts +23 -0
  99. package/dist/llm/providers/xai/media.d.ts +27 -0
  100. package/dist/llm/providers/xai/responses.d.ts +20 -0
  101. package/dist/llm/realtime/session.d.ts +34 -0
  102. package/dist/llm/realtime/types.d.ts +66 -0
  103. package/dist/llm/server-state.d.ts +32 -0
  104. package/dist/llm/types/audio.d.ts +18 -0
  105. package/dist/llm/types/messages.d.ts +125 -0
  106. package/dist/llm/types/options.d.ts +51 -0
  107. package/dist/llm/types/provider.d.ts +39 -0
  108. package/dist/llm/types/request.d.ts +51 -0
  109. package/dist/llm/types/response.d.ts +36 -0
  110. package/dist/llm/types/schema-utils.d.ts +8 -0
  111. package/dist/llm/types/stream.d.ts +42 -0
  112. package/dist/llm/types/tiers.d.ts +11 -0
  113. package/dist/llm/types/tools.d.ts +20 -0
  114. package/dist/network/engine.d.ts +87 -0
  115. package/dist/network/errors.d.ts +14 -0
  116. package/dist/network/queue-state-config.d.ts +41 -0
  117. package/dist/network/queue-state.d.ts +45 -0
  118. package/dist/network/rate-limiter.d.ts +49 -0
  119. package/dist/network/realtime-connection.d.ts +40 -0
  120. package/dist/network/request-queue.d.ts +40 -0
  121. package/dist/network/semaphore.d.ts +12 -0
  122. package/dist/network/sse.d.ts +3 -0
  123. package/dist/network/types.d.ts +127 -0
  124. package/dist/plugins/batch/batcher.d.ts +45 -0
  125. package/dist/plugins/batch/strategy.d.ts +20 -0
  126. package/dist/plugins/batch/types.d.ts +54 -0
  127. package/dist/plugins/cache/cache.d.ts +50 -0
  128. package/dist/plugins/cache/file-store.d.ts +15 -0
  129. package/dist/plugins/cache/memory-store.d.ts +10 -0
  130. package/dist/plugins/cache/types.d.ts +28 -0
  131. package/dist/plugins/configuration/configuration.d.ts +71 -0
  132. package/dist/plugins/context-guard/facts.d.ts +14 -0
  133. package/dist/plugins/context-guard/guard.d.ts +27 -0
  134. package/dist/plugins/context-guard/strategies/layered.d.ts +24 -0
  135. package/dist/plugins/context-guard/strategies/truncate.d.ts +19 -0
  136. package/dist/plugins/context-guard/tools.d.ts +50 -0
  137. package/dist/plugins/context-guard/types.d.ts +110 -0
  138. package/dist/plugins/context-measurer/calibration/store.d.ts +19 -0
  139. package/dist/plugins/context-measurer/counter/count-api.d.ts +41 -0
  140. package/dist/plugins/context-measurer/counter/heuristic.d.ts +25 -0
  141. package/dist/plugins/context-measurer/counter/hybrid.d.ts +33 -0
  142. package/dist/plugins/context-measurer/counter/tiktoken.d.ts +13 -0
  143. package/dist/plugins/context-measurer/measurer.d.ts +49 -0
  144. package/dist/plugins/context-measurer/types.d.ts +40 -0
  145. package/dist/plugins/cost-collector/collector.d.ts +42 -0
  146. package/dist/plugins/cost-collector/cost-collector-internal.d.ts +58 -0
  147. package/dist/plugins/cost-collector/cost-collector-types.d.ts +42 -0
  148. package/dist/plugins/embeddings/types.d.ts +23 -0
  149. package/dist/plugins/files/attachment.d.ts +79 -0
  150. package/dist/plugins/files/provider-adapter.d.ts +37 -0
  151. package/dist/plugins/files/registry.d.ts +48 -0
  152. package/dist/plugins/files/strategy.d.ts +38 -0
  153. package/dist/plugins/internal-tools/backends/local.d.ts +12 -0
  154. package/dist/plugins/internal-tools/builtin/builtin.d.ts +21 -0
  155. package/dist/plugins/internal-tools/builtin/clarify.d.ts +12 -0
  156. package/dist/plugins/internal-tools/builtin/classify.d.ts +12 -0
  157. package/dist/plugins/internal-tools/builtin/score.d.ts +13 -0
  158. package/dist/plugins/internal-tools/builtin/structure.d.ts +11 -0
  159. package/dist/plugins/internal-tools/builtin/summarize.d.ts +19 -0
  160. package/dist/plugins/internal-tools/id.d.ts +12 -0
  161. package/dist/plugins/internal-tools/registry.d.ts +24 -0
  162. package/dist/plugins/internal-tools/runner/define.d.ts +7 -0
  163. package/dist/plugins/internal-tools/runner/json-enforcement.d.ts +3 -0
  164. package/dist/plugins/internal-tools/runner/runner.d.ts +47 -0
  165. package/dist/plugins/internal-tools/runner/template.d.ts +10 -0
  166. package/dist/plugins/internal-tools/runner/types.d.ts +57 -0
  167. package/dist/plugins/internal-tools/runner/variants.d.ts +34 -0
  168. package/dist/plugins/internal-tools/types.d.ts +80 -0
  169. package/dist/plugins/logger/console-sink.d.ts +26 -0
  170. package/dist/plugins/logger/logger.d.ts +38 -0
  171. package/dist/plugins/logger/types.d.ts +25 -0
  172. package/dist/plugins/mcp/base-transport.d.ts +58 -0
  173. package/dist/plugins/mcp/client.d.ts +92 -0
  174. package/dist/plugins/mcp/jsonrpc.d.ts +20 -0
  175. package/dist/plugins/mcp/oauth.d.ts +122 -0
  176. package/dist/plugins/mcp/sampling.d.ts +17 -0
  177. package/dist/plugins/mcp/tools.d.ts +20 -0
  178. package/dist/plugins/mcp/transport-http.d.ts +50 -0
  179. package/dist/plugins/mcp/transport-stdio.d.ts +23 -0
  180. package/dist/plugins/mcp/transport-ws.d.ts +32 -0
  181. package/dist/plugins/mcp/transport.d.ts +29 -0
  182. package/dist/plugins/mcp/types.d.ts +202 -0
  183. package/dist/plugins/mcp/url-guard.d.ts +70 -0
  184. package/dist/plugins/mcp/win-spawn.d.ts +20 -0
  185. package/dist/plugins/media/file-store.d.ts +24 -0
  186. package/dist/plugins/media/memory-store.d.ts +17 -0
  187. package/dist/plugins/media/output.d.ts +44 -0
  188. package/dist/plugins/media/source-image.d.ts +36 -0
  189. package/dist/plugins/media/types.d.ts +146 -0
  190. package/dist/plugins/model-catalog/catalog.d.ts +152 -0
  191. package/dist/plugins/permissions/glob.d.ts +6 -0
  192. package/dist/plugins/permissions/matchers.d.ts +7 -0
  193. package/dist/plugins/permissions/policy.d.ts +10 -0
  194. package/dist/plugins/permissions/types.d.ts +22 -0
  195. package/dist/plugins/persistence/file.d.ts +25 -0
  196. package/dist/plugins/persistence/memory.d.ts +23 -0
  197. package/dist/plugins/persistence/types.d.ts +21 -0
  198. package/dist/plugins/retrieval/chunker.d.ts +28 -0
  199. package/dist/plugins/retrieval/hosted-google.d.ts +60 -0
  200. package/dist/plugins/retrieval/hosted-openai.d.ts +45 -0
  201. package/dist/plugins/retrieval/hosted-xai.d.ts +57 -0
  202. package/dist/plugins/retrieval/index.d.ts +70 -0
  203. package/dist/plugins/retrieval/local.d.ts +50 -0
  204. package/dist/plugins/retrieval/types.d.ts +161 -0
  205. package/dist/plugins/retrieval/vector-store.d.ts +70 -0
  206. package/dist/plugins/scheduler/scheduler.d.ts +31 -0
  207. package/dist/plugins/telemetry/telemetry.d.ts +118 -0
  208. package/dist/plugins/tool-catalog/catalog.d.ts +31 -0
  209. package/dist/plugins/tool-catalog/errors.d.ts +22 -0
  210. package/dist/plugins/tool-catalog/types.d.ts +44 -0
  211. package/dist/runtime/runtime.d.ts +20 -0
  212. package/dist/server/auth.d.ts +25 -0
  213. package/dist/server/dispatch.d.ts +35 -0
  214. package/dist/server/loaders.d.ts +26 -0
  215. package/dist/server/oai-adapter.d.ts +30 -0
  216. package/dist/server/oai-types.d.ts +114 -0
  217. package/dist/server/response-store.d.ts +59 -0
  218. package/dist/server/router.d.ts +59 -0
  219. package/dist/server/server.d.ts +61 -0
  220. package/dist/types/request-context.d.ts +46 -0
  221. package/dist/util/async.d.ts +3 -0
  222. package/dist/util/base64.d.ts +8 -0
  223. package/dist/util/duration.d.ts +12 -0
  224. package/dist/util/http.d.ts +9 -0
  225. package/dist/util/image-mime.d.ts +8 -0
  226. package/dist/util/json-schema.d.ts +7 -0
  227. package/dist/util/wav.d.ts +20 -0
  228. package/package.json +95 -0
@@ -0,0 +1,121 @@
1
+ /** createEngine — build an EngineHandle bag of plugin instances.
2
+ *
3
+ * The EngineHandle is a thin coordinator: shared HookBus + AgentBus,
4
+ * optional persistence/cache, NetworkEngine (which owns multi-queue HTTP),
5
+ * and convenience accessors for downstream helpers. Classes never consult
6
+ * the engine directly; only the createLLM/createAgent/createServer helpers
7
+ * resolve fetch/hooks against it.
8
+ *
9
+ * Usage:
10
+ *
11
+ * const engine = createEngine({
12
+ * persistence: { type: 'file', dir: './data' },
13
+ * cache: { type: 'memory' },
14
+ * });
15
+ *
16
+ * const llm = createLLM({ provider: 'anthropic', model: '...', apiKey: '...' });
17
+ * // llm.client uses engine.fetch + engine.hooks automatically. */
18
+ import { AgentBus } from '../bus/agent-bus';
19
+ import { HookBus } from '../bus/hook-bus';
20
+ import type { ProviderName } from '../llm/types/provider';
21
+ import { NetworkEngine } from '../network/engine';
22
+ import type { EngineConnect, EngineFetch, EngineFetchStream, FetchFn } from '../network/types';
23
+ import { Cache } from '../plugins/cache/cache';
24
+ import { CostCollector } from '../plugins/cost-collector/collector';
25
+ import { ModelCatalog } from '../plugins/model-catalog/catalog';
26
+ import type { Persistence } from '../plugins/persistence/types';
27
+ export interface EngineHandle {
28
+ /** Trace session id — minted once for this engine (the holder), shared by
29
+ * every request built against it. The session half of the OTel trace id. */
30
+ sessionId: string;
31
+ /** Shared HookBus across all subsystems built against this engine. */
32
+ hooks: HookBus;
33
+ /** Shared AgentBus for plugin → tool / module event communication. */
34
+ bus: AgentBus;
35
+ /** Persistence plugin. Always present — defaults to in-memory when no
36
+ * `persistence` option was passed to `createEngine`. */
37
+ persistence: Persistence;
38
+ /** Optional Cache plugin. */
39
+ cache: Cache | null;
40
+ /** Network engine — owns the queue map and fetch lifecycle. */
41
+ network: NetworkEngine;
42
+ /** Bound NetworkEngine.fetch (function reference for LLMClient injection). */
43
+ fetch: EngineFetch;
44
+ /** Bound NetworkEngine.fetchStream. */
45
+ fetchStream: EngineFetchStream;
46
+ /** Bound NetworkEngine.connect — opens a realtime WebSocket (queue-exempt). */
47
+ connect: EngineConnect;
48
+ /** ModelCatalog. Always present — populated synchronously with provider
49
+ * defaults when `engine.catalog: 'defaults'` (or `true`), else empty.
50
+ * CostCollector / MediaOutput / ContextGuard / ContextMeasurer all
51
+ * consult this. */
52
+ catalog: ModelCatalog;
53
+ /** CostCollector — subscribes to onCompletion + onMediaGenerated and
54
+ * prices via catalog. Call `engine.cost.total()` for a running tally. */
55
+ cost: CostCollector;
56
+ /** API keys per provider. Helpers (createLLM, createAgent,
57
+ * createMediaOutput, complete) read these to wire LLM clients without
58
+ * the caller passing apiKey explicitly. */
59
+ apiKeys: Partial<Record<ProviderName, string>>;
60
+ /** Tear down all owned plugins. */
61
+ destroy(): void;
62
+ }
63
+ export interface PersistenceConfig {
64
+ type: 'memory' | 'file';
65
+ /** When type='file': directory under which entries are stored. */
66
+ dir?: string;
67
+ }
68
+ export interface CacheConfig {
69
+ type: 'memory';
70
+ }
71
+ export interface EngineConfig {
72
+ /** Trace session id. Pass one from a parent holder (server / orchestrator) to
73
+ * correlate; omitted → a fresh `sess_…` is minted for this engine's lifetime. */
74
+ sessionId?: string;
75
+ /** Optional shared HookBus — when omitted, a fresh one is created. */
76
+ hooks?: HookBus;
77
+ /** Optional shared AgentBus. */
78
+ bus?: AgentBus;
79
+ /** Optional persistence backing for plugins that want durability. */
80
+ persistence?: PersistenceConfig | Persistence;
81
+ /** Optional cache. */
82
+ cache?: CacheConfig | Cache;
83
+ /** Custom low-level fetch transport — forwarded to the NetworkEngine's queue
84
+ * (so retry/rate-limit/hooks still apply). Defaults to globalThis.fetch. */
85
+ fetch?: FetchFn;
86
+ /** Catalog wiring. Pass:
87
+ * - `true` / 'defaults' → load every bundled provider catalog.json
88
+ * - existing ModelCatalog instance → use as-is
89
+ * - `{ entries: {...} }` → build empty + load() the entries
90
+ * - undefined → empty catalog */
91
+ catalog?: ModelCatalog | true | 'defaults' | {
92
+ entries: Record<string, unknown>;
93
+ };
94
+ /** Per-provider API keys. Helpers consult this when no apiKey is passed
95
+ * alongside `model: 'provider/...'`. */
96
+ apiKeys?: Partial<Record<ProviderName, string>>;
97
+ /** Register this engine as the default for `coreRegistry.get()` (used by
98
+ * helpers when the caller doesn't pass an explicit `engine`). Defaults to
99
+ * `true` so `createEngine({ ... })` followed by helper calls just works.
100
+ * The FIRST `createEngine()` becomes the default; a second one throws unless
101
+ * you pass `registerAsDefault: false` (then pass that engine explicitly to
102
+ * helpers). */
103
+ registerAsDefault?: boolean;
104
+ }
105
+ export declare function createEngine(config?: EngineConfig): EngineHandle;
106
+ declare class CoreRegistry {
107
+ private current;
108
+ /** Get the current default engine, creating a bare one on first read. */
109
+ get(): EngineHandle;
110
+ /** Set the default engine. Throws if one is already set unless replace=true.
111
+ * When replacing, the previous engine is destroyed AFTER the pointer
112
+ * swap so engine.destroy callbacks can safely query the registry. */
113
+ set(engine: EngineHandle, opts?: {
114
+ replace?: boolean;
115
+ }): void;
116
+ /** Clear the default engine. */
117
+ clear(): void;
118
+ has(): boolean;
119
+ }
120
+ export declare const coreRegistry: CoreRegistry;
121
+ export {};
@@ -0,0 +1,67 @@
1
+ /** estimate() — public types and error classes.
2
+ * Extracted per project convention (no inline types in impl files). */
3
+ /** How many output tokens to assume when none are specified.
4
+ * Callers can override via `opts.expectedOutputTokens`. */
5
+ export declare const DEFAULT_EXPECTED_OUTPUT_TOKENS = 512;
6
+ /** Fallback model max-output cap when the catalog does not list one for a
7
+ * model. Used only for the `high` (worst-case) bound; deliberately
8
+ * conservative rather than 0 so callers get a real upper-bound. */
9
+ export declare const FALLBACK_MAX_OUTPUT_TOKENS = 4096;
10
+ /** The three cost bounds `estimate()` returns. */
11
+ export type EstimateBound = 'low' | 'expected' | 'high';
12
+ /** Breakdown of the estimate by cost category (USD). */
13
+ export interface EstimateBreakdown {
14
+ /** Cost of the input tokens. */
15
+ inputUsd: number;
16
+ /** Cost of the output tokens (varies by bound). */
17
+ outputUsd: number;
18
+ /** Per-image cost when present (not yet computed — see assumptions). */
19
+ imageUsd?: number;
20
+ /** Audio-input cost when present (not yet computed — see assumptions). */
21
+ audioUsd?: number;
22
+ }
23
+ /** The full result of `estimate()`. */
24
+ export interface EstimateResult {
25
+ model: string;
26
+ /** Input tokens counted (or estimated) from the request. */
27
+ inputTokens: number;
28
+ /** Output tokens used for the `expected` bound. */
29
+ estOutputTokens: number;
30
+ cost: {
31
+ /** 0 output tokens (just input cost). */
32
+ low: number;
33
+ /** `estOutputTokens` output tokens. */
34
+ expected: number;
35
+ /** `maxTokens` or the model's maxOutput cap output tokens. */
36
+ high: number;
37
+ };
38
+ breakdown: EstimateBreakdown;
39
+ currency: 'USD';
40
+ /** Human-readable notes explaining assumptions made during estimation. */
41
+ assumptions: string[];
42
+ }
43
+ /** Thrown when `estimate()` is called with a model that is not in the catalog.
44
+ * Distinct from `LLMError` because no network call was made. */
45
+ export declare class UnknownModelError extends Error {
46
+ readonly provider: string;
47
+ readonly model: string;
48
+ constructor(provider: string, model: string);
49
+ }
50
+ /** Thrown by the budget guard when the estimated cost for the chosen `bound`
51
+ * exceeds the caller-supplied `maxCostUsd` limit. */
52
+ export declare class BudgetExceededError extends Error {
53
+ /** The bound that was checked ('low' | 'expected' | 'high'). */
54
+ readonly bound: EstimateBound;
55
+ /** The estimate that triggered the guard. */
56
+ readonly estimate: EstimateResult;
57
+ /** The limit that was exceeded (USD). */
58
+ readonly maxCostUsd: number;
59
+ /** The cost for the checked bound (USD). */
60
+ readonly costUsd: number;
61
+ constructor(opts: {
62
+ bound: EstimateBound;
63
+ estimate: EstimateResult;
64
+ maxCostUsd: number;
65
+ costUsd: number;
66
+ });
67
+ }
@@ -0,0 +1,45 @@
1
+ /** estimate() — pure, pre-flight cost estimation. Sends nothing to the
2
+ * network. Counts input tokens via the existing HybridTokenCounter (which
3
+ * falls back to a heuristic when tiktoken is absent), then prices using the
4
+ * ModelCatalog exactly as CostCollector does at runtime.
5
+ *
6
+ * const est = await estimate({
7
+ * model: 'anthropic/claude-haiku-4-5',
8
+ * prompt: 'Hello',
9
+ * });
10
+ * // est.cost.expected — mid-range cost in USD
11
+ * // est.cost.high — worst-case (output = maxOutput cap)
12
+ */
13
+ import type { ContentPart, Message } from '../llm/types/messages';
14
+ import type { ProviderName } from '../llm/types/provider';
15
+ import { type EngineHandle } from './engine';
16
+ import type { EstimateResult } from './estimate-types';
17
+ export interface EstimateRequest {
18
+ /** Model string: bare (`gpt-5.4-nano` + `provider`) or namespaced
19
+ * (`openai/gpt-5.4-nano`). */
20
+ model: string;
21
+ /** Required when `model` is bare. */
22
+ provider?: ProviderName;
23
+ /** Either a string prompt, an array of content parts, or a messages array.
24
+ * Matches the `prompt` field on `CompleteOptions`. */
25
+ prompt: string | ContentPart[] | Message[];
26
+ /** Optional system prompt — included in input-token count. */
27
+ system?: string;
28
+ /** Hard limit on output tokens (used for the `high` bound). */
29
+ maxTokens?: number;
30
+ }
31
+ export interface EstimateOptions {
32
+ /** Override the model (else taken from `request.model`). */
33
+ model?: string;
34
+ /** Caller's guess for the expected output token count. When absent, the
35
+ * helper uses `DEFAULT_EXPECTED_OUTPUT_TOKENS` and notes it in
36
+ * `assumptions`. */
37
+ expectedOutputTokens?: number;
38
+ /** Optional engine for catalog + api-key access. Falls back to coreRegistry. */
39
+ engine?: EngineHandle;
40
+ }
41
+ /** Pre-flight cost estimate. Pure — touches no network, no LLM provider.
42
+ *
43
+ * Throws `UnknownModelError` when the model is absent from the catalog
44
+ * (so callers never silently get $0 instead of a real estimate). */
45
+ export declare function estimate(request: EstimateRequest, opts?: EstimateOptions): Promise<EstimateResult>;
@@ -0,0 +1,48 @@
1
+ /** estimator.ts — Estimator class: static estimate() + optional adaptive
2
+ * calibration (EWMA mean + histogram p90 per provider/model/input-bucket).
3
+ *
4
+ * Usage (opt-in calibration):
5
+ *
6
+ * const estimator = new Estimator({ calibration: { store: 'file', path: './data' } });
7
+ *
8
+ * // Wire it to the engine so completions are recorded automatically:
9
+ * const unsub = estimator.subscribeToEngine(engine);
10
+ *
11
+ * // Use calibrated estimates:
12
+ * const est = await estimator.estimate({ model: 'anthropic/claude-haiku-4-5', prompt: 'Hi' });
13
+ * // est.cost.expected uses the EWMA mean (after data accumulates)
14
+ * // est.cost.high uses the p90 (capped at model ceiling)
15
+ * // est.assumptions records calibration source + count
16
+ *
17
+ * Calling without calibration config is identical to the free estimate() fn. */
18
+ import type { HookBus } from '../bus/hook-bus';
19
+ import type { CompletionContext } from '../bus/hook-map';
20
+ import { type EngineHandle } from './engine';
21
+ import type { EstimateRequest } from './estimate';
22
+ import { DEFAULT_EXPECTED_OUTPUT_TOKENS } from './estimate-types';
23
+ import type { EstimateResult } from './estimate-types';
24
+ import type { EstimatorOptions, CalibrationObservation } from './calibration-types';
25
+ export type { EstimatorOptions } from './calibration-types';
26
+ export declare class Estimator {
27
+ private readonly calibrationStore;
28
+ constructor(opts?: EstimatorOptions);
29
+ /** Pre-flight cost estimate. When calibration is enabled AND the key has
30
+ * data, uses the learned EWMA mean for `expected` and learned p90 (capped)
31
+ * for `high`. Otherwise falls back to the exact static estimate() behavior. */
32
+ estimate(request: EstimateRequest, opts?: import('./estimate').EstimateOptions): Promise<EstimateResult>;
33
+ /** Record one completion observation into the calibration store.
34
+ * This is the manual "feed" path; subscribeToEngine() wires it automatically. */
35
+ record(obs: CalibrationObservation): Promise<void>;
36
+ /** Subscribe to an engine's onCompletion hook so every real completion
37
+ * automatically updates the calibration store.
38
+ * Returns an unsubscribe function. */
39
+ subscribeToEngine(engine: EngineHandle): () => void;
40
+ /** Subscribe directly to a HookBus (for advanced wiring). */
41
+ subscribeToHooks(hooks: HookBus): () => void;
42
+ private applyCalibratedBounds;
43
+ }
44
+ /** Compute and record a CalibrationObservation from raw CompletionContext fields.
45
+ * Exported so tests can call it without a full engine wiring. */
46
+ export declare function observationFromCompletion(ctx: CompletionContext): CalibrationObservation;
47
+ /** Default_expected fallback re-exported for callers who import from Estimator. */
48
+ export { DEFAULT_EXPECTED_OUTPUT_TOKENS };
@@ -0,0 +1,18 @@
1
+ /** Types for the handoff() helper — structured agent-to-agent delegation.
2
+ * Extracted per the library rule: types in *-types.ts, never inline. */
3
+ import type { Usage } from '../llm/types/response';
4
+ /** The structured result returned by a handoff tool call. */
5
+ export interface HandoffResult {
6
+ /** Plain text response from the sub-agent. */
7
+ text: string;
8
+ /** Token usage reported by the sub-agent's run. Null when not available. */
9
+ usage: Usage | null;
10
+ /** The sub-agent's display name (passed as `name` to handoff()). */
11
+ agentName: string;
12
+ }
13
+ /** Options for handoff(). */
14
+ export interface HandoffOptions {
15
+ /** Transform the task string before passing it to the sub-agent.
16
+ * Useful for reformatting or adding context without modifying the parent's input. */
17
+ inputFilter?: (task: string) => string;
18
+ }
@@ -0,0 +1,14 @@
1
+ /** handoff — richer sibling to delegate().
2
+ *
3
+ * Wraps an AgentLoop as an AgentTool but returns a structured HandoffResult
4
+ * (text + usage + agentName) serialised as JSON, rather than bare text.
5
+ * The parent loop sees usage and routing metadata in the tool result.
6
+ *
7
+ * Like delegate(), it is a normal AgentTool so it flows through
8
+ * onToolCallStart — approval gates or hook overrides still apply.
9
+ *
10
+ * delegate() is kept unchanged for back-compat; handoff() is the richer path. */
11
+ import type { AgentLoop } from '../agent/loop';
12
+ import type { AgentTool } from '../agent/types';
13
+ import type { HandoffOptions } from './handoff-types';
14
+ export declare function handoff(name: string, description: string, agent: AgentLoop, opts?: HandoffOptions): AgentTool;
@@ -0,0 +1,24 @@
1
+ /** createLLM — convenience helper that builds an LLMClient using the
2
+ * current EngineHandle (or the global coreRegistry default) for fetch +
3
+ * hooks. Auto-resolves a default ProviderAdapter when none is supplied
4
+ * (anthropic/openai/google/xai/openrouter). Accepts model in either
5
+ * flat form (`{provider, model, apiKey}`) or namespaced form
6
+ * (`{model: 'provider/name'}` — apiKey looked up on engine.apiKeys). */
7
+ import { LLMClient } from '../llm/client';
8
+ import type { LLMClientConfig } from '../llm/client-config';
9
+ import type { ProviderName } from '../llm/types/provider';
10
+ import type { EngineHandle } from './engine';
11
+ export interface CreateLLMOptions extends Omit<LLMClientConfig, 'provider' | 'apiKey' | 'model' | 'fetch' | 'fetchStream' | 'hooks'> {
12
+ /** Model string. Either bare (e.g. `claude-haiku-4-5` — pair with `provider`)
13
+ * or namespaced (e.g. `anthropic/claude-haiku-4-5` — provider parsed). */
14
+ model: string;
15
+ /** Required when `model` is bare. Ignored when `model` is namespaced. */
16
+ provider?: ProviderName;
17
+ /** Optional — falls back to `engine.apiKeys[provider]` when omitted. */
18
+ apiKey?: string;
19
+ engine?: EngineHandle;
20
+ hooks?: LLMClientConfig['hooks'];
21
+ fetch?: LLMClientConfig['fetch'];
22
+ fetchStream?: LLMClientConfig['fetchStream'];
23
+ }
24
+ export declare function createLLM(opts: CreateLLMOptions): LLMClient;
@@ -0,0 +1,82 @@
1
+ /** Public MCP entry points.
2
+ *
3
+ * `connectMcp(config)` — connect to one MCP server (url = Streamable HTTP,
4
+ * command = stdio) and get its tools as `AgentTool[]`, ready to drop into
5
+ * `complete()` / `createAgent()` with any provider.
6
+ * `mcpToolset(configs)` — connect to several servers and get one flat toolset.
7
+ *
8
+ * Client-side execution: the model sees ordinary function tools; our loop runs
9
+ * `tools/call`. Works identically across every provider. See docs/design/mcp.md. */
10
+ import type { AgentTool } from '../agent/types';
11
+ import { McpClient } from '../plugins/mcp/client';
12
+ import { type McpAuthProvider } from '../plugins/mcp/oauth';
13
+ import type { SsrfGuardOptions } from '../plugins/mcp/url-guard';
14
+ import { type McpSamplingConfig } from '../plugins/mcp/sampling';
15
+ import { type McpElicitRequestParams, type McpElicitResult, type McpInitializeResult, type McpRoot, type McpServerConfig } from '../plugins/mcp/types';
16
+ import { type EngineHandle } from './engine';
17
+ export interface ConnectMcpOptions {
18
+ /** Engine providing `fetch`/`fetchStream` for HTTP transports. Default: the registered core engine. */
19
+ engine?: EngineHandle;
20
+ clientInfo?: {
21
+ name: string;
22
+ version: string;
23
+ };
24
+ /** Per-request timeout (ms). */
25
+ timeoutMs?: number;
26
+ /** Namespace for tool names. Default: server name / url host / command basename. */
27
+ namespace?: string;
28
+ /** Every server->client notification (logging, *_changed, progress, …). */
29
+ onNotification?: (method: string, params: unknown) => void;
30
+ /** Re-list tools on `notifications/tools/list_changed` (updates `connection.tools` in place). */
31
+ autoRefreshTools?: boolean;
32
+ /** Called after an auto-refresh with the updated tool list. */
33
+ onToolsChanged?: (tools: AgentTool[]) => void;
34
+ /** Enable sampling: fulfill the server's `sampling/createMessage` with our LLM
35
+ * (pass a model id) or a custom handler. Declares the `sampling` capability. */
36
+ sampling?: McpSamplingConfig;
37
+ /** Enable elicitation: answer the server's `elicitation/create`. Declares the capability. */
38
+ elicit?: (params: McpElicitRequestParams) => Promise<McpElicitResult>;
39
+ /** Expose filesystem roots to the server (`roots/list`). Declares the capability. */
40
+ roots?: McpRoot[] | (() => McpRoot[] | Promise<McpRoot[]>);
41
+ /** Validate tool `structuredContent` against the tool's `outputSchema`. */
42
+ validateOutput?: boolean;
43
+ /** Send a `ping` every N ms to keep the connection alive (0 = off). */
44
+ keepAliveMs?: number;
45
+ /** OAuth provider for servers that require authorization (HTTP only). On a
46
+ * required interactive grant, `connectMcp` throws `McpUnauthorizedError`
47
+ * after the provider redirects; finish with `finishMcpAuth`, then reconnect. */
48
+ auth?: McpAuthProvider;
49
+ /** SSRF security options for the OAuth flow. All options default to the most
50
+ * restrictive posture (https-only, no loopback, same-origin). Use
51
+ * `allowInsecureHttp`/`allowLoopback` ONLY for local development. */
52
+ security?: SsrfGuardOptions;
53
+ }
54
+ export interface McpConnection {
55
+ /** The server's initialize result (capabilities, serverInfo). */
56
+ readonly serverInfo: McpInitializeResult | null;
57
+ /** The server's tools, namespaced and ready for the loop. */
58
+ readonly tools: AgentTool[];
59
+ /** Re-fetch the tool list (returns freshly-wrapped AgentTools). */
60
+ listTools(): Promise<AgentTool[]>;
61
+ /** The underlying client (resources/prompts/logging/low-level access). */
62
+ readonly client: McpClient;
63
+ /** Disconnect (kill the process / terminate the HTTP session). */
64
+ close(): Promise<void>;
65
+ }
66
+ /** Connect to a single MCP server and return its tools + lifecycle handle. */
67
+ export declare function connectMcp(config: McpServerConfig, opts?: ConnectMcpOptions): Promise<McpConnection>;
68
+ /** Connect to several MCP servers and return one combined, namespaced toolset. */
69
+ /** Finish an interactive OAuth grant: exchange the callback `code` for tokens
70
+ * (saved via the provider). The `state` from the authorization callback MUST
71
+ * be provided and is validated against the persisted value (CSRF guard).
72
+ * Call after catching `McpUnauthorizedError`, then `connectMcp` again. */
73
+ export declare function finishMcpAuth(serverUrl: string, code: string, state: string, opts: {
74
+ auth: McpAuthProvider;
75
+ engine?: EngineHandle;
76
+ security?: SsrfGuardOptions;
77
+ }): Promise<void>;
78
+ export declare function mcpToolset(configs: McpServerConfig[], opts?: ConnectMcpOptions): Promise<{
79
+ tools: AgentTool[];
80
+ connections: McpConnection[];
81
+ close(): Promise<void>;
82
+ }>;
@@ -0,0 +1,58 @@
1
+ /** createMediaOutput — convenience wrapper around MediaOutput.
2
+ *
3
+ * Pass a `model: 'provider/...'` string and a `dir`; the helper:
4
+ * - builds a FileMediaStore at `dir`,
5
+ * - threads engine.fetch + hooks + catalog,
6
+ * - auto-registers the right MediaProviderAdapter for the model's
7
+ * provider (using engine.apiKeys[provider] for credentials),
8
+ * - returns a MediaOutputHandle whose `generateImage / generateAudio /
9
+ * generateVideo` methods don't repeat provider+model — the configured
10
+ * defaults flow through.
11
+ *
12
+ * Override the auto-built adapter via `providers` if you need a custom
13
+ * baseURL or shared instance. */
14
+ import type { ProviderName } from '../llm/types/provider';
15
+ import { MediaOutput, type MediaOutputInit } from '../plugins/media/output';
16
+ import type { AudioGenRequest, ImageEditRequest, ImageGenRequest, MediaProviderAdapter, MediaResult, MediaStore, VideoGenRequest } from '../plugins/media/types';
17
+ import type { EngineHandle } from './engine';
18
+ type ProviderAdapterMap = Partial<Record<string, MediaProviderAdapter>>;
19
+ export interface CreateMediaOutputOptions {
20
+ /** Directory where generated media bytes + metadata land (Node/Bun). Provide
21
+ * this OR `store`. */
22
+ dir?: string;
23
+ /** Bring your own MediaStore. Use `new MemoryMediaStore()` in the browser
24
+ * (FileMediaStore needs a filesystem). Takes precedence over `dir`. */
25
+ store?: MediaStore;
26
+ /** Default model. Either bare (`gpt-image-1`, paired with `provider`) or
27
+ * namespaced (`openai/gpt-image-1`). The helper builds the matching
28
+ * adapter automatically when not overridden via `providers`. */
29
+ model?: string;
30
+ /** Required when `model` is bare or omitted. */
31
+ provider?: ProviderName;
32
+ /** Optional — falls back to `engine.apiKeys[provider]`. */
33
+ apiKey?: string;
34
+ /** Override or extend the auto-built provider adapter map. */
35
+ providers?: ProviderAdapterMap;
36
+ engine?: EngineHandle;
37
+ config?: MediaOutputInit['config'];
38
+ }
39
+ export interface MediaOutputHandle {
40
+ /** Underlying MediaOutput, in case you need to register more providers
41
+ * or call methods that don't have a defaulting wrapper here. */
42
+ raw: MediaOutput;
43
+ /** Generate one or more images. `provider` and `model` default to the
44
+ * ones passed to `createMediaOutput`. */
45
+ generateImage(req?: PartialMediaReq<ImageGenRequest>): Promise<MediaResult[]>;
46
+ generateAudio(req?: PartialMediaReq<AudioGenRequest>): Promise<MediaResult>;
47
+ editImage(req: PartialMediaReq<ImageEditRequest>): Promise<MediaResult[]>;
48
+ generateVideo(req?: PartialMediaReq<VideoGenRequest>): Promise<MediaResult>;
49
+ }
50
+ type PartialMediaReq<T extends {
51
+ provider: string;
52
+ model?: string;
53
+ }> = Omit<T, 'provider' | 'model'> & {
54
+ provider?: string;
55
+ model?: string;
56
+ };
57
+ export declare function createMediaOutput(opts: CreateMediaOutputOptions): MediaOutputHandle;
58
+ export {};
@@ -0,0 +1,36 @@
1
+ /** Model listing.
2
+ *
3
+ * `listModels()` — the SDK's curated local catalog (sync, no network). The
4
+ * fast primary answer: ModelInfo with pricing + capabilities.
5
+ *
6
+ * `listModelsLive()` — live availability from the provider's /models endpoint,
7
+ * ENRICHED by default (merged with the frozen catalog; for OpenRouter, which
8
+ * isn't bundled, built straight from the live API incl. prices). Pass
9
+ * `{ raw: true }` for bare id strings. Results are cached IN MEMORY for 24h
10
+ * (override with `refresh: true`). */
11
+ import type { ProviderName } from '../llm/types/provider';
12
+ import type { ModelInfo } from '../plugins/model-catalog/catalog';
13
+ import { type EngineHandle } from './engine';
14
+ /** Curated local catalog (the main answer). */
15
+ export declare function listModels(opts?: {
16
+ provider?: ProviderName;
17
+ engine?: EngineHandle;
18
+ }): ModelInfo[];
19
+ export interface ListModelsLiveOptions {
20
+ provider: ProviderName;
21
+ apiKey?: string;
22
+ engine?: EngineHandle;
23
+ /** Return bare id strings instead of enriched ModelInfo. */
24
+ raw?: boolean;
25
+ /** Bypass the 24h memory cache and re-fetch. */
26
+ refresh?: boolean;
27
+ }
28
+ /** Test/maintenance hook. */
29
+ export declare function clearLiveModelsCache(): void;
30
+ /** Live models — enriched ModelInfo by default; `raw:true` → bare id strings.
31
+ * Cached in memory for 24h (use `refresh:true` to force). Routes through
32
+ * engine.fetch like every other call (central queue, hooks, rate-limit). */
33
+ export declare function listModelsLive(opts: ListModelsLiveOptions & {
34
+ raw: true;
35
+ }): Promise<string[]>;
36
+ export declare function listModelsLive(opts: ListModelsLiveOptions): Promise<ModelInfo[]>;
@@ -0,0 +1,73 @@
1
+ /** Types for the moderate() helper and the OpenAI Moderations API. */
2
+ import type { ProviderName } from '../llm/types/provider';
3
+ import type { EngineHandle } from './engine';
4
+ /** Boolean flags per harm category. */
5
+ export interface ModerationCategories {
6
+ harassment: boolean;
7
+ 'harassment/threatening': boolean;
8
+ hate: boolean;
9
+ 'hate/threatening': boolean;
10
+ illicit: boolean;
11
+ 'illicit/violent': boolean;
12
+ 'self-harm': boolean;
13
+ 'self-harm/intent': boolean;
14
+ 'self-harm/instructions': boolean;
15
+ 'sexual': boolean;
16
+ 'sexual/minors': boolean;
17
+ violence: boolean;
18
+ 'violence/graphic': boolean;
19
+ }
20
+ /** Confidence scores (0-1) per harm category -- parallel shape to ModerationCategories. */
21
+ export type ModerationScores = Record<keyof ModerationCategories, number>;
22
+ /** One item's moderation result (one per input element). */
23
+ export interface ModerationResult {
24
+ /** True when any category was triggered. */
25
+ flagged: boolean;
26
+ /** Per-category boolean flags. */
27
+ categories: ModerationCategories;
28
+ /** Per-category confidence scores (0-1). */
29
+ categoryScores: ModerationScores;
30
+ /** Input types the moderation was applied to, per category (omni models only). */
31
+ categoryAppliedInputTypes?: Record<string, string[]>;
32
+ }
33
+ /** A text content part for multimodal moderation input. */
34
+ export interface ModerationTextPart {
35
+ type: 'text';
36
+ text: string;
37
+ }
38
+ /** An image URL content part for multimodal moderation input. */
39
+ export interface ModerationImageUrlPart {
40
+ type: 'image_url';
41
+ image_url: {
42
+ url: string;
43
+ };
44
+ }
45
+ /** A single content part: text or image_url. */
46
+ export type ModerationContentPart = ModerationTextPart | ModerationImageUrlPart;
47
+ /** Options for the moderate() helper. */
48
+ export interface ModerateOptions {
49
+ /**
50
+ * Input to moderate. One of:
51
+ * - a single string (returns a single ModerationResult)
52
+ * - an array of strings (returns one result per string)
53
+ * - a single content-part array (text + image_url, returns a single ModerationResult)
54
+ * - an array of content-part arrays (one per item, returns one result per array)
55
+ */
56
+ input: string | string[] | ModerationContentPart[] | ModerationContentPart[][];
57
+ /** Model name. Defaults to omni-moderation-latest. */
58
+ model?: string;
59
+ provider?: ProviderName;
60
+ apiKey?: string;
61
+ engine?: EngineHandle;
62
+ }
63
+ export interface ModerationRawResult {
64
+ flagged: boolean;
65
+ categories: Record<string, boolean>;
66
+ category_scores: Record<string, number>;
67
+ category_applied_input_types?: Record<string, string[]>;
68
+ }
69
+ export interface ModerationRawResponse {
70
+ id: string;
71
+ model: string;
72
+ results: ModerationRawResult[];
73
+ }
@@ -0,0 +1,13 @@
1
+ /** moderate() -- one-shot content moderation via OpenAI's moderations API.
2
+ *
3
+ * const result = await moderate({ input: 'some text' });
4
+ * if (result.flagged) { ... }
5
+ *
6
+ * When input is a string or content-part array, a single ModerationResult is
7
+ * returned. When input is an array of strings (or array of content-part arrays),
8
+ * one ModerationResult per element is returned (matching array length).
9
+ *
10
+ * The moderations endpoint is FREE; an honest-zero cost entry is always emitted
11
+ * so the cost ledger has a record of each call. HTTP flows through engine.fetch. */
12
+ import type { ModerateOptions, ModerationResult } from './moderate-types';
13
+ export declare function moderate(opts: ModerateOptions): Promise<ModerationResult | ModerationResult[]>;
@@ -0,0 +1,29 @@
1
+ /** moderationGuardrail — built-in guardrail backed by the OpenAI moderations API.
2
+ *
3
+ * Creates a Guardrail that calls moderate() on the last user message (input kind)
4
+ * or on the assistant response text (output kind). If the moderation result is
5
+ * flagged, the guardrail trips with severity 'high'.
6
+ *
7
+ * Usage:
8
+ * const guard = moderationGuardrail({ apiKey: '...' });
9
+ * const agent = new AgentLoop({ client, guardrails: [guard] });
10
+ *
11
+ * The moderation endpoint is free; a zero-cost entry is always emitted via the
12
+ * engine hook bus (see moderate.ts). Requires an OpenAI API key — fails clearly
13
+ * when invoked without one. */
14
+ import type { Guardrail } from '../agent/guardrail-types';
15
+ export interface ModerationGuardrailOptions {
16
+ /** OpenAI API key. Falls back to engine.apiKeys['openai'] when omitted. */
17
+ apiKey?: string;
18
+ /** Moderate the input (user messages). Default: true. */
19
+ input?: boolean;
20
+ /** Moderate the output (assistant responses). Default: false. */
21
+ output?: boolean;
22
+ /** Moderation model. Defaults to the moderate() helper default (omni-moderation-latest). */
23
+ model?: string;
24
+ /** Custom guardrail name prefix. Defaults to 'moderation'. */
25
+ name?: string;
26
+ }
27
+ /** Build one or two Guardrail instances backed by the OpenAI moderations endpoint.
28
+ * Pass both into `guardrails` on AgentLoopConfig — one for input, one for output. */
29
+ export declare function moderationGuardrail(opts?: ModerationGuardrailOptions): Guardrail[];