@roomle/embedding-lib 0.0.0-dev-1bd05f2 → 0.0.0-dev-5f60635

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 (60) hide show
  1. package/THIRD-PARTY-NOTICES.txt +553 -1
  2. package/coerce-CqJod_GZ.mjs +8 -0
  3. package/coerce-CsI42_k0.mjs +6 -0
  4. package/configurator.d.ts +2 -0
  5. package/configurator.js +29 -0
  6. package/configurator.min.js +27 -0
  7. package/dist-5jYYtT4q.mjs +8216 -0
  8. package/dist-B9yy8ym8.mjs +5512 -0
  9. package/dist-BV-32IEX.mjs +8128 -0
  10. package/dist-Bb2L1Zel.mjs +6045 -0
  11. package/dist-Bo3WzRdf.mjs +6223 -0
  12. package/dist-Bt1FopV4.mjs +7594 -0
  13. package/dist-C5fKJXpB.mjs +5598 -0
  14. package/dist-COgAdYY1.mjs +7554 -0
  15. package/dist-CXemOs84.mjs +849 -0
  16. package/dist-CqP0aX0A.mjs +866 -0
  17. package/dist-CqpDM10w.mjs +1179 -0
  18. package/dist-D0kh4WfT.mjs +7721 -0
  19. package/dist-D5HdKuwj.mjs +1221 -0
  20. package/dist-DJtonrDM.mjs +16906 -0
  21. package/dist-GTk8ppiK.mjs +8380 -0
  22. package/dist-XEy6Tk_Y.mjs +17341 -0
  23. package/{drag-ghost-DRJqglR4.mjs → drag-ghost-D7FnWbO4.mjs} +1 -1
  24. package/{drag-ghost-DvNl926o.mjs → drag-ghost-yXe7c8jA.mjs} +1 -1
  25. package/{drag-in-O6toxxkY.mjs → drag-in-BiEe2Lgv.mjs} +14 -20
  26. package/{drag-in-D_heMFxk.mjs → drag-in-t7T6Pqwc.mjs} +9 -15
  27. package/embedding-plugins.js +1 -1
  28. package/embedding-plugins.min.js +1 -1
  29. package/experimental-evaluation-BgWFolud.mjs +1074 -0
  30. package/experimental-evaluation-D56MbtjO.mjs +970 -0
  31. package/{from-custom-view-CnUFpf6f.mjs → from-custom-view-CTBapIc6.mjs} +30 -30
  32. package/{from-custom-view-DsDwSZTY.mjs → from-custom-view-xbjgsLll.mjs} +31 -31
  33. package/{from-website-bTi4qNXt.mjs → from-website-DUPMQPl6.mjs} +23 -23
  34. package/{from-website-Csj57D58.mjs → from-website-JwG7Ic_U.mjs} +23 -23
  35. package/hi.js +128 -295
  36. package/hi.min.js +118 -261
  37. package/mcp-tools-CJ7j_FI2.mjs +151 -0
  38. package/mcp-tools-D__M74CZ.mjs +153 -0
  39. package/package.json +12 -1
  40. package/packages/embedding-lib/src/configurator-agent/configurator-mcp-tools.d.ts +4 -0
  41. package/packages/embedding-lib/src/configurator-agent/configurator-planning-assistant.d.ts +13 -0
  42. package/packages/embedding-lib/src/configurator.d.ts +3 -0
  43. package/packages/embedding-lib/src/homag-intelligence/hi-mcp-tools.d.ts +4 -61
  44. package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +2 -48
  45. package/packages/embedding-lib/src/planning-assistant/chat-model.d.ts +1 -0
  46. package/packages/embedding-lib/src/planning-assistant/mcp-tools.d.ts +2 -0
  47. package/packages/web-sdk/packages/assistant.d.ts +3 -0
  48. package/packages/web-sdk/packages/common-core/src/agent-tools/mcp-tool-types.d.ts +30 -0
  49. package/packages/web-sdk/packages/common-core/src/planning-assistant/chat-model.d.ts +8 -0
  50. package/packages/web-sdk/packages/common-core/src/planning-assistant/mcp-tools.d.ts +52 -0
  51. package/packages/web-sdk/packages/common-core/src/planning-assistant/types.d.ts +35 -0
  52. package/roomle-embedding-lib.js +2 -2
  53. package/roomle-embedding-lib.min.js +2 -2
  54. package/sbom.cdx.json +363 -5
  55. /package/{browser-BjtSrqbu.mjs → browser-D6As4Zxr.mjs} +0 -0
  56. /package/{browser-D6M-d6y5.mjs → browser-zrjtYpL8.mjs} +0 -0
  57. /package/{comlink-CR7SvKHo.mjs → comlink-Cmiqa2s0.mjs} +0 -0
  58. /package/{comlink-BwWPcVOp.mjs → comlink-Dc3LZUoi.mjs} +0 -0
  59. /package/{utils-BoELtcEK.mjs → utils-CAAGdgk8.mjs} +0 -0
  60. /package/{utils-BwWn6Fw4.mjs → utils-WeolMfC5.mjs} +0 -0
