@useago/sdk 1.5.2 → 1.5.3
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-BGkFSNZF.cjs +8 -0
- package/dist/AgoClient-CW-BLT1_.js +1542 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +311 -0
- package/dist/angular.d.ts +311 -0
- package/dist/angular.js +2 -2
- package/dist/createConversationSession-BCb0D6bt.cjs +1 -0
- package/dist/{createConversationSession-DPrrr70o.js → createConversationSession-C7cnnWKW.js} +3 -3
- package/dist/createFormCollector-iCDwAwYJ.js +279 -0
- package/dist/createFormCollector-t_fGyuTD.cjs +1 -0
- package/dist/createMockClient-Br0TWgLO.js +97 -0
- package/dist/createMockClient-BwNLPjeT.cjs +1 -0
- package/dist/devtools.d.cts +311 -0
- package/dist/devtools.d.ts +311 -0
- package/dist/functions-IGSjjvF4.cjs +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +510 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +95 -90
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +375 -0
- package/dist/react.d.ts +375 -0
- package/dist/react.js +559 -422
- package/dist/rolldown-runtime-16Nf8qvH.cjs +1 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +311 -0
- package/dist/testing.d.ts +311 -0
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +332 -0
- package/dist/vue.d.ts +332 -0
- package/dist/vue.js +133 -110
- package/dist/widget.cjs +1 -1
- package/dist/widget.d.cts +308 -0
- package/dist/widget.d.ts +308 -0
- package/dist/widget.js +7 -7
- package/package.json +1 -1
- package/dist/AgoClient-5VGybmvz.cjs +0 -8
- package/dist/AgoClient-DXrH2AMi.js +0 -964
- package/dist/createConversationSession-0WTqcCLK.cjs +0 -1
- package/dist/createFormCollector-1GKKwQV_.cjs +0 -1
- package/dist/createFormCollector-DYh90kiG.js +0 -305
- package/dist/createMockClient-C-wrjb2C.cjs +0 -1
- package/dist/createMockClient-we-XoPom.js +0 -79
- package/dist/functions-CPs7omgM.cjs +0 -1
- /package/dist/{autoContinue-CP9pJR-V.cjs → autoContinue-CcCTva-D.cjs} +0 -0
- /package/dist/{autoContinue-CC8K9mBU.js → autoContinue-D3Mmaaca.js} +0 -0
- /package/dist/{functions-tzyOZNp6.js → functions-CApuQZ2b.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const d=require("./createFormCollector-1GKKwQV_.cjs");var f="ago_widget_id",g="ago_last_thread",y=7200*1e3;function v(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.floor(Math.random()*16);return(e==="x"?r:r&3|8).toString(16)})}function _(e={}){const r=e.key??f,i=e.threadKey??g,u=e.ttlMs??y,l=e.storage??(typeof localStorage<"u"?localStorage:void 0);let n=e.widgetId??"";if(!n&&l)try{n=l.getItem(r)??""}catch{}if(n||(n=v()),l)try{l.setItem(r,n)}catch{}const o=d.createStore({value:null,lastMessageAt:null},{key:i,storage:l}),c=o.get();c.value!==null&&s(c.lastMessageAt)&&o.set({value:null,lastMessageAt:null});function s(t){return t===null?!0:Number.isFinite(u)?Date.now()-t>u:!1}return{widgetId:n,key:r,getLastActiveThread(){const{value:t,lastMessageAt:a}=o.get();return t===null||s(a)?null:t},setActiveThread(t,a){const x=a==null?null:a instanceof Date?a.getTime():a;o.set({value:t,lastMessageAt:x})},clear(){o.set({value:null,lastMessageAt:null})}}}Object.defineProperty(exports,"createConversationSession",{enumerable:!0,get:function(){return _}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const w=require("./AgoClient-5VGybmvz.cjs");function A(n,e){const a=e?e.storage??(typeof localStorage<"u"?localStorage:void 0):void 0;let o=n;if(e&&a)try{const m=a.getItem(e.key);m!=null&&(o=JSON.parse(m))}catch{}const s=new Set,c=()=>s.forEach(m=>m(o));function b(){if(e&&a)try{a.setItem(e.key,JSON.stringify(o))}catch{}}return{get:()=>o,set:m=>{o=m,b(),c()},subscribe:m=>(s.add(m),()=>{s.delete(m)})}}var W=/^[a-zA-Z0-9_-]{1,40}$/,I=n=>n==null||n==="";function C(n,e){if("anyOf"in n)return n.anyOf.some(c=>C(c,e));if("allOf"in n)return n.allOf.every(c=>C(c,e));const a=e[n.property];if(I(a))return!1;if(Array.isArray(n.value))return n.value.some(c=>String(a)===String(c));if(!n.op)return String(a)===String(n.value);const o=Number(a),s=Number(n.value);if(Number.isNaN(o)||Number.isNaN(s))return!1;switch(n.op){case">=":return o>=s;case"<=":return o<=s;case">":return o>s;case"<":return o<s;default:return w.logger.warn(`Unknown requiredWhen op "${n.op}"; treating as not required.`),!1}}function y(n,e){const a=n.properties??{},o=new Set;for(const c of n.required??[]){const b=a[c]?.requiredWhen;(!b||C(b,e))&&o.add(c)}for(const[c,b]of Object.entries(a))b.requiredWhen&&C(b.requiredWhen,e)&&o.add(c);const s=[...o].filter(c=>I(e[c]));return{missing:s,complete:s.length===0}}function B(n){const e={};for(const[a,o]of Object.entries(n.properties??{}))e[a]={type:o.type,...o.description!=null&&{description:o.description},...o.enum&&{enum:o.enum},...o.default!==void 0&&{default:o.default}};return{type:"object",properties:e,required:[]}}function V(n){const{name:e,description:a,schema:o}=n;if(!W.test(e))throw new Error(`Invalid form collector name "${e}": must match ${W} (it becomes the update_/submit_ function names).`);const s=typeof n.submit=="string"?n.submit?{via:"client",url:n.submit}:!1:n.submit??!1;n.autoSubmit===!0&&!s&&w.logger.warn(`FormCollector "${e}": autoSubmit is ignored because no submit target is configured.`);const c=(n.autoSubmit??!0)&&!!s,b=o.properties??{},m=t=>{const r={};for(const[u,i]of Object.entries(t)){const l=b[u];if(l)if(i==null)r[u]=i;else if(l.type==="number"||l.type==="integer"){const d=typeof i=="number"?i:Number(i);r[u]=Number.isNaN(d)?i:d}else l.type==="boolean"?r[u]=typeof i=="boolean"?i:i==="true"?!0:i==="false"?!1:!!i:r[u]=i}return r},N=n.initialValues??{},f=A({values:N,submitted:!1}),F=t=>{const r=f.get(),u={...r,values:{...r.values,...t}};return f.set(u),u};let h=null;const k=(t,r)=>{h?.emitFormEvent("form:error",{name:e,values:t,error:r})};let g=null;const D=async()=>{const{values:t}=f.get(),{complete:r,missing:u}=y(o,t);if(!r)return{ok:!1,missing:u};if(!s)return{ok:!1,error:"No submit target configured for this form collector."};const i=t;try{let l;if(s.via==="client")if("handler"in s)l=await s.handler(i);else{const d=await fetch(s.url,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(i)});if(!d.ok){const j=`Submit failed: HTTP ${d.status}`;return k(i,j),{ok:!1,error:j}}l=await d.json().catch(()=>{})}else{if(!h)return{ok:!1,error:"Backend submit requires install(client) (or useFormCollector) first."};l=await h.submitFormCollector(e,i)}return f.set({...f.get(),submitted:!0,submitResult:l}),h?.emitFormEvent("form:submitted",{name:e,values:i,result:l}),{ok:!0,result:l}}catch(l){const d=l instanceof Error?l.message:"Submit failed";return w.logger.error(`FormCollector "${e}" submit failed:`,l),k(i,d),{ok:!1,error:d}}},$=()=>g||(g=(async()=>{try{return await D()}finally{g=null}})(),g),q=async()=>{if(!c||!s)return null;const{values:t,submitted:r}=f.get();return r||!y(o,t).complete?null:$()},O={name:`update_${e}`,description:`Fill or update fields of the "${e}" form. ${a} Pass any subset of fields; call it repeatedly to fill the form as the user provides information. Returns the current values and which required fields are still missing.`,parameters:B(o),handler:async t=>{const r=F(m(t)),{missing:u}=y(o,r.values),i=await q();return i?i.ok?{ok:!0,values:r.values,missing:u,submitted:!0}:{ok:!0,values:r.values,missing:u,submitted:!1,submitError:i.error}:{ok:!0,values:r.values,missing:u}}},p=[O];s&&!c&&p.push({name:`submit_${e}`,description:`Submit the completed "${e}" form. Only call this once every required field is collected and the user has confirmed. If fields are missing it returns them instead of submitting.`,parameters:{type:"object",properties:{}},handler:()=>$()});const J="client__",_=s?`submit_${e}`:null,R=t=>{const r=t.functionName??t.toolName;if(r)return r.startsWith(J)?r.slice(8):r},P=t=>{let r={...N},u=!1;for(const i of t){const l=R(i);l===O.name?i.arguments&&(r={...r,...m(i.arguments)}):_&&l===_&&i.status?.toLowerCase()==="done"&&(u=!0)}f.set({values:r,submitted:u})},v=`form:${e}`,S=`${v}:definition`,x=()=>({name:`Form definition: ${e}`,description:`${a} Some fields are conditionally required; the requiredWhen field in the schema tells you when each becomes required. The form schema is the following: ${JSON.stringify(o)}.`,stable:!0}),E=()=>{const{values:t,submitted:r}=f.get(),{missing:u,complete:i}=y(o,t),l=s?c?" The form is submitted automatically as soon as every required field is filled, so there is no submit function to call.":` When nothing is missing and the user confirms, call submit_${e}.`:"",d=r?`The "${e}" form has been submitted.`:`You are currently collecting information from the user to fill the "${e}" form.`;return{name:`Form: ${e}`,description:`${d} The form's schema and field requirements are in the "${S}" client context. Call update_${e} with any fields the user provides; ask only for what is still missing.${l}`,data:{values:t,missing:u,complete:i,submitted:r}}},T=t=>{P((t.messages??[]).flatMap(r=>r.toolCalls??[]))};return{name:e,store:f,functions:p,contextKey:v,contextProvider:E,definitionContextKey:S,definitionContextProvider:x,install:t=>{h=t;for(const u of p)t.register(u);t.addDynamicContext(S,x),t.addDynamicContext(v,E);const r=f.subscribe(()=>t.notifyContextChanged());return t.on("conversation:loaded",T),()=>{r();for(const u of p)t.unregisterFunction(u.name);t.removeDynamicContext(v),t.removeDynamicContext(S),t.off("conversation:loaded",T),h===t&&(h=null)}},hydrate:P,submit:$,getValues:()=>f.get().values,setValues:t=>{F(m(t)),q()},reset:()=>{f.set({values:N,submitted:!1})},getStatus:()=>y(o,f.get().values)}}async function L(n,e){const a=await n.getFormCollector(e.name);return V({name:a.name,description:e.description??a.description,schema:e.schema??a.schema,submit:e.submit??a.submit,initialValues:e.initialValues,autoSubmit:e.autoSubmit??a.autoSubmit})}Object.defineProperty(exports,"createFormCollector",{enumerable:!0,get:function(){return V}});Object.defineProperty(exports,"createStore",{enumerable:!0,get:function(){return A}});Object.defineProperty(exports,"deriveFormStatus",{enumerable:!0,get:function(){return y}});Object.defineProperty(exports,"loadFormCollector",{enumerable:!0,get:function(){return L}});
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import { f as w } from "./AgoClient-DXrH2AMi.js";
|
|
2
|
-
function J(n, e) {
|
|
3
|
-
const a = e ? e.storage ?? (typeof localStorage < "u" ? localStorage : void 0) : void 0;
|
|
4
|
-
let s = n;
|
|
5
|
-
if (e && a) try {
|
|
6
|
-
const m = a.getItem(e.key);
|
|
7
|
-
m != null && (s = JSON.parse(m));
|
|
8
|
-
} catch {
|
|
9
|
-
}
|
|
10
|
-
const o = /* @__PURE__ */ new Set(), c = () => o.forEach((m) => m(s));
|
|
11
|
-
function b() {
|
|
12
|
-
if (e && a) try {
|
|
13
|
-
a.setItem(e.key, JSON.stringify(s));
|
|
14
|
-
} catch {
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
get: () => s,
|
|
19
|
-
set: (m) => {
|
|
20
|
-
s = m, b(), c();
|
|
21
|
-
},
|
|
22
|
-
subscribe: (m) => (o.add(m), () => {
|
|
23
|
-
o.delete(m);
|
|
24
|
-
})
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
var j = /^[a-zA-Z0-9_-]{1,40}$/, I = (n) => n == null || n === "";
|
|
28
|
-
function N(n, e) {
|
|
29
|
-
if ("anyOf" in n) return n.anyOf.some((c) => N(c, e));
|
|
30
|
-
if ("allOf" in n) return n.allOf.every((c) => N(c, e));
|
|
31
|
-
const a = e[n.property];
|
|
32
|
-
if (I(a)) return !1;
|
|
33
|
-
if (Array.isArray(n.value)) return n.value.some((c) => String(a) === String(c));
|
|
34
|
-
if (!n.op) return String(a) === String(n.value);
|
|
35
|
-
const s = Number(a), o = Number(n.value);
|
|
36
|
-
if (Number.isNaN(s) || Number.isNaN(o)) return !1;
|
|
37
|
-
switch (n.op) {
|
|
38
|
-
case ">=":
|
|
39
|
-
return s >= o;
|
|
40
|
-
case "<=":
|
|
41
|
-
return s <= o;
|
|
42
|
-
case ">":
|
|
43
|
-
return s > o;
|
|
44
|
-
case "<":
|
|
45
|
-
return s < o;
|
|
46
|
-
default:
|
|
47
|
-
return w.warn(`Unknown requiredWhen op "${n.op}"; treating as not required.`), !1;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function p(n, e) {
|
|
51
|
-
const a = n.properties ?? {}, s = /* @__PURE__ */ new Set();
|
|
52
|
-
for (const c of n.required ?? []) {
|
|
53
|
-
const b = a[c]?.requiredWhen;
|
|
54
|
-
(!b || N(b, e)) && s.add(c);
|
|
55
|
-
}
|
|
56
|
-
for (const [c, b] of Object.entries(a)) b.requiredWhen && N(b.requiredWhen, e) && s.add(c);
|
|
57
|
-
const o = [...s].filter((c) => I(e[c]));
|
|
58
|
-
return {
|
|
59
|
-
missing: o,
|
|
60
|
-
complete: o.length === 0
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function R(n) {
|
|
64
|
-
const e = {};
|
|
65
|
-
for (const [a, s] of Object.entries(n.properties ?? {})) e[a] = {
|
|
66
|
-
type: s.type,
|
|
67
|
-
...s.description != null && { description: s.description },
|
|
68
|
-
...s.enum && { enum: s.enum },
|
|
69
|
-
...s.default !== void 0 && { default: s.default }
|
|
70
|
-
};
|
|
71
|
-
return {
|
|
72
|
-
type: "object",
|
|
73
|
-
properties: e,
|
|
74
|
-
required: []
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function B(n) {
|
|
78
|
-
const { name: e, description: a, schema: s } = n;
|
|
79
|
-
if (!j.test(e)) throw new Error(`Invalid form collector name "${e}": must match ${j} (it becomes the update_/submit_ function names).`);
|
|
80
|
-
const o = typeof n.submit == "string" ? n.submit ? {
|
|
81
|
-
via: "client",
|
|
82
|
-
url: n.submit
|
|
83
|
-
} : !1 : n.submit ?? !1;
|
|
84
|
-
n.autoSubmit === !0 && !o && w.warn(`FormCollector "${e}": autoSubmit is ignored because no submit target is configured.`);
|
|
85
|
-
const c = (n.autoSubmit ?? !0) && !!o, b = s.properties ?? {}, m = (t) => {
|
|
86
|
-
const r = {};
|
|
87
|
-
for (const [u, i] of Object.entries(t)) {
|
|
88
|
-
const l = b[u];
|
|
89
|
-
if (l)
|
|
90
|
-
if (i == null) r[u] = i;
|
|
91
|
-
else if (l.type === "number" || l.type === "integer") {
|
|
92
|
-
const d = typeof i == "number" ? i : Number(i);
|
|
93
|
-
r[u] = Number.isNaN(d) ? i : d;
|
|
94
|
-
} else l.type === "boolean" ? r[u] = typeof i == "boolean" ? i : i === "true" ? !0 : i === "false" ? !1 : !!i : r[u] = i;
|
|
95
|
-
}
|
|
96
|
-
return r;
|
|
97
|
-
}, $ = n.initialValues ?? {}, f = J({
|
|
98
|
-
values: $,
|
|
99
|
-
submitted: !1
|
|
100
|
-
}), k = (t) => {
|
|
101
|
-
const r = f.get(), u = {
|
|
102
|
-
...r,
|
|
103
|
-
values: {
|
|
104
|
-
...r.values,
|
|
105
|
-
...t
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
return f.set(u), u;
|
|
109
|
-
};
|
|
110
|
-
let h = null;
|
|
111
|
-
const F = (t, r) => {
|
|
112
|
-
h?.emitFormEvent("form:error", {
|
|
113
|
-
name: e,
|
|
114
|
-
values: t,
|
|
115
|
-
error: r
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
let y = null;
|
|
119
|
-
const V = async () => {
|
|
120
|
-
const { values: t } = f.get(), { complete: r, missing: u } = p(s, t);
|
|
121
|
-
if (!r) return {
|
|
122
|
-
ok: !1,
|
|
123
|
-
missing: u
|
|
124
|
-
};
|
|
125
|
-
if (!o) return {
|
|
126
|
-
ok: !1,
|
|
127
|
-
error: "No submit target configured for this form collector."
|
|
128
|
-
};
|
|
129
|
-
const i = t;
|
|
130
|
-
try {
|
|
131
|
-
let l;
|
|
132
|
-
if (o.via === "client") if ("handler" in o) l = await o.handler(i);
|
|
133
|
-
else {
|
|
134
|
-
const d = await fetch(o.url, {
|
|
135
|
-
method: "POST",
|
|
136
|
-
headers: { "Content-Type": "application/json" },
|
|
137
|
-
credentials: "include",
|
|
138
|
-
body: JSON.stringify(i)
|
|
139
|
-
});
|
|
140
|
-
if (!d.ok) {
|
|
141
|
-
const W = `Submit failed: HTTP ${d.status}`;
|
|
142
|
-
return F(i, W), {
|
|
143
|
-
ok: !1,
|
|
144
|
-
error: W
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
l = await d.json().catch(() => {
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
if (!h) return {
|
|
152
|
-
ok: !1,
|
|
153
|
-
error: "Backend submit requires install(client) (or useFormCollector) first."
|
|
154
|
-
};
|
|
155
|
-
l = await h.submitFormCollector(e, i);
|
|
156
|
-
}
|
|
157
|
-
return f.set({
|
|
158
|
-
...f.get(),
|
|
159
|
-
submitted: !0,
|
|
160
|
-
submitResult: l
|
|
161
|
-
}), h?.emitFormEvent("form:submitted", {
|
|
162
|
-
name: e,
|
|
163
|
-
values: i,
|
|
164
|
-
result: l
|
|
165
|
-
}), {
|
|
166
|
-
ok: !0,
|
|
167
|
-
result: l
|
|
168
|
-
};
|
|
169
|
-
} catch (l) {
|
|
170
|
-
const d = l instanceof Error ? l.message : "Submit failed";
|
|
171
|
-
return w.error(`FormCollector "${e}" submit failed:`, l), F(i, d), {
|
|
172
|
-
ok: !1,
|
|
173
|
-
error: d
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
}, C = () => y || (y = (async () => {
|
|
177
|
-
try {
|
|
178
|
-
return await V();
|
|
179
|
-
} finally {
|
|
180
|
-
y = null;
|
|
181
|
-
}
|
|
182
|
-
})(), y), q = async () => {
|
|
183
|
-
if (!c || !o) return null;
|
|
184
|
-
const { values: t, submitted: r } = f.get();
|
|
185
|
-
return r || !p(s, t).complete ? null : C();
|
|
186
|
-
}, O = {
|
|
187
|
-
name: `update_${e}`,
|
|
188
|
-
description: `Fill or update fields of the "${e}" form. ${a} Pass any subset of fields; call it repeatedly to fill the form as the user provides information. Returns the current values and which required fields are still missing.`,
|
|
189
|
-
parameters: R(s),
|
|
190
|
-
handler: async (t) => {
|
|
191
|
-
const r = k(m(t)), { missing: u } = p(s, r.values), i = await q();
|
|
192
|
-
return i ? i.ok ? {
|
|
193
|
-
ok: !0,
|
|
194
|
-
values: r.values,
|
|
195
|
-
missing: u,
|
|
196
|
-
submitted: !0
|
|
197
|
-
} : {
|
|
198
|
-
ok: !0,
|
|
199
|
-
values: r.values,
|
|
200
|
-
missing: u,
|
|
201
|
-
submitted: !1,
|
|
202
|
-
submitError: i.error
|
|
203
|
-
} : {
|
|
204
|
-
ok: !0,
|
|
205
|
-
values: r.values,
|
|
206
|
-
missing: u
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
}, g = [O];
|
|
210
|
-
o && !c && g.push({
|
|
211
|
-
name: `submit_${e}`,
|
|
212
|
-
description: `Submit the completed "${e}" form. Only call this once every required field is collected and the user has confirmed. If fields are missing it returns them instead of submitting.`,
|
|
213
|
-
parameters: {
|
|
214
|
-
type: "object",
|
|
215
|
-
properties: {}
|
|
216
|
-
},
|
|
217
|
-
handler: () => C()
|
|
218
|
-
});
|
|
219
|
-
const A = "client__", x = o ? `submit_${e}` : null, D = (t) => {
|
|
220
|
-
const r = t.functionName ?? t.toolName;
|
|
221
|
-
if (r)
|
|
222
|
-
return r.startsWith(A) ? r.slice(8) : r;
|
|
223
|
-
}, _ = (t) => {
|
|
224
|
-
let r = { ...$ }, u = !1;
|
|
225
|
-
for (const i of t) {
|
|
226
|
-
const l = D(i);
|
|
227
|
-
l === O.name ? i.arguments && (r = {
|
|
228
|
-
...r,
|
|
229
|
-
...m(i.arguments)
|
|
230
|
-
}) : x && l === x && i.status?.toLowerCase() === "done" && (u = !0);
|
|
231
|
-
}
|
|
232
|
-
f.set({
|
|
233
|
-
values: r,
|
|
234
|
-
submitted: u
|
|
235
|
-
});
|
|
236
|
-
}, v = `form:${e}`, S = `${v}:definition`, E = () => ({
|
|
237
|
-
name: `Form definition: ${e}`,
|
|
238
|
-
description: `${a} Some fields are conditionally required; the requiredWhen field in the schema tells you when each becomes required. The form schema is the following: ${JSON.stringify(s)}.`,
|
|
239
|
-
stable: !0
|
|
240
|
-
}), T = () => {
|
|
241
|
-
const { values: t, submitted: r } = f.get(), { missing: u, complete: i } = p(s, t), l = o ? c ? " The form is submitted automatically as soon as every required field is filled, so there is no submit function to call." : ` When nothing is missing and the user confirms, call submit_${e}.` : "", d = r ? `The "${e}" form has been submitted.` : `You are currently collecting information from the user to fill the "${e}" form.`;
|
|
242
|
-
return {
|
|
243
|
-
name: `Form: ${e}`,
|
|
244
|
-
description: `${d} The form's schema and field requirements are in the "${S}" client context. Call update_${e} with any fields the user provides; ask only for what is still missing.${l}`,
|
|
245
|
-
data: {
|
|
246
|
-
values: t,
|
|
247
|
-
missing: u,
|
|
248
|
-
complete: i,
|
|
249
|
-
submitted: r
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
}, P = (t) => {
|
|
253
|
-
_((t.messages ?? []).flatMap((r) => r.toolCalls ?? []));
|
|
254
|
-
};
|
|
255
|
-
return {
|
|
256
|
-
name: e,
|
|
257
|
-
store: f,
|
|
258
|
-
functions: g,
|
|
259
|
-
contextKey: v,
|
|
260
|
-
contextProvider: T,
|
|
261
|
-
definitionContextKey: S,
|
|
262
|
-
definitionContextProvider: E,
|
|
263
|
-
install: (t) => {
|
|
264
|
-
h = t;
|
|
265
|
-
for (const u of g) t.register(u);
|
|
266
|
-
t.addDynamicContext(S, E), t.addDynamicContext(v, T);
|
|
267
|
-
const r = f.subscribe(() => t.notifyContextChanged());
|
|
268
|
-
return t.on("conversation:loaded", P), () => {
|
|
269
|
-
r();
|
|
270
|
-
for (const u of g) t.unregisterFunction(u.name);
|
|
271
|
-
t.removeDynamicContext(v), t.removeDynamicContext(S), t.off("conversation:loaded", P), h === t && (h = null);
|
|
272
|
-
};
|
|
273
|
-
},
|
|
274
|
-
hydrate: _,
|
|
275
|
-
submit: C,
|
|
276
|
-
getValues: () => f.get().values,
|
|
277
|
-
setValues: (t) => {
|
|
278
|
-
k(m(t)), q();
|
|
279
|
-
},
|
|
280
|
-
reset: () => {
|
|
281
|
-
f.set({
|
|
282
|
-
values: $,
|
|
283
|
-
submitted: !1
|
|
284
|
-
});
|
|
285
|
-
},
|
|
286
|
-
getStatus: () => p(s, f.get().values)
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
async function K(n, e) {
|
|
290
|
-
const a = await n.getFormCollector(e.name);
|
|
291
|
-
return B({
|
|
292
|
-
name: a.name,
|
|
293
|
-
description: e.description ?? a.description,
|
|
294
|
-
schema: e.schema ?? a.schema,
|
|
295
|
-
submit: e.submit ?? a.submit,
|
|
296
|
-
initialValues: e.initialValues,
|
|
297
|
-
autoSubmit: e.autoSubmit ?? a.autoSubmit
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
export {
|
|
301
|
-
J as i,
|
|
302
|
-
p as n,
|
|
303
|
-
K as r,
|
|
304
|
-
B as t
|
|
305
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function y(u={}){const{overrides:g={}}=u,a={id:"mock-msg-1",conversationId:"mock-conv-1",content:"Mock response",role:"assistant",status:"DONE",createdAt:new Date},l={id:"mock-conv-1",title:"Mock Conversation",lastMessageDate:new Date},t=new Map,r=[],m={sendMessage:async()=>a,continueMessage:async()=>a,resumePendingClientFunctions:async()=>null,registerResumeGate:()=>()=>{},getConversations:async()=>[l],getConversation:async()=>l,getMessages:async()=>[a],submitToolCallForm:async()=>({status:"completed"}),confirmToolCall:async()=>{},rejectToolCall:async()=>{},submitFeedback:async()=>{},registerFunction:()=>{},unregisterFunction:()=>!0,getRegisteredFunctions:()=>[],getContextSnapshot:()=>null,notifyContextChanged:()=>{},registerNavigationFunction:()=>{},unregisterNavigationFunction:()=>{},on:(e,o)=>{t.has(e)||t.set(e,new Set),t.get(e).add(o)},off:(e,o)=>{t.get(e)?.delete(o)},once:(e,o)=>{const n=(...i)=>{t.get(e)?.delete(n),o(...i)};t.has(e)||t.set(e,new Set),t.get(e).add(n)},waitFor:(e,o)=>new Promise((n,i)=>{let c;const d=f=>{c&&clearTimeout(c),t.get(e)?.delete(d),n(f)};t.has(e)||t.set(e,new Set),t.get(e).add(d),o?.timeout&&(c=setTimeout(()=>{t.get(e)?.delete(d),i(new Error(`waitFor("${e}") timed out after ${o.timeout}ms`))},o.timeout))}),updateConfig:()=>{},destroy:()=>{t.clear()},...g},s={};for(const[e,o]of Object.entries(m))s[e]=(...n)=>(r.push({method:e,args:n}),o(...n));return s.__calls=r,s.__callsFor=e=>r.filter(o=>o.method===e),s.__emitEvent=(e,o)=>{const n=t.get(e);n&&[...n].forEach(i=>i(o))},s}Object.defineProperty(exports,"createMockClient",{enumerable:!0,get:function(){return y}});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
function y(g = {}) {
|
|
2
|
-
const { overrides: u = {} } = g, a = {
|
|
3
|
-
id: "mock-msg-1",
|
|
4
|
-
conversationId: "mock-conv-1",
|
|
5
|
-
content: "Mock response",
|
|
6
|
-
role: "assistant",
|
|
7
|
-
status: "DONE",
|
|
8
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
9
|
-
}, l = {
|
|
10
|
-
id: "mock-conv-1",
|
|
11
|
-
title: "Mock Conversation",
|
|
12
|
-
lastMessageDate: /* @__PURE__ */ new Date()
|
|
13
|
-
}, t = /* @__PURE__ */ new Map(), r = [], m = {
|
|
14
|
-
sendMessage: async () => a,
|
|
15
|
-
continueMessage: async () => a,
|
|
16
|
-
resumePendingClientFunctions: async () => null,
|
|
17
|
-
registerResumeGate: () => () => {
|
|
18
|
-
},
|
|
19
|
-
getConversations: async () => [l],
|
|
20
|
-
getConversation: async () => l,
|
|
21
|
-
getMessages: async () => [a],
|
|
22
|
-
submitToolCallForm: async () => ({ status: "completed" }),
|
|
23
|
-
confirmToolCall: async () => {
|
|
24
|
-
},
|
|
25
|
-
rejectToolCall: async () => {
|
|
26
|
-
},
|
|
27
|
-
submitFeedback: async () => {
|
|
28
|
-
},
|
|
29
|
-
registerFunction: () => {
|
|
30
|
-
},
|
|
31
|
-
unregisterFunction: () => !0,
|
|
32
|
-
getRegisteredFunctions: () => [],
|
|
33
|
-
getContextSnapshot: () => null,
|
|
34
|
-
notifyContextChanged: () => {
|
|
35
|
-
},
|
|
36
|
-
registerNavigationFunction: () => {
|
|
37
|
-
},
|
|
38
|
-
unregisterNavigationFunction: () => {
|
|
39
|
-
},
|
|
40
|
-
on: (e, o) => {
|
|
41
|
-
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(o);
|
|
42
|
-
},
|
|
43
|
-
off: (e, o) => {
|
|
44
|
-
t.get(e)?.delete(o);
|
|
45
|
-
},
|
|
46
|
-
once: (e, o) => {
|
|
47
|
-
const n = (...i) => {
|
|
48
|
-
t.get(e)?.delete(n), o(...i);
|
|
49
|
-
};
|
|
50
|
-
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(n);
|
|
51
|
-
},
|
|
52
|
-
waitFor: (e, o) => new Promise((n, i) => {
|
|
53
|
-
let c;
|
|
54
|
-
const d = (f) => {
|
|
55
|
-
c && clearTimeout(c), t.get(e)?.delete(d), n(f);
|
|
56
|
-
};
|
|
57
|
-
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(d), o?.timeout && (c = setTimeout(() => {
|
|
58
|
-
t.get(e)?.delete(d), i(/* @__PURE__ */ new Error(`waitFor("${e}") timed out after ${o.timeout}ms`));
|
|
59
|
-
}, o.timeout));
|
|
60
|
-
}),
|
|
61
|
-
updateConfig: () => {
|
|
62
|
-
},
|
|
63
|
-
destroy: () => {
|
|
64
|
-
t.clear();
|
|
65
|
-
},
|
|
66
|
-
...u
|
|
67
|
-
}, s = {};
|
|
68
|
-
for (const [e, o] of Object.entries(m)) s[e] = (...n) => (r.push({
|
|
69
|
-
method: e,
|
|
70
|
-
args: n
|
|
71
|
-
}), o(...n));
|
|
72
|
-
return s.__calls = r, s.__callsFor = (e) => r.filter((o) => o.method === e), s.__emitEvent = (e, o) => {
|
|
73
|
-
const n = t.get(e);
|
|
74
|
-
n && [...n].forEach((i) => i(o));
|
|
75
|
-
}, s;
|
|
76
|
-
}
|
|
77
|
-
export {
|
|
78
|
-
y as t
|
|
79
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const v=require("./react.cjs");var w=v.__exportAll({copyToClipboard:()=>c,getLocalStorage:()=>f,getUserLocation:()=>p,highlightElement:()=>h,openUrl:()=>a,scrollToElement:()=>d,setLocalStorage:()=>m,setTheme:()=>l,showConfirmDialog:()=>u,showNotification:()=>s,showToast:()=>i,submitForm:()=>y,trackEvent:()=>g}),i={name:"showToast",description:"Show a toast notification to the user. Use this to confirm actions or display brief messages.",parameters:{type:"object",properties:{message:{type:"string",description:"The message to display"},type:{type:"string",description:"Toast type",enum:["success","error","warning","info"]},duration:{type:"number",description:"Duration in milliseconds (default 3000)"}},required:["message"]},handler:async()=>({shown:!1,error:"No toast handler configured"})},s={name:"showNotification",description:"Show a browser notification to the user. Useful for important alerts even when the tab is not focused.",parameters:{type:"object",properties:{title:{type:"string",description:"Notification title"},body:{type:"string",description:"Notification body text"}},required:["title"]},handler:async e=>typeof Notification>"u"?{shown:!1,error:"Notifications not supported"}:Notification.permission==="denied"?{shown:!1,error:"Notification permission denied"}:(Notification.permission!=="granted"&&await Notification.requestPermission(),Notification.permission==="granted"?(new Notification(e.title,{body:e.body}),{shown:!0}):{shown:!1,error:"Permission not granted"})},a={name:"openUrl",description:"Open a URL in a new browser tab.",parameters:{type:"object",properties:{url:{type:"string",description:"The URL to open"}},required:["url"]},handler:async e=>(window.open(e.url,"_blank","noopener,noreferrer"),{opened:!0})},c={name:"copyToClipboard",description:"Copy text to the user's clipboard.",parameters:{type:"object",properties:{text:{type:"string",description:"The text to copy"}},required:["text"]},handler:async e=>(await navigator.clipboard.writeText(e.text),{copied:!0})},l={name:"setTheme",description:"Change the application's color theme. Sets a data-theme attribute on the document element.",parameters:{type:"object",properties:{theme:{type:"string",description:"Theme to apply",enum:["light","dark","system"]}},required:["theme"]},handler:async e=>{const t=e.theme;return document.documentElement.setAttribute("data-theme",t),t==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"),{theme:t,applied:!0}}},u={name:"showConfirmDialog",description:"Show a confirmation dialog to the user and return their choice (true/false).",parameters:{type:"object",properties:{message:{type:"string",description:"The confirmation message to display"}},required:["message"]},handler:async e=>({confirmed:window.confirm(e.message)})},p={name:"getUserLocation",description:"Get the user's current geographic location (requires permission).",parameters:{type:"object",properties:{}},handler:async()=>navigator.geolocation?new Promise(e=>{navigator.geolocation.getCurrentPosition(t=>e({latitude:t.coords.latitude,longitude:t.coords.longitude,accuracy:t.coords.accuracy}),t=>e({error:t.message}))}):{error:"Geolocation not supported"}},d={name:"scrollToElement",description:"Scroll the page to a specific element identified by CSS selector.",parameters:{type:"object",properties:{selector:{type:"string",description:"CSS selector of the element to scroll to (e.g. '#section-pricing')"},behavior:{type:"string",description:"Scroll behavior",enum:["smooth","instant"]}},required:["selector"]},handler:async e=>{const t=document.querySelector(e.selector);return t?(t.scrollIntoView({behavior:e.behavior||"smooth"}),{scrolled:!0}):{scrolled:!1,error:`Element not found: ${e.selector}`}}},m={name:"setLocalStorage",description:"Store a value in the browser's localStorage.",parameters:{type:"object",properties:{key:{type:"string",description:"Storage key"},value:{type:"string",description:"Value to store"}},required:["key","value"]},handler:async e=>(localStorage.setItem(e.key,e.value),{stored:!0})},f={name:"getLocalStorage",description:"Retrieve a value from the browser's localStorage.",parameters:{type:"object",properties:{key:{type:"string",description:"Storage key"}},required:["key"]},handler:async e=>{const t=localStorage.getItem(e.key);return{key:e.key,value:t,found:t!==null}}},h={name:"highlightElement",description:"Highlight a DOM element to draw the user's attention (e.g. for onboarding).",parameters:{type:"object",properties:{selector:{type:"string",description:"CSS selector of the element to highlight"},color:{type:"string",description:"Highlight border color (default: #3b82f6)"}},required:["selector"]},handler:async e=>{const t=document.querySelector(e.selector);if(!t)return{highlighted:!1,error:`Element not found: ${e.selector}`};const r=t.style.outline,o=e.color||"#3b82f6";return t.style.outline=`3px solid ${o}`,t.style.outlineOffset="2px",t.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>{t.style.outline=r,t.style.outlineOffset=""},3e3),{highlighted:!0}}},y={name:"submitForm",description:"Fill and submit an HTML form on the page. Pass field values as key-value pairs.",parameters:{type:"object",properties:{selector:{type:"string",description:"CSS selector of the form element"},values:{type:"string",description:"JSON string of field name → value pairs"}},required:["selector"]},handler:async e=>{const t=document.querySelector(e.selector);if(!t)return{submitted:!1,error:`Form not found: ${e.selector}`};if(e.values){const r=JSON.parse(e.values);for(const[o,b]of Object.entries(r)){const n=t.elements.namedItem(o);n&&(n.value=b)}}return t.requestSubmit(),{submitted:!0}}},g={name:"trackEvent",description:"Track a custom analytics event. Override the handler to wire up your analytics provider.",parameters:{type:"object",properties:{event:{type:"string",description:"Event name"},properties:{type:"string",description:"JSON string of event properties"}},required:["event"]},handler:async e=>{const t=e.properties?JSON.parse(e.properties):{};return console.log(`[AGO Analytics] ${e.event}`,t),{tracked:!0,event:e.event}}};Object.defineProperty(exports,"copyToClipboard",{enumerable:!0,get:function(){return c}});Object.defineProperty(exports,"functions_exports",{enumerable:!0,get:function(){return w}});Object.defineProperty(exports,"getLocalStorage",{enumerable:!0,get:function(){return f}});Object.defineProperty(exports,"getUserLocation",{enumerable:!0,get:function(){return p}});Object.defineProperty(exports,"highlightElement",{enumerable:!0,get:function(){return h}});Object.defineProperty(exports,"openUrl",{enumerable:!0,get:function(){return a}});Object.defineProperty(exports,"scrollToElement",{enumerable:!0,get:function(){return d}});Object.defineProperty(exports,"setLocalStorage",{enumerable:!0,get:function(){return m}});Object.defineProperty(exports,"setTheme",{enumerable:!0,get:function(){return l}});Object.defineProperty(exports,"showConfirmDialog",{enumerable:!0,get:function(){return u}});Object.defineProperty(exports,"showNotification",{enumerable:!0,get:function(){return s}});Object.defineProperty(exports,"showToast",{enumerable:!0,get:function(){return i}});Object.defineProperty(exports,"submitForm",{enumerable:!0,get:function(){return y}});Object.defineProperty(exports,"trackEvent",{enumerable:!0,get:function(){return g}});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|