@raindrop-ai/ai-sdk 0.0.16 → 0.0.18

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.
package/dist/index.d.mts CHANGED
@@ -81,6 +81,34 @@ type EventMetadataOptions = {
81
81
  * ```
82
82
  */
83
83
  declare function eventMetadata(options: EventMetadataOptions): Record<string, string>;
84
+ type AISDKChatRequestMessageLike = {
85
+ id?: string;
86
+ role?: string;
87
+ [key: string]: unknown;
88
+ };
89
+ type AISDKChatRequestLike = {
90
+ id?: string;
91
+ messageId?: string;
92
+ trigger?: string;
93
+ messages?: AISDKChatRequestMessageLike[];
94
+ [key: string]: unknown;
95
+ };
96
+ /**
97
+ * Creates stable Raindrop metadata from an AI SDK UI chat request body.
98
+ *
99
+ * This is useful for `useChat` applications that require multiple server round-trips
100
+ * for a single user turn, e.g. when the model triggers client-side tools.
101
+ *
102
+ * The helper derives:
103
+ * - `convoId` from the AI SDK chat request `id`
104
+ * - `eventId` from the latest user message id in `messages`
105
+ *
106
+ * Reusing the same derived `eventId` across tool handoff round-trips allows the
107
+ * wrapper to patch one logical event instead of creating a new event per POST.
108
+ */
109
+ declare function eventMetadataFromChatRequest(options: EventMetadataOptions & {
110
+ request: AISDKChatRequestLike;
111
+ }): Record<string, string>;
84
112
  type AgentCallMetadata = ReturnType<typeof eventMetadata>;
85
113
  type NormalizeUnknownAgentOptions<T> = T extends {
86
114
  options: infer CallOptions;
@@ -102,18 +130,18 @@ type AgentWithMetadata<A> = A extends {
102
130
  metadata?: AgentCallMetadata;
103
131
  }, ...Rest] : StreamArgs): StreamReturn;
104
132
  } : A;
133
+ type AgentConstructor = abstract new (...args: any[]) => any;
134
+ type WrapAgentExport<T extends object, K extends PropertyKey> = K extends keyof T ? T[K] extends AgentConstructor ? Omit<T, K> & {
135
+ [P in K]: new (...args: ConstructorParameters<T[K]>) => AgentWithMetadata<InstanceType<T[K]>>;
136
+ } : T : T;
105
137
  /**
106
138
  * Structural wrapper type for AI SDK modules.
107
139
  *
108
- * - AI SDK v6: rewrites `ToolLoopAgent` constructor instance methods to accept
109
- * `metadata` on `generate/stream`.
110
- * - AI SDK v4/v5: no `ToolLoopAgent` export, so the type is unchanged.
140
+ * Rewrites AI SDK agent constructor exports so their instance `generate()` and
141
+ * `stream()` methods accept Raindrop `metadata` while preserving original
142
+ * return types. Covers the current and deprecated public export names.
111
143
  */
112
- type WrappedAISDK<T extends object> = T extends {
113
- ToolLoopAgent: abstract new (...args: any[]) => any;
114
- } ? Omit<T, "ToolLoopAgent"> & {
115
- ToolLoopAgent: new (...args: ConstructorParameters<T["ToolLoopAgent"]>) => AgentWithMetadata<InstanceType<T["ToolLoopAgent"]>>;
116
- } : T;
144
+ type WrappedAISDK<T extends object> = WrapAgentExport<WrapAgentExport<WrapAgentExport<T, "ToolLoopAgent">, "Experimental_Agent">, "Agent">;
117
145
  /**
118
146
  * Backward-compatible alias for wrapped AI SDK module types.
119
147
  *
@@ -282,4 +310,4 @@ type RaindropAISDKClient = {
282
310
  };
283
311
  declare function createRaindropAISDK(opts: RaindropAISDKOptions): RaindropAISDKClient;
284
312
 
285
- export { type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent };
313
+ export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, withCurrent };
package/dist/index.d.ts CHANGED
@@ -81,6 +81,34 @@ type EventMetadataOptions = {
81
81
  * ```
82
82
  */
83
83
  declare function eventMetadata(options: EventMetadataOptions): Record<string, string>;
84
+ type AISDKChatRequestMessageLike = {
85
+ id?: string;
86
+ role?: string;
87
+ [key: string]: unknown;
88
+ };
89
+ type AISDKChatRequestLike = {
90
+ id?: string;
91
+ messageId?: string;
92
+ trigger?: string;
93
+ messages?: AISDKChatRequestMessageLike[];
94
+ [key: string]: unknown;
95
+ };
96
+ /**
97
+ * Creates stable Raindrop metadata from an AI SDK UI chat request body.
98
+ *
99
+ * This is useful for `useChat` applications that require multiple server round-trips
100
+ * for a single user turn, e.g. when the model triggers client-side tools.
101
+ *
102
+ * The helper derives:
103
+ * - `convoId` from the AI SDK chat request `id`
104
+ * - `eventId` from the latest user message id in `messages`
105
+ *
106
+ * Reusing the same derived `eventId` across tool handoff round-trips allows the
107
+ * wrapper to patch one logical event instead of creating a new event per POST.
108
+ */
109
+ declare function eventMetadataFromChatRequest(options: EventMetadataOptions & {
110
+ request: AISDKChatRequestLike;
111
+ }): Record<string, string>;
84
112
  type AgentCallMetadata = ReturnType<typeof eventMetadata>;
85
113
  type NormalizeUnknownAgentOptions<T> = T extends {
86
114
  options: infer CallOptions;
@@ -102,18 +130,18 @@ type AgentWithMetadata<A> = A extends {
102
130
  metadata?: AgentCallMetadata;
103
131
  }, ...Rest] : StreamArgs): StreamReturn;
