@useago/sdk 1.5.3 → 1.5.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 (48) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +10 -0
  3. package/dist/AgoClient-BW0YZsis.js +1681 -0
  4. package/dist/AgoClient-Ba3ICq4K.cjs +8 -0
  5. package/dist/angular.cjs +1 -1
  6. package/dist/angular.d.cts +41 -0
  7. package/dist/angular.d.ts +41 -0
  8. package/dist/angular.js +2 -2
  9. package/dist/{createConversationSession-C7cnnWKW.js → createConversationSession-BjsgjL-v.js} +1 -1
  10. package/dist/{createConversationSession-BCb0D6bt.cjs → createConversationSession-okoz3teC.cjs} +1 -1
  11. package/dist/{createFormCollector-t_fGyuTD.cjs → createFormCollector-BWIh1pMl.cjs} +1 -1
  12. package/dist/{createFormCollector-iCDwAwYJ.js → createFormCollector-Bay2UpRv.js} +1 -1
  13. package/dist/devtools.d.cts +41 -0
  14. package/dist/devtools.d.ts +41 -0
  15. package/dist/functions-CPs7omgM.cjs +1 -0
  16. package/dist/helpers.cjs +1 -1
  17. package/dist/helpers.js +1 -1
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.cts +54 -0
  20. package/dist/index.d.ts +54 -0
  21. package/dist/index.js +64 -62
  22. package/dist/react.cjs +3 -3
  23. package/dist/react.d.cts +55 -0
  24. package/dist/react.d.ts +55 -0
  25. package/dist/react.js +142 -122
  26. package/dist/testing.cjs +1 -1
  27. package/dist/testing.d.cts +41 -0
  28. package/dist/testing.d.ts +41 -0
  29. package/dist/testing.js +1 -1
  30. package/dist/vue.cjs +1 -1
  31. package/dist/vue.d.cts +41 -0
  32. package/dist/vue.d.ts +41 -0
  33. package/dist/vue.js +1 -1
  34. package/dist/widget.cjs +1 -1
  35. package/dist/widget.d.cts +41 -0
  36. package/dist/widget.d.ts +41 -0
  37. package/dist/widget.js +3 -3
  38. package/llms-full.txt +29 -0
  39. package/package.json +1 -1
  40. package/dist/AgoClient-BGkFSNZF.cjs +0 -8
  41. package/dist/AgoClient-CW-BLT1_.js +0 -1542
  42. package/dist/functions-IGSjjvF4.cjs +0 -1
  43. package/dist/rolldown-runtime-16Nf8qvH.cjs +0 -1
  44. /package/dist/{autoContinue-D3Mmaaca.js → autoContinue-CC8K9mBU.js} +0 -0
  45. /package/dist/{autoContinue-CcCTva-D.cjs → autoContinue-CP9pJR-V.cjs} +0 -0
  46. /package/dist/{createMockClient-Br0TWgLO.js → createMockClient-DcuNlufr.js} +0 -0
  47. /package/dist/{createMockClient-BwNLPjeT.cjs → createMockClient-Dw-cyISN.cjs} +0 -0
  48. /package/dist/{functions-CApuQZ2b.js → functions-tzyOZNp6.js} +0 -0
@@ -1,3 +1,19 @@
1
+ declare interface ActivityEntry {
2
+ ts: number;
3
+ actor: "user" | "agent";
4
+ name: string;
5
+ summary: string;
6
+ data?: Record<string, unknown>;
7
+ }
8
+
9
+ declare interface ActivityInput {
10
+ actor?: "user" | "agent";
11
+ name: string;
12
+ summary: string;
13
+ data?: Record<string, unknown>;
14
+ ts?: number;
15
+ }
16
+
1
17
  /**
2
18
  * Agent information
3
19
  */
