@roomle/embedding-lib 0.0.0-dev-a40887e → 0.0.0-dev-9d077e2

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.
Files changed (30) hide show
  1. package/configurator.d.ts +2 -0
  2. package/configurator.js +119 -0
  3. package/configurator.min.js +117 -0
  4. package/hi.js +40 -138
  5. package/hi.min.js +39 -122
  6. package/package.json +8 -1
  7. package/packages/embedding-lib/src/configurator-agent/chat-recovery.d.ts +9 -0
  8. package/packages/embedding-lib/src/configurator-agent/configurator-mcp-tools.d.ts +11 -0
  9. package/packages/embedding-lib/src/configurator-agent/configurator-planning-assistant.d.ts +8 -0
  10. package/packages/embedding-lib/src/configurator.d.ts +3 -0
  11. package/packages/embedding-lib/src/hi.d.ts +1 -3
  12. package/packages/embedding-lib/src/homag-intelligence/hi-mcp-tools.d.ts +11 -11
  13. package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +5 -41
  14. package/packages/embedding-lib/src/planning-assistant/chat-model.d.ts +33 -0
  15. package/packages/embedding-lib/src/{homag-intelligence/hi-mcp/mcp-tool.d.ts → planning-assistant/mcp-tools.d.ts} +10 -27
  16. package/packages/embedding-lib/src/planning-assistant/planning-assistant.d.ts +23 -0
  17. package/planning-assistant-BW9fNGZO.mjs +158 -0
  18. package/planning-assistant-CyVA2uUX.mjs +143 -0
  19. package/roomle-embedding-lib.js +64 -55
  20. package/roomle-embedding-lib.min.js +9 -0
  21. package/hi-mcp-server-B4BAKDmw.mjs +0 -5288
  22. package/hi-mcp-server-DxIvpJmq.mjs +0 -4879
  23. package/packages/embedding-lib/src/homag-intelligence/hi-mcp/agent-facing.d.ts +0 -35
  24. package/packages/embedding-lib/src/homag-intelligence/hi-mcp/hi-mcp-server.d.ts +0 -3
  25. package/packages/embedding-lib/src/homag-intelligence/hi-mcp/plan-history.d.ts +0 -33
  26. package/packages/embedding-lib/src/homag-intelligence/hi-mcp/planner-api.d.ts +0 -32
  27. package/packages/embedding-lib/src/homag-intelligence/hi-mcp/skills.d.ts +0 -23
  28. package/packages/embedding-lib/src/homag-intelligence/hi-mcp/tool-executors.d.ts +0 -4
  29. /package/{comlink-B2Kj_5Ge.mjs → comlink-BJnhpJa4.mjs} +0 -0
  30. /package/{comlink-B5lV2OWp.mjs → comlink-lSsogKgb.mjs} +0 -0
