@roomle/embedding-lib 0.0.0-dev-a4754cb
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/.releaserc.json +60 -0
- package/README.md +13 -0
- package/browser-BxG7yIaK.mjs +16 -0
- package/browser-CW9o-dtT.mjs +18 -0
- package/comlink-B2Kj_5Ge.mjs +206 -0
- package/comlink-B5lV2OWp.mjs +226 -0
- package/drag-ghost-BOwjMbG3.mjs +65 -0
- package/drag-ghost-BQ8r6NVo.mjs +60 -0
- package/drag-in-BP_E53zb.mjs +102 -0
- package/drag-in-QhL3zGC0.mjs +108 -0
- package/embedding-plugins.d.ts +2 -0
- package/embedding-plugins.js +2 -0
- package/embedding-plugins.min.js +2 -0
- package/from-custom-view-BM_zRJCf.mjs +227 -0
- package/from-custom-view-D2Z1YmCx.mjs +226 -0
- package/from-website-CPVeVVMI.mjs +123 -0
- package/from-website-DlklVbxU.mjs +118 -0
- package/hi-mcp-server-BtrPxgNY.mjs +5278 -0
- package/hi-mcp-server-ukmMIPNu.mjs +4866 -0
- package/hi.d.ts +2 -0
- package/hi.js +182 -0
- package/hi.min.js +167 -0
- package/package.json +50 -0
- package/packages/embedding-lib/src/connector.d.ts +44 -0
- package/packages/embedding-lib/src/embedding-plugins.d.ts +9 -0
- package/packages/embedding-lib/src/hi.d.ts +22 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-callbacks.d.ts +3 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/agent-facing.d.ts +35 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/hi-mcp-server.d.ts +3 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/mcp-tool.d.ts +69 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/plan-history.d.ts +33 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/planner-api.d.ts +32 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/skills.d.ts +23 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/tool-executors.d.ts +4 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp-tools.d.ts +11 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-order-manager.d.ts +3 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +55 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-requests.d.ts +35 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-setup.d.ts +6 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-utils.d.ts +8 -0
- package/packages/embedding-lib/src/plugins/constants.d.ts +19 -0
- package/packages/embedding-lib/src/plugins/drag-in.d.ts +32 -0
- package/packages/embedding-lib/src/plugins/strategy/drag-phase.d.ts +25 -0
- package/packages/embedding-lib/src/plugins/strategy/from-custom-view.d.ts +39 -0
- package/packages/embedding-lib/src/plugins/strategy/from-website.d.ts +45 -0
- package/packages/embedding-lib/src/plugins/strategy/types.d.ts +14 -0
- package/packages/embedding-lib/src/plugins/types.d.ts +35 -0
- package/packages/embedding-lib/src/roomle-embedding-lib.d.ts +82 -0
- package/packages/embedding-lib/src/utils.d.ts +35 -0
- package/roomle-embedding-lib.d.ts +6 -0
- package/roomle-embedding-lib.js +396 -0
- package/roomle-embedding-lib.min.js +366 -0
- package/utils-DxJ3PcKe.mjs +131 -0
- package/utils-wJ80awOA.mjs +123 -0
package/hi.d.ts
ADDED
package/hi.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { t as e } from "./browser-CW9o-dtT.mjs";
|
|
2
|
+
import { t } from "./utils-DxJ3PcKe.mjs";
|
|
3
|
+
var n = (e, t) => t === e.libraryId ? e : {
|
|
4
|
+
...e,
|
|
5
|
+
libraryId: t
|
|
6
|
+
}, r = async (e, t, n, r = { property: "default" }) => {
|
|
7
|
+
let i = n.serverOptions ?? {}, a = { headers: {
|
|
8
|
+
"Content-Type": t === "json" ? "application/json" : "text/plain",
|
|
9
|
+
"Access-Control-Allow-Origin": "*"
|
|
10
|
+
} };
|
|
11
|
+
i.language && (a.headers["Accept-Language"] = i.language), i.authData && (a.headers.Authorization = i.authData);
|
|
12
|
+
try {
|
|
13
|
+
let t = performance.now(), { baseUrl: n, subscriptionId: o, key: s, endpointUrl: c } = i, l = await fetch((n ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + encodeURIComponent(e) + (o ? `&subscriptionId=${encodeURIComponent(o || "")}` : "") + (s ? `&apiKey=${encodeURIComponent(s)}` : "") + (c ? `&baseUrl=${encodeURIComponent(c)}` : ""), a), u = performance.now() - t;
|
|
14
|
+
if (!l.ok) throw console.warn(`Failed to fetch data from ${r.property}`), Error(`Failed to fetch data from ${e}: ${l.statusText}`);
|
|
15
|
+
return console.info(`Success to fetch data from ${r.property}`), console.info(`The data for ${r.property} was fetched in ${u} milliseconds`), l;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
throw console.warn(`Failed to fetch data from ${r.property}`), console.error(e), e;
|
|
18
|
+
}
|
|
19
|
+
}, i = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": new Set(["Furniture_Smith"]) }, a = (e, t) => {
|
|
20
|
+
i[e] || (i[e] = /* @__PURE__ */ new Set()), i[e].add(t);
|
|
21
|
+
}, o = (e, t) => {
|
|
22
|
+
i[e]?.delete(t), i[e]?.size === 0 && delete i[e];
|
|
23
|
+
}, s = (e, t) => {
|
|
24
|
+
let { libraryId: n, serverOptions: r } = e;
|
|
25
|
+
return r?.subscriptionId && i[r.subscriptionId]?.has(n) ? `api/pos/${t}?libraryId=${n}` : `api/pos/libraries/${n}/${t}`;
|
|
26
|
+
}, 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) => {
|
|
27
|
+
let t = await (await r(s(e, "calc.js"), "text", e, { property: "calc.js" })).text();
|
|
28
|
+
if (!t) throw Error("Script load error");
|
|
29
|
+
return t;
|
|
30
|
+
}, d = (e) => ({
|
|
31
|
+
onLoadJavascript: (t) => u(n(e, t)),
|
|
32
|
+
onLoadArticleCatalog: (t) => c(n(e, t)),
|
|
33
|
+
onLoadMasterData: (t) => l(n(e, t))
|
|
34
|
+
}), f = async (e, t, n, r = {}) => {
|
|
35
|
+
let { baseUrl: i, om: a } = e.serverOptions ?? {}, o = encodeURIComponent(a?.endpointUrl || ""), s = encodeURIComponent(a?.subscriptionId || ""), c = a?.key || "";
|
|
36
|
+
return await (await fetch((i ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(n)}&subscriptionId=${s}&apiKey=${c}&baseUrl=${o}`, {
|
|
37
|
+
method: "POST",
|
|
38
|
+
body: JSON.stringify(t),
|
|
39
|
+
headers: {
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
...r
|
|
42
|
+
}
|
|
43
|
+
})).json();
|
|
44
|
+
}, p = async (e, t, n = {}) => {
|
|
45
|
+
let { baseUrl: r, om: i } = e.serverOptions ?? {}, a = encodeURIComponent(i?.endpointUrl || ""), o = encodeURIComponent(i?.subscriptionId || ""), s = i?.key || "";
|
|
46
|
+
return await (await fetch((r ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(t)}&subscriptionId=${o}&apiKey=${s}&baseUrl=${a}`, {
|
|
47
|
+
method: "GET",
|
|
48
|
+
headers: {
|
|
49
|
+
"Content-Type": "application/json",
|
|
50
|
+
...n
|
|
51
|
+
}
|
|
52
|
+
})).json();
|
|
53
|
+
}, m = (t, n) => {
|
|
54
|
+
t.serverOptions ||= {}, !t.serverOptions.language && n?.locale && (t.serverOptions.language = n.locale), t.serverOptions.language || (t.serverOptions.language = e(null, !0));
|
|
55
|
+
}, h = null, g = async (e, r = {}) => {
|
|
56
|
+
h && window.removeEventListener("message", h);
|
|
57
|
+
let i = typeof e == "string" ? { libraryId: e } : e;
|
|
58
|
+
r.onLoadJavascript === void 0 && (r.onLoadJavascript = (e) => u(n(i, e))), r.onLoadArticleCatalog === void 0 && (r.onLoadArticleCatalog = (e) => c(n(i, e))), r.onLoadMasterData === void 0 && (r.onLoadMasterData = (e) => l(n(i, e)));
|
|
59
|
+
let { expose: a } = await import("./comlink-B5lV2OWp.mjs");
|
|
60
|
+
h = (e) => {
|
|
61
|
+
if (e.data.type === "connect_hi" && e.data.port) {
|
|
62
|
+
let n = e.data.port;
|
|
63
|
+
m(i, e.data.globalInitData || {}), n.start?.(), a(t(r), n);
|
|
64
|
+
}
|
|
65
|
+
}, window.addEventListener("message", h);
|
|
66
|
+
}, _ = () => {
|
|
67
|
+
h &&= (window.removeEventListener("message", h), null);
|
|
68
|
+
}, v = async (e) => (await import("./hi-mcp-server-BtrPxgNY.mjs")).createHiMcpTools(e), y = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, b = 16, x = async ({ provider: e, model: t, apiKey: n, baseUrl: r, chatCompletions: i, reasoningEffort: a }) => {
|
|
69
|
+
switch (e) {
|
|
70
|
+
case "azure": {
|
|
71
|
+
let { createAzure: e } = await import(
|
|
72
|
+
/* @vite-ignore */
|
|
73
|
+
y("@ai-sdk/azure@4.0.85")
|
|
74
|
+
), o = e({
|
|
75
|
+
apiKey: n,
|
|
76
|
+
baseURL: r
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
languageModel: i ? o.chat(t) : o(t),
|
|
80
|
+
providerOptions: a ? { azure: { reasoningEffort: a } } : void 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
case "mistral": {
|
|
84
|
+
let { createMistral: e } = await import(
|
|
85
|
+
/* @vite-ignore */
|
|
86
|
+
y("@ai-sdk/mistral@4.0.54")
|
|
87
|
+
);
|
|
88
|
+
return { languageModel: e({ apiKey: n })(t) };
|
|
89
|
+
}
|
|
90
|
+
case "anthropic": {
|
|
91
|
+
let { createAnthropic: e } = await import(
|
|
92
|
+
/* @vite-ignore */
|
|
93
|
+
y("@ai-sdk/anthropic@4.0.68")
|
|
94
|
+
);
|
|
95
|
+
return { languageModel: e({
|
|
96
|
+
apiKey: n,
|
|
97
|
+
headers: { "anthropic-dangerous-direct-browser-access": "true" }
|
|
98
|
+
})(t) };
|
|
99
|
+
}
|
|
100
|
+
case "google": {
|
|
101
|
+
let { createGoogleGenerativeAI: e } = await import(
|
|
102
|
+
/* @vite-ignore */
|
|
103
|
+
y("@ai-sdk/google@4.0.85")
|
|
104
|
+
);
|
|
105
|
+
return { languageModel: e({ apiKey: n })(t) };
|
|
106
|
+
}
|
|
107
|
+
default: throw Error(`Unknown provider "${e}" - supported: azure, mistral, anthropic, google`);
|
|
108
|
+
}
|
|
109
|
+
}, S = async (e, t, n) => {
|
|
110
|
+
let r = e.extended, i = (e) => r.planningAssistantOutput(e), a;
|
|
111
|
+
try {
|
|
112
|
+
a = await Promise.all([
|
|
113
|
+
import(
|
|
114
|
+
/* @vite-ignore */
|
|
115
|
+
y("ai@7.0.122")
|
|
116
|
+
),
|
|
117
|
+
x(t),
|
|
118
|
+
r.getExternalObjectAgentPrompts(),
|
|
119
|
+
v(e)
|
|
120
|
+
]);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.log("[planning-assistant]", String(e)), i({
|
|
123
|
+
type: "availability",
|
|
124
|
+
available: !1,
|
|
125
|
+
text: String(e)
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
let [{ streamText: o, stepCountIs: s }, c, l, u] = a, d = [];
|
|
130
|
+
r.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: t }) => {
|
|
131
|
+
let r = {
|
|
132
|
+
role: "user",
|
|
133
|
+
content: [{
|
|
134
|
+
type: "text",
|
|
135
|
+
text: e || l.imagePrompt
|
|
136
|
+
}, ...t.map((e) => ({
|
|
137
|
+
type: "file",
|
|
138
|
+
data: e,
|
|
139
|
+
mediaType: "image/jpeg"
|
|
140
|
+
}))]
|
|
141
|
+
};
|
|
142
|
+
try {
|
|
143
|
+
let e = o({
|
|
144
|
+
model: c.languageModel,
|
|
145
|
+
providerOptions: c.providerOptions,
|
|
146
|
+
instructions: l.systemPrompt,
|
|
147
|
+
messages: [...d, r],
|
|
148
|
+
tools: u,
|
|
149
|
+
stopWhen: s(b),
|
|
150
|
+
abortSignal: n,
|
|
151
|
+
prepareStep: ({ stepNumber: e }) => e === b - 1 ? { toolChoice: "none" } : void 0
|
|
152
|
+
});
|
|
153
|
+
for await (let t of e.stream) if (t.type === "text-delta") i({
|
|
154
|
+
type: "text",
|
|
155
|
+
text: t.text
|
|
156
|
+
});
|
|
157
|
+
else if (t.type === "tool-call") i({
|
|
158
|
+
type: "activity",
|
|
159
|
+
text: t.toolName
|
|
160
|
+
});
|
|
161
|
+
else if (t.type === "error") throw t.error;
|
|
162
|
+
d.push(r, ...await e.responseMessages), i({ type: "done" });
|
|
163
|
+
} catch (e) {
|
|
164
|
+
console.log("[planning-assistant]", String(e)), i({
|
|
165
|
+
type: "error",
|
|
166
|
+
text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}, i({
|
|
170
|
+
type: "images",
|
|
171
|
+
enabled: t.readsImages
|
|
172
|
+
}), i({
|
|
173
|
+
type: "availability",
|
|
174
|
+
available: !0
|
|
175
|
+
});
|
|
176
|
+
}, C = {
|
|
177
|
+
HIDE: "hide",
|
|
178
|
+
SHOW_ATTRIBUTES: "attributes",
|
|
179
|
+
SHOW_ARTICLES: "articles"
|
|
180
|
+
};
|
|
181
|
+
//#endregion
|
|
182
|
+
export { C as HI_PANEL_ACTION, _ as cleanupHi, d as createHiLibraryCallbacks, v as createHiMcpTools, c as libLoadArticleCatalog, u as libLoadCalcScript, l as libLoadMasterData, x as loadChatModel, p as omGetRequest, f as omPostRequest, a as registerLegacyUrlFormat, g as setupHi, S as startPlanningAssistant, o as unregisterLegacyUrlFormat };
|
package/hi.min.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { t as e } from "./browser-BxG7yIaK.mjs";
|
|
2
|
+
import { t } from "./utils-wJ80awOA.mjs";
|
|
3
|
+
var n = (e, t) => t === e.libraryId ? e : {
|
|
4
|
+
...e,
|
|
5
|
+
libraryId: t
|
|
6
|
+
}, r = async (e, t, n, r = { property: "default" }) => {
|
|
7
|
+
let i = n.serverOptions ?? {}, a = { headers: {
|
|
8
|
+
"Content-Type": t === "json" ? "application/json" : "text/plain",
|
|
9
|
+
"Access-Control-Allow-Origin": "*"
|
|
10
|
+
} };
|
|
11
|
+
i.language && (a.headers["Accept-Language"] = i.language), i.authData && (a.headers.Authorization = i.authData);
|
|
12
|
+
try {
|
|
13
|
+
performance.now();
|
|
14
|
+
let { baseUrl: t, subscriptionId: n, key: r, endpointUrl: o } = i, s = await fetch((t ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + encodeURIComponent(e) + (n ? `&subscriptionId=${encodeURIComponent(n || "")}` : "") + (r ? `&apiKey=${encodeURIComponent(r)}` : "") + (o ? `&baseUrl=${encodeURIComponent(o)}` : ""), a);
|
|
15
|
+
if (performance.now(), !s.ok) throw Error(`Failed to fetch data from ${e}: ${s.statusText}`);
|
|
16
|
+
return s;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
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) => {
|
|
25
|
+
let { libraryId: n, serverOptions: r } = e;
|
|
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();
|
|
29
|
+
if (!t) throw Error("Script load error");
|
|
30
|
+
return t;
|
|
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 = {}) => {
|
|
36
|
+
let { baseUrl: i, om: a } = e.serverOptions ?? {}, o = encodeURIComponent(a?.endpointUrl || ""), s = encodeURIComponent(a?.subscriptionId || ""), c = a?.key || "";
|
|
37
|
+
return await (await fetch((i ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(n)}&subscriptionId=${s}&apiKey=${c}&baseUrl=${o}`, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
body: JSON.stringify(t),
|
|
40
|
+
headers: {
|
|
41
|
+
"Content-Type": "application/json",
|
|
42
|
+
...r
|
|
43
|
+
}
|
|
44
|
+
})).json();
|
|
45
|
+
}, p = async (e, t, n = {}) => {
|
|
46
|
+
let { baseUrl: r, om: i } = e.serverOptions ?? {}, a = encodeURIComponent(i?.endpointUrl || ""), o = encodeURIComponent(i?.subscriptionId || ""), s = i?.key || "";
|
|
47
|
+
return await (await fetch((r ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(t)}&subscriptionId=${o}&apiKey=${s}&baseUrl=${a}`, {
|
|
48
|
+
method: "GET",
|
|
49
|
+
headers: {
|
|
50
|
+
"Content-Type": "application/json",
|
|
51
|
+
...n
|
|
52
|
+
}
|
|
53
|
+
})).json();
|
|
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) => {
|
|
60
|
+
if (n.data.type === "connect_hi" && n.data.port) {
|
|
61
|
+
let r = n.data.port;
|
|
62
|
+
((t, n) => {
|
|
63
|
+
t.serverOptions ||= {}, !t.serverOptions.language && n?.locale && (t.serverOptions.language = n.locale), t.serverOptions.language || (t.serverOptions.language = e(null, !0));
|
|
64
|
+
})(a, n.data.globalInitData || {}), r.start?.(), o(t(i), r);
|
|
65
|
+
}
|
|
66
|
+
}, window.addEventListener("message", m);
|
|
67
|
+
}, g = () => {
|
|
68
|
+
m &&= (window.removeEventListener("message", m), null);
|
|
69
|
+
}, _ = async (e) => (await import("./hi-mcp-server-ukmMIPNu.mjs")).createHiMcpTools(e), v = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, y = async ({ provider: e, model: t, apiKey: n, baseUrl: r, chatCompletions: i, reasoningEffort: a }) => {
|
|
70
|
+
switch (e) {
|
|
71
|
+
case "azure": {
|
|
72
|
+
let { createAzure: e } = await import(v("@ai-sdk/azure@4.0.85")), o = e({
|
|
73
|
+
apiKey: n,
|
|
74
|
+
baseURL: r
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
languageModel: i ? o.chat(t) : o(t),
|
|
78
|
+
providerOptions: a ? { azure: { reasoningEffort: a } } : void 0
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
case "mistral": {
|
|
82
|
+
let { createMistral: e } = await import(v("@ai-sdk/mistral@4.0.54"));
|
|
83
|
+
return { languageModel: e({ apiKey: n })(t) };
|
|
84
|
+
}
|
|
85
|
+
case "anthropic": {
|
|
86
|
+
let { createAnthropic: e } = await import(v("@ai-sdk/anthropic@4.0.68"));
|
|
87
|
+
return { languageModel: e({
|
|
88
|
+
apiKey: n,
|
|
89
|
+
headers: { "anthropic-dangerous-direct-browser-access": "true" }
|
|
90
|
+
})(t) };
|
|
91
|
+
}
|
|
92
|
+
case "google": {
|
|
93
|
+
let { createGoogleGenerativeAI: e } = await import(v("@ai-sdk/google@4.0.85"));
|
|
94
|
+
return { languageModel: e({ apiKey: n })(t) };
|
|
95
|
+
}
|
|
96
|
+
default: throw Error(`Unknown provider "${e}" - supported: azure, mistral, anthropic, google`);
|
|
97
|
+
}
|
|
98
|
+
}, b = async (e, t, n) => {
|
|
99
|
+
let r = e.extended, i = (e) => r.planningAssistantOutput(e), a;
|
|
100
|
+
try {
|
|
101
|
+
a = await Promise.all([
|
|
102
|
+
import(v("ai@7.0.122")),
|
|
103
|
+
y(t),
|
|
104
|
+
r.getExternalObjectAgentPrompts(),
|
|
105
|
+
_(e)
|
|
106
|
+
]);
|
|
107
|
+
} catch (e) {
|
|
108
|
+
i({
|
|
109
|
+
type: "availability",
|
|
110
|
+
available: !1,
|
|
111
|
+
text: String(e)
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
let [{ streamText: o, stepCountIs: s }, c, l, u] = a, d = [];
|
|
116
|
+
r.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: t }) => {
|
|
117
|
+
let r = {
|
|
118
|
+
role: "user",
|
|
119
|
+
content: [{
|
|
120
|
+
type: "text",
|
|
121
|
+
text: e || l.imagePrompt
|
|
122
|
+
}, ...t.map((e) => ({
|
|
123
|
+
type: "file",
|
|
124
|
+
data: e,
|
|
125
|
+
mediaType: "image/jpeg"
|
|
126
|
+
}))]
|
|
127
|
+
};
|
|
128
|
+
try {
|
|
129
|
+
let e = o({
|
|
130
|
+
model: c.languageModel,
|
|
131
|
+
providerOptions: c.providerOptions,
|
|
132
|
+
instructions: l.systemPrompt,
|
|
133
|
+
messages: [...d, r],
|
|
134
|
+
tools: u,
|
|
135
|
+
stopWhen: s(16),
|
|
136
|
+
abortSignal: n,
|
|
137
|
+
prepareStep: ({ stepNumber: e }) => e === 15 ? { toolChoice: "none" } : void 0
|
|
138
|
+
});
|
|
139
|
+
for await (let t of e.stream) if (t.type === "text-delta") i({
|
|
140
|
+
type: "text",
|
|
141
|
+
text: t.text
|
|
142
|
+
});
|
|
143
|
+
else if (t.type === "tool-call") i({
|
|
144
|
+
type: "activity",
|
|
145
|
+
text: t.toolName
|
|
146
|
+
});
|
|
147
|
+
else if (t.type === "error") throw t.error;
|
|
148
|
+
d.push(r, ...await e.responseMessages), i({ type: "done" });
|
|
149
|
+
} catch (e) {
|
|
150
|
+
i({
|
|
151
|
+
type: "error",
|
|
152
|
+
text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}, i({
|
|
156
|
+
type: "images",
|
|
157
|
+
enabled: t.readsImages
|
|
158
|
+
}), i({
|
|
159
|
+
type: "availability",
|
|
160
|
+
available: !0
|
|
161
|
+
});
|
|
162
|
+
}, x = {
|
|
163
|
+
HIDE: "hide",
|
|
164
|
+
SHOW_ATTRIBUTES: "attributes",
|
|
165
|
+
SHOW_ARTICLES: "articles"
|
|
166
|
+
};
|
|
167
|
+
export { x as HI_PANEL_ACTION, g as cleanupHi, d as createHiLibraryCallbacks, _ as createHiMcpTools, c as libLoadArticleCatalog, u as libLoadCalcScript, l as libLoadMasterData, y as loadChatModel, p as omGetRequest, f as omPostRequest, a as registerLegacyUrlFormat, h as setupHi, b as startPlanningAssistant, o as unregisterLegacyUrlFormat };
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@roomle/embedding-lib",
|
|
3
|
+
"version": "0.0.0-dev-a4754cb",
|
|
4
|
+
"description": "This is a small library which can be used to communicate with the Roomle Configurator. ES modules only (browser-compatible).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./roomle-embedding-lib.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"./"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./roomle-embedding-lib.js",
|
|
14
|
+
"types": "./index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./min": {
|
|
17
|
+
"import": "./roomle-embedding-lib.min.js"
|
|
18
|
+
},
|
|
19
|
+
"./hi": {
|
|
20
|
+
"import": "./hi.js",
|
|
21
|
+
"types": "./hi.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./hi/min": {
|
|
24
|
+
"import": "./hi.min.js"
|
|
25
|
+
},
|
|
26
|
+
"./plugins": {
|
|
27
|
+
"import": "./embedding-plugins.js",
|
|
28
|
+
"types": "./embedding-plugins.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./plugins/min": {
|
|
31
|
+
"import": "./embedding-plugins.min.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"release": "semantic-release"
|
|
36
|
+
},
|
|
37
|
+
"volta": {
|
|
38
|
+
"node": "18.18.0",
|
|
39
|
+
"npm": "8.3.1"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/roomle-build/npm-packages.git"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public",
|
|
47
|
+
"provenance": false
|
|
48
|
+
},
|
|
49
|
+
"license": "MIT"
|
|
50
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RapiCallbacks, Nullable } from '../../common/src/utils/types';
|
|
2
|
+
import { ExposedAnalyticsCallbacks } from '../../../src/configurator/embedding/exposed-analytics-callbacks';
|
|
3
|
+
import { ExposedApi } from '../../../src/configurator/embedding/exposed-api';
|
|
4
|
+
import { GlobalCallback, RoomleConfigurator } from '../../web-sdk/packages';
|
|
5
|
+
import { EmbeddingCommand, MessageHandler } from '../../common/src/utils/message-handler';
|
|
6
|
+
import { AvailablePlugins, PluginDefinitions } from './roomle-embedding-lib';
|
|
7
|
+
import { EmbeddingPluginMode } from './plugins/types';
|
|
8
|
+
import { PossibleCustomViewsAndMain } from '../../../src/configurator/embedding/custom-views';
|
|
9
|
+
export interface RoomleEmbeddingApiKeys {
|
|
10
|
+
extended: any;
|
|
11
|
+
configurator: any;
|
|
12
|
+
ui: any;
|
|
13
|
+
analytics: any;
|
|
14
|
+
global: any;
|
|
15
|
+
rapi: any;
|
|
16
|
+
}
|
|
17
|
+
export declare class Connector<SdkType, SdkCallbacks> implements RoomleEmbeddingApiKeys {
|
|
18
|
+
protected _messageHandler: Nullable<MessageHandler>;
|
|
19
|
+
isSetupDone: boolean;
|
|
20
|
+
viewName: PossibleCustomViewsAndMain;
|
|
21
|
+
plugins: AvailablePlugins;
|
|
22
|
+
pluginsLoaded: Array<Promise<void>>;
|
|
23
|
+
ui: ExposedApi;
|
|
24
|
+
extended: SdkType;
|
|
25
|
+
configurator: RoomleConfigurator;
|
|
26
|
+
analytics: {
|
|
27
|
+
callbacks: ExposedAnalyticsCallbacks;
|
|
28
|
+
};
|
|
29
|
+
rapi: {
|
|
30
|
+
callbacks: RapiCallbacks;
|
|
31
|
+
};
|
|
32
|
+
global: {
|
|
33
|
+
callbacks: GlobalCallback;
|
|
34
|
+
};
|
|
35
|
+
setMessageHandler(messageHandler: MessageHandler): void;
|
|
36
|
+
handleSetup(methodsAndCallbacks: {
|
|
37
|
+
methods: string[];
|
|
38
|
+
callbacks: string[];
|
|
39
|
+
}): void;
|
|
40
|
+
executeMessage({ message, args }: EmbeddingCommand): Promise<{
|
|
41
|
+
result: any;
|
|
42
|
+
}>;
|
|
43
|
+
setupPlugins(plugins: PluginDefinitions, iframe: HTMLIFrameElement | HTMLBodyElement, mode?: EmbeddingPluginMode): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DragInOptions } from './plugins/types';
|
|
2
|
+
export { TARGET_OPACITY, RML_DRAG_IN_STYLES_ID, RML_DRAG_GHOST_FADE_IN_ANIMATION_CSS, RML_DRAG_GHOST_FADE_OUT_ANIMATION_CSS, RML_DRAG_IN_DRAG_ELEMENT_ID, RML_DRAG_IN_FALLBACK_GHOST_URL, RML_DRAG_IN_FALLBACK_GHOST_WIDTH, RML_DRAG_IN_FALLBACK_GHOST_HEIGHT, RML_DRAG_GHOST_FADE_IN, RML_DRAG_GHOST_FADE_OUT, } from './plugins/constants';
|
|
3
|
+
export type { DragGhostOptions, DragInOptions } from './plugins/types';
|
|
4
|
+
export type OnBeforeUpdateDragGhost = (x: number, y: number, options: DragInOptions) => {
|
|
5
|
+
x?: number;
|
|
6
|
+
y?: number;
|
|
7
|
+
options?: Partial<DragInOptions>;
|
|
8
|
+
};
|
|
9
|
+
export { DragIn } from './plugins/drag-in';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Homag Intelligence exports for roomle/embedding-lib
|
|
3
|
+
*
|
|
4
|
+
* These exports are separated into their own entry point to keep the main
|
|
5
|
+
* embedding library bundle size small. Only import from this module if you
|
|
6
|
+
* need Homag Intelligence functionality.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createHiLibraryCallbacks, libLoadArticleCatalog } from '@roomle/embedding-lib/hi';
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export { createHiLibraryCallbacks } from './homag-intelligence/hi-callbacks';
|
|
14
|
+
export { libLoadArticleCatalog, libLoadMasterData, libLoadCalcScript, registerLegacyUrlFormat, unregisterLegacyUrlFormat, } from './homag-intelligence/hi-requests';
|
|
15
|
+
export { omPostRequest, omGetRequest, } from './homag-intelligence/hi-order-manager';
|
|
16
|
+
export { setupHi, cleanupHi } from './homag-intelligence/hi-setup';
|
|
17
|
+
export { createHiMcpTools } from './homag-intelligence/hi-mcp-tools';
|
|
18
|
+
export type { HiMcpTool, HiMcpTools, } from './homag-intelligence/hi-mcp/mcp-tool';
|
|
19
|
+
export type { HiMcpPlannerApi } from './homag-intelligence/hi-mcp/planner-api';
|
|
20
|
+
export { loadChatModel, startPlanningAssistant, type PlanningAssistantConfig, type PlanningAssistantPlannerApi, } from './homag-intelligence/hi-planning-assistant';
|
|
21
|
+
export { type ExternalObjectSnapshotSaveResult, type HiContextAction, } from '../../web-sdk/packages';
|
|
22
|
+
export { HI_PANEL_ACTION, type HiPanelActionType, type HiOrderHeader, type HiOrder, type HiOrderData, type HiPriceData, type HiCallbacks, } from '../../common/src/hi/hi-types';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type WallSide = 'left' | 'right' | 'top' | 'bottom';
|
|
2
|
+
interface DerivedWall {
|
|
3
|
+
index: number;
|
|
4
|
+
side: WallSide;
|
|
5
|
+
start: [number, number, number];
|
|
6
|
+
end: [number, number, number];
|
|
7
|
+
lengthMm: number;
|
|
8
|
+
type?: string;
|
|
9
|
+
thicknessMm?: number;
|
|
10
|
+
facingRotationY: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const wallName: (side: WallSide) => string;
|
|
13
|
+
export interface RoomCorner {
|
|
14
|
+
name: string;
|
|
15
|
+
point: [number, number, number];
|
|
16
|
+
posRotationY: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const roomCorners: (walls: DerivedWall[]) => RoomCorner[];
|
|
19
|
+
export declare const spanAlongWall: (wall: DerivedWall, points: [number, number][]) => [number, number];
|
|
20
|
+
export interface WallOfOpening {
|
|
21
|
+
roomIndex: number;
|
|
22
|
+
wall: number;
|
|
23
|
+
fromEndMm: [number, number];
|
|
24
|
+
}
|
|
25
|
+
export declare const wallOfOpening: (outline: [number, number][], rooms: {
|
|
26
|
+
walls?: DerivedWall[];
|
|
27
|
+
}[]) => WallOfOpening | undefined;
|
|
28
|
+
export declare const withSharedSelectionsOnce: (attributes: any[]) => any[];
|
|
29
|
+
export declare const agentFacingAttributes: (masterData: any) => {
|
|
30
|
+
[k: string]: any[];
|
|
31
|
+
};
|
|
32
|
+
export declare const agentFacingArticle: (article: any) => any;
|
|
33
|
+
export declare const agentFacingRooms: (rooms: any) => any;
|
|
34
|
+
export declare const agentFacingObstacles: (obstacles: any, rooms: any) => any;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** The result of a tool as an MCP server answers `tools/call`. */
|
|
3
|
+
export interface McpToolResult {
|
|
4
|
+
content: ({
|
|
5
|
+
type: 'text';
|
|
6
|
+
text: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'image';
|
|
9
|
+
data: string;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
})[];
|
|
12
|
+
isError?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** What the model gets of a tool result, as `@ai-sdk/mcp` hands it to the AI SDK. */
|
|
15
|
+
export interface HiMcpModelOutput {
|
|
16
|
+
type: 'content';
|
|
17
|
+
value: ({
|
|
18
|
+
type: 'text';
|
|
19
|
+
text: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'file';
|
|
22
|
+
mediaType: string;
|
|
23
|
+
data: {
|
|
24
|
+
type: 'data';
|
|
25
|
+
data: string;
|
|
26
|
+
};
|
|
27
|
+
})[];
|
|
28
|
+
}
|
|
29
|
+
/** The input schema of a tool as a Standard Schema with its JSON Schema. */
|
|
30
|
+
export interface HiMcpInputSchema {
|
|
31
|
+
'~standard': {
|
|
32
|
+
version: 1;
|
|
33
|
+
vendor: string;
|
|
34
|
+
validate: (value: unknown) => {
|
|
35
|
+
value: unknown;
|
|
36
|
+
};
|
|
37
|
+
jsonSchema: {
|
|
38
|
+
input: (options: {
|
|
39
|
+
target: string;
|
|
40
|
+
}) => Record<string, unknown>;
|
|
41
|
+
output: (options: {
|
|
42
|
+
target: string;
|
|
43
|
+
}) => Record<string, unknown>;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** A tool of the HI MCP tool set, in the shape of an AI SDK dynamic tool. */
|
|
48
|
+
export interface HiMcpTool {
|
|
49
|
+
type: 'dynamic';
|
|
50
|
+
description: string;
|
|
51
|
+
inputSchema: HiMcpInputSchema;
|
|
52
|
+
execute: (input: unknown) => Promise<McpToolResult>;
|
|
53
|
+
toModelOutput: (options: {
|
|
54
|
+
output: McpToolResult;
|
|
55
|
+
}) => HiMcpModelOutput;
|
|
56
|
+
}
|
|
57
|
+
/** The HI MCP tools by name, the tool set an AI SDK `streamText` takes. */
|
|
58
|
+
export type HiMcpTools = Record<string, HiMcpTool>;
|
|
59
|
+
/** The tool result as `@ai-sdk/mcp` passes it to the model: text parts and images as file parts. */
|
|
60
|
+
export declare const mcpToModelOutput: ({ output, }: {
|
|
61
|
+
output: McpToolResult;
|
|
62
|
+
}) => HiMcpModelOutput;
|
|
63
|
+
/**
|
|
64
|
+
* A tool as an MCP server registers it and an MCP client hands it to the AI
|
|
65
|
+
* SDK: the JSON Schema the MCP SDK serves, which the AI SDK does not validate;
|
|
66
|
+
* the input validated here, an invalid input and a thrown error answered as
|
|
67
|
+
* MCP error results, which the model reads like any other result.
|
|
68
|
+
*/
|
|
69
|
+
export declare const mcpTool: (name: string, description: string, shape: z.ZodRawShape, handler: (args: any) => Promise<McpToolResult>) => HiMcpTool;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** A tool call that changed the plan, as the undo tool reverts it. */
|
|
2
|
+
export interface ToolCallRecord {
|
|
3
|
+
tool: string;
|
|
4
|
+
/** The planner steps the call put on the planner's undo history. */
|
|
5
|
+
steps: number;
|
|
6
|
+
/** The plan's groups before and after the call, as comparison keys. */
|
|
7
|
+
groupsBefore: string;
|
|
8
|
+
groupsAfter: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class PlanHistory {
|
|
11
|
+
private _events;
|
|
12
|
+
private _inFlight;
|
|
13
|
+
private _done;
|
|
14
|
+
private _undone;
|
|
15
|
+
private _changedInPlanner;
|
|
16
|
+
private _waiters;
|
|
17
|
+
get events(): number;
|
|
18
|
+
get changedInPlanner(): boolean;
|
|
19
|
+
historyChanged(): void;
|
|
20
|
+
/** Resolves true once `count` events have arrived, false after the timeout. */
|
|
21
|
+
waitForEvents(count: number, timeoutMs: number): Promise<boolean>;
|
|
22
|
+
begin(): void;
|
|
23
|
+
end(): void;
|
|
24
|
+
/** A new change on top of the history ends redo, as in the planner. */
|
|
25
|
+
record(call: ToolCallRecord): void;
|
|
26
|
+
lastDone(): ToolCallRecord | undefined;
|
|
27
|
+
lastUndone(): ToolCallRecord | undefined;
|
|
28
|
+
markUndone(): void;
|
|
29
|
+
markRedone(): void;
|
|
30
|
+
forget(): void;
|
|
31
|
+
/** A change in the planner was found: no record can be trusted any more. */
|
|
32
|
+
markChangedInPlanner(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const DEFAULT_CALL_TIMEOUT_MS = 30000;
|
|
2
|
+
export declare const SNAPSHOT_CALL_TIMEOUT_MS = 120000;
|
|
3
|
+
export interface PlannerApi {
|
|
4
|
+
extended: {
|
|
5
|
+
getExternalObjectPlanContext(include: string[], options?: {
|
|
6
|
+
interiorDesign: {
|
|
7
|
+
groupId: string;
|
|
8
|
+
rootId?: string;
|
|
9
|
+
containerModuleId?: string;
|
|
10
|
+
articleId?: string;
|
|
11
|
+
};
|
|
12
|
+
}): Promise<any>;
|
|
13
|
+
externalObjectGroupOperation(command: string, payload: Record<string, unknown>): Promise<any>;
|
|
14
|
+
fetchPrice(): Promise<any>;
|
|
15
|
+
getExternalObjectSnapshot(options: Record<string, boolean>): Promise<any>;
|
|
16
|
+
undo(): Promise<void>;
|
|
17
|
+
redo(): Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The planner API a host hands to the HI MCP tools: the six planner methods
|
|
22
|
+
* the tools call, and the planner's callbacks, whose `onHistoryChange` the
|
|
23
|
+
* tools chain to tell their own planner steps from the user's changes.
|
|
24
|
+
*/
|
|
25
|
+
export type HiMcpPlannerApi = PlannerApi & {
|
|
26
|
+
extended: {
|
|
27
|
+
callbacks: {
|
|
28
|
+
onHistoryChange?: (undo: boolean, redo: boolean) => void;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare const createPlannerApi: ({ extended }: PlannerApi) => PlannerApi;
|