104
132
  } : A;
133
+ type AgentConstructor = abstract new (...args: any[]) => any;
134
+ type WrapAgentExport<T extends object, K extends PropertyKey> = K extends keyof T ? T[K] extends AgentConstructor ? Omit<T, K> & {
135
+ [P in K]: new (...args: ConstructorParameters<T[K]>) => AgentWithMetadata<InstanceType<T[K]>>;
136
+ } : T : T;
105
137
  /**
106
138
  * Structural wrapper type for AI SDK modules.
107
139
  *
108
- * - AI SDK v6: rewrites `ToolLoopAgent` constructor instance methods to accept
109
- * `metadata` on `generate/stream`.
110
- * - AI SDK v4/v5: no `ToolLoopAgent` export, so the type is unchanged.
140
+ * Rewrites AI SDK agent constructor exports so their instance `generate()` and
141
+ * `stream()` methods accept Raindrop `metadata` while preserving original
142
+ * return types. Covers the current and deprecated public export names.
111
143
  */
112
- type WrappedAISDK<T extends object> = T extends {
113
- ToolLoopAgent: abstract new (...args: any[]) => any;
114
- } ? Omit<T, "ToolLoopAgent"> & {
115
- ToolLoopAgent: new (...args: ConstructorParameters<T["ToolLoopAgent"]>) => AgentWithMetadata<InstanceType<T["ToolLoopAgent"]>>;
116
- } : T;
144
+ type WrappedAISDK<T extends object> = WrapAgentExport<WrapAgentExport<WrapAgentExport<T, "ToolLoopAgent">, "Experimental_Agent">, "Agent">;
117
145
  /**
118
146
  * Backward-compatible alias for wrapped AI SDK module types.
119
147
  *
@@ -282,4 +310,4 @@ type RaindropAISDKClient = {
282
310
  };
283
311
  declare function createRaindropAISDK(opts: RaindropAISDKOptions): RaindropAISDKClient;
284
312
 
285
- export { type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent };
313
+ export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, withCurrent };