@useago/sdk 1.0.7 → 1.0.8
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/dist/{AgoClient--y10UXUV.cjs → AgoClient-B3-WGVne.cjs} +3 -3
- package/dist/{AgoClient-DYdIe_R4.js → AgoClient-QcTtrN7u.js} +3 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +22 -0
- package/dist/angular.d.ts +22 -0
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-BuMXp0Ia.cjs → createConversationSession-BwYNMZWq.cjs} +1 -1
- package/dist/{createConversationSession-CCT1hCf8.js → createConversationSession-DrCMdwkV.js} +1 -1
- package/dist/createFormCollector-BHHEW6uX.cjs +1 -0
- package/dist/{createFormCollector-BwM7qTrp.js → createFormCollector-QyojCH_-.js} +128 -107
- package/dist/devtools.d.cts +22 -0
- package/dist/devtools.d.ts +22 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +39 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +53 -45
- package/dist/react.cjs +1 -1
- package/dist/react.d.cts +22 -0
- package/dist/react.d.ts +22 -0
- package/dist/react.js +2 -2
- package/dist/testing.d.cts +22 -0
- package/dist/testing.d.ts +22 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +22 -0
- package/dist/vue.d.ts +22 -0
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +41 -0
- package/dist/widget.d.ts +41 -0
- package/dist/widget.js +236 -234
- package/package.json +1 -1
- package/dist/createFormCollector-DWzGKDwO.cjs +0 -1
package/dist/devtools.d.cts
CHANGED
|
@@ -176,6 +176,7 @@ declare class AgoClient {
|
|
|
176
176
|
* call it when their store updates so observers like the dev panel stay live.
|
|
177
177
|
*/
|
|
178
178
|
notifyContextChanged(): void;
|
|
179
|
+
/* Excluded from this release type: emitFormEvent */
|
|
179
180
|
/**
|
|
180
181
|
* Enable automatic capture of the current browser page (URL + title).
|
|
181
182
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -290,6 +291,27 @@ declare interface AgoClientEvents {
|
|
|
290
291
|
result: unknown;
|
|
291
292
|
error?: string;
|
|
292
293
|
};
|
|
294
|
+
/**
|
|
295
|
+
* A form collector submitted successfully. `result` is the raw submit response
|
|
296
|
+
* (POST body / handler return value / backend relay result) — the third-party
|
|
297
|
+
* API's answer. `values` is the submitted field set, `name` the collector name.
|
|
298
|
+
*/
|
|
299
|
+
"form:submitted": {
|
|
300
|
+
name: string;
|
|
301
|
+
values: Record<string, unknown>;
|
|
302
|
+
result: unknown;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* A form collector submit was attempted and failed at the network/server level
|
|
306
|
+
* (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
|
|
307
|
+
* pre-checks (missing required fields, no submit target) are NOT errors and do
|
|
308
|
+
* not fire this — they are returned to the caller as `{ ok: false }`.
|
|
309
|
+
*/
|
|
310
|
+
"form:error": {
|
|
311
|
+
name: string;
|
|
312
|
+
values: Record<string, unknown>;
|
|
313
|
+
error: string;
|
|
314
|
+
};
|
|
293
315
|
"connection:status": {
|
|
294
316
|
connected: boolean;
|
|
295
317
|
};
|
package/dist/devtools.d.ts
CHANGED
|
@@ -176,6 +176,7 @@ declare class AgoClient {
|
|
|
176
176
|
* call it when their store updates so observers like the dev panel stay live.
|
|
177
177
|
*/
|
|
178
178
|
notifyContextChanged(): void;
|
|
179
|
+
/* Excluded from this release type: emitFormEvent */
|
|
179
180
|
/**
|
|
180
181
|
* Enable automatic capture of the current browser page (URL + title).
|
|
181
182
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -290,6 +291,27 @@ declare interface AgoClientEvents {
|
|
|
290
291
|
result: unknown;
|
|
291
292
|
error?: string;
|
|
292
293
|
};
|
|
294
|
+
/**
|
|
295
|
+
* A form collector submitted successfully. `result` is the raw submit response
|
|
296
|
+
* (POST body / handler return value / backend relay result) — the third-party
|
|
297
|
+
* API's answer. `values` is the submitted field set, `name` the collector name.
|
|
298
|
+
*/
|
|
299
|
+
"form:submitted": {
|
|
300
|
+
name: string;
|
|
301
|
+
values: Record<string, unknown>;
|
|
302
|
+
result: unknown;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* A form collector submit was attempted and failed at the network/server level
|
|
306
|
+
* (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
|
|
307
|
+
* pre-checks (missing required fields, no submit target) are NOT errors and do
|
|
308
|
+
* not fire this — they are returned to the caller as `{ ok: false }`.
|
|
309
|
+
*/
|
|
310
|
+
"form:error": {
|
|
311
|
+
name: string;
|
|
312
|
+
values: Record<string, unknown>;
|
|
313
|
+
error: string;
|
|
314
|
+
};
|
|
293
315
|
"connection:status": {
|
|
294
316
|
connected: boolean;
|
|
295
317
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./AgoClient
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./AgoClient-B3-WGVne.cjs"),f=require("./createFormCollector-BHHEW6uX.cjs"),p=require("./createConversationSession-BwYNMZWq.cjs"),w=require("./createMockClient-zHQ0cjUH.cjs");require("./testing.cjs");const g=require("./functions-Djnq-JAo.cjs");function h(e){return e}function E(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function S(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function y(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function b(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function F(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function v(e,o){return e.on("form:submitted",o),()=>e.off("form:submitted",o)}function M(e,o){return e.on("form:error",o),()=>e.off("form:error",o)}function q(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*k(e,o,l){const a=[];let r=null,s=!1;const m=i=>{a.push(i),r?.()},c=i=>m({type:"start",data:i}),t=i=>m({type:"chunk",data:i}),u=i=>{m({type:"complete",data:i}),s=!0,r?.()},d=i=>{m({type:"error",data:i}),s=!0,r?.()},C=i=>m({type:"toolCall",data:i});e.on("message:start",c),e.on("message:chunk",t),e.on("message:complete",u),e.on("message:error",d),e.on("toolCall:received",C),e.sendMessage(o,l).catch(()=>{s=!0,r?.()});try{for(;!s||a.length>0;)a.length>0?yield a.shift():(await new Promise(i=>{r=i}),r=null)}finally{e.off("message:start",c),e.off("message:chunk",t),e.off("message:complete",u),e.off("message:error",d),e.off("toolCall:received",C)}}function A(e){let o,l,a,r,s,m;if(typeof window<"u"&&window.AGO){const t=window.AGO;o=t.basepath,l=t.widgetId,a=t.agent||t.defaultAgent,r=t.permission,s=t.email,m=t.jwt}if(typeof document<"u"){const t=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;o=o||t("ago-base-url"),l=l||t("ago-widget-id"),a=a||t("ago-agent")||t("ago-agent-id"),r=r||t("ago-permission"),s=s||t("ago-user-email")}if(typeof document<"u"){const t=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of t)u&&(o=o||u.getAttribute("data-ago-base-url")||void 0,l=l||u.getAttribute("data-ago-widget-id")||void 0,a=a||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,r=r||u.getAttribute("data-ago-permission")||void 0,s=s||u.getAttribute("data-ago-user-email")||void 0)}o=e?.baseUrl||o,l=e?.widgetId||l,a=e?.agent||e?.defaultAgentId||a,r=e?.permission||r,s=e?.userEmail||s,m=e?.userJwt||m;const c=e?.debug;return o?{baseUrl:o,widgetId:l,agent:a,permission:r,userEmail:s,userJwt:m,debug:c}:null}function T(e){const o=A(e);if(!o)throw new n.AgoError('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.',"config_missing_base_url");return new n.AgoClient(o)}function _(e,o){return{...e,handler:o}}exports.AgoApiError=n.AgoApiError;exports.AgoClient=n.AgoClient;exports.AgoError=n.AgoError;exports.AgoFunctionError=n.AgoFunctionError;exports.AgoNetworkError=n.AgoNetworkError;exports.AgoStreamError=n.AgoStreamError;exports.ClientContextRegistry=n.ClientContextRegistry;exports.EventEmitter=n.EventEmitter;exports.FunctionRegistry=n.FunctionRegistry;exports.SSEHandler=n.SSEHandler;exports.autoDetectConfig=A;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=T;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=f.createFormCollector;exports.createMessageStream=k;exports.createMockClient=w.createMockClient;exports.createStore=f.createStore;exports.defineFunction=h;exports.deriveFormStatus=f.deriveFormStatus;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=n.isStreamNetworkError;exports.loadFormCollector=f.loadFormCollector;exports.logger=n.logger;exports.onFormError=M;exports.onFormSubmitted=v;exports.onFunctionInvoke=q;exports.onMessage=E;exports.onMessageChunk=S;exports.onMessageError=b;exports.onMessageStart=y;exports.onToolCall=F;exports.openUrl=g.openUrl;exports.scrollToElement=g.scrollToElement;exports.setLocalStorage=g.setLocalStorage;exports.setTheme=g.setTheme;exports.showConfirmDialog=g.showConfirmDialog;exports.showNotification=g.showNotification;exports.showToast=g.showToast;exports.submitForm=g.submitForm;exports.trackEvent=g.trackEvent;exports.validateConfig=n.validateConfig;exports.withHandler=_;
|
package/dist/index.d.cts
CHANGED
|
@@ -187,6 +187,7 @@ export declare class AgoClient {
|
|
|
187
187
|
* call it when their store updates so observers like the dev panel stay live.
|
|
188
188
|
*/
|
|
189
189
|
notifyContextChanged(): void;
|
|
190
|
+
/* Excluded from this release type: emitFormEvent */
|
|
190
191
|
/**
|
|
191
192
|
* Enable automatic capture of the current browser page (URL + title).
|
|
192
193
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -301,6 +302,27 @@ export declare interface AgoClientEvents {
|
|
|
301
302
|
result: unknown;
|
|
302
303
|
error?: string;
|
|
303
304
|
};
|
|
305
|
+
/**
|
|
306
|
+
* A form collector submitted successfully. `result` is the raw submit response
|
|
307
|
+
* (POST body / handler return value / backend relay result) — the third-party
|
|
308
|
+
* API's answer. `values` is the submitted field set, `name` the collector name.
|
|
309
|
+
*/
|
|
310
|
+
"form:submitted": {
|
|
311
|
+
name: string;
|
|
312
|
+
values: Record<string, unknown>;
|
|
313
|
+
result: unknown;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* A form collector submit was attempted and failed at the network/server level
|
|
317
|
+
* (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
|
|
318
|
+
* pre-checks (missing required fields, no submit target) are NOT errors and do
|
|
319
|
+
* not fire this — they are returned to the caller as `{ ok: false }`.
|
|
320
|
+
*/
|
|
321
|
+
"form:error": {
|
|
322
|
+
name: string;
|
|
323
|
+
values: Record<string, unknown>;
|
|
324
|
+
error: string;
|
|
325
|
+
};
|
|
304
326
|
"connection:status": {
|
|
305
327
|
connected: boolean;
|
|
306
328
|
};
|
|
@@ -1162,6 +1184,23 @@ export declare interface MockAgoClientOptions {
|
|
|
1162
1184
|
|
|
1163
1185
|
declare type MockFn = (...args: any[]) => any;
|
|
1164
1186
|
|
|
1187
|
+
/**
|
|
1188
|
+
* Subscribe to failed form collector submissions (network/server failures).
|
|
1189
|
+
*/
|
|
1190
|
+
export declare function onFormError(client: AgoClient, callback: (data: AgoClientEvents["form:error"]) => void): () => void;
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* Subscribe to successful form collector submissions. `result` is the submit
|
|
1194
|
+
* response (the third-party API's answer). Returns an unsubscribe function.
|
|
1195
|
+
*
|
|
1196
|
+
* ```ts
|
|
1197
|
+
* const unsub = onFormSubmitted(client, ({ name, result }) => {
|
|
1198
|
+
* console.log(name, "submitted", result);
|
|
1199
|
+
* });
|
|
1200
|
+
* ```
|
|
1201
|
+
*/
|
|
1202
|
+
export declare function onFormSubmitted(client: AgoClient, callback: (data: AgoClientEvents["form:submitted"]) => void): () => void;
|
|
1203
|
+
|
|
1165
1204
|
/**
|
|
1166
1205
|
* Subscribe to client function invocations.
|
|
1167
1206
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -187,6 +187,7 @@ export declare class AgoClient {
|
|
|
187
187
|
* call it when their store updates so observers like the dev panel stay live.
|
|
188
188
|
*/
|
|
189
189
|
notifyContextChanged(): void;
|
|
190
|
+
/* Excluded from this release type: emitFormEvent */
|
|
190
191
|
/**
|
|
191
192
|
* Enable automatic capture of the current browser page (URL + title).
|
|
192
193
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -301,6 +302,27 @@ export declare interface AgoClientEvents {
|
|
|
301
302
|
result: unknown;
|
|
302
303
|
error?: string;
|
|
303
304
|
};
|
|
305
|
+
/**
|
|
306
|
+
* A form collector submitted successfully. `result` is the raw submit response
|
|
307
|
+
* (POST body / handler return value / backend relay result) — the third-party
|
|
308
|
+
* API's answer. `values` is the submitted field set, `name` the collector name.
|
|
309
|
+
*/
|
|
310
|
+
"form:submitted": {
|
|
311
|
+
name: string;
|
|
312
|
+
values: Record<string, unknown>;
|
|
313
|
+
result: unknown;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* A form collector submit was attempted and failed at the network/server level
|
|
317
|
+
* (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
|
|
318
|
+
* pre-checks (missing required fields, no submit target) are NOT errors and do
|
|
319
|
+
* not fire this — they are returned to the caller as `{ ok: false }`.
|
|
320
|
+
*/
|
|
321
|
+
"form:error": {
|
|
322
|
+
name: string;
|
|
323
|
+
values: Record<string, unknown>;
|
|
324
|
+
error: string;
|
|
325
|
+
};
|
|
304
326
|
"connection:status": {
|
|
305
327
|
connected: boolean;
|
|
306
328
|
};
|
|
@@ -1162,6 +1184,23 @@ export declare interface MockAgoClientOptions {
|
|
|
1162
1184
|
|
|
1163
1185
|
declare type MockFn = (...args: any[]) => any;
|
|
1164
1186
|
|
|
1187
|
+
/**
|
|
1188
|
+
* Subscribe to failed form collector submissions (network/server failures).
|
|
1189
|
+
*/
|
|
1190
|
+
export declare function onFormError(client: AgoClient, callback: (data: AgoClientEvents["form:error"]) => void): () => void;
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* Subscribe to successful form collector submissions. `result` is the submit
|
|
1194
|
+
* response (the third-party API's answer). Returns an unsubscribe function.
|
|
1195
|
+
*
|
|
1196
|
+
* ```ts
|
|
1197
|
+
* const unsub = onFormSubmitted(client, ({ name, result }) => {
|
|
1198
|
+
* console.log(name, "submitted", result);
|
|
1199
|
+
* });
|
|
1200
|
+
* ```
|
|
1201
|
+
*/
|
|
1202
|
+
export declare function onFormSubmitted(client: AgoClient, callback: (data: AgoClientEvents["form:submitted"]) => void): () => void;
|
|
1203
|
+
|
|
1165
1204
|
/**
|
|
1166
1205
|
* Subscribe to client function invocations.
|
|
1167
1206
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as h, c as A, d as y, f as C, i as E, l as b, m as S, o as v, p as
|
|
2
|
-
import { a as G, c as O, d as q, f as x, i as L, l as N, n as _, o as D, p as H, r as J, s as R, t as d, u as c } from "./AgoClient-
|
|
3
|
-
import { i as B, n as P, r as $, t as z } from "./createFormCollector-
|
|
4
|
-
import { t as Q } from "./createConversationSession-
|
|
1
|
+
import { a as h, c as A, d as y, f as C, i as E, l as b, m as S, o as v, p as F, r as M, s as k, t as T, u as I } from "./functions-CApuQZ2b.js";
|
|
2
|
+
import { a as G, c as O, d as q, f as x, i as L, l as N, n as _, o as D, p as H, r as J, s as R, t as d, u as c } from "./AgoClient-QcTtrN7u.js";
|
|
3
|
+
import { i as B, n as P, r as $, t as z } from "./createFormCollector-QyojCH_-.js";
|
|
4
|
+
import { t as Q } from "./createConversationSession-DrCMdwkV.js";
|
|
5
5
|
import { t as W } from "./createMockClient-DwdxNwEn.js";
|
|
6
6
|
import "./testing.js";
|
|
7
7
|
function Y(e) {
|
|
@@ -19,81 +19,87 @@ function oe(e, o) {
|
|
|
19
19
|
function te(e, o) {
|
|
20
20
|
return e.on("message:error", o), () => e.off("message:error", o);
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function re(e, o) {
|
|
23
23
|
return e.on("toolCall:received", o), () => e.off("toolCall:received", o);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function ne(e, o) {
|
|
26
|
+
return e.on("form:submitted", o), () => e.off("form:submitted", o);
|
|
27
|
+
}
|
|
28
|
+
function ae(e, o) {
|
|
29
|
+
return e.on("form:error", o), () => e.off("form:error", o);
|
|
30
|
+
}
|
|
31
|
+
function se(e, o) {
|
|
26
32
|
return e.on("function:invoke", o), () => e.off("function:invoke", o);
|
|
27
33
|
}
|
|
28
|
-
async function*
|
|
29
|
-
const
|
|
30
|
-
let
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
}, f = (s) =>
|
|
34
|
+
async function* ie(e, o, u) {
|
|
35
|
+
const n = [];
|
|
36
|
+
let r = null, a = !1;
|
|
37
|
+
const g = (s) => {
|
|
38
|
+
n.push(s), r?.();
|
|
39
|
+
}, f = (s) => g({
|
|
34
40
|
type: "start",
|
|
35
41
|
data: s
|
|
36
|
-
}), t = (s) =>
|
|
42
|
+
}), t = (s) => g({
|
|
37
43
|
type: "chunk",
|
|
38
44
|
data: s
|
|
39
45
|
}), i = (s) => {
|
|
40
|
-
|
|
46
|
+
g({
|
|
41
47
|
type: "complete",
|
|
42
48
|
data: s
|
|
43
|
-
}),
|
|
44
|
-
},
|
|
45
|
-
|
|
49
|
+
}), a = !0, r?.();
|
|
50
|
+
}, m = (s) => {
|
|
51
|
+
g({
|
|
46
52
|
type: "error",
|
|
47
53
|
data: s
|
|
48
|
-
}),
|
|
49
|
-
},
|
|
54
|
+
}), a = !0, r?.();
|
|
55
|
+
}, l = (s) => g({
|
|
50
56
|
type: "toolCall",
|
|
51
57
|
data: s
|
|
52
58
|
});
|
|
53
|
-
e.on("message:start", f), e.on("message:chunk", t), e.on("message:complete", i), e.on("message:error",
|
|
54
|
-
|
|
59
|
+
e.on("message:start", f), e.on("message:chunk", t), e.on("message:complete", i), e.on("message:error", m), e.on("toolCall:received", l), e.sendMessage(o, u).catch(() => {
|
|
60
|
+
a = !0, r?.();
|
|
55
61
|
});
|
|
56
62
|
try {
|
|
57
|
-
for (; !
|
|
58
|
-
|
|
59
|
-
}),
|
|
63
|
+
for (; !a || n.length > 0; ) n.length > 0 ? yield n.shift() : (await new Promise((s) => {
|
|
64
|
+
r = s;
|
|
65
|
+
}), r = null);
|
|
60
66
|
} finally {
|
|
61
|
-
e.off("message:start", f), e.off("message:chunk", t), e.off("message:complete", i), e.off("message:error",
|
|
67
|
+
e.off("message:start", f), e.off("message:chunk", t), e.off("message:complete", i), e.off("message:error", m), e.off("toolCall:received", l);
|
|
62
68
|
}
|
|
63
69
|
}
|
|
64
70
|
function p(e) {
|
|
65
|
-
let o,
|
|
71
|
+
let o, u, n, r, a, g;
|
|
66
72
|
if (typeof window < "u" && window.AGO) {
|
|
67
73
|
const t = window.AGO;
|
|
68
|
-
o = t.basepath,
|
|
74
|
+
o = t.basepath, u = t.widgetId, n = t.agent || t.defaultAgent, r = t.permission, a = t.email, g = t.jwt;
|
|
69
75
|
}
|
|
70
76
|
if (typeof document < "u") {
|
|
71
77
|
const t = (i) => document.querySelector(`meta[name="${i}"]`)?.getAttribute("content") || void 0;
|
|
72
|
-
o = o || t("ago-base-url"),
|
|
78
|
+
o = o || t("ago-base-url"), u = u || t("ago-widget-id"), n = n || t("ago-agent") || t("ago-agent-id"), r = r || t("ago-permission"), a = a || t("ago-user-email");
|
|
73
79
|
}
|
|
74
80
|
if (typeof document < "u") {
|
|
75
81
|
const t = [document.body, ...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);
|
|
76
82
|
for (const i of t)
|
|
77
|
-
i && (o = o || i.getAttribute("data-ago-base-url") || void 0,
|
|
83
|
+
i && (o = o || i.getAttribute("data-ago-base-url") || void 0, u = u || i.getAttribute("data-ago-widget-id") || void 0, n = n || i.getAttribute("data-ago-agent") || i.getAttribute("data-ago-agent-id") || void 0, r = r || i.getAttribute("data-ago-permission") || void 0, a = a || i.getAttribute("data-ago-user-email") || void 0);
|
|
78
84
|
}
|
|
79
|
-
o = e?.baseUrl || o,
|
|
85
|
+
o = e?.baseUrl || o, u = e?.widgetId || u, n = e?.agent || e?.defaultAgentId || n, r = e?.permission || r, a = e?.userEmail || a, g = e?.userJwt || g;
|
|
80
86
|
const f = e?.debug;
|
|
81
87
|
return o ? {
|
|
82
88
|
baseUrl: o,
|
|
83
|
-
widgetId:
|
|
84
|
-
agent:
|
|
85
|
-
permission:
|
|
86
|
-
userEmail:
|
|
87
|
-
userJwt:
|
|
89
|
+
widgetId: u,
|
|
90
|
+
agent: n,
|
|
91
|
+
permission: r,
|
|
92
|
+
userEmail: a,
|
|
93
|
+
userJwt: g,
|
|
88
94
|
debug: f
|
|
89
95
|
} : null;
|
|
90
96
|
}
|
|
91
|
-
function
|
|
97
|
+
function ue(e) {
|
|
92
98
|
const o = p(e);
|
|
93
99
|
if (!o) throw new c('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.', "config_missing_base_url");
|
|
94
100
|
return new d(o);
|
|
95
101
|
}
|
|
96
|
-
function
|
|
102
|
+
function ge(e, o) {
|
|
97
103
|
return {
|
|
98
104
|
...e,
|
|
99
105
|
handler: o
|
|
@@ -112,35 +118,37 @@ export {
|
|
|
112
118
|
L as SSEHandler,
|
|
113
119
|
p as autoDetectConfig,
|
|
114
120
|
T as copyToClipboard,
|
|
115
|
-
|
|
121
|
+
ue as createAgo,
|
|
116
122
|
Q as createConversationSession,
|
|
117
123
|
z as createFormCollector,
|
|
118
|
-
|
|
124
|
+
ie as createMessageStream,
|
|
119
125
|
W as createMockClient,
|
|
120
126
|
B as createStore,
|
|
121
127
|
Y as defineFunction,
|
|
122
128
|
P as deriveFormStatus,
|
|
123
|
-
|
|
129
|
+
M as getLocalStorage,
|
|
124
130
|
E as getUserLocation,
|
|
125
131
|
h as highlightElement,
|
|
126
132
|
G as isStreamNetworkError,
|
|
127
133
|
$ as loadFormCollector,
|
|
128
134
|
O as logger,
|
|
129
|
-
|
|
135
|
+
ae as onFormError,
|
|
136
|
+
ne as onFormSubmitted,
|
|
137
|
+
se as onFunctionInvoke,
|
|
130
138
|
Z as onMessage,
|
|
131
139
|
ee as onMessageChunk,
|
|
132
140
|
te as onMessageError,
|
|
133
141
|
oe as onMessageStart,
|
|
134
|
-
|
|
142
|
+
re as onToolCall,
|
|
135
143
|
v as openUrl,
|
|
136
|
-
|
|
144
|
+
k as scrollToElement,
|
|
137
145
|
A as setLocalStorage,
|
|
138
146
|
b as setTheme,
|
|
139
147
|
I as showConfirmDialog,
|
|
140
148
|
y as showNotification,
|
|
141
149
|
C as showToast,
|
|
142
|
-
|
|
150
|
+
F as submitForm,
|
|
143
151
|
S as trackEvent,
|
|
144
152
|
_ as validateConfig,
|
|
145
|
-
|
|
153
|
+
ge as withHandler
|
|
146
154
|
};
|
package/dist/react.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./rolldown-runtime-16Nf8qvH.cjs"),J=require("./AgoClient
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./rolldown-runtime-16Nf8qvH.cjs"),J=require("./AgoClient-B3-WGVne.cjs"),M=require("./createFormCollector-BHHEW6uX.cjs"),V=require("./createMockClient-zHQ0cjUH.cjs");let n=require("react");n=P.__toESM(n,1);let o=require("react/jsx-runtime"),F=require("react-markdown");F=P.__toESM(F,1);let N=require("remark-gfm");N=P.__toESM(N,1);function q(e){const[t,s]=(0,n.useState)(!1),r=(0,n.useRef)(null),a=(0,n.useMemo)(()=>{if(r.current&&(r.current.destroy(),r.current=null),!e)return null;const l=new J.AgoClient(e);return r.current=l,l},[e?.baseUrl,e?.widgetId]);return(0,n.useEffect)(()=>(s(!0),()=>{r.current?.destroy(),r.current=null}),[a]),(0,n.useEffect)(()=>{r.current&&e&&r.current.updateConfig({agent:e.agent,defaultAgentId:e.defaultAgentId,permission:e.permission,userEmail:e.userEmail,userJwt:e.userJwt,debug:e.debug,warnOnEmptyReply:e.warnOnEmptyReply})},[e?.agent,e?.defaultAgentId,e?.permission,e?.userEmail,e?.userJwt,e?.debug,e?.warnOnEmptyReply]),{client:a,isReady:t}}var T=(0,n.createContext)(null),G=({children:e,client:t,tools:s,helpers:r,pageContext:a,...l})=>{const{client:u}=q(t?null:l),i=t||u;return(0,n.useEffect)(()=>{if(!(!s||s.length===0)){for(const p of s)i.register(p);return()=>{for(const p of s)i.unregisterFunction(p.name)}}},[i,s]),(0,n.useEffect)(()=>{if(!r)return;const p=[];return Promise.resolve().then(()=>require("./functions-Djnq-JAo.cjs")).then(d=>d.functions_exports).then(d=>{for(const[h,C]of Object.entries(r)){const k=d[h];if(!k){console.warn(`[AGO] Unknown helper: "${h}"`);continue}const m=C===!0?k:{...k,handler:C};i.register(m),p.push(m.name)}}),()=>{for(const d of p)i.unregisterFunction(d)}},[i,r]),(0,n.useEffect)(()=>{a==="auto"&&i.enableAutoPageContext()},[i,a]),(0,o.jsx)(T.Provider,{value:i,children:e})};function A(){const e=(0,n.useContext)(T);if(!e)throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');return e}function R(){return(0,n.useContext)(T)}function L({client:e,conversationId:t}={}){const s=R(),r=e||s;if(!r)throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");const[a,l]=(0,n.useState)([]),[u,i]=(0,n.useState)(t),[p,d]=(0,n.useState)(!1),[h,C]=(0,n.useState)(null);(0,n.useEffect)(()=>{t&&t!==u&&(i(t),k(t))},[t]);const k=async m=>{try{l(await r.getMessages(m))}catch(v){C(v instanceof Error?v:new Error("Failed to load messages"))}};return(0,n.useEffect)(()=>{const m=x=>{u||i(x.conversationId)},v=x=>{l(f=>{const w=f[f.length-1];return w&&w.id===x.messageId?[...f.slice(0,-1),{...w,content:w.content+x.content}]:f})},c=x=>{l(f=>{let w=-1;for(let S=f.length-1;S>=0;S--)if(f[S].role==="assistant"&&f[S].status==="IN_PROGRESS"){w=S;break}return w<0?f:[...f.slice(0,w),{...f[w],...x},...f.slice(w+1)]})},y=x=>{l(f=>{const w=f.findIndex(S=>S.id===x.id);return w>=0?[...f.slice(0,w),x,...f.slice(w+1)]:[...f,x]}),d(!1)},g=x=>{C(new Error(x.error)),d(!1)};return r.on("message:start",m),r.on("message:chunk",v),r.on("message:answer-complete",c),r.on("message:complete",y),r.on("message:error",g),()=>{r.off("message:start",m),r.off("message:chunk",v),r.off("message:answer-complete",c),r.off("message:complete",y),r.off("message:error",g)}},[r,u]),{messages:a,isLoading:p,error:h,sendMessage:(0,n.useCallback)(async(m,v)=>{d(!0),C(null);const c={id:`temp-${Date.now()}`,conversationId:u||"",content:m,role:"user",status:"DONE",createdAt:new Date},y={id:`temp-assistant-${Date.now()}`,conversationId:u||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};l(g=>[...g,c,y]);try{const g=await r.sendMessage(m,{conversationId:u,files:v});return g.conversationId&&!u&&i(g.conversationId),l(x=>{const f=x.filter(S=>!S.id.startsWith("temp-")),w={...c,id:c.id.replace("temp-","user-"),conversationId:g.conversationId};return f.some(S=>S.id===g.id)?[...f,w].sort((S,_)=>new Date(S.createdAt).getTime()-new Date(_.createdAt).getTime()):[...f,w,g]}),g}catch(g){return C(g instanceof Error?g:new Error("Failed to send message")),d(!1),l(x=>x.filter(f=>!f.id.startsWith("temp-"))),null}},[r,u]),clearMessages:(0,n.useCallback)(()=>{l([]),i(void 0),C(null)},[]),conversationId:u}}var W=({onSend:e,disabled:t=!1,placeholder:s="Type a message...",allowFiles:r=!1,className:a=""})=>{const[l,u]=(0,n.useState)(""),[i,p]=(0,n.useState)([]),d=(0,n.useRef)(null),h=(0,n.useCallback)(c=>{c.preventDefault(),(l.trim()||i.length>0)&&(e(l.trim(),i.length>0?i:void 0),u(""),p([]))},[l,i,e]),C=(0,n.useCallback)(c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),h(c))},[h]),k=(0,n.useCallback)(c=>{const y=Array.from(c.target.files||[]);p(g=>[...g,...y])},[]),m=(0,n.useCallback)(c=>{p(y=>y.filter((g,x)=>x!==c))},[]),v=l.trim()||i.length>0;return(0,o.jsxs)("form",{onSubmit:h,className:`ago-chat-input ${a}`,style:{display:"flex",flexDirection:"column",gap:"8px",padding:"12px 16px",borderTop:"1px solid #dee3e8",backgroundColor:"#fff"},children:[i.length>0&&(0,o.jsx)("div",{className:"ago-chat-input__files",style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:i.map((c,y)=>(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",backgroundColor:"#f0f2f5",borderRadius:"6px",fontSize:"12px",color:"#30373e"},children:[(0,o.jsx)("span",{style:{maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.name}),(0,o.jsx)("button",{type:"button",onClick:()=>m(y),style:{border:"none",background:"none",cursor:"pointer",padding:"0",color:"#6b6d6f",fontSize:"14px",lineHeight:1},children:"×"})]},y))}),(0,o.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[r&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button",onClick:()=>d.current?.click(),disabled:t,style:{padding:"8px",border:"1px solid #dee3e8",borderRadius:"8px",backgroundColor:"#fff",cursor:t?"not-allowed":"pointer",color:"#6b6d6f",fontSize:"16px",lineHeight:1},children:"+"}),(0,o.jsx)("input",{ref:d,type:"file",multiple:!0,onChange:k,style:{display:"none"}})]}),(0,o.jsx)("textarea",{value:l,onChange:c=>u(c.target.value),onKeyDown:C,placeholder:s,disabled:t,rows:1,style:{flex:1,padding:"10px 14px",border:"1px solid #dee3e8",borderRadius:"20px",resize:"none",outline:"none",fontFamily:"inherit",fontSize:"16px",color:"#30373e",backgroundColor:"#f8f8f8",transition:"border-color 0.15s"},onFocus:c=>{c.currentTarget.style.borderColor="#1b5fc4"},onBlur:c=>{c.currentTarget.style.borderColor="#dee3e8"}}),(0,o.jsx)("button",{type:"submit",disabled:t||!v,style:{padding:"10px 18px",border:"none",borderRadius:"20px",backgroundColor:t||!v?"#b5bfc8":"#03182f",color:"#fff",cursor:t||!v?"not-allowed":"pointer",fontWeight:500,fontSize:"16px",transition:"background-color 0.15s"},children:"Send"})]})]})},X=({href:e,children:t,...s})=>(0,o.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"#1b5fc4",textDecoration:"underline"},...s,children:t}),Y=({children:e,...t})=>(0,o.jsx)("p",{style:{margin:"0 0 8px 0",lineHeight:"1.6"},...t,children:e}),I=(e,t)=>{const s=({children:r,...a})=>n.default.createElement(`h${e}`,{style:{margin:"16px 0 8px 0",fontSize:t,fontWeight:600,lineHeight:"1.3"},...a},r);return s.displayName=`MarkdownHeading${e}`,s},Q=({children:e,...t})=>(0,o.jsx)("ul",{style:{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:"disc",listStylePosition:"outside"},...t,children:e}),Z=({children:e,...t})=>(0,o.jsx)("ol",{style:{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:"decimal",listStylePosition:"outside"},...t,children:e}),ee=({children:e,...t})=>(0,o.jsx)("li",{style:{display:"list-item",margin:"2px 0",lineHeight:"1.6"},...t,children:e}),te=({className:e,children:t,...s})=>e!==void 0||String(t).includes(`
|
|
2
2
|
`)?(0,o.jsx)("code",{style:{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:'"IBM Plex Mono", monospace'},...s,children:t}):(0,o.jsx)("code",{style:{background:"#f0f2f5",padding:"2px 5px",borderRadius:"4px",fontSize:"13px",fontFamily:'"IBM Plex Mono", monospace'},...s,children:t}),re=({children:e,...t})=>(0,o.jsx)("pre",{style:{margin:"0 0 8px 0"},...t,children:e}),ne=({children:e,...t})=>(0,o.jsx)("blockquote",{style:{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"},...t,children:e}),oe=({children:e,...t})=>(0,o.jsx)("div",{style:{overflowX:"auto",margin:"0 0 8px 0"},children:(0,o.jsx)("table",{style:{borderCollapse:"collapse",width:"100%",fontSize:"13px"},...t,children:e})}),se=({children:e,...t})=>(0,o.jsx)("th",{style:{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:600},...t,children:e}),ae=({children:e,...t})=>(0,o.jsx)("td",{style:{border:"1px solid #dee3e8",padding:"6px 10px"},...t,children:e}),le=({alt:e,...t})=>(0,o.jsx)("img",{alt:e??"",style:{maxWidth:"100%",borderRadius:"8px",margin:"4px 0"},...t}),ie=e=>(0,o.jsx)("hr",{style:{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"},...e}),ce={a:X,p:Y,h1:I(1,"20px"),h2:I(2,"18px"),h3:I(3,"16px"),h4:I(4,"15px"),h5:I(5,"14px"),h6:I(6,"13px"),ul:Q,ol:Z,li:ee,code:te,pre:re,blockquote:ne,table:oe,th:se,td:ae,img:le,hr:ie},de=[N.default],z=({content:e})=>(0,o.jsx)(F.default,{remarkPlugins:de,components:ce,children:e}),ue=({source:e,index:t})=>{const s=(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",minWidth:0},children:[(0,o.jsx)("div",{style:{flexShrink:0,width:"18px",height:"18px",borderRadius:"3px",border:"1px solid #1b5fc4",color:"#1b5fc4",fontSize:"11px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"},children:t+1}),(0,o.jsx)("div",{style:{fontSize:"12px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#30373e"},title:e.title,children:e.title})]}),r={display:"flex",alignItems:"center",padding:"8px 10px",border:"1px solid #dee3e8",borderRadius:"8px",backgroundColor:"#fff",cursor:e.url?"pointer":"default",textDecoration:"none",color:"inherit",minWidth:0,transition:"border-color 0.15s"};return e.url?(0,o.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:r,onMouseEnter:a=>{a.currentTarget.style.borderColor="#1b5fc4"},onMouseLeave:a=>{a.currentTarget.style.borderColor="#dee3e8"},children:s}):(0,o.jsx)("div",{style:r,children:s})},fe=()=>(0,o.jsxs)("div",{style:{display:"flex",gap:"4px",padding:"4px 0"},children:[[0,1,2].map(e=>(0,o.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#b5bfc8",animation:"ago-pulse 1.2s ease-in-out infinite",animationDelay:`${e*.2}s`}},e)),(0,o.jsx)("style",{children:`
|
|
3
3
|
@keyframes ago-pulse {
|
|
4
4
|
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
|
package/dist/react.d.cts
CHANGED
|
@@ -178,6 +178,7 @@ declare class AgoClient {
|
|
|
178
178
|
* call it when their store updates so observers like the dev panel stay live.
|
|
179
179
|
*/
|
|
180
180
|
notifyContextChanged(): void;
|
|
181
|
+
/* Excluded from this release type: emitFormEvent */
|
|
181
182
|
/**
|
|
182
183
|
* Enable automatic capture of the current browser page (URL + title).
|
|
183
184
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -292,6 +293,27 @@ declare interface AgoClientEvents {
|
|
|
292
293
|
result: unknown;
|
|
293
294
|
error?: string;
|
|
294
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* A form collector submitted successfully. `result` is the raw submit response
|
|
298
|
+
* (POST body / handler return value / backend relay result) — the third-party
|
|
299
|
+
* API's answer. `values` is the submitted field set, `name` the collector name.
|
|
300
|
+
*/
|
|
301
|
+
"form:submitted": {
|
|
302
|
+
name: string;
|
|
303
|
+
values: Record<string, unknown>;
|
|
304
|
+
result: unknown;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* A form collector submit was attempted and failed at the network/server level
|
|
308
|
+
* (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
|
|
309
|
+
* pre-checks (missing required fields, no submit target) are NOT errors and do
|
|
310
|
+
* not fire this — they are returned to the caller as `{ ok: false }`.
|
|
311
|
+
*/
|
|
312
|
+
"form:error": {
|
|
313
|
+
name: string;
|
|
314
|
+
values: Record<string, unknown>;
|
|
315
|
+
error: string;
|
|
316
|
+
};
|
|
295
317
|
"connection:status": {
|
|
296
318
|
connected: boolean;
|
|
297
319
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -178,6 +178,7 @@ declare class AgoClient {
|
|
|
178
178
|
* call it when their store updates so observers like the dev panel stay live.
|
|
179
179
|
*/
|
|
180
180
|
notifyContextChanged(): void;
|
|
181
|
+
/* Excluded from this release type: emitFormEvent */
|
|
181
182
|
/**
|
|
182
183
|
* Enable automatic capture of the current browser page (URL + title).
|
|
183
184
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -292,6 +293,27 @@ declare interface AgoClientEvents {
|
|
|
292
293
|
result: unknown;
|
|
293
294
|
error?: string;
|
|
294
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* A form collector submitted successfully. `result` is the raw submit response
|
|
298
|
+
* (POST body / handler return value / backend relay result) — the third-party
|
|
299
|
+
* API's answer. `values` is the submitted field set, `name` the collector name.
|
|
300
|
+
*/
|
|
301
|
+
"form:submitted": {
|
|
302
|
+
name: string;
|
|
303
|
+
values: Record<string, unknown>;
|
|
304
|
+
result: unknown;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* A form collector submit was attempted and failed at the network/server level
|
|
308
|
+
* (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
|
|
309
|
+
* pre-checks (missing required fields, no submit target) are NOT errors and do
|
|
310
|
+
* not fire this — they are returned to the caller as `{ ok: false }`.
|
|
311
|
+
*/
|
|
312
|
+
"form:error": {
|
|
313
|
+
name: string;
|
|
314
|
+
values: Record<string, unknown>;
|
|
315
|
+
error: string;
|
|
316
|
+
};
|
|
295
317
|
"connection:status": {
|
|
296
318
|
connected: boolean;
|
|
297
319
|
};
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as J } from "./AgoClient-
|
|
2
|
-
import { i as q, n as Me, r as z, t as H } from "./createFormCollector-
|
|
1
|
+
import { t as J } from "./AgoClient-QcTtrN7u.js";
|
|
2
|
+
import { i as q, n as Me, r as z, t as H } from "./createFormCollector-QyojCH_-.js";
|
|
3
3
|
import { t as Ee } from "./createMockClient-DwdxNwEn.js";
|
|
4
4
|
import G, { createContext as V, useCallback as E, useContext as O, useEffect as S, useId as j, useMemo as F, useRef as T, useState as M, useSyncExternalStore as X } from "react";
|
|
5
5
|
import { Fragment as Y, jsx as s, jsxs as I } from "react/jsx-runtime";
|
package/dist/testing.d.cts
CHANGED
|
@@ -176,6 +176,7 @@ declare class AgoClient {
|
|
|
176
176
|
* call it when their store updates so observers like the dev panel stay live.
|
|
177
177
|
*/
|
|
178
178
|
notifyContextChanged(): void;
|
|
179
|
+
/* Excluded from this release type: emitFormEvent */
|
|
179
180
|
/**
|
|
180
181
|
* Enable automatic capture of the current browser page (URL + title).
|
|
181
182
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -290,6 +291,27 @@ declare interface AgoClientEvents {
|
|
|
290
291
|
result: unknown;
|
|
291
292
|
error?: string;
|
|
292
293
|
};
|
|
294
|
+
/**
|
|
295
|
+
* A form collector submitted successfully. `result` is the raw submit response
|
|
296
|
+
* (POST body / handler return value / backend relay result) — the third-party
|
|
297
|
+
* API's answer. `values` is the submitted field set, `name` the collector name.
|
|
298
|
+
*/
|
|
299
|
+
"form:submitted": {
|
|
300
|
+
name: string;
|
|
301
|
+
values: Record<string, unknown>;
|
|
302
|
+
result: unknown;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* A form collector submit was attempted and failed at the network/server level
|
|
306
|
+
* (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
|
|
307
|
+
* pre-checks (missing required fields, no submit target) are NOT errors and do
|
|
308
|
+
* not fire this — they are returned to the caller as `{ ok: false }`.
|
|
309
|
+
*/
|
|
310
|
+
"form:error": {
|
|
311
|
+
name: string;
|
|
312
|
+
values: Record<string, unknown>;
|
|
313
|
+
error: string;
|
|
314
|
+
};
|
|
293
315
|
"connection:status": {
|
|
294
316
|
connected: boolean;
|
|
295
317
|
};
|
package/dist/testing.d.ts
CHANGED
|
@@ -176,6 +176,7 @@ declare class AgoClient {
|
|
|
176
176
|
* call it when their store updates so observers like the dev panel stay live.
|
|
177
177
|
*/
|
|
178
178
|
notifyContextChanged(): void;
|
|
179
|
+
/* Excluded from this release type: emitFormEvent */
|
|
179
180
|
/**
|
|
180
181
|
* Enable automatic capture of the current browser page (URL + title).
|
|
181
182
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -290,6 +291,27 @@ declare interface AgoClientEvents {
|
|
|
290
291
|
result: unknown;
|
|
291
292
|
error?: string;
|
|
292
293
|
};
|
|
294
|
+
/**
|
|
295
|
+
* A form collector submitted successfully. `result` is the raw submit response
|
|
296
|
+
* (POST body / handler return value / backend relay result) — the third-party
|
|
297
|
+
* API's answer. `values` is the submitted field set, `name` the collector name.
|
|
298
|
+
*/
|
|
299
|
+
"form:submitted": {
|
|
300
|
+
name: string;
|
|
301
|
+
values: Record<string, unknown>;
|
|
302
|
+
result: unknown;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* A form collector submit was attempted and failed at the network/server level
|
|
306
|
+
* (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
|
|
307
|
+
* pre-checks (missing required fields, no submit target) are NOT errors and do
|
|
308
|
+
* not fire this — they are returned to the caller as `{ ok: false }`.
|
|
309
|
+
*/
|
|
310
|
+
"form:error": {
|
|
311
|
+
name: string;
|
|
312
|
+
values: Record<string, unknown>;
|
|
313
|
+
error: string;
|
|
314
|
+
};
|
|
293
315
|
"connection:status": {
|
|
294
316
|
connected: boolean;
|
|
295
317
|
};
|
package/dist/vue.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./rolldown-runtime-16Nf8qvH.cjs"),p=require("./AgoClient
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./rolldown-runtime-16Nf8qvH.cjs"),p=require("./AgoClient-B3-WGVne.cjs");let t=require("vue");var I=Symbol("ago-client"),y={install(o,n){const e=new p.AgoClient(n);o.provide(I,e)}};function g(o){if(o)return new p.AgoClient(o);const n=(0,t.inject)(I);if(!n)throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");return n}function E(o={}){const n=o.client??g(),e=(0,t.ref)([]),s=(0,t.ref)(o.conversationId),i=(0,t.ref)(!1),r=(0,t.ref)(null),c=a=>{s.value||(s.value=a.conversationId)},f=a=>{const u=e.value.findIndex(v=>v.id===a.messageId);u>=0&&(e.value[u]={...e.value[u],content:e.value[u].content+a.content})},m=a=>{const u=e.value.findIndex(v=>v.id===a.id);u>=0?e.value[u]=a:e.value.push(a),i.value=!1},C=a=>{r.value=new Error(a.error),i.value=!1};(0,t.onMounted)(()=>{n.on("message:start",c),n.on("message:chunk",f),n.on("message:complete",m),n.on("message:error",C)}),(0,t.onUnmounted)(()=>{n.off("message:start",c),n.off("message:chunk",f),n.off("message:complete",m),n.off("message:error",C)});async function d(a,u){i.value=!0,r.value=null;const v={id:`temp-${Date.now()}`,conversationId:s.value||"",content:a,role:"user",status:"DONE",createdAt:new Date},L={id:`temp-assistant-${Date.now()}`,conversationId:s.value||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};e.value.push(v,L);try{const l=await n.sendMessage(a,{conversationId:s.value,files:u});l.conversationId&&!s.value&&(s.value=l.conversationId),e.value=e.value.filter(w=>!w.id.startsWith("temp-"));const A={...v,id:v.id.replace("temp-","user-"),conversationId:l.conversationId};return e.value.some(w=>w.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"),i.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:i,error:r,conversationId:s,sendMessage:d,clearMessages:h}}function M(o={}){const n=o.client??g(),e=o.autoLoad??!0,s=(0,t.ref)([]),i=(0,t.ref)(null),r=(0,t.ref)(!1),c=(0,t.ref)(null);async function f(){r.value=!0,c.value=null;try{s.value=await n.getConversations()}catch(d){c.value=d instanceof Error?d:new Error("Failed to load conversations")}finally{r.value=!1}}async function m(d){r.value=!0,c.value=null;try{i.value=await n.getConversation(d)}catch(h){c.value=h instanceof Error?h:new Error("Failed to load conversation")}finally{r.value=!1}}function C(){i.value=null}return(0,t.onMounted)(()=>{e&&f()}),{conversations:s,currentConversation:i,isLoading:r,error:c,selectConversation:m,startNewConversation:C,refreshConversations:f}}function N(o={}){const n=E({client:o.client,conversationId:o.conversationId}),e=M({client:o.client,autoLoad:o.autoLoad}),s=(0,t.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 F(o,n){const e=g();(0,t.onMounted)(()=>{e.registerFunction(o,n.handler,{description:n.description,parameters:n.parameters})}),(0,t.onUnmounted)(()=>{e.unregisterFunction(o)})}function S(o,n){const e=g();(0,t.onMounted)(()=>{e.registerNavigationFunction(o,n)}),(0,t.onUnmounted)(()=>{e.unregisterFunction("navigateToPage")})}function _(o,n){const e=g();(0,t.onMounted)(()=>{e.on(o,n)}),(0,t.onUnmounted)(()=>{e.off(o,n)})}function D(o){const n=(0,t.shallowRef)(o.get());return(0,t.onScopeDispose)(o.subscribe(e=>{n.value=e})),n}exports.AGO_CLIENT_KEY=I;exports.AgoPlugin=y;exports.useAgo=g;exports.useAgoEvents=_;exports.useAgoFunction=F;exports.useAgoNavigation=S;exports.useAgoStore=D;exports.useChat=N;exports.useConversation=M;exports.useMessages=E;
|