@useago/sdk 0.3.3 → 0.3.4
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/createFormCollector-ClzHfaBd.js +185 -0
- package/dist/createFormCollector-H4Me_2uj.cjs +1 -0
- package/dist/createMockClient-C50gjV0b.js +71 -0
- package/dist/createMockClient-DQvFFWnc.cjs +1 -0
- package/dist/devtools.cjs +25 -25
- package/dist/devtools.js +49 -49
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +39 -38
- package/dist/react.cjs +19 -19
- package/dist/react.d.cts +47 -8
- package/dist/react.d.ts +47 -8
- package/dist/react.js +1066 -1051
- package/dist/widget.cjs +1 -0
- package/dist/widget.d.cts +536 -0
- package/dist/widget.d.ts +536 -0
- package/dist/widget.js +398 -0
- package/package.json +1 -1
- package/dist/createMockClient-D6uVh-B9.js +0 -254
- package/dist/createMockClient-DecMEUcK.cjs +0 -1
- /package/dist/{functions-Bz-1Bs3I.cjs → functions-BH1X5kas.cjs} +0 -0
- /package/dist/{functions-DdROP6Ui.js → functions-CWSRi3xv.js} +0 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { s as _ } from "./AgoClient-DF7M2WAz.js";
|
|
2
|
+
function q(c, r) {
|
|
3
|
+
const u = r ? r.storage ?? (typeof localStorage < "u" ? localStorage : void 0) : void 0;
|
|
4
|
+
let a = c;
|
|
5
|
+
if (r && u) try {
|
|
6
|
+
const o = u.getItem(r.key);
|
|
7
|
+
o != null && (a = JSON.parse(o));
|
|
8
|
+
} catch {
|
|
9
|
+
}
|
|
10
|
+
const n = /* @__PURE__ */ new Set(), p = () => n.forEach((o) => o(a));
|
|
11
|
+
function b() {
|
|
12
|
+
if (r && u) try {
|
|
13
|
+
u.setItem(r.key, JSON.stringify(a));
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
get: () => a,
|
|
19
|
+
set: (o) => {
|
|
20
|
+
a = o, b(), p();
|
|
21
|
+
},
|
|
22
|
+
subscribe: (o) => (n.add(o), () => {
|
|
23
|
+
n.delete(o);
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var N = /^[a-zA-Z0-9_-]{1,40}$/;
|
|
28
|
+
function E(c) {
|
|
29
|
+
const { name: r, description: u, schema: a } = c;
|
|
30
|
+
if (!N.test(r)) throw new Error(`Invalid form collector name "${r}": must match ${N} (it becomes the update_/submit_ function names).`);
|
|
31
|
+
const n = typeof c.submit == "string" ? c.submit ? {
|
|
32
|
+
via: "client",
|
|
33
|
+
url: c.submit
|
|
34
|
+
} : !1 : c.submit ?? !1, p = a.properties ?? {}, b = a.required ?? [], o = (e) => e == null || e === "", h = (e) => b.filter((t) => o(e[t])), v = (e) => {
|
|
35
|
+
const t = {};
|
|
36
|
+
for (const [i, s] of Object.entries(e)) {
|
|
37
|
+
const m = p[i];
|
|
38
|
+
if (m)
|
|
39
|
+
if (s == null) t[i] = s;
|
|
40
|
+
else if (m.type === "number" || m.type === "integer") {
|
|
41
|
+
const C = typeof s == "number" ? s : Number(s);
|
|
42
|
+
t[i] = Number.isNaN(C) ? s : C;
|
|
43
|
+
} else m.type === "boolean" ? t[i] = typeof s == "boolean" ? s : s === "true" ? !0 : s === "false" ? !1 : !!s : t[i] = s;
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
}, d = c.initialValues ?? {}, $ = h(d), l = q({
|
|
47
|
+
values: d,
|
|
48
|
+
missing: $,
|
|
49
|
+
complete: $.length === 0,
|
|
50
|
+
submitted: !1
|
|
51
|
+
}), k = (e) => {
|
|
52
|
+
const t = l.get(), i = {
|
|
53
|
+
...t.values,
|
|
54
|
+
...e
|
|
55
|
+
}, s = h(i), m = {
|
|
56
|
+
...t,
|
|
57
|
+
values: i,
|
|
58
|
+
missing: s,
|
|
59
|
+
complete: s.length === 0
|
|
60
|
+
};
|
|
61
|
+
return l.set(m), m;
|
|
62
|
+
};
|
|
63
|
+
let f = null;
|
|
64
|
+
const S = async () => {
|
|
65
|
+
const e = l.get();
|
|
66
|
+
if (!e.complete) return {
|
|
67
|
+
ok: !1,
|
|
68
|
+
missing: e.missing
|
|
69
|
+
};
|
|
70
|
+
if (!n) return {
|
|
71
|
+
ok: !1,
|
|
72
|
+
error: "No submit target configured for this form collector."
|
|
73
|
+
};
|
|
74
|
+
const t = e.values;
|
|
75
|
+
try {
|
|
76
|
+
let i;
|
|
77
|
+
if (n.via === "client") if ("handler" in n) i = await n.handler(t);
|
|
78
|
+
else {
|
|
79
|
+
const s = await fetch(n.url, {
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: { "Content-Type": "application/json" },
|
|
82
|
+
credentials: "include",
|
|
83
|
+
body: JSON.stringify(t)
|
|
84
|
+
});
|
|
85
|
+
if (!s.ok) return {
|
|
86
|
+
ok: !1,
|
|
87
|
+
error: `Submit failed: HTTP ${s.status}`
|
|
88
|
+
};
|
|
89
|
+
i = await s.json().catch(() => {
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (!f) return {
|
|
94
|
+
ok: !1,
|
|
95
|
+
error: "Backend submit requires install(client) (or useFormCollector) first."
|
|
96
|
+
};
|
|
97
|
+
i = await f.submitFormCollector(n.destination, t);
|
|
98
|
+
}
|
|
99
|
+
return l.set({
|
|
100
|
+
...l.get(),
|
|
101
|
+
submitted: !0
|
|
102
|
+
}), {
|
|
103
|
+
ok: !0,
|
|
104
|
+
result: i
|
|
105
|
+
};
|
|
106
|
+
} catch (i) {
|
|
107
|
+
const s = i instanceof Error ? i.message : "Submit failed";
|
|
108
|
+
return _.error(`FormCollector "${r}" submit failed:`, i), {
|
|
109
|
+
ok: !1,
|
|
110
|
+
error: s
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}, g = [{
|
|
114
|
+
name: `update_${r}`,
|
|
115
|
+
description: `Fill or update fields of the "${r}" form. ${u} 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.`,
|
|
116
|
+
parameters: {
|
|
117
|
+
...a,
|
|
118
|
+
required: []
|
|
119
|
+
},
|
|
120
|
+
handler: (e) => {
|
|
121
|
+
const t = k(v(e));
|
|
122
|
+
return {
|
|
123
|
+
ok: !0,
|
|
124
|
+
values: t.values,
|
|
125
|
+
missing: t.missing,
|
|
126
|
+
complete: t.complete
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}];
|
|
130
|
+
n && g.push({
|
|
131
|
+
name: `submit_${r}`,
|
|
132
|
+
description: `Submit the completed "${r}" 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.`,
|
|
133
|
+
parameters: {
|
|
134
|
+
type: "object",
|
|
135
|
+
properties: {}
|
|
136
|
+
},
|
|
137
|
+
handler: () => S()
|
|
138
|
+
});
|
|
139
|
+
const y = `form:${r}`, w = () => {
|
|
140
|
+
const e = l.get(), t = n ? ` When all required fields are present and the user confirms, call submit_${r}.` : "";
|
|
141
|
+
return {
|
|
142
|
+
name: `Form: ${r}`,
|
|
143
|
+
description: `Conversational form the assistant is helping fill. ${u} Use update_${r} to record fields; ask the user only for what is still missing.${t}`,
|
|
144
|
+
data: {
|
|
145
|
+
values: e.values,
|
|
146
|
+
missing: e.missing,
|
|
147
|
+
complete: e.complete,
|
|
148
|
+
submitted: e.submitted
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
return {
|
|
153
|
+
name: r,
|
|
154
|
+
store: l,
|
|
155
|
+
functions: g,
|
|
156
|
+
contextKey: y,
|
|
157
|
+
contextProvider: w,
|
|
158
|
+
install: (e) => {
|
|
159
|
+
f = e;
|
|
160
|
+
for (const t of g) e.register(t);
|
|
161
|
+
return e.addDynamicContext(y, w), () => {
|
|
162
|
+
for (const t of g) e.unregisterFunction(t.name);
|
|
163
|
+
e.removeDynamicContext(y), f === e && (f = null);
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
submit: S,
|
|
167
|
+
getValues: () => l.get().values,
|
|
168
|
+
setValues: (e) => {
|
|
169
|
+
k(v(e));
|
|
170
|
+
},
|
|
171
|
+
reset: () => {
|
|
172
|
+
const e = h(d);
|
|
173
|
+
l.set({
|
|
174
|
+
values: d,
|
|
175
|
+
missing: e,
|
|
176
|
+
complete: e.length === 0,
|
|
177
|
+
submitted: !1
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
export {
|
|
183
|
+
q as n,
|
|
184
|
+
E as t
|
|
185
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _=require("./AgoClient-bjN-z2ZQ.cjs");function q(u,s){const c=s?s.storage??(typeof localStorage<"u"?localStorage:void 0):void 0;let a=u;if(s&&c)try{const o=c.getItem(s.key);o!=null&&(a=JSON.parse(o))}catch{}const i=new Set,b=()=>i.forEach(o=>o(a));function p(){if(s&&c)try{c.setItem(s.key,JSON.stringify(a))}catch{}}return{get:()=>a,set:o=>{a=o,p(),b()},subscribe:o=>(i.add(o),()=>{i.delete(o)})}}var N=/^[a-zA-Z0-9_-]{1,40}$/;function F(u){const{name:s,description:c,schema:a}=u;if(!N.test(s))throw new Error(`Invalid form collector name "${s}": must match ${N} (it becomes the update_/submit_ function names).`);const i=typeof u.submit=="string"?u.submit?{via:"client",url:u.submit}:!1:u.submit??!1,b=a.properties??{},p=a.required??[],o=e=>e==null||e==="",h=e=>p.filter(t=>o(e[t])),v=e=>{const t={};for(const[n,r]of Object.entries(e)){const m=b[n];if(m)if(r==null)t[n]=r;else if(m.type==="number"||m.type==="integer"){const w=typeof r=="number"?r:Number(r);t[n]=Number.isNaN(w)?r:w}else m.type==="boolean"?t[n]=typeof r=="boolean"?r:r==="true"?!0:r==="false"?!1:!!r:t[n]=r}return t},d=u.initialValues??{},$=h(d),l=q({values:d,missing:$,complete:$.length===0,submitted:!1}),S=e=>{const t=l.get(),n={...t.values,...e},r=h(n),m={...t,values:n,missing:r,complete:r.length===0};return l.set(m),m};let f=null;const k=async()=>{const e=l.get();if(!e.complete)return{ok:!1,missing:e.missing};if(!i)return{ok:!1,error:"No submit target configured for this form collector."};const t=e.values;try{let n;if(i.via==="client")if("handler"in i)n=await i.handler(t);else{const r=await fetch(i.url,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(t)});if(!r.ok)return{ok:!1,error:`Submit failed: HTTP ${r.status}`};n=await r.json().catch(()=>{})}else{if(!f)return{ok:!1,error:"Backend submit requires install(client) (or useFormCollector) first."};n=await f.submitFormCollector(i.destination,t)}return l.set({...l.get(),submitted:!0}),{ok:!0,result:n}}catch(n){const r=n instanceof Error?n.message:"Submit failed";return _.logger.error(`FormCollector "${s}" submit failed:`,n),{ok:!1,error:r}}},g=[{name:`update_${s}`,description:`Fill or update fields of the "${s}" form. ${c} 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:{...a,required:[]},handler:e=>{const t=S(v(e));return{ok:!0,values:t.values,missing:t.missing,complete:t.complete}}}];i&&g.push({name:`submit_${s}`,description:`Submit the completed "${s}" 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:()=>k()});const y=`form:${s}`,C=()=>{const e=l.get(),t=i?` When all required fields are present and the user confirms, call submit_${s}.`:"";return{name:`Form: ${s}`,description:`Conversational form the assistant is helping fill. ${c} Use update_${s} to record fields; ask the user only for what is still missing.${t}`,data:{values:e.values,missing:e.missing,complete:e.complete,submitted:e.submitted}}};return{name:s,store:l,functions:g,contextKey:y,contextProvider:C,install:e=>{f=e;for(const t of g)e.register(t);return e.addDynamicContext(y,C),()=>{for(const t of g)e.unregisterFunction(t.name);e.removeDynamicContext(y),f===e&&(f=null)}},submit:k,getValues:()=>l.get().values,setValues:e=>{S(v(e))},reset:()=>{const e=h(d);l.set({values:d,missing:e,complete:e.length===0,submitted:!1})}}}Object.defineProperty(exports,"createFormCollector",{enumerable:!0,get:function(){return F}});Object.defineProperty(exports,"createStore",{enumerable:!0,get:function(){return q}});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
function w(g = {}) {
|
|
2
|
+
const { overrides: m = {} } = g, d = {
|
|
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(), i = [], u = {
|
|
14
|
+
sendMessage: async () => d,
|
|
15
|
+
getConversations: async () => [l],
|
|
16
|
+
getConversation: async () => l,
|
|
17
|
+
getMessages: async () => [d],
|
|
18
|
+
submitToolCallForm: async () => {
|
|
19
|
+
},
|
|
20
|
+
confirmToolCall: async () => {
|
|
21
|
+
},
|
|
22
|
+
rejectToolCall: async () => {
|
|
23
|
+
},
|
|
24
|
+
submitFeedback: async () => {
|
|
25
|
+
},
|
|
26
|
+
registerFunction: () => {
|
|
27
|
+
},
|
|
28
|
+
unregisterFunction: () => !0,
|
|
29
|
+
getRegisteredFunctions: () => [],
|
|
30
|
+
registerNavigationFunction: () => {
|
|
31
|
+
},
|
|
32
|
+
on: (e, o) => {
|
|
33
|
+
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(o);
|
|
34
|
+
},
|
|
35
|
+
off: (e, o) => {
|
|
36
|
+
t.get(e)?.delete(o);
|
|
37
|
+
},
|
|
38
|
+
once: (e, o) => {
|
|
39
|
+
const s = (...a) => {
|
|
40
|
+
t.get(e)?.delete(s), o(...a);
|
|
41
|
+
};
|
|
42
|
+
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(s);
|
|
43
|
+
},
|
|
44
|
+
waitFor: (e, o) => new Promise((s, a) => {
|
|
45
|
+
let r;
|
|
46
|
+
const c = (f) => {
|
|
47
|
+
r && clearTimeout(r), t.get(e)?.delete(c), s(f);
|
|
48
|
+
};
|
|
49
|
+
t.has(e) || t.set(e, /* @__PURE__ */ new Set()), t.get(e).add(c), o?.timeout && (r = setTimeout(() => {
|
|
50
|
+
t.get(e)?.delete(c), a(/* @__PURE__ */ new Error(`waitFor("${e}") timed out after ${o.timeout}ms`));
|
|
51
|
+
}, o.timeout));
|
|
52
|
+
}),
|
|
53
|
+
updateConfig: () => {
|
|
54
|
+
},
|
|
55
|
+
destroy: () => {
|
|
56
|
+
t.clear();
|
|
57
|
+
},
|
|
58
|
+
...m
|
|
59
|
+
}, n = {};
|
|
60
|
+
for (const [e, o] of Object.entries(u)) n[e] = (...s) => (i.push({
|
|
61
|
+
method: e,
|
|
62
|
+
args: s
|
|
63
|
+
}), o(...s));
|
|
64
|
+
return n.__calls = i, n.__callsFor = (e) => i.filter((o) => o.method === e), n.__emitEvent = (e, o) => {
|
|
65
|
+
const s = t.get(e);
|
|
66
|
+
s && [...s].forEach((a) => a(o));
|
|
67
|
+
}, n;
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
w as t
|
|
71
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function w(u={}){const{overrides:g={}}=u,d={id:"mock-msg-1",conversationId:"mock-conv-1",content:"Mock response",role:"assistant",status:"DONE",createdAt:new Date},l={id:"mock-conv-1",title:"Mock Conversation",lastMessageDate:new Date},t=new Map,i=[],m={sendMessage:async()=>d,getConversations:async()=>[l],getConversation:async()=>l,getMessages:async()=>[d],submitToolCallForm:async()=>{},confirmToolCall:async()=>{},rejectToolCall:async()=>{},submitFeedback:async()=>{},registerFunction:()=>{},unregisterFunction:()=>!0,getRegisteredFunctions:()=>[],registerNavigationFunction:()=>{},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 s=(...r)=>{t.get(e)?.delete(s),o(...r)};t.has(e)||t.set(e,new Set),t.get(e).add(s)},waitFor:(e,o)=>new Promise((s,r)=>{let a;const c=f=>{a&&clearTimeout(a),t.get(e)?.delete(c),s(f)};t.has(e)||t.set(e,new Set),t.get(e).add(c),o?.timeout&&(a=setTimeout(()=>{t.get(e)?.delete(c),r(new Error(`waitFor("${e}") timed out after ${o.timeout}ms`))},o.timeout))}),updateConfig:()=>{},destroy:()=>{t.clear()},...g},n={};for(const[e,o]of Object.entries(m))n[e]=(...s)=>(i.push({method:e,args:s}),o(...s));return n.__calls=i,n.__callsFor=e=>i.filter(o=>o.method===e),n.__emitEvent=(e,o)=>{const s=t.get(e);s&&[...s].forEach(r=>r(o))},n}Object.defineProperty(exports,"createMockClient",{enumerable:!0,get:function(){return w}});
|
package/dist/devtools.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s,d,u=()=>({});function p(){s&&(s.textContent=JSON.stringify(u(),null,2))}function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s,d,u=()=>({});function p(){s&&(s.textContent=JSON.stringify(u(),null,2))}function g(t,a){if(!d)return;const e=document.createElement("div");e.className=`dev-log-line dev-log-${a}`,e.textContent=`${new Date().toLocaleTimeString()} ${t}`,d.appendChild(e),d.scrollTop=d.scrollHeight}var x="ago_dev_panel_collapsed";function r(t,a){t.classList.toggle("collapsed",a);const e=t.querySelector(".dev-toggle");e&&(e.textContent=a?"▢":"—",e.title=a?"Expand dev tools":"Collapse dev tools",e.setAttribute("aria-expanded",String(!a)));try{localStorage.setItem(x,a?"1":"0")}catch{}}function b(t){const{store:a,client:e,target:i}=t;u=a.get,m();const f=typeof i=="string"?document.querySelector(i):i instanceof Element?i:document.body,o=document.createElement("aside");o.id="ago-dev-panel",(f??document.body).appendChild(o),o.innerHTML=`
|
|
2
2
|
<div class="dev-head">
|
|
3
3
|
<span class="dev-badge">DEV</span>
|
|
4
4
|
<span class="dev-title">DEV TOOLS · client-side function state — not for production</span>
|
|
5
5
|
<button type="button" class="dev-toggle" aria-label="Toggle dev tools">—</button>
|
|
6
6
|
</div>
|
|
7
7
|
<div class="dev-body">
|
|
8
|
-
<div class="dev-fns">Registered functions: <code>${(e.getRegisteredFunctions?.()??[]).map(
|
|
8
|
+
<div class="dev-fns">Registered functions: <code>${(e.getRegisteredFunctions?.()??[]).map(n=>n.name).join(", ")||"—"}</code></div>
|
|
9
9
|
<div class="dev-section-label">JSON object (built by the agent)</div>
|
|
10
|
-
<pre class="dev-state" id="dev-state"></pre>
|
|
10
|
+
<pre class="dev-state" id="ago-dev-state"></pre>
|
|
11
11
|
<div class="dev-section-label">Function calls</div>
|
|
12
|
-
<div class="dev-log" id="dev-log"></div>
|
|
12
|
+
<div class="dev-log" id="ago-dev-log"></div>
|
|
13
13
|
</div>
|
|
14
|
-
`,s=
|
|
15
|
-
#dev-panel {
|
|
14
|
+
`,s=o.querySelector("#ago-dev-state"),d=o.querySelector("#ago-dev-log"),o.querySelector(".dev-toggle")?.addEventListener("click",n=>{n.stopPropagation(),r(o,!o.classList.contains("collapsed"))}),o.addEventListener("click",()=>{o.classList.contains("collapsed")&&r(o,!1)});let c=!1;try{c=localStorage.getItem(x)==="1"}catch{}r(o,c),e.on("function:invoke",({functionName:n,arguments:l})=>{g(`→ ${n}(${JSON.stringify(l??{})})`,"invoke")}),e.on("function:result",({result:n,error:l})=>{g(l?`✗ error: ${l}`:`← ${JSON.stringify(n)}`,l?"error":"result")}),a.subscribe(p),p()}var v="ago-dev-panel-styles";function m(){if(document.getElementById(v))return;const t=document.createElement("style");t.id=v,t.textContent=h,document.head.appendChild(t)}var h=`
|
|
15
|
+
#ago-dev-panel {
|
|
16
16
|
position: fixed;
|
|
17
17
|
top: 16px;
|
|
18
18
|
right: 16px;
|
|
@@ -33,8 +33,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s,d,u=()=
|
|
|
33
33
|
font-size: 12px;
|
|
34
34
|
z-index: 1000;
|
|
35
35
|
}
|
|
36
|
-
#dev-panel .dev-head { display: flex; align-items: center; gap: 8px; }
|
|
37
|
-
#dev-panel .dev-toggle {
|
|
36
|
+
#ago-dev-panel .dev-head { display: flex; align-items: center; gap: 8px; }
|
|
37
|
+
#ago-dev-panel .dev-toggle {
|
|
38
38
|
margin-left: auto;
|
|
39
39
|
flex: none;
|
|
40
40
|
width: 22px;
|
|
@@ -50,19 +50,19 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s,d,u=()=
|
|
|
50
50
|
line-height: 1;
|
|
51
51
|
cursor: pointer;
|
|
52
52
|
}
|
|
53
|
-
#dev-panel .dev-toggle:hover { color: #d7e0e8; border-color: #3a4655; }
|
|
54
|
-
#dev-panel .dev-body { display: flex; flex-direction: column; gap: 8px; }
|
|
53
|
+
#ago-dev-panel .dev-toggle:hover { color: #d7e0e8; border-color: #3a4655; }
|
|
54
|
+
#ago-dev-panel .dev-body { display: flex; flex-direction: column; gap: 8px; }
|
|
55
55
|
|
|
56
56
|
/* Collapsed: shrink to a small clickable widget showing only the DEV badge. */
|
|
57
|
-
#dev-panel.collapsed {
|
|
57
|
+
#ago-dev-panel.collapsed {
|
|
58
58
|
width: auto;
|
|
59
59
|
cursor: pointer;
|
|
60
60
|
padding: 8px 10px;
|
|
61
61
|
}
|
|
62
|
-
#dev-panel.collapsed .dev-title,
|
|
63
|
-
#dev-panel.collapsed .dev-body { display: none; }
|
|
64
|
-
#dev-panel.collapsed .dev-toggle { margin-left: 6px; }
|
|
65
|
-
#dev-panel .dev-badge {
|
|
62
|
+
#ago-dev-panel.collapsed .dev-title,
|
|
63
|
+
#ago-dev-panel.collapsed .dev-body { display: none; }
|
|
64
|
+
#ago-dev-panel.collapsed .dev-toggle { margin-left: 6px; }
|
|
65
|
+
#ago-dev-panel .dev-badge {
|
|
66
66
|
background: #f59e0b;
|
|
67
67
|
color: #1c1206;
|
|
68
68
|
font-weight: 700;
|
|
@@ -71,17 +71,17 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s,d,u=()=
|
|
|
71
71
|
padding: 2px 6px;
|
|
72
72
|
border-radius: 5px;
|
|
73
73
|
}
|
|
74
|
-
#dev-panel .dev-title { color: #f59e0b; font-size: 11px; line-height: 1.3; }
|
|
75
|
-
#dev-panel .dev-fns { color: #7c8a99; font-size: 11px; }
|
|
76
|
-
#dev-panel .dev-fns code { color: #9ecbff; }
|
|
77
|
-
#dev-panel .dev-section-label {
|
|
74
|
+
#ago-dev-panel .dev-title { color: #f59e0b; font-size: 11px; line-height: 1.3; }
|
|
75
|
+
#ago-dev-panel .dev-fns { color: #7c8a99; font-size: 11px; }
|
|
76
|
+
#ago-dev-panel .dev-fns code { color: #9ecbff; }
|
|
77
|
+
#ago-dev-panel .dev-section-label {
|
|
78
78
|
color: #7c8a99;
|
|
79
79
|
text-transform: uppercase;
|
|
80
80
|
letter-spacing: .08em;
|
|
81
81
|
font-size: 10px;
|
|
82
82
|
margin-top: 4px;
|
|
83
83
|
}
|
|
84
|
-
#dev-panel .dev-state {
|
|
84
|
+
#ago-dev-panel .dev-state {
|
|
85
85
|
margin: 0;
|
|
86
86
|
padding: 8px;
|
|
87
87
|
background: #060a0e;
|
|
@@ -91,7 +91,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s,d,u=()=
|
|
|
91
91
|
white-space: pre;
|
|
92
92
|
color: #c8e6c9;
|
|
93
93
|
}
|
|
94
|
-
#dev-panel .dev-log {
|
|
94
|
+
#ago-dev-panel .dev-log {
|
|
95
95
|
display: flex;
|
|
96
96
|
flex-direction: column;
|
|
97
97
|
gap: 2px;
|
|
@@ -101,8 +101,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s,d,u=()=
|
|
|
101
101
|
border-radius: 8px;
|
|
102
102
|
padding: 6px 8px;
|
|
103
103
|
}
|
|
104
|
-
#dev-panel .dev-log-line { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
|
|
105
|
-
#dev-panel .dev-log-invoke { color: #9ecbff; }
|
|
106
|
-
#dev-panel .dev-log-result { color: #86efac; }
|
|
107
|
-
#dev-panel .dev-log-error { color: #fca5a5; }
|
|
104
|
+
#ago-dev-panel .dev-log-line { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
|
|
105
|
+
#ago-dev-panel .dev-log-invoke { color: #9ecbff; }
|
|
106
|
+
#ago-dev-panel .dev-log-result { color: #86efac; }
|
|
107
|
+
#ago-dev-panel .dev-log-error { color: #fca5a5; }
|
|
108
108
|
`;exports.initDevPanel=b;
|
package/dist/devtools.js
CHANGED
|
@@ -2,62 +2,62 @@ var r, d, x = () => ({});
|
|
|
2
2
|
function p() {
|
|
3
3
|
r && (r.textContent = JSON.stringify(x(), null, 2));
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function g(t, a) {
|
|
6
6
|
if (!d) return;
|
|
7
7
|
const e = document.createElement("div");
|
|
8
|
-
e.className = `dev-log-line dev-log-${
|
|
8
|
+
e.className = `dev-log-line dev-log-${a}`, e.textContent = `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} ${t}`, d.appendChild(e), d.scrollTop = d.scrollHeight;
|
|
9
9
|
}
|
|
10
|
-
var u = "
|
|
11
|
-
function s(
|
|
12
|
-
|
|
13
|
-
const e =
|
|
14
|
-
e && (e.textContent =
|
|
10
|
+
var u = "ago_dev_panel_collapsed";
|
|
11
|
+
function s(t, a) {
|
|
12
|
+
t.classList.toggle("collapsed", a);
|
|
13
|
+
const e = t.querySelector(".dev-toggle");
|
|
14
|
+
e && (e.textContent = a ? "▢" : "—", e.title = a ? "Expand dev tools" : "Collapse dev tools", e.setAttribute("aria-expanded", String(!a)));
|
|
15
15
|
try {
|
|
16
|
-
localStorage.setItem(u,
|
|
16
|
+
localStorage.setItem(u, a ? "1" : "0");
|
|
17
17
|
} catch {
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function m(
|
|
21
|
-
const { store:
|
|
22
|
-
x =
|
|
23
|
-
const f = typeof i == "string" ? document.querySelector(i) : i instanceof Element ? i : document.body,
|
|
24
|
-
|
|
20
|
+
function m(t) {
|
|
21
|
+
const { store: a, client: e, target: i } = t;
|
|
22
|
+
x = a.get, b();
|
|
23
|
+
const f = typeof i == "string" ? document.querySelector(i) : i instanceof Element ? i : document.body, o = document.createElement("aside");
|
|
24
|
+
o.id = "ago-dev-panel", (f ?? document.body).appendChild(o), o.innerHTML = `
|
|
25
25
|
<div class="dev-head">
|
|
26
26
|
<span class="dev-badge">DEV</span>
|
|
27
27
|
<span class="dev-title">DEV TOOLS · client-side function state — not for production</span>
|
|
28
28
|
<button type="button" class="dev-toggle" aria-label="Toggle dev tools">—</button>
|
|
29
29
|
</div>
|
|
30
30
|
<div class="dev-body">
|
|
31
|
-
<div class="dev-fns">Registered functions: <code>${(e.getRegisteredFunctions?.() ?? []).map((
|
|
31
|
+
<div class="dev-fns">Registered functions: <code>${(e.getRegisteredFunctions?.() ?? []).map((n) => n.name).join(", ") || "—"}</code></div>
|
|
32
32
|
<div class="dev-section-label">JSON object (built by the agent)</div>
|
|
33
|
-
<pre class="dev-state" id="dev-state"></pre>
|
|
33
|
+
<pre class="dev-state" id="ago-dev-state"></pre>
|
|
34
34
|
<div class="dev-section-label">Function calls</div>
|
|
35
|
-
<div class="dev-log" id="dev-log"></div>
|
|
35
|
+
<div class="dev-log" id="ago-dev-log"></div>
|
|
36
36
|
</div>
|
|
37
|
-
`, r =
|
|
38
|
-
|
|
39
|
-
}),
|
|
40
|
-
|
|
37
|
+
`, r = o.querySelector("#ago-dev-state"), d = o.querySelector("#ago-dev-log"), o.querySelector(".dev-toggle")?.addEventListener("click", (n) => {
|
|
38
|
+
n.stopPropagation(), s(o, !o.classList.contains("collapsed"));
|
|
39
|
+
}), o.addEventListener("click", () => {
|
|
40
|
+
o.classList.contains("collapsed") && s(o, !1);
|
|
41
41
|
});
|
|
42
42
|
let c = !1;
|
|
43
43
|
try {
|
|
44
44
|
c = localStorage.getItem(u) === "1";
|
|
45
45
|
} catch {
|
|
46
46
|
}
|
|
47
|
-
s(
|
|
48
|
-
|
|
49
|
-
}), e.on("function:result", ({ result:
|
|
50
|
-
|
|
51
|
-
}),
|
|
47
|
+
s(o, c), e.on("function:invoke", ({ functionName: n, arguments: l }) => {
|
|
48
|
+
g(`→ ${n}(${JSON.stringify(l ?? {})})`, "invoke");
|
|
49
|
+
}), e.on("function:result", ({ result: n, error: l }) => {
|
|
50
|
+
g(l ? `✗ error: ${l}` : `← ${JSON.stringify(n)}`, l ? "error" : "result");
|
|
51
|
+
}), a.subscribe(p), p();
|
|
52
52
|
}
|
|
53
|
-
var
|
|
53
|
+
var v = "ago-dev-panel-styles";
|
|
54
54
|
function b() {
|
|
55
|
-
if (document.getElementById(
|
|
56
|
-
const
|
|
57
|
-
|
|
55
|
+
if (document.getElementById(v)) return;
|
|
56
|
+
const t = document.createElement("style");
|
|
57
|
+
t.id = v, t.textContent = h, document.head.appendChild(t);
|
|
58
58
|
}
|
|
59
59
|
var h = `
|
|
60
|
-
#dev-panel {
|
|
60
|
+
#ago-dev-panel {
|
|
61
61
|
position: fixed;
|
|
62
62
|
top: 16px;
|
|
63
63
|
right: 16px;
|
|
@@ -78,8 +78,8 @@ var h = `
|
|
|
78
78
|
font-size: 12px;
|
|
79
79
|
z-index: 1000;
|
|
80
80
|
}
|
|
81
|
-
#dev-panel .dev-head { display: flex; align-items: center; gap: 8px; }
|
|
82
|
-
#dev-panel .dev-toggle {
|
|
81
|
+
#ago-dev-panel .dev-head { display: flex; align-items: center; gap: 8px; }
|
|
82
|
+
#ago-dev-panel .dev-toggle {
|
|
83
83
|
margin-left: auto;
|
|
84
84
|
flex: none;
|
|
85
85
|
width: 22px;
|
|
@@ -95,19 +95,19 @@ var h = `
|
|
|
95
95
|
line-height: 1;
|
|
96
96
|
cursor: pointer;
|
|
97
97
|
}
|
|
98
|
-
#dev-panel .dev-toggle:hover { color: #d7e0e8; border-color: #3a4655; }
|
|
99
|
-
#dev-panel .dev-body { display: flex; flex-direction: column; gap: 8px; }
|
|
98
|
+
#ago-dev-panel .dev-toggle:hover { color: #d7e0e8; border-color: #3a4655; }
|
|
99
|
+
#ago-dev-panel .dev-body { display: flex; flex-direction: column; gap: 8px; }
|
|
100
100
|
|
|
101
101
|
/* Collapsed: shrink to a small clickable widget showing only the DEV badge. */
|
|
102
|
-
#dev-panel.collapsed {
|
|
102
|
+
#ago-dev-panel.collapsed {
|
|
103
103
|
width: auto;
|
|
104
104
|
cursor: pointer;
|
|
105
105
|
padding: 8px 10px;
|
|
106
106
|
}
|
|
107
|
-
#dev-panel.collapsed .dev-title,
|
|
108
|
-
#dev-panel.collapsed .dev-body { display: none; }
|
|
109
|
-
#dev-panel.collapsed .dev-toggle { margin-left: 6px; }
|
|
110
|
-
#dev-panel .dev-badge {
|
|
107
|
+
#ago-dev-panel.collapsed .dev-title,
|
|
108
|
+
#ago-dev-panel.collapsed .dev-body { display: none; }
|
|
109
|
+
#ago-dev-panel.collapsed .dev-toggle { margin-left: 6px; }
|
|
110
|
+
#ago-dev-panel .dev-badge {
|
|
111
111
|
background: #f59e0b;
|
|
112
112
|
color: #1c1206;
|
|
113
113
|
font-weight: 700;
|
|
@@ -116,17 +116,17 @@ var h = `
|
|
|
116
116
|
padding: 2px 6px;
|
|
117
117
|
border-radius: 5px;
|
|
118
118
|
}
|
|
119
|
-
#dev-panel .dev-title { color: #f59e0b; font-size: 11px; line-height: 1.3; }
|
|
120
|
-
#dev-panel .dev-fns { color: #7c8a99; font-size: 11px; }
|
|
121
|
-
#dev-panel .dev-fns code { color: #9ecbff; }
|
|
122
|
-
#dev-panel .dev-section-label {
|
|
119
|
+
#ago-dev-panel .dev-title { color: #f59e0b; font-size: 11px; line-height: 1.3; }
|
|
120
|
+
#ago-dev-panel .dev-fns { color: #7c8a99; font-size: 11px; }
|
|
121
|
+
#ago-dev-panel .dev-fns code { color: #9ecbff; }
|
|
122
|
+
#ago-dev-panel .dev-section-label {
|
|
123
123
|
color: #7c8a99;
|
|
124
124
|
text-transform: uppercase;
|
|
125
125
|
letter-spacing: .08em;
|
|
126
126
|
font-size: 10px;
|
|
127
127
|
margin-top: 4px;
|
|
128
128
|
}
|
|
129
|
-
#dev-panel .dev-state {
|
|
129
|
+
#ago-dev-panel .dev-state {
|
|
130
130
|
margin: 0;
|
|
131
131
|
padding: 8px;
|
|
132
132
|
background: #060a0e;
|
|
@@ -136,7 +136,7 @@ var h = `
|
|
|
136
136
|
white-space: pre;
|
|
137
137
|
color: #c8e6c9;
|
|
138
138
|
}
|
|
139
|
-
#dev-panel .dev-log {
|
|
139
|
+
#ago-dev-panel .dev-log {
|
|
140
140
|
display: flex;
|
|
141
141
|
flex-direction: column;
|
|
142
142
|
gap: 2px;
|
|
@@ -146,10 +146,10 @@ var h = `
|
|
|
146
146
|
border-radius: 8px;
|
|
147
147
|
padding: 6px 8px;
|
|
148
148
|
}
|
|
149
|
-
#dev-panel .dev-log-line { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
|
|
150
|
-
#dev-panel .dev-log-invoke { color: #9ecbff; }
|
|
151
|
-
#dev-panel .dev-log-result { color: #86efac; }
|
|
152
|
-
#dev-panel .dev-log-error { color: #fca5a5; }
|
|
149
|
+
#ago-dev-panel .dev-log-line { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
|
|
150
|
+
#ago-dev-panel .dev-log-invoke { color: #9ecbff; }
|
|
151
|
+
#ago-dev-panel .dev-log-result { color: #86efac; }
|
|
152
|
+
#ago-dev-panel .dev-log-error { color: #fca5a5; }
|
|
153
153
|
`;
|
|
154
154
|
export {
|
|
155
155
|
m as initDevPanel
|
package/dist/helpers.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./functions-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./functions-BH1X5kas.cjs");exports.copyToClipboard=o.copyToClipboard;exports.getLocalStorage=o.getLocalStorage;exports.getUserLocation=o.getUserLocation;exports.highlightElement=o.highlightElement;exports.openUrl=o.openUrl;exports.scrollToElement=o.scrollToElement;exports.setLocalStorage=o.setLocalStorage;exports.setTheme=o.setTheme;exports.showConfirmDialog=o.showConfirmDialog;exports.showNotification=o.showNotification;exports.showToast=o.showToast;exports.submitForm=o.submitForm;exports.trackEvent=o.trackEvent;
|
package/dist/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a, c as s, d as t, f as e, i as r, l as i, m as l, o as m, p as c, r as g, s as h, t as n, u as p } from "./functions-
|
|
1
|
+
import { a, c as s, d as t, f as e, i as r, l as i, m as l, o as m, p as c, r as g, s as h, t as n, u as p } from "./functions-CWSRi3xv.js";
|
|
2
2
|
export {
|
|
3
3
|
n as copyToClipboard,
|
|
4
4
|
g as getLocalStorage,
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./AgoClient-bjN-z2ZQ.cjs"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./AgoClient-bjN-z2ZQ.cjs"),p=require("./createFormCollector-H4Me_2uj.cjs"),A=require("./createMockClient-DQvFFWnc.cjs"),g=require("./functions-BH1X5kas.cjs");function h(e){return e}function C(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function E(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 S(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function b(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function M(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*k(e,o,l){const n=[];let r=null,a=!1;const c=s=>{n.push(s),r?.()},f=s=>c({type:"start",data:s}),t=s=>c({type:"chunk",data:s}),u=s=>{c({type:"complete",data:s}),a=!0,r?.()},m=s=>{c({type:"error",data:s}),a=!0,r?.()},d=s=>c({type:"toolCall",data:s});e.on("message:start",f),e.on("message:chunk",t),e.on("message:complete",u),e.on("message:error",m),e.on("toolCall:received",d),e.sendMessage(o,l).catch(()=>{a=!0,r?.()});try{for(;!a||n.length>0;)n.length>0?yield n.shift():(await new Promise(s=>{r=s}),r=null)}finally{e.off("message:start",f),e.off("message:chunk",t),e.off("message:complete",u),e.off("message:error",m),e.off("toolCall:received",d)}}function w(e){let o,l,n,r,a,c;if(typeof window<"u"&&window.AGO){const t=window.AGO;o=t.basepath,l=t.widgetId,n=t.agent||t.defaultAgent,r=t.permission,a=t.email,c=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"),n=n||t("ago-agent")||t("ago-agent-id"),r=r||t("ago-permission"),a=a||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,n=n||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,r=r||u.getAttribute("data-ago-permission")||void 0,a=a||u.getAttribute("data-ago-user-email")||void 0)}o=e?.baseUrl||o,l=e?.widgetId||l,n=e?.agent||e?.defaultAgentId||n,r=e?.permission||r,a=e?.userEmail||a,c=e?.userJwt||c;const f=e?.debug;return o?{baseUrl:o,widgetId:l,agent:n,permission:r,userEmail:a,userJwt:c,debug:f}:null}function v(e){const o=w(e);if(!o)throw new Error('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.');return new i.AgoClient(o)}function F(e,o){return{...e,handler:o}}exports.AgoApiError=i.AgoApiError;exports.AgoClient=i.AgoClient;exports.AgoError=i.AgoError;exports.AgoFunctionError=i.AgoFunctionError;exports.AgoNetworkError=i.AgoNetworkError;exports.AgoStreamError=i.AgoStreamError;exports.ClientContextRegistry=i.ClientContextRegistry;exports.EventEmitter=i.EventEmitter;exports.FunctionRegistry=i.FunctionRegistry;exports.SSEHandler=i.SSEHandler;exports.autoDetectConfig=w;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=v;exports.createFormCollector=p.createFormCollector;exports.createMessageStream=k;exports.createMockClient=A.createMockClient;exports.createStore=p.createStore;exports.defineFunction=h;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=i.isStreamNetworkError;exports.logger=i.logger;exports.onFunctionInvoke=M;exports.onMessage=C;exports.onMessageChunk=E;exports.onMessageError=S;exports.onMessageStart=y;exports.onToolCall=b;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.withHandler=F;
|