@useago/sdk 1.13.0 → 1.13.1

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 (37) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/angular.cjs +1 -1
  3. package/dist/angular.d.cts +43 -10
  4. package/dist/angular.d.ts +43 -10
  5. package/dist/angular.js +4 -4
  6. package/dist/autoContinue-C3UsCvT5.cjs +1 -0
  7. package/dist/{autoContinue-CC8K9mBU.js → autoContinue-Cb4_iEbO.js} +1 -1
  8. package/dist/{createConversationSession-BfJg0WyA.js → createConversationSession-D0vks-8C.js} +1 -1
  9. package/dist/{createConversationSession-CiOXKWl0.cjs → createConversationSession-Ri3EKIJU.cjs} +1 -1
  10. package/dist/{createFormCollector-DN1xjAv5.js → createFormCollector-BMN-blXs.js} +1 -1
  11. package/dist/{createFormCollector-DnQl77Ko.cjs → createFormCollector-BNCMIUw2.cjs} +1 -1
  12. package/dist/devtools.d.cts +34 -5
  13. package/dist/devtools.d.ts +34 -5
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.d.cts +34 -5
  16. package/dist/index.d.ts +34 -5
  17. package/dist/index.js +4 -4
  18. package/dist/react.cjs +3 -3
  19. package/dist/react.d.cts +40 -6
  20. package/dist/react.d.ts +40 -6
  21. package/dist/react.js +290 -284
  22. package/dist/testing.d.cts +34 -5
  23. package/dist/testing.d.ts +34 -5
  24. package/dist/types-Ck3iZG0K.cjs +10 -0
  25. package/dist/{types-Q7t1peH-.js → types-fX-VoHfa.js} +860 -753
  26. package/dist/vue.cjs +1 -1
  27. package/dist/vue.d.cts +38 -7
  28. package/dist/vue.d.ts +38 -7
  29. package/dist/vue.js +57 -57
  30. package/dist/widget.cjs +6 -6
  31. package/dist/widget.d.cts +34 -5
  32. package/dist/widget.d.ts +34 -5
  33. package/dist/widget.js +136 -136
  34. package/llms-full.txt +37 -0
  35. package/package.json +1 -1
  36. package/dist/autoContinue-CP9pJR-V.cjs +0 -1
  37. package/dist/types-a7teDBnC.cjs +0 -10
