@useago/sdk 0.3.0 → 0.3.2
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 +2 -0
- package/dist/AgoClient-DPZdN5n2.js +905 -0
- package/dist/AgoClient-DPZdN5n2.js.map +1 -0
- package/dist/AgoClient-wMVUQqCD.cjs +976 -0
- package/dist/AgoClient-wMVUQqCD.cjs.map +1 -0
- package/dist/angular.cjs +138 -100
- package/dist/angular.cjs.map +1 -1
- package/dist/angular.d.ts +1 -0
- package/dist/angular.js +139 -103
- package/dist/angular.js.map +1 -1
- package/dist/client/AgoClient.d.ts +56 -0
- package/dist/client/types.d.ts +5 -1
- package/dist/createMockClient-Ci_N2tH8.cjs +104 -0
- package/dist/createMockClient-Ci_N2tH8.cjs.map +1 -0
- package/dist/createMockClient-U0ae_AYy.js +99 -0
- package/dist/createMockClient-U0ae_AYy.js.map +1 -0
- package/dist/devtools/index.d.ts +2 -0
- package/dist/devtools/initDevPanel.d.ts +15 -0
- package/dist/devtools.cjs +182 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.ts +2 -0
- package/dist/devtools.js +181 -0
- package/dist/devtools.js.map +1 -0
- package/dist/functions--c6lx3ic.cjs +480 -0
- package/dist/functions--c6lx3ic.cjs.map +1 -0
- package/dist/functions-C9F1dnmh.js +398 -0
- package/dist/functions-C9F1dnmh.js.map +1 -0
- package/dist/helpers/factory.d.ts +20 -0
- package/dist/helpers.cjs +14 -305
- package/dist/helpers.d.ts +1 -0
- package/dist/helpers.js +2 -306
- package/dist/index.cjs +316 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -9
- package/dist/index.js +289 -163
- package/dist/index.js.map +1 -1
- package/dist/react/components/ChatWidget.d.ts +2 -0
- package/dist/react/components/Markdown.d.ts +12 -0
- package/dist/react/components/Message.d.ts +2 -0
- package/dist/react/components/index.d.ts +2 -0
- package/dist/react/context/AgoContext.d.ts +29 -3
- package/dist/react/context/index.d.ts +1 -1
- package/dist/react/hooks/index.d.ts +1 -0
- package/dist/react/hooks/useAgoContext.d.ts +40 -0
- package/dist/react/hooks/useAgoFunction.d.ts +14 -2
- package/dist/react/hooks/useAgoStore.d.ts +17 -0
- package/dist/react/index.d.ts +5 -1
- package/dist/react.cjs +22130 -10274
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +1 -0
- package/dist/react.js +22128 -10289
- package/dist/react.js.map +1 -1
- package/dist/rolldown-runtime-BqCkTl7Q.cjs +50 -0
- package/dist/rolldown-runtime-CNZpIYwj.js +33 -0
- package/dist/state/ClientContextRegistry.d.ts +64 -0
- package/dist/state/createStore.d.ts +30 -0
- package/dist/vue/composables/useAgoStore.d.ts +18 -0
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue.cjs +312 -208
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.ts +1 -0
- package/dist/vue.js +311 -218
- package/dist/vue.js.map +1 -1
- package/dist/widget/types.d.ts +1 -0
- package/dist/widget.cjs +0 -2
- package/dist/widget.d.ts +1 -0
- package/dist/widget.js +0 -2
- package/package.json +6 -1
- package/dist/AgoClient-B-SONi_K.js +0 -861
- package/dist/AgoClient-B-SONi_K.js.map +0 -1
- package/dist/AgoClient-xTWfMWKh.cjs +0 -860
- package/dist/AgoClient-xTWfMWKh.cjs.map +0 -1
- package/dist/createMockClient-B1DcBiIK.js +0 -94
- package/dist/createMockClient-B1DcBiIK.js.map +0 -1
- package/dist/createMockClient-BqNSJUu4.cjs +0 -93
- package/dist/createMockClient-BqNSJUu4.cjs.map +0 -1
- package/dist/helpers.cjs.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/widget.cjs.map +0 -1
- package/dist/widget.js.map +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ContextEntry, DynamicContextProvider } from "../../state/ClientContextRegistry";
|
|
2
|
+
/**
|
|
3
|
+
* Declaratively expose a piece of context to the AI agent with every message.
|
|
4
|
+
*
|
|
5
|
+
* Accepts either:
|
|
6
|
+
* - An **object** — sent as-is on every message (re-registered when it changes).
|
|
7
|
+
* Use for data that already lives in React state.
|
|
8
|
+
* - A **function** — called lazily at each message send, so the AI always gets
|
|
9
|
+
* the freshest value. Use for data outside React state (global stores, refs,
|
|
10
|
+
* computed values).
|
|
11
|
+
*
|
|
12
|
+
* A unique key is auto-generated per component instance via `useId()`. Pass an
|
|
13
|
+
* explicit key as second argument to share context across components or
|
|
14
|
+
* reference it from elsewhere.
|
|
15
|
+
*
|
|
16
|
+
* ```tsx
|
|
17
|
+
* // Static object — captured at render time
|
|
18
|
+
* function OrderPage({ order }) {
|
|
19
|
+
* useAgoContext({
|
|
20
|
+
* name: "Order detail",
|
|
21
|
+
* description: "The user is viewing a specific order",
|
|
22
|
+
* data: { orderId: order.id, status: order.status },
|
|
23
|
+
* });
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Dynamic function — evaluated at each sendMessage
|
|
27
|
+
* function App() {
|
|
28
|
+
* const storeRef = useRef(reduxStore);
|
|
29
|
+
* useAgoContext(() => {
|
|
30
|
+
* const state = storeRef.current.getState();
|
|
31
|
+
* return { name: "App shell", data: { userId: state.auth.userId } };
|
|
32
|
+
* });
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* // With an explicit key
|
|
36
|
+
* useAgoContext({ name: "Sidebar filter", data: { filter } }, "sidebar-filter");
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function useAgoContext(entry: ContextEntry, key?: string): void;
|
|
40
|
+
export declare function useAgoContext(provider: DynamicContextProvider, key?: string): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClientFunctionHandler } from "../../functions/types";
|
|
1
|
+
import type { ClientFunctionDefinition, ClientFunctionHandler } from "../../functions/types";
|
|
2
2
|
export interface UseAgoFunctionOptions {
|
|
3
3
|
description: string;
|
|
4
4
|
parameters: {
|
|
@@ -17,14 +17,26 @@ export interface UseAgoFunctionOptions {
|
|
|
17
17
|
* Declaratively register a client-side function with the AGO agent.
|
|
18
18
|
* Automatically unregisters on unmount and re-registers when deps change.
|
|
19
19
|
*
|
|
20
|
+
* Accepts either a full definition object (preferred) or classic (name, options) args.
|
|
21
|
+
*
|
|
20
22
|
* ```tsx
|
|
21
|
-
*
|
|
23
|
+
* // Preferred — pass the whole definition
|
|
24
|
+
* useAgoFunction({
|
|
25
|
+
* name: "showToast",
|
|
22
26
|
* description: "Show a notification to the user",
|
|
23
27
|
* parameters: { type: "object", properties: { message: { type: "string" } } },
|
|
24
28
|
* handler: async (args) => { toast(args.message); return { shown: true }; },
|
|
25
29
|
* });
|
|
30
|
+
*
|
|
31
|
+
* // Or reuse a pre-defined function
|
|
32
|
+
* const lookupOrder = defineFunction({ name: "lookupOrder", ... });
|
|
33
|
+
* useAgoFunction(lookupOrder);
|
|
34
|
+
*
|
|
35
|
+
* // Classic form
|
|
36
|
+
* useAgoFunction("showToast", { description: "...", parameters: {...}, handler: async (args) => ... });
|
|
26
37
|
* ```
|
|
27
38
|
*/
|
|
39
|
+
export declare function useAgoFunction(definition: ClientFunctionDefinition): void;
|
|
28
40
|
export declare function useAgoFunction(name: string, options: UseAgoFunctionOptions): void;
|
|
29
41
|
export interface AgoRoute {
|
|
30
42
|
name: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Store } from "../../state/createStore";
|
|
2
|
+
/**
|
|
3
|
+
* Read a framework-agnostic AGO store (`createStore`) reactively in React.
|
|
4
|
+
*
|
|
5
|
+
* Re-renders the component whenever the store's value changes. Mutate the store
|
|
6
|
+
* via `store.set(...)`, not the value returned here.
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* const cart = createStore({ items: [] as string[] });
|
|
10
|
+
*
|
|
11
|
+
* function CartBadge() {
|
|
12
|
+
* const { items } = useAgoStore(cart);
|
|
13
|
+
* return <span>{items.length}</span>;
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function useAgoStore<T>(store: Store<T>): T;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { AgoProvider, useAgoClient, useOptionalAgoClient } from "./context";
|
|
2
|
-
export type { AgoProviderProps } from "./context";
|
|
2
|
+
export type { AgoProviderProps, AgoDeclarativeConfig } from "./context/AgoContext";
|
|
3
3
|
export { ChatWidget } from "./components/ChatWidget";
|
|
4
4
|
export type { ChatWidgetProps } from "./components/ChatWidget";
|
|
5
5
|
export { Message } from "./components/Message";
|
|
6
6
|
export type { MessageProps } from "./components/Message";
|
|
7
|
+
export { Markdown } from "./components/Markdown";
|
|
8
|
+
export type { MarkdownProps } from "./components/Markdown";
|
|
7
9
|
export { ChatInput } from "./components/ChatInput";
|
|
8
10
|
export type { ChatInputProps } from "./components/ChatInput";
|
|
9
11
|
export { useAgo } from "./hooks/useAgo";
|
|
@@ -16,5 +18,7 @@ export { useChat } from "./hooks/useChat";
|
|
|
16
18
|
export type { UseChatOptions, UseChatResult } from "./hooks/useChat";
|
|
17
19
|
export { useAgoFunction, useAgoNavigation } from "./hooks/useAgoFunction";
|
|
18
20
|
export type { UseAgoFunctionOptions, AgoRoute } from "./hooks/useAgoFunction";
|
|
21
|
+
export { useAgoContext } from "./hooks/useAgoContext";
|
|
22
|
+
export { useAgoStore } from "./hooks/useAgoStore";
|
|
19
23
|
export { createMockClient } from "./testing";
|
|
20
24
|
export type { AgoConfig, AgoMessage, Conversation, AgoAgent, AgoSource, ToolCallData, } from "../client/types";
|