@roomle/embedding-lib 11.0.0-alpha.1 → 11.0.0-alpha.10
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 +86 -17
- package/ai.min.js +83 -13
- package/{browser-D6M-d6y5.mjs → browser-Cys-y5Hy.mjs} +1 -2
- package/chat-model-B7BO8IhK.mjs +212 -0
- package/chat-model-XYf503pT.mjs +213 -0
- package/coerce-CuLRCRlo.mjs +6 -0
- package/coerce-Dup0o-HR.mjs +7 -0
- package/{comlink-m82YLjsS.mjs → comlink-7u13Z2ZH.mjs} +2 -3
- package/{comlink-BYqErFai.mjs → comlink-DKhvPU0o.mjs} +1 -1
- package/configurator.js +7 -7
- package/configurator.min.js +6 -5
- package/construction.js +279 -22
- package/construction.min.js +287 -27
- package/continuation-CswXtOus.mjs +10 -0
- package/continuation-NclHDSgS.mjs +9 -0
- package/{dist-DCzWWudD.mjs → dist-7-X7Xqsl.mjs} +851 -919
- package/{dist-CjIZv2gB.mjs → dist-BMxyw-Zs.mjs} +411 -405
- package/{dist-wPZpiGiu.mjs → dist-BU022PnG.mjs} +4 -9
- package/{dist-CGgFMwb1.mjs → dist-BY8OLJ2p.mjs} +1 -1
- package/{dist-6TznX-Ae.mjs → dist-BZSd56sr.mjs} +3850 -3942
- package/{dist-Ur4DqwwC.mjs → dist-Ba3J8AjB.mjs} +400 -390
- package/{dist-CnTUCpLZ.mjs → dist-CbQKC1xX.mjs} +1590 -1616
- package/{dist-BsVeWZ8R.mjs → dist-CiybWJvs.mjs} +44 -41
- package/{dist-BI_3AeI-.mjs → dist-CkZuNdCU.mjs} +6 -4
- package/{dist-Bt1FopV4.mjs → dist-D2ZAAHGn.mjs} +1058 -1042
- package/{dist-Cxe4osFc.mjs → dist-DjsS42rR.mjs} +916 -962
- package/{dist-Cmx_tCV5.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-CZbrRF4T.mjs → dist-a5_BIeaS.mjs} +45 -51
- package/{dist-Dr3LcjP6.mjs → dist-bQAJDeYc.mjs} +698 -748
- package/docs/md/web/embedding/CHANGELOG.md +20 -175
- package/{drag-ghost-C1WS2KmW.mjs → drag-ghost-QZelgA-_.mjs} +2 -3
- package/{drag-ghost-B24KVqgc.mjs → drag-ghost-VmgSWLva.mjs} +5 -7
- package/{drag-in-O5uwMddL.mjs → drag-in-Cd_67tzS.mjs} +4 -5
- package/{drag-in-CWHSbwvG.mjs → drag-in-DlDsgY4T.mjs} +3 -3
- package/embedding-plugins.js +1 -2
- package/embedding-plugins.min.js +1 -2
- package/{experimental-evaluation-DyONuPyk.mjs → experimental-evaluation-B4hKMgFH.mjs} +19 -38
- package/{experimental-evaluation-DPkDk-5A.mjs → experimental-evaluation-DmqghFSx.mjs} +1 -1
- package/{from-custom-view-BgmiWIEN.mjs → from-custom-view-6HMD_sPe.mjs} +5 -4
- package/{from-custom-view-CxmIIsHU.mjs → from-custom-view-BRFynafo.mjs} +16 -16
- package/{from-website-CvcnHmr2.mjs → from-website-Dl1VN4h7.mjs} +5 -6
- package/{from-website-B8qFEG_R.mjs → from-website-iZzauH4C.mjs} +3 -3
- package/hi.js +251 -214
- package/hi.min.js +330 -288
- package/mcp-tools-BLB7pCga.mjs +42 -0
- package/mcp-tools-BirFT2R0.mjs +41 -0
- package/package.json +1 -1
- package/packages/common/src/utils/ai-model-relay.d.ts +22 -2
- package/packages/embedding-lib/src/ai.d.ts +3 -1
- package/packages/embedding-lib/src/hi.d.ts +1 -1
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +14 -2
- package/packages/embedding-lib/src/planning-assistant/chat-model.d.ts +1 -1
- package/packages/web-sdk/packages/assistant.d.ts +2 -0
- package/packages/web-sdk/packages/common-core/src/planning-assistant/chat-model.d.ts +1 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/continuation.d.ts +5 -0
- package/packages/web-sdk/packages/common-core/src/planning-assistant/mcp-tools.d.ts +3 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/runtime.d.ts +6 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/types.d.ts +3 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant.d.ts +3 -0
- 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/turn-limits-9LbUeSG2.mjs +9 -0
- package/turn-limits-Ciq383Bd.mjs +10 -0
- package/{utils-BwWn6Fw4.mjs → utils-CJnKZceY.mjs} +3 -4
- package/{utils-BoELtcEK.mjs → utils-DdNhTbJr.mjs} +6 -6
- package/chat-model-CFuHw4cp.mjs +0 -322
- package/chat-model-JqqVnnmY.mjs +0 -327
- package/coerce-CqJod_GZ.mjs +0 -8
- package/coerce-CsI42_k0.mjs +0 -6
- /package/{browser-BjtSrqbu.mjs → browser-CzLpXYFF.mjs} +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
|
|
2
|
+
// packages/web-sdk/packages/common-core/src/planning-assistant/chat-model.ts
|
|
3
|
+
var e = (e) => e.flatMap((e) => {
|
|
4
|
+
if (e.role !== "tool") return [e];
|
|
5
|
+
let t = [], n = e.content.map((e) => {
|
|
6
|
+
if (e.type !== "tool-result" || e.output.type !== "content") return e;
|
|
7
|
+
let n = e.output.value.filter((e) => e.type === "file");
|
|
8
|
+
return n.length ? (t.push(...n), {
|
|
9
|
+
...e,
|
|
10
|
+
output: {
|
|
11
|
+
...e.output,
|
|
12
|
+
value: [...e.output.value.filter((e) => e.type !== "file"), {
|
|
13
|
+
type: "text",
|
|
14
|
+
text: "The images of this result follow in the next message."
|
|
15
|
+
}]
|
|
16
|
+
}
|
|
17
|
+
}) : e;
|
|
18
|
+
});
|
|
19
|
+
return t.length ? [{
|
|
20
|
+
...e,
|
|
21
|
+
content: n
|
|
22
|
+
}, {
|
|
23
|
+
role: "user",
|
|
24
|
+
content: t
|
|
25
|
+
}] : [e];
|
|
26
|
+
}), t = (t) => ({
|
|
27
|
+
specificationVersion: t.specificationVersion,
|
|
28
|
+
provider: t.provider,
|
|
29
|
+
modelId: t.modelId,
|
|
30
|
+
supportedUrls: t.supportedUrls,
|
|
31
|
+
doGenerate: (n) => t.doGenerate({
|
|
32
|
+
...n,
|
|
33
|
+
prompt: e(n.prompt)
|
|
34
|
+
}),
|
|
35
|
+
doStream: (n) => t.doStream({
|
|
36
|
+
...n,
|
|
37
|
+
prompt: e(n.prompt)
|
|
38
|
+
})
|
|
39
|
+
}), n = async ({ provider: e, model: n, apiKey: r, baseUrl: i, headers: a, chatCompletions: o, responses: s, storedResponses: c, reasoningEffort: l }, u, d) => {
|
|
40
|
+
let f = u ? { fetch: new Proxy(fetch, { apply: async (e, t, n) => (typeof n[1]?.body == "string" && await u(n[1].body), fetch(...n)) }) } : {};
|
|
41
|
+
switch (e) {
|
|
42
|
+
case "host":
|
|
43
|
+
if (!d) throw Error("The host assistant model is unavailable.");
|
|
44
|
+
return { languageModel: d };
|
|
45
|
+
case "openai": {
|
|
46
|
+
let { createOpenAI: e } = await import("./dist-DjsS42rR.mjs");
|
|
47
|
+
return { languageModel: e({
|
|
48
|
+
apiKey: r,
|
|
49
|
+
...f
|
|
50
|
+
})(n) };
|
|
51
|
+
}
|
|
52
|
+
case "azure": {
|
|
53
|
+
let { createAzure: e } = await import("./dist-bQAJDeYc.mjs"), t = e({
|
|
54
|
+
apiKey: r,
|
|
55
|
+
baseURL: i,
|
|
56
|
+
...f
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
languageModel: o ? t.chat(n) : t(n),
|
|
60
|
+
providerOptions: l ? { azure: { reasoningEffort: l } } : void 0
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
case "openai-compatible": {
|
|
64
|
+
if (!i) throw Error("The provider \"openai-compatible\" needs a baseUrl");
|
|
65
|
+
if (s) {
|
|
66
|
+
let { createOpenAI: e } = await import("./dist-DjsS42rR.mjs"), t = {
|
|
67
|
+
...!r && !a?.Authorization ? { Authorization: void 0 } : {},
|
|
68
|
+
...a
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
languageModel: e({
|
|
72
|
+
baseURL: i,
|
|
73
|
+
apiKey: r ?? "none",
|
|
74
|
+
headers: t,
|
|
75
|
+
...f
|
|
76
|
+
}).responses(n),
|
|
77
|
+
providerOptions: { openai: c ? { store: !0 } : {
|
|
78
|
+
store: !1,
|
|
79
|
+
forceReasoning: !0
|
|
80
|
+
} }
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
let { createOpenAICompatible: e } = await import("./dist-BU022PnG.mjs");
|
|
84
|
+
return { languageModel: t(e({
|
|
85
|
+
name: "openai-compatible",
|
|
86
|
+
baseURL: i,
|
|
87
|
+
apiKey: r,
|
|
88
|
+
headers: a,
|
|
89
|
+
includeUsage: !0,
|
|
90
|
+
...f
|
|
91
|
+
})(n)) };
|
|
92
|
+
}
|
|
93
|
+
case "mistral": {
|
|
94
|
+
let { createMistral: e } = await import("./dist-a5_BIeaS.mjs");
|
|
95
|
+
return { languageModel: t(e({
|
|
96
|
+
apiKey: r,
|
|
97
|
+
...f
|
|
98
|
+
})(n)) };
|
|
99
|
+
}
|
|
100
|
+
case "anthropic": {
|
|
101
|
+
let { createAnthropic: e } = await import("./dist-CbQKC1xX.mjs");
|
|
102
|
+
return { languageModel: e({
|
|
103
|
+
apiKey: r,
|
|
104
|
+
headers: { "anthropic-dangerous-direct-browser-access": "true" },
|
|
105
|
+
...f
|
|
106
|
+
})(n) };
|
|
107
|
+
}
|
|
108
|
+
case "google": {
|
|
109
|
+
let { createGoogleGenerativeAI: e } = await import("./dist-7-X7Xqsl.mjs");
|
|
110
|
+
return { languageModel: e({
|
|
111
|
+
apiKey: r,
|
|
112
|
+
...f
|
|
113
|
+
})(n) };
|
|
114
|
+
}
|
|
115
|
+
default: throw Error(`Unknown provider "${e}" - supported: azure, openai, openai-compatible, mistral, anthropic, google`);
|
|
116
|
+
}
|
|
117
|
+
}, r = {
|
|
118
|
+
undo: "Undo",
|
|
119
|
+
redo: "Redo",
|
|
120
|
+
"change-component-parameter": "Component parameter change",
|
|
121
|
+
"change-global-parameter": "Global parameter change",
|
|
122
|
+
"dock-component": "Component dock",
|
|
123
|
+
"drag-component": "Component drag",
|
|
124
|
+
"delete-component": "Component deletion",
|
|
125
|
+
"load-configuration": "Configuration load",
|
|
126
|
+
"get-configurator-capabilities": "Capabilities read",
|
|
127
|
+
"get-configuration": "Configuration read",
|
|
128
|
+
"get-component-parameters": "Component parameters read",
|
|
129
|
+
"get-global-parameters": "Global parameters read",
|
|
130
|
+
"get-possible-children": "Possible children read",
|
|
131
|
+
"get-docking-positions": "Docking positions read",
|
|
132
|
+
"get-component-docking-positions": "Component docking positions read",
|
|
133
|
+
"get-delete-impact": "Delete impact read"
|
|
134
|
+
}, i = new Set(Object.keys(r).filter((e) => e.startsWith("get-"))), a = (e) => {
|
|
135
|
+
if (e instanceof Error) return e.message;
|
|
136
|
+
try {
|
|
137
|
+
return typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
|
|
138
|
+
} catch {
|
|
139
|
+
return Object.prototype.toString.call(e);
|
|
140
|
+
}
|
|
141
|
+
}, o = (e) => {
|
|
142
|
+
if (e?.structuredContent !== void 0) return e.structuredContent;
|
|
143
|
+
let t = e?.content?.filter((e) => e.type === "text").map((e) => e.text).join("\n");
|
|
144
|
+
if (t === void 0) return e;
|
|
145
|
+
try {
|
|
146
|
+
return JSON.parse(t);
|
|
147
|
+
} catch {
|
|
148
|
+
return t;
|
|
149
|
+
}
|
|
150
|
+
}, s = (e) => {
|
|
151
|
+
if (!e || typeof e != "object") return e == null ? [] : [a(e)];
|
|
152
|
+
let t = [];
|
|
153
|
+
for (let n of [
|
|
154
|
+
"applied",
|
|
155
|
+
"undone",
|
|
156
|
+
"redone",
|
|
157
|
+
"confirmed",
|
|
158
|
+
"canUndo",
|
|
159
|
+
"canRedo"
|
|
160
|
+
]) e[n] !== void 0 && t.push(`${n}: ${a(e[n])}`);
|
|
161
|
+
return e.hint && t.push(a(e.hint)), t;
|
|
162
|
+
}, c = (e, t = {
|
|
163
|
+
subject: "configuration",
|
|
164
|
+
readTools: i
|
|
165
|
+
}) => {
|
|
166
|
+
let n = [];
|
|
167
|
+
return {
|
|
168
|
+
tools: Object.fromEntries(Object.entries(e).map(([e, t]) => {
|
|
169
|
+
if (!t.execute) return [e, t];
|
|
170
|
+
let r = t.execute.bind(t);
|
|
171
|
+
return [e, {
|
|
172
|
+
...t,
|
|
173
|
+
execute: async (t, i) => {
|
|
174
|
+
let a = {
|
|
175
|
+
toolName: e,
|
|
176
|
+
status: "pending"
|
|
177
|
+
};
|
|
178
|
+
n.push(a);
|
|
179
|
+
try {
|
|
180
|
+
let e = await r(t, i);
|
|
181
|
+
return a.result = e, a.status = "returned", e;
|
|
182
|
+
} catch (e) {
|
|
183
|
+
throw a.error = e, a.status = "threw", e;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}];
|
|
187
|
+
})),
|
|
188
|
+
summary: () => {
|
|
189
|
+
let e = ["The assistant's reply was interrupted. Any text above is incomplete."];
|
|
190
|
+
if (!n.length) return e.push(`No tool ran, so the ${t.subject} was not changed.`), e.join("\n\n");
|
|
191
|
+
for (let i of n) {
|
|
192
|
+
let n = r[i.toolName] ?? i.toolName;
|
|
193
|
+
if (t.readTools.has(i.toolName)) {
|
|
194
|
+
let r = i.status === "returned" && !i.result?.isError, a = r ? o(i.result) : void 0;
|
|
195
|
+
e.push(r ? `- Completed ${n}: ${a?.complete === !1 ? "some requested information was unresolved" : "information was returned"}. The read did not change the ${t.subject}.` : `- Incomplete ${n}: ${i.status === "pending" ? "no result was received" : "the read failed"}. The read did not change the ${t.subject}.`);
|
|
196
|
+
} else if (i.status === "returned" && !i.result?.isError) {
|
|
197
|
+
let r = o(i.result);
|
|
198
|
+
if (r?.confirmed === !1) {
|
|
199
|
+
e.push(`- Unconfirmed ${n}: ${r?.hint ?? r?.unresolved?.join(" ") ?? `the SDK did not confirm the ${t.subject} change`}. Check the ${t.subject} before trying this operation again.`);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
let a = s(r);
|
|
203
|
+
e.push(`- Completed ${n}: ${a.length ? a.join("; ") : "the tool returned successfully."}`);
|
|
204
|
+
} else {
|
|
205
|
+
let r = i.status === "threw" ? a(i.error) : i.status === "returned" ? a(o(i.result)) : "no result was received";
|
|
206
|
+
e.push(`- Unconfirmed ${n}: ${r}. Check the ${t.subject} before trying this operation again.`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return e.push("These are the recorded tool outcomes; no operation was repeated automatically."), e.join("\n\n");
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
export { n, c as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
var e = Symbol("Comlink.proxy"), t = Symbol("Comlink.endpoint"), n = Symbol("Comlink.releaseProxy"), r = Symbol("Comlink.finalizer"), i = Symbol("Comlink.thrown"), a = (e) => typeof e == "object" && !!e || typeof e == "function", o = new Map([["proxy", {
|
|
2
|
+
// node_modules/comlink/dist/esm/comlink.mjs
|
|
3
|
+
var e = Symbol("Comlink.proxy"), t = Symbol("Comlink.endpoint"), n = Symbol("Comlink.releaseProxy"), r = Symbol("Comlink.finalizer"), i = Symbol("Comlink.thrown"), a = (e) => typeof e == "object" && !!e || typeof e == "function", o = /* @__PURE__ */ new Map([["proxy", {
|
|
4
4
|
canHandle: (t) => a(t) && t[e],
|
|
5
5
|
serialize(e) {
|
|
6
6
|
let { port1: t, port2: n } = new MessageChannel();
|
|
@@ -230,5 +230,4 @@ function O() {
|
|
|
230
230
|
,
|
|
231
231
|
].fill(0).map(() => Math.floor(Math.random() * (2 ** 53 - 1)).toString(16)).join("-");
|
|
232
232
|
}
|
|
233
|
-
//#endregion
|
|
234
233
|
export { t as createEndpoint, c as expose, r as finalizer, C as proxy, e as proxyMarker, n as releaseProxy, S as transfer, o as transferHandlers, w as windowEndpoint, d as wrap };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
var e = Symbol("Comlink.proxy"), t = Symbol("Comlink.endpoint"), n = Symbol("Comlink.releaseProxy"), r = Symbol("Comlink.finalizer"), i = Symbol("Comlink.thrown"), a = (e) => typeof e == "object" && !!e || typeof e == "function", o = new Map([["proxy", {
|
|
2
|
+
var e = Symbol("Comlink.proxy"), t = Symbol("Comlink.endpoint"), n = Symbol("Comlink.releaseProxy"), r = Symbol("Comlink.finalizer"), i = Symbol("Comlink.thrown"), a = (e) => typeof e == "object" && !!e || typeof e == "function", o = /* @__PURE__ */ new Map([["proxy", {
|
|
3
3
|
canHandle: (t) => a(t) && t[e],
|
|
4
4
|
serialize(e) {
|
|
5
5
|
let { port1: t, port2: n } = new MessageChannel();
|
package/configurator.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { t as e } from "./mcp-tools-BLB7pCga.mjs";
|
|
3
|
+
import { n as t } from "./chat-model-XYf503pT.mjs";
|
|
4
|
+
// packages/embedding-lib/src/configurator-agent/configurator-mcp-tools.ts
|
|
5
|
+
var n = async (t) => {
|
|
6
|
+
if (typeof t.getConfiguratorAgentTools != "function" || typeof t.callConfiguratorAgentTool != "function") throw Error("Update the Rubens UI: configurator agent tools are unavailable.");
|
|
7
|
+
return e(await t.getConfiguratorAgentTools(), (e, n) => t.callConfiguratorAgentTool(e, n), "configurator-mcp");
|
|
7
8
|
}, r = async (e, t, n) => {
|
|
8
9
|
let r = e.window;
|
|
9
10
|
if (typeof r.startConfigurationAssistant != "function" || typeof r.stopConfigurationAssistant != "function") {
|
|
@@ -25,5 +26,4 @@ var n = async (e) => {
|
|
|
25
26
|
throw n.removeEventListener("abort", a), e;
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
-
export { n as createConfiguratorMcpTools, e as loadChatModel, r as startConfiguratorPlanningAssistant };
|
|
29
|
+
export { n as createConfiguratorMcpTools, t as loadChatModel, r as startConfiguratorPlanningAssistant };
|
package/configurator.min.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { t as e } from "./mcp-tools-BirFT2R0.mjs";
|
|
3
|
+
import { n as t } from "./chat-model-B7BO8IhK.mjs";
|
|
4
|
+
var n = async (t) => {
|
|
5
|
+
if (typeof t.getConfiguratorAgentTools != "function" || typeof t.callConfiguratorAgentTool != "function") throw Error("Update the Rubens UI: configurator agent tools are unavailable.");
|
|
6
|
+
return e(await t.getConfiguratorAgentTools(), (e, n) => t.callConfiguratorAgentTool(e, n), "configurator-mcp");
|
|
6
7
|
}, r = async (e, t, n) => {
|
|
7
8
|
let r = e.window;
|
|
8
9
|
if (typeof r.startConfigurationAssistant != "function" || typeof r.stopConfigurationAssistant != "function") {
|
|
@@ -24,4 +25,4 @@ var n = async (e) => {
|
|
|
24
25
|
throw n.removeEventListener("abort", a), e;
|
|
25
26
|
}
|
|
26
27
|
};
|
|
27
|
-
export { n as createConfiguratorMcpTools,
|
|
28
|
+
export { n as createConfiguratorMcpTools, t as loadChatModel, r as startConfiguratorPlanningAssistant };
|
package/construction.js
CHANGED
|
@@ -1,47 +1,305 @@
|
|
|
1
1
|
/*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { t as e } from "./mcp-tools-BLB7pCga.mjs";
|
|
3
|
+
import { n as t, t as n } from "./chat-model-XYf503pT.mjs";
|
|
4
|
+
import { a as r, i, n as a, r as o, t as s } from "./turn-limits-Ciq383Bd.mjs";
|
|
5
|
+
import { n as c, r as l, t as u } from "./continuation-CswXtOus.mjs";
|
|
6
|
+
import { _n as d } from "./dist-XECXrV5Q.mjs";
|
|
7
|
+
// packages/web-sdk/packages/common-core/src/planning-assistant/session-log.ts
|
|
8
|
+
var f = {
|
|
9
|
+
done: () => {},
|
|
10
|
+
failed: () => {}
|
|
11
|
+
}, p = {
|
|
12
|
+
systemPrompt: () => {},
|
|
13
|
+
context: () => {},
|
|
14
|
+
text: () => {},
|
|
15
|
+
tool: () => f,
|
|
16
|
+
end: () => {}
|
|
17
|
+
}, m = (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
|
+
}, h = (e) => typeof e == "string" ? e : e instanceof URL ? e.href : e instanceof ArrayBuffer ? m(new Uint8Array(e)) : e instanceof Uint8Array ? m(e) : String(e), g = (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: h(e.type === "file" ? e.data : e.image)
|
|
28
|
+
}] : [], _ = (e) => ({
|
|
29
|
+
role: e.role,
|
|
30
|
+
content: typeof e.content == "string" ? [{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: e.content
|
|
33
|
+
}] : e.content.flatMap(g)
|
|
34
|
+
}), v = (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(_);
|
|
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
|
+
}, y = (e = {}) => ({
|
|
101
|
+
inputTokens: e.inputTokens ?? null,
|
|
102
|
+
outputTokens: e.outputTokens ?? null,
|
|
103
|
+
totalTokens: e.totalTokens ?? (e.inputTokens !== void 0 && e.outputTokens !== void 0 ? e.inputTokens + e.outputTokens : null)
|
|
104
|
+
}), b = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, x = (e) => new TextEncoder().encode(e).length, S = async (e, n, s, f, m, h) => {
|
|
105
|
+
let g = [], _ = await Promise.all([
|
|
106
|
+
import("./dist-BZSd56sr.mjs").then((e) => e.t),
|
|
107
|
+
t(e, async (e) => {
|
|
108
|
+
g.push(x(e));
|
|
109
|
+
}, h),
|
|
110
|
+
f()
|
|
111
|
+
]);
|
|
112
|
+
n.throwIfAborted();
|
|
113
|
+
let [{ streamText: S, stepCountIs: C }, w, { prompts: T, tools: E, beforeTurn: D }] = _, O = v(e, Object.entries(E).map(([e, { description: t, inputSchema: n, annotations: r }]) => ({
|
|
114
|
+
name: e,
|
|
115
|
+
description: t,
|
|
116
|
+
inputSchema: n["~standard"].jsonSchema.input({ target: "draft-07" }),
|
|
117
|
+
...r && { annotations: r }
|
|
118
|
+
}))), k = p, A = Object.fromEntries(Object.entries(E).map(([e, t]) => [e, {
|
|
119
|
+
...t,
|
|
120
|
+
execute: async (n, r) => {
|
|
121
|
+
let i = k.tool(e, n);
|
|
122
|
+
try {
|
|
123
|
+
let e = await t.execute(n, r);
|
|
124
|
+
return i.done(e), e;
|
|
125
|
+
} catch (e) {
|
|
126
|
+
throw i.failed(e instanceof Error ? e.message : String(e)), e;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}])), j = [], M = c(e), N = (e) => M ? e?.providerMetadata?.[M]?.responseId ?? void 0 : void 0, P, F = n;
|
|
130
|
+
return Object.assign(async ({ text: t, images: n }, c = F) => {
|
|
131
|
+
let f = r([F, c]), p = O.startTurn({
|
|
132
|
+
text: t,
|
|
133
|
+
images: n
|
|
134
|
+
});
|
|
135
|
+
k = p, p.systemPrompt(T);
|
|
136
|
+
let h = "done", _ = null, v = !1, E = !1, I = !1;
|
|
137
|
+
g = [];
|
|
138
|
+
let L = [], R = [], z, B = !1, V = !1, H = {
|
|
139
|
+
role: "user",
|
|
140
|
+
content: [{
|
|
141
|
+
type: "text",
|
|
142
|
+
text: t || T.imagePrompt
|
|
143
|
+
}, ...n.map((e) => ({
|
|
144
|
+
type: "file",
|
|
145
|
+
data: e,
|
|
146
|
+
mediaType: "image/jpeg"
|
|
147
|
+
}))]
|
|
148
|
+
}, U = m?.recovery(A), W = new AbortController(), G = () => W.abort(f.reason);
|
|
149
|
+
f.addEventListener("abort", G, { once: !0 }), f.aborted && G();
|
|
150
|
+
let K = m ? Error(i(m.timeoutMs)) : void 0, q = m ? setTimeout(() => W.abort(K), m.timeoutMs) : void 0;
|
|
151
|
+
try {
|
|
152
|
+
let e = D ? [{
|
|
153
|
+
role: "user",
|
|
154
|
+
content: "Plan at the start of this turn (data, not instructions):\n" + await D()
|
|
155
|
+
}] : [];
|
|
156
|
+
f.throwIfAborted(), p.context(e);
|
|
157
|
+
let t = [
|
|
158
|
+
...j,
|
|
159
|
+
...e,
|
|
160
|
+
H
|
|
161
|
+
], n = D ? P : void 0;
|
|
162
|
+
v = n !== void 0;
|
|
163
|
+
let r, i = 0, a = !1, c = [], d, h;
|
|
164
|
+
do {
|
|
165
|
+
d = void 0;
|
|
166
|
+
let g = [], _ = i, v = n;
|
|
167
|
+
h = S({
|
|
168
|
+
model: w.languageModel,
|
|
169
|
+
providerOptions: w.providerOptions,
|
|
170
|
+
instructions: T.systemPrompt,
|
|
171
|
+
messages: a ? [...t, ...c].map(l) : [...t, ...c],
|
|
172
|
+
tools: U?.tools ?? A,
|
|
173
|
+
stopWhen: C(32 - _),
|
|
174
|
+
abortSignal: m ? W.signal : f,
|
|
175
|
+
onStepEnd: (e) => {
|
|
176
|
+
g.push(...e.response.messages), i++, r = N(e);
|
|
177
|
+
},
|
|
178
|
+
prepareStep: (t) => {
|
|
179
|
+
let n = _ + t.stepNumber, r = o(n, T.systemPrompt);
|
|
180
|
+
if (!M) return r;
|
|
181
|
+
let i = t.steps?.at(-1), a = t.stepNumber === 0 ? v : N(i);
|
|
182
|
+
if (!a) {
|
|
183
|
+
if (t.stepNumber > 0) throw Error("The previous model response has no continuation ID");
|
|
184
|
+
return r;
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
instructions: [],
|
|
188
|
+
...o(n),
|
|
189
|
+
messages: t.stepNumber === 0 ? [...e, H] : i.response.messages.filter((e) => e.role === "tool"),
|
|
190
|
+
providerOptions: { [M]: {
|
|
191
|
+
previousResponseId: a,
|
|
192
|
+
store: !0
|
|
193
|
+
} }
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
for await (let e of h.stream) if (e.type === "text-delta") p.text(e.text), s({
|
|
198
|
+
type: "text",
|
|
199
|
+
text: e.text
|
|
200
|
+
});
|
|
201
|
+
else if (e.type === "tool-call") s({
|
|
202
|
+
type: "activity",
|
|
203
|
+
text: e.toolName
|
|
204
|
+
});
|
|
205
|
+
else if (e.type === "error") {
|
|
206
|
+
if ((v || g.length) && u(e.error)) {
|
|
207
|
+
d = e.error;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
throw e.error;
|
|
211
|
+
} else if (e.type === "finish-step") L.push(y(e.usage)), R.push(e.usage?.inputTokenDetails?.cacheReadTokens ?? null);
|
|
212
|
+
else if (e.type === "finish") z = c.length ? void 0 : y(e.totalUsage), B = !0;
|
|
213
|
+
else if (e.type === "abort" && (V = !0, m)) throw W.signal.reason ?? /* @__PURE__ */ Error("Turn aborted");
|
|
214
|
+
d && (c.push(...g), n = void 0, a = !0);
|
|
215
|
+
} while (d);
|
|
216
|
+
if (W.signal.aborted) throw W.signal.reason;
|
|
217
|
+
return E = i >= 32, j.push(H, ...c, ...await h.responseMessages), P = r, s({ type: "done" }), !0;
|
|
218
|
+
} catch (e) {
|
|
219
|
+
P = void 0;
|
|
220
|
+
let t = U?.summary();
|
|
221
|
+
if (m && t && W.signal.reason === K) {
|
|
222
|
+
I = !0;
|
|
223
|
+
let e = a(t, m.timeoutMs, s);
|
|
224
|
+
return j.push(H, e), p.text(e.content), !0;
|
|
225
|
+
}
|
|
226
|
+
return t && j.push(H, {
|
|
227
|
+
role: "assistant",
|
|
228
|
+
content: t
|
|
229
|
+
}), h = W.signal.aborted ? "aborted" : "error", _ = `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}${t ? `\n\n${t}` : ""}`, s({
|
|
230
|
+
type: "error",
|
|
231
|
+
...d.isInstance(e) && { statusCode: e.statusCode },
|
|
232
|
+
text: _
|
|
233
|
+
}), !1;
|
|
234
|
+
} finally {
|
|
235
|
+
clearTimeout(q), f.removeEventListener("abort", G);
|
|
236
|
+
let t = {
|
|
237
|
+
inputTokens: z?.inputTokens ?? b(L.map((e) => e.inputTokens)),
|
|
238
|
+
outputTokens: z?.outputTokens ?? b(L.map((e) => e.outputTokens)),
|
|
239
|
+
totalTokens: z?.totalTokens ?? b(L.map((e) => e.totalTokens))
|
|
240
|
+
}, n = Object.values(t).some((e) => e !== null), r = B && !V && !W.signal.aborted && Object.values(t).every((e) => e !== null) && L.every((e) => Object.values(e).every((e) => e !== null)), i = {
|
|
241
|
+
status: n ? r ? "complete" : "partial" : "unavailable",
|
|
242
|
+
...t
|
|
243
|
+
};
|
|
244
|
+
p.end(h, _, {
|
|
245
|
+
...i,
|
|
246
|
+
promptBytes: x(T.systemPrompt),
|
|
247
|
+
configurationBytes: null,
|
|
248
|
+
requestBytes: g,
|
|
249
|
+
cachedInputTokens: b(R),
|
|
250
|
+
chained: v,
|
|
251
|
+
stepLimitReached: E,
|
|
252
|
+
timeLimitReached: I
|
|
253
|
+
}), console.log(`[planning-assistant] usage ${JSON.stringify({
|
|
254
|
+
provider: e.provider,
|
|
255
|
+
model: e.model,
|
|
256
|
+
...i
|
|
257
|
+
})}`);
|
|
258
|
+
}
|
|
259
|
+
}, { report: O.snapshot });
|
|
260
|
+
}, C = async (t) => {
|
|
261
|
+
if (typeof t.getConstructionAgentTools != "function" || typeof t.callConstructionAgentTool != "function") throw Error("Update the Rubens UI: fence agent tools are unavailable.");
|
|
262
|
+
return e(await t.getConstructionAgentTools(), (e, n) => t.callConstructionAgentTool(e, n), "fence-mcp");
|
|
263
|
+
}, w = async (e, t, n, r, i) => {
|
|
264
|
+
let a = (t) => {
|
|
265
|
+
n.aborted || e.planningAssistantOutput(t);
|
|
10
266
|
};
|
|
11
267
|
try {
|
|
12
|
-
let
|
|
13
|
-
|
|
268
|
+
let o = await S(t, n, a, r, i), s = async (e) => {
|
|
269
|
+
await o(e);
|
|
270
|
+
};
|
|
271
|
+
n.throwIfAborted();
|
|
14
272
|
let c = e.callbacks.onPlanningAssistantPrompt;
|
|
15
|
-
e.callbacks.onPlanningAssistantPrompt = s,
|
|
273
|
+
e.callbacks.onPlanningAssistantPrompt = s, n.addEventListener("abort", () => {
|
|
16
274
|
e.callbacks.onPlanningAssistantPrompt === s && (e.callbacks.onPlanningAssistantPrompt = c, e.planningAssistantOutput({
|
|
17
275
|
type: "availability",
|
|
18
276
|
available: !1
|
|
19
277
|
}));
|
|
20
|
-
}, { once: !0 }),
|
|
278
|
+
}, { once: !0 }), a({
|
|
21
279
|
type: "images",
|
|
22
|
-
enabled:
|
|
23
|
-
}),
|
|
280
|
+
enabled: t.readsImages
|
|
281
|
+
}), a({
|
|
24
282
|
type: "availability",
|
|
25
283
|
available: !0
|
|
26
284
|
});
|
|
27
285
|
} catch (e) {
|
|
28
|
-
|
|
286
|
+
a({
|
|
29
287
|
type: "availability",
|
|
30
288
|
available: !1,
|
|
31
289
|
text: String(e)
|
|
32
290
|
});
|
|
33
291
|
}
|
|
34
|
-
},
|
|
35
|
-
let [t, n] = await Promise.all([e.planner.getConstructionAgentPrompts(),
|
|
292
|
+
}, T = (e, t, r) => w(e.window, t, r, async () => {
|
|
293
|
+
let [t, n] = await Promise.all([e.planner.getConstructionAgentPrompts(), C(e.planner)]);
|
|
36
294
|
return {
|
|
37
295
|
prompts: t,
|
|
38
296
|
tools: n
|
|
39
297
|
};
|
|
40
298
|
}, {
|
|
41
|
-
timeoutMs:
|
|
42
|
-
recovery: (e) =>
|
|
299
|
+
timeoutMs: s,
|
|
300
|
+
recovery: (e) => n(e, {
|
|
43
301
|
subject: "plan",
|
|
44
|
-
readTools: new Set([
|
|
302
|
+
readTools: /* @__PURE__ */ new Set([
|
|
45
303
|
"get-construction-capabilities",
|
|
46
304
|
"get-terrain-context",
|
|
47
305
|
"get-construction-context",
|
|
@@ -54,5 +312,4 @@ var i = async (e) => {
|
|
|
54
312
|
])
|
|
55
313
|
})
|
|
56
314
|
});
|
|
57
|
-
|
|
58
|
-
export { i as createConstructionMcpTools, e as loadChatModel, o as startFencePlanningAssistant };
|
|
315
|
+
export { C as createConstructionMcpTools, t as loadChatModel, T as startFencePlanningAssistant };
|