package/dist/vue.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./types-a7teDBnC.cjs");let o=require("vue");var S=Symbol("ago-client"),I={install(t,e){const n=new y.AgoClient(e);t.provide(S,n)}};function g(t){if(t)return new y.AgoClient(t);const e=(0,o.inject)(S);if(!e)throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");return e}function b(t={}){const e=t.client??g(),n=(0,o.ref)([]),a=(0,o.ref)(t.conversationId),r=(0,o.ref)(!1),l=(0,o.ref)(null),v=s=>{a.value||(a.value=s.conversationId)},m=s=>{const i=n.value.findIndex(d=>d.id===s.messageId);i>=0&&(n.value[i]={...n.value[i],content:n.value[i].content+s.content})},p=s=>{const i=n.value.findIndex(d=>d.id===s.id);i>=0?n.value[i]=s:n.value.push(s),r.value=!1},C=s=>{l.value=new Error(s.error),r.value=!1},u=()=>{let s=-1;for(let i=n.value.length-1;i>=0;i--){const d=n.value[i];if(d.role==="assistant"&&(d.status==="IN_PROGRESS"||d.status==="WAITING_CLIENT")){s=i;break}}s>=0&&(n.value[s].content?n.value[s]={...n.value[s],status:"CANCELED"}:n.value.splice(s,1)),r.value=!1};(0,o.onMounted)(()=>{e.on("message:start",v),e.on("message:chunk",m),e.on("message:complete",p),e.on("message:error",C),e.on("message:stopped",u)}),(0,o.onUnmounted)(()=>{e.off("message:start",v),e.off("message:chunk",m),e.off("message:complete",p),e.off("message:error",C),e.off("message:stopped",u)});async function c(s,i){r.value=!0,l.value=null;const d={id:`temp-${Date.now()}`,conversationId:a.value||"",content:s,role:"user",status:"DONE",createdAt:new Date},F={id:`temp-assistant-${Date.now()}`,conversationId:a.value||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};n.value.push(d,F);try{const f=await e.sendMessage(s,{conversationId:a.value,files:i});f.conversationId&&!a.value&&(a.value=f.conversationId),n.value=n.value.filter(A=>!A.id.startsWith("temp-"));const E={...d,id:d.id.replace("temp-","user-"),conversationId:f.conversationId};return n.value.some(A=>A.id===f.id)?n.value.push(E):n.value.push(E,f),f}catch(f){return l.value=f instanceof Error?f:new Error("Failed to send"),r.value=!1,n.value=n.value.filter(E=>!E.id.startsWith("temp-")),null}}async function h(){await e.stop()}function w(){n.value=[],a.value=void 0,l.value=null}return{messages:n,isLoading:r,error:l,conversationId:a,sendMessage:c,stop:h,clearMessages:w}}function N(t={}){const e=t.client??g(),n=t.autoLoad??!0,a=(0,o.ref)([]),r=(0,o.ref)(null),l=(0,o.ref)(!1),v=(0,o.ref)(null);async function m(){l.value=!0,v.value=null;try{a.value=(await e.getConversations()).data}catch(u){v.value=u instanceof Error?u:new Error("Failed to load conversations")}finally{l.value=!1}}async function p(u){l.value=!0,v.value=null;try{r.value=await e.getConversation(u)}catch(c){v.value=c instanceof Error?c:new Error("Failed to load conversation")}finally{l.value=!1}}function C(){r.value=null}return(0,o.onMounted)(()=>{n&&m()}),{conversations:a,currentConversation:r,isLoading:l,error:v,selectConversation:p,startNewConversation:C,refreshConversations:m}}function M(t={}){const e=b({client:t.client,conversationId:t.conversationId}),n=N({client:t.client,autoLoad:t.autoLoad}),a=(0,o.computed)(()=>e.error.value||n.error.value);return{messages:e.messages,isLoading:e.isLoading,error:a,sendMessage:e.sendMessage,stop:e.stop,clearMessages:e.clearMessages,conversationId:e.conversationId,conversations:n.conversations,currentConversation:n.currentConversation,isConversationsLoading:n.isLoading,selectConversation:n.selectConversation,startNewConversation:n.startNewConversation,refreshConversations:n.refreshConversations}}function L(t={}){const e=t.client??g(),n=(0,o.ref)({}),a=(0,o.ref)(!1),r=(0,o.ref)(null),l=new Map;function v(u){const c=(l.get(u)??0)+1;return l.set(u,c),c}const m=(u,c)=>l.get(u)===c;async function p(u,c,h){const w=v(u);a.value=!0,r.value=null;try{await e.submitFeedback(u,c,h),m(u,w)&&(n.value={...n.value,[u]:c})}catch(s){const i=s instanceof Error?s:new Error("Failed to submit feedback");throw r.value=i,i}finally{a.value=!1}}async function C(u,c,h){const w=v(u);a.value=!0,r.value=null;try{const s=await e.submitConversationFeedback(u,c,h);return m(u,w)&&(n.value={...n.value,[s]:c}),s}catch(s){const i=s instanceof Error?s:new Error("Failed to submit feedback");throw r.value=i,i}finally{a.value=!1}}return{ratings:n,isSubmitting:a,error:r,submitFeedback:p,submitConversationFeedback:C}}function R(t,e){const n=g();(0,o.onMounted)(()=>{n.registerFunction(t,e.handler,{description:e.description,parameters:e.parameters,maxResultBytes:e.maxResultBytes,requiresApproval:e.requiresApproval,webmcp:e.webmcp})}),(0,o.onUnmounted)(()=>{n.unregisterFunction(t)})}function P(t,e){const n=g();(0,o.onMounted)(()=>{n.registerNavigationFunction(t,e)}),(0,o.onUnmounted)(()=>{n.unregisterNavigationFunction()})}function k(t,e){const n=g(),a=e?.functionName??"setPageState";(0,o.onMounted)(()=>{n.registerPageStateFunction(t,{...e,functionName:a})}),(0,o.onUnmounted)(()=>{n.unregisterPageStateFunction(a)})}function q(t,e){const n=g();(0,o.onMounted)(()=>{n.on(t,e)}),(0,o.onUnmounted)(()=>{n.off(t,e)})}function _(t){const e=(0,o.shallowRef)(t.get());return(0,o.onScopeDispose)(t.subscribe(n=>{e.value=n})),e}function D(){const t=g(),e=(0,o.shallowRef)(null),n=r=>{e.value=r,t.proactive?.shown(r)},a=({nudge:r})=>{e.value?.id===r.id&&(e.value=null)};return(0,o.onMounted)(()=>{t.on("nudge:ready",n),t.on("nudge:accepted",a),t.on("nudge:dismissed",a)}),(0,o.onUnmounted)(()=>{t.off("nudge:ready",n),t.off("nudge:accepted",a),t.off("nudge:dismissed",a)}),{nudge:e,accept:async()=>{const r=e.value;r&&(e.value=null,await t.proactive?.accept(r))},dismiss:()=>{const r=e.value;r&&(e.value=null,t.proactive?.dismiss(r))}}}exports.AGO_CLIENT_KEY=S;exports.AgoPlugin=I;exports.FEEDBACK_REASONS=y.FEEDBACK_REASONS;exports.useAgo=g;exports.useAgoEvents=q;exports.useAgoFunction=R;exports.useAgoNavigation=P;exports.useAgoPageState=k;exports.useAgoStore=_;exports.useChat=M;exports.useConversation=N;exports.useFeedback=L;exports.useMessages=b;exports.useProactiveNudge=D;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./types-Ck3iZG0K.cjs");let a=require("vue");var S=Symbol("ago-client"),I={install(t,e){const n=new y.AgoClient(e);t.provide(S,n)}};function g(t){if(t)return new y.AgoClient(t);const e=(0,a.inject)(S);if(!e)throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");return e}function b(t={}){const e=t.client??g(),n=(0,a.ref)([]),s=(0,a.ref)(t.conversationId),r=(0,a.ref)(!1),l=(0,a.ref)(null),v=o=>{s.value||(s.value=o.conversationId)},m=o=>{const i=n.value.findIndex(d=>d.id===o.messageId);i>=0&&(n.value[i]={...n.value[i],content:n.value[i].content+o.content})},p=o=>{const i=n.value.findIndex(d=>d.id===o.id);i>=0?n.value[i]=o:n.value.push(o),r.value=!1},C=o=>{l.value=new Error(o.error),r.value=!1},u=()=>{let o=-1;for(let i=n.value.length-1;i>=0;i--){const d=n.value[i];if(d.role==="assistant"&&(d.status==="IN_PROGRESS"||d.status==="WAITING_CLIENT")){o=i;break}}o>=0&&(n.value[o].content?n.value[o]={...n.value[o],status:"CANCELED"}:n.value.splice(o,1)),r.value=!1};(0,a.onMounted)(()=>{e.on("message:start",v),e.on("message:chunk",m),e.on("message:complete",p),e.on("message:error",C),e.on("message:stopped",u)}),(0,a.onUnmounted)(()=>{e.off("message:start",v),e.off("message:chunk",m),e.off("message:complete",p),e.off("message:error",C),e.off("message:stopped",u)});async function c(o,i){r.value=!0,l.value=null;const d={id:`temp-${Date.now()}`,conversationId:s.value||"",content:o,role:"user",status:"DONE",createdAt:new Date},F={id:`temp-assistant-${Date.now()}`,conversationId:s.value||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};n.value.push(d,F);try{const f=await e.sendMessage(o,{conversationId:s.value,files:i});f.conversationId&&!s.value&&(s.value=f.conversationId),n.value=n.value.filter(A=>!A.id.startsWith("temp-"));const E={...d,id:d.id.replace("temp-","user-"),conversationId:f.conversationId};return n.value.some(A=>A.id===f.id)?n.value.push(E):n.value.push(E,f),f}catch(f){return l.value=f instanceof Error?f:new Error("Failed to send"),r.value=!1,n.value=n.value.filter(E=>!E.id.startsWith("temp-")),null}}async function h(){await e.stop()}function w(){n.value=[],s.value=void 0,l.value=null}return{messages:n,isLoading:r,error:l,conversationId:s,sendMessage:c,stop:h,clearMessages:w}}function N(t={}){const e=t.client??g(),n=t.autoLoad??!0,s=(0,a.ref)([]),r=(0,a.ref)(null),l=(0,a.ref)(!1),v=(0,a.ref)(null);async function m(){l.value=!0,v.value=null;try{s.value=(await e.getConversations()).data}catch(u){v.value=u instanceof Error?u:new Error("Failed to load conversations")}finally{l.value=!1}}async function p(u){l.value=!0,v.value=null;try{r.value=await e.getConversation(u)}catch(c){v.value=c instanceof Error?c:new Error("Failed to load conversation")}finally{l.value=!1}}function C(){r.value=null}return(0,a.onMounted)(()=>{n&&m()}),{conversations:s,currentConversation:r,isLoading:l,error:v,selectConversation:p,startNewConversation:C,refreshConversations:m}}function M(t={}){const e=b({client:t.client,conversationId:t.conversationId}),n=N({client:t.client,autoLoad:t.autoLoad}),s=(0,a.computed)(()=>e.error.value||n.error.value);return{messages:e.messages,isLoading:e.isLoading,error:s,sendMessage:e.sendMessage,stop:e.stop,clearMessages:e.clearMessages,conversationId:e.conversationId,conversations:n.conversations,currentConversation:n.currentConversation,isConversationsLoading:n.isLoading,selectConversation:n.selectConversation,startNewConversation:n.startNewConversation,refreshConversations:n.refreshConversations}}function L(t={}){const e=t.client??g(),n=(0,a.ref)({}),s=(0,a.ref)(!1),r=(0,a.ref)(null),l=new Map;function v(u){const c=(l.get(u)??0)+1;return l.set(u,c),c}const m=(u,c)=>l.get(u)===c;async function p(u,c,h){const w=v(u);s.value=!0,r.value=null;try{await e.submitFeedback(u,c,h),m(u,w)&&(n.value={...n.value,[u]:c})}catch(o){const i=o instanceof Error?o:new Error("Failed to submit feedback");throw r.value=i,i}finally{s.value=!1}}async function C(u,c,h){const w=v(u);s.value=!0,r.value=null;try{const o=await e.submitConversationFeedback(u,c,h);return m(u,w)&&(n.value={...n.value,[o]:c}),o}catch(o){const i=o instanceof Error?o:new Error("Failed to submit feedback");throw r.value=i,i}finally{s.value=!1}}return{ratings:n,isSubmitting:s,error:r,submitFeedback:p,submitConversationFeedback:C}}function R(t,e){const n=g();(0,a.onMounted)(()=>{n.registerFunction(t,e.handler,{description:e.description,parameters:e.parameters,maxResultBytes:e.maxResultBytes,requiresApproval:e.requiresApproval,webmcp:e.webmcp})}),(0,a.onUnmounted)(()=>{n.unregisterFunction(t)})}function P(t,e,n){const s=g();(0,a.onMounted)(()=>{s.registerNavigationFunction(t,e,{catalogue:n?.catalogue==="onDemand"?"onDemand":"inline"})}),(0,a.onUnmounted)(()=>{s.unregisterNavigationFunction()})}function k(t,e){const n=g(),s=e?.functionName??"setPageState";(0,a.onMounted)(()=>{n.registerPageStateFunction(t,{...e,functionName:s})}),(0,a.onUnmounted)(()=>{n.unregisterPageStateFunction(s)})}function D(t,e){const n=g();(0,a.onMounted)(()=>{n.on(t,e)}),(0,a.onUnmounted)(()=>{n.off(t,e)})}function q(t){const e=(0,a.shallowRef)(t.get());return(0,a.onScopeDispose)(t.subscribe(n=>{e.value=n})),e}function _(){const t=g(),e=(0,a.shallowRef)(null),n=r=>{e.value=r,t.proactive?.shown(r)},s=({nudge:r})=>{e.value?.id===r.id&&(e.value=null)};return(0,a.onMounted)(()=>{t.on("nudge:ready",n),t.on("nudge:accepted",s),t.on("nudge:dismissed",s)}),(0,a.onUnmounted)(()=>{t.off("nudge:ready",n),t.off("nudge:accepted",s),t.off("nudge:dismissed",s)}),{nudge:e,accept:async()=>{const r=e.value;r&&(e.value=null,await t.proactive?.accept(r))},dismiss:()=>{const r=e.value;r&&(e.value=null,t.proactive?.dismiss(r))}}}exports.AGO_CLIENT_KEY=S;exports.AgoPlugin=I;exports.FEEDBACK_REASONS=y.FEEDBACK_REASONS;exports.useAgo=g;exports.useAgoEvents=D;exports.useAgoFunction=R;exports.useAgoNavigation=P;exports.useAgoPageState=k;exports.useAgoStore=q;exports.useChat=M;exports.useConversation=N;exports.useFeedback=L;exports.useMessages=b;exports.useProactiveNudge=_;
package/dist/vue.d.cts CHANGED
@@ -66,6 +66,8 @@ declare class AgoClient {
66
66
  private config;
67
67
  /** Conversations already warned about an empty reply (one warning each). */
68
68
  private warnedEmptyConversations;
69
+ /** Client functions the backend has accepted from a WebMCP call report. */
70
+ private declaredExternally;
69
71
  /** Whether the placeholder-mode page-data warning has already been logged. */
70
72
  private warnedPageDataPlaceholder;
71
73
  /** `readPageData` companions this SDK registered, so cleanup only removes its own. */
@@ -102,6 +104,8 @@ declare class AgoClient {
102
104
  proactive: ProactiveController | null;
103
105
  /** Removes the mirrored WebMCP tools; `null` when the bridge is off. */
104
106
  private detachWebMCP;
107
+ /** The `listPages` companion is live. */
108
+ private listPagesRegistered;
105
109
  constructor(config: AgoConfig);
106
110
  private attachWebMCPBridge;
107
111
  /**
@@ -216,6 +220,11 @@ declare class AgoClient {
216
220
  */
217
221
  rejectFunction(invocationId: string): Promise<void>;
218
222
  /* Excluded from this release type: runExternalFunction */
223
+ /**
224
+ * Best-effort analytics for one WebMCP call. No agent: the caller is someone
225
+ * else's agent and cannot be known from `execute`.
226
+ */
227
+ private reportExternalCall;
219
228
  /**
220
229
  * Get a page of conversations, newest-first. `pageSize` is capped at 100 by
221
230
  * the backend (default 50). Returns the `{ data, has_more, total }` envelope
@@ -410,14 +419,15 @@ declare class AgoClient {
410
419
  * page of an entity. Flat arguments only: nested object parameters are not
411
420
  * reliably rendered to the model, so placeholders must not be named `page`.
412
421
  *
422
+ * For a large table, `{ catalogue: "onDemand" }` moves the route descriptions
423
+ * into a read-only `listPages` companion, leaving only the page names in the
424
+ * per-message schema. Routes may carry a `section` to group that companion.
425
+ *
413
426
  * @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
414
427
  * @param routes - Map of route names to paths, with descriptions for the LLM
428
+ * @param opts - Where the catalogue lives; `"inline"` by default
415
429
  */
416
- registerNavigationFunction(navigate: (path: string) => void, routes: Array<{
417
- name: string;
418
- path: string;
419
- description: string;
420
- }>): void;
430
+ registerNavigationFunction(navigate: (path: string) => void, routes: NavRoute[], opts?: AgoNavigationOptions): void;
421
431
  /**
422
432
  * Unregister the navigation function and its `current-page` context provider.
423
433
  */
@@ -912,6 +922,16 @@ export declare interface AgoMessage {
912
922
  createdAt: Date;
913
923
  }
914
924
 
925
+ /**
926
+ * Where the route catalogue lives: `"inline"` (default) in `navigateToPage`'s
927
+ * description, or `"onDemand"` in a `listPages` companion's result.
928
+ */
929
+ export declare type AgoNavigationOptions = {
930
+ catalogue?: "inline";
931
+ } | {
932
+ catalogue: "onDemand";
933
+ };
934
+
915
935
  /**
916
936
  * What the page currently displays, returned to the agent as the *result* of
917
937
  * `setPageState` instead of only as context on the next message.
@@ -1031,10 +1051,12 @@ export declare const AgoPlugin: {
1031
1051
 
1032
1052
  export declare type AgoPluginOptions = AgoConfig;
1033
1053
 
1034
- declare interface AgoRoute {
1054
+ export declare interface AgoRoute {
1035
1055
  name: string;
1036
1056
  path: string;
1037
1057
  description: string;
1058
+ /** Groups this route for `catalogue: "onDemand"`. Unused otherwise. */
1059
+ section?: string;
1038
1060
  }
1039
1061
 
1040
1062
  /**
@@ -1496,6 +1518,15 @@ declare type MessageStatus_2 = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANC
1496
1518
  */
1497
1519
  | "WAITING_CLIENT";
1498
1520
 
1521
+ /** A navigable page. `path` may carry `:param` placeholders. */
1522
+ declare interface NavRoute {
1523
+ name: string;
1524
+ path: string;
1525
+ description: string;
1526
+ /** Only read under `catalogue: "onDemand"`. */
1527
+ section?: string;
1528
+ }
1529
+
1499
1530
  /**
1500
1531
  * Optional action attached to a nudge. Accepting a `functionName` action
1501
1532
  * executes the registered client function (same `FunctionRegistry` path as
@@ -2166,7 +2197,7 @@ export declare function useAgoFunction(name: string, options: {
2166
2197
  * ]);
2167
2198
  * ```
2168
2199
  */
2169
- export declare function useAgoNavigation(navigate: (path: string) => void, routes: AgoRoute[]): void;
2200
+ export declare function useAgoNavigation(navigate: (path: string) => void, routes: AgoRoute[], opts?: AgoNavigationOptions): void;
2170
2201
 
2171
2202
  /**
2172
2203
  * Register editable page-state controls with auto-cleanup on unmount.
package/dist/vue.d.ts CHANGED
@@ -66,6 +66,8 @@ declare class AgoClient {
66
66
  private config;
67
67
  /** Conversations already warned about an empty reply (one warning each). */
68
68
  private warnedEmptyConversations;
69
+ /** Client functions the backend has accepted from a WebMCP call report. */
70
+ private declaredExternally;
69
71
  /** Whether the placeholder-mode page-data warning has already been logged. */
70
72
  private warnedPageDataPlaceholder;
71
73
  /** `readPageData` companions this SDK registered, so cleanup only removes its own. */
@@ -102,6 +104,8 @@ declare class AgoClient {
102
104
  proactive: ProactiveController | null;
103
105
  /** Removes the mirrored WebMCP tools; `null` when the bridge is off. */
104
106
  private detachWebMCP;
107
+ /** The `listPages` companion is live. */
108
+ private listPagesRegistered;
105
109
  constructor(config: AgoConfig);
106
110
  private attachWebMCPBridge;
107
111
  /**
@@ -216,6 +220,11 @@ declare class AgoClient {
216
220
  */
217
221
  rejectFunction(invocationId: string): Promise<void>;
218
222
  /* Excluded from this release type: runExternalFunction */
223
+ /**
224
+ * Best-effort analytics for one WebMCP call. No agent: the caller is someone
225
+ * else's agent and cannot be known from `execute`.
226
+ */
227
+ private reportExternalCall;
219
228
  /**
220
229
  * Get a page of conversations, newest-first. `pageSize` is capped at 100 by
221
230
  * the backend (default 50). Returns the `{ data, has_more, total }` envelope
@@ -410,14 +419,15 @@ declare class AgoClient {
410
419
  * page of an entity. Flat arguments only: nested object parameters are not
411
420
  * reliably rendered to the model, so placeholders must not be named `page`.
412
421
  *
422
+ * For a large table, `{ catalogue: "onDemand" }` moves the route descriptions
423
+ * into a read-only `listPages` companion, leaving only the page names in the
424
+ * per-message schema. Routes may carry a `section` to group that companion.
425
+ *
413
426
  * @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
414
427
  * @param routes - Map of route names to paths, with descriptions for the LLM
428
+ * @param opts - Where the catalogue lives; `"inline"` by default
415
429
  */
416
- registerNavigationFunction(navigate: (path: string) => void, routes: Array<{
417
- name: string;
418
- path: string;
419
- description: string;
420
- }>): void;
430
+ registerNavigationFunction(navigate: (path: string) => void, routes: NavRoute[], opts?: AgoNavigationOptions): void;
421
431
  /**
422
432
  * Unregister the navigation function and its `current-page` context provider.
423
433
  */
@@ -912,6 +922,16 @@ export declare interface AgoMessage {
912
922
  createdAt: Date;
913
923
  }
914
924
 
925
+ /**
926
+ * Where the route catalogue lives: `"inline"` (default) in `navigateToPage`'s
927
+ * description, or `"onDemand"` in a `listPages` companion's result.
928
+ */
929
+ export declare type AgoNavigationOptions = {
930
+ catalogue?: "inline";
931
+ } | {
932
+ catalogue: "onDemand";
933
+ };
934
+
915
935
  /**
916
936
  * What the page currently displays, returned to the agent as the *result* of
917
937
  * `setPageState` instead of only as context on the next message.
@@ -1031,10 +1051,12 @@ export declare const AgoPlugin: {
1031
1051
 
1032
1052
  export declare type AgoPluginOptions = AgoConfig;
1033
1053
 
1034
- declare interface AgoRoute {
1054
+ export declare interface AgoRoute {
1035
1055
  name: string;
1036
1056
  path: string;
1037
1057
  description: string;
1058
+ /** Groups this route for `catalogue: "onDemand"`. Unused otherwise. */
1059
+ section?: string;
1038
1060
  }
1039
1061
 
1040
1062
  /**
@@ -1496,6 +1518,15 @@ declare type MessageStatus_2 = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANC
1496
1518
  */
1497
1519
  | "WAITING_CLIENT";
1498
1520
 
1521
+ /** A navigable page. `path` may carry `:param` placeholders. */
1522
+ declare interface NavRoute {
1523
+ name: string;
1524
+ path: string;
1525
+ description: string;
1526
+ /** Only read under `catalogue: "onDemand"`. */
1527
+ section?: string;
1528
+ }
1529
+
1499
1530
  /**
1500
1531
  * Optional action attached to a nudge. Accepting a `functionName` action
1501
1532
  * executes the registered client function (same `FunctionRegistry` path as
@@ -2166,7 +2197,7 @@ export declare function useAgoFunction(name: string, options: {
2166
2197
  * ]);
2167
2198
  * ```
2168
2199
  */
2169
- export declare function useAgoNavigation(navigate: (path: string) => void, routes: AgoRoute[]): void;
2200
+ export declare function useAgoNavigation(navigate: (path: string) => void, routes: AgoRoute[], opts?: AgoNavigationOptions): void;
2170
2201
 
2171
2202
  /**
2172
2203
  * Register editable page-state controls with auto-cleanup on unmount.
package/dist/vue.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as I, t as D } from "./types-Q7t1peH-.js";
1
+ import { n as I, t as x } from "./types-fX-VoHfa.js";
2
2
  import { computed as L, inject as M, onMounted as p, onScopeDispose as R, onUnmounted as C, ref as d, shallowRef as F } from "vue";
3
3
  var N = /* @__PURE__ */ Symbol("ago-client"), _ = { install(t, e) {
4
4
  const n = new I(e);
@@ -11,50 +11,50 @@ function m(t) {
11
11
  return e;
12
12
  }
13
13
  function k(t = {}) {
14
- const e = t.client ?? m(), n = d([]), a = d(t.conversationId), o = d(!1), i = d(null), c = (s) => {
15
- a.value || (a.value = s.conversationId);
16
- }, g = (s) => {
17
- const u = n.value.findIndex((v) => v.id === s.messageId);
14
+ const e = t.client ?? m(), n = d([]), s = d(t.conversationId), o = d(!1), i = d(null), c = (a) => {
15
+ s.value || (s.value = a.conversationId);
16
+ }, g = (a) => {
17
+ const u = n.value.findIndex((v) => v.id === a.messageId);
18
18
  u >= 0 && (n.value[u] = {
19
19
  ...n.value[u],
20
- content: n.value[u].content + s.content
20
+ content: n.value[u].content + a.content
21
21
  });
22
- }, w = (s) => {
23
- const u = n.value.findIndex((v) => v.id === s.id);
24
- u >= 0 ? n.value[u] = s : n.value.push(s), o.value = !1;
25
- }, h = (s) => {
26
- i.value = new Error(s.error), o.value = !1;
22
+ }, w = (a) => {
23
+ const u = n.value.findIndex((v) => v.id === a.id);
24
+ u >= 0 ? n.value[u] = a : n.value.push(a), o.value = !1;
25
+ }, h = (a) => {
26
+ i.value = new Error(a.error), o.value = !1;
27
27
  }, r = () => {
28
- let s = -1;
28
+ let a = -1;
29
29
  for (let u = n.value.length - 1; u >= 0; u--) {
30
30
  const v = n.value[u];
31
31
  if (v.role === "assistant" && (v.status === "IN_PROGRESS" || v.status === "WAITING_CLIENT")) {
32
- s = u;
32
+ a = u;
33
33
  break;
34
34
  }
35
35
  }
36
- s >= 0 && (n.value[s].content ? n.value[s] = {
37
- ...n.value[s],
36
+ a >= 0 && (n.value[a].content ? n.value[a] = {
37
+ ...n.value[a],
38
38
  status: "CANCELED"
39
- } : n.value.splice(s, 1)), o.value = !1;
39
+ } : n.value.splice(a, 1)), o.value = !1;
40
40
  };
41
41
  p(() => {
42
42
  e.on("message:start", c), e.on("message:chunk", g), e.on("message:complete", w), e.on("message:error", h), e.on("message:stopped", r);
43
43
  }), C(() => {
44
44
  e.off("message:start", c), e.off("message:chunk", g), e.off("message:complete", w), e.off("message:error", h), e.off("message:stopped", r);
45
45
  });
46
- async function l(s, u) {
46
+ async function l(a, u) {
47
47
  o.value = !0, i.value = null;
48
48
  const v = {
49
49
  id: `temp-${Date.now()}`,
50
- conversationId: a.value || "",
51
- content: s,
50
+ conversationId: s.value || "",
51
+ content: a,
52
52
  role: "user",
53
53
  status: "DONE",
54
54
  createdAt: /* @__PURE__ */ new Date()
55
55
  }, S = {
56
56
  id: `temp-assistant-${Date.now()}`,
57
- conversationId: a.value || "",
57
+ conversationId: s.value || "",
58
58
  content: "",
59
59
  role: "assistant",
60
60
  status: "IN_PROGRESS",
@@ -62,11 +62,11 @@ function k(t = {}) {
62
62
  };
63
63
  n.value.push(v, S);
64
64
  try {
65
- const f = await e.sendMessage(s, {
66
- conversationId: a.value,
65
+ const f = await e.sendMessage(a, {
66
+ conversationId: s.value,
67
67
  files: u
68
68
  });
69
- f.conversationId && !a.value && (a.value = f.conversationId), n.value = n.value.filter((A) => !A.id.startsWith("temp-"));
69
+ f.conversationId && !s.value && (s.value = f.conversationId), n.value = n.value.filter((A) => !A.id.startsWith("temp-"));
70
70
  const b = {
71
71
  ...v,
72
72
  id: v.id.replace("temp-", "user-"),
@@ -81,24 +81,24 @@ function k(t = {}) {
81
81
  await e.stop();
82
82
  }
83
83
  function y() {
84
- n.value = [], a.value = void 0, i.value = null;
84
+ n.value = [], s.value = void 0, i.value = null;
85
85
  }
86
86
  return {
87
87
  messages: n,
88
88
  isLoading: o,
89
89
  error: i,
90
- conversationId: a,
90
+ conversationId: s,
91
91
  sendMessage: l,
92
92
  stop: E,
93
93
  clearMessages: y
94
94
  };
95
95
  }
96
- function P(t = {}) {
97
- const e = t.client ?? m(), n = t.autoLoad ?? !0, a = d([]), o = d(null), i = d(!1), c = d(null);
96
+ function D(t = {}) {
97
+ const e = t.client ?? m(), n = t.autoLoad ?? !0, s = d([]), o = d(null), i = d(!1), c = d(null);
98
98
  async function g() {
99
99
  i.value = !0, c.value = null;
100
100
  try {
101
- a.value = (await e.getConversations()).data;
101
+ s.value = (await e.getConversations()).data;
102
102
  } catch (r) {
103
103
  c.value = r instanceof Error ? r : /* @__PURE__ */ new Error("Failed to load conversations");
104
104
  } finally {
@@ -121,7 +121,7 @@ function P(t = {}) {
121
121
  return p(() => {
122
122
  n && g();
123
123
  }), {
124
- conversations: a,
124
+ conversations: s,
125
125
  currentConversation: o,
126
126
  isLoading: i,
127
127
  error: c,
@@ -134,14 +134,14 @@ function O(t = {}) {
134
134
  const e = k({
135
135
  client: t.client,
136
136
  conversationId: t.conversationId
137
- }), n = P({
137
+ }), n = D({
138
138
  client: t.client,
139
139
  autoLoad: t.autoLoad
140
- }), a = L(() => e.error.value || n.error.value);
140
+ }), s = L(() => e.error.value || n.error.value);
141
141
  return {
142
142
  messages: e.messages,
143
143
  isLoading: e.isLoading,
144
- error: a,
144
+ error: s,
145
145
  sendMessage: e.sendMessage,
146
146
  stop: e.stop,
147
147
  clearMessages: e.clearMessages,
@@ -155,7 +155,7 @@ function O(t = {}) {
155
155
  };
156
156
  }
157
157
  function G(t = {}) {
158
- const e = t.client ?? m(), n = d({}), a = d(!1), o = d(null), i = /* @__PURE__ */ new Map();
158
+ const e = t.client ?? m(), n = d({}), s = d(!1), o = d(null), i = /* @__PURE__ */ new Map();
159
159
  function c(r) {
160
160
  const l = (i.get(r) ?? 0) + 1;
161
161
  return i.set(r, l), l;
@@ -163,38 +163,38 @@ function G(t = {}) {
163
163
  const g = (r, l) => i.get(r) === l;
164
164
  async function w(r, l, E) {
165
165
  const y = c(r);
166
- a.value = !0, o.value = null;
166
+ s.value = !0, o.value = null;
167
167
  try {
168
168
  await e.submitFeedback(r, l, E), g(r, y) && (n.value = {
169
169
  ...n.value,
170
170
  [r]: l
171
171
  });
172
- } catch (s) {
173
- const u = s instanceof Error ? s : /* @__PURE__ */ new Error("Failed to submit feedback");
172
+ } catch (a) {
173
+ const u = a instanceof Error ? a : /* @__PURE__ */ new Error("Failed to submit feedback");
174
174
  throw o.value = u, u;
175
175
  } finally {
176
- a.value = !1;
176
+ s.value = !1;
177
177
  }
178
178
  }
179
179
  async function h(r, l, E) {
180
180
  const y = c(r);
181
- a.value = !0, o.value = null;
181
+ s.value = !0, o.value = null;
182
182
  try {
183
- const s = await e.submitConversationFeedback(r, l, E);
183
+ const a = await e.submitConversationFeedback(r, l, E);
184
184
  return g(r, y) && (n.value = {
185
185
  ...n.value,
186
- [s]: l
187
- }), s;
188
- } catch (s) {
189
- const u = s instanceof Error ? s : /* @__PURE__ */ new Error("Failed to submit feedback");
186
+ [a]: l
187
+ }), a;
188
+ } catch (a) {
189
+ const u = a instanceof Error ? a : /* @__PURE__ */ new Error("Failed to submit feedback");
190
190
  throw o.value = u, u;
191
191
  } finally {
192
- a.value = !1;
192
+ s.value = !1;
193
193
  }
194
194
  }
195
195
  return {
196
196
  ratings: n,
197
- isSubmitting: a,
197
+ isSubmitting: s,
198
198
  error: o,
199
199
  submitFeedback: w,
200
200
  submitConversationFeedback: h
@@ -214,23 +214,23 @@ function B(t, e) {
214
214
  n.unregisterFunction(t);
215
215
  });
216
216
  }
217
- function T(t, e) {
218
- const n = m();
217
+ function T(t, e, n) {
218
+ const s = m();
219
219
  p(() => {
220
- n.registerNavigationFunction(t, e);
220
+ s.registerNavigationFunction(t, e, { catalogue: n?.catalogue === "onDemand" ? "onDemand" : "inline" });
221
221
  }), C(() => {
222
- n.unregisterNavigationFunction();
222
+ s.unregisterNavigationFunction();
223
223
  });
224
224
  }
225
225
  function W(t, e) {
226
- const n = m(), a = e?.functionName ?? "setPageState";
226
+ const n = m(), s = e?.functionName ?? "setPageState";
227
227
  p(() => {
228
228
  n.registerPageStateFunction(t, {
229
229
  ...e,
230
- functionName: a
230
+ functionName: s
231
231
  });
232
232
  }), C(() => {
233
- n.unregisterPageStateFunction(a);
233
+ n.unregisterPageStateFunction(s);
234
234
  });
235
235
  }
236
236
  function K(t, e) {
@@ -250,13 +250,13 @@ function U(t) {
250
250
  function $() {
251
251
  const t = m(), e = F(null), n = (o) => {
252
252
  e.value = o, t.proactive?.shown(o);
253
- }, a = ({ nudge: o }) => {
253
+ }, s = ({ nudge: o }) => {
254
254
  e.value?.id === o.id && (e.value = null);
255
255
  };
256
256
  return p(() => {
257
- t.on("nudge:ready", n), t.on("nudge:accepted", a), t.on("nudge:dismissed", a);
257
+ t.on("nudge:ready", n), t.on("nudge:accepted", s), t.on("nudge:dismissed", s);
258
258
  }), C(() => {
259
- t.off("nudge:ready", n), t.off("nudge:accepted", a), t.off("nudge:dismissed", a);
259
+ t.off("nudge:ready", n), t.off("nudge:accepted", s), t.off("nudge:dismissed", s);
260
260
  }), {
261
261
  nudge: e,
262
262
  accept: async () => {
@@ -272,7 +272,7 @@ function $() {
272
272
  export {
273
273
  N as AGO_CLIENT_KEY,
274
274
  _ as AgoPlugin,
275
- D as FEEDBACK_REASONS,
275
+ x as FEEDBACK_REASONS,
276
276
  m as useAgo,
277
277
  K as useAgoEvents,
278
278
  B as useAgoFunction,
@@ -280,7 +280,7 @@ export {
280
280
  W as useAgoPageState,
281
281
  U as useAgoStore,
282
282
  O as useChat,
283
- P as useConversation,
283
+ D as useConversation,
284
284
  G as useFeedback,
285
285
  k as useMessages,
286
286
  $ as useProactiveNudge