package/hi.min.js CHANGED
@@ -1,10 +1,11 @@
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 "./browser-BjtSrqbu.mjs";
3
- import { t } from "./utils-BoELtcEK.mjs";
4
- var n = (e, t) => t === e.libraryId ? e : {
2
+ import { t as e } from "./browser-D6As4Zxr.mjs";
3
+ import { t } from "./utils-CAAGdgk8.mjs";
4
+ import { n, t as r } from "./mcp-tools-CJ7j_FI2.mjs";
5
+ var i = (e, t) => t === e.libraryId ? e : {
5
6
  ...e,
6
7
  libraryId: t
7
- }, r = async (e, t, n, r = { property: "default" }) => {
8
+ }, a = async (e, t, n, r = { property: "default" }) => {
8
9
  let i = n.serverOptions ?? {}, a = { headers: {
9
10
  "Content-Type": t === "json" ? "application/json" : "text/plain",
10
11
  "Access-Control-Allow-Origin": "*"
@@ -18,22 +19,22 @@ var n = (e, t) => t === e.libraryId ? e : {
18
19
  } catch (e) {
19
20
  throw e;
20
21
  }
21
- }, i = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": new Set(["Furniture_Smith"]) }, a = (e, t) => {
22
- i[e] || (i[e] = /* @__PURE__ */ new Set()), i[e].add(t);
23
- }, o = (e, t) => {
24
- i[e]?.delete(t), i[e]?.size === 0 && delete i[e];
25
- }, s = (e, t) => {
22
+ }, o = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": new Set(["Furniture_Smith"]) }, s = (e, t) => {
23
+ o[e] || (o[e] = /* @__PURE__ */ new Set()), o[e].add(t);
24
+ }, c = (e, t) => {
25
+ o[e]?.delete(t), o[e]?.size === 0 && delete o[e];
26
+ }, l = (e, t) => {
26
27
  let { libraryId: n, serverOptions: r } = e;
27
- return r?.subscriptionId && i[r.subscriptionId]?.has(n) ? `api/pos/${t}?libraryId=${n}` : `api/pos/libraries/${n}/${t}`;
28
- }, 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) => {
29
- let t = await (await r(s(e, "calc.js"), "text", e, { property: "calc.js" })).text();
28
+ return r?.subscriptionId && o[r.subscriptionId]?.has(n) ? `api/pos/${t}?libraryId=${n}` : `api/pos/libraries/${n}/${t}`;
29
+ }, u = async (e) => await (await a(l(e, "articles"), "json", e, { property: "articles" })).json(), d = async (e) => await (await a(l(e, "masterData"), "json", e, { property: "masterData" })).json(), f = async (e) => {
30
+ let t = await (await a(l(e, "calc.js"), "text", e, { property: "calc.js" })).text();
30
31
  if (!t) throw Error("Script load error");
31
32
  return t;
32
- }, d = (e) => ({
33
- onLoadJavascript: (t) => u(n(e, t)),
34
- onLoadArticleCatalog: (t) => c(n(e, t)),
35
- onLoadMasterData: (t) => l(n(e, t))
36
- }), f = async (e, t, n, r = {}) => {
33
+ }, p = (e) => ({
34
+ onLoadJavascript: (t) => f(i(e, t)),
35
+ onLoadArticleCatalog: (t) => u(i(e, t)),
36
+ onLoadMasterData: (t) => d(i(e, t))
37
+ }), m = async (e, t, n, r = {}) => {
37
38
  let { baseUrl: i, om: a } = e.serverOptions ?? {}, o = encodeURIComponent(a?.endpointUrl || ""), s = encodeURIComponent(a?.subscriptionId || ""), c = a?.key || "";
38
39
  return await (await fetch((i ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(n)}&subscriptionId=${s}&apiKey=${c}&baseUrl=${o}`, {
39
40
  method: "POST",
@@ -43,7 +44,7 @@ var n = (e, t) => t === e.libraryId ? e : {
43
44
  ...r
44
45
  }
45
46
  })).json();
46
- }, p = async (e, t, n = {}) => {
47
+ }, h = async (e, t, n = {}) => {
47
48
  let { baseUrl: r, om: i } = e.serverOptions ?? {}, a = encodeURIComponent(i?.endpointUrl || ""), o = encodeURIComponent(i?.subscriptionId || ""), s = i?.key || "";
48
49
  return await (await fetch((r ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(t)}&subscriptionId=${o}&apiKey=${s}&baseUrl=${a}`, {
49
50
  method: "GET",
@@ -52,86 +53,49 @@ var n = (e, t) => t === e.libraryId ? e : {
52
53
  ...n
53
54
  }
54
55
  })).json();
55
- }, m = null, h = async (r, i = {}) => {
56
- m && window.removeEventListener("message", m);
57
- let a = typeof r == "string" ? { libraryId: r } : r;
58
- 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)));
59
- let { expose: o } = await import("./comlink-BwWPcVOp.mjs");
60
- m = (n) => {
56
+ }, g = null, _ = async (n, r = {}) => {
57
+ g && window.removeEventListener("message", g);
58
+ let a = typeof n == "string" ? { libraryId: n } : n;
59
+ r.onLoadJavascript === void 0 && (r.onLoadJavascript = (e) => f(i(a, e))), r.onLoadArticleCatalog === void 0 && (r.onLoadArticleCatalog = (e) => u(i(a, e))), r.onLoadMasterData === void 0 && (r.onLoadMasterData = (e) => d(i(a, e)));
60
+ let { expose: o } = await import("./comlink-Dc3LZUoi.mjs");
61
+ g = (n) => {
61
62
  if (n.data.type === "connect_hi" && n.data.port) {
62
- let r = n.data.port;
63
+ let i = n.data.port;
63
64
  ((t, n) => {
64
65
  t.serverOptions ||= {}, !t.serverOptions.language && n?.locale && (t.serverOptions.language = n.locale), t.serverOptions.language || (t.serverOptions.language = e(null, !0));
65
- })(a, n.data.globalInitData || {}), r.start?.(), o(t(i), r);
66
+ })(a, n.data.globalInitData || {}), i.start?.(), o(t(r), i);
66
67
  }