@@ -36,6 +52,8 @@ declare class AgoClient {
36
52
  private functionRegistry;
37
53
  private contextRegistry;
38
54
  private eventEmitter;
55
+ private activityLedger;
56
+ private lastSentPageState;
39
57
  private config;
40
58
  /** Conversations already warned about an empty reply (one warning each). */
41
59
  private warnedEmptyConversations;
@@ -346,6 +364,19 @@ declare class AgoClient {
346
364
  * Get the current context snapshot.
347
365
  */
348
366
  getContextSnapshot(): ContextSnapshot | null;
367
+ private buildSendContext;
368
+ /**
369
+ * Record something the user just did so the agent is aware of it on the next
370
+ * message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
371
+ * (no raw payloads, secrets, or PII).
372
+ */
373
+ recordActivity(entry: ActivityInput): void;
374
+ /** Recent user + agent actions, oldest first (a copy). */
375
+ getRecentActivity(): ActivityEntry[];
376
+ clearActivity(): void;
377
+ private addActivity;
378
+ private recordAgentAction;
379
+ private registerActivityContext;
349
380
  /**
350
381
  * Subscribe to an event
351
382
  */
@@ -517,6 +548,8 @@ declare interface AgoClientEvents {
517
548
  "nudge:accepted": {
518
549
  nudge: ProactiveNudgeInstance;
519
550
  };
551
+ /** A user- or agent-action was recorded into the activity ledger. */
552
+ "activity:recorded": ActivityEntry;
520
553
  }
521
554
 
522
555
  /**
@@ -578,6 +611,14 @@ declare interface AgoConfig {
578
611
  * with `maxResultBytes` on its definition; `Infinity` disables the guard.
579
612
  */
580
613
  maxFunctionResultBytes?: number;
614
+ /**
615
+ * Max number of recent actions kept in the in-memory activity ledger that
616
+ * rides along as the `activity:recent` context entry. Older entries drop
617
+ * first. Default `10`. Larger values give the agent more history at the cost
618
+ * of tokens on every message. Each entry's `data` is also size-clamped (long
619
+ * strings truncated, large arrays capped) so one event can't bloat the context.
620
+ */
621
+ maxActivityEntries?: number;
581
622
  /**
582
623
  * Enable the proactive mode: declarative triggers evaluated client-side
583
624
  * against friction signals (dwell/idle time, rage clicks, route bounces…)
package/dist/testing.d.ts CHANGED
@@ -1,3 +1,19 @@
1
+ declare interface ActivityEntry {
2
+ ts: number;
3
+ actor: "user" | "agent";
4
+ name: string;
5
+ summary: string;
6
+ data?: Record<string, unknown>;
7
+ }
8
+
9
+ declare interface ActivityInput {
10
+ actor?: "user" | "agent";
11
+ name: string;
12
+ summary: string;
13
+ data?: Record<string, unknown>;
14
+ ts?: number;
15
+ }
16
+
1
17
  /**
2
18
  * Agent information
3
19
  */
@@ -36,6 +52,8 @@ declare class AgoClient {
36
52
  private functionRegistry;
37
53
  private contextRegistry;
38
54
  private eventEmitter;
55
+ private activityLedger;
56
+ private lastSentPageState;
39
57
  private config;
40
58
  /** Conversations already warned about an empty reply (one warning each). */
41
59
  private warnedEmptyConversations;
@@ -346,6 +364,19 @@ declare class AgoClient {
346
364
  * Get the current context snapshot.
347
365
  */
348
366
  getContextSnapshot(): ContextSnapshot | null;
367
+ private buildSendContext;
368
+ /**
369
+ * Record something the user just did so the agent is aware of it on the next
370
+ * message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
371
+ * (no raw payloads, secrets, or PII).
372
+ */
373
+ recordActivity(entry: ActivityInput): void;
374
+ /** Recent user + agent actions, oldest first (a copy). */
375
+ getRecentActivity(): ActivityEntry[];
376
+ clearActivity(): void;
377
+ private addActivity;
378
+ private recordAgentAction;
379
+ private registerActivityContext;
349
380
  /**
350
381
  * Subscribe to an event
351
382
  */
@@ -517,6 +548,8 @@ declare interface AgoClientEvents {
517
548
  "nudge:accepted": {
518
549
  nudge: ProactiveNudgeInstance;
519
550
  };
551
+ /** A user- or agent-action was recorded into the activity ledger. */
552
+ "activity:recorded": ActivityEntry;
520
553
  }
521
554
 
522
555
  /**
@@ -578,6 +611,14 @@ declare interface AgoConfig {
578
611
  * with `maxResultBytes` on its definition; `Infinity` disables the guard.
579
612
  */
580
613
  maxFunctionResultBytes?: number;
614
+ /**
615
+ * Max number of recent actions kept in the in-memory activity ledger that
616
+ * rides along as the `activity:recent` context entry. Older entries drop
617
+ * first. Default `10`. Larger values give the agent more history at the cost
618
+ * of tokens on every message. Each entry's `data` is also size-clamped (long
619
+ * strings truncated, large arrays capped) so one event can't bloat the context.
620
+ */
621
+ maxActivityEntries?: number;
581
622
  /**
582
623
  * Enable the proactive mode: declarative triggers evaluated client-side
583
624
  * against friction signals (dwell/idle time, rage clicks, route bounces…)
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as e } from "./createMockClient-Br0TWgLO.js";
1
+ import { t as e } from "./createMockClient-DcuNlufr.js";
2
2
  export {
3
3
  e as createMockClient
4
4
  };
package/dist/vue.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./rolldown-runtime-16Nf8qvH.cjs"),I=require("./AgoClient-BGkFSNZF.cjs");let o=require("vue");var w=Symbol("ago-client"),N={install(t,e){const n=new I.AgoClient(e);t.provide(w,n)}};function v(t){if(t)return new I.AgoClient(t);const e=(0,o.inject)(w);if(!e)throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");return e}function M(t={}){const e=t.client??v(),n=(0,o.ref)([]),s=(0,o.ref)(t.conversationId),a=(0,o.ref)(!1),u=(0,o.ref)(null),c=r=>{s.value||(s.value=r.conversationId)},f=r=>{const i=n.value.findIndex(d=>d.id===r.messageId);i>=0&&(n.value[i]={...n.value[i],content:n.value[i].content+r.content})},m=r=>{const i=n.value.findIndex(d=>d.id===r.id);i>=0?n.value[i]=r:n.value.push(r),a.value=!1},C=r=>{u.value=new Error(r.error),a.value=!1};(0,o.onMounted)(()=>{e.on("message:start",c),e.on("message:chunk",f),e.on("message:complete",m),e.on("message:error",C)}),(0,o.onUnmounted)(()=>{e.off("message:start",c),e.off("message:chunk",f),e.off("message:complete",m),e.off("message:error",C)});async function g(r,i){a.value=!0,u.value=null;const d={id:`temp-${Date.now()}`,conversationId:s.value||"",content:r,role:"user",status:"DONE",createdAt:new Date},y={id:`temp-assistant-${Date.now()}`,conversationId:s.value||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};n.value.push(d,y);try{const l=await e.sendMessage(r,{conversationId:s.value,files:i});l.conversationId&&!s.value&&(s.value=l.conversationId),n.value=n.value.filter(A=>!A.id.startsWith("temp-"));const p={...d,id:d.id.replace("temp-","user-"),conversationId:l.conversationId};return n.value.some(A=>A.id===l.id)?n.value.push(p):n.value.push(p,l),l}catch(l){return u.value=l instanceof Error?l:new Error("Failed to send"),a.value=!1,n.value=n.value.filter(p=>!p.id.startsWith("temp-")),null}}function h(){n.value=[],s.value=void 0,u.value=null}return{messages:n,isLoading:a,error:u,conversationId:s,sendMessage:g,clearMessages:h}}function E(t={}){const e=t.client??v(),n=t.autoLoad??!0,s=(0,o.ref)([]),a=(0,o.ref)(null),u=(0,o.ref)(!1),c=(0,o.ref)(null);async function f(){u.value=!0,c.value=null;try{s.value=await e.getConversations()}catch(g){c.value=g instanceof Error?g:new Error("Failed to load conversations")}finally{u.value=!1}}async function m(g){u.value=!0,c.value=null;try{a.value=await e.getConversation(g)}catch(h){c.value=h instanceof Error?h:new Error("Failed to load conversation")}finally{u.value=!1}}function C(){a.value=null}return(0,o.onMounted)(()=>{n&&f()}),{conversations:s,currentConversation:a,isLoading:u,error:c,selectConversation:m,startNewConversation:C,refreshConversations:f}}function S(t={}){const e=M({client:t.client,conversationId:t.conversationId}),n=E({client:t.client,autoLoad:t.autoLoad}),s=(0,o.computed)(()=>e.error.value||n.error.value);return{messages:e.messages,isLoading:e.isLoading,error:s,sendMessage:e.sendMessage,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,e){const n=v();(0,o.onMounted)(()=>{n.registerFunction(t,e.handler,{description:e.description,parameters:e.parameters,maxResultBytes:e.maxResultBytes})}),(0,o.onUnmounted)(()=>{n.unregisterFunction(t)})}function P(t,e){const n=v();(0,o.onMounted)(()=>{n.registerNavigationFunction(t,e)}),(0,o.onUnmounted)(()=>{n.unregisterNavigationFunction()})}function F(t,e){const n=v(),s=e?.functionName??"setPageState";(0,o.onMounted)(()=>{n.registerPageStateFunction(t,{functionName:s})}),(0,o.onUnmounted)(()=>{n.unregisterPageStateFunction(s)})}function R(t,e){const n=v();(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 U(){const t=v(),e=(0,o.shallowRef)(null),n=a=>{e.value=a,t.proactive?.shown(a)},s=({nudge:a})=>{e.value?.id===a.id&&(e.value=null)};return(0,o.onMounted)(()=>{t.on("nudge:ready",n),t.on("nudge:accepted",s),t.on("nudge:dismissed",s)}),(0,o.onUnmounted)(()=>{t.off("nudge:ready",n),t.off("nudge:accepted",s),t.off("nudge:dismissed",s)}),{nudge:e,accept:async()=>{const a=e.value;a&&(e.value=null,await t.proactive?.accept(a))},dismiss:()=>{const a=e.value;a&&(e.value=null,t.proactive?.dismiss(a))}}}exports.AGO_CLIENT_KEY=w;exports.AgoPlugin=N;exports.useAgo=v;exports.useAgoEvents=R;exports.useAgoFunction=L;exports.useAgoNavigation=P;exports.useAgoPageState=F;exports.useAgoStore=_;exports.useChat=S;exports.useConversation=E;exports.useMessages=M;exports.useProactiveNudge=U;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("./AgoClient-Ba3ICq4K.cjs");let o=require("vue");var w=Symbol("ago-client"),N={install(t,e){const n=new I.AgoClient(e);t.provide(w,n)}};function v(t){if(t)return new I.AgoClient(t);const e=(0,o.inject)(w);if(!e)throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");return e}function M(t={}){const e=t.client??v(),n=(0,o.ref)([]),s=(0,o.ref)(t.conversationId),a=(0,o.ref)(!1),u=(0,o.ref)(null),c=r=>{s.value||(s.value=r.conversationId)},f=r=>{const i=n.value.findIndex(d=>d.id===r.messageId);i>=0&&(n.value[i]={...n.value[i],content:n.value[i].content+r.content})},m=r=>{const i=n.value.findIndex(d=>d.id===r.id);i>=0?n.value[i]=r:n.value.push(r),a.value=!1},C=r=>{u.value=new Error(r.error),a.value=!1};(0,o.onMounted)(()=>{e.on("message:start",c),e.on("message:chunk",f),e.on("message:complete",m),e.on("message:error",C)}),(0,o.onUnmounted)(()=>{e.off("message:start",c),e.off("message:chunk",f),e.off("message:complete",m),e.off("message:error",C)});async function g(r,i){a.value=!0,u.value=null;const d={id:`temp-${Date.now()}`,conversationId:s.value||"",content:r,role:"user",status:"DONE",createdAt:new Date},y={id:`temp-assistant-${Date.now()}`,conversationId:s.value||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};n.value.push(d,y);try{const l=await e.sendMessage(r,{conversationId:s.value,files:i});l.conversationId&&!s.value&&(s.value=l.conversationId),n.value=n.value.filter(A=>!A.id.startsWith("temp-"));const p={...d,id:d.id.replace("temp-","user-"),conversationId:l.conversationId};return n.value.some(A=>A.id===l.id)?n.value.push(p):n.value.push(p,l),l}catch(l){return u.value=l instanceof Error?l:new Error("Failed to send"),a.value=!1,n.value=n.value.filter(p=>!p.id.startsWith("temp-")),null}}function h(){n.value=[],s.value=void 0,u.value=null}return{messages:n,isLoading:a,error:u,conversationId:s,sendMessage:g,clearMessages:h}}function E(t={}){const e=t.client??v(),n=t.autoLoad??!0,s=(0,o.ref)([]),a=(0,o.ref)(null),u=(0,o.ref)(!1),c=(0,o.ref)(null);async function f(){u.value=!0,c.value=null;try{s.value=await e.getConversations()}catch(g){c.value=g instanceof Error?g:new Error("Failed to load conversations")}finally{u.value=!1}}async function m(g){u.value=!0,c.value=null;try{a.value=await e.getConversation(g)}catch(h){c.value=h instanceof Error?h:new Error("Failed to load conversation")}finally{u.value=!1}}function C(){a.value=null}return(0,o.onMounted)(()=>{n&&f()}),{conversations:s,currentConversation:a,isLoading:u,error:c,selectConversation:m,startNewConversation:C,refreshConversations:f}}function S(t={}){const e=M({client:t.client,conversationId:t.conversationId}),n=E({client:t.client,autoLoad:t.autoLoad}),s=(0,o.computed)(()=>e.error.value||n.error.value);return{messages:e.messages,isLoading:e.isLoading,error:s,sendMessage:e.sendMessage,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,e){const n=v();(0,o.onMounted)(()=>{n.registerFunction(t,e.handler,{description:e.description,parameters:e.parameters,maxResultBytes:e.maxResultBytes})}),(0,o.onUnmounted)(()=>{n.unregisterFunction(t)})}function P(t,e){const n=v();(0,o.onMounted)(()=>{n.registerNavigationFunction(t,e)}),(0,o.onUnmounted)(()=>{n.unregisterNavigationFunction()})}function F(t,e){const n=v(),s=e?.functionName??"setPageState";(0,o.onMounted)(()=>{n.registerPageStateFunction(t,{functionName:s})}),(0,o.onUnmounted)(()=>{n.unregisterPageStateFunction(s)})}function R(t,e){const n=v();(0,o.onMounted)(()=>{n.on(t,e)}),(0,o.onUnmounted)(()=>{n.off(t,e)})}function U(t){const e=(0,o.shallowRef)(t.get());return(0,o.onScopeDispose)(t.subscribe(n=>{e.value=n})),e}function D(){const t=v(),e=(0,o.shallowRef)(null),n=a=>{e.value=a,t.proactive?.shown(a)},s=({nudge:a})=>{e.value?.id===a.id&&(e.value=null)};return(0,o.onMounted)(()=>{t.on("nudge:ready",n),t.on("nudge:accepted",s),t.on("nudge:dismissed",s)}),(0,o.onUnmounted)(()=>{t.off("nudge:ready",n),t.off("nudge:accepted",s),t.off("nudge:dismissed",s)}),{nudge:e,accept:async()=>{const a=e.value;a&&(e.value=null,await t.proactive?.accept(a))},dismiss:()=>{const a=e.value;a&&(e.value=null,t.proactive?.dismiss(a))}}}exports.AGO_CLIENT_KEY=w;exports.AgoPlugin=N;exports.useAgo=v;exports.useAgoEvents=R;exports.useAgoFunction=L;exports.useAgoNavigation=P;exports.useAgoPageState=F;exports.useAgoStore=U;exports.useChat=S;exports.useConversation=E;exports.useMessages=M;exports.useProactiveNudge=D;
package/dist/vue.d.cts CHANGED
@@ -4,6 +4,22 @@ import { InjectionKey } from 'vue';
4
4
  import { Ref } from 'vue';
5
5
  import { ShallowRef } from 'vue';
6
6
 
7
+ declare interface ActivityEntry {
8
+ ts: number;
9
+ actor: "user" | "agent";
10
+ name: string;
11
+ summary: string;
12
+ data?: Record<string, unknown>;
13
+ }
14
+
15
+ declare interface ActivityInput {
16
+ actor?: "user" | "agent";
17
+ name: string;
18
+ summary: string;
19
+ data?: Record<string, unknown>;
20
+ ts?: number;
21
+ }
22
+
7
23
  export declare const AGO_CLIENT_KEY: InjectionKey<AgoClient>;
8
24
 
9
25
  /**
@@ -44,6 +60,8 @@ declare class AgoClient {
44
60
  private functionRegistry;
45
61
  private contextRegistry;
46
62
  private eventEmitter;
63
+ private activityLedger;
64
+ private lastSentPageState;
47
65
  private config;
48
66
  /** Conversations already warned about an empty reply (one warning each). */
49
67
  private warnedEmptyConversations;
@@ -354,6 +372,19 @@ declare class AgoClient {
354
372
  * Get the current context snapshot.
355
373
  */
356
374
  getContextSnapshot(): ContextSnapshot | null;
375
+ private buildSendContext;
376
+ /**
377
+ * Record something the user just did so the agent is aware of it on the next
378
+ * message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
379
+ * (no raw payloads, secrets, or PII).
380
+ */
381
+ recordActivity(entry: ActivityInput): void;
382
+ /** Recent user + agent actions, oldest first (a copy). */
383
+ getRecentActivity(): ActivityEntry[];
384
+ clearActivity(): void;
385
+ private addActivity;
386
+ private recordAgentAction;
387
+ private registerActivityContext;
357
388
  /**
358
389
  * Subscribe to an event
359
390
  */
@@ -525,6 +556,8 @@ declare interface AgoClientEvents {
525
556
  "nudge:accepted": {
526
557
  nudge: ProactiveNudgeInstance;
527
558
  };
559
+ /** A user- or agent-action was recorded into the activity ledger. */
560
+ "activity:recorded": ActivityEntry;
528
561
  }
529
562
 
530
563
  /**
@@ -586,6 +619,14 @@ export declare interface AgoConfig {
586
619
  * with `maxResultBytes` on its definition; `Infinity` disables the guard.
587
620
  */
588
621
  maxFunctionResultBytes?: number;
622
+ /**
623
+ * Max number of recent actions kept in the in-memory activity ledger that
624
+ * rides along as the `activity:recent` context entry. Older entries drop
625
+ * first. Default `10`. Larger values give the agent more history at the cost
626
+ * of tokens on every message. Each entry's `data` is also size-clamped (long
627
+ * strings truncated, large arrays capped) so one event can't bloat the context.
628
+ */
629
+ maxActivityEntries?: number;
589
630
  /**
590
631
  * Enable the proactive mode: declarative triggers evaluated client-side
591
632
  * against friction signals (dwell/idle time, rage clicks, route bounces…)
package/dist/vue.d.ts CHANGED
@@ -4,6 +4,22 @@ import { InjectionKey } from 'vue';
4
4
  import { Ref } from 'vue';
5
5
  import { ShallowRef } from 'vue';
6
6
 
7
+ declare interface ActivityEntry {
8
+ ts: number;
9
+ actor: "user" | "agent";
10
+ name: string;
11
+ summary: string;
12
+ data?: Record<string, unknown>;
13
+ }
14
+
15
+ declare interface ActivityInput {
16
+ actor?: "user" | "agent";
17
+ name: string;
18
+ summary: string;
19
+ data?: Record<string, unknown>;
20
+ ts?: number;
21
+ }
22
+
7
23
  export declare const AGO_CLIENT_KEY: InjectionKey<AgoClient>;
8
24
 
9
25
  /**
@@ -44,6 +60,8 @@ declare class AgoClient {
44
60
  private functionRegistry;
45
61
  private contextRegistry;
46
62
  private eventEmitter;
63
+ private activityLedger;
64
+ private lastSentPageState;
47
65
  private config;
48
66
  /** Conversations already warned about an empty reply (one warning each). */
49
67
  private warnedEmptyConversations;
@@ -354,6 +372,19 @@ declare class AgoClient {
354
372
  * Get the current context snapshot.
355
373
  */
356
374
  getContextSnapshot(): ContextSnapshot | null;
375
+ private buildSendContext;
376
+ /**
377
+ * Record something the user just did so the agent is aware of it on the next
378
+ * message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
379
+ * (no raw payloads, secrets, or PII).
380
+ */
381
+ recordActivity(entry: ActivityInput): void;
382
+ /** Recent user + agent actions, oldest first (a copy). */
383
+ getRecentActivity(): ActivityEntry[];
384
+ clearActivity(): void;
385
+ private addActivity;
386
+ private recordAgentAction;
387
+ private registerActivityContext;
357
388
  /**
358
389
  * Subscribe to an event
359
390
  */
@@ -525,6 +556,8 @@ declare interface AgoClientEvents {
525
556
  "nudge:accepted": {
526
557
  nudge: ProactiveNudgeInstance;
527
558
  };
559
+ /** A user- or agent-action was recorded into the activity ledger. */
560
+ "activity:recorded": ActivityEntry;
528
561
  }
529
562
 
530
563
  /**
@@ -586,6 +619,14 @@ export declare interface AgoConfig {
586
619
  * with `maxResultBytes` on its definition; `Infinity` disables the guard.
587
620
  */
588
621
  maxFunctionResultBytes?: number;
622
+ /**
623
+ * Max number of recent actions kept in the in-memory activity ledger that
624
+ * rides along as the `activity:recent` context entry. Older entries drop
625
+ * first. Default `10`. Larger values give the agent more history at the cost
626
+ * of tokens on every message. Each entry's `data` is also size-clamped (long
627
+ * strings truncated, large arrays capped) so one event can't bloat the context.
628
+ */
629
+ maxActivityEntries?: number;
589
630
  /**
590
631
  * Enable the proactive mode: declarative triggers evaluated client-side
591
632
  * against friction signals (dwell/idle time, rage clicks, route bounces…)
package/dist/vue.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as E } from "./AgoClient-CW-BLT1_.js";
1
+ import { t as E } from "./AgoClient-BW0YZsis.js";
2
2
  import { computed as M, inject as F, onMounted as d, onScopeDispose as S, onUnmounted as m, ref as l, shallowRef as A } from "vue";
3
3
  var N = /* @__PURE__ */ Symbol("ago-client"), b = { install(t, e) {
4
4
  const n = new E(e);
package/dist/widget.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("./AgoClient-BGkFSNZF.cjs"),Xt=require("./createConversationSession-BCb0D6bt.cjs"),mt=require("./createFormCollector-t_fGyuTD.cjs");var Yt='"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',Ie=`var(--ago-font, ${Yt})`,gt={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color",agentBubbleBg:"--ago-agent-bubble-background"},_e="var(--ago-brand-color, #03182f)",Le="var(--ago-brand-text-color, #fff)",Qt="var(--ago-header-background, var(--ago-brand-color, #03182f))",ht="var(--ago-header-text-color, #e8f0fe)",te="var(--ago-panel-background, #fff)",Ct="var(--ago-messages-background, #fbfbfb)",ee="var(--ago-text-color, #30373e)",Et="var(--ago-muted-text-color, #6b6d6f)",N="var(--ago-border-color, #dee3e8)",Fe="var(--ago-accent-color, #1b5fc4)",xt="var(--ago-agent-bubble-background, #f1f3f5)",Zt="var(--ago-radius, 16px)",Pe="var(--ago-message-radius, 16px)",Jt="var(--ago-message-radius, 20px)";function en(t,o){if(o)for(const i of Object.keys(gt)){const r=o[i];r!=null&&t.style.setProperty(gt[i],r)}}function v(t,o){Object.assign(t.style,o)}function h(t={}){const o=document.createElement("div");return v(o,t),o}var bt="ago-chat-widget-keyframes";function tn(){if(typeof document>"u"||document.getElementById(bt))return;const t=document.createElement("style");t.id=bt,t.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }",document.head.appendChild(t)}function nn(t){let o=[];const i=document.createElement("form");v(i,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${N}`,backgroundColor:te}),i.className="ago-chat-input";const r=h({display:"flex",flexWrap:"wrap",gap:"6px"}),b=h({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=t.placeholder,a.setAttribute("aria-label",t.placeholder),a.rows=1,v(a,{flex:"1",resize:"none",boxSizing:"border-box",padding:"10px 12px",border:`1px solid ${N}`,borderRadius:"12px",fontSize:"16px",fontFamily:Ie,lineHeight:"1.4",maxHeight:"110px",overflowY:"hidden"});const C=()=>{a.style.height="auto";const c=Math.min(a.scrollHeight+2,110);a.style.height=`${c}px`,a.style.overflowY=a.scrollHeight+2>110?"auto":"hidden"};a.addEventListener("input",()=>{C(),I()});const m='<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>',x='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',p=document.createElement("button");p.type="submit",p.setAttribute("aria-label","Send"),p.innerHTML=m,v(p,{flexShrink:"0",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:_e,color:Le,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"});let f=!1;const I=()=>{const l=a.value.trim()!==""||o.length>0,c=f||!l;p.disabled=c,p.innerHTML=f?x:m,p.style.opacity=c&&!f?"0.5":"1",p.style.cursor=c?"default":"pointer"};let R=null,A=null;t.allowFiles&&(R=document.createElement("input"),R.type="file",R.multiple=!0,v(R,{display:"none"}),A=document.createElement("button"),A.type="button",A.setAttribute("aria-label","Attach file"),A.textContent="📎",v(A,{padding:"10px 12px",border:`1px solid ${N}`,borderRadius:"12px",backgroundColor:te,cursor:"pointer",fontSize:"14px"}),A.addEventListener("click",()=>R?.click()),R.addEventListener("change",()=>{o=[...o,...Array.from(R?.files??[])],Q()}));function Q(){r.replaceChildren(),o.forEach((l,c)=>{const w=h({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${N}`,borderRadius:"8px",fontSize:"12px"}),B=document.createElement("span");B.textContent=l.name;const k=document.createElement("button");k.type="button",k.setAttribute("aria-label",`Remove ${l.name}`),k.textContent="×",v(k,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),k.addEventListener("click",()=>{o=o.filter((j,V)=>V!==c),Q()}),w.append(B,k),r.appendChild(w)}),I()}const D=()=>{const l=a.value,c=o;return a.value="",C(),o=[],Q(),{content:l,files:c}},g=()=>{const{content:l,files:c}=D();(l.trim()||c.length>0)&&t.onSend(l.trim(),c.length>0?c:void 0)};return i.addEventListener("submit",l=>{l.preventDefault(),g()}),a.addEventListener("keydown",l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),g())}),A&&b.appendChild(A),b.append(a,p),R&&i.appendChild(R),i.append(r,b),I(),{inputRow:i,getValueAndClear:D,setDisabled:l=>{a.disabled=l,f=l,I()},focus:()=>a.focus()}}var on={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ae(t){return t.replace(/[&<>"']/g,o=>on[o])}function vt(t){const o=t.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o)||!/^[a-z][a-z0-9+.-]*:/i.test(o)?o:null}var St='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Re="";function ne(t){const o=[],i=b=>(o.push(b),`${Re}${o.length-1}${Re}`);let r=t;return r=r.replace(/`([^`]+)`/g,(b,a)=>i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${St}">${ae(a)}</code>`)),r=r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=vt(C);return m?i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):b}),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=vt(C);return m?i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${ne(a)}</a>`):b}),r=ae(r),r=r.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),r=r.replace(new RegExp(`${Re}(\\d+)${Re}`,"g"),(b,a)=>o[Number(a)]),r}function O(t,o,i){const r=document.createElement(t);return Object.assign(r.style,o),i!==void 0&&(r.innerHTML=i),r}var Rt=/^ {0,3}([-*_])( *\1){2,} *$/,kt=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,It=/^ {0,3}(```+|~~~+)/,Ae=/^ {0,3}>\s?/,le=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,rn=["20px","18px","16px","15px","14px","13px"],He=t=>t.match(/^\s*/)?.[0].length??0;function an(t){return t.trim()===""||Rt.test(t)||kt.test(t)||It.test(t)||Ae.test(t)||le.test(t)}function At(t){const o=t[0].match(le),i=o[1].length,r=/\d/.test(o[2]),b=O(r?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:r?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<t.length;){const C=t[a].match(le),m=[];for(a++;a<t.length&&He(t[a])>i;)m.push(t[a]),a++;const x=O("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),p=C[3].match(/^\[([ xX])\]\s+(.*)$/);p?(x.style.listStyleType="none",x.style.marginLeft="-20px",x.innerHTML=`<span style="margin-right:6px">${p[1].toLowerCase()==="x"?"☑":"☐"}</span>${ne(p[2])}`):x.innerHTML=ne(C[3]),m.filter(f=>le.test(f)).length>0&&x.appendChild(At(m.filter(f=>f.trim()!==""))),b.appendChild(x)}return b}function sn(t){const o=m=>m.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(x=>x.trim()),i=O("div",{overflowX:"auto",margin:"0 0 8px 0"}),r=O("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),b=document.createElement("thead"),a=document.createElement("tr");for(const m of o(t[0]))a.appendChild(O("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},ne(m)));b.appendChild(a),r.appendChild(b);const C=document.createElement("tbody");for(const m of t.slice(2)){const x=document.createElement("tr");for(const p of o(m))x.appendChild(O("td",{border:"1px solid #dee3e8",padding:"6px 10px"},ne(p)));C.appendChild(x)}return r.appendChild(C),i.appendChild(r),i}var ln=t=>!!t&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(t);function Ne(t){const o=document.createDocumentFragment(),i=t.replace(/\r\n?/g,`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("./AgoClient-Ba3ICq4K.cjs"),Xt=require("./createConversationSession-okoz3teC.cjs"),mt=require("./createFormCollector-BWIh1pMl.cjs");var Yt='"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',Ie=`var(--ago-font, ${Yt})`,gt={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color",agentBubbleBg:"--ago-agent-bubble-background"},_e="var(--ago-brand-color, #03182f)",Le="var(--ago-brand-text-color, #fff)",Qt="var(--ago-header-background, var(--ago-brand-color, #03182f))",ht="var(--ago-header-text-color, #e8f0fe)",te="var(--ago-panel-background, #fff)",Ct="var(--ago-messages-background, #fbfbfb)",ee="var(--ago-text-color, #30373e)",Et="var(--ago-muted-text-color, #6b6d6f)",N="var(--ago-border-color, #dee3e8)",Fe="var(--ago-accent-color, #1b5fc4)",xt="var(--ago-agent-bubble-background, #f1f3f5)",Zt="var(--ago-radius, 16px)",Pe="var(--ago-message-radius, 16px)",Jt="var(--ago-message-radius, 20px)";function en(t,o){if(o)for(const i of Object.keys(gt)){const r=o[i];r!=null&&t.style.setProperty(gt[i],r)}}function v(t,o){Object.assign(t.style,o)}function h(t={}){const o=document.createElement("div");return v(o,t),o}var bt="ago-chat-widget-keyframes";function tn(){if(typeof document>"u"||document.getElementById(bt))return;const t=document.createElement("style");t.id=bt,t.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }",document.head.appendChild(t)}function nn(t){let o=[];const i=document.createElement("form");v(i,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${N}`,backgroundColor:te}),i.className="ago-chat-input";const r=h({display:"flex",flexWrap:"wrap",gap:"6px"}),b=h({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=t.placeholder,a.setAttribute("aria-label",t.placeholder),a.rows=1,v(a,{flex:"1",resize:"none",boxSizing:"border-box",padding:"10px 12px",border:`1px solid ${N}`,borderRadius:"12px",fontSize:"16px",fontFamily:Ie,lineHeight:"1.4",maxHeight:"110px",overflowY:"hidden"});const C=()=>{a.style.height="auto";const c=Math.min(a.scrollHeight+2,110);a.style.height=`${c}px`,a.style.overflowY=a.scrollHeight+2>110?"auto":"hidden"};a.addEventListener("input",()=>{C(),I()});const m='<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>',x='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',p=document.createElement("button");p.type="submit",p.setAttribute("aria-label","Send"),p.innerHTML=m,v(p,{flexShrink:"0",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:_e,color:Le,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"});let f=!1;const I=()=>{const l=a.value.trim()!==""||o.length>0,c=f||!l;p.disabled=c,p.innerHTML=f?x:m,p.style.opacity=c&&!f?"0.5":"1",p.style.cursor=c?"default":"pointer"};let R=null,A=null;t.allowFiles&&(R=document.createElement("input"),R.type="file",R.multiple=!0,v(R,{display:"none"}),A=document.createElement("button"),A.type="button",A.setAttribute("aria-label","Attach file"),A.textContent="📎",v(A,{padding:"10px 12px",border:`1px solid ${N}`,borderRadius:"12px",backgroundColor:te,cursor:"pointer",fontSize:"14px"}),A.addEventListener("click",()=>R?.click()),R.addEventListener("change",()=>{o=[...o,...Array.from(R?.files??[])],Q()}));function Q(){r.replaceChildren(),o.forEach((l,c)=>{const w=h({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${N}`,borderRadius:"8px",fontSize:"12px"}),B=document.createElement("span");B.textContent=l.name;const k=document.createElement("button");k.type="button",k.setAttribute("aria-label",`Remove ${l.name}`),k.textContent="×",v(k,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),k.addEventListener("click",()=>{o=o.filter((j,V)=>V!==c),Q()}),w.append(B,k),r.appendChild(w)}),I()}const D=()=>{const l=a.value,c=o;return a.value="",C(),o=[],Q(),{content:l,files:c}},g=()=>{const{content:l,files:c}=D();(l.trim()||c.length>0)&&t.onSend(l.trim(),c.length>0?c:void 0)};return i.addEventListener("submit",l=>{l.preventDefault(),g()}),a.addEventListener("keydown",l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),g())}),A&&b.appendChild(A),b.append(a,p),R&&i.appendChild(R),i.append(r,b),I(),{inputRow:i,getValueAndClear:D,setDisabled:l=>{a.disabled=l,f=l,I()},focus:()=>a.focus()}}var on={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ae(t){return t.replace(/[&<>"']/g,o=>on[o])}function vt(t){const o=t.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o)||!/^[a-z][a-z0-9+.-]*:/i.test(o)?o:null}var St='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Re="";function ne(t){const o=[],i=b=>(o.push(b),`${Re}${o.length-1}${Re}`);let r=t;return r=r.replace(/`([^`]+)`/g,(b,a)=>i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${St}">${ae(a)}</code>`)),r=r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=vt(C);return m?i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):b}),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=vt(C);return m?i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${ne(a)}</a>`):b}),r=ae(r),r=r.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),r=r.replace(new RegExp(`${Re}(\\d+)${Re}`,"g"),(b,a)=>o[Number(a)]),r}function O(t,o,i){const r=document.createElement(t);return Object.assign(r.style,o),i!==void 0&&(r.innerHTML=i),r}var Rt=/^ {0,3}([-*_])( *\1){2,} *$/,kt=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,It=/^ {0,3}(```+|~~~+)/,Ae=/^ {0,3}>\s?/,le=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,rn=["20px","18px","16px","15px","14px","13px"],He=t=>t.match(/^\s*/)?.[0].length??0;function an(t){return t.trim()===""||Rt.test(t)||kt.test(t)||It.test(t)||Ae.test(t)||le.test(t)}function At(t){const o=t[0].match(le),i=o[1].length,r=/\d/.test(o[2]),b=O(r?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:r?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<t.length;){const C=t[a].match(le),m=[];for(a++;a<t.length&&He(t[a])>i;)m.push(t[a]),a++;const x=O("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),p=C[3].match(/^\[([ xX])\]\s+(.*)$/);p?(x.style.listStyleType="none",x.style.marginLeft="-20px",x.innerHTML=`<span style="margin-right:6px">${p[1].toLowerCase()==="x"?"☑":"☐"}</span>${ne(p[2])}`):x.innerHTML=ne(C[3]),m.filter(f=>le.test(f)).length>0&&x.appendChild(At(m.filter(f=>f.trim()!==""))),b.appendChild(x)}return b}function sn(t){const o=m=>m.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(x=>x.trim()),i=O("div",{overflowX:"auto",margin:"0 0 8px 0"}),r=O("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),b=document.createElement("thead"),a=document.createElement("tr");for(const m of o(t[0]))a.appendChild(O("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},ne(m)));b.appendChild(a),r.appendChild(b);const C=document.createElement("tbody");for(const m of t.slice(2)){const x=document.createElement("tr");for(const p of o(m))x.appendChild(O("td",{border:"1px solid #dee3e8",padding:"6px 10px"},ne(p)));C.appendChild(x)}return r.appendChild(C),i.appendChild(r),i}var ln=t=>!!t&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(t);function Ne(t){const o=document.createDocumentFragment(),i=t.replace(/\r\n?/g,`
2
2
  `).split(`
3
3
  `);let r=0;for(;r<i.length;){const a=i[r];if(a.trim()===""){r++;continue}const C=a.match(It);if(C){const p=C[1][0],f=[];for(r++;r<i.length&&!new RegExp(`^ {0,3}${p==="`"?"`{3,}":"~{3,}"}\\s*$`).test(i[r]);)f.push(i[r]),r++;r++;const I=O("pre",{margin:"0 0 8px 0"});I.appendChild(O("code",{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:St,whiteSpace:"pre"},ae(f.join(`
4
4
  `)))),o.appendChild(I);continue}if(Rt.test(a)){o.appendChild(O("hr",{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"})),r++;continue}const m=a.match(kt);if(m){const p=m[1].length;o.appendChild(O(`h${p}`,{margin:"16px 0 8px 0",fontSize:rn[p-1],fontWeight:"600",lineHeight:"1.3"},ne(m[2]))),r++;continue}if(Ae.test(a)){const p=[];for(;r<i.length&&Ae.test(i[r]);)p.push(i[r].replace(Ae,"")),r++;const f=O("blockquote",{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"});f.appendChild(Ne(p.join(`
package/dist/widget.d.cts CHANGED
@@ -1,3 +1,19 @@
1
+ declare interface ActivityEntry {
2
+ ts: number;
3
+ actor: "user" | "agent";
4
+ name: string;
5
+ summary: string;
6
+ data?: Record<string, unknown>;
7
+ }
8
+
9
+ declare interface ActivityInput {
10
+ actor?: "user" | "agent";
11
+ name: string;
12
+ summary: string;
13
+ data?: Record<string, unknown>;
14
+ ts?: number;
15
+ }
16
+
1
17
  /**
2
18
  * Agent information
3
19
  */
@@ -36,6 +52,8 @@ declare class AgoClient {
36
52
  private functionRegistry;
37
53
  private contextRegistry;
38
54
  private eventEmitter;
55
+ private activityLedger;
56
+ private lastSentPageState;
39
57
  private config;
40
58
  /** Conversations already warned about an empty reply (one warning each). */
41
59
  private warnedEmptyConversations;
@@ -346,6 +364,19 @@ declare class AgoClient {
346
364
  * Get the current context snapshot.
347
365
  */
348
366
  getContextSnapshot(): ContextSnapshot | null;
367
+ private buildSendContext;
368
+ /**
369
+ * Record something the user just did so the agent is aware of it on the next
370
+ * message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
371
+ * (no raw payloads, secrets, or PII).
372
+ */
373
+ recordActivity(entry: ActivityInput): void;
374
+ /** Recent user + agent actions, oldest first (a copy). */
375
+ getRecentActivity(): ActivityEntry[];
376
+ clearActivity(): void;
377
+ private addActivity;
378
+ private recordAgentAction;
379
+ private registerActivityContext;
349
380
  /**
350
381
  * Subscribe to an event
351
382
  */
@@ -517,6 +548,8 @@ declare interface AgoClientEvents {
517
548
  "nudge:accepted": {
518
549
  nudge: ProactiveNudgeInstance;
519
550
  };
551
+ /** A user- or agent-action was recorded into the activity ledger. */
552
+ "activity:recorded": ActivityEntry;
520
553
  }
521
554
 
522
555
  /**
@@ -578,6 +611,14 @@ declare interface AgoConfig {
578
611
  * with `maxResultBytes` on its definition; `Infinity` disables the guard.
579
612
  */
580
613
  maxFunctionResultBytes?: number;
614
+ /**
615
+ * Max number of recent actions kept in the in-memory activity ledger that
616
+ * rides along as the `activity:recent` context entry. Older entries drop
617
+ * first. Default `10`. Larger values give the agent more history at the cost
618
+ * of tokens on every message. Each entry's `data` is also size-clamped (long
619
+ * strings truncated, large arrays capped) so one event can't bloat the context.
620
+ */
621
+ maxActivityEntries?: number;
581
622
  /**
582
623
  * Enable the proactive mode: declarative triggers evaluated client-side
583
624
  * against friction signals (dwell/idle time, rage clicks, route bounces…)
package/dist/widget.d.ts CHANGED
@@ -1,3 +1,19 @@
1
+ declare interface ActivityEntry {
2
+ ts: number;
3
+ actor: "user" | "agent";
4
+ name: string;
5
+ summary: string;
6
+ data?: Record<string, unknown>;
7
+ }
8
+
9
+ declare interface ActivityInput {
10
+ actor?: "user" | "agent";
11
+ name: string;
12
+ summary: string;
13
+ data?: Record<string, unknown>;
14
+ ts?: number;
15
+ }
16
+
1
17
  /**
2
18
  * Agent information
3
19
  */
@@ -36,6 +52,8 @@ declare class AgoClient {
36
52
  private functionRegistry;
37
53
  private contextRegistry;
38
54
  private eventEmitter;
55
+ private activityLedger;
56
+ private lastSentPageState;
39
57
  private config;
40
58
  /** Conversations already warned about an empty reply (one warning each). */
41
59
  private warnedEmptyConversations;
@@ -346,6 +364,19 @@ declare class AgoClient {
346
364
  * Get the current context snapshot.
347
365
  */
348
366
  getContextSnapshot(): ContextSnapshot | null;
367
+ private buildSendContext;
368
+ /**
369
+ * Record something the user just did so the agent is aware of it on the next
370
+ * message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
371
+ * (no raw payloads, secrets, or PII).
372
+ */
373
+ recordActivity(entry: ActivityInput): void;
374
+ /** Recent user + agent actions, oldest first (a copy). */
375
+ getRecentActivity(): ActivityEntry[];
376
+ clearActivity(): void;
377
+ private addActivity;
378
+ private recordAgentAction;
379
+ private registerActivityContext;
349
380
  /**
350
381
  * Subscribe to an event
351
382
  */
@@ -517,6 +548,8 @@ declare interface AgoClientEvents {
517
548
  "nudge:accepted": {
518
549
  nudge: ProactiveNudgeInstance;
519
550
  };
551
+ /** A user- or agent-action was recorded into the activity ledger. */
552
+ "activity:recorded": ActivityEntry;
520
553
  }
521
554
 
522
555
  /**
@@ -578,6 +611,14 @@ declare interface AgoConfig {
578
611
  * with `maxResultBytes` on its definition; `Infinity` disables the guard.
579
612
  */
580
613
  maxFunctionResultBytes?: number;
614
+ /**
615
+ * Max number of recent actions kept in the in-memory activity ledger that
616
+ * rides along as the `activity:recent` context entry. Older entries drop
617
+ * first. Default `10`. Larger values give the agent more history at the cost
618
+ * of tokens on every message. Each entry's `data` is also size-clamped (long
619
+ * strings truncated, large arrays capped) so one event can't bloat the context.
620
+ */
621
+ maxActivityEntries?: number;
581
622
  /**
582
623
  * Enable the proactive mode: declarative triggers evaluated client-side
583
624
  * against friction signals (dwell/idle time, rage clicks, route bounces…)
package/dist/widget.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a as qt, b as Kt, i as Xt, o as Yt, s as Qt, t as Zt } from "./AgoClient-CW-BLT1_.js";
2
- import { t as Jt } from "./createConversationSession-C7cnnWKW.js";
3
- import { r as en, t as tn } from "./createFormCollector-iCDwAwYJ.js";
1
+ import { a as qt, b as Kt, i as Xt, o as Yt, s as Qt, t as Zt } from "./AgoClient-BW0YZsis.js";
2
+ import { t as Jt } from "./createConversationSession-BjsgjL-v.js";
3
+ import { r as en, t as tn } from "./createFormCollector-Bay2UpRv.js";
4
4
  var nn = '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', ke = `var(--ago-font, ${nn})`, ut = {
5
5
  font: "--ago-font",
6
6
  radius: "--ago-radius",
package/llms-full.txt CHANGED
@@ -1389,6 +1389,11 @@ It's fire-and-forget: the handler applies each `set()` locally and returns
1389
1389
  the next message. React/Vue offer `useAgoPageState(controls, opts?)` with
1390
1390
  lifecycle cleanup; Angular exposes `agoService.registerPageStateFunction(...)`.
1391
1391
 
1392
+ The SDK also tells the agent **what changed**: on each message it diffs the page
1393
+ state against the previous message and adds a `state:delta` entry listing the
1394
+ fields that changed. A navigation (a different page) resets the baseline instead
1395
+ of reporting a diff, so a page switch never shows up as a spurious change.
1396
+
1392
1397
  ### Navigate then change the page in one go
1393
1398
 
1394
1399
  A request like "open the invoices page and show only the overdue ones" needs two
@@ -1617,6 +1622,29 @@ client.enableAutoPageContext();
1617
1622
 
1618
1623
  (In React, set `<AgoProvider pageContext="auto">`.)
1619
1624
 
1625
+ ### Activity ledger
1626
+
1627
+ Tell the agent what the user (or the agent) just did, so it can reason about
1628
+ recent actions. Call `recordActivity` for meaningful user actions; the agent's
1629
+ own client-function calls (navigation, page-state changes, custom functions) are
1630
+ recorded automatically.
1631
+
1632
+ ```ts
1633
+ client.recordActivity({
1634
+ name: "order.shipped",
1635
+ summary: 'User changed order #123 from "Pending" to "Shipped"',
1636
+ });
1637
+ ```
1638
+
1639
+ The recent window (last 10 by default, oldest dropped first) rides along as the
1640
+ `activity:recent` context entry. Change the size with `maxActivityEntries` in the
1641
+ config. `actor` defaults to `"user"`; keep `summary` short and high-signal (no raw
1642
+ payloads or secrets). Each entry's `data` is size-clamped before it is stored (long
1643
+ strings truncated with a `…[truncated N chars]` marker, large arrays capped), so one
1644
+ event can't bloat the context. Read or clear the log with
1645
+ `client.getRecentActivity()` / `client.clearActivity()`, observe it via
1646
+ `client.on("activity:recorded", …)`, or use the React `useAgoActivityLog()` hook.
1647
+
1620
1648
  ### Per framework
1621
1649
 
1622
1650
  | Framework | Idiomatic API |
@@ -1681,6 +1709,7 @@ const final = await client.waitFor("message:complete", { timeout: 10_000 });
1681
1709
  | `function:invoke` | `{ invocationId, functionName, arguments, conversationId }` |
1682
1710
  | `function:awaiting-approval` | `{ invocationId, functionName, arguments, conversationId }`: a client function call is held pending user approval (pause mode + an `approvalPolicy`/`requiresApproval` match). The turn stays at `WAITING_CLIENT`; call `approveFunction(invocationId)` to run it and resume, or `rejectFunction(invocationId)` to decline. See [Approval gate](functions-and-context.md#approval-gate-ask-before-running) |
1683
1711
  | `function:result` | `{ invocationId, result, error? }` |
1712
+ | `activity:recorded` | `ActivityEntry`: a user- or agent-action was recorded into the activity ledger (via `recordActivity`, or auto-recorded when the agent calls a client function). See [Activity ledger](functions-and-context.md#activity-ledger) |
1684
1713
  | `form:submitted` | `{ name, values, result }`: a form collector submitted successfully; `result` is the submit response (the third-party API's answer) |
1685
1714
  | `form:error` | `{ name, values, error }`: a form collector submit failed at the network/server level (HTTP non-2xx or a thrown handler/fetch). Validation pre-checks (missing fields, no submit target) do not fire this |
1686
1715
  | `connection:status` | `{ connected }` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useago/sdk",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "Create In-APP AI agents that answers question and performs actions. Works with React, Vue, Angular and vanilla JS/TS.",
5
5
  "type": "module",
6
6
  "sideEffects": false,