@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.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-D6M-d6y5.mjs";
3
- import { t } from "./utils-BwWn6Fw4.mjs";
4
- var n = (e, t) => t === e.libraryId ? e : {
2
+ import { t as e } from "./browser-zrjtYpL8.mjs";
3
+ import { t } from "./utils-WeolMfC5.mjs";
4
+ import { n, t as r } from "./mcp-tools-D__M74CZ.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": "*"
@@ -17,22 +18,22 @@ var n = (e, t) => t === e.libraryId ? e : {
17
18
  } catch (e) {
18
19
  throw console.warn(`Failed to fetch data from ${r.property}`), console.error(e), 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
+ }, o = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": new Set(["Furniture_Smith"]) }, s = (e, t) => {
22
+ o[e] || (o[e] = /* @__PURE__ */ new Set()), o[e].add(t);
23
+ }, c = (e, t) => {
24
+ o[e]?.delete(t), o[e]?.size === 0 && delete o[e];
25
+ }, l = (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 && o[r.subscriptionId]?.has(n) ? `api/pos/${t}?libraryId=${n}` : `api/pos/libraries/${n}/${t}`;
28
+ }, 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) => {
29
+ let t = await (await a(l(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
+ }, p = (e) => ({
33
+ onLoadJavascript: (t) => f(i(e, t)),
34
+ onLoadArticleCatalog: (t) => u(i(e, t)),
35
+ onLoadMasterData: (t) => d(i(e, t))
36
+ }), m = 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
+ }, h = 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,75 +52,38 @@ var n = (e, t) => t === e.libraryId ? e : {
51
52
  ...n
52
53
  }
53
54
  })).json();