67
- }, window.addEventListener("message", m);
68
- }, g = () => {
69
- m &&= (window.removeEventListener("message", m), null);
70
- }, _ = ({ output: e }) => ({
71
- type: "content",
72
- value: e.content.map((e) => e.type === "text" ? {
73
- type: "text",
74
- text: e.text
75
- } : {
76
- type: "file",
77
- mediaType: e.mimeType,
78
- data: {
79
- type: "data",
80
- data: e.data
81
- }
82
- })
83
- }), v = async ({ extended: e }) => {
68
+ }, window.addEventListener("message", g);
69
+ }, v = () => {
70
+ g &&= (window.removeEventListener("message", g), null);
71
+ }, y = async ({ extended: e }) => {
84
72
  if (typeof e.getExternalObjectAgentTools != "function") throw Error("The planner has no HI agent tools: it needs a Rubens UI with getExternalObjectAgentTools.");
85
- let t = await e.getExternalObjectAgentTools();
86
- return Object.fromEntries(t.map(({ name: t, description: n, inputSchema: r }) => {
87
- let i = () => r;
88
- return [t, {
89
- type: "dynamic",
90
- description: n,
91
- inputSchema: { "~standard": {
92
- version: 1,
93
- vendor: "hi-mcp",
94
- validate: (e) => ({ value: e }),
95
- jsonSchema: {
96
- input: i,
97
- output: i
98
- }
99
- } },
100
- execute: (n) => e.callExternalObjectAgentTool(t, n).catch((e) => ({
101
- content: [{
102
- type: "text",
103
- text: e instanceof Error ? e.message : String(e)
104
- }],
105
- isError: !0
106
- })),
107
- toModelOutput: _
108
- }];
109
- }));
110
- }, y = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : null, b = (e = {}) => ({
111
- inputTokens: y(e.inputTokens),
112
- outputTokens: y(e.outputTokens),
113
- totalTokens: y(e.totalTokens) ?? (y(e.inputTokens) !== null && y(e.outputTokens) !== null ? e.inputTokens + e.outputTokens : null)
114
- }), x = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, S = (e = {}) => {
115
- let t = e.raw, n = t?.input_tokens_details ?? t?.prompt_tokens_details, r = t?.output_tokens_details ?? t?.completion_tokens_details, i = y(n?.cached_tokens ?? t?.cache_read_input_tokens), a = y(n?.cache_write_tokens ?? t?.cache_creation_input_tokens), o = (e, t) => t ?? (y(e) !== null && Number(e) > 0 ? Number(e) : null);
73
+ return r(await e.getExternalObjectAgentTools(), (t, n) => e.callExternalObjectAgentTool(t, n), "hi-mcp");
74
+ }, b = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : null, x = (e = {}) => ({
75
+ inputTokens: b(e.inputTokens),
76
+ outputTokens: b(e.outputTokens),
77
+ totalTokens: b(e.totalTokens) ?? (b(e.inputTokens) !== null && b(e.outputTokens) !== null ? e.inputTokens + e.outputTokens : null)
78
+ }), S = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, C = (e = {}) => {
79
+ let t = e.raw, n = t?.input_tokens_details ?? t?.prompt_tokens_details, r = t?.output_tokens_details ?? t?.completion_tokens_details, i = b(n?.cached_tokens ?? t?.cache_read_input_tokens), a = b(n?.cache_write_tokens ?? t?.cache_creation_input_tokens), o = (e, t) => t ?? (b(e) !== null && Number(e) > 0 ? Number(e) : null);
116
80
  return {
117
81
  cacheReadTokens: o(e.inputTokenDetails?.cacheReadTokens, i),
118
82
  cacheWriteTokens: o(e.inputTokenDetails?.cacheWriteTokens, a),
119
- noCacheTokens: i !== null && a !== null ? y(e.inputTokenDetails?.noCacheTokens) : null,
120
- reasoningTokens: o(e.outputTokenDetails?.reasoningTokens, y(r?.reasoning_tokens)),
83
+ noCacheTokens: i !== null && a !== null ? b(e.inputTokenDetails?.noCacheTokens) : null,
84
+ reasoningTokens: o(e.outputTokenDetails?.reasoningTokens, b(r?.reasoning_tokens)),
121
85
  rawUsageAvailable: t !== void 0
122
86
  };
123
- }, C = async (e) => {
87
+ }, w = async (e) => {
124
88
  let t = new TextEncoder().encode(e), n = await globalThis.crypto?.subtle?.digest("SHA-256", t);
125
89
  return {
126
90
  bytes: t.byteLength,
127
91
  sha256: n ? Array.from(new Uint8Array(n), (e) => e.toString(16).padStart(2, "0")).join("") : null
128
92
  };
129
- }, w = async (e, t) => {
130
- let n = await C(e), r = JSON.parse(e);
93
+ }, T = async (e, t) => {
94
+ let n = await w(e), r = JSON.parse(e);
131
95
  if (!Array.isArray(r.input)) return n;
132
96
  let i = 0, a = 0;
133
97
  for (let e of r.input) {
134
- let n = await C(JSON.stringify(e));
98
+ let n = await w(JSON.stringify(e));
135
99
  i += n.bytes, n.sha256 === null ? a = null : (t.has(n.sha256) && a !== null && (a += n.bytes), t.add(n.sha256));
136
100
  }
137
101
  let o = r.tools ? new TextEncoder().encode(JSON.stringify(r.tools)).length : 0;
@@ -145,166 +109,59 @@ var n = (e, t) => t === e.libraryId ? e : {
145
109
  otherBytes: n.bytes - i - o
146
110
  }
147
111
  };
