@roomle/embedding-lib 0.0.0-dev-20f436f → 0.0.0-dev-86c52f1
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-model-host-CS8tMlto.mjs +144 -0
- package/ai-model-host-D_b_GVlC.mjs +145 -0
- package/ai.js +1 -128
- package/ai.min.js +1 -126
- 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 +17865 -37
- package/construction.min.js +17536 -41
- 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-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-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 +80 -428
- package/hi.min.js +75 -376
- 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/ai-model-host.d.ts +34 -0
- package/packages/embedding-lib/src/ai.d.ts +11 -27
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +11 -19
- 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 +31 -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-C3HE9yXi.mjs +33 -0
- package/usage-CYqDPQOx.mjs +34 -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/dist-6TznX-Ae.mjs +0 -17514
- package/dist-D0XFfKEL.mjs +0 -17079
- package/mcp-tools-CC8DTfZA.mjs +0 -2
- package/mcp-tools-CfJ_ue_2.mjs +0 -2
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-usage.d.ts +0 -54
- /package/{browser-BjtSrqbu.mjs → browser-CzLpXYFF.mjs} +0 -0
package/hi.min.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
|
|
2
|
-
import { t as e } from "./
|
|
3
|
-
import { t } from "./
|
|
4
|
-
import {
|
|
5
|
-
import "./mcp-tools-
|
|
2
|
+
import { t as e } from "./utils-DdNhTbJr.mjs";
|
|
3
|
+
import { t } from "./browser-CzLpXYFF.mjs";
|
|
4
|
+
import { t as n } from "./chat-model-DooKwd8I.mjs";
|
|
5
|
+
import { t as r } from "./mcp-tools-m_3IX0vB.mjs";
|
|
6
|
+
import { t as i } from "./ai-model-host-CS8tMlto.mjs";
|
|
7
|
+
import { o as a } from "./usage-C3HE9yXi.mjs";
|
|
6
8
|
var o = (e, t) => t === e.libraryId ? e : {
|
|
7
9
|
...e,
|
|
8
10
|
libraryId: t
|
|
@@ -20,7 +22,7 @@ var o = (e, t) => t === e.libraryId ? e : {
|
|
|
20
22
|
} catch (e) {
|
|
21
23
|
throw e;
|
|
22
24
|
}
|
|
23
|
-
}, c = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": new Set(["Furniture_Smith"]) }, l = (e, t) => {
|
|
25
|
+
}, c = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": /* @__PURE__ */ new Set(["Furniture_Smith"]) }, l = (e, t) => {
|
|
24
26
|
c[e] || (c[e] = /* @__PURE__ */ new Set()), c[e].add(t);
|
|
25
27
|
}, u = (e, t) => {
|
|
26
28
|
c[e]?.delete(t), c[e]?.size === 0 && delete c[e];
|
|
@@ -35,388 +37,85 @@ var o = (e, t) => t === e.libraryId ? e : {
|
|
|
35
37
|
onLoadJavascript: (t) => m(o(e, t)),
|
|
36
38
|
onLoadArticleCatalog: (t) => f(o(e, t)),
|
|
37
39
|
onLoadMasterData: (t) => p(o(e, t))
|
|
38
|
-
}), g = async (e, t, n, r
|
|
39
|
-
let { baseUrl: i, om: a } = e.serverOptions ?? {}, o = encodeURIComponent(a?.endpointUrl || ""), s = encodeURIComponent(a?.subscriptionId || ""), c = a?.key || ""
|
|
40
|
-
|
|
41
|
-
method: "POST",
|
|
42
|
-
body: JSON.stringify(t),
|
|
40
|
+
}), g = async (e, t, n, r) => {
|
|
41
|
+
let { baseUrl: i, om: a } = e.serverOptions ?? {}, o = encodeURIComponent(a?.endpointUrl || ""), s = encodeURIComponent(a?.subscriptionId || ""), c = a?.key || "", l = await fetch((i ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(t)}&subscriptionId=${s}&apiKey=${c}&baseUrl=${o}`, {
|
|
42
|
+
...n,
|
|
43
43
|
headers: {
|
|
44
44
|
"Content-Type": "application/json",
|
|
45
45
|
...r
|
|
46
46
|
}
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
v && window.removeEventListener("message", v);
|
|
47
|
+
});
|
|
48
|
+
if (!l.ok) {
|
|
49
|
+
let e = `HTTP ${l.status} ${l.statusText}`.trimEnd(), n = await l.text();
|
|
50
|
+
throw Error(`Order Manager request ${t} failed with ${e}${n ? `: ${n}` : ""}`);
|
|
51
|
+
}
|
|
52
|
+
return l.json();
|
|
53
|
+
}, _ = async (e, t, n, r = {}) => g(e, n, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
body: JSON.stringify(t)
|
|
56
|
+
}, r), v = async (e, t, n = {}) => g(e, t, { method: "GET" }, n), y = null, b = async (n, r = {}) => {
|
|
57
|
+
y && window.removeEventListener("message", y);
|
|
59
58
|
let i = typeof n == "string" ? { libraryId: n } : n;
|
|
60
59
|
r.onLoadJavascript === void 0 && (r.onLoadJavascript = (e) => m(o(i, e))), r.onLoadArticleCatalog === void 0 && (r.onLoadArticleCatalog = (e) => f(o(i, e))), r.onLoadMasterData === void 0 && (r.onLoadMasterData = (e) => p(o(i, e)));
|
|
61
|
-
let { expose: a } = await import("./comlink-
|
|
62
|
-
|
|
60
|
+
let { expose: a } = await import("./comlink-DKhvPU0o.mjs");
|
|
61
|
+
y = (n) => {
|
|
63
62
|
if (n.data.type === "connect_hi" && n.data.port) {
|
|
64
63
|
let o = n.data.port;
|
|
65
|
-
((
|
|
66
|
-
|
|
67
|
-
})(i, n.data.globalInitData || {}), o.start?.(), a(
|
|
64
|
+
((e, n) => {
|
|
65
|
+
e.serverOptions ||= {}, !e.serverOptions.language && n?.locale && (e.serverOptions.language = n.locale), e.serverOptions.language || (e.serverOptions.language = t(null, !0));
|
|
66
|
+
})(i, n.data.globalInitData || {}), o.start?.(), a(e(r), o);
|
|
68
67
|
}
|
|
69
|
-
}, window.addEventListener("message",
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
},
|
|
68
|
+
}, window.addEventListener("message", y);
|
|
69
|
+
}, x = () => {
|
|
70
|
+
y &&= (window.removeEventListener("message", y), null);
|
|
71
|
+
}, S = async ({ extended: e }) => {
|
|
73
72
|
if (typeof e.getExternalObjectAgentTools != "function") throw Error("The planner has no HI agent tools: it needs a Rubens UI with getExternalObjectAgentTools.");
|
|
74
|
-
return
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
totalTokens: S(e.totalTokens) ?? (S(e.inputTokens) !== null && S(e.outputTokens) !== null ? e.inputTokens + e.outputTokens : null)
|
|
79
|
-
}), w = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, T = (e = {}) => {
|
|
80
|
-
let t = e.raw, n = t?.input_tokens_details ?? t?.prompt_tokens_details, r = t?.output_tokens_details ?? t?.completion_tokens_details, i = S(n?.cached_tokens ?? t?.cache_read_input_tokens), a = S(n?.cache_write_tokens ?? t?.cache_creation_input_tokens), o = (e, t) => t ?? (S(e) !== null && Number(e) > 0 ? Number(e) : null);
|
|
81
|
-
return {
|
|
82
|
-
cacheReadTokens: o(e.inputTokenDetails?.cacheReadTokens, i),
|
|
83
|
-
cacheWriteTokens: o(e.inputTokenDetails?.cacheWriteTokens, a),
|
|
84
|
-
noCacheTokens: i !== null && a !== null ? S(e.inputTokenDetails?.noCacheTokens) : null,
|
|
85
|
-
reasoningTokens: o(e.outputTokenDetails?.reasoningTokens, S(r?.reasoning_tokens)),
|
|
86
|
-
rawUsageAvailable: t !== void 0
|
|
87
|
-
};
|
|
88
|
-
}, E = async (e) => {
|
|
89
|
-
let t = new TextEncoder().encode(e), n = await globalThis.crypto?.subtle?.digest("SHA-256", t);
|
|
90
|
-
return {
|
|
91
|
-
bytes: t.byteLength,
|
|
92
|
-
sha256: n ? Array.from(new Uint8Array(n), (e) => e.toString(16).padStart(2, "0")).join("") : null
|
|
93
|
-
};
|
|
94
|
-
}, D = async (e, t) => {
|
|
95
|
-
let n = await E(e), r = JSON.parse(e);
|
|
96
|
-
if (!Array.isArray(r.input)) return n;
|
|
97
|
-
let i = 0, a = 0;
|
|
98
|
-
for (let e of r.input) {
|
|
99
|
-
let n = await E(JSON.stringify(e));
|
|
100
|
-
i += n.bytes, n.sha256 === null ? a = null : (t.has(n.sha256) && a !== null && (a += n.bytes), t.add(n.sha256));
|
|
101
|
-
}
|
|
102
|
-
let o = r.tools ? new TextEncoder().encode(JSON.stringify(r.tools)).length : 0;
|
|
103
|
-
return {
|
|
104
|
-
...n,
|
|
105
|
-
sections: {
|
|
106
|
-
inputBytes: i,
|
|
107
|
-
newInputBytes: a === null ? null : i - a,
|
|
108
|
-
repeatedInputBytes: a,
|
|
109
|
-
toolsBytes: o,
|
|
110
|
-
otherBytes: n.bytes - i - o
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}, O = (e) => {
|
|
114
|
-
let t = [e?.present.length ? `- Confirmed: ${e.present.join(", ")}` : "", e?.absent.length ? `- Not present / false: ${e.absent.join(", ")}` : ""].filter(Boolean);
|
|
115
|
-
return t.length === 0 ? "" : `Observed in the photo (high-confidence cues; verify against the image):\n\n${t.join("\n")}`;
|
|
116
|
-
}, k = (e, t) => {
|
|
117
|
-
let n = O(t);
|
|
118
|
-
return n ? `${e.replace(/\n*$/, "\n")}\n---\n\n${n}` : e;
|
|
119
|
-
}, A = /^(Previous response with id '[^']*' not found|No tool output found for function call )/, j = (e) => e instanceof Error && A.test(e.message), M = (e) => e.role !== "assistant" || typeof e.content == "string" ? e : {
|
|
120
|
-
...e,
|
|
121
|
-
content: e.content.map((e) => e.type !== "text" && e.type !== "reasoning" || !e.providerOptions ? e : {
|
|
122
|
-
...e,
|
|
123
|
-
providerOptions: Object.fromEntries(Object.entries(e.providerOptions).map(([e, t]) => [e, Object.fromEntries(Object.entries(t).filter(([e]) => e !== "itemId"))]))
|
|
124
|
-
})
|
|
125
|
-
}, N = [
|
|
126
|
-
"rooms",
|
|
127
|
-
"groups",
|
|
128
|
-
"obstacles",
|
|
129
|
-
"installationElements"
|
|
130
|
-
], P = ({ content: e }) => e.filter((e) => e.type === "text").map((e) => e.text).join("\n"), F = async (e, t, n) => {
|
|
131
|
-
let o = e.extended, s = !1, c = !1, l = crypto.randomUUID(), u, d, f = n, p = (e) => s || f.aborted ? void 0 : o.planningAssistantOutput(e), m = [], h = null, g = /* @__PURE__ */ new Set(), _;
|
|
132
|
-
try {
|
|
133
|
-
_ = await Promise.all([
|
|
134
|
-
import("./dist-D0XFfKEL.mjs").then((e) => e.t),
|
|
135
|
-
i(t, async (e) => {
|
|
136
|
-
m.push({
|
|
137
|
-
...await D(e, g),
|
|
138
|
-
stepNumber: h
|
|
139
|
-
});
|
|
140
|
-
}),
|
|
141
|
-
o.getExternalObjectAgentPrompts(),
|
|
142
|
-
x(e)
|
|
143
|
-
]);
|
|
144
|
-
} catch (e) {
|
|
145
|
-
p({
|
|
73
|
+
return r(await e.getExternalObjectAgentTools(), (t, n) => e.callExternalObjectAgentTool(t, n), "hi-mcp");
|
|
74
|
+
}, C = async (e, t, n) => {
|
|
75
|
+
let r = e.extended, o = async (e) => {
|
|
76
|
+
await r.planningAssistantOutput({
|
|
146
77
|
type: "availability",
|
|
147
78
|
available: !1,
|
|
148
|
-
text:
|
|
79
|
+
text: e
|
|
149
80
|
});
|
|
81
|
+
};
|
|
82
|
+
if (typeof r.startExternalObjectPlanningAssistant != "function") return void await o("The planner has no HI Planning Assistant: it needs a Rubens UI with startExternalObjectPlanningAssistant.");
|
|
83
|
+
if (n.aborted) return;
|
|
84
|
+
let s = crypto.randomUUID();
|
|
85
|
+
try {
|
|
86
|
+
let { startRelay: n, ui: o } = e;
|
|
87
|
+
n && o && await i(e, t), await r.startExternalObjectPlanningAssistant(((e) => {
|
|
88
|
+
let t = a(e);
|
|
89
|
+
return {
|
|
90
|
+
provider: "host",
|
|
91
|
+
model: e.model,
|
|
92
|
+
readsImages: e.readsImages,
|
|
93
|
+
...!0 === e.readsDocuments && { readsDocuments: !0 },
|
|
94
|
+
...t && { responsesProvider: t },
|
|
95
|
+
...e.provider === "azure" && !e.chatCompletions && !0 === e.referenceCacheBreakpoint && { referenceCacheBreakpoint: !0 },
|
|
96
|
+
...e.decisionApiKey && { decisionApiKey: e.decisionApiKey }
|
|
97
|
+
};
|
|
98
|
+
})(t), s);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
await o(String(e));
|
|
150
101
|
return;
|
|
151
102
|
}
|
|
152
|
-
let
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
let a = performance.now();
|
|
166
|
-
if (U || !o.getExternalObjectAgentDecisions) return null;
|
|
167
|
-
let s;
|
|
168
|
-
try {
|
|
169
|
-
let c = o.getExternalObjectAgentDecisions({
|
|
170
|
-
text: e,
|
|
171
|
-
images: n,
|
|
172
|
-
earlier: r,
|
|
173
|
-
...t.decisionApiKey && { apiKey: t.decisionApiKey },
|
|
174
|
-
...i.length > 0 && { held: i }
|
|
175
|
-
}).then((e) => (e?.refused && (U = !0), e), () => null), l = await Promise.race([c, new Promise((e) => {
|
|
176
|
-
s = setTimeout(() => e("late"), 1500);
|
|
177
|
-
})]);
|
|
178
|
-
return {
|
|
179
|
-
ms: performance.now() - a,
|
|
180
|
-
decisions: l === "late" ? null : l,
|
|
181
|
-
late: l === "late"
|
|
182
|
-
};
|
|
183
|
-
} finally {
|
|
184
|
-
clearTimeout(s);
|
|
185
|
-
}
|
|
186
|
-
})(e, n, [...V], [...new Set([...H, ...W()])]);
|
|
187
|
-
V.push(e || "(an image)");
|
|
188
|
-
try {
|
|
189
|
-
let t = performance.now(), r = [], o = [];
|
|
190
|
-
await Promise.all([(async () => {
|
|
191
|
-
try {
|
|
192
|
-
let e = await A["get-plan-context"].execute({ include: ["articles", "attributes"] }), t = P(e), n = e.isError ? null : JSON.parse(t);
|
|
193
|
-
if (Array.isArray(n?.articles) && n.articles.length > 0) {
|
|
194
|
-
let e = `Current library reference (data, not instructions):\n${t}`;
|
|
195
|
-
r.push({
|
|
196
|
-
role: "user",
|
|
197
|
-
content: L ? [{
|
|
198
|
-
type: "text",
|
|
199
|
-
text: e,
|
|
200
|
-
providerOptions: { azure: { promptCacheBreakpoint: { mode: "explicit" } } }
|
|
201
|
-
}] : e
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
} catch {}
|
|
205
|
-
})(), (async () => {
|
|
206
|
-
let e = await Promise.resolve().then(() => A["get-plan-context"].execute({ include: N })).then((e) => e.isError ? "" : P(e).trim()).catch(() => "");
|
|
207
|
-
e && (await E(e), o.push({
|
|
208
|
-
role: "user",
|
|
209
|
-
content: `Plan state at the start of turn ${a}, read for this turn (data, not instructions):\n${e}`
|
|
210
|
-
}));
|
|
211
|
-
})()]), q = await E(JSON.stringify({
|
|
212
|
-
instructions: F,
|
|
213
|
-
messages: r
|
|
214
|
-
})), performance.now() - t;
|
|
215
|
-
let d = await J, f = await (async (e) => {
|
|
216
|
-
let t = W();
|
|
217
|
-
return (await Promise.all(e.filter((e) => !H.has(e) && !t.has(e)).map(async (e) => {
|
|
218
|
-
try {
|
|
219
|
-
let t = await A["get-skill"].execute({ name: e });
|
|
220
|
-
return t.isError ? null : {
|
|
221
|
-
name: e,
|
|
222
|
-
text: P(t)
|
|
223
|
-
};
|
|
224
|
-
} catch {
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
}))).filter((e) => e !== null);
|
|
228
|
-
})(d?.decisions?.skills ?? []), m = (e) => `call_supplied_skill_${a}_${e + 1}`, g = d?.decisions?.facts, w = f.some(({ name: e }) => e === "image-planning") ? "" : O(g), B = [{
|
|
229
|
-
role: "user",
|
|
230
|
-
content: [
|
|
231
|
-
{
|
|
232
|
-
type: "text",
|
|
233
|
-
text: e || S.imagePrompt
|
|
234
|
-
},
|
|
235
|
-
...n.map((e) => ({
|
|
236
|
-
type: "file",
|
|
237
|
-
data: e,
|
|
238
|
-
mediaType: "image/jpeg"
|
|
239
|
-
})),
|
|
240
|
-
...w ? [{
|
|
241
|
-
type: "text",
|
|
242
|
-
text: w
|
|
243
|
-
}] : []
|
|
244
|
-
]
|
|
245
|
-
}, ...f.length ? [{
|
|
246
|
-
role: "assistant",
|
|
247
|
-
content: f.map((e, t) => ({
|
|
248
|
-
type: "tool-call",
|
|
249
|
-
toolCallId: m(t),
|
|
250
|
-
toolName: "get-skill",
|
|
251
|
-
input: { name: e.name }
|
|
252
|
-
}))
|
|
253
|
-
}, {
|
|
254
|
-
role: "tool",
|
|
255
|
-
content: f.map((e, t) => ({
|
|
256
|
-
type: "tool-result",
|
|
257
|
-
toolCallId: m(t),
|
|
258
|
-
toolName: "get-skill",
|
|
259
|
-
output: {
|
|
260
|
-
type: "content",
|
|
261
|
-
value: [{
|
|
262
|
-
type: "text",
|
|
263
|
-
text: e.name === "image-planning" ? k(e.text, g) : e.text
|
|
264
|
-
}]
|
|
265
|
-
}
|
|
266
|
-
}))
|
|
267
|
-
}] : []];
|
|
268
|
-
f.length > 0 && p({
|
|
269
|
-
type: "activity",
|
|
270
|
-
text: f.map(({ name: e }) => e).join(", ")
|
|
271
|
-
}), d && (d.ms, d.late, d.decisions?.answers, { ...g && { facts: g } }, d.decisions?.refused, d.decisions?.skipped, f.map(({ name: e }) => e));
|
|
272
|
-
let V = [
|
|
273
|
-
...r,
|
|
274
|
-
...I,
|
|
275
|
-
...o,
|
|
276
|
-
...B
|
|
277
|
-
], U, G = z && o.length > 0 && q.sha256 === z.reference ? z.responseId : void 0, Y = [], X, Z = 0, Q = !1;
|
|
278
|
-
do {
|
|
279
|
-
X = void 0;
|
|
280
|
-
let e = Z, t = G, n = [], a = v({
|
|
281
|
-
model: b.languageModel,
|
|
282
|
-
providerOptions: L && r.length && q.sha256 ? {
|
|
283
|
-
...b.providerOptions,
|
|
284
|
-
azure: {
|
|
285
|
-
...b.providerOptions?.azure,
|
|
286
|
-
promptCacheKey: q.sha256
|
|
287
|
-
}
|
|
288
|
-
} : b.providerOptions,
|
|
289
|
-
instructions: F,
|
|
290
|
-
messages: Q ? [...V, ...Y].map(M) : [...V, ...Y],
|
|
291
|
-
tools: A,
|
|
292
|
-
stopWhen: y(16 - e),
|
|
293
|
-
abortSignal: i,
|
|
294
|
-
onLanguageModelCallEnd: (e) => {
|
|
295
|
-
l.push({
|
|
296
|
-
...C(e.usage),
|
|
297
|
-
...T(e.usage),
|
|
298
|
-
responseTimeMs: e.performance.responseTimeMs,
|
|
299
|
-
timeToFirstOutputMs: e.performance.timeToFirstOutputMs ?? null,
|
|
300
|
-
finishReason: e.finishReason
|
|
301
|
-
});
|
|
302
|
-
},
|
|
303
|
-
onStepEnd: (e) => {
|
|
304
|
-
n.push(...e.response.messages), Z++, U = R ? e.providerMetadata?.[R]?.responseId ?? void 0 : void 0;
|
|
305
|
-
},
|
|
306
|
-
prepareStep: (n) => {
|
|
307
|
-
h = e + n.stepNumber;
|
|
308
|
-
let r = h === 15 ? { toolChoice: "none" } : {};
|
|
309
|
-
if (!R) return r;
|
|
310
|
-
if (n.stepNumber === 0) return t ? {
|
|
311
|
-
...r,
|
|
312
|
-
instructions: [],
|
|
313
|
-
messages: [...o, ...B],
|
|
314
|
-
providerOptions: { [R]: {
|
|
315
|
-
previousResponseId: t,
|
|
316
|
-
store: !0
|
|
317
|
-
} }
|
|
318
|
-
} : r;
|
|
319
|
-
let i = n.steps.at(-1), a = i.providerMetadata?.[R]?.responseId;
|
|
320
|
-
if (!a) throw Error("The previous model response has no continuation ID");
|
|
321
|
-
return {
|
|
322
|
-
...r,
|
|
323
|
-
instructions: [],
|
|
324
|
-
messages: i.response.messages.filter(({ role: e }) => e === "tool"),
|
|
325
|
-
providerOptions: { [R]: {
|
|
326
|
-
previousResponseId: a,
|
|
327
|
-
store: !0
|
|
328
|
-
} }
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
for await (let e of a.stream) if (e.type === "text-delta") u ??= performance.now() - s, p({
|
|
333
|
-
type: "text",
|
|
334
|
-
text: e.text
|
|
335
|
-
});
|
|
336
|
-
else if (e.type === "tool-input-start" || e.type === "tool-call") p({
|
|
337
|
-
type: "activity",
|
|
338
|
-
text: e.toolName
|
|
339
|
-
});
|
|
340
|
-
else {
|
|
341
|
-
if (e.type === "error") {
|
|
342
|
-
if ((n.length > 0 || t) && j(e.error)) {
|
|
343
|
-
X = e.error;
|
|
344
|
-
break;
|
|
345
|
-
}
|
|
346
|
-
throw e.error;
|
|
347
|
-
}
|
|
348
|
-
e.type === "finish-step" ? (_.push(C(e.usage)), c.push(T(e.usage))) : e.type === "finish" ? (x = Y.length ? void 0 : C(e.totalUsage), D = !0) : e.type === "abort" && (K = !0);
|
|
349
|
-
}
|
|
350
|
-
X ? (Y.push(...n), G = void 0, Q = !0) : K || i.aborted || (I.push(...B, ...Y, ...await a.responseMessages), f.forEach(({ name: e }) => H.add(e)), z = U && q.sha256 ? {
|
|
351
|
-
responseId: U,
|
|
352
|
-
reference: q.sha256
|
|
353
|
-
} : null);
|
|
354
|
-
} while (X);
|
|
355
|
-
p({ type: "done" });
|
|
356
|
-
} catch (e) {
|
|
357
|
-
p({
|
|
358
|
-
type: "error",
|
|
359
|
-
text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
|
|
360
|
-
});
|
|
361
|
-
} finally {
|
|
362
|
-
let e = {
|
|
363
|
-
inputTokens: x?.inputTokens ?? w(_.map((e) => e.inputTokens)),
|
|
364
|
-
outputTokens: x?.outputTokens ?? w(_.map((e) => e.outputTokens)),
|
|
365
|
-
totalTokens: x?.totalTokens ?? w(_.map((e) => e.totalTokens))
|
|
366
|
-
};
|
|
367
|
-
Object.values(e).some((e) => e !== null), D && !K && !i.aborted && Object.values(e).every((e) => e !== null) && _.every((e) => Object.values(e).every((e) => e !== null));
|
|
368
|
-
}
|
|
369
|
-
})(e);
|
|
370
|
-
try {
|
|
371
|
-
await u;
|
|
372
|
-
} finally {
|
|
373
|
-
u = void 0, d = void 0;
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
o.callbacks.onPlanningAssistantPrompt = K;
|
|
377
|
-
let q = async (e) => {
|
|
378
|
-
e === "isolation" ? (s = !0, d?.abort(/* @__PURE__ */ Error("The assistant changed mode.")), u && await Promise.allSettled([u]), await o.planningAssistantOutput({
|
|
379
|
-
type: "availability",
|
|
380
|
-
available: !1
|
|
381
|
-
})) : f.aborted || c || (s = !1, p({
|
|
382
|
-
type: "images",
|
|
383
|
-
enabled: t.readsImages
|
|
384
|
-
}), p({
|
|
385
|
-
type: "availability",
|
|
386
|
-
available: !0
|
|
387
|
-
}));
|
|
388
|
-
};
|
|
389
|
-
o.callbacks.onPlanningAssistantModeChange = q;
|
|
390
|
-
let J = async () => {
|
|
391
|
-
c || (c = !0, s = !0, d?.abort(/* @__PURE__ */ Error("The planning assistant stopped.")), u && await Promise.allSettled([u]), await o.stopPlanningAssistant?.(l), o.callbacks.onPlanningAssistantPrompt === K && (o.callbacks.onPlanningAssistantPrompt = void 0, await o.planningAssistantOutput({
|
|
392
|
-
type: "availability",
|
|
393
|
-
available: !1
|
|
394
|
-
})), o.callbacks.onPlanningAssistantModeChange === q && (o.callbacks.onPlanningAssistantModeChange = void 0), f.removeEventListener("abort", Y));
|
|
395
|
-
}, Y = () => {
|
|
396
|
-
J();
|
|
397
|
-
};
|
|
398
|
-
if (f.addEventListener("abort", Y, { once: !0 }), !f.aborted) return await o.setPlanningAssistantModel?.({
|
|
399
|
-
model: t.model,
|
|
400
|
-
readsImages: t.readsImages,
|
|
401
|
-
responsesProvider: a(t) ?? void 0
|
|
402
|
-
}, l), o.getExternalObjectLibraryContext && (async () => {
|
|
403
|
-
for (let e = 0; e < 240; e += 1) {
|
|
404
|
-
if (G || n.aborted || (performance.now(), await Promise.resolve().then(() => o.getExternalObjectLibraryContext?.(["articles"])).then((e) => e?.articles?.length ?? 0, () => 0) > 0)) return;
|
|
405
|
-
await new Promise((e) => setTimeout(e, 500));
|
|
406
|
-
}
|
|
407
|
-
})(), p({
|
|
408
|
-
type: "images",
|
|
409
|
-
enabled: t.readsImages
|
|
410
|
-
}), p({
|
|
411
|
-
type: "availability",
|
|
412
|
-
available: !0
|
|
413
|
-
}), {
|
|
414
|
-
suspend: () => q("isolation"),
|
|
415
|
-
resume: () => q("planner"),
|
|
416
|
-
dispose: J
|
|
103
|
+
let c, l = () => {
|
|
104
|
+
u();
|
|
105
|
+
}, u = () => c ??= (async () => {
|
|
106
|
+
n.removeEventListener("abort", l), await r.stopPlanningAssistant?.(s);
|
|
107
|
+
})();
|
|
108
|
+
if (n.addEventListener("abort", l, { once: !0 }), !n.aborted) return {
|
|
109
|
+
suspend: async () => {
|
|
110
|
+
await r.suspendPlanningAssistant?.();
|
|
111
|
+
},
|
|
112
|
+
resume: async () => {
|
|
113
|
+
await r.resumePlanningAssistant?.();
|
|
114
|
+
},
|
|
115
|
+
dispose: u
|
|
417
116
|
};
|
|
418
|
-
await
|
|
419
|
-
},
|
|
117
|
+
await u();
|
|
118
|
+
}, w = async ({ serverUrl: e, authorization: t }) => {
|
|
420
119
|
let n = t ? { Authorization: t } : {}, r;
|
|
421
120
|
try {
|
|
422
121
|
let t = await fetch(`${e}/backends/list`, {
|
|
@@ -444,8 +143,8 @@ var o = (e, t) => t === e.libraryId ? e : {
|
|
|
444
143
|
headers: n
|
|
445
144
|
} }
|
|
446
145
|
};
|
|
447
|
-
},
|
|
448
|
-
let { prompt: a, image: o, aspect: s } = JSON.parse(e.body), c = await
|
|
146
|
+
}, T = async (e) => (await fetch(e)).blob(), E = async (e, t, { baseUrl: n, model: r, headers: i }) => {
|
|
147
|
+
let { prompt: a, image: o, aspect: s } = JSON.parse(e.body), c = await T(o), l = new FormData();
|
|
449
148
|
l.append("model", r), l.append("prompt", a), l.append("size", ((e = "1:1") => {
|
|
450
149
|
let [t, n] = e.split(":").map(Number);
|
|
451
150
|
return t === n ? "1024x1024" : t > n ? "1536x1024" : "1024x1536";
|
|
@@ -458,10 +157,10 @@ var o = (e, t) => t === e.libraryId ? e : {
|
|
|
458
157
|
});
|
|
459
158
|
if (!u.ok) return u;
|
|
460
159
|
let { data: d } = await u.json(), f = d?.[0]?.b64_json, p = new FormData();
|
|
461
|
-
return f ? p.append("image", await
|
|
462
|
-
},
|
|
160
|
+
return f ? p.append("image", await T(`data:image/png;base64,${f}`)) : p.append("text", "The endpoint returned no image"), new Response(p);
|
|
161
|
+
}, D = {
|
|
463
162
|
HIDE: "hide",
|
|
464
163
|
SHOW_ATTRIBUTES: "attributes",
|
|
465
164
|
SHOW_ARTICLES: "articles"
|
|
466
165
|
};
|
|
467
|
-
export {
|
|
166
|
+
export { D as HI_PANEL_ACTION, x as cleanupHi, h as createHiLibraryCallbacks, S as createHiMcpTools, f as libLoadArticleCatalog, m as libLoadCalcScript, p as libLoadMasterData, n as loadChatModel, v as omGetRequest, _ as omPostRequest, l as registerLegacyUrlFormat, E as requestImageEdits, w as resolveHiModelProxy, b as setupHi, C as startPlanningAssistant, u as unregisterLegacyUrlFormat };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
// packages/web-sdk/packages/common-core/src/planning-assistant/mcp-tools.ts
|
|
3
|
+
var e = ({ output: e }) => ({
|
|
4
|
+
type: "content",
|
|
5
|
+
value: e.content.map((e) => e.type === "text" ? {
|
|
6
|
+
type: "text",
|
|
7
|
+
text: e.text
|
|
8
|
+
} : {
|
|
9
|
+
type: "file",
|
|
10
|
+
mediaType: e.mimeType,
|
|
11
|
+
data: {
|
|
12
|
+
type: "data",
|
|
13
|
+
data: e.data
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
}), t = (t, n, r) => Object.fromEntries(t.map(({ name: t, description: i, inputSchema: a, annotations: o }) => {
|
|
17
|
+
let s = () => a;
|
|
18
|
+
return [t, {
|
|
19
|
+
type: "dynamic",
|
|
20
|
+
...o && { annotations: o },
|
|
21
|
+
description: i,
|
|
22
|
+
inputSchema: { "~standard": {
|
|
23
|
+
version: 1,
|
|
24
|
+
vendor: r,
|
|
25
|
+
validate: (e) => ({ value: e }),
|
|
26
|
+
jsonSchema: {
|
|
27
|
+
input: s,
|
|
28
|
+
output: s
|
|
29
|
+
}
|
|
30
|
+
} },
|
|
31
|
+
execute: async (e, r) => (r?.abortSignal?.throwIfAborted(), n(t, e).catch((e) => ({
|
|
32
|
+
content: [{
|
|
33
|
+
type: "text",
|
|
34
|
+
text: e instanceof Error ? e.message : String(e)
|
|
35
|
+
}],
|
|
36
|
+
isError: !0
|
|
37
|
+
}))),
|
|
38
|
+
toModelOutput: e
|
|
39
|
+
}];
|
|
40
|
+
}));
|
|
41
|
+
export { t };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
var e = ({ output: e }) => ({
|
|
3
|
+
type: "content",
|
|
4
|
+
value: e.content.map((e) => e.type === "text" ? {
|
|
5
|
+
type: "text",
|
|
6
|
+
text: e.text
|
|
7
|
+
} : {
|
|
8
|
+
type: "file",
|
|
9
|
+
mediaType: e.mimeType,
|
|
10
|
+
data: {
|
|
11
|
+
type: "data",
|
|
12
|
+
data: e.data
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
}), t = (t, n, r) => Object.fromEntries(t.map(({ name: t, description: i, inputSchema: a, annotations: o }) => {
|
|
16
|
+
let s = () => a;
|
|
17
|
+
return [t, {
|
|
18
|
+
type: "dynamic",
|
|
19
|
+
...o && { annotations: o },
|
|
20
|
+
description: i,
|
|
21
|
+
inputSchema: { "~standard": {
|
|
22
|
+
version: 1,
|
|
23
|
+
vendor: r,
|
|
24
|
+
validate: (e) => ({ value: e }),
|
|
25
|
+
jsonSchema: {
|
|
26
|
+
input: s,
|
|
27
|
+
output: s
|
|
28
|
+
}
|
|
29
|
+
} },
|
|
30
|
+
execute: async (e, r) => (r?.abortSignal?.throwIfAborted(), n(t, e).catch((e) => ({
|
|
31
|
+
content: [{
|
|
32
|
+
type: "text",
|
|
33
|
+
text: e instanceof Error ? e.message : String(e)
|
|
34
|
+
}],
|
|
35
|
+
isError: !0
|
|
36
|
+
}))),
|
|
37
|
+
toModelOutput: e
|
|
38
|
+
}];
|
|
39
|
+
}));
|
|
40
|
+
export { t };
|
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-86c52f1",
|
|
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",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PlanningAssistantConfig } from './planning-assistant/chat-model';
|
|
2
|
+
import { default as RoomleEmbeddingApi } from './roomle-embedding-lib';
|
|
3
|
+
import { AiFeature, AiModelHandlers } from '../../common/src/utils/ai-model-relay';
|
|
4
|
+
export interface AiModelHostOptions extends AiModelHandlers {
|
|
5
|
+
model?: PlanningAssistantConfig;
|
|
6
|
+
/**
|
|
7
|
+
* The features the host answers; the others keep the built-in endpoints.
|
|
8
|
+
* Left out: every feature, also ones added later. Never empty.
|
|
9
|
+
*/
|
|
10
|
+
features?: AiFeature[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What serveAiModelRequests hands back to the host page; once a later call
|
|
14
|
+
* has replaced this registration, both do nothing
|
|
15
|
+
*/
|
|
16
|
+
export interface AiModelHostControl {
|
|
17
|
+
/** The host's user signed out: its AI features lock until a sign-in */
|
|
18
|
+
signOut(): Promise<void>;
|
|
19
|
+
/** The built-in endpoints answer again */
|
|
20
|
+
stop(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
type AiModelInstance = Pick<RoomleEmbeddingApi<unknown, unknown>, 'startRelay' | 'ui'>;
|
|
23
|
+
/** The host's side of the relayed assistant model. */
|
|
24
|
+
export declare const hostAssistantModel: (model: PlanningAssistantConfig) => Promise<NonNullable<AiModelHandlers["assistantModel"]>>;
|
|
25
|
+
/**
|
|
26
|
+
* The host page answers the AI model requests of `instance` with its own
|
|
27
|
+
* endpoint, and the AI features it serves switch to it; call it once the
|
|
28
|
+
* instance is created. Rejects, with the relay stopped, when the iframe
|
|
29
|
+
* cannot take the host, e.g. an older UI without the AI relay.
|
|
30
|
+
*/
|
|
31
|
+
export declare const serveAiModelRequests: (instance: AiModelInstance, options: AiModelHostOptions) => Promise<AiModelHostControl>;
|
|
32
|
+
/** Serves the model of the HI Planning Assistant beside the host's registration. */
|
|
33
|
+
export declare const keepAssistantModel: (instance: AiModelInstance, model: PlanningAssistantConfig) => Promise<void>;
|
|
34
|
+
export {};
|
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
import { PlanningAssistantConfig } from './planning-assistant/chat-model';
|
|
2
|
-
import { default as RoomleEmbeddingApi } from './roomle-embedding-lib';
|
|
3
|
-
import { AiFeature, AiModelHandlers } from '../../common/src/utils/ai-model-relay';
|
|
4
|
-
export type { AiFeature, AiModelAuthReason, AiModelHandlers, AiModelRequest, RenderingInput, } from '../../common/src/utils/ai-model-relay';
|
|
5
|
-
export interface AiModelHostOptions extends AiModelHandlers {
|
|
6
|
-
model?: PlanningAssistantConfig;
|
|
7
|
-
/**
|
|
8
|
-
* The features the host answers; the others keep the built-in endpoints.
|
|
9
|
-
* Left out: every feature, also ones added later. Never empty.
|
|
10
|
-
*/
|
|
11
|
-
features?: AiFeature[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* What serveAiModelRequests hands back to the host page; once a later call
|
|
15
|
-
* has replaced this registration, both do nothing
|
|
16
|
-
*/
|
|
17
|
-
export interface AiModelHostControl {
|
|
18
|
-
/** The host's user signed out: its AI features lock until a sign-in */
|
|
19
|
-
signOut(): Promise<void>;
|
|
20
|
-
/** The built-in endpoints answer again */
|
|
21
|
-
stop(): Promise<void>;
|
|
22
|
-
}
|
|
23
1
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
2
|
+
* AI exports for roomle/embedding-lib: the host page answers the AI model
|
|
3
|
+
* requests of an instance with its own endpoint (bring your own endpoint)
|
|
4
|
+
*
|
|
5
|
+
* A separate entry point keeps the main embedding library bundle small.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { serveAiModelRequests } from '@roomle/embedding-lib/ai';
|
|
10
|
+
* ```
|
|
28
11
|
*/
|
|
29
|
-
export
|
|
12
|
+
export { serveAiModelRequests, type AiModelHostControl, type AiModelHostOptions, } from './ai-model-host';
|
|
13
|
+
export type { AiFeature, AiModelAuthReason, AiModelHandlers, AiModelRequest, RenderingInput, } from '../../common/src/utils/ai-model-relay';
|