@useago/sdk 1.3.2 → 1.4.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.
- package/README.md +41 -0
- package/dist/{AgoClient-Cwx_eYSu.js → AgoClient-BdtuHX7k.js} +150 -85
- package/dist/AgoClient-CRAnT4qE.cjs +8 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +99 -1
- package/dist/angular.d.ts +99 -1
- package/dist/angular.js +16 -7
- package/dist/{createConversationSession-DV0Xp_3O.cjs → createConversationSession-B8zfTL78.cjs} +1 -1
- package/dist/{createConversationSession-B3h567tt.js → createConversationSession-CWpf4u6I.js} +1 -1
- package/dist/{createFormCollector-CyWisAkI.js → createFormCollector-B4n0_diV.js} +1 -1
- package/dist/{createFormCollector-BB3Uscuo.cjs → createFormCollector-BB_l0Sia.cjs} +1 -1
- package/dist/{createMockClient-DwdxNwEn.js → createMockClient-d-arlmCq.js} +19 -17
- package/dist/createMockClient-ucPENDzz.cjs +1 -0
- package/dist/devtools.d.cts +93 -1
- package/dist/devtools.d.ts +93 -1
- package/dist/helpers.d.cts +5 -1
- package/dist/helpers.d.ts +5 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +93 -1
- package/dist/index.d.ts +93 -1
- package/dist/index.js +4 -4
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +158 -2
- package/dist/react.d.ts +158 -2
- package/dist/react.js +469 -391
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +93 -1
- package/dist/testing.d.ts +93 -1
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +125 -1
- package/dist/vue.d.ts +125 -1
- package/dist/vue.js +73 -64
- package/dist/widget.cjs +1 -1
- package/dist/widget.d.cts +93 -1
- package/dist/widget.d.ts +93 -1
- package/dist/widget.js +3 -3
- package/package.json +1 -1
- package/dist/AgoClient-CzSmJQxl.cjs +0 -6
- package/dist/createMockClient-zHQ0cjUH.cjs +0 -1
package/dist/angular.d.cts
CHANGED
|
@@ -146,6 +146,12 @@ declare class AgoClient {
|
|
|
146
146
|
getRegisteredFunctions(): ClientFunctionSchema[];
|
|
147
147
|
/**
|
|
148
148
|
* Register a navigation function that lets AGO navigate users to different pages.
|
|
149
|
+
*
|
|
150
|
+
* Also registers a dynamic context entry (`current-page`) that reports the page
|
|
151
|
+
* the user is currently on, by route name, on every message. This is what lets
|
|
152
|
+
* the agent know *where* it is after it navigates (e.g. so auto-continuation
|
|
153
|
+
* can apply page state on the destination), not just how to navigate away.
|
|
154
|
+
*
|
|
149
155
|
* @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
|
|
150
156
|
* @param routes - Map of route names to paths, with descriptions for the LLM
|
|
151
157
|
*/
|
|
@@ -154,6 +160,41 @@ declare class AgoClient {
|
|
|
154
160
|
path: string;
|
|
155
161
|
description: string;
|
|
156
162
|
}>): void;
|
|
163
|
+
/**
|
|
164
|
+
* Unregister the navigation function and its `current-page` context provider.
|
|
165
|
+
*/
|
|
166
|
+
unregisterNavigationFunction(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Register a "page state" function that lets AGO change the current page's
|
|
169
|
+
* state (filters, sort, view mode, selection…) and reads the current state
|
|
170
|
+
* back as dynamic context. This is the state-mutation mirror of
|
|
171
|
+
* {@link registerNavigationFunction}.
|
|
172
|
+
*
|
|
173
|
+
* It does two things:
|
|
174
|
+
* - Synthesizes ONE client function (default name `setPageState`) whose
|
|
175
|
+
* properties are the controls — all optional, so the agent sets only the
|
|
176
|
+
* ones the user asked for.
|
|
177
|
+
* - Registers a dynamic context provider (keyed `page-state:<fnName>`) that
|
|
178
|
+
* reports each control's current `get()` value on every message.
|
|
179
|
+
*
|
|
180
|
+
* ```ts
|
|
181
|
+
* client.registerPageStateFunction([
|
|
182
|
+
* {
|
|
183
|
+
* name: "statusFilter",
|
|
184
|
+
* description: "Filter the list by review status",
|
|
185
|
+
* schema: { type: "string", enum: ["all", "pending", "approved"] },
|
|
186
|
+
* get: () => filters.status,
|
|
187
|
+
* set: (v) => setFilters({ ...filters, status: v }),
|
|
188
|
+
* },
|
|
189
|
+
* ]);
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
registerPageStateFunction(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
|
|
193
|
+
/**
|
|
194
|
+
* Unregister a page state function and its dynamic context provider.
|
|
195
|
+
* Mirror of unregistering `navigateToPage`.
|
|
196
|
+
*/
|
|
197
|
+
unregisterPageStateFunction(functionName?: string): void;
|
|
157
198
|
/**
|
|
158
199
|
* Register or update a piece of client-side context.
|
|
159
200
|
* This context is sent with every message so the AI understands the user's situation.
|
|
@@ -386,9 +427,23 @@ export declare interface AgoMessage {
|
|
|
386
427
|
followUpReplies?: string[];
|
|
387
428
|
/** Uploaded files on this message (usually the user's). */
|
|
388
429
|
attachments?: AgoAttachment[];
|
|
430
|
+
/**
|
|
431
|
+
* True when the backend flagged this message as hidden (e.g. an
|
|
432
|
+
* auto-continuation nudge). Kept in the model's context but not displayed;
|
|
433
|
+
* UI helpers like `useMessages`/`ChatWidget` filter these out.
|
|
434
|
+
*/
|
|
435
|
+
hidden?: boolean;
|
|
389
436
|
createdAt: Date;
|
|
390
437
|
}
|
|
391
438
|
|
|
439
|
+
/**
|
|
440
|
+
* Options for {@link AgoClient.registerPageStateFunction}.
|
|
441
|
+
*/
|
|
442
|
+
export declare interface AgoPageStateOptions {
|
|
443
|
+
/** Name of the synthesized client function. Defaults to "setPageState". */
|
|
444
|
+
functionName?: string;
|
|
445
|
+
}
|
|
446
|
+
|
|
392
447
|
export declare type AgoProvideOptions = AgoConfig;
|
|
393
448
|
|
|
394
449
|
/**
|
|
@@ -466,6 +521,12 @@ export declare class AgoService {
|
|
|
466
521
|
path: string;
|
|
467
522
|
description: string;
|
|
468
523
|
}>): void;
|
|
524
|
+
/** Unregister navigation (function + current-page context) */
|
|
525
|
+
unregisterNavigationFunction(): void;
|
|
526
|
+
/** Register editable page-state controls (filters, sort, view mode…) */
|
|
527
|
+
registerPageStateFunction(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
|
|
528
|
+
/** Unregister a page-state function and its dynamic context */
|
|
529
|
+
unregisterPageStateFunction(functionName?: string): void;
|
|
469
530
|
/** Subscribe to a client event */
|
|
470
531
|
on<K extends AgoEventName>(event: K, handler: (data: AgoClientEvents[K]) => void): void;
|
|
471
532
|
/** Unsubscribe from a client event */
|
|
@@ -487,6 +548,32 @@ export declare interface AgoSource {
|
|
|
487
548
|
url?: string;
|
|
488
549
|
}
|
|
489
550
|
|
|
551
|
+
/**
|
|
552
|
+
* A single editable control on the current page (a filter, a sort, a view mode,
|
|
553
|
+
* a selection…). It becomes one optional property of the synthesized
|
|
554
|
+
* `setPageState` function, and its current value is surfaced back to the agent
|
|
555
|
+
* as dynamic context. This is the state-mutation mirror of a navigation route.
|
|
556
|
+
*/
|
|
557
|
+
export declare interface AgoStateControl<T = unknown> {
|
|
558
|
+
/** Machine name of the control, e.g. "statusFilter". Becomes a property of the tool. */
|
|
559
|
+
name: string;
|
|
560
|
+
/** Description for the LLM, e.g. "Filter the list by review status". */
|
|
561
|
+
description: string;
|
|
562
|
+
/** JSON schema for a SINGLE field (like one property of navigateToPage). */
|
|
563
|
+
schema: {
|
|
564
|
+
type: "string" | "number" | "boolean" | "array";
|
|
565
|
+
enum?: (string | number)[];
|
|
566
|
+
items?: {
|
|
567
|
+
type: string;
|
|
568
|
+
enum?: (string | number)[];
|
|
569
|
+
};
|
|
570
|
+
};
|
|
571
|
+
/** Current value → pushed as dynamic context so the agent knows what to change. */
|
|
572
|
+
get?: () => T;
|
|
573
|
+
/** Apply the state change on the page. May be async. */
|
|
574
|
+
set: (value: T) => void | Promise<void>;
|
|
575
|
+
}
|
|
576
|
+
|
|
490
577
|
/**
|
|
491
578
|
* Single-object function definition — combines name, schema, and handler.
|
|
492
579
|
*
|
|
@@ -533,7 +620,11 @@ declare interface ClientFunctionSchema {
|
|
|
533
620
|
properties: Record<string, {
|
|
534
621
|
type: string;
|
|
535
622
|
description?: string;
|
|
536
|
-
enum?: string[];
|
|
623
|
+
enum?: (string | number)[];
|
|
624
|
+
items?: {
|
|
625
|
+
type: string;
|
|
626
|
+
enum?: (string | number)[];
|
|
627
|
+
};
|
|
537
628
|
default?: unknown;
|
|
538
629
|
}>;
|
|
539
630
|
required?: string[];
|
|
@@ -718,6 +809,13 @@ declare interface SendMessageOptions {
|
|
|
718
809
|
agentId?: string;
|
|
719
810
|
/** File attachments */
|
|
720
811
|
files?: File[];
|
|
812
|
+
/**
|
|
813
|
+
* Mark this message as hidden. The backend keeps it in the model's context but
|
|
814
|
+
* flags it so the UI never displays it. Used by auto-continuation to nudge the
|
|
815
|
+
* agent after a navigation without polluting the visible transcript.
|
|
816
|
+
* Requires backend support for the `hidden` flag; older backends ignore it.
|
|
817
|
+
*/
|
|
818
|
+
hidden?: boolean;
|
|
721
819
|
}
|
|
722
820
|
|
|
723
821
|
/**
|
package/dist/angular.d.ts
CHANGED
|
@@ -146,6 +146,12 @@ declare class AgoClient {
|
|
|
146
146
|
getRegisteredFunctions(): ClientFunctionSchema[];
|
|
147
147
|
/**
|
|
148
148
|
* Register a navigation function that lets AGO navigate users to different pages.
|
|
149
|
+
*
|
|
150
|
+
* Also registers a dynamic context entry (`current-page`) that reports the page
|
|
151
|
+
* the user is currently on, by route name, on every message. This is what lets
|
|
152
|
+
* the agent know *where* it is after it navigates (e.g. so auto-continuation
|
|
153
|
+
* can apply page state on the destination), not just how to navigate away.
|
|
154
|
+
*
|
|
149
155
|
* @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
|
|
150
156
|
* @param routes - Map of route names to paths, with descriptions for the LLM
|
|
151
157
|
*/
|
|
@@ -154,6 +160,41 @@ declare class AgoClient {
|
|
|
154
160
|
path: string;
|
|
155
161
|
description: string;
|
|
156
162
|
}>): void;
|
|
163
|
+
/**
|
|
164
|
+
* Unregister the navigation function and its `current-page` context provider.
|
|
165
|
+
*/
|
|
166
|
+
unregisterNavigationFunction(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Register a "page state" function that lets AGO change the current page's
|
|
169
|
+
* state (filters, sort, view mode, selection…) and reads the current state
|
|
170
|
+
* back as dynamic context. This is the state-mutation mirror of
|
|
171
|
+
* {@link registerNavigationFunction}.
|
|
172
|
+
*
|
|
173
|
+
* It does two things:
|
|
174
|
+
* - Synthesizes ONE client function (default name `setPageState`) whose
|
|
175
|
+
* properties are the controls — all optional, so the agent sets only the
|
|
176
|
+
* ones the user asked for.
|
|
177
|
+
* - Registers a dynamic context provider (keyed `page-state:<fnName>`) that
|
|
178
|
+
* reports each control's current `get()` value on every message.
|
|
179
|
+
*
|
|
180
|
+
* ```ts
|
|
181
|
+
* client.registerPageStateFunction([
|
|
182
|
+
* {
|
|
183
|
+
* name: "statusFilter",
|
|
184
|
+
* description: "Filter the list by review status",
|
|
185
|
+
* schema: { type: "string", enum: ["all", "pending", "approved"] },
|
|
186
|
+
* get: () => filters.status,
|
|
187
|
+
* set: (v) => setFilters({ ...filters, status: v }),
|
|
188
|
+
* },
|
|
189
|
+
* ]);
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
registerPageStateFunction(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
|
|
193
|
+
/**
|
|
194
|
+
* Unregister a page state function and its dynamic context provider.
|
|
195
|
+
* Mirror of unregistering `navigateToPage`.
|
|
196
|
+
*/
|
|
197
|
+
unregisterPageStateFunction(functionName?: string): void;
|
|
157
198
|
/**
|
|
158
199
|
* Register or update a piece of client-side context.
|
|
159
200
|
* This context is sent with every message so the AI understands the user's situation.
|
|
@@ -386,9 +427,23 @@ export declare interface AgoMessage {
|
|
|
386
427
|
followUpReplies?: string[];
|
|
387
428
|
/** Uploaded files on this message (usually the user's). */
|
|
388
429
|
attachments?: AgoAttachment[];
|
|
430
|
+
/**
|
|
431
|
+
* True when the backend flagged this message as hidden (e.g. an
|
|
432
|
+
* auto-continuation nudge). Kept in the model's context but not displayed;
|
|
433
|
+
* UI helpers like `useMessages`/`ChatWidget` filter these out.
|
|
434
|
+
*/
|
|
435
|
+
hidden?: boolean;
|
|
389
436
|
createdAt: Date;
|
|
390
437
|
}
|
|
391
438
|
|
|
439
|
+
/**
|
|
440
|
+
* Options for {@link AgoClient.registerPageStateFunction}.
|
|
441
|
+
*/
|
|
442
|
+
export declare interface AgoPageStateOptions {
|
|
443
|
+
/** Name of the synthesized client function. Defaults to "setPageState". */
|
|
444
|
+
functionName?: string;
|
|
445
|
+
}
|
|
446
|
+
|
|
392
447
|
export declare type AgoProvideOptions = AgoConfig;
|
|
393
448
|
|
|
394
449
|
/**
|
|
@@ -466,6 +521,12 @@ export declare class AgoService {
|
|
|
466
521
|
path: string;
|
|
467
522
|
description: string;
|
|
468
523
|
}>): void;
|
|
524
|
+
/** Unregister navigation (function + current-page context) */
|
|
525
|
+
unregisterNavigationFunction(): void;
|
|
526
|
+
/** Register editable page-state controls (filters, sort, view mode…) */
|
|
527
|
+
registerPageStateFunction(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
|
|
528
|
+
/** Unregister a page-state function and its dynamic context */
|
|
529
|
+
unregisterPageStateFunction(functionName?: string): void;
|
|
469
530
|
/** Subscribe to a client event */
|
|
470
531
|
on<K extends AgoEventName>(event: K, handler: (data: AgoClientEvents[K]) => void): void;
|
|
471
532
|
/** Unsubscribe from a client event */
|
|
@@ -487,6 +548,32 @@ export declare interface AgoSource {
|
|
|
487
548
|
url?: string;
|
|
488
549
|
}
|
|
489
550
|
|
|
551
|
+
/**
|
|
552
|
+
* A single editable control on the current page (a filter, a sort, a view mode,
|
|
553
|
+
* a selection…). It becomes one optional property of the synthesized
|
|
554
|
+
* `setPageState` function, and its current value is surfaced back to the agent
|
|
555
|
+
* as dynamic context. This is the state-mutation mirror of a navigation route.
|
|
556
|
+
*/
|
|
557
|
+
export declare interface AgoStateControl<T = unknown> {
|
|
558
|
+
/** Machine name of the control, e.g. "statusFilter". Becomes a property of the tool. */
|
|
559
|
+
name: string;
|
|
560
|
+
/** Description for the LLM, e.g. "Filter the list by review status". */
|
|
561
|
+
description: string;
|
|
562
|
+
/** JSON schema for a SINGLE field (like one property of navigateToPage). */
|
|
563
|
+
schema: {
|
|
564
|
+
type: "string" | "number" | "boolean" | "array";
|
|
565
|
+
enum?: (string | number)[];
|
|
566
|
+
items?: {
|
|
567
|
+
type: string;
|
|
568
|
+
enum?: (string | number)[];
|
|
569
|
+
};
|
|
570
|
+
};
|
|
571
|
+
/** Current value → pushed as dynamic context so the agent knows what to change. */
|
|
572
|
+
get?: () => T;
|
|
573
|
+
/** Apply the state change on the page. May be async. */
|
|
574
|
+
set: (value: T) => void | Promise<void>;
|
|
575
|
+
}
|
|
576
|
+
|
|
490
577
|
/**
|
|
491
578
|
* Single-object function definition — combines name, schema, and handler.
|
|
492
579
|
*
|
|
@@ -533,7 +620,11 @@ declare interface ClientFunctionSchema {
|
|
|
533
620
|
properties: Record<string, {
|
|
534
621
|
type: string;
|
|
535
622
|
description?: string;
|
|
536
|
-
enum?: string[];
|
|
623
|
+
enum?: (string | number)[];
|
|
624
|
+
items?: {
|
|
625
|
+
type: string;
|
|
626
|
+
enum?: (string | number)[];
|
|
627
|
+
};
|
|
537
628
|
default?: unknown;
|
|
538
629
|
}>;
|
|
539
630
|
required?: string[];
|
|
@@ -718,6 +809,13 @@ declare interface SendMessageOptions {
|
|
|
718
809
|
agentId?: string;
|
|
719
810
|
/** File attachments */
|
|
720
811
|
files?: File[];
|
|
812
|
+
/**
|
|
813
|
+
* Mark this message as hidden. The backend keeps it in the model's context but
|
|
814
|
+
* flags it so the UI never displays it. Used by auto-continuation to nudge the
|
|
815
|
+
* agent after a navigation without polluting the visible transcript.
|
|
816
|
+
* Requires backend support for the `hidden` flag; older backends ignore it.
|
|
817
|
+
*/
|
|
818
|
+
hidden?: boolean;
|
|
721
819
|
}
|
|
722
820
|
|
|
723
821
|
/**
|
package/dist/angular.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { t as o } from "./AgoClient-
|
|
2
|
-
var
|
|
1
|
+
import { t as o } from "./AgoClient-BdtuHX7k.js";
|
|
2
|
+
var s = class {
|
|
3
3
|
constructor(t) {
|
|
4
4
|
this.client = new o(t), this.messages$ = this.fromEvent("message:complete"), this.chunks$ = this.fromEvent("message:chunk"), this.errors$ = this.fromEvent("message:error"), this.messageStart$ = this.fromEvent("message:start");
|
|
5
5
|
}
|
|
6
6
|
fromEvent(t) {
|
|
7
7
|
const e = this.client;
|
|
8
8
|
return { subscribe(i) {
|
|
9
|
-
const
|
|
9
|
+
const n = (r) => {
|
|
10
10
|
i.next?.(r);
|
|
11
11
|
};
|
|
12
|
-
return e.on(t,
|
|
12
|
+
return e.on(t, n), { unsubscribe: () => e.off(t, n) };
|
|
13
13
|
} };
|
|
14
14
|
}
|
|
15
15
|
sendMessage(t, e) {
|
|
@@ -45,6 +45,15 @@ var n = class {
|
|
|
45
45
|
registerNavigationFunction(t, e) {
|
|
46
46
|
this.client.registerNavigationFunction(t, e);
|
|
47
47
|
}
|
|
48
|
+
unregisterNavigationFunction() {
|
|
49
|
+
this.client.unregisterNavigationFunction();
|
|
50
|
+
}
|
|
51
|
+
registerPageStateFunction(t, e) {
|
|
52
|
+
this.client.registerPageStateFunction(t, e);
|
|
53
|
+
}
|
|
54
|
+
unregisterPageStateFunction(t) {
|
|
55
|
+
this.client.unregisterPageStateFunction(t);
|
|
56
|
+
}
|
|
48
57
|
on(t, e) {
|
|
49
58
|
this.client.on(t, e);
|
|
50
59
|
}
|
|
@@ -63,11 +72,11 @@ var n = class {
|
|
|
63
72
|
};
|
|
64
73
|
function l(t) {
|
|
65
74
|
return {
|
|
66
|
-
provide:
|
|
67
|
-
useValue: new
|
|
75
|
+
provide: s,
|
|
76
|
+
useValue: new s(t)
|
|
68
77
|
};
|
|
69
78
|
}
|
|
70
79
|
export {
|
|
71
|
-
|
|
80
|
+
s as AgoService,
|
|
72
81
|
l as provideAgo
|
|
73
82
|
};
|
package/dist/{createConversationSession-DV0Xp_3O.cjs → createConversationSession-B8zfTL78.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
const d=require("./createFormCollector-
|
|
1
|
+
const d=require("./createFormCollector-BB_l0Sia.cjs");var f="ago_widget_id",g="ago_last_thread",y=7200*1e3;function v(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.floor(Math.random()*16);return(e==="x"?r:r&3|8).toString(16)})}function _(e={}){const r=e.key??f,i=e.threadKey??g,u=e.ttlMs??y,l=e.storage??(typeof localStorage<"u"?localStorage:void 0);let n=e.widgetId??"";if(!n&&l)try{n=l.getItem(r)??""}catch{}if(n||(n=v()),l)try{l.setItem(r,n)}catch{}const o=d.createStore({value:null,lastMessageAt:null},{key:i,storage:l}),c=o.get();c.value!==null&&s(c.lastMessageAt)&&o.set({value:null,lastMessageAt:null});function s(t){return t===null?!0:Number.isFinite(u)?Date.now()-t>u:!1}return{widgetId:n,key:r,getLastActiveThread(){const{value:t,lastMessageAt:a}=o.get();return t===null||s(a)?null:t},setActiveThread(t,a){const x=a==null?null:a instanceof Date?a.getTime():a;o.set({value:t,lastMessageAt:x})},clear(){o.set({value:null,lastMessageAt:null})}}}Object.defineProperty(exports,"createConversationSession",{enumerable:!0,get:function(){return _}});
|
package/dist/{createConversationSession-B3h567tt.js → createConversationSession-CWpf4u6I.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as d } from "./createFormCollector-
|
|
1
|
+
import { i as d } from "./createFormCollector-B4n0_diV.js";
|
|
2
2
|
var f = "ago_widget_id", g = "ago_last_thread", y = 7200 * 1e3;
|
|
3
3
|
function v() {
|
|
4
4
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const C=require("./AgoClient-
|
|
1
|
+
const C=require("./AgoClient-CRAnT4qE.cjs");function W(n,e){const a=e?e.storage??(typeof localStorage<"u"?localStorage:void 0):void 0;let s=n;if(e&&a)try{const m=a.getItem(e.key);m!=null&&(s=JSON.parse(m))}catch{}const i=new Set,c=()=>i.forEach(m=>m(s));function b(){if(e&&a)try{a.setItem(e.key,JSON.stringify(s))}catch{}}return{get:()=>s,set:m=>{s=m,b(),c()},subscribe:m=>(i.add(m),()=>{i.delete(m)})}}var T=/^[a-zA-Z0-9_-]{1,40}$/,x=n=>n==null||n==="";function v(n,e){if("anyOf"in n)return n.anyOf.some(c=>v(c,e));if("allOf"in n)return n.allOf.every(c=>v(c,e));const a=e[n.property];if(x(a))return!1;if(Array.isArray(n.value))return n.value.some(c=>String(a)===String(c));if(!n.op)return String(a)===String(n.value);const s=Number(a),i=Number(n.value);if(Number.isNaN(s)||Number.isNaN(i))return!1;switch(n.op){case">=":return s>=i;case"<=":return s<=i;case">":return s>i;case"<":return s<i;default:return C.logger.warn(`Unknown requiredWhen op "${n.op}"; treating as not required.`),!1}}function h(n,e){const a=n.properties??{},s=new Set;for(const c of n.required??[]){const b=a[c]?.requiredWhen;(!b||v(b,e))&&s.add(c)}for(const[c,b]of Object.entries(a))b.requiredWhen&&v(b.requiredWhen,e)&&s.add(c);const i=[...s].filter(c=>x(e[c]));return{missing:i,complete:i.length===0}}function R(n){const e={};for(const[a,s]of Object.entries(n.properties??{}))e[a]={type:s.type,...s.description!=null&&{description:s.description},...s.enum&&{enum:s.enum},...s.default!==void 0&&{default:s.default}};return{type:"object",properties:e,required:[]}}function A(n){const{name:e,description:a,schema:s}=n;if(!T.test(e))throw new Error(`Invalid form collector name "${e}": must match ${T} (it becomes the update_/submit_ function names).`);const i=typeof n.submit=="string"?n.submit?{via:"client",url:n.submit}:!1:n.submit??!1;n.autoSubmit===!0&&!i&&C.logger.warn(`FormCollector "${e}": autoSubmit is ignored because no submit target is configured.`);const c=(n.autoSubmit??!0)&&!!i,b=s.properties??{},m=t=>{const r={};for(const[u,o]of Object.entries(t)){const l=b[u];if(l)if(o==null)r[u]=o;else if(l.type==="number"||l.type==="integer"){const d=typeof o=="number"?o:Number(o);r[u]=Number.isNaN(d)?o:d}else l.type==="boolean"?r[u]=typeof o=="boolean"?o:o==="true"?!0:o==="false"?!1:!!o:r[u]=o}return r},S=n.initialValues??{},f=W({values:S,submitted:!1}),$=t=>{const r=f.get(),u={...r,values:{...r.values,...t}};return f.set(u),u};let g=null;const F=(t,r)=>{g?.emitFormEvent("form:error",{name:e,values:t,error:r})};let y=null;const I=async()=>{const{values:t}=f.get(),{complete:r,missing:u}=h(s,t);if(!r)return{ok:!1,missing:u};if(!i)return{ok:!1,error:"No submit target configured for this form collector."};const o=t;try{let l;if(i.via==="client")if("handler"in i)l=await i.handler(o);else{const d=await fetch(i.url,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(o)});if(!d.ok){const j=`Submit failed: HTTP ${d.status}`;return F(o,j),{ok:!1,error:j}}l=await d.json().catch(()=>{})}else{if(!g)return{ok:!1,error:"Backend submit requires install(client) (or useFormCollector) first."};l=await g.submitFormCollector(e,o)}return f.set({...f.get(),submitted:!0,submitResult:l}),g?.emitFormEvent("form:submitted",{name:e,values:o,result:l}),{ok:!0,result:l}}catch(l){const d=l instanceof Error?l.message:"Submit failed";return C.logger.error(`FormCollector "${e}" submit failed:`,l),F(o,d),{ok:!1,error:d}}},N=()=>y||(y=(async()=>{try{return await I()}finally{y=null}})(),y),k=async()=>{if(!c||!i)return null;const{values:t,submitted:r}=f.get();return r||!h(s,t).complete?null:N()},O={name:`update_${e}`,description:`Fill or update fields of the "${e}" form. ${a} Pass any subset of fields; call it repeatedly to fill the form as the user provides information. Returns the current values and which required fields are still missing.`,parameters:R(s),handler:async t=>{const r=$(m(t)),{missing:u}=h(s,r.values),o=await k();return o?o.ok?{ok:!0,values:r.values,missing:u,submitted:!0}:{ok:!0,values:r.values,missing:u,submitted:!1,submitError:o.error}:{ok:!0,values:r.values,missing:u}}},p=[O];i&&!c&&p.push({name:`submit_${e}`,description:`Submit the completed "${e}" form. Only call this once every required field is collected and the user has confirmed. If fields are missing it returns them instead of submitting.`,parameters:{type:"object",properties:{}},handler:()=>N()});const V="client__",q=i?`submit_${e}`:null,J=t=>{const r=t.functionName??t.toolName;if(r)return r.startsWith(V)?r.slice(8):r},_=t=>{let r={...S},u=!1;for(const o of t){const l=J(o);l===O.name?o.arguments&&(r={...r,...m(o.arguments)}):q&&l===q&&o.status?.toLowerCase()==="done"&&(u=!0)}f.set({values:r,submitted:u})},w=`form:${e}`,E=()=>{const{values:t,submitted:r}=f.get(),{missing:u,complete:o}=h(s,t),l=i?c?" The form is submitted automatically as soon as every required field is filled, so there is no submit function to call.":` When nothing is missing and the user confirms, call submit_${e}.`:"",d=r?`The "${e}" form has been submitted.`:`You are currently collecting information from the user to fill the "${e}" form.`;return{name:`Form: ${e}`,description:`${d} ${a} Some fields are conditionally required; the requiredWhen field in the schema tells you when each becomes required. The form schema is the following: ${JSON.stringify(s)}. Data collected so far: ${JSON.stringify(t)}. Call update_${e} with any fields the user provides; ask only for what is still missing.${l}`,data:{values:t,missing:u,complete:o,submitted:r}}},P=t=>{_((t.messages??[]).flatMap(r=>r.toolCalls??[]))};return{name:e,store:f,functions:p,contextKey:w,contextProvider:E,install:t=>{g=t;for(const u of p)t.register(u);t.addDynamicContext(w,E);const r=f.subscribe(()=>t.notifyContextChanged());return t.on("conversation:loaded",P),()=>{r();for(const u of p)t.unregisterFunction(u.name);t.removeDynamicContext(w),t.off("conversation:loaded",P),g===t&&(g=null)}},hydrate:_,submit:N,getValues:()=>f.get().values,setValues:t=>{$(m(t)),k()},reset:()=>{f.set({values:S,submitted:!1})},getStatus:()=>h(s,f.get().values)}}async function B(n,e){const a=await n.getFormCollector(e.name);return A({name:a.name,description:e.description??a.description,schema:e.schema??a.schema,submit:e.submit??a.submit,initialValues:e.initialValues,autoSubmit:e.autoSubmit??a.autoSubmit})}Object.defineProperty(exports,"createFormCollector",{enumerable:!0,get:function(){return A}});Object.defineProperty(exports,"createStore",{enumerable:!0,get:function(){return W}});Object.defineProperty(exports,"deriveFormStatus",{enumerable:!0,get:function(){return h}});Object.defineProperty(exports,"loadFormCollector",{enumerable:!0,get:function(){return B}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function C(g = {}) {
|
|
2
|
-
const { overrides:
|
|
2
|
+
const { overrides: u = {} } = g, d = {
|
|
3
3
|
id: "mock-msg-1",
|
|
4
4
|
conversationId: "mock-conv-1",
|
|
5
5
|
content: "Mock response",
|
|
@@ -10,7 +10,7 @@ function C(g = {}) {
|
|
|
10
10
|
id: "mock-conv-1",
|
|
11
11
|
title: "Mock Conversation",
|
|
12
12
|
lastMessageDate: /* @__PURE__ */ new Date()
|
|
13
|
-
}, t = /* @__PURE__ */ new Map(),
|
|
13
|
+
}, t = /* @__PURE__ */ new Map(), a = [], m = {
|
|
14
14
|
sendMessage: async () => d,
|
|
15
15
|
getConversations: async () => [l],
|
|
16
16
|
getConversation: async () => l,
|
|
@@ -32,6 +32,8 @@ function C(g = {}) {
|
|
|
32
32
|
},
|
|
33
33
|
registerNavigationFunction: () => {
|
|
34
34
|
},
|
|
35
|
+
unregisterNavigationFunction: () => {
|
|
36
|
+
},
|
|
35
37
|
on: (e, o) => {
|
|
36
38
|
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(o);
|
|
37
39
|
},
|
|
@@ -39,18 +41,18 @@ function C(g = {}) {
|
|
|
39
41
|
t.get(e)?.delete(o);
|
|
40
42
|
},
|
|
41
43
|
once: (e, o) => {
|
|
42
|
-
const
|
|
43
|
-
t.get(e)?.delete(
|
|
44
|
+
const n = (...i) => {
|
|
45
|
+
t.get(e)?.delete(n), o(...i);
|
|
44
46
|
};
|
|
45
|
-
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(
|
|
47
|
+
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(n);
|
|
46
48
|
},
|
|
47
|
-
waitFor: (e, o) => new Promise((
|
|
49
|
+
waitFor: (e, o) => new Promise((n, i) => {
|
|
48
50
|
let r;
|
|
49
51
|
const c = (f) => {
|
|
50
|
-
r && clearTimeout(r), t.get(e)?.delete(c),
|
|
52
|
+
r && clearTimeout(r), t.get(e)?.delete(c), n(f);
|
|
51
53
|
};
|
|
52
54
|
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(c), o?.timeout && (r = setTimeout(() => {
|
|
53
|
-
t.get(e)?.delete(c),
|
|
55
|
+
t.get(e)?.delete(c), i(/* @__PURE__ */ new Error(`waitFor("${e}") timed out after ${o.timeout}ms`));
|
|
54
56
|
}, o.timeout));
|
|
55
57
|
}),
|
|
56
58
|
updateConfig: () => {
|
|
@@ -58,16 +60,16 @@ function C(g = {}) {
|
|
|
58
60
|
destroy: () => {
|
|
59
61
|
t.clear();
|
|
60
62
|
},
|
|
61
|
-
...
|
|
62
|
-
},
|
|
63
|
-
for (const [e, o] of Object.entries(
|
|
63
|
+
...u
|
|
64
|
+
}, s = {};
|
|
65
|
+
for (const [e, o] of Object.entries(m)) s[e] = (...n) => (a.push({
|
|
64
66
|
method: e,
|
|
65
|
-
args:
|
|
66
|
-
}), o(...
|
|
67
|
-
return
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
},
|
|
67
|
+
args: n
|
|
68
|
+
}), o(...n));
|
|
69
|
+
return s.__calls = a, s.__callsFor = (e) => a.filter((o) => o.method === e), s.__emitEvent = (e, o) => {
|
|
70
|
+
const n = t.get(e);
|
|
71
|
+
n && [...n].forEach((i) => i(o));
|
|
72
|
+
}, s;
|
|
71
73
|
}
|
|
72
74
|
export {
|
|
73
75
|
C as t
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function C(g={}){const{overrides:u={}}=g,d={id:"mock-msg-1",conversationId:"mock-conv-1",content:"Mock response",role:"assistant",status:"DONE",createdAt:new Date},l={id:"mock-conv-1",title:"Mock Conversation",lastMessageDate:new Date},t=new Map,r=[],m={sendMessage:async()=>d,getConversations:async()=>[l],getConversation:async()=>l,getMessages:async()=>[d],submitToolCallForm:async()=>{},confirmToolCall:async()=>{},rejectToolCall:async()=>{},submitFeedback:async()=>{},registerFunction:()=>{},unregisterFunction:()=>!0,getRegisteredFunctions:()=>[],getContextSnapshot:()=>null,notifyContextChanged:()=>{},registerNavigationFunction:()=>{},unregisterNavigationFunction:()=>{},on:(e,o)=>{t.has(e)||t.set(e,new Set),t.get(e).add(o)},off:(e,o)=>{t.get(e)?.delete(o)},once:(e,o)=>{const n=(...i)=>{t.get(e)?.delete(n),o(...i)};t.has(e)||t.set(e,new Set),t.get(e).add(n)},waitFor:(e,o)=>new Promise((n,i)=>{let a;const c=f=>{a&&clearTimeout(a),t.get(e)?.delete(c),n(f)};t.has(e)||t.set(e,new Set),t.get(e).add(c),o?.timeout&&(a=setTimeout(()=>{t.get(e)?.delete(c),i(new Error(`waitFor("${e}") timed out after ${o.timeout}ms`))},o.timeout))}),updateConfig:()=>{},destroy:()=>{t.clear()},...u},s={};for(const[e,o]of Object.entries(m))s[e]=(...n)=>(r.push({method:e,args:n}),o(...n));return s.__calls=r,s.__callsFor=e=>r.filter(o=>o.method===e),s.__emitEvent=(e,o)=>{const n=t.get(e);n&&[...n].forEach(i=>i(o))},s}Object.defineProperty(exports,"createMockClient",{enumerable:!0,get:function(){return C}});
|
package/dist/devtools.d.cts
CHANGED
|
@@ -146,6 +146,12 @@ declare class AgoClient {
|
|
|
146
146
|
getRegisteredFunctions(): ClientFunctionSchema[];
|
|
147
147
|
/**
|
|
148
148
|
* Register a navigation function that lets AGO navigate users to different pages.
|
|
149
|
+
*
|
|
150
|
+
* Also registers a dynamic context entry (`current-page`) that reports the page
|
|
151
|
+
* the user is currently on, by route name, on every message. This is what lets
|
|
152
|
+
* the agent know *where* it is after it navigates (e.g. so auto-continuation
|
|
153
|
+
* can apply page state on the destination), not just how to navigate away.
|
|
154
|
+
*
|
|
149
155
|
* @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
|
|
150
156
|
* @param routes - Map of route names to paths, with descriptions for the LLM
|
|
151
157
|
*/
|
|
@@ -154,6 +160,41 @@ declare class AgoClient {
|
|
|
154
160
|
path: string;
|
|
155
161
|
description: string;
|
|
156
162
|
}>): void;
|
|
163
|
+
/**
|
|
164
|
+
* Unregister the navigation function and its `current-page` context provider.
|
|
165
|
+
*/
|
|
166
|
+
unregisterNavigationFunction(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Register a "page state" function that lets AGO change the current page's
|
|
169
|
+
* state (filters, sort, view mode, selection…) and reads the current state
|
|
170
|
+
* back as dynamic context. This is the state-mutation mirror of
|
|
171
|
+
* {@link registerNavigationFunction}.
|
|
172
|
+
*
|
|
173
|
+
* It does two things:
|
|
174
|
+
* - Synthesizes ONE client function (default name `setPageState`) whose
|
|
175
|
+
* properties are the controls — all optional, so the agent sets only the
|
|
176
|
+
* ones the user asked for.
|
|
177
|
+
* - Registers a dynamic context provider (keyed `page-state:<fnName>`) that
|
|
178
|
+
* reports each control's current `get()` value on every message.
|
|
179
|
+
*
|
|
180
|
+
* ```ts
|
|
181
|
+
* client.registerPageStateFunction([
|
|
182
|
+
* {
|
|
183
|
+
* name: "statusFilter",
|
|
184
|
+
* description: "Filter the list by review status",
|
|
185
|
+
* schema: { type: "string", enum: ["all", "pending", "approved"] },
|
|
186
|
+
* get: () => filters.status,
|
|
187
|
+
* set: (v) => setFilters({ ...filters, status: v }),
|
|
188
|
+
* },
|
|
189
|
+
* ]);
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
registerPageStateFunction(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
|
|
193
|
+
/**
|
|
194
|
+
* Unregister a page state function and its dynamic context provider.
|
|
195
|
+
* Mirror of unregistering `navigateToPage`.
|
|
196
|
+
*/
|
|
197
|
+
unregisterPageStateFunction(functionName?: string): void;
|
|
157
198
|
/**
|
|
158
199
|
* Register or update a piece of client-side context.
|
|
159
200
|
* This context is sent with every message so the AI understands the user's situation.
|
|
@@ -386,9 +427,23 @@ declare interface AgoMessage {
|
|
|
386
427
|
followUpReplies?: string[];
|
|
387
428
|
/** Uploaded files on this message (usually the user's). */
|
|
388
429
|
attachments?: AgoAttachment[];
|
|
430
|
+
/**
|
|
431
|
+
* True when the backend flagged this message as hidden (e.g. an
|
|
432
|
+
* auto-continuation nudge). Kept in the model's context but not displayed;
|
|
433
|
+
* UI helpers like `useMessages`/`ChatWidget` filter these out.
|
|
434
|
+
*/
|
|
435
|
+
hidden?: boolean;
|
|
389
436
|
createdAt: Date;
|
|
390
437
|
}
|
|
391
438
|
|
|
439
|
+
/**
|
|
440
|
+
* Options for {@link AgoClient.registerPageStateFunction}.
|
|
441
|
+
*/
|
|
442
|
+
declare interface AgoPageStateOptions {
|
|
443
|
+
/** Name of the synthesized client function. Defaults to "setPageState". */
|
|
444
|
+
functionName?: string;
|
|
445
|
+
}
|
|
446
|
+
|
|
392
447
|
/**
|
|
393
448
|
* Knowledge source citation
|
|
394
449
|
*/
|
|
@@ -398,6 +453,32 @@ declare interface AgoSource {
|
|
|
398
453
|
url?: string;
|
|
399
454
|
}
|
|
400
455
|
|
|
456
|
+
/**
|
|
457
|
+
* A single editable control on the current page (a filter, a sort, a view mode,
|
|
458
|
+
* a selection…). It becomes one optional property of the synthesized
|
|
459
|
+
* `setPageState` function, and its current value is surfaced back to the agent
|
|
460
|
+
* as dynamic context. This is the state-mutation mirror of a navigation route.
|
|
461
|
+
*/
|
|
462
|
+
declare interface AgoStateControl<T = unknown> {
|
|
463
|
+
/** Machine name of the control, e.g. "statusFilter". Becomes a property of the tool. */
|
|
464
|
+
name: string;
|
|
465
|
+
/** Description for the LLM, e.g. "Filter the list by review status". */
|
|
466
|
+
description: string;
|
|
467
|
+
/** JSON schema for a SINGLE field (like one property of navigateToPage). */
|
|
468
|
+
schema: {
|
|
469
|
+
type: "string" | "number" | "boolean" | "array";
|
|
470
|
+
enum?: (string | number)[];
|
|
471
|
+
items?: {
|
|
472
|
+
type: string;
|
|
473
|
+
enum?: (string | number)[];
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
/** Current value → pushed as dynamic context so the agent knows what to change. */
|
|
477
|
+
get?: () => T;
|
|
478
|
+
/** Apply the state change on the page. May be async. */
|
|
479
|
+
set: (value: T) => void | Promise<void>;
|
|
480
|
+
}
|
|
481
|
+
|
|
401
482
|
/**
|
|
402
483
|
* Single-object function definition — combines name, schema, and handler.
|
|
403
484
|
*
|
|
@@ -444,7 +525,11 @@ declare interface ClientFunctionSchema {
|
|
|
444
525
|
properties: Record<string, {
|
|
445
526
|
type: string;
|
|
446
527
|
description?: string;
|
|
447
|
-
enum?: string[];
|
|
528
|
+
enum?: (string | number)[];
|
|
529
|
+
items?: {
|
|
530
|
+
type: string;
|
|
531
|
+
enum?: (string | number)[];
|
|
532
|
+
};
|
|
448
533
|
default?: unknown;
|
|
449
534
|
}>;
|
|
450
535
|
required?: string[];
|
|
@@ -621,6 +706,13 @@ declare interface SendMessageOptions {
|
|
|
621
706
|
agentId?: string;
|
|
622
707
|
/** File attachments */
|
|
623
708
|
files?: File[];
|
|
709
|
+
/**
|
|
710
|
+
* Mark this message as hidden. The backend keeps it in the model's context but
|
|
711
|
+
* flags it so the UI never displays it. Used by auto-continuation to nudge the
|
|
712
|
+
* agent after a navigation without polluting the visible transcript.
|
|
713
|
+
* Requires backend support for the `hidden` flag; older backends ignore it.
|
|
714
|
+
*/
|
|
715
|
+
hidden?: boolean;
|
|
624
716
|
}
|
|
625
717
|
|
|
626
718
|
/**
|