54
- }, m = (t, n) => {
55
+ }, g = (t, n) => {
55
56
  t.serverOptions ||= {}, !t.serverOptions.language && n?.locale && (t.serverOptions.language = n.locale), t.serverOptions.language || (t.serverOptions.language = e(null, !0));
56
- }, h = null, g = async (e, r = {}) => {
57
- h && window.removeEventListener("message", h);
58
- let i = typeof e == "string" ? { libraryId: e } : e;
59
- 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)));
60
- let { expose: a } = await import("./comlink-CR7SvKHo.mjs");
61
- h = (e) => {
57
+ }, _ = null, v = async (e, n = {}) => {
58
+ _ && window.removeEventListener("message", _);
59
+ let r = typeof e == "string" ? { libraryId: e } : e;
60
+ n.onLoadJavascript === void 0 && (n.onLoadJavascript = (e) => f(i(r, e))), n.onLoadArticleCatalog === void 0 && (n.onLoadArticleCatalog = (e) => u(i(r, e))), n.onLoadMasterData === void 0 && (n.onLoadMasterData = (e) => d(i(r, e)));
61
+ let { expose: a } = await import("./comlink-Cmiqa2s0.mjs");
62
+ _ = (e) => {
62
63
  if (e.data.type === "connect_hi" && e.data.port) {
63
- let n = e.data.port;
64
- m(i, e.data.globalInitData || {}), n.start?.(), a(t(r), n);
64
+ let i = e.data.port;
65
+ g(r, e.data.globalInitData || {}), i.start?.(), a(t(n), i);
65
66
  }
66
- }, window.addEventListener("message", h);
67
- }, _ = () => {
68
- h &&= (window.removeEventListener("message", h), null);
69
- }, v = ({ output: e }) => ({
70
- type: "content",
71
- value: e.content.map((e) => e.type === "text" ? {
72
- type: "text",
73
- text: e.text
74
- } : {
75
- type: "file",
76
- mediaType: e.mimeType,
77
- data: {
78
- type: "data",
79
- data: e.data
80
- }
81
- })
82
- }), y = async ({ extended: e }) => {
67
+ }, window.addEventListener("message", _);
68
+ }, y = () => {
69
+ _ &&= (window.removeEventListener("message", _), null);
70
+ }, b = async ({ extended: e }) => {
83
71
  if (typeof e.getExternalObjectAgentTools != "function") throw Error("The planner has no HI agent tools: it needs a Rubens UI with getExternalObjectAgentTools.");
84
- let t = await e.getExternalObjectAgentTools();
85
- return Object.fromEntries(t.map(({ name: t, description: n, inputSchema: r }) => {
86
- let i = () => r;
87
- return [t, {
88
- type: "dynamic",
89
- description: n,
90
- inputSchema: { "~standard": {
91
- version: 1,
92
- vendor: "hi-mcp",
93
- validate: (e) => ({ value: e }),
94
- jsonSchema: {
95
- input: i,
96
- output: i
97
- }
98
- } },
99
- execute: (n) => e.callExternalObjectAgentTool(t, n).catch((e) => ({
100
- content: [{
101
- type: "text",
102
- text: e instanceof Error ? e.message : String(e)
103
- }],
104
- isError: !0
105
- })),
106
- toModelOutput: v
107
- }];
108
- }));
109
- }, b = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : null, x = (e = {}) => ({
110
- inputTokens: b(e.inputTokens),
111
- outputTokens: b(e.outputTokens),
112
- totalTokens: b(e.totalTokens) ?? (b(e.inputTokens) !== null && b(e.outputTokens) !== null ? e.inputTokens + e.outputTokens : null)
113
- }), S = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, C = (e = {}) => {
114
- let t = e.raw, n = t?.input_tokens_details ?? t?.prompt_tokens_details, r = t?.output_tokens_details ?? t?.completion_tokens_details, i = 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);
72
+ return r(await e.getExternalObjectAgentTools(), (t, n) => e.callExternalObjectAgentTool(t, n), "hi-mcp");
73
+ }, x = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : null, S = (e = {}) => ({
74
+ inputTokens: x(e.inputTokens),
75
+ outputTokens: x(e.outputTokens),
76
+ totalTokens: x(e.totalTokens) ?? (x(e.inputTokens) !== null && x(e.outputTokens) !== null ? e.inputTokens + e.outputTokens : null)
77
+ }), C = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, w = (e = {}) => {
78
+ let t = e.raw, n = t?.input_tokens_details ?? t?.prompt_tokens_details, r = t?.output_tokens_details ?? t?.completion_tokens_details, i = x(n?.cached_tokens ?? t?.cache_read_input_tokens), a = x(n?.cache_write_tokens ?? t?.cache_creation_input_tokens), o = (e, t) => t ?? (x(e) !== null && Number(e) > 0 ? Number(e) : null);
115
79
  return {
116
80
  cacheReadTokens: o(e.inputTokenDetails?.cacheReadTokens, i),
117
81
  cacheWriteTokens: o(e.inputTokenDetails?.cacheWriteTokens, a),
118
- noCacheTokens: i !== null && a !== null ? b(e.inputTokenDetails?.noCacheTokens) : null,
119
- reasoningTokens: o(e.outputTokenDetails?.reasoningTokens, b(r?.reasoning_tokens)),
82
+ noCacheTokens: i !== null && a !== null ? x(e.inputTokenDetails?.noCacheTokens) : null,
83
+ reasoningTokens: o(e.outputTokenDetails?.reasoningTokens, x(r?.reasoning_tokens)),
120
84
  rawUsageAvailable: t !== void 0
121
85
  };
122
- }, w = (e) => Object.fromEntries([
86
+ }, T = (e) => Object.fromEntries([
123
87
  "cacheReadTokens",
124
88
  "cacheWriteTokens",
125
89
  "noCacheTokens",
@@ -127,23 +91,23 @@ var n = (e, t) => t === e.libraryId ? e : {
127
91
  ].map((t) => {
128
92
  let n = e.map((e) => e[t]), r = n.filter((e) => e !== null).length;
129
93
  return [t, {
130
- tokens: S(n),
94
+ tokens: C(n),
131
95
  status: r === 0 ? "unavailable" : r === e.length ? "complete" : "partial",
132
96
  reportedSteps: r,
133
97
  observedSteps: e.length
134
98
  }];
135
- })), T = async (e) => {
99
+ })), E = async (e) => {
136
100
  let t = new TextEncoder().encode(e), n = await globalThis.crypto?.subtle?.digest("SHA-256", t);
137
101
  return {
138
102
  bytes: t.byteLength,
139
103
  sha256: n ? Array.from(new Uint8Array(n), (e) => e.toString(16).padStart(2, "0")).join("") : null
140
104
  };
141
- }, E = async (e, t) => {
142
- let n = await T(e), r = JSON.parse(e);
105
+ }, D = async (e, t) => {
106
+ let n = await E(e), r = JSON.parse(e);
143
107
  if (!Array.isArray(r.input)) return n;
144
108
  let i = 0, a = 0;
145
109
  for (let e of r.input) {
146
- let n = await T(JSON.stringify(e));
110
+ let n = await E(JSON.stringify(e));
147
111
  i += n.bytes, n.sha256 === null ? a = null : (t.has(n.sha256) && a !== null && (a += n.bytes), t.add(n.sha256));
148
112
  }
149
113
  let o = r.tools ? new TextEncoder().encode(JSON.stringify(r.tools)).length : 0;
@@ -157,200 +121,69 @@ var n = (e, t) => t === e.libraryId ? e : {
157
121
  otherBytes: n.bytes - i - o
158
122
  }
159
123
  };