@@ -0,0 +1,2 @@
1
+ export * from './packages/embedding-lib/src/configurator'
2
+ export {}
@@ -0,0 +1,119 @@
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 };
@@ -0,0 +1,117 @@
1
+ import { n as e, r as t, t as n } from "./planning-assistant-CyVA2uUX.mjs";
2
+ var r = async (e) => {
3
+ if (typeof e.getConfiguratorAgentTools != "function" || typeof e.callConfiguratorAgentTool != "function") throw Error("Update the Rubens UI: configurator agent tools are unavailable.");
4
+ return t(await e.getConfiguratorAgentTools(), (t, n) => e.callConfiguratorAgentTool(t, n), "configurator-mcp");
5
+ }, i = {
6
+ undo: "Undo",
7
+ redo: "Redo",
8
+ "change-component-parameter": "Component parameter change",
9
+ "change-global-parameter": "Global parameter change",
10
+ "dock-component": "Component dock",
11
+ "drag-component": "Component drag",
12
+ "delete-component": "Component deletion",
13
+ "load-configuration": "Configuration load",
14
+ "get-configurator-capabilities": "Capabilities read",
15
+ "get-configuration": "Configuration read",
16
+ "get-component-parameters": "Component parameters read",
17
+ "get-global-parameters": "Global parameters read",
18
+ "get-possible-children": "Possible children read",
19
+ "get-docking-positions": "Docking positions read",
20
+ "get-component-docking-positions": "Component docking positions read",
21
+ "get-delete-impact": "Delete impact read"
22
+ }, a = new Set([
23
+ "get-configurator-capabilities",
24
+ "get-configuration",
25
+ "get-component-parameters",
26
+ "get-global-parameters",
27
+ "get-possible-children",
28
+ "get-docking-positions",
29
+ "get-component-docking-positions",
30
+ "get-delete-impact"
31
+ ]), o = (e) => {
32
+ if (e instanceof Error) return e.message;
33
+ try {
34
+ return typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
35
+ } catch {
36
+ return Object.prototype.toString.call(e);
37
+ }
38
+ }, s = (e) => {
39
+ if (e?.structuredContent !== void 0) return e.structuredContent;
40
+ let t = e?.content?.filter((e) => e.type === "text").map((e) => e.text).join("\n");
41
+ if (t === void 0) return e;
42
+ try {
43
+ return JSON.parse(t);
44
+ } catch {
45
+ return t;
46
+ }
47
+ }, c = (e) => {
48
+ if (!e || typeof e != "object") return e == null ? [] : [o(e)];
49
+ let t = [];
50
+ for (let n of [
51
+ "undone",
52
+ "redone",
53
+ "confirmed",
54
+ "canUndo",
55
+ "canRedo"
56
+ ]) e[n] !== void 0 && t.push(`${n}: ${o(e[n])}`);
57
+ return e.hint && t.push(o(e.hint)), t;
58
+ }, l = (e) => {
59
+ let t = [];
60
+ return {
61
+ tools: Object.fromEntries(Object.entries(e).map(([e, n]) => {
62
+ if (!n.execute) return [e, n];
63
+ let r = n.execute.bind(n);
64
+ return [e, {
65
+ ...n,
66
+ execute: async (n) => {
67
+ let i = {
68
+ toolName: e,
69
+ status: "pending"
70
+ };
71
+ t.push(i);
72
+ try {
73
+ let e = await r(n);
74
+ return i.result = e, i.status = "returned", e;
75
+ } catch (e) {
76
+ throw i.error = e, i.status = "threw", e;
77
+ }
78
+ }
79
+ }];
80
+ })),
81
+ summary: () => {
82
+ let e = ["The assistant's reply was interrupted. Any text above is incomplete."];
83
+ if (!t.length) return e.push("No tool ran, so the configuration was not changed."), e.join("\n\n");
84
+ for (let n of t) {
85
+ let t = i[n.toolName] ?? n.toolName;
86
+ if (a.has(n.toolName)) {
87
+ let r = n.status === "returned" && !n.result?.isError, i = r ? s(n.result) : void 0;
88
+ e.push(r ? `- Completed ${t}: ${!1 === i?.complete ? "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.`);
89
+ continue;
90
+ }
91
+ if (n.status !== "returned" || n.result?.isError) {
92
+ let r = n.status === "threw" ? o(n.error) : n.status === "returned" ? o(s(n.result)) : "no result was received";
93
+ e.push(`- Unconfirmed ${t}: ${r}. Check the configuration before trying this operation again.`);
94
+ } else {
95
+ let r = s(n.result);
96
+ if (!1 === r?.confirmed) {
97
+ e.push(`- Unconfirmed ${t}: ${r?.hint ?? "the configurator did not report the change"}. Check the configuration before trying this operation again.`);
98
+ continue;
99
+ }
100
+ let i = c(r);
101
+ e.push(`- Completed ${t}: ${i.length ? i.join("; ") : "the tool returned successfully."}`);
102
+ }
103
+ }
104
+ return e.push("These are the recorded tool outcomes; no operation was repeated automatically."), e.join("\n\n");
105
+ }
106
+ };
107
+ }, u = (e, t, i) => n(e.window, t, i, async () => {
108
+ let [t, n] = await Promise.all([e.configurator.getConfiguratorAgentPrompts(), r(e.configurator)]);
109
+ return {
110
+ prompts: t,
111
+ tools: n
112
+ };
113
+ }, {
114
+ timeoutMs: 3e5,
115
+ recovery: l
116
+ });
117
+ export { r as createConfiguratorMcpTools, e as loadChatModel, u as startConfiguratorPlanningAssistant };
package/hi.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { t as e } from "./browser-CW9o-dtT.mjs";
2
2
  import { t } from "./utils-DxJ3PcKe.mjs";
