@better-agent/core 0.1.0-beta.1

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 (179) hide show
  1. package/README.md +3 -0
  2. package/dist/agent/constants.mjs +6 -0
  3. package/dist/agent/constants.mjs.map +1 -0
  4. package/dist/agent/define-agent.d.mts +29 -0
  5. package/dist/agent/define-agent.d.mts.map +1 -0
  6. package/dist/agent/define-agent.mjs +27 -0
  7. package/dist/agent/define-agent.mjs.map +1 -0
  8. package/dist/agent/index.d.mts +2 -0
  9. package/dist/agent/types.d.mts +216 -0
  10. package/dist/agent/types.d.mts.map +1 -0
  11. package/dist/agent/validation.mjs +64 -0
  12. package/dist/agent/validation.mjs.map +1 -0
  13. package/dist/api.d.mts +8 -0
  14. package/dist/api.d.mts.map +1 -0
  15. package/dist/api.mjs +63 -0
  16. package/dist/api.mjs.map +1 -0
  17. package/dist/app/config.mjs +43 -0
  18. package/dist/app/config.mjs.map +1 -0
  19. package/dist/app/create-app.d.mts +36 -0
  20. package/dist/app/create-app.d.mts.map +1 -0
  21. package/dist/app/create-app.mjs +132 -0
  22. package/dist/app/create-app.mjs.map +1 -0
  23. package/dist/app/registry.mjs +43 -0
  24. package/dist/app/registry.mjs.map +1 -0
  25. package/dist/app/types.d.mts +142 -0
  26. package/dist/app/types.d.mts.map +1 -0
  27. package/dist/events/constants.d.mts +49 -0
  28. package/dist/events/constants.d.mts.map +1 -0
  29. package/dist/events/constants.mjs +46 -0
  30. package/dist/events/constants.mjs.map +1 -0
  31. package/dist/events/index.d.mts +4 -0
  32. package/dist/events/index.mjs +3 -0
  33. package/dist/events/types.d.mts +289 -0
  34. package/dist/events/types.d.mts.map +1 -0
  35. package/dist/index.d.mts +23 -0
  36. package/dist/index.mjs +14 -0
  37. package/dist/internal/id.mjs +21 -0
  38. package/dist/internal/id.mjs.map +1 -0
  39. package/dist/internal/types.d.mts +11 -0
  40. package/dist/internal/types.d.mts.map +1 -0
  41. package/dist/mcp/error/mcp-client-error.d.mts +36 -0
  42. package/dist/mcp/error/mcp-client-error.d.mts.map +1 -0
  43. package/dist/mcp/error/mcp-client-error.mjs +33 -0
  44. package/dist/mcp/error/mcp-client-error.mjs.map +1 -0
  45. package/dist/mcp/index.d.mts +8 -0
  46. package/dist/mcp/index.mjs +9 -0
  47. package/dist/mcp/tool/json-rpc-message.d.mts +50 -0
  48. package/dist/mcp/tool/json-rpc-message.d.mts.map +1 -0
  49. package/dist/mcp/tool/json-rpc-message.mjs +84 -0
  50. package/dist/mcp/tool/json-rpc-message.mjs.map +1 -0
  51. package/dist/mcp/tool/mcp-client.d.mts +71 -0
  52. package/dist/mcp/tool/mcp-client.d.mts.map +1 -0
  53. package/dist/mcp/tool/mcp-client.mjs +304 -0
  54. package/dist/mcp/tool/mcp-client.mjs.map +1 -0
  55. package/dist/mcp/tool/mcp-http-transport.d.mts +62 -0
  56. package/dist/mcp/tool/mcp-http-transport.d.mts.map +1 -0
  57. package/dist/mcp/tool/mcp-http-transport.mjs +307 -0
  58. package/dist/mcp/tool/mcp-http-transport.mjs.map +1 -0
  59. package/dist/mcp/tool/mcp-tools.d.mts +20 -0
  60. package/dist/mcp/tool/mcp-tools.d.mts.map +1 -0
  61. package/dist/mcp/tool/mcp-tools.mjs +73 -0
  62. package/dist/mcp/tool/mcp-tools.mjs.map +1 -0
  63. package/dist/mcp/tool/mcp-transport.d.mts +81 -0
  64. package/dist/mcp/tool/mcp-transport.d.mts.map +1 -0
  65. package/dist/mcp/tool/mcp-transport.mjs +11 -0
  66. package/dist/mcp/tool/mcp-transport.mjs.map +1 -0
  67. package/dist/mcp/tool/types.d.mts +230 -0
  68. package/dist/mcp/tool/types.d.mts.map +1 -0
  69. package/dist/mcp/tool/types.mjs +19 -0
  70. package/dist/mcp/tool/types.mjs.map +1 -0
  71. package/dist/persistence/index.d.mts +3 -0
  72. package/dist/persistence/index.mjs +3 -0
  73. package/dist/persistence/memory.d.mts +21 -0
  74. package/dist/persistence/memory.d.mts.map +1 -0
  75. package/dist/persistence/memory.mjs +107 -0
  76. package/dist/persistence/memory.mjs.map +1 -0
  77. package/dist/persistence/types.d.mts +124 -0
  78. package/dist/persistence/types.d.mts.map +1 -0
  79. package/dist/plugins/index.d.mts +2 -0
  80. package/dist/plugins/runtime.d.mts +17 -0
  81. package/dist/plugins/runtime.d.mts.map +1 -0
  82. package/dist/plugins/runtime.mjs +456 -0
  83. package/dist/plugins/runtime.mjs.map +1 -0
  84. package/dist/plugins/types.d.mts +344 -0
  85. package/dist/plugins/types.d.mts.map +1 -0
  86. package/dist/providers/index.d.mts +9 -0
  87. package/dist/providers/index.mjs +0 -0
  88. package/dist/providers/types/capabilities.d.mts +153 -0
  89. package/dist/providers/types/capabilities.d.mts.map +1 -0
  90. package/dist/providers/types/content.d.mts +125 -0
  91. package/dist/providers/types/content.d.mts.map +1 -0
  92. package/dist/providers/types/conversation.d.mts +32 -0
  93. package/dist/providers/types/conversation.d.mts.map +1 -0
  94. package/dist/providers/types/index.d.mts +8 -0
  95. package/dist/providers/types/input.d.mts +74 -0
  96. package/dist/providers/types/input.d.mts.map +1 -0
  97. package/dist/providers/types/model.d.mts +68 -0
  98. package/dist/providers/types/model.d.mts.map +1 -0
  99. package/dist/providers/types/output.d.mts +29 -0
  100. package/dist/providers/types/output.d.mts.map +1 -0
  101. package/dist/providers/types/response.d.mts +35 -0
  102. package/dist/providers/types/response.d.mts.map +1 -0
  103. package/dist/providers/types/tool-calls.d.mts +51 -0
  104. package/dist/providers/types/tool-calls.d.mts.map +1 -0
  105. package/dist/run/agent-loop.mjs +231 -0
  106. package/dist/run/agent-loop.mjs.map +1 -0
  107. package/dist/run/event-queue.mjs +67 -0
  108. package/dist/run/event-queue.mjs.map +1 -0
  109. package/dist/run/execute-tool-calls.mjs +550 -0
  110. package/dist/run/execute-tool-calls.mjs.map +1 -0
  111. package/dist/run/execution.mjs +93 -0
  112. package/dist/run/execution.mjs.map +1 -0
  113. package/dist/run/helpers.mjs +466 -0
  114. package/dist/run/helpers.mjs.map +1 -0
  115. package/dist/run/hooks.mjs +124 -0
  116. package/dist/run/hooks.mjs.map +1 -0
  117. package/dist/run/index.d.mts +4 -0
  118. package/dist/run/messages.d.mts +8 -0
  119. package/dist/run/messages.d.mts.map +1 -0
  120. package/dist/run/messages.mjs +83 -0
  121. package/dist/run/messages.mjs.map +1 -0
  122. package/dist/run/model-strategy.mjs +105 -0
  123. package/dist/run/model-strategy.mjs.map +1 -0
  124. package/dist/run/output-errors.d.mts +75 -0
  125. package/dist/run/output-errors.d.mts.map +1 -0
  126. package/dist/run/pending-tools.d.mts +1 -0
  127. package/dist/run/pending-tools.mjs +185 -0
  128. package/dist/run/pending-tools.mjs.map +1 -0
  129. package/dist/run/registry.mjs +22 -0
  130. package/dist/run/registry.mjs.map +1 -0
  131. package/dist/run/runtime.d.mts +19 -0
  132. package/dist/run/runtime.d.mts.map +1 -0
  133. package/dist/run/runtime.mjs +491 -0
  134. package/dist/run/runtime.mjs.map +1 -0
  135. package/dist/run/stop-conditions.mjs +41 -0
  136. package/dist/run/stop-conditions.mjs.map +1 -0
  137. package/dist/run/types.d.mts +348 -0
  138. package/dist/run/types.d.mts.map +1 -0
  139. package/dist/schema/index.d.mts +2 -0
  140. package/dist/schema/resolve-json-schema.d.mts +12 -0
  141. package/dist/schema/resolve-json-schema.d.mts.map +1 -0
  142. package/dist/schema/resolve-json-schema.mjs +167 -0
  143. package/dist/schema/resolve-json-schema.mjs.map +1 -0
  144. package/dist/schema/types.d.mts +27 -0
  145. package/dist/schema/types.d.mts.map +1 -0
  146. package/dist/server/create-server.d.mts +21 -0
  147. package/dist/server/create-server.d.mts.map +1 -0
  148. package/dist/server/create-server.mjs +107 -0
  149. package/dist/server/create-server.mjs.map +1 -0
  150. package/dist/server/http.mjs +182 -0
  151. package/dist/server/http.mjs.map +1 -0
  152. package/dist/server/index.d.mts +3 -0
  153. package/dist/server/index.mjs +3 -0
  154. package/dist/server/routes.mjs +399 -0
  155. package/dist/server/routes.mjs.map +1 -0
  156. package/dist/server/types.d.mts +31 -0
  157. package/dist/server/types.d.mts.map +1 -0
  158. package/dist/tools/constants.d.mts +12 -0
  159. package/dist/tools/constants.d.mts.map +1 -0
  160. package/dist/tools/constants.mjs +13 -0
  161. package/dist/tools/constants.mjs.map +1 -0
  162. package/dist/tools/define-tool.d.mts +25 -0
  163. package/dist/tools/define-tool.d.mts.map +1 -0
  164. package/dist/tools/define-tool.mjs +76 -0
  165. package/dist/tools/define-tool.mjs.map +1 -0
  166. package/dist/tools/index.d.mts +5 -0
  167. package/dist/tools/lazy-tools.d.mts +49 -0
  168. package/dist/tools/lazy-tools.d.mts.map +1 -0
  169. package/dist/tools/lazy-tools.mjs +87 -0
  170. package/dist/tools/lazy-tools.mjs.map +1 -0
  171. package/dist/tools/resolve-tools.d.mts +12 -0
  172. package/dist/tools/resolve-tools.d.mts.map +1 -0
  173. package/dist/tools/resolve-tools.mjs +86 -0
  174. package/dist/tools/resolve-tools.mjs.map +1 -0
  175. package/dist/tools/types.d.mts +318 -0
  176. package/dist/tools/types.d.mts.map +1 -0
  177. package/dist/tools/validation.mjs +23 -0
  178. package/dist/tools/validation.mjs.map +1 -0
  179. package/package.json +72 -0
