@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.
Files changed (80) hide show
  1. package/README.md +2 -0
  2. package/dist/AgoClient-DPZdN5n2.js +905 -0
  3. package/dist/AgoClient-DPZdN5n2.js.map +1 -0
  4. package/dist/AgoClient-wMVUQqCD.cjs +976 -0
  5. package/dist/AgoClient-wMVUQqCD.cjs.map +1 -0
  6. package/dist/angular.cjs +138 -100
  7. package/dist/angular.cjs.map +1 -1
  8. package/dist/angular.d.ts +1 -0
  9. package/dist/angular.js +139 -103
  10. package/dist/angular.js.map +1 -1
  11. package/dist/client/AgoClient.d.ts +56 -0
  12. package/dist/client/types.d.ts +5 -1
  13. package/dist/createMockClient-Ci_N2tH8.cjs +104 -0
  14. package/dist/createMockClient-Ci_N2tH8.cjs.map +1 -0
  15. package/dist/createMockClient-U0ae_AYy.js +99 -0
  16. package/dist/createMockClient-U0ae_AYy.js.map +1 -0
  17. package/dist/devtools/index.d.ts +2 -0
  18. package/dist/devtools/initDevPanel.d.ts +15 -0
  19. package/dist/devtools.cjs +182 -0
  20. package/dist/devtools.cjs.map +1 -0
  21. package/dist/devtools.d.ts +2 -0
  22. package/dist/devtools.js +181 -0
  23. package/dist/devtools.js.map +1 -0
  24. package/dist/functions--c6lx3ic.cjs +480 -0
  25. package/dist/functions--c6lx3ic.cjs.map +1 -0
  26. package/dist/functions-C9F1dnmh.js +398 -0
  27. package/dist/functions-C9F1dnmh.js.map +1 -0
  28. package/dist/helpers/factory.d.ts +20 -0
  29. package/dist/helpers.cjs +14 -305
  30. package/dist/helpers.d.ts +1 -0
  31. package/dist/helpers.js +2 -306
  32. package/dist/index.cjs +316 -151
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.ts +14 -9
  35. package/dist/index.js +289 -163
  36. package/dist/index.js.map +1 -1
  37. package/dist/react/components/ChatWidget.d.ts +2 -0
  38. package/dist/react/components/Markdown.d.ts +12 -0
  39. package/dist/react/components/Message.d.ts +2 -0
  40. package/dist/react/components/index.d.ts +2 -0
  41. package/dist/react/context/AgoContext.d.ts +29 -3
  42. package/dist/react/context/index.d.ts +1 -1
  43. package/dist/react/hooks/index.d.ts +1 -0
  44. package/dist/react/hooks/useAgoContext.d.ts +40 -0
  45. package/dist/react/hooks/useAgoFunction.d.ts +14 -2
  46. package/dist/react/hooks/useAgoStore.d.ts +17 -0
  47. package/dist/react/index.d.ts +5 -1
  48. package/dist/react.cjs +22130 -10274
  49. package/dist/react.cjs.map +1 -1
  50. package/dist/react.d.ts +1 -0
  51. package/dist/react.js +22128 -10289
  52. package/dist/react.js.map +1 -1
  53. package/dist/rolldown-runtime-BqCkTl7Q.cjs +50 -0
  54. package/dist/rolldown-runtime-CNZpIYwj.js +33 -0
  55. package/dist/state/ClientContextRegistry.d.ts +64 -0
  56. package/dist/state/createStore.d.ts +30 -0
  57. package/dist/vue/composables/useAgoStore.d.ts +18 -0
  58. package/dist/vue/index.d.ts +1 -0
  59. package/dist/vue.cjs +312 -208
  60. package/dist/vue.cjs.map +1 -1
  61. package/dist/vue.d.ts +1 -0
  62. package/dist/vue.js +311 -218
  63. package/dist/vue.js.map +1 -1
  64. package/dist/widget/types.d.ts +1 -0
  65. package/dist/widget.cjs +0 -2
  66. package/dist/widget.d.ts +1 -0
  67. package/dist/widget.js +0 -2
  68. package/package.json +6 -1
  69. package/dist/AgoClient-B-SONi_K.js +0 -861
  70. package/dist/AgoClient-B-SONi_K.js.map +0 -1
  71. package/dist/AgoClient-xTWfMWKh.cjs +0 -860
  72. package/dist/AgoClient-xTWfMWKh.cjs.map +0 -1
  73. package/dist/createMockClient-B1DcBiIK.js +0 -94
  74. package/dist/createMockClient-B1DcBiIK.js.map +0 -1
  75. package/dist/createMockClient-BqNSJUu4.cjs +0 -93
  76. package/dist/createMockClient-BqNSJUu4.cjs.map +0 -1
  77. package/dist/helpers.cjs.map +0 -1
  78. package/dist/helpers.js.map +0 -1
  79. package/dist/widget.cjs.map +0 -1
  80. 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
- * useAgoFunction("showToast", {
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;
@@ -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";