3
- var n = (e, t) => t === e.libraryId ? e : {
3
+ import { n, r, t as i } from "./planning-assistant-BW9fNGZO.mjs";
4
+ var a = (e, t) => t === e.libraryId ? e : {
4
5
  ...e,
5
6
  libraryId: t
6
- }, r = async (e, t, n, r = { property: "default" }) => {
7
+ }, o = async (e, t, n, r = { property: "default" }) => {
7
8
  let i = n.serverOptions ?? {}, a = { headers: {
8
9
  "Content-Type": t === "json" ? "application/json" : "text/plain",
9
10
  "Access-Control-Allow-Origin": "*"
@@ -16,22 +17,22 @@ var n = (e, t) => t === e.libraryId ? e : {
16
17
  } catch (e) {
17
18
  throw console.warn(`Failed to fetch data from ${r.property}`), console.error(e), e;
18
19
  }
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) => {
20
+ }, s = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": new Set(["Furniture_Smith"]) }, c = (e, t) => {
21
+ s[e] || (s[e] = /* @__PURE__ */ new Set()), s[e].add(t);
22
+ }, l = (e, t) => {
23
+ s[e]?.delete(t), s[e]?.size === 0 && delete s[e];
24
+ }, u = (e, t) => {
24
25
  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();
26
+ return r?.subscriptionId && s[r.subscriptionId]?.has(n) ? `api/pos/${t}?libraryId=${n}` : `api/pos/libraries/${n}/${t}`;
27
+ }, d = async (e) => await (await o(u(e, "articles"), "json", e, { property: "articles" })).json(), f = async (e) => await (await o(u(e, "masterData"), "json", e, { property: "masterData" })).json(), p = async (e) => {
28
+ let t = await (await o(u(e, "calc.js"), "text", e, { property: "calc.js" })).text();
28
29
  if (!t) throw Error("Script load error");
29
30
  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 = {}) => {
31
+ }, m = (e) => ({
32
+ onLoadJavascript: (t) => p(a(e, t)),
33
+ onLoadArticleCatalog: (t) => d(a(e, t)),
34
+ onLoadMasterData: (t) => f(a(e, t))
35
+ }), h = async (e, t, n, r = {}) => {
35
36
  let { baseUrl: i, om: a } = e.serverOptions ?? {}, o = encodeURIComponent(a?.endpointUrl || ""), s = encodeURIComponent(a?.subscriptionId || ""), c = a?.key || "";
36
37
  return await (await fetch((i ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(n)}&subscriptionId=${s}&apiKey=${c}&baseUrl=${o}`, {
37
38
  method: "POST",
@@ -41,7 +42,7 @@ var n = (e, t) => t === e.libraryId ? e : {
41
42
  ...r
42
43
  }
43
44
  })).json();
44
- }, p = async (e, t, n = {}) => {
45
+ }, g = async (e, t, n = {}) => {
45
46
  let { baseUrl: r, om: i } = e.serverOptions ?? {}, a = encodeURIComponent(i?.endpointUrl || ""), o = encodeURIComponent(i?.subscriptionId || ""), s = i?.key || "";
46
47
  return await (await fetch((r ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(t)}&subscriptionId=${o}&apiKey=${s}&baseUrl=${a}`, {
47
48
  method: "GET",
@@ -50,133 +51,34 @@ var n = (e, t) => t === e.libraryId ? e : {
50
51
  ...n
51
52
  }
52
53
  })).json();
53
- }, m = (t, n) => {
54
+ }, _ = (t, n) => {
54
55
  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) => {
56
+ }, v = null, y = async (e, n = {}) => {
57
+ v && window.removeEventListener("message", v);
58
+ let r = typeof e == "string" ? { libraryId: e } : e;
59
+ n.onLoadJavascript === void 0 && (n.onLoadJavascript = (e) => p(a(r, e))), n.onLoadArticleCatalog === void 0 && (n.onLoadArticleCatalog = (e) => d(a(r, e))), n.onLoadMasterData === void 0 && (n.onLoadMasterData = (e) => f(a(r, e)));
60
+ let { expose: i } = await import("./comlink-lSsogKgb.mjs");
61
+ v = (e) => {
61
62
  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);
63
+ let a = e.data.port;
64
+ _(r, e.data.globalInitData || {}), a.start?.(), i(t(n), a);
64
65
  }
65
- }, window.addEventListener("message", h);
66
- }, _ = () => {
67
- h &&= (window.removeEventListener("message", h), null);
68
- }, v = async (e) => (await import("./hi-mcp-server-B4BAKDmw.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 = {
66
+ }, window.addEventListener("message", v);
67
+ }, b = () => {
68
+ v &&= (window.removeEventListener("message", v), null);
69
+ }, x = async ({ extended: e }) => {
70
+ if (typeof e.getExternalObjectAgentTools != "function") throw Error("The planner has no HI agent tools: it needs a Rubens UI with getExternalObjectAgentTools.");
71
+ return r(await e.getExternalObjectAgentTools(), (t, n) => e.callExternalObjectAgentTool(t, n), "hi-mcp");
72
+ }, S = (e, t, n) => i(e.extended, t, n, async () => {
73
+ let [t, n] = await Promise.all([e.extended.getExternalObjectAgentPrompts(), x(e)]);
74
+ return {
75
+ prompts: t,
76
+ tools: n
77
+ };
78
+ }), C = {
177
79
  HIDE: "hide",
178
80
  SHOW_ATTRIBUTES: "attributes",
179
81
  SHOW_ARTICLES: "articles"
180
82
  };