@@ -0,0 +1,344 @@
1
+ import { EventName } from "../events/constants.mjs";
2
+ import { Awaitable } from "../internal/types.mjs";
3
+ import { Capabilities, InstructionEnabled } from "../providers/types/capabilities.mjs";
4
+ import { AgentToolDefinition, ToolSource } from "../tools/types.mjs";
5
+ import { ToolChoice } from "../providers/types/tool-calls.mjs";
6
+ import { GenerativeModelInputItem, GenerativeModelInputMessageContent } from "../providers/types/input.mjs";
7
+ import { ConversationItem } from "../providers/types/conversation.mjs";
8
+ import { GenerativeModelResponse } from "../providers/types/response.mjs";
9
+ import { HttpMethod } from "../api.mjs";
10
+ import { PreviousStepResult } from "../run/types.mjs";
11
+ import { Event } from "../events/types.mjs";
12
+ //#region src/plugins/types.d.ts
13
+ /**
14
+ * Request mode passed to plugin guards.
15
+ *
16
+ * - `run`: one-shot non-streaming agent execution via the built-in run route.
17
+ * - `stream`: streaming agent execution via the built-in run route with SSE.
18
+ * - `load_conversation`: durable conversation history lookup.
19
+ * - `abort_run`: abort request for an active run id.
20
+ * - `resume_stream`: stream event resumption by known stream id.
21
+ * - `resume_conversation`: active conversation stream resumption by conversation id.
22
+ */
23
+ type PluginGuardMode = "run" | "stream" | "load_conversation" | "abort_run" | "resume_stream" | "resume_conversation";
24
+ /**
25
+ * Plugin definition.
26
+ *
27
+ * Plugin hook contexts are intentionally broad at authoring time. Some
28
+ * capability-sensitive controls may be omitted at runtime for models that do
29
+ * not support them. For example, tool-mutation helpers are only available
30
+ * during runs whose active model supports tools.
31
+ */
32
+ interface Plugin {
33
+ /** Unique plugin id. */
34
+ id: string;
35
+ /** Event middleware configuration. */
36
+ events?: {
37
+ /** Event type filter. When omitted, receives all events. */subscribe?: EventName[]; /** Ordered middleware chain for matching events. */
38
+ middleware?: PluginEventMiddleware[];
39
+ };
40
+ /** Request guard functions. */
41
+ guards?: PluginGuard[];
42
+ /** Custom HTTP endpoints. */
43
+ endpoints?: PluginEndpoint[];
44
+ /** Event observer that cannot mutate or drop events. */
45
+ onEvent?: (event: Event, ctx: PluginEventContext) => Awaitable<void>;
46
+ /** Additional tools available to all agents. */
47
+ tools?: ToolSource<unknown>;
48
+ /** Called before each model call, before agent.onStep. */
49
+ onStep?: (ctx: PluginOnStepContext) => Awaitable<void>;
50
+ /** Transform model input just before the provider call. */
51
+ onBeforeModelCall?: (ctx: PluginModelCallContext) => Awaitable<void>;
52
+ /** Observe model response after the provider call, before tool execution. */
53
+ onAfterModelCall?: (ctx: PluginModelResponseContext) => Awaitable<void>;
54
+ /** Called before a tool executes. Can skip or modify args. */
55
+ onBeforeToolCall?: (ctx: PluginToolCallContext) => Awaitable<PluginToolCallDecision>;
56
+ /** Called after a tool executes. Can observe or modify result. */
57
+ onAfterToolCall?: (ctx: PluginToolResultContext) => Awaitable<void>;
58
+ /** Transform durable items before conversation persistence. */
59
+ onBeforeSave?: (ctx: PluginSaveContext) => Awaitable<void>;
60
+ }
61
+ /**
62
+ * Plugin endpoint definition.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * endpoints: [
67
+ * {
68
+ * method: "GET",
69
+ * path: "/health",
70
+ * public: true,
71
+ * handler: () => Response.json({ ok: true }),
72
+ * },
73
+ * ]
74
+ * ```
75
+ */
76
+ interface PluginEndpoint {
77
+ /** HTTP method or methods. */
78
+ method: HttpMethod | HttpMethod[];
79
+ /** Route path pattern. Must start with `/`. */
80
+ path: string;
81
+ /**
82
+ * Bypasses the app's built-in bearer `secret` auth for this endpoint.
83
+ *
84
+ * This does not bypass auth outside Better Agent.
85
+ */
86
+ public?: boolean;
87
+ /** Endpoint handler. */
88
+ handler: PluginEndpointHandler;
89
+ }
90
+ /**
91
+ * Plugin endpoint handler.
92
+ */
93
+ type PluginEndpointHandler = (ctx: {
94
+ request: Request;
95
+ params: Record<string, string>;
96
+ query: URLSearchParams;
97
+ }) => Promise<Response> | Response;
98
+ /**
99
+ * Plugin event middleware.
100
+ *
101
+ * Return the next event to continue, or `null` to drop it.
102
+ */
103
+ type PluginEventMiddleware = (event: Event, ctx: PluginEventContext, next: (event: Event) => Promise<Event | null>) => Promise<Event | null>;
104
+ /**
105
+ * Context passed to plugin event middleware.
106
+ */
107
+ interface PluginEventContext {
108
+ /** Active run id. */
109
+ runId: string;
110
+ /** Agent name for this run. */
111
+ agentName: string;
112
+ /** Shared conversation id, if present. */
113
+ conversationId?: string;
114
+ /** Run control helpers. */
115
+ control: {
116
+ /** Aborts the active run. */abortRun: () => Promise<void>;
117
+ };
118
+ }
119
+ /**
120
+ * Shared base for plugin hook contexts tied to a live run.
121
+ */
122
+ interface PluginBaseContext {
123
+ /** Active run id. */
124
+ runId: string;
125
+ /** Agent name for this run. */
126
+ agentName: string;
127
+ /** Shared conversation id, if present. */
128
+ conversationId?: string;
129
+ }
130
+ /**
131
+ * Context passed to plugin onStep hooks.
132
+ *
133
+ * Plugins always receive `context` as `unknown`.
134
+ */
135
+ type PluginToolControlField<TModelCaps extends Capabilities = Capabilities> = TModelCaps["tools"] extends true ? {
136
+ setToolChoice(choice: ToolChoice): void;
137
+ setActiveTools(names: readonly string[]): void;
138
+ } : Record<never, never>;
139
+ type PluginInstructionControlField<TModelCaps extends Capabilities = Capabilities> = InstructionEnabled<TModelCaps> extends true ? {
140
+ setSystemInstruction(instruction: GenerativeModelInputMessageContent<TModelCaps>): void;
141
+ } : Record<never, never>;
142
+ type PluginOnStepContext<TModelCaps extends Capabilities = Capabilities> = PluginBaseContext & {
143
+ stepIndex: number;
144
+ maxSteps: number | undefined;
145
+ messages: GenerativeModelInputItem<TModelCaps>[]; /** Agent context as `unknown`. Plugins cannot assume its shape. */
146
+ context?: unknown;
147
+ previousStep?: PreviousStepResult;
148
+ updateMessages(updater: (messages: GenerativeModelInputItem<TModelCaps>[]) => GenerativeModelInputItem<TModelCaps>[]): void;
149
+ } & PluginInstructionControlField<TModelCaps> & PluginToolControlField<TModelCaps>;
150
+ /**
151
+ * Context passed to plugin `onBeforeModelCall` hooks.
152
+ */
153
+ interface PluginModelCallContext extends PluginBaseContext {
154
+ stepIndex: number;
155
+ input: GenerativeModelInputItem[];
156
+ tools: AgentToolDefinition[];
157
+ toolChoice?: ToolChoice;
158
+ setInput(input: GenerativeModelInputItem[]): void;
159
+ setTools(tools: AgentToolDefinition[]): void;
160
+ setToolChoice(choice: ToolChoice | undefined): void;
161
+ }
162
+ /**
163
+ * Context passed to plugin `onAfterModelCall` hooks.
164
+ */
165
+ interface PluginModelResponseContext extends PluginBaseContext {
166
+ stepIndex: number;
167
+ response: GenerativeModelResponse;
168
+ }
169
+ /**
170
+ * Context passed to plugin `onBeforeToolCall` hooks.
171
+ */
172
+ interface PluginToolCallContext extends PluginBaseContext {
173
+ toolName: string;
174
+ toolCallId: string;
175
+ args: unknown;
176
+ setArgs(args: unknown): void;
177
+ }
178
+ /**
179
+ * Decision returned by plugin `onBeforeToolCall` hooks.
180
+ */
181
+ type PluginToolCallDecision = undefined | {
182
+ skip: true;
183
+ result?: unknown;
184
+ };
185
+ /**
186
+ * Context passed to plugin `onAfterToolCall` hooks.
187
+ */
188
+ interface PluginToolResultContext extends PluginBaseContext {
189
+ toolName: string;
190
+ toolCallId: string;
191
+ args: unknown;
192
+ result: unknown;
193
+ error?: string;
194
+ setResult(result: unknown): void;
195
+ }
196
+ /**
197
+ * Context passed to plugin `onBeforeSave` hooks.
198
+ */
199
+ interface PluginSaveContext extends PluginBaseContext {
200
+ items: ConversationItem[];
201
+ setItems(items: ConversationItem[]): void;
202
+ }
203
+ /**
204
+ * Plugin guard.
205
+ *
206
+ * Return `null` to allow the request, or a `Response` to reject it.
207
+ */
208
+ type PluginGuard = (ctx: PluginRunContext) => Promise<Response | null> | Response | null;
209
+ /**
210
+ * Context passed to plugin guards.
211
+ */
212
+ interface PluginRunContext {
213
+ /** Request mode. */
214
+ mode: PluginGuardMode;
215
+ /** Resolved agent name. */
216
+ agentName: string;
217
+ /** Parsed request body. */
218
+ input: Record<string, unknown>;
219
+ /** Original request object. */
220
+ request: Request;
221
+ /** Active plugins. */
222
+ plugins: readonly Plugin[];
223
+ }
224
+ /**
225
+ * Normalized plugin endpoint used at runtime.
226
+ */
227
+ type PluginRuntimeEndpoint = {
228
+ /** Plugin id that owns this endpoint. */pluginId: string; /** HTTP method. */
229
+ method: HttpMethod; /** Route path pattern. */
230
+ path: string; /** When true, this endpoint bypasses the app's built-in bearer auth. */
231
+ public?: boolean; /** Endpoint handler. */
232
+ handler: PluginEndpointHandler;
233
+ };
234
+ /**
235
+ * Prepared plugin runtime consumed by the runner and server.
236
+ */
237
+ interface PluginRuntime {
238
+ /** Original plugin list in registration order. */
239
+ plugins: readonly Plugin[];
240
+ /** Expanded endpoint routes with one method per entry. */
241
+ endpoints: readonly PluginRuntimeEndpoint[];
242
+ /** Fast flag used to skip event middleware when unused. */
243
+ hasEventMiddleware: boolean;
244
+ /** Fast flag used to skip `onEvent` hooks when unused. */
245
+ hasOnEvent: boolean;
246
+ /** Fast flag used to skip guards when unused. */
247
+ hasGuards: boolean;
248
+ /** Fast flag used to skip plugin-provided tools when unused. */
249
+ hasTools: boolean;
250
+ /** Fast flag used to skip `onStep` hooks when unused. */
251
+ hasOnStep: boolean;
252
+ /** Fast flag used to skip model hooks when unused. */
253
+ hasModelHooks: boolean;
254
+ /** Fast flag used to skip tool hooks when unused. */
255
+ hasToolHooks: boolean;
256
+ /** Fast flag used to skip `onBeforeSave` hooks when unused. */
257
+ hasOnBeforeSave: boolean;
258
+ /** Dispatches an event through plugin middleware. */
259
+ dispatchEvent(event: Event, ctx: PluginEventContext): Promise<Event | null>;
260
+ /** Notifies observing plugins after the event is committed. */
261
+ dispatchOnEvent(event: Event, ctx: PluginEventContext): Promise<void>;
262
+ /** Dispatches a run request through the guard chain. */
263
+ dispatchRun(ctx: PluginRunContext): Promise<Response | null>;
264
+ /** Resolves additional plugin-provided tools for one run. */
265
+ resolveTools<TContext>(context?: TContext): Promise<{
266
+ tools: AgentToolDefinition[];
267
+ runCleanup: () => Awaitable<void>;
268
+ }>;
269
+ /** Applies `onStep` hooks in registration order. */
270
+ applyOnStep<TContext, TToolName extends string = string, TModelCaps extends Capabilities = Capabilities>(params: {
271
+ runId: string;
272
+ agentName: string;
273
+ conversationId?: string;
274
+ stepIndex: number;
275
+ maxSteps: number | undefined;
276
+ messages: GenerativeModelInputItem<TModelCaps>[];
277
+ context?: TContext;
278
+ previousStep?: PreviousStepResult; /** Model capabilities used to determine which control helpers are valid. */
279
+ modelCaps?: TModelCaps;
280
+ }): Promise<{
281
+ messages: GenerativeModelInputItem<TModelCaps>[];
282
+ toolChoice?: ToolChoice;
283
+ activeTools?: TToolName[];
284
+ systemInstruction?: GenerativeModelInputMessageContent<TModelCaps>;
285
+ }>;
286
+ /** Applies `onBeforeModelCall` hooks in registration order. */
287
+ applyBeforeModelCall(params: {
288
+ runId: string;
289
+ agentName: string;
290
+ conversationId?: string;
291
+ stepIndex: number;
292
+ input: GenerativeModelInputItem[];
293
+ tools: AgentToolDefinition[];
294
+ toolChoice?: ToolChoice; /** Model capabilities used to determine which control helpers are valid. */
295
+ modelCaps?: Capabilities;
296
+ }): Promise<{
297
+ input: GenerativeModelInputItem[];
298
+ tools: AgentToolDefinition[];
299
+ toolChoice?: ToolChoice;
300
+ }>;
301
+ /** Notifies plugins after a model response is available. */
302
+ applyAfterModelCall(params: {
303
+ runId: string;
304
+ agentName: string;
305
+ conversationId?: string;
306
+ stepIndex: number;
307
+ response: GenerativeModelResponse;
308
+ }): Promise<void>;
309
+ /** Applies `onBeforeToolCall` hooks in registration order. */
310
+ applyBeforeToolCall(params: {
311
+ runId: string;
312
+ agentName: string;
313
+ conversationId?: string;
314
+ toolName: string;
315
+ toolCallId: string;
316
+ args: unknown;
317
+ }): Promise<{
318
+ args: unknown;
319
+ decision?: PluginToolCallDecision;
320
+ }>;
321
+ /** Notifies plugins after tool execution and allows result mutation. */
322
+ applyAfterToolCall(params: {
323
+ runId: string;
324
+ agentName: string;
325
+ conversationId?: string;
326
+ toolName: string;
327
+ toolCallId: string;
328
+ args: unknown;
329
+ result: unknown;
330
+ error?: string;
331
+ }): Promise<{
332
+ result: unknown;
333
+ }>;
334
+ /** Applies `onBeforeSave` hooks in registration order. */
335
+ applyBeforeSave(params: {
336
+ runId: string;
337
+ agentName: string;
338
+ conversationId?: string;
339
+ items: ConversationItem[];
340
+ }): Promise<ConversationItem[]>;
341
+ }
342
+ //#endregion
343
+ export { Plugin, PluginBaseContext, PluginEndpoint, PluginEndpointHandler, PluginEventContext, PluginEventMiddleware, PluginGuard, PluginGuardMode, PluginModelCallContext, PluginModelResponseContext, PluginOnStepContext, PluginRunContext, PluginRuntime, PluginRuntimeEndpoint, PluginSaveContext, PluginToolCallContext, PluginToolCallDecision, PluginToolResultContext };
344
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":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A;EAtJJ;EAwJV,eAAA,CAAgB,MAAA;IACZ,KAAA;IACA,SAAA;IACA,cAAA;IACA,KAAA,EAAO,gBAAA;EAAA,IACP,OAAA,CAAQ,gBAAA;AAAA"}
@@ -0,0 +1,9 @@
1
+ import { CapEnabled, Capabilities, IfCap, InferOutputSchema, InputEnabled, InputModalitySpec, InputShape, InstructionEnabled, ModalitiesField, ModalitiesParam, Modality, ModalityOptionsFor, OutputEnabled, OutputModalitySpec, OutputSchemaDefinition, OutputSchemaForCaps, OutputSchemaSource, ReplayMode, StructuredOutput } from "./types/capabilities.mjs";
2
+ import { AudioContentBase, EmbeddingContentBase, FileContentBase, GenerativeModelAudioSource, GenerativeModelFileSource, GenerativeModelImageSource, GenerativeModelVideoSource, ImageContentBase, ReasoningContentBase, TextContentBase, TranscriptContentBase, VideoContentBase } from "./types/content.mjs";
3
+ import { GenerativeModelProviderToolResult, GenerativeModelToolCallRequest, GenerativeModelToolCallResult, ToolChoice } from "./types/tool-calls.mjs";
4
+ import { ChatInputMessage, GenerativeModelCallOptions, GenerativeModelInput, GenerativeModelInputItem, GenerativeModelInputMessage, GenerativeModelInputMessageContent, GenerativeModelInputMessagePart, GenerativeModelMessageRole, ModelOptions, PromptInputMessage } from "./types/input.mjs";
5
+ import { ConversationItem, ConversationMessage, ConversationMessageContent, ConversationMessagePart } from "./types/conversation.mjs";
6
+ import { GenerativeModelOutputItem, GenerativeModelOutputMessage, GenerativeModelOutputMessageContent, GenerativeModelOutputMessagePart } from "./types/output.mjs";
7
+ import { GenerativeModelFinishReason, GenerativeModelResponse, GenerativeModelUsage } from "./types/response.mjs";
8
+ import { GenerativeModel, GenerativeModelGenerateResult, ModelDescriptor } from "./types/model.mjs";
9
+ export { AudioContentBase, CapEnabled, Capabilities, ChatInputMessage, ConversationItem, ConversationMessage, ConversationMessageContent, ConversationMessagePart, EmbeddingContentBase, FileContentBase, GenerativeModel, GenerativeModelAudioSource, GenerativeModelCallOptions, GenerativeModelFileSource, GenerativeModelFinishReason, GenerativeModelGenerateResult, GenerativeModelImageSource, GenerativeModelInput, GenerativeModelInputItem, GenerativeModelInputMessage, GenerativeModelInputMessageContent, GenerativeModelInputMessagePart, GenerativeModelMessageRole, GenerativeModelOutputItem, GenerativeModelOutputMessage, GenerativeModelOutputMessageContent, GenerativeModelOutputMessagePart, GenerativeModelProviderToolResult, GenerativeModelResponse, GenerativeModelToolCallRequest, GenerativeModelToolCallResult, GenerativeModelUsage, GenerativeModelVideoSource, IfCap, ImageContentBase, InferOutputSchema, InputEnabled, InputModalitySpec, InputShape, InstructionEnabled, ModalitiesField, ModalitiesParam, Modality, ModalityOptionsFor, ModelDescriptor, ModelOptions, OutputEnabled, OutputModalitySpec, OutputSchemaDefinition, OutputSchemaForCaps, OutputSchemaSource, PromptInputMessage, ReasoningContentBase, ReplayMode, StructuredOutput, TextContentBase, ToolChoice, TranscriptContentBase, VideoContentBase };
File without changes
@@ -0,0 +1,153 @@
1
+ import { IsAny, UnionToIntersection } from "../../internal/types.mjs";
2
+ import { InferSchemaInput, ResolvableSchema } from "../../schema/types.mjs";
3
+ //#region src/providers/types/capabilities.d.ts
4
+ /**
5
+ * Supported input and output modalities.
6
+ */
7
+ type Modality = "text" | "image" | "video" | "audio" | "file" | "embedding";
8
+ /**
9
+ * How persisted conversation history should be treated on subsequent runs.
10
+ */
11
+ type ReplayMode = "multi_turn" | "single_turn_persistent" | "single_turn_only";
12
+ /**
13
+ * Capability spec for an input modality.
14
+ */
15
+ type InputModalitySpec = boolean;
16
+ /**
17
+ * Shape of input expected by a model.
18
+ */
19
+ type InputShape = "chat" | "prompt";
20
+ /**
21
+ * Capability spec for an output modality.
22
+ */
23
+ type OutputModalitySpec = boolean | {
24
+ options?: Record<string, unknown>;
25
+ };
26
+ /**
27
+ * Model capability flags and modality support.
28
+ */
29
+ interface Capabilities {
30
+ /**
31
+ * Supported input modalities and their capability extensions.
32
+ */
33
+ inputModalities?: Partial<Record<Modality, InputModalitySpec>>;
34
+ /**
35
+ * Supported output modalities and their capability extensions.
36
+ */
37
+ outputModalities?: Partial<Record<Modality, OutputModalitySpec>>;
38
+ /**
39
+ * Shape of the model input.
40
+ */
41
+ inputShape?: InputShape;
42
+ /**
43
+ * Whether stored conversation history should be replayed into future model calls.
44
+ */
45
+ replayMode?: ReplayMode;
46
+ /**
47
+ * Whether agent/system instruction controls are supported for this model.
48
+ */
49
+ supportsInstruction?: boolean;
50
+ /**
51
+ * Whether structured output is supported.
52
+ */
53
+ structured_output?: boolean | Record<string, unknown>;
54
+ /**
55
+ * Whether tool calling is supported.
56
+ */
57
+ tools?: boolean;
58
+ /**
59
+ * Additional message roles supported by the model, beyond `"system"`, `"user"`, and `"assistant"`.
60
+ */
61
+ additionalSupportedRoles?: readonly string[];
62
+ }
63
+ /**
64
+ * Schema accepted for requested structured output.
65
+ */
66
+ type OutputSchemaSource = ResolvableSchema;
67
+ /**
68
+ * User-facing structured output definition.
69
+ *
70
+ * Requires a text-output model.
71
+ */
72
+ type OutputSchemaDefinition<TSchema extends OutputSchemaSource = OutputSchemaSource> = {
73
+ /** Schema that the model output should match. */schema: TSchema; /** Optional name forwarded to providers that support named structured outputs. */
74
+ name?: string; /** Whether strict schema adherence should be requested when supported. */
75
+ strict?: boolean;
76
+ };
77
+ /**
78
+ * Structured output definition gated by model capabilities.
79
+ */
80
+ type OutputSchemaForCaps<TCaps extends Capabilities, TSchema extends OutputSchemaSource = OutputSchemaSource> = CapEnabled<TCaps["structured_output"]> extends true ? OutputSchemaDefinition<TSchema> : never;
81
+ /**
82
+ * Infers the validated structured output type from a schema definition.
83
+ */
84
+ type InferOutputSchema<TOutput> = TOutput extends {
85
+ schema: infer TSchema;
86
+ } ? InferSchemaInput<NonNullable<TSchema>> : unknown;
87
+ /**
88
+ * Determines whether a capability is enabled.
89
+ */
90
+ type CapEnabled<C> = IsAny<C> extends true ? true : [C] extends [false | undefined] ? false : [Extract<C, true | boolean | Record<string, unknown>>] extends [never] ? false : true;
91
+ /**
92
+ * Resolved structured output config sent to providers.
93
+ */
94
+ interface StructuredOutput {
95
+ name: string;
96
+ schema: Record<string, unknown>;
97
+ strict?: boolean;
98
+ }
99
+ /**
100
+ * Tuple of enabled output modalities, or `undefined`.
101
+ */
102
+ type ModalitiesParam<TCaps extends Capabilities> = undefined | readonly [EnabledOutputModality<TCaps>, ...EnabledOutputModality<TCaps>[]];
103
+ /**
104
+ * Extracts output spec for a modality from model capabilities.
105
+ */
106
+ type OutputSpec<TCaps extends Capabilities, M extends Modality> = TCaps["outputModalities"] extends infer O ? O extends Partial<Record<Modality, OutputModalitySpec>> ? O[M] : undefined : undefined;
107
+ /**
108
+ * Extracts input spec for a modality from model capabilities.
109
+ */
110
+ type InputSpec<TCaps extends Capabilities, M extends Modality> = TCaps["inputModalities"] extends infer I ? I extends Partial<Record<Modality, InputModalitySpec>> ? I[M] : undefined : undefined;
111
+ /**
112
+ * Conditional object fields based on capability enablement.
113
+ */
114
+ type IfCap<C, T extends object> = CapEnabled<C> extends true ? T : object;
115
+ /**
116
+ * Whether a given output modality is enabled.
117
+ */
118
+ type OutputEnabled<TCaps extends Capabilities, M extends Modality> = CapEnabled<OutputSpec<TCaps, M>> extends true ? true : false;
119
+ /**
120
+ * Whether a given input modality is enabled.
121
+ */
122
+ type InputEnabled<TCaps extends Capabilities, M extends Modality> = IsAny<TCaps> extends true ? true : M extends "text" ? TCaps["inputModalities"] extends Partial<Record<Modality, InputModalitySpec>> ? [InputSpec<TCaps, "text">] extends [false] ? false : true : true : TCaps["inputModalities"] extends Partial<Record<Modality, InputModalitySpec>> ? CapEnabled<InputSpec<TCaps, M>> : false;
123
+ /**
124
+ * Whether system or instruction prompting is supported for a model.
125
+ */
126
+ type InstructionEnabled<TCaps extends Capabilities> = IsAny<TCaps> extends true ? true : TCaps["supportsInstruction"] extends true ? true : false;
127
+ /**
128
+ * Union of all enabled output modalities.
129
+ */
130
+ type EnabledOutputModality<TCaps extends Capabilities> = (CapEnabled<OutputSpec<TCaps, "text">> extends true ? "text" : never) | (CapEnabled<OutputSpec<TCaps, "image">> extends true ? "image" : never) | (CapEnabled<OutputSpec<TCaps, "video">> extends true ? "video" : never) | (CapEnabled<OutputSpec<TCaps, "audio">> extends true ? "audio" : never) | (CapEnabled<OutputSpec<TCaps, "embedding">> extends true ? "embedding" : never);
131
+ type IsUnion<T, U = T> = T extends unknown ? ([U] extends [T] ? false : true) : never;
132
+ /**
133
+ * Extracts provider-specific output options for a modality spec.
134
+ */
135
+ type OutputOptionsOfSpec<S> = S extends {
136
+ options?: infer O;
137
+ } ? O extends object ? O : object : object;
138
+ type DefaultModalityOptionsFor<TCaps extends Capabilities> = [EnabledOutputModality<TCaps>] extends [never] ? object : IsUnion<EnabledOutputModality<TCaps>> extends true ? object : EnabledOutputModality<TCaps> extends infer K ? K extends keyof NonNullable<TCaps["outputModalities"]> ? OutputOptionsOfSpec<NonNullable<TCaps["outputModalities"]>[K]> : object : object;
139
+ /**
140
+ * Aggregates output options for all selected modalities.
141
+ */
142
+ type ModalityOptionsFor<TCaps extends Capabilities, T extends readonly unknown[] | undefined> = [T] extends [undefined] ? DefaultModalityOptionsFor<TCaps> : T extends readonly (infer K)[] ? UnionToIntersection<K extends keyof NonNullable<TCaps["outputModalities"]> ? OutputOptionsOfSpec<NonNullable<TCaps["outputModalities"]>[K]> : object> : object;
143
+ /**
144
+ * Adds the `modalities` field when required.
145
+ */
146
+ type ModalitiesField<TModalities> = undefined extends TModalities ? {
147
+ modalities?: TModalities;
148
+ } : {
149
+ modalities: TModalities;
150
+ };
151
+ //#endregion
152
+ export { CapEnabled, Capabilities, IfCap, InferOutputSchema, InputEnabled, InputModalitySpec, InputShape, InstructionEnabled, ModalitiesField, ModalitiesParam, Modality, ModalityOptionsFor, OutputEnabled, OutputModalitySpec, OutputSchemaDefinition, OutputSchemaForCaps, OutputSchemaSource, ReplayMode, StructuredOutput };
153
+ //# sourceMappingURL=capabilities.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.d.m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B,WAAA,CAAY,KAAA,wBACxB,mBAAA,CAAoB,WAAA,CAAY,KAAA,sBAA2B,CAAA;;;;KAO7D,kBAAA,eACM,YAAA,+CAEb,CAAA,wBACC,yBAAA,CAA0B,KAAA,IAC1B,CAAA,gCACE,mBAAA,CACI,CAAA,eAAgB,WAAA,CAAY,KAAA,wBACtB,mBAAA,CAAoB,WAAA,CAAY,KAAA,sBAA2B,CAAA;;;;KAQjE,eAAA,kCAAiD,WAAA;EAEnD,UAAA,GAAa,WAAA;AAAA;EAGb,UAAA,EAAY,WAAA;AAAA"}
@@ -0,0 +1,125 @@
1
+ //#region src/providers/types/content.d.ts
2
+ type GenerativeModelBinaryMediaSource = {
3
+ kind: "url";
4
+ url: string;
5
+ } | {
6
+ kind: "base64";
7
+ data: string;
8
+ mimeType: string;
9
+ };
10
+ /**
11
+ * Image source supported by input and output content.
12
+ */
13
+ type GenerativeModelImageSource = GenerativeModelBinaryMediaSource;
14
+ /**
15
+ * Base text content shape.
16
+ */
17
+ type TextContentBase = {
18
+ type: "text";
19
+ text: string;
20
+ providerMetadata?: Record<string, unknown>;
21
+ };
22
+ /**
23
+ * Base image content shape.
24
+ */
25
+ type ImageContentBase = {
26
+ type: "image";
27
+ source: GenerativeModelImageSource;
28
+ providerMetadata?: Record<string, unknown>;
29
+ };
30
+ /**
31
+ * File source supported by input content.
32
+ *
33
+ * Prefer `url` or `base64` when the content is portable across providers.
34
+ *
35
+ * Use `provider-file` as a deliberate escape hatch for provider-managed asset
36
+ * references when the upstream provider expects a previously uploaded file or
37
+ * asset id rather than inline bytes.
38
+ */
39
+ type GenerativeModelFileSource = {
40
+ kind: "url";
41
+ url: string;
42
+ mimeType?: string;
43
+ filename?: string;
44
+ } | {
45
+ kind: "base64";
46
+ data: string;
47
+ mimeType: string;
48
+ filename?: string;
49
+ } | {
50
+ kind: "provider-file";
51
+ ref: {
52
+ provider: string;
53
+ id: string;
54
+ };
55
+ mimeType?: string;
56
+ filename?: string;
57
+ };
58
+ /**
59
+ * Base file content shape.
60
+ */
61
+ type FileContentBase = {
62
+ type: "file";
63
+ source: GenerativeModelFileSource;
64
+ providerMetadata?: Record<string, unknown>;
65
+ };
66
+ /**
67
+ * Audio source supported by input and output content.
68
+ */
69
+ type GenerativeModelAudioSource = GenerativeModelBinaryMediaSource;
70
+ /**
71
+ * Base audio content shape.
72
+ */
73
+ type AudioContentBase = {
74
+ type: "audio";
75
+ source: GenerativeModelAudioSource;
76
+ providerMetadata?: Record<string, unknown>;
77
+ };
78
+ /**
79
+ * Base embedding content shape.
80
+ */
81
+ type EmbeddingContentBase = {
82
+ type: "embedding";
83
+ embedding: number[];
84
+ providerMetadata?: Record<string, unknown>;
85
+ };
86
+ /**
87
+ * Base transcript content shape.
88
+ */
89
+ type TranscriptContentBase = {
90
+ type: "transcript";
91
+ text: string;
92
+ segments?: Array<{
93
+ id: string;
94
+ start: number;
95
+ end: number;
96
+ text: string;
97
+ speaker?: string;
98
+ }>;
99
+ providerMetadata?: Record<string, unknown>;
100
+ };
101
+ /**
102
+ * Base reasoning content shape.
103
+ */
104
+ type ReasoningContentBase = {
105
+ type: "reasoning";
106
+ text: string;
107
+ visibility: "summary" | "full";
108
+ provider?: string;
109
+ providerMetadata?: Record<string, unknown>;
110
+ };
111
+ /**
112
+ * Video source supported by input and output content.
113
+ */
114
+ type GenerativeModelVideoSource = GenerativeModelBinaryMediaSource;
115
+ /**
116
+ * Base video content shape.
117
+ */
118
+ type VideoContentBase = {
119
+ type: "video";
120
+ source: GenerativeModelVideoSource;
121
+ providerMetadata?: Record<string, unknown>;
122
+ };
123
+ //#endregion
124
+ export { AudioContentBase, EmbeddingContentBase, FileContentBase, GenerativeModelAudioSource, GenerativeModelFileSource, GenerativeModelImageSource, GenerativeModelVideoSource, ImageContentBase, ReasoningContentBase, TextContentBase, TranscriptContentBase, VideoContentBase };
125
+ //# sourceMappingURL=content.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.mts","names":[],"sources":["../../../src/providers/types/content.ts"],"mappings":";KAAK,gCAAA;EAEK,IAAA;EACA,GAAA;AAAA;EAGA,IAAA;EACA,IAAA;EACA,QAAA;AAAA;;;;KAME,0BAAA,GAA6B,gCAAA;AAAzC;;;AAAA,KAKY,eAAA;EACR,IAAA;EACA,IAAA;EACA,gBAAA,GAAmB,MAAA;AAAA;;;;KAMX,gBAAA;EACR,IAAA;EACA,MAAA,EAAQ,0BAAA;EACR,gBAAA,GAAmB,MAAA;AAAA;;;;;;;;;;KAYX,yBAAA;EAEF,IAAA;EACA,GAAA;EACA,QAAA;EACA,QAAA;AAAA;EAGA,IAAA;EACA,IAAA;EACA,QAAA;EACA,QAAA;AAAA;EAGA,IAAA;EACA,GAAA;IACI,QAAA;IACA,EAAA;EAAA;EAEJ,QAAA;EACA,QAAA;AAAA;;;AAMV;KAAY,eAAA;EACR,IAAA;EACA,MAAA,EAAQ,yBAAA;EACR,gBAAA,GAAmB,MAAA;AAAA;;;;KAMX,0BAAA,GAA6B,gCAAA;;AAAzC;;KAKY,gBAAA;EACR,IAAA;EACA,MAAA,EAAQ,0BAAA;EACR,gBAAA,GAAmB,MAAA;AAAA;;;;KAMX,oBAAA;EACR,IAAA;EACA,SAAA;EACA,gBAAA,GAAmB,MAAA;AAAA;;AAHvB;;KASY,qBAAA;EACR,IAAA;EACA,IAAA;EACA,QAAA,GAAW,KAAA;IACP,EAAA;IACA,KAAA;IACA,GAAA;IACA,IAAA;IACA,OAAA;EAAA;EAEJ,gBAAA,GAAmB,MAAA;AAAA;;;;KAMX,oBAAA;EACR,IAAA;EACA,IAAA;EACA,UAAA;EACA,QAAA;EACA,gBAAA,GAAmB,MAAA;AAAA;;;;KAMX,0BAAA,GAA6B,gCAAA;;;;KAK7B,gBAAA;EACR,IAAA;EACA,MAAA,EAAQ,0BAAA;EACR,gBAAA,GAAmB,MAAA;AAAA"}