@useago/sdk 0.3.2 → 0.3.4

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 (121) hide show
  1. package/dist/AgoClient-DF7M2WAz.js +575 -0
  2. package/dist/AgoClient-bjN-z2ZQ.cjs +6 -0
  3. package/dist/angular.cjs +1 -143
  4. package/dist/angular.d.cts +530 -0
  5. package/dist/angular.d.ts +530 -2
  6. package/dist/angular.js +71 -139
  7. package/dist/createFormCollector-ClzHfaBd.js +185 -0
  8. package/dist/createFormCollector-H4Me_2uj.cjs +1 -0
  9. package/dist/createMockClient-C50gjV0b.js +71 -0
  10. package/dist/createMockClient-DQvFFWnc.cjs +1 -0
  11. package/dist/devtools.cjs +26 -100
  12. package/dist/devtools.d.cts +443 -0
  13. package/dist/devtools.d.ts +443 -2
  14. package/dist/devtools.js +68 -93
  15. package/dist/functions-BH1X5kas.cjs +1 -0
  16. package/dist/functions-CWSRi3xv.js +312 -0
  17. package/dist/helpers.cjs +1 -15
  18. package/dist/{helpers/functions.d.ts → helpers.d.cts} +121 -62
  19. package/dist/helpers.d.ts +121 -2
  20. package/dist/helpers.js +16 -2
  21. package/dist/index.cjs +1 -347
  22. package/dist/index.d.cts +1150 -0
  23. package/dist/index.d.ts +1150 -20
  24. package/dist/index.js +129 -298
  25. package/dist/react.cjs +31 -22438
  26. package/dist/react.d.cts +999 -0
  27. package/dist/react.d.ts +999 -2
  28. package/dist/react.js +8416 -22376
  29. package/dist/rolldown-runtime-CaekUdDJ.cjs +1 -0
  30. package/dist/rolldown-runtime-DxmricAu.js +25 -0
  31. package/dist/vue.cjs +1 -336
  32. package/dist/vue.d.cts +1063 -0
  33. package/dist/vue.d.ts +1063 -2
  34. package/dist/vue.js +174 -316
  35. package/dist/widget.cjs +1 -0
  36. package/dist/widget.d.cts +577 -0
  37. package/dist/widget.d.ts +577 -2
  38. package/dist/widget.js +398 -0
  39. package/package.json +35 -24
  40. package/dist/AgoClient-DPZdN5n2.js +0 -905
  41. package/dist/AgoClient-DPZdN5n2.js.map +0 -1
  42. package/dist/AgoClient-wMVUQqCD.cjs +0 -976
  43. package/dist/AgoClient-wMVUQqCD.cjs.map +0 -1
  44. package/dist/angular/ago.service.d.ts +0 -98
  45. package/dist/angular/index.d.ts +0 -4
  46. package/dist/angular/provide.d.ts +0 -27
  47. package/dist/angular.cjs.map +0 -1
  48. package/dist/angular.js.map +0 -1
  49. package/dist/api/HttpClient.d.ts +0 -31
  50. package/dist/api/index.d.ts +0 -1
  51. package/dist/auto/createAgo.d.ts +0 -39
  52. package/dist/auto/index.d.ts +0 -1
  53. package/dist/client/AgoClient.d.ts +0 -169
  54. package/dist/client/errors.d.ts +0 -48
  55. package/dist/client/index.d.ts +0 -3
  56. package/dist/client/types.d.ts +0 -205
  57. package/dist/createMockClient-Ci_N2tH8.cjs +0 -104
  58. package/dist/createMockClient-Ci_N2tH8.cjs.map +0 -1
  59. package/dist/createMockClient-U0ae_AYy.js +0 -99
  60. package/dist/createMockClient-U0ae_AYy.js.map +0 -1
  61. package/dist/devtools/index.d.ts +0 -2
  62. package/dist/devtools/initDevPanel.d.ts +0 -15
  63. package/dist/devtools.cjs.map +0 -1
  64. package/dist/devtools.js.map +0 -1
  65. package/dist/functions/FunctionRegistry.d.ts +0 -41
  66. package/dist/functions/defineFunction.d.ts +0 -22
  67. package/dist/functions/index.d.ts +0 -2
  68. package/dist/functions/types.d.ts +0 -50
  69. package/dist/functions--c6lx3ic.cjs +0 -480
  70. package/dist/functions--c6lx3ic.cjs.map +0 -1
  71. package/dist/functions-C9F1dnmh.js +0 -398
  72. package/dist/functions-C9F1dnmh.js.map +0 -1
  73. package/dist/helpers/factory.d.ts +0 -20
  74. package/dist/helpers/index.d.ts +0 -1
  75. package/dist/index.cjs.map +0 -1
  76. package/dist/index.js.map +0 -1
  77. package/dist/react/components/ChatInput.d.ts +0 -12
  78. package/dist/react/components/ChatWidget.d.ts +0 -35
  79. package/dist/react/components/Markdown.d.ts +0 -12
  80. package/dist/react/components/Message.d.ts +0 -9
  81. package/dist/react/components/index.d.ts +0 -8
  82. package/dist/react/context/AgoContext.d.ts +0 -62
  83. package/dist/react/context/index.d.ts +0 -2
  84. package/dist/react/hooks/index.d.ts +0 -7
  85. package/dist/react/hooks/useAgo.d.ts +0 -14
  86. package/dist/react/hooks/useAgoContext.d.ts +0 -40
  87. package/dist/react/hooks/useAgoFunction.d.ts +0 -58
  88. package/dist/react/hooks/useAgoStore.d.ts +0 -17
  89. package/dist/react/hooks/useChat.d.ts +0 -45
  90. package/dist/react/hooks/useConversation.d.ts +0 -28
  91. package/dist/react/hooks/useMessages.d.ts +0 -26
  92. package/dist/react/index.d.ts +0 -24
  93. package/dist/react/testing.d.ts +0 -2
  94. package/dist/react.cjs.map +0 -1
  95. package/dist/react.js.map +0 -1
  96. package/dist/rolldown-runtime-BqCkTl7Q.cjs +0 -50
  97. package/dist/rolldown-runtime-CNZpIYwj.js +0 -33
  98. package/dist/state/ClientContextRegistry.d.ts +0 -64
  99. package/dist/state/createStore.d.ts +0 -30
  100. package/dist/streaming/SSEHandler.d.ts +0 -46
  101. package/dist/streaming/helpers.d.ts +0 -67
  102. package/dist/streaming/index.d.ts +0 -2
  103. package/dist/testing/createMockClient.d.ts +0 -42
  104. package/dist/testing/index.d.ts +0 -2
  105. package/dist/utils/eventEmitter.d.ts +0 -23
  106. package/dist/utils/index.d.ts +0 -2
  107. package/dist/utils/logger.d.ts +0 -14
  108. package/dist/vue/composables/useAgo.d.ts +0 -17
  109. package/dist/vue/composables/useAgoEvents.d.ts +0 -11
  110. package/dist/vue/composables/useAgoFunction.d.ts +0 -34
  111. package/dist/vue/composables/useAgoStore.d.ts +0 -18
  112. package/dist/vue/composables/useChat.d.ts +0 -251
  113. package/dist/vue/composables/useConversation.d.ts +0 -178
  114. package/dist/vue/composables/useMessages.d.ts +0 -89
  115. package/dist/vue/index.d.ts +0 -11
  116. package/dist/vue/plugin.d.ts +0 -16
  117. package/dist/vue/symbols.d.ts +0 -3
  118. package/dist/vue.cjs.map +0 -1
  119. package/dist/vue.js.map +0 -1
  120. package/dist/widget/index.d.ts +0 -1
  121. package/dist/widget/types.d.ts +0 -43
