blink 0.1.67 → 0.1.69
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/browser/api/index.browser.d.cts +1 -1
- package/dist/browser/api/index.browser.d.ts +1 -1
- package/dist/browser/{client-J5gD4j_a.d.ts → client-LG-tSJAT.d.ts} +1 -1
- package/dist/browser/{client-Co98ZOqj.d.cts → client-lXd2XNhf.d.cts} +1 -1
- package/dist/browser/http/index.d.cts +2 -2
- package/dist/browser/http/index.d.ts +2 -2
- package/dist/{node/index.browser-wBJ4jcnM.d.cts → browser/index.browser-DSTjG8Ih.d.ts} +50 -19
- package/dist/{node/index.browser-D1y2mwdW.d.ts → browser/index.browser-DokYAoMj.d.cts} +50 -19
- package/dist/browser/react/index.cjs +1 -1
- package/dist/browser/react/index.d.cts +2 -2
- package/dist/browser/react/index.d.ts +2 -2
- package/dist/browser/react/index.js +1 -1
- package/dist/cli/{dev-BAQJ4XqP.js → dev-BnaJT8A_.js} +10 -4
- package/dist/cli/index.js +3 -3
- package/dist/cli/{util-cVEGIV3r.js → util-D3Iuwmav.js} +5 -5
- package/dist/node/api/index.node.d.cts +1 -1
- package/dist/node/api/index.node.d.ts +1 -1
- package/dist/node/build/index.cjs +1 -1
- package/dist/node/build/index.js +4 -4
- package/dist/{browser/index.browser-CHLe3dau.d.cts → node/index.browser-BxnYzsYC.d.ts} +50 -19
- package/dist/{browser/index.browser-Db4eudpn.d.ts → node/index.browser-C1lOzjkX.d.cts} +50 -19
- package/dist/node/test.d.cts +1 -1
- package/dist/node/test.d.ts +1 -1
- package/package.json +1 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, ExtractUIOptions, Message, MessageOptions, OptionSelect, OptionSelectValue, Options, OptionsSchema, ProvideOptionsRequest, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolSetWithApproval, ToolWithApproval, ToolWithContext, WithUIOptions, chat, isToolApprovalOutput, lastUIOptions, storage, toolWithApproval, tools, withResponseFormat } from "../index.browser-
|
|
1
|
+
import { AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, ExtractUIOptions, Message, MessageOptions, OptionSelect, OptionSelectValue, Options, OptionsSchema, ProvideOptionsRequest, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolSetWithApproval, ToolWithApproval, ToolWithContext, WithUIOptions, chat, isToolApprovalOutput, lastUIOptions, storage, toolWithApproval, tools, withResponseFormat } from "../index.browser-DokYAoMj.cjs";
|
|
2
2
|
export { AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, ExtractUIOptions, Message, MessageOptions, OptionSelect, OptionSelectValue, Options, OptionsSchema, ProvideOptionsRequest, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolSetWithApproval, ToolWithApproval, ToolWithContext, WithUIOptions, chat, isToolApprovalOutput, lastUIOptions, storage, toolWithApproval, tools, withResponseFormat };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, ExtractUIOptions, Message, MessageOptions, OptionSelect, OptionSelectValue, Options, OptionsSchema, ProvideOptionsRequest, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolSetWithApproval, ToolWithApproval, ToolWithContext, WithUIOptions, chat, isToolApprovalOutput, lastUIOptions, storage, toolWithApproval, tools, withResponseFormat } from "../index.browser-
|
|
1
|
+
import { AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, ExtractUIOptions, Message, MessageOptions, OptionSelect, OptionSelectValue, Options, OptionsSchema, ProvideOptionsRequest, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolSetWithApproval, ToolWithApproval, ToolWithContext, WithUIOptions, chat, isToolApprovalOutput, lastUIOptions, storage, toolWithApproval, tools, withResponseFormat } from "../index.browser-DSTjG8Ih.js";
|
|
2
2
|
export { AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, ExtractUIOptions, Message, MessageOptions, OptionSelect, OptionSelectValue, Options, OptionsSchema, ProvideOptionsRequest, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolSetWithApproval, ToolWithApproval, ToolWithContext, WithUIOptions, chat, isToolApprovalOutput, lastUIOptions, storage, toolWithApproval, tools, withResponseFormat };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chat, ExperimentalCompletion, OptionsSchema, ProvideOptionsRequest, WithUIOptions } from "./index.browser-
|
|
1
|
+
import { Chat, ExperimentalCompletion, OptionsSchema, ProvideOptionsRequest, WithUIOptions } from "./index.browser-DSTjG8Ih.js";
|
|
2
2
|
import { UIMessage, UIMessageChunk } from "ai";
|
|
3
3
|
|
|
4
4
|
//#region src/api/internal/client.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chat, ExperimentalCompletion, OptionsSchema, ProvideOptionsRequest, WithUIOptions } from "./index.browser-
|
|
1
|
+
import { Chat, ExperimentalCompletion, OptionsSchema, ProvideOptionsRequest, WithUIOptions } from "./index.browser-DokYAoMj.cjs";
|
|
2
2
|
import { UIMessage, UIMessageChunk } from "ai";
|
|
3
3
|
|
|
4
4
|
//#region src/api/internal/client.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Chat, ChatBehavior, Message } from "../index.browser-
|
|
2
|
-
import { APIServerURLEnvironmentVariable, CapabilitiesResponse, Client, ClientOptions, ExperimentalProvideCompletionsRequest, SendMessagesRequest, StreamResponseFormatHeader, streamSSE } from "../client-
|
|
1
|
+
import { Chat, ChatBehavior, Message } from "../index.browser-DokYAoMj.cjs";
|
|
2
|
+
import { APIServerURLEnvironmentVariable, CapabilitiesResponse, Client, ClientOptions, ExperimentalProvideCompletionsRequest, SendMessagesRequest, StreamResponseFormatHeader, streamSSE } from "../client-lXd2XNhf.cjs";
|
|
3
3
|
import { UIMessageChunk } from "ai";
|
|
4
4
|
import * as hono_types0 from "hono/types";
|
|
5
5
|
import * as hono_hono_base0 from "hono/hono-base";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Chat, ChatBehavior, Message } from "../index.browser-
|
|
2
|
-
import { APIServerURLEnvironmentVariable, CapabilitiesResponse, Client, ClientOptions, ExperimentalProvideCompletionsRequest, SendMessagesRequest, StreamResponseFormatHeader, streamSSE } from "../client-
|
|
1
|
+
import { Chat, ChatBehavior, Message } from "../index.browser-DSTjG8Ih.js";
|
|
2
|
+
import { APIServerURLEnvironmentVariable, CapabilitiesResponse, Client, ClientOptions, ExperimentalProvideCompletionsRequest, SendMessagesRequest, StreamResponseFormatHeader, streamSSE } from "../client-LG-tSJAT.js";
|
|
3
3
|
import { UIMessageChunk } from "ai";
|
|
4
4
|
import * as hono_types0 from "hono/types";
|
|
5
5
|
import * as hono_hono_base0 from "hono/hono-base";
|
|
@@ -25,6 +25,19 @@ declare const chat: Readonly<{
|
|
|
25
25
|
message: (id: string, message: Message, options?: MessageOptions) => Promise<void>;
|
|
26
26
|
}>;
|
|
27
27
|
//#endregion
|
|
28
|
+
//#region src/api/storage.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* Storage allows agents to persist data.
|
|
31
|
+
* Every agent has it's own persistent storage namespace.
|
|
32
|
+
*/
|
|
33
|
+
declare const storage: Readonly<{
|
|
34
|
+
kv: Readonly<{
|
|
35
|
+
get: (key: string) => Promise<string | undefined>;
|
|
36
|
+
set: (key: string, value: string) => Promise<void>;
|
|
37
|
+
del: (key: string) => Promise<void>;
|
|
38
|
+
}>;
|
|
39
|
+
}>;
|
|
40
|
+
//#endregion
|
|
28
41
|
//#region src/api/tools.d.ts
|
|
29
42
|
/**
|
|
30
43
|
* ToolWithContext is a tool that supports the "withContext" method.
|
|
@@ -124,19 +137,6 @@ interface ToolApprovalOutput {
|
|
|
124
137
|
*/
|
|
125
138
|
declare function isToolApprovalOutput(output: unknown): output is ToolApprovalOutput;
|
|
126
139
|
//#endregion
|
|
127
|
-
//#region src/api/storage.d.ts
|
|
128
|
-
/**
|
|
129
|
-
* Storage allows agents to persist data.
|
|
130
|
-
* Every agent has it's own persistent storage namespace.
|
|
131
|
-
*/
|
|
132
|
-
declare const storage: Readonly<{
|
|
133
|
-
kv: Readonly<{
|
|
134
|
-
get: (key: string) => Promise<string | undefined>;
|
|
135
|
-
set: (key: string, value: string) => Promise<void>;
|
|
136
|
-
del: (key: string) => Promise<void>;
|
|
137
|
-
}>;
|
|
138
|
-
}>;
|
|
139
|
-
//#endregion
|
|
140
140
|
//#region src/api/index.browser.d.ts
|
|
141
141
|
/**
|
|
142
142
|
* SendMessagesResponse is the response of the sendMessages function.
|
|
@@ -199,15 +199,49 @@ type ProvideOptionsRequest<MESSAGE extends UIMessage = UIMessage> = {
|
|
|
199
199
|
*/
|
|
200
200
|
readonly selectedOptions?: ExtractUIOptions<MESSAGE>;
|
|
201
201
|
};
|
|
202
|
+
type OptionIcon = `lucide:${string}` | `simple-icons:${string}`;
|
|
202
203
|
type OptionSelectValue<ID extends string = string> = {
|
|
203
204
|
readonly id: ID;
|
|
204
205
|
readonly label: string;
|
|
206
|
+
/**
|
|
207
|
+
* description will provide additional context to the user in the UI.
|
|
208
|
+
*/
|
|
209
|
+
readonly description?: string | Array<{
|
|
210
|
+
readonly text: string;
|
|
211
|
+
readonly color?: "primary" | "muted" | "warning";
|
|
212
|
+
}>;
|
|
213
|
+
/**
|
|
214
|
+
* icon is a slug of a Lucide or SimpleIcons icon.
|
|
215
|
+
* This will only be rendered in a web-based UI.
|
|
216
|
+
*
|
|
217
|
+
* Find icons:
|
|
218
|
+
* - https://simpleicons.org/
|
|
219
|
+
* - https://lucide.dev/icons/
|
|
220
|
+
*/
|
|
221
|
+
readonly icon?: OptionIcon;
|
|
205
222
|
};
|
|
206
223
|
type OptionSelect<Values extends readonly OptionSelectValue[] = readonly OptionSelectValue[]> = {
|
|
207
224
|
readonly type: "select";
|
|
208
|
-
|
|
225
|
+
/**
|
|
226
|
+
* label indicates the purpose of the option.
|
|
227
|
+
* If omitted, it will not be displayed in the UI.
|
|
228
|
+
*/
|
|
229
|
+
readonly label?: string;
|
|
230
|
+
/**
|
|
231
|
+
* icon is a slug of a Lucide or SimpleIcons icon.
|
|
232
|
+
* This will only be rendered in a web-based UI.
|
|
233
|
+
*
|
|
234
|
+
* Find icons:
|
|
235
|
+
* - https://simpleicons.org/
|
|
236
|
+
* - https://lucide.dev/icons/
|
|
237
|
+
*/
|
|
238
|
+
readonly icon?: OptionIcon;
|
|
239
|
+
/**
|
|
240
|
+
* defaultValue is the default value for the option.
|
|
241
|
+
* If omitted, the option will not be selected by default.
|
|
242
|
+
*/
|
|
243
|
+
readonly defaultValue?: Values[number]["id"];
|
|
209
244
|
readonly values: Values;
|
|
210
|
-
readonly defaultValue: Values[number]["id"];
|
|
211
245
|
};
|
|
212
246
|
type Options = Record<string, string>;
|
|
213
247
|
type WithUIOptions<OPTIONS extends Options, MESSAGE extends UIMessage = UIMessage> = MESSAGE & {
|
|
@@ -217,10 +251,7 @@ type WithUIOptions<OPTIONS extends Options, MESSAGE extends UIMessage = UIMessag
|
|
|
217
251
|
};
|
|
218
252
|
};
|
|
219
253
|
type ExtractUIOptions<M> = M extends WithUIOptions<infer O> ? O : never;
|
|
220
|
-
type OptionsSchema<OPTIONS extends Options> = { [K in keyof OPTIONS]: OptionSelect<Array<
|
|
221
|
-
id: OPTIONS[K];
|
|
222
|
-
label: string;
|
|
223
|
-
}>> };
|
|
254
|
+
type OptionsSchema<OPTIONS extends Options> = { [K in keyof OPTIONS]: OptionSelect<Array<OptionSelectValue<OPTIONS[K]>>> };
|
|
224
255
|
/**
|
|
225
256
|
* lastUIOptions finds the last user message with options.
|
|
226
257
|
* Options are stored in message metadata to preserve the history
|
|
@@ -25,6 +25,19 @@ declare const chat: Readonly<{
|
|
|
25
25
|
message: (id: string, message: Message, options?: MessageOptions) => Promise<void>;
|
|
26
26
|
}>;
|
|
27
27
|
//#endregion
|
|
28
|
+
//#region src/api/storage.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* Storage allows agents to persist data.
|
|
31
|
+
* Every agent has it's own persistent storage namespace.
|
|
32
|
+
*/
|
|
33
|
+
declare const storage: Readonly<{
|
|
34
|
+
kv: Readonly<{
|
|
35
|
+
get: (key: string) => Promise<string | undefined>;
|
|
36
|
+
set: (key: string, value: string) => Promise<void>;
|
|
37
|
+
del: (key: string) => Promise<void>;
|
|
38
|
+
}>;
|
|
39
|
+
}>;
|
|
40
|
+
//#endregion
|
|
28
41
|
//#region src/api/tools.d.ts
|
|
29
42
|
/**
|
|
30
43
|
* ToolWithContext is a tool that supports the "withContext" method.
|
|
@@ -124,19 +137,6 @@ interface ToolApprovalOutput {
|
|
|
124
137
|
*/
|
|
125
138
|
declare function isToolApprovalOutput(output: unknown): output is ToolApprovalOutput;
|
|
126
139
|
//#endregion
|
|
127
|
-
//#region src/api/storage.d.ts
|
|
128
|
-
/**
|
|
129
|
-
* Storage allows agents to persist data.
|
|
130
|
-
* Every agent has it's own persistent storage namespace.
|
|
131
|
-
*/
|
|
132
|
-
declare const storage: Readonly<{
|
|
133
|
-
kv: Readonly<{
|
|
134
|
-
get: (key: string) => Promise<string | undefined>;
|
|
135
|
-
set: (key: string, value: string) => Promise<void>;
|
|
136
|
-
del: (key: string) => Promise<void>;
|
|
137
|
-
}>;
|
|
138
|
-
}>;
|
|
139
|
-
//#endregion
|
|
140
140
|
//#region src/api/index.browser.d.ts
|
|
141
141
|
/**
|
|
142
142
|
* SendMessagesResponse is the response of the sendMessages function.
|
|
@@ -199,15 +199,49 @@ type ProvideOptionsRequest<MESSAGE extends UIMessage = UIMessage> = {
|
|
|
199
199
|
*/
|
|
200
200
|
readonly selectedOptions?: ExtractUIOptions<MESSAGE>;
|
|
201
201
|
};
|
|
202
|
+
type OptionIcon = `lucide:${string}` | `simple-icons:${string}`;
|
|
202
203
|
type OptionSelectValue<ID extends string = string> = {
|
|
203
204
|
readonly id: ID;
|
|
204
205
|
readonly label: string;
|
|
206
|
+
/**
|
|
207
|
+
* description will provide additional context to the user in the UI.
|
|
208
|
+
*/
|
|
209
|
+
readonly description?: string | Array<{
|
|
210
|
+
readonly text: string;
|
|
211
|
+
readonly color?: "primary" | "muted" | "warning";
|
|
212
|
+
}>;
|
|
213
|
+
/**
|
|
214
|
+
* icon is a slug of a Lucide or SimpleIcons icon.
|
|
215
|
+
* This will only be rendered in a web-based UI.
|
|
216
|
+
*
|
|
217
|
+
* Find icons:
|
|
218
|
+
* - https://simpleicons.org/
|
|
219
|
+
* - https://lucide.dev/icons/
|
|
220
|
+
*/
|
|
221
|
+
readonly icon?: OptionIcon;
|
|
205
222
|
};
|
|
206
223
|
type OptionSelect<Values extends readonly OptionSelectValue[] = readonly OptionSelectValue[]> = {
|
|
207
224
|
readonly type: "select";
|
|
208
|
-
|
|
225
|
+
/**
|
|
226
|
+
* label indicates the purpose of the option.
|
|
227
|
+
* If omitted, it will not be displayed in the UI.
|
|
228
|
+
*/
|
|
229
|
+
readonly label?: string;
|
|
230
|
+
/**
|
|
231
|
+
* icon is a slug of a Lucide or SimpleIcons icon.
|
|
232
|
+
* This will only be rendered in a web-based UI.
|
|
233
|
+
*
|
|
234
|
+
* Find icons:
|
|
235
|
+
* - https://simpleicons.org/
|
|
236
|
+
* - https://lucide.dev/icons/
|
|
237
|
+
*/
|
|
238
|
+
readonly icon?: OptionIcon;
|
|
239
|
+
/**
|
|
240
|
+
* defaultValue is the default value for the option.
|
|
241
|
+
* If omitted, the option will not be selected by default.
|
|
242
|
+
*/
|
|
243
|
+
readonly defaultValue?: Values[number]["id"];
|
|
209
244
|
readonly values: Values;
|
|
210
|
-
readonly defaultValue: Values[number]["id"];
|
|
211
245
|
};
|
|
212
246
|
type Options = Record<string, string>;
|
|
213
247
|
type WithUIOptions<OPTIONS extends Options, MESSAGE extends UIMessage = UIMessage> = MESSAGE & {
|
|
@@ -217,10 +251,7 @@ type WithUIOptions<OPTIONS extends Options, MESSAGE extends UIMessage = UIMessag
|
|
|
217
251
|
};
|
|
218
252
|
};
|
|
219
253
|
type ExtractUIOptions<M> = M extends WithUIOptions<infer O> ? O : never;
|
|
220
|
-
type OptionsSchema<OPTIONS extends Options> = { [K in keyof OPTIONS]: OptionSelect<Array<
|
|
221
|
-
id: OPTIONS[K];
|
|
222
|
-
label: string;
|
|
223
|
-
}>> };
|
|
254
|
+
type OptionsSchema<OPTIONS extends Options> = { [K in keyof OPTIONS]: OptionSelect<Array<OptionSelectValue<OPTIONS[K]>>> };
|
|
224
255
|
/**
|
|
225
256
|
* lastUIOptions finds the last user message with options.
|
|
226
257
|
* Options are stored in message metadata to preserve the history
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../client-DFaZjb1-.cjs`),t=require(`../index.browser-BwGhLjB7.cjs`);let n=require(`react`);n=e.__toESM(n);function r({agent:e,capabilities:r,messages:i}){let[a,o]=(0,n.useState)(void 0),[s,c]=(0,n.useState)(!0),[l,u]=(0,n.useState)(void 0),d=(0,n.
|
|
1
|
+
const e=require(`../client-DFaZjb1-.cjs`),t=require(`../index.browser-BwGhLjB7.cjs`);let n=require(`react`);n=e.__toESM(n);function r({agent:e,capabilities:r,messages:i}){let[a,o]=(0,n.useState)(void 0),[s,c]=(0,n.useState)(!0),[l,u]=(0,n.useState)(void 0),d=(0,n.useRef)(l);(0,n.useEffect)(()=>{d.current=l},[l]);let[f,p]=(0,n.useState)(()=>t.lastUIOptions(i));(0,n.useEffect)(()=>{p(e=>{let n=t.lastUIOptions(i);return JSON.stringify(n)===JSON.stringify(e)?e:n})},[i]);let[m,h]=(0,n.useState)(void 0),g=(0,n.useCallback)((e,t)=>{if(!d.current)return!1;let n=d.current[e];return n?n.values.some(e=>e.id===t):!1},[]),_=(0,n.useCallback)(e=>{h(t=>{let n={...f,...t,...e};for(let[e,t]of Object.entries(n))g(e,t)||delete n[e];for(let[e,t]of Object.entries(d.current??{}))!n[e]&&t.defaultValue!==void 0&&(n[e]=t.defaultValue);return JSON.stringify(n)===JSON.stringify(t)?t:n})},[f,g]);(0,n.useEffect)(()=>{if(!f&&!l){h(void 0);return}_()},[f,l,_]),(0,n.useEffect)(()=>{if(r&&!r.options||!e){u(void 0),h(void 0),o(void 0);return}if(d.current&&m){let e=Object.entries(d.current).every(([e,t])=>m[e]===t.defaultValue);if(e){c(!1),o(void 0);return}}let t=new AbortController;return c(!0),o(void 0),e.provideUIOptions(m?{selectedOptions:m}:{},{signal:t.signal}).then(e=>{t.signal.aborted||u(t=>JSON.stringify(t)===JSON.stringify(e)?t:e)}).catch(e=>{t.signal.aborted||o(e instanceof Error?e:Error(String(e)))}).finally(()=>{c(!1)}),()=>{t.abort()}},[e,r,m]);let v=(0,n.useCallback)((e,t)=>{_({[e]:t})},[_]);return{schema:l,options:m,setOption:v,loading:s,error:a}}exports.useOptions=r;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Options, OptionsSchema } from "../index.browser-
|
|
2
|
-
import { CapabilitiesResponse, Client } from "../client-
|
|
1
|
+
import { Options, OptionsSchema } from "../index.browser-DokYAoMj.cjs";
|
|
2
|
+
import { CapabilitiesResponse, Client } from "../client-lXd2XNhf.cjs";
|
|
3
3
|
import { UIMessage } from "ai";
|
|
4
4
|
|
|
5
5
|
//#region src/react/use-options.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Options, OptionsSchema } from "../index.browser-
|
|
2
|
-
import { CapabilitiesResponse, Client } from "../client-
|
|
1
|
+
import { Options, OptionsSchema } from "../index.browser-DSTjG8Ih.js";
|
|
2
|
+
import { CapabilitiesResponse, Client } from "../client-LG-tSJAT.js";
|
|
3
3
|
import { UIMessage } from "ai";
|
|
4
4
|
|
|
5
5
|
//#region src/react/use-options.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../client-BbZudkEc.js";import{lastUIOptions as e}from"../index.browser-Dj8kjB6X.js";import{useCallback as t,useEffect as n,
|
|
1
|
+
import"../client-BbZudkEc.js";import{lastUIOptions as e}from"../index.browser-Dj8kjB6X.js";import{useCallback as t,useEffect as n,useRef as r,useState as i}from"react";function a({agent:a,capabilities:o,messages:s}){let[c,l]=i(void 0),[u,d]=i(!0),[f,p]=i(void 0),m=r(f);n(()=>{m.current=f},[f]);let[h,g]=i(()=>e(s));n(()=>{g(t=>{let n=e(s);return JSON.stringify(n)===JSON.stringify(t)?t:n})},[s]);let[_,v]=i(void 0),y=t((e,t)=>{if(!m.current)return!1;let n=m.current[e];return n?n.values.some(e=>e.id===t):!1},[]),b=t(e=>{v(t=>{let n={...h,...t,...e};for(let[e,t]of Object.entries(n))y(e,t)||delete n[e];for(let[e,t]of Object.entries(m.current??{}))!n[e]&&t.defaultValue!==void 0&&(n[e]=t.defaultValue);return JSON.stringify(n)===JSON.stringify(t)?t:n})},[h,y]);n(()=>{if(!h&&!f){v(void 0);return}b()},[h,f,b]),n(()=>{if(o&&!o.options||!a){p(void 0),v(void 0),l(void 0);return}if(m.current&&_){let e=Object.entries(m.current).every(([e,t])=>_[e]===t.defaultValue);if(e){d(!1),l(void 0);return}}let e=new AbortController;return d(!0),l(void 0),a.provideUIOptions(_?{selectedOptions:_}:{},{signal:e.signal}).then(t=>{e.signal.aborted||p(e=>JSON.stringify(e)===JSON.stringify(t)?e:t)}).catch(t=>{e.signal.aborted||l(t instanceof Error?t:Error(String(t)))}).finally(()=>{d(!1)}),()=>{e.abort()}},[a,o,_]);let x=t((e,t)=>{b({[e]:t})},[b]);return{schema:f,options:_,setOption:x,loading:u,error:c}}export{a as useOptions};
|