@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/README.md +6 -6
- package/dist/{chunk-MYJCN2H7.mjs → chunk-4RNTOVBH.mjs} +395 -30
- package/dist/index.d.mts +37 -9
- package/dist/index.d.ts +37 -9
- package/dist/index.js +395 -29
- package/dist/index.mjs +1 -1
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +395 -29
- package/dist/index.node.mjs +1 -1
- package/dist/index.workers.d.mts +1 -1
- package/dist/index.workers.d.ts +1 -1
- package/dist/index.workers.js +395 -29
- package/dist/index.workers.mjs +1 -1
- package/package.json +7 -7
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
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
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
|
|
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
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
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
|
|
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 };
|