@@ -1,62 +0,0 @@
1
- import React from "react";
2
- import type { AgoClient } from "../../client/AgoClient";
3
- import type { AgoConfig } from "../../client/types";
4
- import type { ClientFunctionDefinition, ClientFunctionHandler } from "../../functions/types";
5
- /**
6
- * Top-level declarative configuration for the `AgoProvider`.
7
- *
8
- * - `tools` — full function definitions to expose to the AI app-wide
9
- * - `helpers` — map of pre-built helper name → handler override (or `true` for default)
10
- * - `pageContext` — `"auto"` enables automatic URL/title capture
11
- */
12
- export interface AgoDeclarativeConfig {
13
- tools?: ClientFunctionDefinition[];
14
- helpers?: Record<string, ClientFunctionHandler | true>;
15
- pageContext?: "auto" | "manual";
16
- }
17
- export type AgoProviderProps = {
18
- children: React.ReactNode;
19
- } & AgoDeclarativeConfig & (({
20
- client: AgoClient;
21
- } & Partial<Record<keyof AgoConfig, never>>) | ({
22
- client?: never;
23
- } & AgoConfig));
24
- /**
25
- * Provides an AgoClient to all descendant components via React context.
26
- *
27
- * ```tsx
28
- * // Minimal setup
29
- * <AgoProvider baseUrl="https://YOUR-DOMAIN.useago.com">
30
- * <App />
31
- * </AgoProvider>
32
- *
33
- * // Declarative config — tools, helpers, page context
34
- * <AgoProvider
35
- * baseUrl="https://YOUR-DOMAIN.useago.com"
36
- * tools={[lookupOrder, cancelOrder]}
37
- * helpers={{
38
- * showToast: (args) => toast(args.message as string),
39
- * copyToClipboard: true, // use default handler
40
- * }}
41
- * pageContext="auto"
42
- * >
43
- * <App />
44
- * </AgoProvider>
45
- *
46
- * // With a pre-built client (useful for testing)
47
- * <AgoProvider client={myClient}>
48
- * <App />
49
- * </AgoProvider>
50
- * ```
51
- */
52
- export declare const AgoProvider: React.FC<AgoProviderProps>;
53
- /**
54
- * Returns the AgoClient from the nearest AgoProvider.
55
- * Throws if used outside of an AgoProvider.
56
- */
57
- export declare function useAgoClient(): AgoClient;
58
- /**
59
- * Returns the AgoClient from context, or null if no provider exists.
60
- * Use this when client access is optional.
61
- */
62
- export declare function useOptionalAgoClient(): AgoClient | null;
@@ -1,2 +0,0 @@
1
- export { AgoProvider, useAgoClient, useOptionalAgoClient } from "./AgoContext";
2
- export type { AgoProviderProps, AgoDeclarativeConfig } from "./AgoContext";
@@ -1,7 +0,0 @@
1
- export { useAgo } from "./useAgo";
2
- export type { UseAgoOptions, UseAgoResult } from "./useAgo";
3
- export { useMessages } from "./useMessages";
4
- export type { UseMessagesOptions, UseMessagesResult } from "./useMessages";
5
- export { useConversation } from "./useConversation";
6
- export type { UseConversationOptions, UseConversationResult } from "./useConversation";
7
- export { useAgoContext } from "./useAgoContext";
@@ -1,14 +0,0 @@
1
- import { AgoClient } from "../../client/AgoClient";
2
- import type { AgoConfig } from "../../client/types";
3
- export interface UseAgoOptions extends AgoConfig {
4
- }
5
- export interface UseAgoResult {
6
- /** The AGO client instance */
7
- client: AgoClient;
8
- /** Whether the client is ready */
9
- isReady: boolean;
10
- }
11
- /**
12
- * Hook to create and manage an AgoClient instance
13
- */
14
- export declare function useAgo(config: UseAgoOptions): UseAgoResult;
@@ -1,40 +0,0 @@
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,58 +0,0 @@
1
- import type { ClientFunctionDefinition, ClientFunctionHandler } from "../../functions/types";
2
- export interface UseAgoFunctionOptions {
3
- description: string;
4
- parameters: {
5
- type: "object";
6
- properties: Record<string, {
7
- type: string;
8
- description?: string;
9
- enum?: string[];
10
- default?: unknown;
11
- }>;
12
- required?: string[];
13
- };
14
- handler: ClientFunctionHandler;
15
- }
16
- /**
17
- * Declaratively register a client-side function with the AGO agent.
18
- * Automatically unregisters on unmount and re-registers when deps change.
19
- *
20
- * Accepts either a full definition object (preferred) or classic (name, options) args.
21
- *
22
- * ```tsx
23
- * // Preferred — pass the whole definition
24
- * useAgoFunction({
25
- * name: "showToast",
26
- * description: "Show a notification to the user",
27
- * parameters: { type: "object", properties: { message: { type: "string" } } },
28
- * handler: async (args) => { toast(args.message); return { shown: true }; },
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) => ... });
37
- * ```
38
- */
39
- export declare function useAgoFunction(definition: ClientFunctionDefinition): void;
40
- export declare function useAgoFunction(name: string, options: UseAgoFunctionOptions): void;
41
- export interface AgoRoute {
42
- name: string;
43
- path: string;
44
- description: string;
45
- }
46
- /**
47
- * Declaratively register navigation routes with the AGO agent.
48
- * Wraps `registerNavigationFunction` with React lifecycle management.
49
- *
50
- * ```tsx
51
- * const navigate = useNavigate();
52
- * useAgoNavigation(navigate, [
53
- * { name: "dashboard", path: "/dashboard", description: "Main dashboard" },
54
- * { name: "settings", path: "/settings", description: "User settings" },
55
- * ]);
56
- * ```
57
- */
58
- export declare function useAgoNavigation(navigate: (path: string) => void, routes: AgoRoute[]): void;
@@ -1,17 +0,0 @@
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,45 +0,0 @@
1
- import type { AgoClient } from "../../client/AgoClient";
2
- import type { AgoMessage, Conversation } from "../../client/types";
3
- export interface UseChatOptions {
4
- /** AgoClient instance. If omitted, reads from AgoProvider context. */
5
- client?: AgoClient;
6
- /** Initial conversation ID to load */
7
- conversationId?: string;
8
- /** Auto-load conversation list on mount (default: true) */
9
- autoLoad?: boolean;
10
- }
11
- export interface UseChatResult {
12
- /** Messages in the current conversation */
13
- messages: AgoMessage[];
14
- /** Whether a message is being sent/streamed */
15
- isLoading: boolean;
16
- /** Current error */
17
- error: Error | null;
18
- /** Send a message */
19
- sendMessage: (content: string, files?: File[]) => Promise<AgoMessage | null>;
20
- /** Clear current messages */
21
- clearMessages: () => void;
22
- /** Current conversation ID */
23
- conversationId: string | undefined;
24
- /** All conversations */
25
- conversations: Conversation[];
26
- /** Currently selected conversation */
27
- currentConversation: Conversation | null;
28
- /** Whether conversations are loading */
29
- isConversationsLoading: boolean;
30
- /** Select a conversation by ID */
31
- selectConversation: (conversationId: string) => Promise<void>;
32
- /** Start a new conversation */
33
- startNewConversation: () => void;
34
- /** Refresh conversations list */
35
- refreshConversations: () => Promise<void>;
36
- }
37
- /**
38
- * All-in-one hook for building a custom chat UI.
39
- * Composes useMessages + useConversation.
40
- *
41
- * ```tsx
42
- * const { messages, sendMessage, conversations, selectConversation } = useChat();
43
- * ```
44
- */
45
- export declare function useChat(options?: UseChatOptions): UseChatResult;
@@ -1,28 +0,0 @@
1
- import type { AgoClient } from "../../client/AgoClient";
2
- import type { Conversation } from "../../client/types";
3
- export interface UseConversationOptions {
4
- /** The AGO client instance. If omitted, reads from AgoProvider context. */
5
- client?: AgoClient;
6
- /** Auto-load conversations on mount */
7
- autoLoad?: boolean;
8
- }
9
- export interface UseConversationResult {
10
- /** List of conversations */
11
- conversations: Conversation[];
12
- /** Currently selected conversation */
13
- currentConversation: Conversation | null;
14
- /** Whether conversations are loading */
15
- isLoading: boolean;
16
- /** Current error, if any */
17
- error: Error | null;
18
- /** Select a conversation */
19
- selectConversation: (conversationId: string) => Promise<void>;
20
- /** Clear current conversation (start new) */
21
- startNewConversation: () => void;
22
- /** Refresh conversations list */
23
- refreshConversations: () => Promise<void>;
24
- }
25
- /**
26
- * Hook to manage conversations
27
- */
28
- export declare function useConversation({ client: clientProp, autoLoad, }?: UseConversationOptions): UseConversationResult;
@@ -1,26 +0,0 @@
1
- import type { AgoClient } from "../../client/AgoClient";
2
- import type { AgoMessage } from "../../client/types";
3
- export interface UseMessagesOptions {
4
- /** The AGO client instance. If omitted, reads from AgoProvider context. */
5
- client?: AgoClient;
6
- /** Conversation ID to load messages for */
7
- conversationId?: string;
8
- }
9
- export interface UseMessagesResult {
10
- /** List of messages */
11
- messages: AgoMessage[];
12
- /** Whether a message is being sent */
13
- isLoading: boolean;
14
- /** Current error, if any */
15
- error: Error | null;
16
- /** Send a new message */
17
- sendMessage: (content: string, files?: File[]) => Promise<AgoMessage | null>;
18
- /** Clear messages */
19
- clearMessages: () => void;
20
- /** Current conversation ID */
21
- conversationId: string | undefined;
22
- }
23
- /**
24
- * Hook to manage messages in a conversation
25
- */
26
- export declare function useMessages({ client: clientProp, conversationId: initialConversationId, }?: UseMessagesOptions): UseMessagesResult;
@@ -1,24 +0,0 @@
1
- export { AgoProvider, useAgoClient, useOptionalAgoClient } from "./context";
2
- export type { AgoProviderProps, AgoDeclarativeConfig } from "./context/AgoContext";
3
- export { ChatWidget } from "./components/ChatWidget";
4
- export type { ChatWidgetProps } from "./components/ChatWidget";
5
- export { Message } from "./components/Message";
6
- export type { MessageProps } from "./components/Message";
7
- export { Markdown } from "./components/Markdown";
8
- export type { MarkdownProps } from "./components/Markdown";
9
- export { ChatInput } from "./components/ChatInput";
10
- export type { ChatInputProps } from "./components/ChatInput";
11
- export { useAgo } from "./hooks/useAgo";
12
- export type { UseAgoOptions, UseAgoResult } from "./hooks/useAgo";
13
- export { useMessages } from "./hooks/useMessages";
14
- export type { UseMessagesOptions, UseMessagesResult } from "./hooks/useMessages";
15
- export { useConversation } from "./hooks/useConversation";
16
- export type { UseConversationOptions, UseConversationResult } from "./hooks/useConversation";
17
- export { useChat } from "./hooks/useChat";
18
- export type { UseChatOptions, UseChatResult } from "./hooks/useChat";
19
- export { useAgoFunction, useAgoNavigation } from "./hooks/useAgoFunction";
20
- export type { UseAgoFunctionOptions, AgoRoute } from "./hooks/useAgoFunction";
21
- export { useAgoContext } from "./hooks/useAgoContext";
22
- export { useAgoStore } from "./hooks/useAgoStore";
23
- export { createMockClient } from "./testing";
24
- export type { AgoConfig, AgoMessage, Conversation, AgoAgent, AgoSource, ToolCallData, } from "../client/types";
@@ -1,2 +0,0 @@
1
- export { createMockClient } from "../testing";
2
- export type { MockAgoClient, MockAgoClientOptions } from "../testing";