160
- }, D = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, O = (e) => `https://cdn.jsdelivr.net/npm/${e}/+esm`, k = 16, A = /^(Previous response with id '[^']*' not found|No tool output found for function call )/, j = (e) => e instanceof Error && A.test(e.message), M = [
124
+ }, O = 16, k = /^(Previous response with id '[^']*' not found|No tool output found for function call )/, A = (e) => e instanceof Error && k.test(e.message), j = [
161
125
  "rooms",
162
126
  "groups",
163
127
  "obstacles",
164
128
  "installationElements"
165
- ], N = 500, P = 240, F = ({ content: e }) => e.filter((e) => e.type === "text").map((e) => e.text).join("\n"), I = "The images of this result follow in the next message.", L = (e) => e.flatMap((e) => {
166
- if (e.role !== "tool" || typeof e.content == "string") return [e];
167
- let t = [], n = e.content.map((e) => {
168
- let n = e.output?.type === "content" ? e.output.value.filter(({ type: e }) => e === "file") : [];
169
- return !e.output || n.length === 0 ? e : (t.push(...n), {
170
- ...e,
171
- output: {
172
- ...e.output,
173
- value: [...e.output.value.filter(({ type: e }) => e !== "file"), {
174
- type: "text",
175
- text: I
176
- }]
177
- }
178
- });
179
- });
180
- return t.length === 0 ? [e] : [{
181
- ...e,
182
- content: n
183
- }, {
184
- role: "user",
185
- content: t
186
- }];
187
- }), R = (e) => ({
188
- specificationVersion: e.specificationVersion,
189
- provider: e.provider,
190
- modelId: e.modelId,
191
- supportedUrls: e.supportedUrls,
192
- doGenerate: (t) => e.doGenerate({
193
- ...t,
194
- prompt: L(t.prompt)
195
- }),
196
- doStream: (t) => e.doStream({
197
- ...t,
198
- prompt: L(t.prompt)
199
- })
200
- }), z = async ({ provider: e, model: t, apiKey: n, baseUrl: r, headers: i, chatCompletions: a, responses: o, reasoningEffort: s }, c) => {
201
- let l = c ? { fetch: async (e, t) => (typeof t?.body == "string" && await c(t.body), fetch(e, t)) } : {};
202
- switch (e) {
203
- case "openai": {
204
- let { createOpenAI: e } = await import(
205
- /* @vite-ignore */
206
- D("@ai-sdk/openai@4.0.81")
207
- );
208
- return { languageModel: e({
209
- apiKey: n,
210
- ...l
211
- })(t) };
212
- }
213
- case "azure": {
214
- let { createAzure: e } = await import(
215
- /* @vite-ignore */
216
- D("@ai-sdk/azure@4.0.85")
217
- ), i = e({
218
- apiKey: n,
219
- baseURL: r,
220
- ...l
221
- });
222
- return {
223
- languageModel: a ? i.chat(t) : i(t),
224
- providerOptions: s ? { azure: { reasoningEffort: s } } : void 0
225
- };
226
- }
227
- case "openai-compatible": {
228
- if (!r) throw Error("The provider \"openai-compatible\" needs a baseUrl");
229
- if (o) {
230
- let { createOpenAI: e } = await import(
231
- /* @vite-ignore */
232
- D("@ai-sdk/openai@4.0.81")
233
- );
234
- return {
235
- languageModel: e({
236
- baseURL: r,
237
- apiKey: n ?? "none",
238
- headers: i,
239
- ...l
240
- }).responses(t),
241
- providerOptions: { openai: {
242
- store: !1,
243
- forceReasoning: !0
244
- } }
245
- };
246
- }
247
- let { createOpenAICompatible: e } = await import(
248
- /* @vite-ignore */
249
- O("@ai-sdk/openai-compatible@3.0.59")
250
- );
251
- return { languageModel: R(e({
252
- name: "openai-compatible",
253
- baseURL: r,
254
- apiKey: n,
255
- headers: i,
256
- includeUsage: !0,
257
- ...l
258
- })(t)) };
259
- }
260
- case "mistral": {
261
- let { createMistral: e } = await import(
262
- /* @vite-ignore */
263
- D("@ai-sdk/mistral@4.0.54")
264
- );
265
- return { languageModel: e({
266
- apiKey: n,
267
- ...l
268
- })(t) };
269
- }
270
- case "anthropic": {
271
- let { createAnthropic: e } = await import(
272
- /* @vite-ignore */
273
- D("@ai-sdk/anthropic@4.0.68")
274
- );
275
- return { languageModel: e({
276
- apiKey: n,
277
- headers: { "anthropic-dangerous-direct-browser-access": "true" },
278
- ...l
279
- })(t) };
280
- }
281
- case "google": {
282
- let { createGoogleGenerativeAI: e } = await import(
283
- /* @vite-ignore */
284
- D("@ai-sdk/google@4.0.85")
285
- );
286
- return { languageModel: e({
287
- apiKey: n,
288
- ...l
289
- })(t) };
290
- }
291
- default: throw Error(`Unknown provider "${e}" - supported: azure, openai, openai-compatible, mistral, anthropic, google`);
292
- }
293
- }, B = async (e, t, n) => {
294
- let r = e.extended, i = (e) => r.planningAssistantOutput(e), a = [], o = null, s = /* @__PURE__ */ new Set(), c;
129
+ ], M = 500, N = 240, P = ({ content: e }) => e.filter((e) => e.type === "text").map((e) => e.text).join("\n"), F = async (e, t, r) => {
130
+ let i = e.extended, a = (e) => i.planningAssistantOutput(e), o = [], s = null, c = /* @__PURE__ */ new Set(), l;
295
131
  try {
296
- c = await Promise.all([
297
- import(
298
- /* @vite-ignore */
299
- D("ai@7.0.122")
300
- ),
301
- z(t, async (e) => {
302
- a.push({
303
- ...await E(e, s),
304
- stepNumber: o
132
+ l = await Promise.all([
133
+ import("./dist-XEy6Tk_Y.mjs"),
134
+ n(t, async (e) => {
135
+ o.push({
136
+ ...await D(e, c),
137
+ stepNumber: s
305
138
  });
306
139
  }),
307
- r.getExternalObjectAgentPrompts(),
308
- y(e)
140
+ i.getExternalObjectAgentPrompts(),
141
+ b(e)
309
142
  ]);
310
143
  } catch (e) {
311
- console.log("[planning-assistant]", String(e)), i({
144
+ console.log("[planning-assistant]", String(e)), a({
312
145
  type: "availability",
313
146
  available: !1,
314
147
  text: String(e)
315
148
  });
316
149
  return;
317
150
  }
318
- 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 && t.referenceCacheBreakpoint === !0, _ = !1, v = async () => {
319
- for (let e = 0; e < P; e += 1) {
320
- if (_ || n.aborted) return;
321
- let e = performance.now(), t = await Promise.resolve().then(() => r.getExternalObjectLibraryContext?.(["articles"])).then((e) => e?.articles?.length ?? 0, () => 0);
151
+ 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 && t.referenceCacheBreakpoint === !0, v = !1, y = async () => {
152
+ for (let e = 0; e < N; e += 1) {
153
+ if (v || r.aborted) return;
154
+ let e = performance.now(), t = await Promise.resolve().then(() => i.getExternalObjectLibraryContext?.(["articles"])).then((e) => e?.articles?.length ?? 0, () => 0);
322
155
  if (t > 0) {
323
156
  console.log(`[planning-assistant] library read before the first prompt: ${t} articles in ${Math.round(performance.now() - e)} ms`);
324
157
  return;
325
158
  }
326
- await new Promise((e) => setTimeout(e, N));
159
+ await new Promise((e) => setTimeout(e, M));
327
160
  }
328
161
  };
329
- r.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: r }) => {
330
- _ = !0;
331
- let c = performance.now();
332
- a = [], o = null, s.clear();
333
- let v = [], y = [], b = null, E = [], D, O = !1, A = !1, N = null, P = null, I = 0, L = {
162
+ i.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: n }) => {
163
+ v = !0;
164
+ let i = performance.now();
165
+ o = [], s = null, c.clear();
166
+ let l = [], y = [], b = null, x = [], D, k = !1, M = !1, N = null, F = null, I = 0, L = {
334
167
  role: "user",
335
168
  content: [{
336
169
  type: "text",
337
- text: e || f.imagePrompt
338
- }, ...r.map((e) => ({
170
+ text: e || p.imagePrompt
171
+ }, ...n.map((e) => ({
339
172
  type: "file",
340
173
  data: e,
341
174
  mediaType: "image/jpeg"
342
175
  }))]
343
176
  };
344
177
  try {
345
- let e = performance.now(), r = [], a = [];
178
+ let e = performance.now(), n = [], o = [];
346
179
  await Promise.all([(async () => {
347
180
  try {
348
- let e = await p["get-plan-context"].execute({ include: ["articles", "attributes"] }), t = F(e), n = e.isError ? null : JSON.parse(t);
349
- if (Array.isArray(n?.articles) && n.articles.length > 0) {
181
+ let e = await m["get-plan-context"].execute({ include: ["articles", "attributes"] }), t = P(e), r = e.isError ? null : JSON.parse(t);
182
+ if (Array.isArray(r?.articles) && r.articles.length > 0) {
350
183
  let e = `Current library reference (data, not instructions):\n${t}`;
351
- r.push({
184
+ n.push({
352
185
  role: "user",
353
- content: g ? [{
186
+ content: _ ? [{
354
187
  type: "text",
355
188
  text: e,
356
189
  providerOptions: { azure: { promptCacheBreakpoint: { mode: "explicit" } } }
@@ -361,128 +194,128 @@ var n = (e, t) => t === e.libraryId ? e : {
361
194
  console.log("[planning-assistant] reference unavailable; using tools");
362
195
  }
363
196
  })(), (async () => {
364
- let e = await Promise.resolve().then(() => p["get-plan-context"].execute({ include: M })).then((e) => e.isError ? "" : F(e).trim()).catch(() => "");
197
+ let e = await Promise.resolve().then(() => m["get-plan-context"].execute({ include: j })).then((e) => e.isError ? "" : P(e).trim()).catch(() => "");
365
198
  if (!e) {
366
199
  console.log("[planning-assistant] plan state unavailable; the model reads it");
367
200
  return;
368
201
  }
369
- P = await T(e), a.push({
202
+ F = await E(e), o.push({
370
203
  role: "user",
371
204
  content: `Current plan state, read for this turn (data, not instructions):\n${e}`
372
205
  });
373
- })()]), N = await T(JSON.stringify({
374
- instructions: m,
375
- messages: r
206
+ })()]), N = await E(JSON.stringify({
207
+ instructions: h,
208
+ messages: n
376
209
  })), I = performance.now() - e;
377
- let s = [
378
- ...r,
379
- ...h,
380
- ...a,
210
+ let c = [
211
+ ...n,
212
+ ...g,
213
+ ...o,
381
214
  L
382
- ], f = [], _ = 0, S;
215
+ ], p = [], v = 0, C;
383
216
  do {
384
- S = void 0;
385
- let e = _, a = [], w = l({
386
- model: d.languageModel,
387
- providerOptions: g && r.length && N.sha256 ? {
388
- ...d.providerOptions,
217
+ C = void 0;
218
+ let e = v, o = [], T = u({
219
+ model: f.languageModel,
220
+ providerOptions: _ && n.length && N.sha256 ? {
221
+ ...f.providerOptions,
389
222
  azure: {
390
- ...d.providerOptions?.azure,
223
+ ...f.providerOptions?.azure,
391
224
  promptCacheKey: N.sha256
392
225
  }
393
- } : d.providerOptions,
394
- instructions: m,
395
- messages: [...s, ...f],
396
- tools: p,
397
- stopWhen: u(k - e),
398
- abortSignal: n,
226
+ } : f.providerOptions,
227
+ instructions: h,
228
+ messages: [...c, ...p],
229
+ tools: m,
230
+ stopWhen: d(O - e),
231
+ abortSignal: r,
399
232
  onLanguageModelCallEnd: (e) => {
400
233
  y.push({
401
- ...x(e.usage),
402
- ...C(e.usage),
234
+ ...S(e.usage),
235
+ ...w(e.usage),
403
236
  responseTimeMs: e.performance.responseTimeMs,
404
237
  timeToFirstOutputMs: e.performance.timeToFirstOutputMs ?? null,
405
238
  finishReason: e.finishReason
406
239
  });
407
240
  },
408
241
  onStepEnd: (e) => {
409
- a.push(...e.response.messages), _++;
242
+ o.push(...e.response.messages), v++;
410
243
  },
411
244
  prepareStep: (n) => {
412
- o = e + n.stepNumber;
413
- let r = o === k - 1 ? { toolChoice: "none" } : {}, i = t.provider === "openai" || t.provider === "azure" && !t.chatCompletions ? t.provider : null;
245
+ s = e + n.stepNumber;
246
+ let r = s === O - 1 ? { toolChoice: "none" } : {}, i = t.provider === "openai" || t.provider === "azure" && !t.chatCompletions ? t.provider : null;
414
247
  if (!i || n.stepNumber === 0) return r;
415
- let a = n.steps.at(-1), s = a.providerMetadata?.[i]?.responseId;
416
- if (!s) throw Error("The previous model response has no continuation ID");
248
+ let a = n.steps.at(-1), o = a.providerMetadata?.[i]?.responseId;
249
+ if (!o) throw Error("The previous model response has no continuation ID");
417
250
  return {
418
251
  ...r,
419
252
  instructions: [],
420
253
  messages: a.response.messages.filter(({ role: e }) => e === "tool"),
421
254
  providerOptions: { [i]: {
422
- previousResponseId: s,
255
+ previousResponseId: o,
423
256
  store: !0
424
257
  } }
425
258
  };
426
259
  }
427
260
  });
428
- for await (let e of w.stream) if (e.type === "text-delta") b ??= performance.now() - c, i({
261
+ for await (let e of T.stream) if (e.type === "text-delta") b ??= performance.now() - i, a({
429
262
  type: "text",
430
263
  text: e.text
431
264
  });
432
- else if (e.type === "tool-input-start" || e.type === "tool-call") i({
265
+ else if (e.type === "tool-input-start" || e.type === "tool-call") a({
433
266
  type: "activity",
434
267
  text: e.toolName
435
268
  });
436
269
  else if (e.type === "error") {
437
- if (a.length > 0 && j(e.error)) {
438
- S = e.error;
270
+ if (o.length > 0 && A(e.error)) {
271
+ C = e.error;
439
272
  break;
440
273
  }
441
274
  throw e.error;
442
- } else e.type === "finish-step" ? (E.push(x(e.usage)), v.push(C(e.usage))) : e.type === "finish" ? (D = f.length ? void 0 : x(e.totalUsage), O = !0) : e.type === "abort" && (A = !0);
443
- S ? (console.log(`[planning-assistant] continuation rejected (${S.message}) - continuing with the whole history`), f.push(...a)) : !A && !n.aborted && h.push(L, ...f, ...await w.responseMessages);
444
- } while (S);
445
- i({ type: "done" });
275
+ } else e.type === "finish-step" ? (x.push(S(e.usage)), l.push(w(e.usage))) : e.type === "finish" ? (D = p.length ? void 0 : S(e.totalUsage), k = !0) : e.type === "abort" && (M = !0);
276
+ C ? (console.log(`[planning-assistant] continuation rejected (${C.message}) - continuing with the whole history`), p.push(...o)) : !M && !r.aborted && g.push(L, ...p, ...await T.responseMessages);
277
+ } while (C);
278
+ a({ type: "done" });
446
279
  } catch (e) {
447
- console.log("[planning-assistant]", String(e)), i({
280
+ console.log("[planning-assistant]", String(e)), a({
448
281
  type: "error",
449
282
  text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
450
283
  });
451
284
  } finally {
452
285
  let e = {
453
- inputTokens: D?.inputTokens ?? S(E.map((e) => e.inputTokens)),
454
- outputTokens: D?.outputTokens ?? S(E.map((e) => e.outputTokens)),
455
- totalTokens: D?.totalTokens ?? S(E.map((e) => e.totalTokens))
456
- }, r = Object.values(e).some((e) => e !== null), i = O && !A && !n.aborted && Object.values(e).every((e) => e !== null) && E.every((e) => Object.values(e).every((e) => e !== null));
286
+ inputTokens: D?.inputTokens ?? C(x.map((e) => e.inputTokens)),
287
+ outputTokens: D?.outputTokens ?? C(x.map((e) => e.outputTokens)),
288
+ totalTokens: D?.totalTokens ?? C(x.map((e) => e.totalTokens))
289
+ }, n = Object.values(e).some((e) => e !== null), a = k && !M && !r.aborted && Object.values(e).every((e) => e !== null) && x.every((e) => Object.values(e).every((e) => e !== null));
457
290
  console.log(`[planning-assistant] usage ${JSON.stringify({
458
291
  provider: t.provider,
459
292
  model: t.model,
460
- status: r ? i ? "complete" : "partial" : "unavailable",
293
+ status: n ? a ? "complete" : "partial" : "unavailable",
461
294
  ...e,
462
295
  diagnostics: {
463
296
  version: 1,
464
- details: w(v),
297
+ details: T(l),
465
298
  modelCalls: y,
466
- requests: a,
299
+ requests: o,
467
300
  reference: N,
468
- planState: P,
301
+ planState: F,
469
302
  referenceAcquisitionMs: I,
470
303
  firstTextMs: b,
471
- turnMs: performance.now() - c
304
+ turnMs: performance.now() - i
472
305
  }
473
306
  })}`);
474
307
  }
475
- }, r.getExternalObjectLibraryContext && v(), i({
308
+ }, i.getExternalObjectLibraryContext && y(), a({
476
309
  type: "images",
477
310
  enabled: t.readsImages
478
- }), i({
311
+ }), a({
479
312
  type: "availability",
480
313
  available: !0
481
314
  });
482
- }, V = {
315
+ }, I = {
483
316
  HIDE: "hide",
484
317
  SHOW_ATTRIBUTES: "attributes",
485
318
  SHOW_ARTICLES: "articles"
486
319
  };
487
320
  //#endregion
488
- export { V as HI_PANEL_ACTION, _ as cleanupHi, d as createHiLibraryCallbacks, y as createHiMcpTools, c as libLoadArticleCatalog, u as libLoadCalcScript, l as libLoadMasterData, z as loadChatModel, p as omGetRequest, f as omPostRequest, a as registerLegacyUrlFormat, g as setupHi, B as startPlanningAssistant, o as unregisterLegacyUrlFormat };
321
+ export { I as HI_PANEL_ACTION, y as cleanupHi, p as createHiLibraryCallbacks, b as createHiMcpTools, u as libLoadArticleCatalog, f as libLoadCalcScript, d as libLoadMasterData, n as loadChatModel, h as omGetRequest, m as omPostRequest, s as registerLegacyUrlFormat, v as setupHi, F as startPlanningAssistant, c as unregisterLegacyUrlFormat };