@useago/sdk 1.4.4 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -1
- package/dist/AgoClient-5VGybmvz.cjs +8 -0
- package/dist/AgoClient-DXrH2AMi.js +964 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +124 -5
- package/dist/angular.d.ts +124 -5
- package/dist/angular.js +5 -1
- package/dist/autoContinue-CC8K9mBU.js +63 -0
- package/dist/autoContinue-CP9pJR-V.cjs +1 -0
- package/dist/{createConversationSession-CUkNp6mZ.cjs → createConversationSession-0WTqcCLK.cjs} +1 -1
- package/dist/{createConversationSession-QIBN0gLx.js → createConversationSession-DPrrr70o.js} +1 -1
- package/dist/createFormCollector-1GKKwQV_.cjs +1 -0
- package/dist/{createFormCollector-F3YJfsbg.js → createFormCollector-DYh90kiG.js} +97 -91
- package/dist/devtools.d.cts +82 -5
- package/dist/devtools.d.ts +82 -5
- package/dist/functions-CPs7omgM.cjs +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.d.cts +5 -0
- package/dist/helpers.d.ts +5 -0
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +147 -7
- package/dist/index.d.ts +147 -7
- package/dist/index.js +45 -43
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +191 -21
- package/dist/react.d.ts +191 -21
- package/dist/react.js +666 -529
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +82 -5
- package/dist/testing.d.ts +82 -5
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +82 -5
- package/dist/vue.d.ts +82 -5
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +82 -5
- package/dist/widget.d.ts +82 -5
- package/dist/widget.js +437 -423
- package/llms-full.txt +100 -6
- package/package.json +1 -1
- package/dist/AgoClient-CLmtYTJx.cjs +0 -8
- package/dist/AgoClient-Ozz2b1dQ.js +0 -912
- package/dist/createFormCollector-DHT1ObOb.cjs +0 -1
- package/dist/functions-Djnq-JAo.cjs +0 -1
- package/dist/rolldown-runtime-16Nf8qvH.cjs +0 -1
- /package/dist/{createMockClient-BSr-UV8R.cjs → createMockClient-C-wrjb2C.cjs} +0 -0
- /package/dist/{createMockClient-bAZ9KBHC.js → createMockClient-we-XoPom.js} +0 -0
- /package/dist/{functions-CApuQZ2b.js → functions-tzyOZNp6.js} +0 -0
package/dist/testing.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./createMockClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./createMockClient-C-wrjb2C.cjs");exports.createMockClient=e.createMockClient;
|
package/dist/testing.d.cts
CHANGED
|
@@ -41,6 +41,12 @@ declare class AgoClient {
|
|
|
41
41
|
private warnedEmptyConversations;
|
|
42
42
|
/** Paused turns awaiting auto-resume, keyed by assistant message id. */
|
|
43
43
|
private pendingResumes;
|
|
44
|
+
/**
|
|
45
|
+
* Client function invocations held pending user approval, keyed by
|
|
46
|
+
* invocationId (the tool-call id). Populated when {@link requiresApproval}
|
|
47
|
+
* matches; drained by {@link approveFunction} / {@link rejectFunction}.
|
|
48
|
+
*/
|
|
49
|
+
private pendingApprovals;
|
|
44
50
|
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
45
51
|
private resumeGate;
|
|
46
52
|
constructor(config: AgoConfig);
|
|
@@ -91,6 +97,24 @@ declare class AgoClient {
|
|
|
91
97
|
*/
|
|
92
98
|
private maybeFlagEmptyReply;
|
|
93
99
|
private handleClientFunctionInvocation;
|
|
100
|
+
/**
|
|
101
|
+
* Whether a client function invocation must wait for explicit user approval.
|
|
102
|
+
* True when the {@link AgoConfig.approvalPolicy} returns true OR the function
|
|
103
|
+
* was registered with `requiresApproval: true` — the two OR together.
|
|
104
|
+
*/
|
|
105
|
+
private requiresApproval;
|
|
106
|
+
/**
|
|
107
|
+
* Approve a client function call held by the approval gate: run it, submit its
|
|
108
|
+
* result, and let the paused turn resume. No-op if the invocation is unknown
|
|
109
|
+
* (already handled, or never gated).
|
|
110
|
+
*/
|
|
111
|
+
approveFunction(invocationId: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Reject a client function call held by the approval gate: submit a rejection
|
|
114
|
+
* result so the agent sees the user declined, and let the paused turn resume
|
|
115
|
+
* (the agent decides what to do next). No-op if the invocation is unknown.
|
|
116
|
+
*/
|
|
117
|
+
rejectFunction(invocationId: string): Promise<void>;
|
|
94
118
|
/**
|
|
95
119
|
* Get list of conversations
|
|
96
120
|
*/
|
|
@@ -120,8 +144,10 @@ declare class AgoClient {
|
|
|
120
144
|
*
|
|
121
145
|
* Opt-in on purpose — re-running functions on reload can be surprising (e.g. a
|
|
122
146
|
* navigation function would navigate again), so the app decides. Returns the
|
|
123
|
-
* resumed turn's final message, or `null` when there was nothing to resume
|
|
124
|
-
* some waiting function is not registered on this page
|
|
147
|
+
* resumed turn's final message, or `null` when there was nothing to resume,
|
|
148
|
+
* some waiting function is not registered on this page, or a waiting call is
|
|
149
|
+
* gated by the approval policy (it is held for `approveFunction` /
|
|
150
|
+
* `rejectFunction` and the turn stays paused, exactly as on the live stream).
|
|
125
151
|
*/
|
|
126
152
|
resumePendingClientFunctions(conversation: Conversation): Promise<AgoMessage | null>;
|
|
127
153
|
/**
|
|
@@ -416,6 +442,15 @@ declare interface AgoClientEvents {
|
|
|
416
442
|
"toolCall:received": ToolCallData;
|
|
417
443
|
"toolCall:form": ToolCallData;
|
|
418
444
|
"function:invoke": ClientFunctionInvocation;
|
|
445
|
+
/**
|
|
446
|
+
* A client function call is held pending the user's approval (pause mode +
|
|
447
|
+
* an {@link AgoConfig.approvalPolicy}/`requiresApproval` match). The turn stays
|
|
448
|
+
* at `WAITING_CLIENT`; call `approveFunction(invocationId)` to run it and
|
|
449
|
+
* resume, or `rejectFunction(invocationId)` to decline. Fires after
|
|
450
|
+
* `function:invoke` (which still fires for every call) and instead of the
|
|
451
|
+
* call running immediately.
|
|
452
|
+
*/
|
|
453
|
+
"function:awaiting-approval": ClientFunctionInvocation;
|
|
419
454
|
"function:result": {
|
|
420
455
|
invocationId: string;
|
|
421
456
|
result: unknown;
|
|
@@ -476,14 +511,28 @@ declare interface AgoConfig {
|
|
|
476
511
|
warnOnEmptyReply?: boolean;
|
|
477
512
|
/**
|
|
478
513
|
* How the agent loop treats client function calls (requires backend support):
|
|
479
|
-
* - `"
|
|
480
|
-
* result; the real result is only visible to the agent on later turns.
|
|
481
|
-
* - `"pause"`: the turn stops on client function call(s) with status
|
|
514
|
+
* - `"pause"` (default): the turn stops on client function call(s) with status
|
|
482
515
|
* `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
|
|
483
516
|
* turn via `POST /messages/{id}/continue`, so the agent sees the real results.
|
|
517
|
+
* - `"placeholder"` (legacy): the turn continues immediately on a placeholder
|
|
518
|
+
* result; the real result is only visible to the agent on later turns.
|
|
484
519
|
* Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
|
|
485
520
|
*/
|
|
486
521
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
522
|
+
/**
|
|
523
|
+
* Gate client function calls behind explicit user approval. Return `true` for
|
|
524
|
+
* an invocation the user must approve/reject before it runs; return `false`
|
|
525
|
+
* (or omit the policy) to let it run immediately as before.
|
|
526
|
+
*
|
|
527
|
+
* Only effective in pause mode (`clientFunctionsMode: "pause"`) — a gated call
|
|
528
|
+
* holds at `WAITING_CLIENT`, the SDK emits `function:awaiting-approval`, and it
|
|
529
|
+
* runs (and the turn resumes) only after `approveFunction(invocationId)`; a
|
|
530
|
+
* `rejectFunction(invocationId)` submits a rejection so the agent sees the
|
|
531
|
+
* decline. In placeholder mode there is no pause to hold, so the policy is a
|
|
532
|
+
* no-op and the call runs normally. A per-function `requiresApproval: true`
|
|
533
|
+
* also gates a call; the policy and the flag OR together.
|
|
534
|
+
*/
|
|
535
|
+
approvalPolicy?: (invocation: ClientFunctionInvocation) => boolean;
|
|
487
536
|
/**
|
|
488
537
|
* Max serialized size (bytes) of a client function result before the SDK
|
|
489
538
|
* replaces it with a flagged, truncated preview. Everything a handler
|
|
@@ -528,6 +577,11 @@ declare interface AgoMessage {
|
|
|
528
577
|
declare interface AgoPageStateOptions {
|
|
529
578
|
/** Name of the synthesized client function. Defaults to "setPageState". */
|
|
530
579
|
functionName?: string;
|
|
580
|
+
/**
|
|
581
|
+
* Require explicit user approval before this state change runs. See
|
|
582
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. Defaults to `false`.
|
|
583
|
+
*/
|
|
584
|
+
requiresApproval?: boolean;
|
|
531
585
|
}
|
|
532
586
|
|
|
533
587
|
/**
|
|
@@ -589,6 +643,11 @@ declare interface ClientFunctionDefinition {
|
|
|
589
643
|
* `Infinity` disables the guard for this function.
|
|
590
644
|
*/
|
|
591
645
|
maxResultBytes?: number;
|
|
646
|
+
/**
|
|
647
|
+
* Require explicit user approval before this function runs. See
|
|
648
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
649
|
+
*/
|
|
650
|
+
requiresApproval?: boolean;
|
|
592
651
|
}
|
|
593
652
|
|
|
594
653
|
/**
|
|
@@ -615,6 +674,11 @@ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name">
|
|
|
615
674
|
* disables the guard for this function.
|
|
616
675
|
*/
|
|
617
676
|
maxResultBytes?: number;
|
|
677
|
+
/**
|
|
678
|
+
* Require explicit user approval before this function runs. See
|
|
679
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
680
|
+
*/
|
|
681
|
+
requiresApproval?: boolean;
|
|
618
682
|
};
|
|
619
683
|
|
|
620
684
|
/**
|
|
@@ -655,6 +719,19 @@ declare interface ContextEntry {
|
|
|
655
719
|
description?: string;
|
|
656
720
|
/** Arbitrary structured data the AI should know about */
|
|
657
721
|
data?: Record<string, unknown>;
|
|
722
|
+
/**
|
|
723
|
+
* Marks the entry as constant for the whole conversation. The backend then
|
|
724
|
+
* pins it right after the system prompt, where LLM providers cache it across
|
|
725
|
+
* turns, instead of re-processing it next to every new user message.
|
|
726
|
+
*
|
|
727
|
+
* Only set this when the entry's content is byte-identical on every message
|
|
728
|
+
* of a conversation (a schema, a capability list, static instructions). A
|
|
729
|
+
* stable entry that changes between messages invalidates the provider's
|
|
730
|
+
* cache for the entire conversation history, which costs more than leaving
|
|
731
|
+
* the flag off. Default: `false` (re-sent near the newest user message).
|
|
732
|
+
* Backends that don't know the flag ignore it.
|
|
733
|
+
*/
|
|
734
|
+
stable?: boolean;
|
|
658
735
|
}
|
|
659
736
|
|
|
660
737
|
/**
|
package/dist/testing.d.ts
CHANGED
|
@@ -41,6 +41,12 @@ declare class AgoClient {
|
|
|
41
41
|
private warnedEmptyConversations;
|
|
42
42
|
/** Paused turns awaiting auto-resume, keyed by assistant message id. */
|
|
43
43
|
private pendingResumes;
|
|
44
|
+
/**
|
|
45
|
+
* Client function invocations held pending user approval, keyed by
|
|
46
|
+
* invocationId (the tool-call id). Populated when {@link requiresApproval}
|
|
47
|
+
* matches; drained by {@link approveFunction} / {@link rejectFunction}.
|
|
48
|
+
*/
|
|
49
|
+
private pendingApprovals;
|
|
44
50
|
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
45
51
|
private resumeGate;
|
|
46
52
|
constructor(config: AgoConfig);
|
|
@@ -91,6 +97,24 @@ declare class AgoClient {
|
|
|
91
97
|
*/
|
|
92
98
|
private maybeFlagEmptyReply;
|
|
93
99
|
private handleClientFunctionInvocation;
|
|
100
|
+
/**
|
|
101
|
+
* Whether a client function invocation must wait for explicit user approval.
|
|
102
|
+
* True when the {@link AgoConfig.approvalPolicy} returns true OR the function
|
|
103
|
+
* was registered with `requiresApproval: true` — the two OR together.
|
|
104
|
+
*/
|
|
105
|
+
private requiresApproval;
|
|
106
|
+
/**
|
|
107
|
+
* Approve a client function call held by the approval gate: run it, submit its
|
|
108
|
+
* result, and let the paused turn resume. No-op if the invocation is unknown
|
|
109
|
+
* (already handled, or never gated).
|
|
110
|
+
*/
|
|
111
|
+
approveFunction(invocationId: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Reject a client function call held by the approval gate: submit a rejection
|
|
114
|
+
* result so the agent sees the user declined, and let the paused turn resume
|
|
115
|
+
* (the agent decides what to do next). No-op if the invocation is unknown.
|
|
116
|
+
*/
|
|
117
|
+
rejectFunction(invocationId: string): Promise<void>;
|
|
94
118
|
/**
|
|
95
119
|
* Get list of conversations
|
|
96
120
|
*/
|
|
@@ -120,8 +144,10 @@ declare class AgoClient {
|
|
|
120
144
|
*
|
|
121
145
|
* Opt-in on purpose — re-running functions on reload can be surprising (e.g. a
|
|
122
146
|
* navigation function would navigate again), so the app decides. Returns the
|
|
123
|
-
* resumed turn's final message, or `null` when there was nothing to resume
|
|
124
|
-
* some waiting function is not registered on this page
|
|
147
|
+
* resumed turn's final message, or `null` when there was nothing to resume,
|
|
148
|
+
* some waiting function is not registered on this page, or a waiting call is
|
|
149
|
+
* gated by the approval policy (it is held for `approveFunction` /
|
|
150
|
+
* `rejectFunction` and the turn stays paused, exactly as on the live stream).
|
|
125
151
|
*/
|
|
126
152
|
resumePendingClientFunctions(conversation: Conversation): Promise<AgoMessage | null>;
|
|
127
153
|
/**
|
|
@@ -416,6 +442,15 @@ declare interface AgoClientEvents {
|
|
|
416
442
|
"toolCall:received": ToolCallData;
|
|
417
443
|
"toolCall:form": ToolCallData;
|
|
418
444
|
"function:invoke": ClientFunctionInvocation;
|
|
445
|
+
/**
|
|
446
|
+
* A client function call is held pending the user's approval (pause mode +
|
|
447
|
+
* an {@link AgoConfig.approvalPolicy}/`requiresApproval` match). The turn stays
|
|
448
|
+
* at `WAITING_CLIENT`; call `approveFunction(invocationId)` to run it and
|
|
449
|
+
* resume, or `rejectFunction(invocationId)` to decline. Fires after
|
|
450
|
+
* `function:invoke` (which still fires for every call) and instead of the
|
|
451
|
+
* call running immediately.
|
|
452
|
+
*/
|
|
453
|
+
"function:awaiting-approval": ClientFunctionInvocation;
|
|
419
454
|
"function:result": {
|
|
420
455
|
invocationId: string;
|
|
421
456
|
result: unknown;
|
|
@@ -476,14 +511,28 @@ declare interface AgoConfig {
|
|
|
476
511
|
warnOnEmptyReply?: boolean;
|
|
477
512
|
/**
|
|
478
513
|
* How the agent loop treats client function calls (requires backend support):
|
|
479
|
-
* - `"
|
|
480
|
-
* result; the real result is only visible to the agent on later turns.
|
|
481
|
-
* - `"pause"`: the turn stops on client function call(s) with status
|
|
514
|
+
* - `"pause"` (default): the turn stops on client function call(s) with status
|
|
482
515
|
* `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
|
|
483
516
|
* turn via `POST /messages/{id}/continue`, so the agent sees the real results.
|
|
517
|
+
* - `"placeholder"` (legacy): the turn continues immediately on a placeholder
|
|
518
|
+
* result; the real result is only visible to the agent on later turns.
|
|
484
519
|
* Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
|
|
485
520
|
*/
|
|
486
521
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
522
|
+
/**
|
|
523
|
+
* Gate client function calls behind explicit user approval. Return `true` for
|
|
524
|
+
* an invocation the user must approve/reject before it runs; return `false`
|
|
525
|
+
* (or omit the policy) to let it run immediately as before.
|
|
526
|
+
*
|
|
527
|
+
* Only effective in pause mode (`clientFunctionsMode: "pause"`) — a gated call
|
|
528
|
+
* holds at `WAITING_CLIENT`, the SDK emits `function:awaiting-approval`, and it
|
|
529
|
+
* runs (and the turn resumes) only after `approveFunction(invocationId)`; a
|
|
530
|
+
* `rejectFunction(invocationId)` submits a rejection so the agent sees the
|
|
531
|
+
* decline. In placeholder mode there is no pause to hold, so the policy is a
|
|
532
|
+
* no-op and the call runs normally. A per-function `requiresApproval: true`
|
|
533
|
+
* also gates a call; the policy and the flag OR together.
|
|
534
|
+
*/
|
|
535
|
+
approvalPolicy?: (invocation: ClientFunctionInvocation) => boolean;
|
|
487
536
|
/**
|
|
488
537
|
* Max serialized size (bytes) of a client function result before the SDK
|
|
489
538
|
* replaces it with a flagged, truncated preview. Everything a handler
|
|
@@ -528,6 +577,11 @@ declare interface AgoMessage {
|
|
|
528
577
|
declare interface AgoPageStateOptions {
|
|
529
578
|
/** Name of the synthesized client function. Defaults to "setPageState". */
|
|
530
579
|
functionName?: string;
|
|
580
|
+
/**
|
|
581
|
+
* Require explicit user approval before this state change runs. See
|
|
582
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. Defaults to `false`.
|
|
583
|
+
*/
|
|
584
|
+
requiresApproval?: boolean;
|
|
531
585
|
}
|
|
532
586
|
|
|
533
587
|
/**
|
|
@@ -589,6 +643,11 @@ declare interface ClientFunctionDefinition {
|
|
|
589
643
|
* `Infinity` disables the guard for this function.
|
|
590
644
|
*/
|
|
591
645
|
maxResultBytes?: number;
|
|
646
|
+
/**
|
|
647
|
+
* Require explicit user approval before this function runs. See
|
|
648
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
649
|
+
*/
|
|
650
|
+
requiresApproval?: boolean;
|
|
592
651
|
}
|
|
593
652
|
|
|
594
653
|
/**
|
|
@@ -615,6 +674,11 @@ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name">
|
|
|
615
674
|
* disables the guard for this function.
|
|
616
675
|
*/
|
|
617
676
|
maxResultBytes?: number;
|
|
677
|
+
/**
|
|
678
|
+
* Require explicit user approval before this function runs. See
|
|
679
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
680
|
+
*/
|
|
681
|
+
requiresApproval?: boolean;
|
|
618
682
|
};
|
|
619
683
|
|
|
620
684
|
/**
|
|
@@ -655,6 +719,19 @@ declare interface ContextEntry {
|
|
|
655
719
|
description?: string;
|
|
656
720
|
/** Arbitrary structured data the AI should know about */
|
|
657
721
|
data?: Record<string, unknown>;
|
|
722
|
+
/**
|
|
723
|
+
* Marks the entry as constant for the whole conversation. The backend then
|
|
724
|
+
* pins it right after the system prompt, where LLM providers cache it across
|
|
725
|
+
* turns, instead of re-processing it next to every new user message.
|
|
726
|
+
*
|
|
727
|
+
* Only set this when the entry's content is byte-identical on every message
|
|
728
|
+
* of a conversation (a schema, a capability list, static instructions). A
|
|
729
|
+
* stable entry that changes between messages invalidates the provider's
|
|
730
|
+
* cache for the entire conversation history, which costs more than leaving
|
|
731
|
+
* the flag off. Default: `false` (re-sent near the newest user message).
|
|
732
|
+
* Backends that don't know the flag ignore it.
|
|
733
|
+
*/
|
|
734
|
+
stable?: boolean;
|
|
658
735
|
}
|
|
659
736
|
|
|
660
737
|
/**
|
package/dist/testing.js
CHANGED
package/dist/vue.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./AgoClient-5VGybmvz.cjs");let o=require("vue");var w=Symbol("ago-client"),S={install(t,n){const e=new E.AgoClient(n);t.provide(w,e)}};function d(t){if(t)return new E.AgoClient(t);const n=(0,o.inject)(w);if(!n)throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");return n}function M(t={}){const n=t.client??d(),e=(0,o.ref)([]),s=(0,o.ref)(t.conversationId),u=(0,o.ref)(!1),r=(0,o.ref)(null),c=a=>{s.value||(s.value=a.conversationId)},f=a=>{const i=e.value.findIndex(v=>v.id===a.messageId);i>=0&&(e.value[i]={...e.value[i],content:e.value[i].content+a.content})},m=a=>{const i=e.value.findIndex(v=>v.id===a.id);i>=0?e.value[i]=a:e.value.push(a),u.value=!1},C=a=>{r.value=new Error(a.error),u.value=!1};(0,o.onMounted)(()=>{n.on("message:start",c),n.on("message:chunk",f),n.on("message:complete",m),n.on("message:error",C)}),(0,o.onUnmounted)(()=>{n.off("message:start",c),n.off("message:chunk",f),n.off("message:complete",m),n.off("message:error",C)});async function g(a,i){u.value=!0,r.value=null;const v={id:`temp-${Date.now()}`,conversationId:s.value||"",content:a,role:"user",status:"DONE",createdAt:new Date},N={id:`temp-assistant-${Date.now()}`,conversationId:s.value||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};e.value.push(v,N);try{const l=await n.sendMessage(a,{conversationId:s.value,files:i});l.conversationId&&!s.value&&(s.value=l.conversationId),e.value=e.value.filter(I=>!I.id.startsWith("temp-"));const A={...v,id:v.id.replace("temp-","user-"),conversationId:l.conversationId};return e.value.some(I=>I.id===l.id)?e.value.push(A):e.value.push(A,l),l}catch(l){return r.value=l instanceof Error?l:new Error("Failed to send"),u.value=!1,e.value=e.value.filter(A=>!A.id.startsWith("temp-")),null}}function h(){e.value=[],s.value=void 0,r.value=null}return{messages:e,isLoading:u,error:r,conversationId:s,sendMessage:g,clearMessages:h}}function p(t={}){const n=t.client??d(),e=t.autoLoad??!0,s=(0,o.ref)([]),u=(0,o.ref)(null),r=(0,o.ref)(!1),c=(0,o.ref)(null);async function f(){r.value=!0,c.value=null;try{s.value=await n.getConversations()}catch(g){c.value=g instanceof Error?g:new Error("Failed to load conversations")}finally{r.value=!1}}async function m(g){r.value=!0,c.value=null;try{u.value=await n.getConversation(g)}catch(h){c.value=h instanceof Error?h:new Error("Failed to load conversation")}finally{r.value=!1}}function C(){u.value=null}return(0,o.onMounted)(()=>{e&&f()}),{conversations:s,currentConversation:u,isLoading:r,error:c,selectConversation:m,startNewConversation:C,refreshConversations:f}}function y(t={}){const n=M({client:t.client,conversationId:t.conversationId}),e=p({client:t.client,autoLoad:t.autoLoad}),s=(0,o.computed)(()=>n.error.value||e.error.value);return{messages:n.messages,isLoading:n.isLoading,error:s,sendMessage:n.sendMessage,clearMessages:n.clearMessages,conversationId:n.conversationId,conversations:e.conversations,currentConversation:e.currentConversation,isConversationsLoading:e.isLoading,selectConversation:e.selectConversation,startNewConversation:e.startNewConversation,refreshConversations:e.refreshConversations}}function L(t,n){const e=d();(0,o.onMounted)(()=>{e.registerFunction(t,n.handler,{description:n.description,parameters:n.parameters,maxResultBytes:n.maxResultBytes})}),(0,o.onUnmounted)(()=>{e.unregisterFunction(t)})}function F(t,n){const e=d();(0,o.onMounted)(()=>{e.registerNavigationFunction(t,n)}),(0,o.onUnmounted)(()=>{e.unregisterNavigationFunction()})}function P(t,n){const e=d(),s=n?.functionName??"setPageState";(0,o.onMounted)(()=>{e.registerPageStateFunction(t,{functionName:s})}),(0,o.onUnmounted)(()=>{e.unregisterPageStateFunction(s)})}function R(t,n){const e=d();(0,o.onMounted)(()=>{e.on(t,n)}),(0,o.onUnmounted)(()=>{e.off(t,n)})}function x(t){const n=(0,o.shallowRef)(t.get());return(0,o.onScopeDispose)(t.subscribe(e=>{n.value=e})),n}exports.AGO_CLIENT_KEY=w;exports.AgoPlugin=S;exports.useAgo=d;exports.useAgoEvents=R;exports.useAgoFunction=L;exports.useAgoNavigation=F;exports.useAgoPageState=P;exports.useAgoStore=x;exports.useChat=y;exports.useConversation=p;exports.useMessages=M;
|
package/dist/vue.d.cts
CHANGED
|
@@ -49,6 +49,12 @@ declare class AgoClient {
|
|
|
49
49
|
private warnedEmptyConversations;
|
|
50
50
|
/** Paused turns awaiting auto-resume, keyed by assistant message id. */
|
|
51
51
|
private pendingResumes;
|
|
52
|
+
/**
|
|
53
|
+
* Client function invocations held pending user approval, keyed by
|
|
54
|
+
* invocationId (the tool-call id). Populated when {@link requiresApproval}
|
|
55
|
+
* matches; drained by {@link approveFunction} / {@link rejectFunction}.
|
|
56
|
+
*/
|
|
57
|
+
private pendingApprovals;
|
|
52
58
|
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
53
59
|
private resumeGate;
|
|
54
60
|
constructor(config: AgoConfig);
|
|
@@ -99,6 +105,24 @@ declare class AgoClient {
|
|
|
99
105
|
*/
|
|
100
106
|
private maybeFlagEmptyReply;
|
|
101
107
|
private handleClientFunctionInvocation;
|
|
108
|
+
/**
|
|
109
|
+
* Whether a client function invocation must wait for explicit user approval.
|
|
110
|
+
* True when the {@link AgoConfig.approvalPolicy} returns true OR the function
|
|
111
|
+
* was registered with `requiresApproval: true` — the two OR together.
|
|
112
|
+
*/
|
|
113
|
+
private requiresApproval;
|
|
114
|
+
/**
|
|
115
|
+
* Approve a client function call held by the approval gate: run it, submit its
|
|
116
|
+
* result, and let the paused turn resume. No-op if the invocation is unknown
|
|
117
|
+
* (already handled, or never gated).
|
|
118
|
+
*/
|
|
119
|
+
approveFunction(invocationId: string): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Reject a client function call held by the approval gate: submit a rejection
|
|
122
|
+
* result so the agent sees the user declined, and let the paused turn resume
|
|
123
|
+
* (the agent decides what to do next). No-op if the invocation is unknown.
|
|
124
|
+
*/
|
|
125
|
+
rejectFunction(invocationId: string): Promise<void>;
|
|
102
126
|
/**
|
|
103
127
|
* Get list of conversations
|
|
104
128
|
*/
|
|
@@ -128,8 +152,10 @@ declare class AgoClient {
|
|
|
128
152
|
*
|
|
129
153
|
* Opt-in on purpose — re-running functions on reload can be surprising (e.g. a
|
|
130
154
|
* navigation function would navigate again), so the app decides. Returns the
|
|
131
|
-
* resumed turn's final message, or `null` when there was nothing to resume
|
|
132
|
-
* some waiting function is not registered on this page
|
|
155
|
+
* resumed turn's final message, or `null` when there was nothing to resume,
|
|
156
|
+
* some waiting function is not registered on this page, or a waiting call is
|
|
157
|
+
* gated by the approval policy (it is held for `approveFunction` /
|
|
158
|
+
* `rejectFunction` and the turn stays paused, exactly as on the live stream).
|
|
133
159
|
*/
|
|
134
160
|
resumePendingClientFunctions(conversation: Conversation): Promise<AgoMessage | null>;
|
|
135
161
|
/**
|
|
@@ -424,6 +450,15 @@ declare interface AgoClientEvents {
|
|
|
424
450
|
"toolCall:received": ToolCallData;
|
|
425
451
|
"toolCall:form": ToolCallData;
|
|
426
452
|
"function:invoke": ClientFunctionInvocation;
|
|
453
|
+
/**
|
|
454
|
+
* A client function call is held pending the user's approval (pause mode +
|
|
455
|
+
* an {@link AgoConfig.approvalPolicy}/`requiresApproval` match). The turn stays
|
|
456
|
+
* at `WAITING_CLIENT`; call `approveFunction(invocationId)` to run it and
|
|
457
|
+
* resume, or `rejectFunction(invocationId)` to decline. Fires after
|
|
458
|
+
* `function:invoke` (which still fires for every call) and instead of the
|
|
459
|
+
* call running immediately.
|
|
460
|
+
*/
|
|
461
|
+
"function:awaiting-approval": ClientFunctionInvocation;
|
|
427
462
|
"function:result": {
|
|
428
463
|
invocationId: string;
|
|
429
464
|
result: unknown;
|
|
@@ -484,14 +519,28 @@ export declare interface AgoConfig {
|
|
|
484
519
|
warnOnEmptyReply?: boolean;
|
|
485
520
|
/**
|
|
486
521
|
* How the agent loop treats client function calls (requires backend support):
|
|
487
|
-
* - `"
|
|
488
|
-
* result; the real result is only visible to the agent on later turns.
|
|
489
|
-
* - `"pause"`: the turn stops on client function call(s) with status
|
|
522
|
+
* - `"pause"` (default): the turn stops on client function call(s) with status
|
|
490
523
|
* `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
|
|
491
524
|
* turn via `POST /messages/{id}/continue`, so the agent sees the real results.
|
|
525
|
+
* - `"placeholder"` (legacy): the turn continues immediately on a placeholder
|
|
526
|
+
* result; the real result is only visible to the agent on later turns.
|
|
492
527
|
* Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
|
|
493
528
|
*/
|
|
494
529
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
530
|
+
/**
|
|
531
|
+
* Gate client function calls behind explicit user approval. Return `true` for
|
|
532
|
+
* an invocation the user must approve/reject before it runs; return `false`
|
|
533
|
+
* (or omit the policy) to let it run immediately as before.
|
|
534
|
+
*
|
|
535
|
+
* Only effective in pause mode (`clientFunctionsMode: "pause"`) — a gated call
|
|
536
|
+
* holds at `WAITING_CLIENT`, the SDK emits `function:awaiting-approval`, and it
|
|
537
|
+
* runs (and the turn resumes) only after `approveFunction(invocationId)`; a
|
|
538
|
+
* `rejectFunction(invocationId)` submits a rejection so the agent sees the
|
|
539
|
+
* decline. In placeholder mode there is no pause to hold, so the policy is a
|
|
540
|
+
* no-op and the call runs normally. A per-function `requiresApproval: true`
|
|
541
|
+
* also gates a call; the policy and the flag OR together.
|
|
542
|
+
*/
|
|
543
|
+
approvalPolicy?: (invocation: ClientFunctionInvocation) => boolean;
|
|
495
544
|
/**
|
|
496
545
|
* Max serialized size (bytes) of a client function result before the SDK
|
|
497
546
|
* replaces it with a flagged, truncated preview. Everything a handler
|
|
@@ -536,6 +585,11 @@ export declare interface AgoMessage {
|
|
|
536
585
|
export declare interface AgoPageStateOptions {
|
|
537
586
|
/** Name of the synthesized client function. Defaults to "setPageState". */
|
|
538
587
|
functionName?: string;
|
|
588
|
+
/**
|
|
589
|
+
* Require explicit user approval before this state change runs. See
|
|
590
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. Defaults to `false`.
|
|
591
|
+
*/
|
|
592
|
+
requiresApproval?: boolean;
|
|
539
593
|
}
|
|
540
594
|
|
|
541
595
|
/**
|
|
@@ -618,6 +672,11 @@ declare interface ClientFunctionDefinition {
|
|
|
618
672
|
* `Infinity` disables the guard for this function.
|
|
619
673
|
*/
|
|
620
674
|
maxResultBytes?: number;
|
|
675
|
+
/**
|
|
676
|
+
* Require explicit user approval before this function runs. See
|
|
677
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
678
|
+
*/
|
|
679
|
+
requiresApproval?: boolean;
|
|
621
680
|
}
|
|
622
681
|
|
|
623
682
|
/**
|
|
@@ -644,6 +703,11 @@ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name">
|
|
|
644
703
|
* disables the guard for this function.
|
|
645
704
|
*/
|
|
646
705
|
maxResultBytes?: number;
|
|
706
|
+
/**
|
|
707
|
+
* Require explicit user approval before this function runs. See
|
|
708
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
709
|
+
*/
|
|
710
|
+
requiresApproval?: boolean;
|
|
647
711
|
};
|
|
648
712
|
|
|
649
713
|
/**
|
|
@@ -684,6 +748,19 @@ declare interface ContextEntry {
|
|
|
684
748
|
description?: string;
|
|
685
749
|
/** Arbitrary structured data the AI should know about */
|
|
686
750
|
data?: Record<string, unknown>;
|
|
751
|
+
/**
|
|
752
|
+
* Marks the entry as constant for the whole conversation. The backend then
|
|
753
|
+
* pins it right after the system prompt, where LLM providers cache it across
|
|
754
|
+
* turns, instead of re-processing it next to every new user message.
|
|
755
|
+
*
|
|
756
|
+
* Only set this when the entry's content is byte-identical on every message
|
|
757
|
+
* of a conversation (a schema, a capability list, static instructions). A
|
|
758
|
+
* stable entry that changes between messages invalidates the provider's
|
|
759
|
+
* cache for the entire conversation history, which costs more than leaving
|
|
760
|
+
* the flag off. Default: `false` (re-sent near the newest user message).
|
|
761
|
+
* Backends that don't know the flag ignore it.
|
|
762
|
+
*/
|
|
763
|
+
stable?: boolean;
|
|
687
764
|
}
|
|
688
765
|
|
|
689
766
|
/**
|
package/dist/vue.d.ts
CHANGED
|
@@ -49,6 +49,12 @@ declare class AgoClient {
|
|
|
49
49
|
private warnedEmptyConversations;
|
|
50
50
|
/** Paused turns awaiting auto-resume, keyed by assistant message id. */
|
|
51
51
|
private pendingResumes;
|
|
52
|
+
/**
|
|
53
|
+
* Client function invocations held pending user approval, keyed by
|
|
54
|
+
* invocationId (the tool-call id). Populated when {@link requiresApproval}
|
|
55
|
+
* matches; drained by {@link approveFunction} / {@link rejectFunction}.
|
|
56
|
+
*/
|
|
57
|
+
private pendingApprovals;
|
|
52
58
|
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
53
59
|
private resumeGate;
|
|
54
60
|
constructor(config: AgoConfig);
|
|
@@ -99,6 +105,24 @@ declare class AgoClient {
|
|
|
99
105
|
*/
|
|
100
106
|
private maybeFlagEmptyReply;
|
|
101
107
|
private handleClientFunctionInvocation;
|
|
108
|
+
/**
|
|
109
|
+
* Whether a client function invocation must wait for explicit user approval.
|
|
110
|
+
* True when the {@link AgoConfig.approvalPolicy} returns true OR the function
|
|
111
|
+
* was registered with `requiresApproval: true` — the two OR together.
|
|
112
|
+
*/
|
|
113
|
+
private requiresApproval;
|
|
114
|
+
/**
|
|
115
|
+
* Approve a client function call held by the approval gate: run it, submit its
|
|
116
|
+
* result, and let the paused turn resume. No-op if the invocation is unknown
|
|
117
|
+
* (already handled, or never gated).
|
|
118
|
+
*/
|
|
119
|
+
approveFunction(invocationId: string): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Reject a client function call held by the approval gate: submit a rejection
|
|
122
|
+
* result so the agent sees the user declined, and let the paused turn resume
|
|
123
|
+
* (the agent decides what to do next). No-op if the invocation is unknown.
|
|
124
|
+
*/
|
|
125
|
+
rejectFunction(invocationId: string): Promise<void>;
|
|
102
126
|
/**
|
|
103
127
|
* Get list of conversations
|
|
104
128
|
*/
|
|
@@ -128,8 +152,10 @@ declare class AgoClient {
|
|
|
128
152
|
*
|
|
129
153
|
* Opt-in on purpose — re-running functions on reload can be surprising (e.g. a
|
|
130
154
|
* navigation function would navigate again), so the app decides. Returns the
|
|
131
|
-
* resumed turn's final message, or `null` when there was nothing to resume
|
|
132
|
-
* some waiting function is not registered on this page
|
|
155
|
+
* resumed turn's final message, or `null` when there was nothing to resume,
|
|
156
|
+
* some waiting function is not registered on this page, or a waiting call is
|
|
157
|
+
* gated by the approval policy (it is held for `approveFunction` /
|
|
158
|
+
* `rejectFunction` and the turn stays paused, exactly as on the live stream).
|
|
133
159
|
*/
|
|
134
160
|
resumePendingClientFunctions(conversation: Conversation): Promise<AgoMessage | null>;
|
|
135
161
|
/**
|
|
@@ -424,6 +450,15 @@ declare interface AgoClientEvents {
|
|
|
424
450
|
"toolCall:received": ToolCallData;
|
|
425
451
|
"toolCall:form": ToolCallData;
|
|
426
452
|
"function:invoke": ClientFunctionInvocation;
|
|
453
|
+
/**
|
|
454
|
+
* A client function call is held pending the user's approval (pause mode +
|
|
455
|
+
* an {@link AgoConfig.approvalPolicy}/`requiresApproval` match). The turn stays
|
|
456
|
+
* at `WAITING_CLIENT`; call `approveFunction(invocationId)` to run it and
|
|
457
|
+
* resume, or `rejectFunction(invocationId)` to decline. Fires after
|
|
458
|
+
* `function:invoke` (which still fires for every call) and instead of the
|
|
459
|
+
* call running immediately.
|
|
460
|
+
*/
|
|
461
|
+
"function:awaiting-approval": ClientFunctionInvocation;
|
|
427
462
|
"function:result": {
|
|
428
463
|
invocationId: string;
|
|
429
464
|
result: unknown;
|
|
@@ -484,14 +519,28 @@ export declare interface AgoConfig {
|
|
|
484
519
|
warnOnEmptyReply?: boolean;
|
|
485
520
|
/**
|
|
486
521
|
* How the agent loop treats client function calls (requires backend support):
|
|
487
|
-
* - `"
|
|
488
|
-
* result; the real result is only visible to the agent on later turns.
|
|
489
|
-
* - `"pause"`: the turn stops on client function call(s) with status
|
|
522
|
+
* - `"pause"` (default): the turn stops on client function call(s) with status
|
|
490
523
|
* `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
|
|
491
524
|
* turn via `POST /messages/{id}/continue`, so the agent sees the real results.
|
|
525
|
+
* - `"placeholder"` (legacy): the turn continues immediately on a placeholder
|
|
526
|
+
* result; the real result is only visible to the agent on later turns.
|
|
492
527
|
* Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
|
|
493
528
|
*/
|
|
494
529
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
530
|
+
/**
|
|
531
|
+
* Gate client function calls behind explicit user approval. Return `true` for
|
|
532
|
+
* an invocation the user must approve/reject before it runs; return `false`
|
|
533
|
+
* (or omit the policy) to let it run immediately as before.
|
|
534
|
+
*
|
|
535
|
+
* Only effective in pause mode (`clientFunctionsMode: "pause"`) — a gated call
|
|
536
|
+
* holds at `WAITING_CLIENT`, the SDK emits `function:awaiting-approval`, and it
|
|
537
|
+
* runs (and the turn resumes) only after `approveFunction(invocationId)`; a
|
|
538
|
+
* `rejectFunction(invocationId)` submits a rejection so the agent sees the
|
|
539
|
+
* decline. In placeholder mode there is no pause to hold, so the policy is a
|
|
540
|
+
* no-op and the call runs normally. A per-function `requiresApproval: true`
|
|
541
|
+
* also gates a call; the policy and the flag OR together.
|
|
542
|
+
*/
|
|
543
|
+
approvalPolicy?: (invocation: ClientFunctionInvocation) => boolean;
|
|
495
544
|
/**
|
|
496
545
|
* Max serialized size (bytes) of a client function result before the SDK
|
|
497
546
|
* replaces it with a flagged, truncated preview. Everything a handler
|
|
@@ -536,6 +585,11 @@ export declare interface AgoMessage {
|
|
|
536
585
|
export declare interface AgoPageStateOptions {
|
|
537
586
|
/** Name of the synthesized client function. Defaults to "setPageState". */
|
|
538
587
|
functionName?: string;
|
|
588
|
+
/**
|
|
589
|
+
* Require explicit user approval before this state change runs. See
|
|
590
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. Defaults to `false`.
|
|
591
|
+
*/
|
|
592
|
+
requiresApproval?: boolean;
|
|
539
593
|
}
|
|
540
594
|
|
|
541
595
|
/**
|
|
@@ -618,6 +672,11 @@ declare interface ClientFunctionDefinition {
|
|
|
618
672
|
* `Infinity` disables the guard for this function.
|
|
619
673
|
*/
|
|
620
674
|
maxResultBytes?: number;
|
|
675
|
+
/**
|
|
676
|
+
* Require explicit user approval before this function runs. See
|
|
677
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
678
|
+
*/
|
|
679
|
+
requiresApproval?: boolean;
|
|
621
680
|
}
|
|
622
681
|
|
|
623
682
|
/**
|
|
@@ -644,6 +703,11 @@ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name">
|
|
|
644
703
|
* disables the guard for this function.
|
|
645
704
|
*/
|
|
646
705
|
maxResultBytes?: number;
|
|
706
|
+
/**
|
|
707
|
+
* Require explicit user approval before this function runs. See
|
|
708
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
709
|
+
*/
|
|
710
|
+
requiresApproval?: boolean;
|
|
647
711
|
};
|
|
648
712
|
|
|
649
713
|
/**
|
|
@@ -684,6 +748,19 @@ declare interface ContextEntry {
|
|
|
684
748
|
description?: string;
|
|
685
749
|
/** Arbitrary structured data the AI should know about */
|
|
686
750
|
data?: Record<string, unknown>;
|
|
751
|
+
/**
|
|
752
|
+
* Marks the entry as constant for the whole conversation. The backend then
|
|
753
|
+
* pins it right after the system prompt, where LLM providers cache it across
|
|
754
|
+
* turns, instead of re-processing it next to every new user message.
|
|
755
|
+
*
|
|
756
|
+
* Only set this when the entry's content is byte-identical on every message
|
|
757
|
+
* of a conversation (a schema, a capability list, static instructions). A
|
|
758
|
+
* stable entry that changes between messages invalidates the provider's
|
|
759
|
+
* cache for the entire conversation history, which costs more than leaving
|
|
760
|
+
* the flag off. Default: `false` (re-sent near the newest user message).
|
|
761
|
+
* Backends that don't know the flag ignore it.
|
|
762
|
+
*/
|
|
763
|
+
stable?: boolean;
|
|
687
764
|
}
|
|
688
765
|
|
|
689
766
|
/**
|
package/dist/vue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as A } from "./AgoClient-
|
|
1
|
+
import { t as A } from "./AgoClient-DXrH2AMi.js";
|
|
2
2
|
import { computed as L, inject as M, onMounted as f, onScopeDispose as F, onUnmounted as h, ref as c, shallowRef as S } from "vue";
|
|
3
3
|
var N = /* @__PURE__ */ Symbol("ago-client"), b = { install(t, n) {
|
|
4
4
|
const e = new A(n);
|