@useago/sdk 1.0.6 → 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/README.md +53 -0
- 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 +24 -0
- package/dist/angular.d.ts +24 -0
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-lJWANT6T.cjs → createConversationSession-BwYNMZWq.cjs} +1 -1
- package/dist/{createConversationSession-Boi0PjDU.js → createConversationSession-DrCMdwkV.js} +1 -1
- package/dist/createFormCollector-BHHEW6uX.cjs +1 -0
- package/dist/createFormCollector-QyojCH_-.js +297 -0
- package/dist/devtools.d.cts +24 -0
- package/dist/devtools.d.ts +24 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +58 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +53 -45
- package/dist/react.cjs +2 -2
- package/dist/react.d.cts +41 -0
- package/dist/react.d.ts +41 -0
- package/dist/react.js +43 -41
- package/dist/testing.d.cts +24 -0
- package/dist/testing.d.ts +24 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +24 -0
- package/dist/vue.d.ts +24 -0
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +63 -0
- package/dist/widget.d.ts +63 -0
- package/dist/widget.js +362 -310
- package/package.json +1 -1
- package/dist/createFormCollector-BUqSA2Qw.js +0 -257
- package/dist/createFormCollector-CSG5ioym.cjs +0 -1
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
|
};
|
|
@@ -591,6 +613,16 @@ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>>
|
|
|
591
613
|
submit?: SubmitConfig<V>;
|
|
592
614
|
/** Pre-filled values. */
|
|
593
615
|
initialValues?: Partial<V>;
|
|
616
|
+
/**
|
|
617
|
+
* Submit on its own as soon as every required field is filled, without waiting
|
|
618
|
+
* for the agent or a UI button. The form submits at most once. Defaults to
|
|
619
|
+
* `true` whenever a `submit` target is set: when on, no `submit_<name>` function
|
|
620
|
+
* is exposed, the form submits itself, and the agent never confirms a submit.
|
|
621
|
+
* Pass `autoSubmit: false` to keep the manual flow (expose `submit_<name>` and
|
|
622
|
+
* submit only on an explicit call). Has no effect on a collect-only form (no
|
|
623
|
+
* `submit` target); setting it `true` there is ignored with a warning.
|
|
624
|
+
*/
|
|
625
|
+
autoSubmit?: boolean;
|
|
594
626
|
}
|
|
595
627
|
|
|
596
628
|
/**
|
|
@@ -667,6 +699,8 @@ export declare interface FormCollectorDefinition<V = Record<string, unknown>> {
|
|
|
667
699
|
schema: FormCollectorSchema;
|
|
668
700
|
/** Server-stored submit target, if any. Absent means collect-only. */
|
|
669
701
|
submit?: SubmitConfig<V>;
|
|
702
|
+
/** Server-stored default for auto-submitting once the form is complete. */
|
|
703
|
+
autoSubmit?: boolean;
|
|
670
704
|
}
|
|
671
705
|
|
|
672
706
|
/**
|
|
@@ -685,6 +719,13 @@ export declare interface FormCollectorState<V = Record<string, unknown>> {
|
|
|
685
719
|
values: Partial<V>;
|
|
686
720
|
/** True once a submit succeeded. */
|
|
687
721
|
submitted: boolean;
|
|
722
|
+
/**
|
|
723
|
+
* The submit response, set once `submitted` is true: the resolved value of the
|
|
724
|
+
* client `handler`, the parsed JSON of a client `url` POST, or the backend
|
|
725
|
+
* relay result. Lets a UI surface a server-returned message. Undefined until
|
|
726
|
+
* a submit succeeds (and after `reset()`).
|
|
727
|
+
*/
|
|
728
|
+
submitResult?: unknown;
|
|
688
729
|
}
|
|
689
730
|
|
|
690
731
|
/** Completeness status derived from values + schema — computed on read, never stored. */
|
package/dist/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
import G, { createContext as V, useCallback as E, useContext as O, useEffect as
|
|
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";
|
|
6
6
|
import Q from "react-markdown";
|
|
7
7
|
import Z from "remark-gfm";
|
|
@@ -11,9 +11,9 @@ function ee(e) {
|
|
|
11
11
|
const a = new J(e);
|
|
12
12
|
return n.current = a, a;
|
|
13
13
|
}, [e?.baseUrl, e?.widgetId]);
|
|
14
|
-
return
|
|
14
|
+
return S(() => (r(!0), () => {
|
|
15
15
|
n.current?.destroy(), n.current = null;
|
|
16
|
-
}), [o]),
|
|
16
|
+
}), [o]), S(() => {
|
|
17
17
|
n.current && e && n.current.updateConfig({
|
|
18
18
|
agent: e.agent,
|
|
19
19
|
defaultAgentId: e.defaultAgentId,
|
|
@@ -38,25 +38,25 @@ function ee(e) {
|
|
|
38
38
|
}
|
|
39
39
|
var D = V(null), Te = ({ children: e, client: t, tools: r, helpers: n, pageContext: o, ...a }) => {
|
|
40
40
|
const { client: d } = ee(t ? null : a), i = t || d;
|
|
41
|
-
return
|
|
41
|
+
return S(() => {
|
|
42
42
|
if (!(!r || r.length === 0)) {
|
|
43
43
|
for (const f of r) i.register(f);
|
|
44
44
|
return () => {
|
|
45
45
|
for (const f of r) i.unregisterFunction(f.name);
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
}, [i, r]),
|
|
48
|
+
}, [i, r]), S(() => {
|
|
49
49
|
if (!n) return;
|
|
50
50
|
const f = [];
|
|
51
51
|
return import("./functions-CApuQZ2b.js").then((c) => c.n).then((c) => {
|
|
52
52
|
for (const [x, v] of Object.entries(n)) {
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
53
|
+
const k = c[x];
|
|
54
|
+
if (!k) {
|
|
55
55
|
console.warn(`[AGO] Unknown helper: "${x}"`);
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
|
-
const m = v === !0 ?
|
|
59
|
-
...
|
|
58
|
+
const m = v === !0 ? k : {
|
|
59
|
+
...k,
|
|
60
60
|
handler: v
|
|
61
61
|
};
|
|
62
62
|
i.register(m), f.push(m.name);
|
|
@@ -64,7 +64,7 @@ var D = V(null), Te = ({ children: e, client: t, tools: r, helpers: n, pageConte
|
|
|
64
64
|
}), () => {
|
|
65
65
|
for (const c of f) i.unregisterFunction(c);
|
|
66
66
|
};
|
|
67
|
-
}, [i, n]),
|
|
67
|
+
}, [i, n]), S(() => {
|
|
68
68
|
o === "auto" && i.enableAutoPageContext();
|
|
69
69
|
}, [i, o]), /* @__PURE__ */ s(D.Provider, {
|
|
70
70
|
value: i,
|
|
@@ -83,17 +83,17 @@ function $({ client: e, conversationId: t } = {}) {
|
|
|
83
83
|
const r = L(), n = e || r;
|
|
84
84
|
if (!n) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
85
85
|
const [o, a] = M([]), [d, i] = M(t), [f, c] = M(!1), [x, v] = M(null);
|
|
86
|
-
|
|
87
|
-
t && t !== d && (i(t),
|
|
86
|
+
S(() => {
|
|
87
|
+
t && t !== d && (i(t), k(t));
|
|
88
88
|
}, [t]);
|
|
89
|
-
const
|
|
89
|
+
const k = async (m) => {
|
|
90
90
|
try {
|
|
91
91
|
a(await n.getMessages(m));
|
|
92
92
|
} catch (b) {
|
|
93
93
|
v(b instanceof Error ? b : /* @__PURE__ */ new Error("Failed to load messages"));
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
return
|
|
96
|
+
return S(() => {
|
|
97
97
|
const m = (g) => {
|
|
98
98
|
d || i(g.conversationId);
|
|
99
99
|
}, b = (g) => {
|
|
@@ -197,7 +197,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
197
197
|
e
|
|
198
198
|
]), v = E((l) => {
|
|
199
199
|
l.key === "Enter" && !l.shiftKey && (l.preventDefault(), x(l));
|
|
200
|
-
}, [x]),
|
|
200
|
+
}, [x]), k = E((l) => {
|
|
201
201
|
const h = Array.from(l.target.files || []);
|
|
202
202
|
f((p) => [...p, ...h]);
|
|
203
203
|
}, []), m = E((l) => {
|
|
@@ -281,7 +281,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
281
281
|
ref: c,
|
|
282
282
|
type: "file",
|
|
283
283
|
multiple: !0,
|
|
284
|
-
onChange:
|
|
284
|
+
onChange: k,
|
|
285
285
|
style: { display: "none" }
|
|
286
286
|
})] }),
|
|
287
287
|
/* @__PURE__ */ s("textarea", {
|
|
@@ -299,7 +299,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
299
299
|
resize: "none",
|
|
300
300
|
outline: "none",
|
|
301
301
|
fontFamily: "inherit",
|
|
302
|
-
fontSize: "
|
|
302
|
+
fontSize: "16px",
|
|
303
303
|
color: "#30373e",
|
|
304
304
|
backgroundColor: "#f8f8f8",
|
|
305
305
|
transition: "border-color 0.15s"
|
|
@@ -322,7 +322,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
322
322
|
color: "#fff",
|
|
323
323
|
cursor: t || !b ? "not-allowed" : "pointer",
|
|
324
324
|
fontWeight: 500,
|
|
325
|
-
fontSize: "
|
|
325
|
+
fontSize: "16px",
|
|
326
326
|
transition: "background-color 0.15s"
|
|
327
327
|
},
|
|
328
328
|
children: "Send"
|
|
@@ -628,7 +628,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
628
628
|
backgroundColor: a ? "#03182f" : "transparent",
|
|
629
629
|
color: a ? "#fff" : "#30373e",
|
|
630
630
|
wordBreak: "break-word",
|
|
631
|
-
fontSize: "
|
|
631
|
+
fontSize: "16px",
|
|
632
632
|
lineHeight: "1.6"
|
|
633
633
|
},
|
|
634
634
|
children: e.content ? /* @__PURE__ */ s(he, { content: e.content }) : d && /* @__PURE__ */ s(be, {})
|
|
@@ -667,12 +667,12 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
667
667
|
})
|
|
668
668
|
]
|
|
669
669
|
});
|
|
670
|
-
}, _e = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: o = "Type a message...", allowFiles: a = !1, height: d = 500, logoUrl: i, showAgentName: f = !1, forms: c, onFollowUpClick: x, className: v = "", onMessageSent:
|
|
670
|
+
}, _e = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: o = "Type a message...", allowFiles: a = !1, height: d = 500, logoUrl: i, showAgentName: f = !1, forms: c, onFollowUpClick: x, className: v = "", onMessageSent: k, onMessageReceived: m }) => {
|
|
671
671
|
const b = T(null), l = L(), h = e ?? l, { messages: p, isLoading: g, error: u, sendMessage: w } = $({
|
|
672
672
|
client: e,
|
|
673
673
|
conversationId: t
|
|
674
674
|
});
|
|
675
|
-
|
|
675
|
+
S(() => {
|
|
676
676
|
if (!h || !c || c.length === 0) return;
|
|
677
677
|
let y = !1;
|
|
678
678
|
const A = [];
|
|
@@ -688,9 +688,9 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
688
688
|
y.schema ?? null,
|
|
689
689
|
y.submit ?? !1,
|
|
690
690
|
y.description ?? null
|
|
691
|
-
])) : ""]),
|
|
691
|
+
])) : ""]), S(() => {
|
|
692
692
|
b.current?.scrollIntoView({ behavior: "smooth" });
|
|
693
|
-
}, [p]),
|
|
693
|
+
}, [p]), S(() => {
|
|
694
694
|
const y = p[p.length - 1];
|
|
695
695
|
y && y.role === "assistant" && y.status === "DONE" && m && m({
|
|
696
696
|
id: y.id,
|
|
@@ -698,7 +698,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
698
698
|
});
|
|
699
699
|
}, [p, m]);
|
|
700
700
|
const C = async (y, A) => {
|
|
701
|
-
|
|
701
|
+
k?.(y), await w(y, A);
|
|
702
702
|
}, _ = p[p.length - 1], B = g && _?.role === "assistant" && _.status === "IN_PROGRESS", K = x === !1 ? void 0 : x ?? ((y) => C(y));
|
|
703
703
|
return /* @__PURE__ */ I("div", {
|
|
704
704
|
className: `ago-chat-widget ${v}`,
|
|
@@ -756,7 +756,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
756
756
|
textAlign: "center",
|
|
757
757
|
color: "#6b6d6f",
|
|
758
758
|
padding: "24px 16px",
|
|
759
|
-
fontSize: "
|
|
759
|
+
fontSize: "16px",
|
|
760
760
|
lineHeight: "1.5"
|
|
761
761
|
},
|
|
762
762
|
children: n
|
|
@@ -793,7 +793,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
793
793
|
function we({ client: e, autoLoad: t = !0 } = {}) {
|
|
794
794
|
const r = L(), n = e || r;
|
|
795
795
|
if (!n) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
796
|
-
const [o, a] = M([]), [d, i] = M(null), [f, c] = M(!1), [x, v] = M(null),
|
|
796
|
+
const [o, a] = M([]), [d, i] = M(null), [f, c] = M(!1), [x, v] = M(null), k = E(async () => {
|
|
797
797
|
c(!0), v(null);
|
|
798
798
|
try {
|
|
799
799
|
a(await n.getConversations());
|
|
@@ -814,16 +814,16 @@ function we({ client: e, autoLoad: t = !0 } = {}) {
|
|
|
814
814
|
}, [n]), b = E(() => {
|
|
815
815
|
i(null);
|
|
816
816
|
}, []);
|
|
817
|
-
return
|
|
818
|
-
t &&
|
|
819
|
-
}, [t,
|
|
817
|
+
return S(() => {
|
|
818
|
+
t && k();
|
|
819
|
+
}, [t, k]), {
|
|
820
820
|
conversations: o,
|
|
821
821
|
currentConversation: d,
|
|
822
822
|
isLoading: f,
|
|
823
823
|
error: x,
|
|
824
824
|
selectConversation: m,
|
|
825
825
|
startNewConversation: b,
|
|
826
|
-
refreshConversations:
|
|
826
|
+
refreshConversations: k
|
|
827
827
|
};
|
|
828
828
|
}
|
|
829
829
|
function Pe(e = {}) {
|
|
@@ -856,7 +856,7 @@ function Le(e, t) {
|
|
|
856
856
|
name: e,
|
|
857
857
|
...t
|
|
858
858
|
} : e, i = T(d);
|
|
859
|
-
i.current = d,
|
|
859
|
+
i.current = d, S(() => {
|
|
860
860
|
const f = (c) => i.current(c);
|
|
861
861
|
return r.registerFunction(n, f, {
|
|
862
862
|
description: o,
|
|
@@ -873,7 +873,7 @@ function Le(e, t) {
|
|
|
873
873
|
}
|
|
874
874
|
function De(e, t) {
|
|
875
875
|
const r = P(), n = T(e);
|
|
876
|
-
n.current = e,
|
|
876
|
+
n.current = e, S(() => (r.registerNavigationFunction((o) => n.current(o), t), () => {
|
|
877
877
|
r.unregisterFunction("navigateToPage");
|
|
878
878
|
}), [r, t]);
|
|
879
879
|
}
|
|
@@ -881,7 +881,7 @@ function We(e, t) {
|
|
|
881
881
|
const r = P(), n = j(), o = t ?? n, a = T(e);
|
|
882
882
|
a.current = e;
|
|
883
883
|
const d = typeof e == "function";
|
|
884
|
-
|
|
884
|
+
S(() => {
|
|
885
885
|
if (typeof a.current == "function") {
|
|
886
886
|
const i = () => a.current();
|
|
887
887
|
return r.addDynamicContext(o, i), () => {
|
|
@@ -911,13 +911,14 @@ function ze(e) {
|
|
|
911
911
|
e.name,
|
|
912
912
|
n,
|
|
913
913
|
a,
|
|
914
|
-
d
|
|
914
|
+
d,
|
|
915
|
+
e.autoSubmit
|
|
915
916
|
]), [f, c] = M({
|
|
916
917
|
collector: null,
|
|
917
918
|
loading: !r,
|
|
918
919
|
error: null
|
|
919
920
|
});
|
|
920
|
-
|
|
921
|
+
S(() => {
|
|
921
922
|
if (r) return;
|
|
922
923
|
let g = !1;
|
|
923
924
|
return c({
|
|
@@ -944,10 +945,11 @@ function ze(e) {
|
|
|
944
945
|
r,
|
|
945
946
|
e.name,
|
|
946
947
|
a,
|
|
947
|
-
d
|
|
948
|
+
d,
|
|
949
|
+
e.autoSubmit
|
|
948
950
|
]);
|
|
949
|
-
const x = r ? i : f.collector, v = r ? !1 : f.loading,
|
|
950
|
-
|
|
951
|
+
const x = r ? i : f.collector, v = r ? !1 : f.loading, k = r ? null : f.error;
|
|
952
|
+
S(() => {
|
|
951
953
|
if (x)
|
|
952
954
|
return x.install(t);
|
|
953
955
|
}, [t, x]);
|
|
@@ -985,7 +987,7 @@ function ze(e) {
|
|
|
985
987
|
...x ?? p,
|
|
986
988
|
state: h,
|
|
987
989
|
loading: v,
|
|
988
|
-
error:
|
|
990
|
+
error: k
|
|
989
991
|
};
|
|
990
992
|
}
|
|
991
993
|
export {
|
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
|
};
|
|
@@ -468,6 +490,8 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
|
|
|
468
490
|
schema: FormCollectorSchema;
|
|
469
491
|
/** Server-stored submit target, if any. Absent means collect-only. */
|
|
470
492
|
submit?: SubmitConfig<V>;
|
|
493
|
+
/** Server-stored default for auto-submitting once the form is complete. */
|
|
494
|
+
autoSubmit?: boolean;
|
|
471
495
|
}
|
|
472
496
|
|
|
473
497
|
/**
|
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
|
};
|
|
@@ -468,6 +490,8 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
|
|
|
468
490
|
schema: FormCollectorSchema;
|
|
469
491
|
/** Server-stored submit target, if any. Absent means collect-only. */
|
|
470
492
|
submit?: SubmitConfig<V>;
|
|
493
|
+
/** Server-stored default for auto-submitting once the form is complete. */
|
|
494
|
+
autoSubmit?: boolean;
|
|
471
495
|
}
|
|
472
496
|
|
|
473
497
|
/**
|
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;
|
package/dist/vue.d.cts
CHANGED
|
@@ -184,6 +184,7 @@ declare class AgoClient {
|
|
|
184
184
|
* call it when their store updates so observers like the dev panel stay live.
|
|
185
185
|
*/
|
|
186
186
|
notifyContextChanged(): void;
|
|
187
|
+
/* Excluded from this release type: emitFormEvent */
|
|
187
188
|
/**
|
|
188
189
|
* Enable automatic capture of the current browser page (URL + title).
|
|
189
190
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -298,6 +299,27 @@ declare interface AgoClientEvents {
|
|
|
298
299
|
result: unknown;
|
|
299
300
|
error?: string;
|
|
300
301
|
};
|
|
302
|
+
/**
|
|
303
|
+
* A form collector submitted successfully. `result` is the raw submit response
|
|
304
|
+
* (POST body / handler return value / backend relay result) — the third-party
|
|
305
|
+
* API's answer. `values` is the submitted field set, `name` the collector name.
|
|
306
|
+
*/
|
|
307
|
+
"form:submitted": {
|
|
308
|
+
name: string;
|
|
309
|
+
values: Record<string, unknown>;
|
|
310
|
+
result: unknown;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* A form collector submit was attempted and failed at the network/server level
|
|
314
|
+
* (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
|
|
315
|
+
* pre-checks (missing required fields, no submit target) are NOT errors and do
|
|
316
|
+
* not fire this — they are returned to the caller as `{ ok: false }`.
|
|
317
|
+
*/
|
|
318
|
+
"form:error": {
|
|
319
|
+
name: string;
|
|
320
|
+
values: Record<string, unknown>;
|
|
321
|
+
error: string;
|
|
322
|
+
};
|
|
301
323
|
"connection:status": {
|
|
302
324
|
connected: boolean;
|
|
303
325
|
};
|
|
@@ -484,6 +506,8 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
|
|
|
484
506
|
schema: FormCollectorSchema;
|
|
485
507
|
/** Server-stored submit target, if any. Absent means collect-only. */
|
|
486
508
|
submit?: SubmitConfig<V>;
|
|
509
|
+
/** Server-stored default for auto-submitting once the form is complete. */
|
|
510
|
+
autoSubmit?: boolean;
|
|
487
511
|
}
|
|
488
512
|
|
|
489
513
|
/**
|
package/dist/vue.d.ts
CHANGED
|
@@ -184,6 +184,7 @@ declare class AgoClient {
|
|
|
184
184
|
* call it when their store updates so observers like the dev panel stay live.
|
|
185
185
|
*/
|
|
186
186
|
notifyContextChanged(): void;
|
|
187
|
+
/* Excluded from this release type: emitFormEvent */
|
|
187
188
|
/**
|
|
188
189
|
* Enable automatic capture of the current browser page (URL + title).
|
|
189
190
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -298,6 +299,27 @@ declare interface AgoClientEvents {
|
|
|
298
299
|
result: unknown;
|
|
299
300
|
error?: string;
|
|
300
301
|
};
|
|
302
|
+
/**
|
|
303
|
+
* A form collector submitted successfully. `result` is the raw submit response
|
|
304
|
+
* (POST body / handler return value / backend relay result) — the third-party
|
|
305
|
+
* API's answer. `values` is the submitted field set, `name` the collector name.
|
|
306
|
+
*/
|
|
307
|
+
"form:submitted": {
|
|
308
|
+
name: string;
|
|
309
|
+
values: Record<string, unknown>;
|
|
310
|
+
result: unknown;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* A form collector submit was attempted and failed at the network/server level
|
|
314
|
+
* (HTTP non-2xx, or a thrown handler/fetch). `error` is the message. Validation
|
|
315
|
+
* pre-checks (missing required fields, no submit target) are NOT errors and do
|
|
316
|
+
* not fire this — they are returned to the caller as `{ ok: false }`.
|
|
317
|
+
*/
|
|
318
|
+
"form:error": {
|
|
319
|
+
name: string;
|
|
320
|
+
values: Record<string, unknown>;
|
|
321
|
+
error: string;
|
|
322
|
+
};
|
|
301
323
|
"connection:status": {
|
|
302
324
|
connected: boolean;
|
|
303
325
|
};
|
|
@@ -484,6 +506,8 @@ declare interface FormCollectorDefinition<V = Record<string, unknown>> {
|
|
|
484
506
|
schema: FormCollectorSchema;
|
|
485
507
|
/** Server-stored submit target, if any. Absent means collect-only. */
|
|
486
508
|
submit?: SubmitConfig<V>;
|
|
509
|
+
/** Server-stored default for auto-submitting once the form is complete. */
|
|
510
|
+
autoSubmit?: boolean;
|
|
487
511
|
}
|
|
488
512
|
|
|
489
513
|
/**
|
package/dist/vue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as A } from "./AgoClient-
|
|
1
|
+
import { t as A } from "./AgoClient-QcTtrN7u.js";
|
|
2
2
|
import { computed as y, inject as F, onMounted as g, onScopeDispose as N, onUnmounted as I, ref as c, shallowRef as D } from "vue";
|
|
3
3
|
var L = /* @__PURE__ */ Symbol("ago-client"), b = { install(t, n) {
|
|
4
4
|
const e = new A(n);
|