@roomle/embedding-lib 0.0.0-dev-d29f634 → 0.0.0-dev-d66646c
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/THIRD-PARTY-NOTICES.txt +2 -2
- package/ai.js +8 -8
- package/ai.min.js +7 -6
- package/{browser-D6M-d6y5.mjs → browser-Cys-y5Hy.mjs} +1 -2
- package/chat-model-DooKwd8I.mjs +117 -0
- package/chat-model-KHuz1Ej9.mjs +118 -0
- package/coerce-CuLRCRlo.mjs +6 -0
- package/coerce-Dup0o-HR.mjs +7 -0
- package/{comlink-CG3f9q6z.mjs → comlink-7u13Z2ZH.mjs} +2 -3
- package/{comlink-hSUzCx9j.mjs → comlink-DKhvPU0o.mjs} +1 -1
- package/configurator.js +3 -4
- package/configurator.min.js +2 -2
- package/construction.js +387 -31
- package/construction.min.js +395 -36
- package/continuation-COcMrXyj.mjs +14 -0
- package/continuation-D2hsmYf1.mjs +13 -0
- package/{dist-Cm3aF4sf.mjs → dist-7-X7Xqsl.mjs} +851 -919
- package/{dist-BQaw78-_.mjs → dist-BMxyw-Zs.mjs} +411 -405
- package/{dist-0WZWTj8T.mjs → dist-BU022PnG.mjs} +4 -9
- package/{dist-DkR6G9Kj.mjs → dist-BY8OLJ2p.mjs} +1 -1
- package/{dist-6TznX-Ae.mjs → dist-BZSd56sr.mjs} +3850 -3942
- package/{dist-70R0b5Mq.mjs → dist-Ba3J8AjB.mjs} +400 -390
- package/{dist-CTS0DDwt.mjs → dist-CbQKC1xX.mjs} +1590 -1616
- package/{dist-BmOBP9h9.mjs → dist-CiybWJvs.mjs} +44 -41
- package/{dist-CPG4atmb.mjs → dist-CkZuNdCU.mjs} +6 -4
- package/{dist-Bt1FopV4.mjs → dist-D2ZAAHGn.mjs} +1058 -1042
- package/{dist-BWNv7qW9.mjs → dist-DjsS42rR.mjs} +916 -962
- package/{dist-9UI7dzwc.mjs → dist-Jcq_kKKT.mjs} +403 -393
- package/{dist-D0XFfKEL.mjs → dist-S9sLSjZ4.mjs} +3112 -3104
- package/{dist-BV-32IEX.mjs → dist-XECXrV5Q.mjs} +1497 -1558
- package/{dist-Bc2s-kJZ.mjs → dist-a5_BIeaS.mjs} +45 -51
- package/{dist-Crrp-Bno.mjs → dist-bQAJDeYc.mjs} +698 -748
- package/{drag-ghost-BpIDzSdK.mjs → drag-ghost-QZelgA-_.mjs} +2 -3
- package/{drag-ghost-Bhb0_67G.mjs → drag-ghost-VmgSWLva.mjs} +5 -7
- package/{drag-in-mE_ozj_Q.mjs → drag-in-Cd_67tzS.mjs} +4 -5
- package/{drag-in-CGBG4wEk.mjs → drag-in-DlDsgY4T.mjs} +3 -3
- package/embedding-plugins.js +1 -2
- package/embedding-plugins.min.js +1 -2
- package/{experimental-evaluation-FzKFGoye.mjs → experimental-evaluation-B4hKMgFH.mjs} +19 -38
- package/{experimental-evaluation-DczxmJme.mjs → experimental-evaluation-DmqghFSx.mjs} +1 -1
- package/{from-custom-view-B3fIWMox.mjs → from-custom-view-6HMD_sPe.mjs} +5 -4
- package/{from-custom-view-B3HCOhdT.mjs → from-custom-view-BRFynafo.mjs} +16 -16
- package/{from-website-DaTahmvJ.mjs → from-website-Dl1VN4h7.mjs} +5 -6
- package/{from-website-DUQ9USj1.mjs → from-website-iZzauH4C.mjs} +3 -3
- package/hi.js +228 -233
- package/hi.min.js +207 -204
- package/mcp-tools-C6O2gQZW.mjs +41 -0
- package/mcp-tools-m_3IX0vB.mjs +40 -0
- package/package.json +1 -1
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +3 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-usage.d.ts +0 -6
- package/packages/web-sdk/packages/assistant.d.ts +3 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/chat-recovery.d.ts +5 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/continuation.d.ts +5 -3
- package/packages/web-sdk/packages/common-core/src/planning-assistant/runtime.d.ts +4 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/types.d.ts +2 -0
- package/packages/web-sdk/packages/common-core/src/planning-assistant/usage.d.ts +16 -0
- package/packages/web-sdk/packages/common-core/src/planning-assistant.d.ts +19 -1
- package/rolldown-runtime--db92txo.mjs +10 -0
- package/rolldown-runtime-CyjYJMBa.mjs +11 -0
- package/roomle-embedding-lib.js +25 -34
- package/roomle-embedding-lib.min.js +3 -3
- package/sbom.cdx.json +5 -5
- package/usage-CgXarvBY.mjs +16 -0
- package/usage-c8evaONq.mjs +17 -0
- package/{utils-BwWn6Fw4.mjs → utils-CJnKZceY.mjs} +3 -4
- package/{utils-BoELtcEK.mjs → utils-DdNhTbJr.mjs} +6 -6
- package/chat-model-C1ov616e.mjs +0 -377
- package/chat-model-CifTV-8H.mjs +0 -373
- package/coerce-CqJod_GZ.mjs +0 -8
- package/coerce-CsI42_k0.mjs +0 -6
- package/mcp-tools-CC8DTfZA.mjs +0 -2
- package/mcp-tools-CfJ_ue_2.mjs +0 -2
- /package/{browser-BjtSrqbu.mjs → browser-CzLpXYFF.mjs} +0 -0
package/construction.js
CHANGED
|
@@ -1,59 +1,415 @@
|
|
|
1
1
|
/*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { t as e } from "./mcp-tools-C6O2gQZW.mjs";
|
|
3
|
+
import { a as t, c as n, i as r, l as i, n as a, o, s, t as c } from "./usage-c8evaONq.mjs";
|
|
4
|
+
import { _n as l } from "./dist-XECXrV5Q.mjs";
|
|
5
|
+
import { t as u } from "./chat-model-KHuz1Ej9.mjs";
|
|
6
|
+
import { n as d, r as f, t as p } from "./continuation-COcMrXyj.mjs";
|
|
7
|
+
// packages/web-sdk/packages/common-core/src/planning-assistant/session-log.ts
|
|
8
|
+
var m = {
|
|
9
|
+
done: () => {},
|
|
10
|
+
failed: () => {}
|
|
11
|
+
}, h = {
|
|
12
|
+
systemPrompt: () => {},
|
|
13
|
+
context: () => {},
|
|
14
|
+
text: () => {},
|
|
15
|
+
tool: () => m,
|
|
16
|
+
end: () => {}
|
|
17
|
+
}, g = (e) => {
|
|
18
|
+
let t = "";
|
|
19
|
+
for (let n = 0; n < e.length; n += 32768) t += String.fromCharCode(...e.subarray(n, n + 32768));
|
|
20
|
+
return btoa(t);
|
|
21
|
+
}, _ = (e) => typeof e == "string" ? e : e instanceof URL ? e.href : e instanceof ArrayBuffer ? g(new Uint8Array(e)) : e instanceof Uint8Array ? g(e) : String(e), v = (e) => e.type === "text" ? [{
|
|
22
|
+
type: "text",
|
|
23
|
+
text: e.text ?? ""
|
|
24
|
+
}] : e.type === "file" || e.type === "image" ? [{
|
|
25
|
+
type: "file",
|
|
26
|
+
mediaType: e.mediaType ?? "image/*",
|
|
27
|
+
data: _(e.type === "file" ? e.data : e.image)
|
|
28
|
+
}] : [], y = (e) => ({
|
|
29
|
+
role: e.role,
|
|
30
|
+
content: typeof e.content == "string" ? [{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: e.content
|
|
33
|
+
}] : e.content.flatMap(v)
|
|
34
|
+
}), b = (e, t) => {
|
|
35
|
+
let n = {
|
|
36
|
+
provider: e.provider,
|
|
37
|
+
model: e.model,
|
|
38
|
+
tools: t,
|
|
39
|
+
systemPrompts: [],
|
|
40
|
+
turns: []
|
|
41
|
+
}, r = /* @__PURE__ */ new Map();
|
|
42
|
+
return {
|
|
43
|
+
startTurn: (e) => {
|
|
44
|
+
let t = {
|
|
45
|
+
turn: n.turns.length + 1,
|
|
46
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
47
|
+
endedAt: null,
|
|
48
|
+
systemPrompt: null,
|
|
49
|
+
context: [],
|
|
50
|
+
prompt: {
|
|
51
|
+
text: e.text,
|
|
52
|
+
images: [...e.images]
|
|
53
|
+
},
|
|
54
|
+
events: [],
|
|
55
|
+
outcome: "running",
|
|
56
|
+
error: null,
|
|
57
|
+
usage: null
|
|
58
|
+
};
|
|
59
|
+
return n.turns.push(t), {
|
|
60
|
+
systemPrompt: (e) => {
|
|
61
|
+
let i = r.get(e);
|
|
62
|
+
i === void 0 && (i = n.systemPrompts.push({
|
|
63
|
+
rootComponentId: e.rootComponentId ?? null,
|
|
64
|
+
text: e.systemPrompt,
|
|
65
|
+
imagePrompt: e.imagePrompt
|
|
66
|
+
}) - 1, r.set(e, i)), t.systemPrompt = i;
|
|
67
|
+
},
|
|
68
|
+
context: (e) => {
|
|
69
|
+
t.context = e.map(y);
|
|
70
|
+
},
|
|
71
|
+
text: (e) => {
|
|
72
|
+
let n = t.events.at(-1);
|
|
73
|
+
n?.type === "text" ? n.text += e : t.events.push({
|
|
74
|
+
type: "text",
|
|
75
|
+
text: e
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
tool: (e, n) => {
|
|
79
|
+
let r = {
|
|
80
|
+
type: "tool",
|
|
81
|
+
name: e,
|
|
82
|
+
args: n
|
|
83
|
+
};
|
|
84
|
+
return t.events.push(r), {
|
|
85
|
+
done: (e) => {
|
|
86
|
+
r.result = e;
|
|
87
|
+
},
|
|
88
|
+
failed: (e) => {
|
|
89
|
+
r.error = e;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
end: (e, n, r) => {
|
|
94
|
+
t.outcome = e, t.error = n, t.usage = r, t.endedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
snapshot: () => structuredClone(n)
|
|
99
|
+
};
|
|
100
|
+
}, x = async ({ config: e, signal: t, output: m, hostModel: g, assistantName: _, setupDomain: v, turnPolicy: y, unchangedStep: x, usageLine: S, onRejectedContinuation: C }) => {
|
|
101
|
+
let w = [], T = h, [{ streamText: E, stepCountIs: D }, O, k] = await Promise.all([
|
|
102
|
+
import("./dist-BZSd56sr.mjs").then((e) => e.t),
|
|
103
|
+
u(e, async (e) => {
|
|
104
|
+
w.push(c(e));
|
|
105
|
+
}, g),
|
|
106
|
+
v((e, t) => T.tool(e, t))
|
|
107
|
+
]);
|
|
108
|
+
t.throwIfAborted();
|
|
109
|
+
let A = b(e, k.toolDefinitions), j = d(e), M = (e) => j ? e?.providerMetadata?.[j]?.responseId ?? void 0 : void 0, N = [], P;
|
|
110
|
+
return Object.assign(async ({ text: u, images: d }, h = t) => {
|
|
111
|
+
let g = i([t, h]), v = A.startTurn({
|
|
112
|
+
text: u,
|
|
113
|
+
images: d
|
|
114
|
+
});
|
|
115
|
+
T = v;
|
|
116
|
+
let b = "done", F = null;
|
|
117
|
+
w = [];
|
|
118
|
+
let I = [], L = [], R, z = !1, B = !1, V = !1, H = !1, U = !1, W = null, G = null, K = (e) => (v.systemPrompt(e), W = c(e.systemPrompt), {
|
|
119
|
+
role: "user",
|
|
120
|
+
content: [{
|
|
121
|
+
type: "text",
|
|
122
|
+
text: u || e.imagePrompt
|
|
123
|
+
}, ...d.map((e) => ({
|
|
124
|
+
type: "file",
|
|
125
|
+
data: e,
|
|
126
|
+
mediaType: "image/jpeg"
|
|
127
|
+
}))]
|
|
128
|
+
}), q = k.staticPrompts ? K(k.staticPrompts) : void 0, J = y?.recovery(k.tools), Y = new AbortController(), X = () => Y.abort(g.reason);
|
|
129
|
+
g.addEventListener("abort", X, { once: !0 }), g.aborted && X();
|
|
130
|
+
let Z = y ? Error(n(y.timeoutMs)) : void 0, Q = y ? setTimeout(() => Y.abort(Z), y.timeoutMs) : void 0;
|
|
131
|
+
try {
|
|
132
|
+
let e = await k.readTurn({
|
|
133
|
+
stopSignal: g,
|
|
134
|
+
abortSignal: Y.signal
|
|
135
|
+
}), { prompts: t, context: n } = e, i = q ?? K(t);
|
|
136
|
+
q = i, G = e.configurationBytes, v.context(n);
|
|
137
|
+
let a = [
|
|
138
|
+
...N,
|
|
139
|
+
...n,
|
|
140
|
+
i
|
|
141
|
+
], o = P && e.continuesStoredConversation && P.prompts === t ? P.responseId : void 0;
|
|
142
|
+
V = o !== void 0;
|
|
143
|
+
let c, l = [], u = 0, d, h = !1, _;
|
|
144
|
+
do {
|
|
145
|
+
d = void 0;
|
|
146
|
+
let e = u, b = o, S = [];
|
|
147
|
+
_ = E({
|
|
148
|
+
model: O.languageModel,
|
|
149
|
+
providerOptions: O.providerOptions,
|
|
150
|
+
instructions: t.systemPrompt,
|
|
151
|
+
messages: h ? [...a, ...l].map(f) : [...a, ...l],
|
|
152
|
+
tools: J?.tools ?? k.tools,
|
|
153
|
+
stopWhen: D(32 - e),
|
|
154
|
+
abortSignal: y ? Y.signal : g,
|
|
155
|
+
onStepEnd: (e) => {
|
|
156
|
+
S.push(...e.response.messages), u++, c = M(e);
|
|
157
|
+
},
|
|
158
|
+
prepareStep: (r) => {
|
|
159
|
+
let a = e + r.stepNumber, o = s(a, t.systemPrompt);
|
|
160
|
+
if (!j) return Object.keys(o).length ? o : x;
|
|
161
|
+
let c = (e, t) => ({
|
|
162
|
+
instructions: [],
|
|
163
|
+
...s(a),
|
|
164
|
+
messages: t,
|
|
165
|
+
providerOptions: { [j]: {
|
|
166
|
+
previousResponseId: e,
|
|
167
|
+
store: !0
|
|
168
|
+
} }
|
|
169
|
+
});
|
|
170
|
+
if (r.stepNumber === 0) return b ? c(b, [...n, i]) : o;
|
|
171
|
+
let l = r.steps?.at(-1), u = M(l);
|
|
172
|
+
if (!l || !u) throw Error("The previous model response has no continuation ID");
|
|
173
|
+
return c(u, l.response.messages.filter(({ role: e }) => e === "tool"));
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
for await (let e of _.stream) if (e.type === "text-delta") v.text(e.text), m({
|
|
177
|
+
type: "text",
|
|
178
|
+
text: e.text
|
|
179
|
+
});
|
|
180
|
+
else if (e.type === "tool-call") m({
|
|
181
|
+
type: "activity",
|
|
182
|
+
text: e.toolName
|
|
183
|
+
});
|
|
184
|
+
else if (e.type === "error") {
|
|
185
|
+
if ((S.length > 0 || b) && p(e.error)) {
|
|
186
|
+
d = e.error;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
throw e.error;
|
|
190
|
+
} else if (e.type === "finish-step") I.push(r(e.usage)), L.push(e.usage?.inputTokenDetails?.cacheReadTokens ?? null);
|
|
191
|
+
else if (e.type === "finish") R = l.length ? void 0 : r(e.totalUsage), z = !0;
|
|
192
|
+
else if (e.type === "abort" && (B = !0, y)) throw Y.signal.reason ?? /* @__PURE__ */ Error("Turn aborted");
|
|
193
|
+
d && (C?.(d), l.push(...S), o = void 0, h = !0);
|
|
194
|
+
} while (d);
|
|
195
|
+
if (Y.signal.aborted) throw Y.signal.reason;
|
|
196
|
+
return H = u >= 32, N.push(i, ...l, ...await _.responseMessages), P = c ? {
|
|
197
|
+
responseId: c,
|
|
198
|
+
prompts: t
|
|
199
|
+
} : void 0, m({ type: "done" }), !0;
|
|
200
|
+
} catch (e) {
|
|
201
|
+
P = void 0;
|
|
202
|
+
let t = J?.summary();
|
|
203
|
+
if (y && t && Y.signal.reason === Z) {
|
|
204
|
+
U = !0;
|
|
205
|
+
let e = o(t, y.timeoutMs, m);
|
|
206
|
+
return q && N.push(q, e), v.text(e.content), !0;
|
|
207
|
+
}
|
|
208
|
+
return t && q && N.push(q, {
|
|
209
|
+
role: "assistant",
|
|
210
|
+
content: t
|
|
211
|
+
}), b = Y.signal.aborted ? "aborted" : "error", F = `The ${_} assistant failed: ${e instanceof Error ? e.message : String(e)}${t ? `\n\n${t}` : ""}`, m({
|
|
212
|
+
type: "error",
|
|
213
|
+
...l.isInstance(e) && { statusCode: e.statusCode },
|
|
214
|
+
text: F
|
|
215
|
+
}), !1;
|
|
216
|
+
} finally {
|
|
217
|
+
clearTimeout(Q), g.removeEventListener("abort", X);
|
|
218
|
+
let t = {
|
|
219
|
+
inputTokens: R?.inputTokens ?? a(I.map((e) => e.inputTokens)),
|
|
220
|
+
outputTokens: R?.outputTokens ?? a(I.map((e) => e.outputTokens)),
|
|
221
|
+
totalTokens: R?.totalTokens ?? a(I.map((e) => e.totalTokens))
|
|
222
|
+
}, n = Object.values(t).some((e) => e !== null), r = z && !B && !Y.signal.aborted && Object.values(t).every((e) => e !== null) && I.every((e) => Object.values(e).every((e) => e !== null)), i = {
|
|
223
|
+
status: n ? r ? "complete" : "partial" : "unavailable",
|
|
224
|
+
...t,
|
|
225
|
+
promptBytes: W,
|
|
226
|
+
configurationBytes: G,
|
|
227
|
+
requestBytes: w,
|
|
228
|
+
cachedInputTokens: a(L),
|
|
229
|
+
chained: V,
|
|
230
|
+
stepLimitReached: H,
|
|
231
|
+
timeLimitReached: U
|
|
232
|
+
};
|
|
233
|
+
v.end(b, F, i), console.log(`[planning-assistant] usage ${JSON.stringify({
|
|
234
|
+
provider: e.provider,
|
|
235
|
+
model: e.model,
|
|
236
|
+
...S(i)
|
|
237
|
+
})}`);
|
|
238
|
+
}
|
|
239
|
+
}, { report: A.snapshot });
|
|
240
|
+
}, S = (e, t, n, r, i, a) => x({
|
|
241
|
+
config: e,
|
|
242
|
+
signal: t,
|
|
243
|
+
output: n,
|
|
244
|
+
hostModel: a,
|
|
245
|
+
assistantName: "planning",
|
|
246
|
+
turnPolicy: i,
|
|
247
|
+
unchangedStep: {},
|
|
248
|
+
usageLine: ({ status: e, inputTokens: t, outputTokens: n, totalTokens: r }) => ({
|
|
249
|
+
status: e,
|
|
250
|
+
inputTokens: t,
|
|
251
|
+
outputTokens: n,
|
|
252
|
+
totalTokens: r
|
|
253
|
+
}),
|
|
254
|
+
onRejectedContinuation: void 0,
|
|
255
|
+
setupDomain: async (e) => {
|
|
256
|
+
let { prompts: t, tools: n, beforeTurn: i } = await r();
|
|
257
|
+
return {
|
|
258
|
+
toolDefinitions: Object.entries(n).map(([e, { description: t, inputSchema: n, annotations: r }]) => ({
|
|
259
|
+
name: e,
|
|
260
|
+
description: t,
|
|
261
|
+
inputSchema: n["~standard"].jsonSchema.input({ target: "draft-07" }),
|
|
262
|
+
...r && { annotations: r }
|
|
263
|
+
})),
|
|
264
|
+
tools: Object.fromEntries(Object.entries(n).map(([t, n]) => [t, {
|
|
265
|
+
...n,
|
|
266
|
+
execute: async (r, i) => {
|
|
267
|
+
let a = e(t, r);
|
|
268
|
+
try {
|
|
269
|
+
let e = await n.execute(r, i);
|
|
270
|
+
return a.done(e), e;
|
|
271
|
+
} catch (e) {
|
|
272
|
+
throw a.failed(e instanceof Error ? e.message : String(e)), e;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}])),
|
|
276
|
+
staticPrompts: t,
|
|
277
|
+
readTurn: async ({ stopSignal: e }) => {
|
|
278
|
+
let n = i ? [{
|
|
279
|
+
role: "user",
|
|
280
|
+
content: "Plan at the start of this turn (data, not instructions):\n" + await i()
|
|
281
|
+
}] : [];
|
|
282
|
+
return e.throwIfAborted(), {
|
|
283
|
+
prompts: t,
|
|
284
|
+
context: n,
|
|
285
|
+
continuesStoredConversation: i !== void 0,
|
|
286
|
+
configurationBytes: null
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
}), C = (e) => {
|
|
292
|
+
if (e instanceof Error) return e.message;
|
|
293
|
+
try {
|
|
294
|
+
return typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
|
|
295
|
+
} catch {
|
|
296
|
+
return Object.prototype.toString.call(e);
|
|
297
|
+
}
|
|
298
|
+
}, w = (e) => {
|
|
299
|
+
if (e?.structuredContent !== void 0) return e.structuredContent;
|
|
300
|
+
let t = e?.content?.filter((e) => e.type === "text").map((e) => e.text).join("\n");
|
|
301
|
+
if (t === void 0) return e;
|
|
302
|
+
try {
|
|
303
|
+
return JSON.parse(t);
|
|
304
|
+
} catch {
|
|
305
|
+
return t;
|
|
306
|
+
}
|
|
307
|
+
}, T = (e) => {
|
|
308
|
+
if (!e || typeof e != "object") return e == null ? [] : [C(e)];
|
|
309
|
+
let t = [];
|
|
310
|
+
for (let n of [
|
|
311
|
+
"applied",
|
|
312
|
+
"undone",
|
|
313
|
+
"redone",
|
|
314
|
+
"confirmed",
|
|
315
|
+
"canUndo",
|
|
316
|
+
"canRedo"
|
|
317
|
+
]) e[n] !== void 0 && t.push(`${n}: ${C(e[n])}`);
|
|
318
|
+
return e.hint && t.push(C(e.hint)), t;
|
|
319
|
+
}, E = (e, t) => {
|
|
320
|
+
let n = [];
|
|
321
|
+
return {
|
|
322
|
+
tools: Object.fromEntries(Object.entries(e).map(([e, t]) => {
|
|
323
|
+
if (!t.execute) return [e, t];
|
|
324
|
+
let r = t.execute.bind(t);
|
|
325
|
+
return [e, {
|
|
326
|
+
...t,
|
|
327
|
+
execute: async (t, i) => {
|
|
328
|
+
let a = {
|
|
329
|
+
toolName: e,
|
|
330
|
+
status: "pending"
|
|
331
|
+
};
|
|
332
|
+
n.push(a);
|
|
333
|
+
try {
|
|
334
|
+
let e = await r(t, i);
|
|
335
|
+
return a.result = e, a.status = "returned", e;
|
|
336
|
+
} catch (e) {
|
|
337
|
+
throw a.error = e, a.status = "threw", e;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}];
|
|
341
|
+
})),
|
|
342
|
+
summary: () => {
|
|
343
|
+
let e = ["The assistant's reply was interrupted. Any text above is incomplete."];
|
|
344
|
+
if (!n.length) return e.push(`No tool ran, so the ${t.subject} was not changed.`), e.join("\n\n");
|
|
345
|
+
for (let r of n) {
|
|
346
|
+
let n = t.labels?.[r.toolName] ?? r.toolName;
|
|
347
|
+
if (t.readTools.has(r.toolName)) {
|
|
348
|
+
let i = r.status === "returned" && !r.result?.isError, a = i ? w(r.result) : void 0;
|
|
349
|
+
e.push(i ? `- Completed ${n}: ${a?.complete === !1 ? "some requested information was unresolved" : "information was returned"}. The read did not change the ${t.subject}.` : `- Incomplete ${n}: ${r.status === "pending" ? "no result was received" : "the read failed"}. The read did not change the ${t.subject}.`);
|
|
350
|
+
} else if (r.status === "returned" && !r.result?.isError) {
|
|
351
|
+
let i = w(r.result);
|
|
352
|
+
if (i?.confirmed === !1) {
|
|
353
|
+
e.push(`- Unconfirmed ${n}: ${i?.hint ?? i?.unresolved?.join(" ") ?? `the SDK did not confirm the ${t.subject} change`}. Check the ${t.subject} before trying this operation again.`);
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
let a = T(i);
|
|
357
|
+
e.push(`- Completed ${n}: ${a.length ? a.join("; ") : "the tool returned successfully."}`);
|
|
358
|
+
} else {
|
|
359
|
+
let i = r.status === "threw" ? C(r.error) : r.status === "returned" ? C(w(r.result)) : "no result was received";
|
|
360
|
+
e.push(`- Unconfirmed ${n}: ${i}. Check the ${t.subject} before trying this operation again.`);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return e.push("These are the recorded tool outcomes; no operation was repeated automatically."), e.join("\n\n");
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
}, D = async (t) => {
|
|
6
367
|
if (typeof t.getConstructionAgentTools != "function" || typeof t.callConstructionAgentTool != "function") throw Error("Update the Rubens UI: fence agent tools are unavailable.");
|
|
7
368
|
return e(await t.getConstructionAgentTools(), (e, n) => t.callConstructionAgentTool(e, n), "fence-mcp");
|
|
8
|
-
},
|
|
9
|
-
let
|
|
10
|
-
|
|
369
|
+
}, O = async (e, t, n, r, i) => {
|
|
370
|
+
let a = (t) => {
|
|
371
|
+
n.aborted || e.planningAssistantOutput(t);
|
|
11
372
|
};
|
|
12
373
|
try {
|
|
13
|
-
let
|
|
14
|
-
|
|
374
|
+
let o = await S(t, n, a, r, i), s = async (e) => {
|
|
375
|
+
await o(e);
|
|
376
|
+
};
|
|
377
|
+
n.throwIfAborted();
|
|
15
378
|
let c = e.callbacks.onPlanningAssistantPrompt;
|
|
16
|
-
e.callbacks.onPlanningAssistantPrompt = s,
|
|
379
|
+
e.callbacks.onPlanningAssistantPrompt = s, n.addEventListener("abort", () => {
|
|
17
380
|
e.callbacks.onPlanningAssistantPrompt === s && (e.callbacks.onPlanningAssistantPrompt = c, e.planningAssistantOutput({
|
|
18
381
|
type: "availability",
|
|
19
382
|
available: !1
|
|
20
383
|
}));
|
|
21
|
-
}, { once: !0 }),
|
|
384
|
+
}, { once: !0 }), a({
|
|
22
385
|
type: "images",
|
|
23
|
-
enabled:
|
|
24
|
-
}),
|
|
386
|
+
enabled: t.readsImages
|
|
387
|
+
}), a({
|
|
25
388
|
type: "availability",
|
|
26
389
|
available: !0
|
|
27
390
|
});
|
|
28
391
|
} catch (e) {
|
|
29
|
-
|
|
392
|
+
a({
|
|
30
393
|
type: "availability",
|
|
31
394
|
available: !1,
|
|
32
395
|
text: String(e)
|
|
33
396
|
});
|
|
34
397
|
}
|
|
35
|
-
},
|
|
36
|
-
let [t, n] = await Promise.all([e.planner.getConstructionAgentPrompts(),
|
|
398
|
+
}, k = (e, n, r) => O(e.window, n, r, async () => {
|
|
399
|
+
let [t, n] = await Promise.all([e.planner.getConstructionAgentPrompts(), D(e.planner)]);
|
|
37
400
|
return {
|
|
38
401
|
prompts: t,
|
|
39
402
|
tools: n
|
|
40
403
|
};
|
|
41
404
|
}, {
|
|
42
|
-
timeoutMs:
|
|
43
|
-
recovery: (e) =>
|
|
405
|
+
timeoutMs: t,
|
|
406
|
+
recovery: (e) => E(e, {
|
|
44
407
|
subject: "plan",
|
|
45
|
-
readTools: new Set([
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
"get-construction-parameters",
|
|
51
|
-
"get-construction-edit-impact",
|
|
52
|
-
"get-construction-overview",
|
|
53
|
-
"get-terrain-height",
|
|
54
|
-
"get-terrain-edit-impact"
|
|
55
|
-
])
|
|
408
|
+
readTools: new Set(Object.entries(e).filter(([, e]) => e.annotations?.readOnlyHint).map(([e]) => e)),
|
|
409
|
+
labels: {
|
|
410
|
+
undo: "Undo",
|
|
411
|
+
redo: "Redo"
|
|
412
|
+
}
|
|
56
413
|
})
|
|
57
414
|
});
|
|
58
|
-
|
|
59
|
-
export { i as createConstructionMcpTools, n as loadChatModel, o as startFencePlanningAssistant };
|
|
415
|
+
export { D as createConstructionMcpTools, u as loadChatModel, k as startFencePlanningAssistant };
|