181
83
  //#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 };
84
+ export { C as HI_PANEL_ACTION, b as cleanupHi, m as createHiLibraryCallbacks, x as createHiMcpTools, d as libLoadArticleCatalog, p as libLoadCalcScript, f as libLoadMasterData, n as loadChatModel, g as omGetRequest, h as omPostRequest, c as registerLegacyUrlFormat, y as setupHi, S as startPlanningAssistant, l as unregisterLegacyUrlFormat };
package/hi.min.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { t as e } from "./browser-BxG7yIaK.mjs";
2
2
  import { t } from "./utils-wJ80awOA.mjs";
3
- var n = (e, t) => t === e.libraryId ? e : {
3
+ import { n, r, t as i } from "./planning-assistant-CyVA2uUX.mjs";
4
+ var a = (e, t) => t === e.libraryId ? e : {
4
5
  ...e,
5
6
  libraryId: t
6
- }, r = async (e, t, n, r = { property: "default" }) => {
7
+ }, o = async (e, t, n, r = { property: "default" }) => {
7
8
  let i = n.serverOptions ?? {}, a = { headers: {
8
9
  "Content-Type": t === "json" ? "application/json" : "text/plain",
9
10
  "Access-Control-Allow-Origin": "*"
@@ -17,22 +18,22 @@ var n = (e, t) => t === e.libraryId ? e : {
17
18
  } catch (e) {
18
19
  throw e;
19
20
  }
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) => {
21
+ }, s = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": new Set(["Furniture_Smith"]) }, c = (e, t) => {
22
+ s[e] || (s[e] = /* @__PURE__ */ new Set()), s[e].add(t);
23
+ }, l = (e, t) => {
24
+ s[e]?.delete(t), s[e]?.size === 0 && delete s[e];
25
+ }, u = (e, t) => {
25
26
  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();
27
+ return r?.subscriptionId && s[r.subscriptionId]?.has(n) ? `api/pos/${t}?libraryId=${n}` : `api/pos/libraries/${n}/${t}`;
28
+ }, d = async (e) => await (await o(u(e, "articles"), "json", e, { property: "articles" })).json(), f = async (e) => await (await o(u(e, "masterData"), "json", e, { property: "masterData" })).json(), p = async (e) => {
29
+ let t = await (await o(u(e, "calc.js"), "text", e, { property: "calc.js" })).text();
29
30
  if (!t) throw Error("Script load error");
30
31
  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 = {}) => {
32
+ }, m = (e) => ({
33
+ onLoadJavascript: (t) => p(a(e, t)),
34
+ onLoadArticleCatalog: (t) => d(a(e, t)),
35
+ onLoadMasterData: (t) => f(a(e, t))
36
+ }), h = async (e, t, n, r = {}) => {
36
37
  let { baseUrl: i, om: a } = e.serverOptions ?? {}, o = encodeURIComponent(a?.endpointUrl || ""), s = encodeURIComponent(a?.subscriptionId || ""), c = a?.key || "";
37
38
  return await (await fetch((i ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(n)}&subscriptionId=${s}&apiKey=${c}&baseUrl=${o}`, {
38
39
  method: "POST",
@@ -42,7 +43,7 @@ var n = (e, t) => t === e.libraryId ? e : {
42
43
  ...r
43
44
  }
44
45
  })).json();
45
- }, p = async (e, t, n = {}) => {
46
+ }, g = async (e, t, n = {}) => {
46
47
  let { baseUrl: r, om: i } = e.serverOptions ?? {}, a = encodeURIComponent(i?.endpointUrl || ""), o = encodeURIComponent(i?.subscriptionId || ""), s = i?.key || "";
47
48
  return await (await fetch((r ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(t)}&subscriptionId=${o}&apiKey=${s}&baseUrl=${a}`, {
48
49
  method: "GET",
@@ -51,117 +52,33 @@ var n = (e, t) => t === e.libraryId ? e : {
51
52
  ...n
52
53
  }
53
54
  })).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) => {
55
+ }, _ = null, v = async (n, r = {}) => {
56
+ _ && window.removeEventListener("message", _);
57
+ let i = typeof n == "string" ? { libraryId: n } : n;
58
+ r.onLoadJavascript === void 0 && (r.onLoadJavascript = (e) => p(a(i, e))), r.onLoadArticleCatalog === void 0 && (r.onLoadArticleCatalog = (e) => d(a(i, e))), r.onLoadMasterData === void 0 && (r.onLoadMasterData = (e) => f(a(i, e)));
59
+ let { expose: o } = await import("./comlink-BJnhpJa4.mjs");
60
+ _ = (n) => {
60
61
  if (n.data.type === "connect_hi" && n.data.port) {
61
- let r = n.data.port;
62
+ let a = n.data.port;
62
63
  ((t, n) => {
63
64
  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
+ })(i, n.data.globalInitData || {}), a.start?.(), o(t(r), a);
65
66
  }
66
- }, window.addEventListener("message", m);
67
- }, g = () => {
68
- m &&= (window.removeEventListener("message", m), null);
69
- }, _ = async (e) => (await import("./hi-mcp-server-DxIvpJmq.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 = {
67
+ }, window.addEventListener("message", _);
68
+ }, y = () => {
69
+ _ &&= (window.removeEventListener("message", _), null);
70
+ }, b = async ({ extended: e }) => {
71
+ if (typeof e.getExternalObjectAgentTools != "function") throw Error("The planner has no HI agent tools: it needs a Rubens UI with getExternalObjectAgentTools.");
72
+ return r(await e.getExternalObjectAgentTools(), (t, n) => e.callExternalObjectAgentTool(t, n), "hi-mcp");
73
+ }, x = (e, t, n) => i(e.extended, t, n, async () => {
74
+ let [t, n] = await Promise.all([e.extended.getExternalObjectAgentPrompts(), b(e)]);
75
+ return {
76
+ prompts: t,
77
+ tools: n
78
+ };
79
+ }), S = {
163
80
  HIDE: "hide",
164
81
  SHOW_ATTRIBUTES: "attributes",
165
82
  SHOW_ARTICLES: "articles"
166
83
  };
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 };
84
+ export { S as HI_PANEL_ACTION, y as cleanupHi, m as createHiLibraryCallbacks, b as createHiMcpTools, d as libLoadArticleCatalog, p as libLoadCalcScript, f as libLoadMasterData, n as loadChatModel, g as omGetRequest, h as omPostRequest, c as registerLegacyUrlFormat, v as setupHi, x as startPlanningAssistant, l as unregisterLegacyUrlFormat };