@roomle/embedding-lib 0.0.0-dev-9d077e2 → 0.0.0-dev-b626163
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/{drag-ghost-BOwjMbG3.mjs → drag-ghost-BxqPJdhq.mjs} +1 -1
- package/{drag-ghost-BQ8r6NVo.mjs → drag-ghost-CDFtC1pd.mjs} +1 -1
- package/{drag-in-BP_E53zb.mjs → drag-in-CV1E-DO6.mjs} +2 -2
- package/{drag-in-QhL3zGC0.mjs → drag-in-ClPpCYyi.mjs} +2 -2
- package/embedding-plugins.js +1 -1
- package/embedding-plugins.min.js +1 -1
- package/{from-custom-view-BM_zRJCf.mjs → from-custom-view-Q9A-J7qV.mjs} +2 -2
- package/{from-custom-view-D2Z1YmCx.mjs → from-custom-view-Sx6P6iDI.mjs} +2 -2
- package/{from-website-DlklVbxU.mjs → from-website-BmCO2xli.mjs} +2 -2
- package/{from-website-CPVeVVMI.mjs → from-website-DZJy_l42.mjs} +2 -2
- package/hi.js +283 -37
- package/hi.min.js +239 -36
- package/package.json +1 -8
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp-tools.d.ts +61 -4
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +46 -4
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-usage.d.ts +40 -0
- package/roomle-embedding-lib.js +1 -1
- package/roomle-embedding-lib.min.js +1 -1
- package/configurator.d.ts +0 -2
- package/configurator.js +0 -119
- package/configurator.min.js +0 -117
- package/packages/embedding-lib/src/configurator-agent/chat-recovery.d.ts +0 -9
- package/packages/embedding-lib/src/configurator-agent/configurator-mcp-tools.d.ts +0 -11
- package/packages/embedding-lib/src/configurator-agent/configurator-planning-assistant.d.ts +0 -8
- package/packages/embedding-lib/src/configurator.d.ts +0 -3
- package/packages/embedding-lib/src/planning-assistant/chat-model.d.ts +0 -33
- package/packages/embedding-lib/src/planning-assistant/mcp-tools.d.ts +0 -52
- package/packages/embedding-lib/src/planning-assistant/planning-assistant.d.ts +0 -23
- package/planning-assistant-BW9fNGZO.mjs +0 -158
- package/planning-assistant-CyVA2uUX.mjs +0 -143
- /package/{comlink-BJnhpJa4.mjs → comlink-B2Kj_5Ge.mjs} +0 -0
- /package/{comlink-lSsogKgb.mjs → comlink-B5lV2OWp.mjs} +0 -0
package/hi.min.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { t as e } from "./browser-BxG7yIaK.mjs";
|
|
2
2
|
import { t } from "./utils-wJ80awOA.mjs";
|
|
3
|
-
|
|
4
|
-
var a = (e, t) => t === e.libraryId ? e : {
|
|
3
|
+
var n = (e, t) => t === e.libraryId ? e : {
|
|
5
4
|
...e,
|
|
6
5
|
libraryId: t
|
|
7
|
-
},
|
|
6
|
+
}, r = async (e, t, n, r = { property: "default" }) => {
|
|
8
7
|
let i = n.serverOptions ?? {}, a = { headers: {
|
|
9
8
|
"Content-Type": t === "json" ? "application/json" : "text/plain",
|
|
10
9
|
"Access-Control-Allow-Origin": "*"
|
|
@@ -18,22 +17,22 @@ var a = (e, t) => t === e.libraryId ? e : {
|
|
|
18
17
|
} catch (e) {
|
|
19
18
|
throw e;
|
|
20
19
|
}
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
},
|
|
20
|
+
}, i = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": new Set(["Furniture_Smith"]) }, a = (e, t) => {
|
|
21
|
+
i[e] || (i[e] = /* @__PURE__ */ new Set()), i[e].add(t);
|
|
22
|
+
}, o = (e, t) => {
|
|
23
|
+
i[e]?.delete(t), i[e]?.size === 0 && delete i[e];
|
|
24
|
+
}, s = (e, t) => {
|
|
26
25
|
let { libraryId: n, serverOptions: r } = e;
|
|
27
|
-
return r?.subscriptionId &&
|
|
28
|
-
},
|
|
29
|
-
let t = await (await
|
|
26
|
+
return r?.subscriptionId && i[r.subscriptionId]?.has(n) ? `api/pos/${t}?libraryId=${n}` : `api/pos/libraries/${n}/${t}`;
|
|
27
|
+
}, c = async (e) => await (await r(s(e, "articles"), "json", e, { property: "articles" })).json(), l = async (e) => await (await r(s(e, "masterData"), "json", e, { property: "masterData" })).json(), u = async (e) => {
|
|
28
|
+
let t = await (await r(s(e, "calc.js"), "text", e, { property: "calc.js" })).text();
|
|
30
29
|
if (!t) throw Error("Script load error");
|
|
31
30
|
return t;
|
|
32
|
-
},
|
|
33
|
-
onLoadJavascript: (t) =>
|
|
34
|
-
onLoadArticleCatalog: (t) =>
|
|
35
|
-
onLoadMasterData: (t) =>
|
|
36
|
-
}),
|
|
31
|
+
}, d = (e) => ({
|
|
32
|
+
onLoadJavascript: (t) => u(n(e, t)),
|
|
33
|
+
onLoadArticleCatalog: (t) => c(n(e, t)),
|
|
34
|
+
onLoadMasterData: (t) => l(n(e, t))
|
|
35
|
+
}), f = async (e, t, n, r = {}) => {
|
|
37
36
|
let { baseUrl: i, om: a } = e.serverOptions ?? {}, o = encodeURIComponent(a?.endpointUrl || ""), s = encodeURIComponent(a?.subscriptionId || ""), c = a?.key || "";
|
|
38
37
|
return await (await fetch((i ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(n)}&subscriptionId=${s}&apiKey=${c}&baseUrl=${o}`, {
|
|
39
38
|
method: "POST",
|
|
@@ -43,7 +42,7 @@ var a = (e, t) => t === e.libraryId ? e : {
|
|
|
43
42
|
...r
|
|
44
43
|
}
|
|
45
44
|
})).json();
|
|
46
|
-
},
|
|
45
|
+
}, p = async (e, t, n = {}) => {
|
|
47
46
|
let { baseUrl: r, om: i } = e.serverOptions ?? {}, a = encodeURIComponent(i?.endpointUrl || ""), o = encodeURIComponent(i?.subscriptionId || ""), s = i?.key || "";
|
|
48
47
|
return await (await fetch((r ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(t)}&subscriptionId=${o}&apiKey=${s}&baseUrl=${a}`, {
|
|
49
48
|
method: "GET",
|
|
@@ -52,33 +51,237 @@ var a = (e, t) => t === e.libraryId ? e : {
|
|
|
52
51
|
...n
|
|
53
52
|
}
|
|
54
53
|
})).json();
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
let { expose: o } = await import("./comlink-
|
|
60
|
-
|
|
54
|
+
}, m = null, h = async (r, i = {}) => {
|
|
55
|
+
m && window.removeEventListener("message", m);
|
|
56
|
+
let a = typeof r == "string" ? { libraryId: r } : r;
|
|
57
|
+
i.onLoadJavascript === void 0 && (i.onLoadJavascript = (e) => u(n(a, e))), i.onLoadArticleCatalog === void 0 && (i.onLoadArticleCatalog = (e) => c(n(a, e))), i.onLoadMasterData === void 0 && (i.onLoadMasterData = (e) => l(n(a, e)));
|
|
58
|
+
let { expose: o } = await import("./comlink-B2Kj_5Ge.mjs");
|
|
59
|
+
m = (n) => {
|
|
61
60
|
if (n.data.type === "connect_hi" && n.data.port) {
|
|
62
|
-
let
|
|
61
|
+
let r = n.data.port;
|
|
63
62
|
((t, n) => {
|
|
64
63
|
t.serverOptions ||= {}, !t.serverOptions.language && n?.locale && (t.serverOptions.language = n.locale), t.serverOptions.language || (t.serverOptions.language = e(null, !0));
|
|
65
|
-
})(
|
|
64
|
+
})(a, n.data.globalInitData || {}), r.start?.(), o(t(i), r);
|
|
66
65
|
}
|
|
67
|
-
}, window.addEventListener("message",
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
},
|
|
66
|
+
}, window.addEventListener("message", m);
|
|
67
|
+
}, g = () => {
|
|
68
|
+
m &&= (window.removeEventListener("message", m), null);
|
|
69
|
+
}, _ = ({ output: e }) => ({
|
|
70
|
+
type: "content",
|
|
71
|
+
value: e.content.map((e) => e.type === "text" ? {
|
|
72
|
+
type: "text",
|
|
73
|
+
text: e.text
|
|
74
|
+
} : {
|
|
75
|
+
type: "file",
|
|
76
|
+
mediaType: e.mimeType,
|
|
77
|
+
data: {
|
|
78
|
+
type: "data",
|
|
79
|
+
data: e.data
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}), v = async ({ extended: e }) => {
|
|
71
83
|
if (typeof e.getExternalObjectAgentTools != "function") throw Error("The planner has no HI agent tools: it needs a Rubens UI with getExternalObjectAgentTools.");
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
let t = await e.getExternalObjectAgentTools();
|
|
85
|
+
return Object.fromEntries(t.map(({ name: t, description: n, inputSchema: r }) => {
|
|
86
|
+
let i = () => r;
|
|
87
|
+
return [t, {
|
|
88
|
+
type: "dynamic",
|
|
89
|
+
description: n,
|
|
90
|
+
inputSchema: { "~standard": {
|
|
91
|
+
version: 1,
|
|
92
|
+
vendor: "hi-mcp",
|
|
93
|
+
validate: (e) => ({ value: e }),
|
|
94
|
+
jsonSchema: {
|
|
95
|
+
input: i,
|
|
96
|
+
output: i
|
|
97
|
+
}
|
|
98
|
+
} },
|
|
99
|
+
execute: (n) => e.callExternalObjectAgentTool(t, n).catch((e) => ({
|
|
100
|
+
content: [{
|
|
101
|
+
type: "text",
|
|
102
|
+
text: e instanceof Error ? e.message : String(e)
|
|
103
|
+
}],
|
|
104
|
+
isError: !0
|
|
105
|
+
})),
|
|
106
|
+
toModelOutput: _
|
|
107
|
+
}];
|
|
108
|
+
}));
|
|
109
|
+
}, y = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : null, b = (e = {}) => ({
|
|
110
|
+
inputTokens: y(e.inputTokens),
|
|
111
|
+
outputTokens: y(e.outputTokens),
|
|
112
|
+
totalTokens: y(e.totalTokens) ?? (y(e.inputTokens) !== null && y(e.outputTokens) !== null ? e.inputTokens + e.outputTokens : null)
|
|
113
|
+
}), x = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, S = (e = {}) => {
|
|
114
|
+
let t = e.raw, n = t?.input_tokens_details ?? t?.prompt_tokens_details, r = t?.output_tokens_details ?? t?.completion_tokens_details, i = y(n?.cached_tokens ?? t?.cache_read_input_tokens), a = y(n?.cache_write_tokens ?? t?.cache_creation_input_tokens), o = (e, t) => t ?? (y(e) !== null && Number(e) > 0 ? Number(e) : null);
|
|
115
|
+
return {
|
|
116
|
+
cacheReadTokens: o(e.inputTokenDetails?.cacheReadTokens, i),
|
|
117
|
+
cacheWriteTokens: o(e.inputTokenDetails?.cacheWriteTokens, a),
|
|
118
|
+
noCacheTokens: i !== null && a !== null ? y(e.inputTokenDetails?.noCacheTokens) : null,
|
|
119
|
+
reasoningTokens: o(e.outputTokenDetails?.reasoningTokens, y(r?.reasoning_tokens)),
|
|
120
|
+
rawUsageAvailable: t !== void 0
|
|
121
|
+
};
|
|
122
|
+
}, C = async (e) => {
|
|
123
|
+
let t = new TextEncoder().encode(e), n = await globalThis.crypto?.subtle?.digest("SHA-256", t);
|
|
75
124
|
return {
|
|
76
|
-
|
|
77
|
-
|
|
125
|
+
bytes: t.byteLength,
|
|
126
|
+
sha256: n ? Array.from(new Uint8Array(n), (e) => e.toString(16).padStart(2, "0")).join("") : null
|
|
78
127
|
};
|
|
79
|
-
}
|
|
128
|
+
}, w = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, T = async ({ provider: e, model: t, apiKey: n, baseUrl: r, chatCompletions: i, reasoningEffort: a }, o) => {
|
|
129
|
+
let s = o ? { fetch: async (e, t) => (typeof t?.body == "string" && await o(t.body), fetch(e, t)) } : {};
|
|
130
|
+
switch (e) {
|
|
131
|
+
case "azure": {
|
|
132
|
+
let { createAzure: e } = await import(w("@ai-sdk/azure@4.0.85")), o = e({
|
|
133
|
+
apiKey: n,
|
|
134
|
+
baseURL: r,
|
|
135
|
+
...s
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
languageModel: i ? o.chat(t) : o(t),
|
|
139
|
+
providerOptions: a ? { azure: { reasoningEffort: a } } : void 0
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
case "mistral": {
|
|
143
|
+
let { createMistral: e } = await import(w("@ai-sdk/mistral@4.0.54"));
|
|
144
|
+
return { languageModel: e({
|
|
145
|
+
apiKey: n,
|
|
146
|
+
...s
|
|
147
|
+
})(t) };
|
|
148
|
+
}
|
|
149
|
+
case "anthropic": {
|
|
150
|
+
let { createAnthropic: e } = await import(w("@ai-sdk/anthropic@4.0.68"));
|
|
151
|
+
return { languageModel: e({
|
|
152
|
+
apiKey: n,
|
|
153
|
+
headers: { "anthropic-dangerous-direct-browser-access": "true" },
|
|
154
|
+
...s
|
|
155
|
+
})(t) };
|
|
156
|
+
}
|
|
157
|
+
case "google": {
|
|
158
|
+
let { createGoogleGenerativeAI: e } = await import(w("@ai-sdk/google@4.0.85"));
|
|
159
|
+
return { languageModel: e({
|
|
160
|
+
apiKey: n,
|
|
161
|
+
...s
|
|
162
|
+
})(t) };
|
|
163
|
+
}
|
|
164
|
+
default: throw Error(`Unknown provider "${e}" - supported: azure, mistral, anthropic, google`);
|
|
165
|
+
}
|
|
166
|
+
}, E = async (e, t, n) => {
|
|
167
|
+
let r = e.extended, i = (e) => r.planningAssistantOutput(e), a, o = [];
|
|
168
|
+
try {
|
|
169
|
+
a = await Promise.all([
|
|
170
|
+
import(w("ai@7.0.122")),
|
|
171
|
+
T(t, async (e) => {
|
|
172
|
+
o.push(await C(e));
|
|
173
|
+
}),
|
|
174
|
+
r.getExternalObjectAgentPrompts(),
|
|
175
|
+
v(e)
|
|
176
|
+
]);
|
|
177
|
+
} catch (e) {
|
|
178
|
+
i({
|
|
179
|
+
type: "availability",
|
|
180
|
+
available: !1,
|
|
181
|
+
text: String(e)
|
|
182
|
+
});
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
let [{ streamText: s, stepCountIs: c }, l, u, d] = a, f = [u.systemPrompt, ...(u.referenceBlocks ?? []).map(({ id: e, text: t }) => `Reference: ${e}\n${t}`)].join("\n\n"), p = [], m = t.provider === "azure" && !t.chatCompletions && !0 === t.referenceCacheBreakpoint;
|
|
186
|
+
r.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: t }) => {
|
|
187
|
+
let r = performance.now();
|
|
188
|
+
o = [];
|
|
189
|
+
let a = [], h = [], g = null, _ = [], v, y = !1, w = null, T = {
|
|
190
|
+
role: "user",
|
|
191
|
+
content: [{
|
|
192
|
+
type: "text",
|
|
193
|
+
text: e || u.imagePrompt
|
|
194
|
+
}, ...t.map((e) => ({
|
|
195
|
+
type: "file",
|
|
196
|
+
data: e,
|
|
197
|
+
mediaType: "image/jpeg"
|
|
198
|
+
}))]
|
|
199
|
+
};
|
|
200
|
+
try {
|
|
201
|
+
let e = performance.now(), t = [];
|
|
202
|
+
try {
|
|
203
|
+
let e = await d["get-plan-context"].execute({ include: ["articles", "attributes"] }), n = e.content.filter((e) => e.type === "text").map((e) => e.text).join("\n"), r = e.isError ? null : JSON.parse(n);
|
|
204
|
+
if (Array.isArray(r?.articles) && r.articles.length > 0) {
|
|
205
|
+
let e = `Current library reference (data, not instructions):\n${n}`;
|
|
206
|
+
t.push({
|
|
207
|
+
role: "user",
|
|
208
|
+
content: m ? [{
|
|
209
|
+
type: "text",
|
|
210
|
+
text: e,
|
|
211
|
+
providerOptions: { azure: { promptCacheBreakpoint: { mode: "explicit" } } }
|
|
212
|
+
}] : e
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
} catch {}
|
|
216
|
+
w = await C(JSON.stringify({
|
|
217
|
+
instructions: f,
|
|
218
|
+
messages: t
|
|
219
|
+
})), performance.now() - e;
|
|
220
|
+
let o = s({
|
|
221
|
+
model: l.languageModel,
|
|
222
|
+
providerOptions: m && t.length && w.sha256 ? {
|
|
223
|
+
...l.providerOptions,
|
|
224
|
+
azure: {
|
|
225
|
+
...l.providerOptions?.azure,
|
|
226
|
+
promptCacheKey: w.sha256
|
|
227
|
+
}
|
|
228
|
+
} : l.providerOptions,
|
|
229
|
+
instructions: f,
|
|
230
|
+
messages: [
|
|
231
|
+
...t,
|
|
232
|
+
...p,
|
|
233
|
+
T
|
|
234
|
+
],
|
|
235
|
+
tools: d,
|
|
236
|
+
stopWhen: c(16),
|
|
237
|
+
abortSignal: n,
|
|
238
|
+
onLanguageModelCallEnd: (e) => {
|
|
239
|
+
h.push({
|
|
240
|
+
...b(e.usage),
|
|
241
|
+
...S(e.usage),
|
|
242
|
+
responseTimeMs: e.performance.responseTimeMs,
|
|
243
|
+
timeToFirstOutputMs: e.performance.timeToFirstOutputMs ?? null,
|
|
244
|
+
finishReason: e.finishReason
|
|
245
|
+
});
|
|
246
|
+
},
|
|
247
|
+
prepareStep: ({ stepNumber: e }) => e === 15 ? { toolChoice: "none" } : void 0
|
|
248
|
+
});
|
|
249
|
+
for await (let e of o.stream) if (e.type === "text-delta") g ??= performance.now() - r, i({
|
|
250
|
+
type: "text",
|
|
251
|
+
text: e.text
|
|
252
|
+
});
|
|
253
|
+
else if (e.type === "tool-call") i({
|
|
254
|
+
type: "activity",
|
|
255
|
+
text: e.toolName
|
|
256
|
+
});
|
|
257
|
+
else {
|
|
258
|
+
if (e.type === "error") throw e.error;
|
|
259
|
+
e.type === "finish-step" ? (_.push(b(e.usage)), a.push(S(e.usage))) : e.type === "finish" ? v = b(e.totalUsage) : e.type === "abort" && (y = !0);
|
|
260
|
+
}
|
|
261
|
+
y || n.aborted || p.push(T, ...await o.responseMessages), i({ type: "done" });
|
|
262
|
+
} catch (e) {
|
|
263
|
+
i({
|
|
264
|
+
type: "error",
|
|
265
|
+
text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
|
|
266
|
+
});
|
|
267
|
+
} finally {
|
|
268
|
+
let e = {
|
|
269
|
+
inputTokens: v?.inputTokens ?? x(_.map((e) => e.inputTokens)),
|
|
270
|
+
outputTokens: v?.outputTokens ?? x(_.map((e) => e.outputTokens)),
|
|
271
|
+
totalTokens: v?.totalTokens ?? x(_.map((e) => e.totalTokens))
|
|
272
|
+
};
|
|
273
|
+
Object.values(e).some((e) => e !== null), v && !y && !n.aborted && Object.values(e).every((e) => e !== null) && _.every((e) => Object.values(e).every((e) => e !== null));
|
|
274
|
+
}
|
|
275
|
+
}, i({
|
|
276
|
+
type: "images",
|
|
277
|
+
enabled: t.readsImages
|
|
278
|
+
}), i({
|
|
279
|
+
type: "availability",
|
|
280
|
+
available: !0
|
|
281
|
+
});
|
|
282
|
+
}, D = {
|
|
80
283
|
HIDE: "hide",
|
|
81
284
|
SHOW_ATTRIBUTES: "attributes",
|
|
82
285
|
SHOW_ARTICLES: "articles"
|
|
83
286
|
};
|
|
84
|
-
export {
|
|
287
|
+
export { D as HI_PANEL_ACTION, g as cleanupHi, d as createHiLibraryCallbacks, v as createHiMcpTools, c as libLoadArticleCatalog, u as libLoadCalcScript, l as libLoadMasterData, T as loadChatModel, p as omGetRequest, f as omPostRequest, a as registerLegacyUrlFormat, h as setupHi, E as startPlanningAssistant, o as unregisterLegacyUrlFormat };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roomle/embedding-lib",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-b626163",
|
|
4
4
|
"description": "This is a small library which can be used to communicate with the Roomle Configurator. ES modules only (browser-compatible).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./roomle-embedding-lib.js",
|
|
@@ -29,13 +29,6 @@
|
|
|
29
29
|
},
|
|
30
30
|
"./plugins/min": {
|
|
31
31
|
"import": "./embedding-plugins.min.js"
|
|
32
|
-
},
|
|
33
|
-
"./configurator": {
|
|
34
|
-
"import": "./configurator.js",
|
|
35
|
-
"types": "./configurator.d.ts"
|
|
36
|
-
},
|
|
37
|
-
"./configurator/min": {
|
|
38
|
-
"import": "./configurator.min.js"
|
|
39
32
|
}
|
|
40
33
|
},
|
|
41
34
|
"scripts": {
|
|
@@ -1,11 +1,68 @@
|
|
|
1
1
|
import { HiAgentToolDefinition, McpToolResult } from '../../../web-sdk/packages';
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
/** What the model gets of a tool result, as `@ai-sdk/mcp` hands it to the AI SDK. */
|
|
3
|
+
export interface HiMcpModelOutput {
|
|
4
|
+
type: 'content';
|
|
5
|
+
value: ({
|
|
6
|
+
type: 'text';
|
|
7
|
+
text: string;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'file';
|
|
10
|
+
mediaType: string;
|
|
11
|
+
data: {
|
|
12
|
+
type: 'data';
|
|
13
|
+
data: string;
|
|
14
|
+
};
|
|
15
|
+
})[];
|
|
16
|
+
}
|
|
17
|
+
/** The input schema of a tool as a Standard Schema with its JSON Schema. */
|
|
18
|
+
export interface HiMcpInputSchema {
|
|
19
|
+
'~standard': {
|
|
20
|
+
version: 1;
|
|
21
|
+
vendor: string;
|
|
22
|
+
validate: (value: unknown) => {
|
|
23
|
+
value: unknown;
|
|
24
|
+
};
|
|
25
|
+
jsonSchema: {
|
|
26
|
+
input: (options: {
|
|
27
|
+
target: string;
|
|
28
|
+
}) => Record<string, unknown>;
|
|
29
|
+
output: (options: {
|
|
30
|
+
target: string;
|
|
31
|
+
}) => Record<string, unknown>;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** A tool of the HI MCP tool set, in the shape of an AI SDK dynamic tool. */
|
|
36
|
+
export interface HiMcpTool {
|
|
37
|
+
type: 'dynamic';
|
|
38
|
+
description: string;
|
|
39
|
+
inputSchema: HiMcpInputSchema;
|
|
40
|
+
execute: (input: unknown) => Promise<McpToolResult>;
|
|
41
|
+
toModelOutput: (options: {
|
|
42
|
+
output: McpToolResult;
|
|
43
|
+
}) => HiMcpModelOutput;
|
|
44
|
+
}
|
|
45
|
+
/** The HI MCP tools by name, the tool set an AI SDK `streamText` takes. */
|
|
46
|
+
export type HiMcpTools = Record<string, HiMcpTool>;
|
|
47
|
+
/** The planner methods the HI MCP tools forward to: the HI agent tools of the planner. */
|
|
4
48
|
export interface HiMcpPlannerApi {
|
|
5
49
|
extended: {
|
|
6
50
|
getExternalObjectAgentTools(): Promise<HiAgentToolDefinition[]>;
|
|
7
51
|
callExternalObjectAgentTool(name: string, input: unknown): Promise<McpToolResult>;
|
|
8
52
|
};
|
|
9
53
|
}
|
|
10
|
-
/** The
|
|
11
|
-
export declare const
|
|
54
|
+
/** The tool result as `@ai-sdk/mcp` passes it to the model: text parts and images as file parts. */
|
|
55
|
+
export declare const mcpToModelOutput: ({ output, }: {
|
|
56
|
+
output: McpToolResult;
|
|
57
|
+
}) => HiMcpModelOutput;
|
|
58
|
+
/**
|
|
59
|
+
* Creates the HI MCP tools for an AI agent that plans in the planner of this
|
|
60
|
+
* page: the HI agent tools of the planner as an AI SDK tool set, without the
|
|
61
|
+
* MCP protocol. The host passes the tool set as `tools` to its own
|
|
62
|
+
* `streamText`. The tools run in the planner; every call is forwarded to
|
|
63
|
+
* `callExternalObjectAgentTool`. The AI SDK gets the JSON Schema of each input
|
|
64
|
+
* and lets every input through: the planner validates it and answers an
|
|
65
|
+
* invalid input and a failed call as an MCP error result (`isError`), as a
|
|
66
|
+
* forwarding error is answered here.
|
|
67
|
+
*/
|
|
68
|
+
export declare const createHiMcpTools: ({ extended, }: HiMcpPlannerApi) => Promise<HiMcpTools>;
|
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
import { PlanningAssistantOutput, PlanningAssistantPrompt } from '../../../web-sdk/packages';
|
|
2
2
|
import { HiMcpPlannerApi } from './hi-mcp-tools';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The model of the AI Planning Assistant as a JSON object: everything
|
|
5
|
+
* `loadChatModel` and `startPlanningAssistant` need to reach it.
|
|
6
|
+
*/
|
|
7
|
+
export interface PlanningAssistantConfig {
|
|
8
|
+
/** `azure` for a deployment on an Azure AI Foundry resource, else the provider of the model. */
|
|
9
|
+
provider: 'azure' | 'mistral' | 'anthropic' | 'google';
|
|
10
|
+
/** The model id at the provider; for `azure` the name of the deployment. */
|
|
11
|
+
model: string;
|
|
12
|
+
/** The API key of the provider; for `azure` the key of the Foundry resource. */
|
|
13
|
+
apiKey: string;
|
|
14
|
+
/** `azure` only: the OpenAI v1 endpoint of the Foundry resource, e.g. `https://<resource>.services.ai.azure.com/openai/v1`. */
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
/** `azure` only: call the deployment through the Chat Completions API instead of the Responses API. */
|
|
17
|
+
chatCompletions?: boolean;
|
|
18
|
+
/** `azure` only: the reasoning effort of the deployment; its default when unset. */
|
|
19
|
+
reasoningEffort?: string;
|
|
20
|
+
/** Azure Responses only: mark the library prefix for caching on a deployment verified to support explicit breakpoints. */
|
|
21
|
+
referenceCacheBreakpoint?: boolean;
|
|
22
|
+
/** Whether the model reads images: the window offers the image drop only then. */
|
|
23
|
+
readsImages: boolean;
|
|
24
|
+
}
|
|
5
25
|
/** The planner the planning assistant runs in: the HI MCP tools' planner API, the agent prompts and the window. */
|
|
6
26
|
export type PlanningAssistantPlannerApi = HiMcpPlannerApi & {
|
|
7
27
|
extended: {
|
|
8
28
|
getExternalObjectAgentPrompts(): Promise<{
|
|
9
29
|
systemPrompt: string;
|
|
10
30
|
imagePrompt: string;
|
|
31
|
+
referenceBlocks?: {
|
|
32
|
+
id: string;
|
|
33
|
+
text: string;
|
|
34
|
+
}[];
|
|
11
35
|
}>;
|
|
12
36
|
planningAssistantOutput(part: PlanningAssistantOutput): unknown;
|
|
13
37
|
callbacks: {
|
|
@@ -15,5 +39,23 @@ export type PlanningAssistantPlannerApi = HiMcpPlannerApi & {
|
|
|
15
39
|
};
|
|
16
40
|
};
|
|
17
41
|
};
|
|
18
|
-
/**
|
|
19
|
-
export declare const
|
|
42
|
+
/** The AI SDK language model of the config and the provider options `streamText` takes with it. */
|
|
43
|
+
export declare const loadChatModel: ({ provider, model, apiKey, baseUrl, chatCompletions, reasoningEffort, }: PlanningAssistantConfig, observeRequest?: (body: string) => Promise<void>) => Promise<{
|
|
44
|
+
languageModel: any;
|
|
45
|
+
providerOptions: {
|
|
46
|
+
azure: {
|
|
47
|
+
reasoningEffort: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
languageModel: any;
|
|
52
|
+
providerOptions?: undefined;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Runs the planning agent of the AI Planning Assistant window
|
|
56
|
+
* (featureFlags.planningAssistant) in this page: the window hands every
|
|
57
|
+
* message to "onPlanningAssistantPrompt", the agent calls the HI MCP tools,
|
|
58
|
+
* the tools run in the planner of this page, and the agent's output goes to
|
|
59
|
+
* "planningAssistantOutput". Aborting the signal ends a running turn.
|
|
60
|
+
*/
|
|
61
|
+
export declare const startPlanningAssistant: (roomDesignerApi: PlanningAssistantPlannerApi, config: PlanningAssistantConfig, signal: AbortSignal) => Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type Usage = {
|
|
2
|
+
inputTokens?: number;
|
|
3
|
+
outputTokens?: number;
|
|
4
|
+
totalTokens?: number;
|
|
5
|
+
inputTokenDetails?: {
|
|
6
|
+
noCacheTokens?: number;
|
|
7
|
+
cacheReadTokens?: number;
|
|
8
|
+
cacheWriteTokens?: number;
|
|
9
|
+
};
|
|
10
|
+
outputTokenDetails?: {
|
|
11
|
+
reasoningTokens?: number;
|
|
12
|
+
};
|
|
13
|
+
raw?: Record<string, unknown>;
|
|
14
|
+
};
|
|
15
|
+
export declare const tokenCounts: (usage?: Usage) => {
|
|
16
|
+
inputTokens: number;
|
|
17
|
+
outputTokens: number;
|
|
18
|
+
totalTokens: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const sumCounts: (counts: (number | null)[]) => number;
|
|
21
|
+
export declare const usageDetails: (usage?: Usage) => {
|
|
22
|
+
cacheReadTokens: number;
|
|
23
|
+
cacheWriteTokens: number;
|
|
24
|
+
noCacheTokens: number;
|
|
25
|
+
reasoningTokens: number;
|
|
26
|
+
rawUsageAvailable: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare const summarizeDetails: (steps: ReturnType<typeof usageDetails>[]) => {
|
|
29
|
+
[k: string]: {
|
|
30
|
+
tokens: number;
|
|
31
|
+
status: string;
|
|
32
|
+
reportedSteps: number;
|
|
33
|
+
observedSteps: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export declare const describePayload: (text: string) => Promise<{
|
|
37
|
+
bytes: number;
|
|
38
|
+
sha256: string;
|
|
39
|
+
}>;
|
|
40
|
+
export {};
|
package/roomle-embedding-lib.js
CHANGED
|
@@ -203,7 +203,7 @@ var t = class {
|
|
|
203
203
|
setupPlugins(e, t, n = "website") {
|
|
204
204
|
for (let r of e) typeof r == "string" && r === "dragIn" ? this.pluginsLoaded.push(new Promise((e, r) => {
|
|
205
205
|
try {
|
|
206
|
-
import("./drag-in-
|
|
206
|
+
import("./drag-in-ClPpCYyi.mjs").then((e) => e.n).then(({ DragIn: i }) => {
|
|
207
207
|
let a = new i(this.ui, t, n, this.viewName);
|
|
208
208
|
a.init().then(() => {
|
|
209
209
|
this.plugins.dragIn = a, e();
|
|
@@ -184,7 +184,7 @@ var t = class {
|
|
|
184
184
|
setupPlugins(e, t, n = "website") {
|
|
185
185
|
for (let r of e) typeof r == "string" && r === "dragIn" ? this.pluginsLoaded.push(new Promise((e, r) => {
|
|
186
186
|
try {
|
|
187
|
-
import("./drag-in-
|
|
187
|
+
import("./drag-in-CV1E-DO6.mjs").then((e) => e.n).then(({ DragIn: i }) => {
|
|
188
188
|
let a = new i(this.ui, t, n, this.viewName);
|
|
189
189
|
a.init().then(() => {
|
|
190
190
|
this.plugins.dragIn = a, e();
|
package/configurator.d.ts
DELETED
package/configurator.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./planning-assistant-BW9fNGZO.mjs";
|
|
2
|
-
//#region packages/embedding-lib/src/configurator-agent/configurator-mcp-tools.ts
|
|
3
|
-
var r = async (e) => {
|
|
4
|
-
if (typeof e.getConfiguratorAgentTools != "function" || typeof e.callConfiguratorAgentTool != "function") throw Error("Update the Rubens UI: configurator agent tools are unavailable.");
|
|
5
|
-
return t(await e.getConfiguratorAgentTools(), (t, n) => e.callConfiguratorAgentTool(t, n), "configurator-mcp");
|
|
6
|
-
}, i = {
|
|
7
|
-
undo: "Undo",
|
|
8
|
-
redo: "Redo",
|
|
9
|
-
"change-component-parameter": "Component parameter change",
|
|
10
|
-
"change-global-parameter": "Global parameter change",
|
|
11
|
-
"dock-component": "Component dock",
|
|
12
|
-
"drag-component": "Component drag",
|
|
13
|
-
"delete-component": "Component deletion",
|
|
14
|
-
"load-configuration": "Configuration load",
|
|
15
|
-
"get-configurator-capabilities": "Capabilities read",
|
|
16
|
-
"get-configuration": "Configuration read",
|
|
17
|
-
"get-component-parameters": "Component parameters read",
|
|
18
|
-
"get-global-parameters": "Global parameters read",
|
|
19
|
-
"get-possible-children": "Possible children read",
|
|
20
|
-
"get-docking-positions": "Docking positions read",
|
|
21
|
-
"get-component-docking-positions": "Component docking positions read",
|
|
22
|
-
"get-delete-impact": "Delete impact read"
|
|
23
|
-
}, a = new Set([
|
|
24
|
-
"get-configurator-capabilities",
|
|
25
|
-
"get-configuration",
|
|
26
|
-
"get-component-parameters",
|
|
27
|
-
"get-global-parameters",
|
|
28
|
-
"get-possible-children",
|
|
29
|
-
"get-docking-positions",
|
|
30
|
-
"get-component-docking-positions",
|
|
31
|
-
"get-delete-impact"
|
|
32
|
-
]), o = (e) => {
|
|
33
|
-
if (e instanceof Error) return e.message;
|
|
34
|
-
try {
|
|
35
|
-
return typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
|
|
36
|
-
} catch {
|
|
37
|
-
return Object.prototype.toString.call(e);
|
|
38
|
-
}
|
|
39
|
-
}, s = (e) => {
|
|
40
|
-
if (e?.structuredContent !== void 0) return e.structuredContent;
|
|
41
|
-
let t = e?.content?.filter((e) => e.type === "text").map((e) => e.text).join("\n");
|
|
42
|
-
if (t === void 0) return e;
|
|
43
|
-
try {
|
|
44
|
-
return JSON.parse(t);
|
|
45
|
-
} catch {
|
|
46
|
-
return t;
|
|
47
|
-
}
|
|
48
|
-
}, c = (e) => {
|
|
49
|
-
if (!e || typeof e != "object") return e == null ? [] : [o(e)];
|
|
50
|
-
let t = [];
|
|
51
|
-
for (let n of [
|
|
52
|
-
"undone",
|
|
53
|
-
"redone",
|
|
54
|
-
"confirmed",
|
|
55
|
-
"canUndo",
|
|
56
|
-
"canRedo"
|
|
57
|
-
]) e[n] !== void 0 && t.push(`${n}: ${o(e[n])}`);
|
|
58
|
-
return e.hint && t.push(o(e.hint)), t;
|
|
59
|
-
}, l = (e) => {
|
|
60
|
-
let t = [];
|
|
61
|
-
return {
|
|
62
|
-
tools: Object.fromEntries(Object.entries(e).map(([e, n]) => {
|
|
63
|
-
if (!n.execute) return [e, n];
|
|
64
|
-
let r = n.execute.bind(n);
|
|
65
|
-
return [e, {
|
|
66
|
-
...n,
|
|
67
|
-
execute: async (n) => {
|
|
68
|
-
let i = {
|
|
69
|
-
toolName: e,
|
|
70
|
-
status: "pending"
|
|
71
|
-
};
|
|
72
|
-
t.push(i);
|
|
73
|
-
try {
|
|
74
|
-
let e = await r(n);
|
|
75
|
-
return i.result = e, i.status = "returned", e;
|
|
76
|
-
} catch (e) {
|
|
77
|
-
throw i.error = e, i.status = "threw", e;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}];
|
|
81
|
-
})),
|
|
82
|
-
summary: () => {
|
|
83
|
-
let e = ["The assistant's reply was interrupted. Any text above is incomplete."];
|
|
84
|
-
if (!t.length) return e.push("No tool ran, so the configuration was not changed."), e.join("\n\n");
|
|
85
|
-
for (let n of t) {
|
|
86
|
-
let t = i[n.toolName] ?? n.toolName;
|
|
87
|
-
if (a.has(n.toolName)) {
|
|
88
|
-
let r = n.status === "returned" && !n.result?.isError, i = r ? s(n.result) : void 0;
|
|
89
|
-
e.push(r ? `- Completed ${t}: ${i?.complete === !1 ? "some requested information was unresolved" : "information was returned"}. The read did not change the configuration.` : `- Incomplete ${t}: ${n.status === "pending" ? "no result was received" : "the read failed"}. The read did not change the configuration.`);
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (n.status === "returned" && !n.result?.isError) {
|
|
93
|
-
let r = s(n.result);
|
|
94
|
-
if (r?.confirmed === !1) {
|
|
95
|
-
e.push(`- Unconfirmed ${t}: ${r?.hint ?? "the configurator did not report the change"}. Check the configuration before trying this operation again.`);
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
let i = c(r);
|
|
99
|
-
e.push(`- Completed ${t}: ${i.length ? i.join("; ") : "the tool returned successfully."}`);
|
|
100
|
-
} else {
|
|
101
|
-
let r = n.status === "threw" ? o(n.error) : n.status === "returned" ? o(s(n.result)) : "no result was received";
|
|
102
|
-
e.push(`- Unconfirmed ${t}: ${r}. Check the configuration before trying this operation again.`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return e.push("These are the recorded tool outcomes; no operation was repeated automatically."), e.join("\n\n");
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
}, u = (e, t, i) => n(e.window, t, i, async () => {
|
|
109
|
-
let [t, n] = await Promise.all([e.configurator.getConfiguratorAgentPrompts(), r(e.configurator)]);
|
|
110
|
-
return {
|
|
111
|
-
prompts: t,
|
|
112
|
-
tools: n
|
|
113
|
-
};
|
|
114
|
-
}, {
|
|
115
|
-
timeoutMs: 5 * 6e4,
|
|
116
|
-
recovery: l
|
|
117
|
-
});
|
|
118
|
-
//#endregion
|
|
119
|
-
export { r as createConfiguratorMcpTools, e as loadChatModel, u as startConfiguratorPlanningAssistant };
|