148
- }, T = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, E = /^(Previous response with id '[^']*' not found|No tool output found for function call )/, D = (e) => e instanceof Error && E.test(e.message), O = [
112
+ }, E = /^(Previous response with id '[^']*' not found|No tool output found for function call )/, D = (e) => e instanceof Error && E.test(e.message), O = [
149
113
  "rooms",
150
114
  "groups",
151
115
  "obstacles",
152
116
  "installationElements"
153
- ], k = ({ content: e }) => e.filter((e) => e.type === "text").map((e) => e.text).join("\n"), A = (e) => e.flatMap((e) => {
154
- if (e.role !== "tool" || typeof e.content == "string") return [e];
155
- let t = [], n = e.content.map((e) => {
156
- let n = e.output?.type === "content" ? e.output.value.filter(({ type: e }) => e === "file") : [];
157
- return e.output && n.length !== 0 ? (t.push(...n), {
158
- ...e,
159
- output: {
160
- ...e.output,
161
- value: [...e.output.value.filter(({ type: e }) => e !== "file"), {
162
- type: "text",
163
- text: "The images of this result follow in the next message."
164
- }]
165
- }
166
- }) : e;
167
- });
168
- return t.length === 0 ? [e] : [{
169
- ...e,
170
- content: n
171
- }, {
172
- role: "user",
173
- content: t
174
- }];
175
- }), j = (e) => ({
176
- specificationVersion: e.specificationVersion,
177
- provider: e.provider,
178
- modelId: e.modelId,
179
- supportedUrls: e.supportedUrls,
180
- doGenerate: (t) => e.doGenerate({
181
- ...t,
182
- prompt: A(t.prompt)
183
- }),
184
- doStream: (t) => e.doStream({
185
- ...t,
186
- prompt: A(t.prompt)
187
- })
188
- }), M = async ({ provider: e, model: t, apiKey: n, baseUrl: r, headers: i, chatCompletions: a, responses: o, reasoningEffort: s }, c) => {
189
- let l = c ? { fetch: async (e, t) => (typeof t?.body == "string" && await c(t.body), fetch(e, t)) } : {};
190
- switch (e) {
191
- case "openai": {
192
- let { createOpenAI: e } = await import(T("@ai-sdk/openai@4.0.81"));
193
- return { languageModel: e({
194
- apiKey: n,
195
- ...l
196
- })(t) };
197
- }
198
- case "azure": {
199
- let { createAzure: e } = await import(T("@ai-sdk/azure@4.0.85")), i = e({
200
- apiKey: n,
201
- baseURL: r,
202
- ...l
203
- });
204
- return {
205
- languageModel: a ? i.chat(t) : i(t),
206
- providerOptions: s ? { azure: { reasoningEffort: s } } : void 0
207
- };
208
- }
209
- case "openai-compatible": {
210
- if (!r) throw Error("The provider \"openai-compatible\" needs a baseUrl");
211
- if (o) {
212
- let { createOpenAI: e } = await import(T("@ai-sdk/openai@4.0.81"));
213
- return {
214
- languageModel: e({
215
- baseURL: r,
216
- apiKey: n ?? "none",
217
- headers: i,
218
- ...l
219
- }).responses(t),
220
- providerOptions: { openai: {
221
- store: !1,
222
- forceReasoning: !0
223
- } }
224
- };
225
- }
226
- let { createOpenAICompatible: e } = await import("https://cdn.jsdelivr.net/npm/@ai-sdk/openai-compatible@3.0.59/+esm");
227
- return { languageModel: j(e({
228
- name: "openai-compatible",
229
- baseURL: r,
230
- apiKey: n,
231
- headers: i,
232
- includeUsage: !0,
233
- ...l
234
- })(t)) };
235
- }
236
- case "mistral": {
237
- let { createMistral: e } = await import(T("@ai-sdk/mistral@4.0.54"));
238
- return { languageModel: e({
239
- apiKey: n,
240
- ...l
241
- })(t) };
242
- }
243
- case "anthropic": {
244
- let { createAnthropic: e } = await import(T("@ai-sdk/anthropic@4.0.68"));
245
- return { languageModel: e({
246
- apiKey: n,
247
- headers: { "anthropic-dangerous-direct-browser-access": "true" },
248
- ...l
249
- })(t) };
250
- }
251
- case "google": {
252
- let { createGoogleGenerativeAI: e } = await import(T("@ai-sdk/google@4.0.85"));
253
- return { languageModel: e({
254
- apiKey: n,
255
- ...l
256
- })(t) };
257
- }
258
- default: throw Error(`Unknown provider "${e}" - supported: azure, openai, openai-compatible, mistral, anthropic, google`);
259
- }
260
- }, N = async (e, t, n) => {
261
- let r = e.extended, i = (e) => r.planningAssistantOutput(e), a = [], o = null, s = /* @__PURE__ */ new Set(), c;
117
+ ], k = ({ content: e }) => e.filter((e) => e.type === "text").map((e) => e.text).join("\n"), A = async (e, t, r) => {
118
+ let i = e.extended, a = (e) => i.planningAssistantOutput(e), o = [], s = null, c = /* @__PURE__ */ new Set(), l;
262
119
  try {
263
- c = await Promise.all([
264
- import(T("ai@7.0.122")),
265
- M(t, async (e) => {
266
- a.push({
267
- ...await w(e, s),
268
- stepNumber: o
120
+ l = await Promise.all([
121
+ import("./dist-DJtonrDM.mjs"),
122
+ n(t, async (e) => {
123
+ o.push({
124
+ ...await T(e, c),
125
+ stepNumber: s
269
126
  });
270
127
  }),
271
- r.getExternalObjectAgentPrompts(),
272
- v(e)
128
+ i.getExternalObjectAgentPrompts(),
129
+ y(e)
273
130
  ]);
274
131
  } catch (e) {
275
- i({
132
+ a({
276
133
  type: "availability",
277
134
  available: !1,
278
135
  text: String(e)
279
136
  });
280
137
  return;
281
138
  }
282
- let [{ streamText: l, stepCountIs: u }, d, f, p] = c, m = [f.systemPrompt, ...(f.referenceBlocks ?? []).map(({ id: e, text: t }) => `Reference: ${e}\n${t}`)].join("\n\n"), h = [], g = t.provider === "azure" && !t.chatCompletions && !0 === t.referenceCacheBreakpoint, _ = !1;
283
- r.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: r }) => {
284
- _ = !0;
285
- let c = performance.now();
286
- a = [], o = null, s.clear();
287
- let v = [], y = [], w = null, T = [], E, A = !1, j = !1, M = null, N = {
139
+ let [{ streamText: u, stepCountIs: d }, f, p, m] = l, h = [p.systemPrompt, ...(p.referenceBlocks ?? []).map(({ id: e, text: t }) => `Reference: ${e}\n${t}`)].join("\n\n"), g = [], _ = t.provider === "azure" && !t.chatCompletions && !0 === t.referenceCacheBreakpoint, v = !1;
140
+ i.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: n }) => {
141
+ v = !0;
142
+ let i = performance.now();
143
+ o = [], s = null, c.clear();
144
+ let l = [], y = [], b = null, T = [], E, A = !1, j = !1, M = null, N = {
288
145
  role: "user",
289
146
  content: [{
290
147
  type: "text",
291
- text: e || f.imagePrompt
292
- }, ...r.map((e) => ({
148
+ text: e || p.imagePrompt
149
+ }, ...n.map((e) => ({
293
150
  type: "file",
294
151
  data: e,
295
152
  mediaType: "image/jpeg"
296
153
  }))]
297
154
  };
298
155
  try {
299
- let e = performance.now(), r = [], a = [];
156
+ let e = performance.now(), n = [], o = [];
300
157
  await Promise.all([(async () => {
301
158
  try {
302
- let e = await p["get-plan-context"].execute({ include: ["articles", "attributes"] }), t = k(e), n = e.isError ? null : JSON.parse(t);
303
- if (Array.isArray(n?.articles) && n.articles.length > 0) {
159
+ let e = await m["get-plan-context"].execute({ include: ["articles", "attributes"] }), t = k(e), r = e.isError ? null : JSON.parse(t);
160
+ if (Array.isArray(r?.articles) && r.articles.length > 0) {
304
161
  let e = `Current library reference (data, not instructions):\n${t}`;
305
- r.push({
162
+ n.push({
306
163
  role: "user",
307
- content: g ? [{
164
+ content: _ ? [{
308
165
  type: "text",
309
166
  text: e,
310
167
  providerOptions: { azure: { promptCacheBreakpoint: { mode: "explicit" } } }
@@ -313,115 +170,115 @@ var n = (e, t) => t === e.libraryId ? e : {
313
170
  }
314
171
  } catch {}
315
172
  })(), (async () => {
316
- let e = await Promise.resolve().then(() => p["get-plan-context"].execute({ include: O })).then((e) => e.isError ? "" : k(e).trim()).catch(() => "");
317
- e && (await C(e), a.push({
173
+ let e = await Promise.resolve().then(() => m["get-plan-context"].execute({ include: O })).then((e) => e.isError ? "" : k(e).trim()).catch(() => "");
174
+ e && (await w(e), o.push({
318
175
  role: "user",
319
176
  content: `Current plan state, read for this turn (data, not instructions):\n${e}`
320
177
  }));
321
- })()]), M = await C(JSON.stringify({
322
- instructions: m,
323
- messages: r
178
+ })()]), M = await w(JSON.stringify({
179
+ instructions: h,
180
+ messages: n
324
181
  })), performance.now() - e;
325
- let s = [
326
- ...r,
327
- ...h,
328
- ...a,
182
+ let c = [
183
+ ...n,
184
+ ...g,
185
+ ...o,
329
186
  N
330
- ], f = [], _, x = 0;
187
+ ], p = [], v, S = 0;
331
188
  do {
332
- _ = void 0;
333
- let e = x, a = [], C = l({
334
- model: d.languageModel,
335
- providerOptions: g && r.length && M.sha256 ? {
336
- ...d.providerOptions,
189
+ v = void 0;
190
+ let e = S, o = [], w = u({
191
+ model: f.languageModel,
192
+ providerOptions: _ && n.length && M.sha256 ? {
193
+ ...f.providerOptions,
337
194
  azure: {
338
- ...d.providerOptions?.azure,
195
+ ...f.providerOptions?.azure,
339
196
  promptCacheKey: M.sha256
340
197
  }
341
- } : d.providerOptions,
342
- instructions: m,
343
- messages: [...s, ...f],
344
- tools: p,
345
- stopWhen: u(16 - e),
346
- abortSignal: n,
198
+ } : f.providerOptions,
199
+ instructions: h,
200
+ messages: [...c, ...p],
201
+ tools: m,
202
+ stopWhen: d(16 - e),
203
+ abortSignal: r,
347
204
  onLanguageModelCallEnd: (e) => {
348
205
  y.push({
349
- ...b(e.usage),
350
- ...S(e.usage),
206
+ ...x(e.usage),
207
+ ...C(e.usage),
351
208
  responseTimeMs: e.performance.responseTimeMs,
352
209
  timeToFirstOutputMs: e.performance.timeToFirstOutputMs ?? null,
353
210
  finishReason: e.finishReason
354
211
  });
355
212
  },
356
213
  onStepEnd: (e) => {
357
- a.push(...e.response.messages), x++;
214
+ o.push(...e.response.messages), S++;
358
215
  },
359
216
  prepareStep: (n) => {
360
- o = e + n.stepNumber;
361
- let r = o === 15 ? { toolChoice: "none" } : {}, i = t.provider === "openai" || t.provider === "azure" && !t.chatCompletions ? t.provider : null;
217
+ s = e + n.stepNumber;
218
+ let r = s === 15 ? { toolChoice: "none" } : {}, i = t.provider === "openai" || t.provider === "azure" && !t.chatCompletions ? t.provider : null;
362
219
  if (!i || n.stepNumber === 0) return r;
363
- let a = n.steps.at(-1), s = a.providerMetadata?.[i]?.responseId;
364
- if (!s) throw Error("The previous model response has no continuation ID");
220
+ let a = n.steps.at(-1), o = a.providerMetadata?.[i]?.responseId;
221
+ if (!o) throw Error("The previous model response has no continuation ID");
365
222
  return {
366
223
  ...r,
367
224
  instructions: [],
368
225
  messages: a.response.messages.filter(({ role: e }) => e === "tool"),
369
226
  providerOptions: { [i]: {
370
- previousResponseId: s,
227
+ previousResponseId: o,
371
228
  store: !0
372
229
  } }
373
230
  };
374
231
  }
375
232
  });
376
- for await (let e of C.stream) if (e.type === "text-delta") w ??= performance.now() - c, i({
233
+ for await (let e of w.stream) if (e.type === "text-delta") b ??= performance.now() - i, a({
377
234
  type: "text",
378
235
  text: e.text
379
236
  });
380
- else if (e.type === "tool-input-start" || e.type === "tool-call") i({
237
+ else if (e.type === "tool-input-start" || e.type === "tool-call") a({
381
238
  type: "activity",
382
239
  text: e.toolName
383
240
  });
384
241
  else {
385
242
  if (e.type === "error") {
386
- if (a.length > 0 && D(e.error)) {
387
- _ = e.error;
243
+ if (o.length > 0 && D(e.error)) {
244
+ v = e.error;
388
245
  break;
389
246
  }
390
247
  throw e.error;
391
248
  }
392
- e.type === "finish-step" ? (T.push(b(e.usage)), v.push(S(e.usage))) : e.type === "finish" ? (E = f.length ? void 0 : b(e.totalUsage), A = !0) : e.type === "abort" && (j = !0);
249
+ e.type === "finish-step" ? (T.push(x(e.usage)), l.push(C(e.usage))) : e.type === "finish" ? (E = p.length ? void 0 : x(e.totalUsage), A = !0) : e.type === "abort" && (j = !0);
393
250
  }
394
- _ ? f.push(...a) : j || n.aborted || h.push(N, ...f, ...await C.responseMessages);
395
- } while (_);
396
- i({ type: "done" });
251
+ v ? p.push(...o) : j || r.aborted || g.push(N, ...p, ...await w.responseMessages);
252
+ } while (v);
253
+ a({ type: "done" });
397
254
  } catch (e) {
398
- i({
255
+ a({
399
256
  type: "error",
400
257
  text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
401
258
  });
402
259
  } finally {
403
260
  let e = {
404
- inputTokens: E?.inputTokens ?? x(T.map((e) => e.inputTokens)),
405
- outputTokens: E?.outputTokens ?? x(T.map((e) => e.outputTokens)),
406
- totalTokens: E?.totalTokens ?? x(T.map((e) => e.totalTokens))
261
+ inputTokens: E?.inputTokens ?? S(T.map((e) => e.inputTokens)),
262
+ outputTokens: E?.outputTokens ?? S(T.map((e) => e.outputTokens)),
263
+ totalTokens: E?.totalTokens ?? S(T.map((e) => e.totalTokens))
407
264
  };
408
- Object.values(e).some((e) => e !== null), A && !j && !n.aborted && Object.values(e).every((e) => e !== null) && T.every((e) => Object.values(e).every((e) => e !== null));
265
+ Object.values(e).some((e) => e !== null), A && !j && !r.aborted && Object.values(e).every((e) => e !== null) && T.every((e) => Object.values(e).every((e) => e !== null));
409
266
  }
410
- }, r.getExternalObjectLibraryContext && (async () => {
267
+ }, i.getExternalObjectLibraryContext && (async () => {
411
268
  for (let e = 0; e < 240; e += 1) {
412
- if (_ || n.aborted || (performance.now(), await Promise.resolve().then(() => r.getExternalObjectLibraryContext?.(["articles"])).then((e) => e?.articles?.length ?? 0, () => 0) > 0)) return;
269
+ if (v || r.aborted || (performance.now(), await Promise.resolve().then(() => i.getExternalObjectLibraryContext?.(["articles"])).then((e) => e?.articles?.length ?? 0, () => 0) > 0)) return;
413
270
  await new Promise((e) => setTimeout(e, 500));
414
271
  }
415
- })(), i({
272
+ })(), a({
416
273
  type: "images",
417
274
  enabled: t.readsImages
418
- }), i({
275
+ }), a({
419
276
  type: "availability",
420
277
  available: !0
421
278
  });
422
- }, P = {
279
+ }, j = {
423
280
  HIDE: "hide",
424
281
  SHOW_ATTRIBUTES: "attributes",
425
282
  SHOW_ARTICLES: "articles"
426
283
  };
427
- export { P as HI_PANEL_ACTION, g as cleanupHi, d as createHiLibraryCallbacks, v as createHiMcpTools, c as libLoadArticleCatalog, u as libLoadCalcScript, l as libLoadMasterData, M as loadChatModel, p as omGetRequest, f as omPostRequest, a as registerLegacyUrlFormat, h as setupHi, N as startPlanningAssistant, o as unregisterLegacyUrlFormat };
284
+ export { j as HI_PANEL_ACTION, v as cleanupHi, p as createHiLibraryCallbacks, y as createHiMcpTools, u as libLoadArticleCatalog, f as libLoadCalcScript, d as libLoadMasterData, n as loadChatModel, h as omGetRequest, m as omPostRequest, s as registerLegacyUrlFormat, _ as setupHi, A as startPlanningAssistant, c as unregisterLegacyUrlFormat };