@roomle/embedding-lib 11.0.0-alpha.12 → 11.0.0-alpha.14

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 (42) hide show
  1. package/THIRD-PARTY-NOTICES.txt +2 -2
  2. package/ai-model-host-CaiYrZkh.mjs +152 -0
  3. package/ai-model-host-HAJONHCj.mjs +156 -0
  4. package/ai.js +1 -128
  5. package/ai.min.js +1 -127
  6. package/chat-model-DooKwd8I.mjs +117 -0
  7. package/chat-model-KHuz1Ej9.mjs +118 -0
  8. package/configurator.js +2 -2
  9. package/configurator.min.js +2 -2
  10. package/construction.js +17718 -162
  11. package/construction.min.js +17397 -177
  12. package/docs/md/web/embedding/CHANGELOG.md +4 -4
  13. package/hi.js +91 -393
  14. package/hi.min.js +88 -351
  15. package/{mcp-tools-BLB7pCga.mjs → mcp-tools-C6O2gQZW.mjs} +0 -1
  16. package/{mcp-tools-BirFT2R0.mjs → mcp-tools-m_3IX0vB.mjs} +0 -1
  17. package/package.json +1 -1
  18. package/packages/common/src/utils/ai-model-relay.d.ts +1 -1
  19. package/packages/embedding-lib/src/ai-model-host.d.ts +36 -0
  20. package/packages/embedding-lib/src/ai.d.ts +11 -27
  21. package/packages/embedding-lib/src/hi.d.ts +1 -0
  22. package/packages/embedding-lib/src/homag-intelligence/decisions.d.ts +7 -0
  23. package/packages/embedding-lib/src/homag-intelligence/hi-model-proxy.d.ts +4 -1
  24. package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +9 -19
  25. package/packages/web-sdk/packages/assistant.d.ts +2 -1
  26. package/packages/web-sdk/packages/common-core/src/planning-assistant/chat-recovery.d.ts +5 -1
  27. package/packages/web-sdk/packages/common-core/src/planning-assistant/continuation.d.ts +5 -3
  28. package/packages/web-sdk/packages/common-core/src/planning-assistant/usage.d.ts +31 -0
  29. package/roomle-embedding-lib.js +37 -37
  30. package/roomle-embedding-lib.min.js +30 -30
  31. package/sbom.cdx.json +5 -5
  32. package/usage-C3HE9yXi.mjs +33 -0
  33. package/usage-CYqDPQOx.mjs +34 -0
  34. package/chat-model-B7BO8IhK.mjs +0 -212
  35. package/chat-model-XYf503pT.mjs +0 -213
  36. package/continuation-CswXtOus.mjs +0 -10
  37. package/continuation-NclHDSgS.mjs +0 -9
  38. package/dist-BZSd56sr.mjs +0 -17422
  39. package/dist-S9sLSjZ4.mjs +0 -17087
  40. package/packages/embedding-lib/src/homag-intelligence/hi-planning-usage.d.ts +0 -54
  41. package/turn-limits-9LbUeSG2.mjs +0 -9
  42. package/turn-limits-Ciq383Bd.mjs +0 -10
@@ -1,5 +1,5 @@
1
- ## 11.0.0-alpha.12 (2026-11-24)
1
+ ## 11.0.0-alpha.14 (2026-11-25)
2
2
 
3
- * Merge branch 'master' into release/test ([0fcf2ec](https://github.com/roomle-dev/roomle-ui/commit/0fcf2ec))
4
- * Merge pull request #3471 from roomle-dev/fix/cubemap-light-source-detection ([e990cdc](https://github.com/roomle-dev/roomle-ui/commit/e990cdc)), closes [#3471](https://github.com/roomle-dev/roomle-ui/issues/3471)
5
- * fix: light source detection for cubemap environment maps ([8d55e05](https://github.com/roomle-dev/roomle-ui/commit/8d55e05))
3
+ * Merge branch 'master' into release/test ([8f27abd](https://github.com/roomle-dev/roomle-ui/commit/8f27abd))
4
+ * Merge pull request #3480 from roomle-dev/upgraded-by-ci/core-3.4.0-alpha.10 ([25a9aac](https://github.com/roomle-dev/roomle-ui/commit/25a9aac)), closes [#3480](https://github.com/roomle-dev/roomle-ui/issues/3480)
5
+ * feat(core): upgrade to version 3.4.0-alpha.10 ([1736bba](https://github.com/roomle-dev/roomle-ui/commit/1736bba))
package/hi.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
2
2
  import { t as e } from "./utils-CJnKZceY.mjs";
3
3
  import { t } from "./browser-Cys-y5Hy.mjs";
4
- import { t as n } from "./mcp-tools-BLB7pCga.mjs";
5
- import { a as r, r as i } from "./turn-limits-Ciq383Bd.mjs";
6
- import { n as a } from "./chat-model-XYf503pT.mjs";
7
- import { n as o } from "./continuation-CswXtOus.mjs";
4
+ import { t as n } from "./chat-model-KHuz1Ej9.mjs";
5
+ import { t as r } from "./mcp-tools-C6O2gQZW.mjs";
6
+ import { n as i, t as a } from "./ai-model-host-HAJONHCj.mjs";
7
+ import { o } from "./usage-CYqDPQOx.mjs";
8
8
  var s = (e, t) => t === e.libraryId ? e : {
9
9
  ...e,
10
10
  libraryId: t
@@ -69,427 +69,97 @@ var s = (e, t) => t === e.libraryId ? e : {
69
69
  x &&= (window.removeEventListener("message", x), null);
70
70
  }, w = async ({ extended: e }) => {
71
71
  if (typeof e.getExternalObjectAgentTools != "function") throw Error("The planner has no HI agent tools: it needs a Rubens UI with getExternalObjectAgentTools.");
72
- return n(await e.getExternalObjectAgentTools(), (t, n) => e.callExternalObjectAgentTool(t, n), "hi-mcp");
73
- }, T = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : null, E = (e = {}) => ({
74
- inputTokens: T(e.inputTokens),
75
- outputTokens: T(e.outputTokens),
76
- totalTokens: T(e.totalTokens) ?? (T(e.inputTokens) !== null && T(e.outputTokens) !== null ? e.inputTokens + e.outputTokens : null)
77
- }), D = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, O = (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 = T(n?.cached_tokens ?? t?.cache_read_input_tokens), a = T(n?.cache_write_tokens ?? t?.cache_creation_input_tokens), o = (e, t) => t ?? (T(e) !== null && Number(e) > 0 ? Number(e) : null);
72
+ return r(await e.getExternalObjectAgentTools(), (t, n) => e.callExternalObjectAgentTool(t, n), "hi-mcp");
73
+ }, T = (e) => {
74
+ let t = o(e);
79
75
  return {
80
- cacheReadTokens: o(e.inputTokenDetails?.cacheReadTokens, i),
81
- cacheWriteTokens: o(e.inputTokenDetails?.cacheWriteTokens, a),
82
- noCacheTokens: i !== null && a !== null ? T(e.inputTokenDetails?.noCacheTokens) : null,
83
- reasoningTokens: o(e.outputTokenDetails?.reasoningTokens, T(r?.reasoning_tokens)),
84
- rawUsageAvailable: t !== void 0
76
+ provider: "host",
77
+ model: e.model,
78
+ readsImages: e.readsImages,
79
+ ...t && { responsesProvider: t },
80
+ ...e.provider === "azure" && !e.chatCompletions && e.referenceCacheBreakpoint === !0 && { referenceCacheBreakpoint: !0 },
81
+ ...e.decisionApiKey && { decisionApiKey: e.decisionApiKey }
85
82
  };
86
- }, k = (e) => Object.fromEntries([
87
- "cacheReadTokens",
88
- "cacheWriteTokens",
89
- "noCacheTokens",
90
- "reasoningTokens"
91
- ].map((t) => {
92
- let n = e.map((e) => e[t]), r = n.filter((e) => e !== null).length;
93
- return [t, {
94
- tokens: D(n),
95
- status: r === 0 ? "unavailable" : r === e.length ? "complete" : "partial",
96
- reportedSteps: r,
97
- observedSteps: e.length
98
- }];
99
- })), A = async (e) => {
100
- let t = new TextEncoder().encode(e), n = await globalThis.crypto?.subtle?.digest("SHA-256", t);
101
- return {
102
- bytes: t.byteLength,
103
- sha256: n ? Array.from(new Uint8Array(n), (e) => e.toString(16).padStart(2, "0")).join("") : null
83
+ }, E = async (e, t, n) => {
84
+ let r = e.extended, o = async (e) => {
85
+ console.log("[planning-assistant]", e), await r.planningAssistantOutput({
86
+ type: "availability",
87
+ available: !1,
88
+ text: e
89
+ });
104
90
  };
105
- }, j = async (e, t) => {
106
- let n = await A(e), r = JSON.parse(e);
107
- if (!Array.isArray(r.input)) return n;
108
- let i = 0, a = 0;
109
- for (let e of r.input) {
110
- let n = await A(JSON.stringify(e));
111
- i += n.bytes, n.sha256 === null ? a = null : (t.has(n.sha256) && a !== null && (a += n.bytes), t.add(n.sha256));
91
+ if (typeof r.startExternalObjectPlanningAssistant != "function") {
92
+ await o("The planner has no HI Planning Assistant: it needs a Rubens UI with startExternalObjectPlanningAssistant.");
93
+ return;
112
94
  }
113
- let o = r.tools ? new TextEncoder().encode(JSON.stringify(r.tools)).length : 0;
114
- return {
115
- ...n,
116
- sections: {
117
- inputBytes: i,
118
- newInputBytes: a === null ? null : i - a,
119
- repeatedInputBytes: a,
120
- toolsBytes: o,
121
- otherBytes: n.bytes - i - o
122
- }
95
+ if (n.aborted) return;
96
+ let s = crypto.randomUUID(), { startRelay: c, ui: l } = e, u = c && l ? e : void 0, d = async () => {
97
+ u && await i(u, t);
123
98
  };
124
- }, M = (e) => {
125
- let t = [e?.present.length ? `- Confirmed: ${e.present.join(", ")}` : "", e?.absent.length ? `- Not present / false: ${e.absent.join(", ")}` : ""].filter(Boolean);
126
- return t.length === 0 ? "" : `Observed in the photo (high-confidence cues; verify against the image):\n\n${t.join("\n")}`;
127
- }, ee = (e, t) => {
128
- let n = M(t);
129
- return n ? `${e.replace(/\n*$/, "\n")}\n---\n\n${n}` : e;
130
- }, N = /^(Previous response with id '[^']*' not found|No tool output found for function call )/, te = (e) => e instanceof Error && N.test(e.message), ne = (e) => e.role !== "assistant" || typeof e.content == "string" ? e : {
131
- ...e,
132
- content: e.content.map((e) => (e.type === "text" || e.type === "reasoning") && e.providerOptions ? {
133
- ...e,
134
- providerOptions: Object.fromEntries(Object.entries(e.providerOptions).map(([e, t]) => [e, Object.fromEntries(Object.entries(t).filter(([e]) => e !== "itemId"))]))
135
- } : e)
136
- }, re = [
137
- "rooms",
138
- "groups",
139
- "obstacles",
140
- "installationElements"
141
- ], P = 500, F = 240, I = 1500, L = ({ content: e }) => e.filter((e) => e.type === "text").map((e) => e.text).join("\n"), R = async (e, t, n) => {
142
- let s = e.extended, c = !1, l = !1, u = crypto.randomUUID(), d, f, p = n, m = (e) => !c && !p.aborted ? s.planningAssistantOutput(e) : void 0, h = [], g = null, _ = /* @__PURE__ */ new Set(), v;
143
99
  try {
144
- v = await Promise.all([
145
- import("./dist-BZSd56sr.mjs").then((e) => e.t),
146
- a(t, async (e) => {
147
- h.push({
148
- ...await j(e, _),
149
- stepNumber: g
150
- });
151
- }),
152
- s.getExternalObjectAgentPrompts(),
153
- w(e)
154
- ]);
100
+ let e = u ? await a(u, t) : t;
101
+ await r.startExternalObjectPlanningAssistant(T({
102
+ ...e,
103
+ decisionApiKey: t.decisionApiKey
104
+ }), s);
155
105
  } catch (e) {
156
- console.log("[planning-assistant]", String(e)), m({
157
- type: "availability",
158
- available: !1,
159
- text: String(e)
160
- });
106
+ await o(String(e)), await d();
161
107
  return;
162
108
  }
163
- let [{ streamText: y, stepCountIs: b }, x, S, C] = v, T = [S.systemPrompt, ...(S.referenceBlocks ?? []).map(({ id: e, text: t }) => `Reference: ${e}\n${t}`)].join("\n\n"), N = [], R = t.provider === "azure" && !t.chatCompletions && t.referenceCacheBreakpoint === !0, z = o(t), B = null, V = 0, H = [], U = /* @__PURE__ */ new Set(), W = !1, G = async (e, n, r, i) => {
164
- let a = performance.now();
165
- if (W || !s.getExternalObjectAgentDecisions) return null;
166
- let o;
167
- try {
168
- let c = s.getExternalObjectAgentDecisions({
169
- text: e,
170
- images: n,
171
- earlier: r,
172
- ...t.decisionApiKey && { apiKey: t.decisionApiKey },
173
- ...i.length > 0 && { held: i }
174
- }).then((e) => (e?.refused && (W = !0), e), () => null), l = await Promise.race([c, new Promise((e) => {
175
- o = setTimeout(() => e("late"), I);
176
- })]);
177
- return {
178
- ms: performance.now() - a,
179
- decisions: l === "late" ? null : l,
180
- late: l === "late"
181
- };
182
- } finally {
183
- clearTimeout(o);
184
- }
185
- }, K = () => new Set(N.flatMap((e) => e.role === "assistant" && Array.isArray(e.content) ? e.content.flatMap((e) => {
186
- let t = e.type === "tool-call" && e.toolName === "get-skill" ? e.input : void 0;
187
- return t && t.file === void 0 ? [String(t.name)] : [];
188
- }) : [])), ie = async (e) => {
189
- let t = K();
190
- return (await Promise.all(e.filter((e) => !U.has(e) && !t.has(e)).map(async (e) => {
191
- try {
192
- let t = await C["get-skill"].execute({ name: e });
193
- return t.isError ? null : {
194
- name: e,
195
- text: L(t)
196
- };
197
- } catch {
198
- return null;
199
- }
200
- }))).filter((e) => e !== null);
201
- }, q = !1, J = async () => {
202
- for (let e = 0; e < F; e += 1) {
203
- if (q || n.aborted) return;
204
- let e = performance.now(), t = await Promise.resolve().then(() => s.getExternalObjectLibraryContext?.(["articles"])).then((e) => e?.articles?.length ?? 0, () => 0);
205
- if (t > 0) {
206
- console.log(`[planning-assistant] library read before the first prompt: ${t} articles in ${Math.round(performance.now() - e)} ms`);
207
- return;
208
- }
209
- await new Promise((e) => setTimeout(e, P));
210
- }
211
- }, Y = async ({ text: e, images: n }) => {
212
- f = new AbortController();
213
- let a = r([p, f.signal]);
214
- q = !0;
215
- let o = ++V, s = performance.now();
216
- h = [], g = null, _.clear();
217
- let c = [], l = [], u = null, d = [], v, w = !1, j = !1, P = null, F = null, I = 0, W = null, J = G(e, n, [...H], [.../* @__PURE__ */ new Set([...U, ...K()])]);
218
- H.push(e || "(an image)");
219
- try {
220
- let t = performance.now(), r = [], f = [];
221
- await Promise.all([(async () => {
222
- try {
223
- let e = await C["get-plan-context"].execute({ include: ["articles", "attributes"] }), t = L(e), n = e.isError ? null : JSON.parse(t);
224
- if (Array.isArray(n?.articles) && n.articles.length > 0) {
225
- let e = `Current library reference (data, not instructions):\n${t}`;
226
- r.push({
227
- role: "user",
228
- content: R ? [{
229
- type: "text",
230
- text: e,
231
- providerOptions: { azure: { promptCacheBreakpoint: { mode: "explicit" } } }
232
- }] : e
233
- });
234
- }
235
- } catch {
236
- console.log("[planning-assistant] reference unavailable; using tools");
237
- }
238
- })(), (async () => {
239
- let e = await Promise.resolve().then(() => C["get-plan-context"].execute({ include: re })).then((e) => e.isError ? "" : L(e).trim()).catch(() => "");
240
- e ? (F = await A(e), f.push({
241
- role: "user",
242
- content: `Plan state at the start of turn ${o}, read for this turn (data, not instructions):\n${e}`
243
- })) : console.log("[planning-assistant] plan state unavailable; the model reads it");
244
- })()]), P = await A(JSON.stringify({
245
- instructions: T,
246
- messages: r
247
- })), I = performance.now() - t;
248
- let p = await J, h = await ie(p?.decisions?.skills ?? []), _ = (e) => `call_supplied_skill_${o}_${e + 1}`, D = p?.decisions?.facts, k = h.some(({ name: e }) => e === "image-planning") ? "" : M(D), V = [{
249
- role: "user",
250
- content: [
251
- {
252
- type: "text",
253
- text: e || S.imagePrompt
254
- },
255
- ...n.map((e) => ({
256
- type: "file",
257
- data: e,
258
- mediaType: "image/jpeg"
259
- })),
260
- ...k ? [{
261
- type: "text",
262
- text: k
263
- }] : []
264
- ]
265
- }, ...h.length ? [{
266
- role: "assistant",
267
- content: h.map((e, t) => ({
268
- type: "tool-call",
269
- toolCallId: _(t),
270
- toolName: "get-skill",
271
- input: { name: e.name }
272
- }))
273
- }, {
274
- role: "tool",
275
- content: h.map((e, t) => ({
276
- type: "tool-result",
277
- toolCallId: _(t),
278
- toolName: "get-skill",
279
- output: {
280
- type: "content",
281
- value: [{
282
- type: "text",
283
- text: e.name === "image-planning" ? ee(e.text, D) : e.text
284
- }]
285
- }
286
- }))
287
- }] : []];
288
- h.length > 0 && m({
289
- type: "activity",
290
- text: h.map(({ name: e }) => e).join(", ")
291
- }), W = p && {
292
- ms: p.ms,
293
- late: p.late,
294
- answers: p.decisions?.answers ?? null,
295
- ...D && { facts: D },
296
- refused: p.decisions?.refused ?? !1,
297
- skipped: p.decisions?.skipped ?? !1,
298
- supplied: h.map(({ name: e }) => e)
299
- };
300
- let H = [
301
- ...r,
302
- ...N,
303
- ...f,
304
- ...V
305
- ], G = B && f.length > 0 && P.sha256 === B.reference ? B.responseId : void 0, K, q = [], Y = 0, X, Z = !1;
306
- do {
307
- X = void 0;
308
- let e = Y, t = G, n = [], o = y({
309
- model: x.languageModel,
310
- providerOptions: R && r.length && P.sha256 ? {
311
- ...x.providerOptions,
312
- azure: {
313
- ...x.providerOptions?.azure,
314
- promptCacheKey: P.sha256
315
- }
316
- } : x.providerOptions,
317
- instructions: T,
318
- messages: Z ? [...H, ...q].map(ne) : [...H, ...q],
319
- tools: C,
320
- stopWhen: b(32 - e),
321
- abortSignal: a,
322
- onLanguageModelCallEnd: (e) => {
323
- l.push({
324
- ...E(e.usage),
325
- ...O(e.usage),
326
- responseTimeMs: e.performance.responseTimeMs,
327
- timeToFirstOutputMs: e.performance.timeToFirstOutputMs ?? null,
328
- finishReason: e.finishReason
329
- });
330
- },
331
- onStepEnd: (e) => {
332
- n.push(...e.response.messages), Y++, K = z ? e.providerMetadata?.[z]?.responseId ?? void 0 : void 0;
333
- },
334
- prepareStep: (n) => {
335
- g = e + n.stepNumber;
336
- let r = i(g, T);
337
- if (!z) return r;
338
- if (n.stepNumber === 0) return t ? {
339
- instructions: [],
340
- ...i(g),
341
- messages: [...f, ...V],
342
- providerOptions: { [z]: {
343
- previousResponseId: t,
344
- store: !0
345
- } }
346
- } : r;
347
- let a = n.steps.at(-1), o = a.providerMetadata?.[z]?.responseId;
348
- if (!o) throw Error("The previous model response has no continuation ID");
349
- return {
350
- instructions: [],
351
- ...i(g),
352
- messages: a.response.messages.filter(({ role: e }) => e === "tool"),
353
- providerOptions: { [z]: {
354
- previousResponseId: o,
355
- store: !0
356
- } }
357
- };
358
- }
359
- });
360
- for await (let e of o.stream) if (e.type === "text-delta") u ??= performance.now() - s, m({
361
- type: "text",
362
- text: e.text
363
- });
364
- else if (e.type === "tool-input-start" || e.type === "tool-call") m({
365
- type: "activity",
366
- text: e.toolName
367
- });
368
- else if (e.type === "error") {
369
- if ((n.length > 0 || t) && te(e.error)) {
370
- X = e.error;
371
- break;
372
- }
373
- throw e.error;
374
- } else e.type === "finish-step" ? (d.push(E(e.usage)), c.push(O(e.usage))) : e.type === "finish" ? (v = q.length ? void 0 : E(e.totalUsage), w = !0) : e.type === "abort" && (j = !0);
375
- X ? (console.log(`[planning-assistant] continuation rejected (${X.message}) - continuing with the whole history`), q.push(...n), G = void 0, Z = !0) : !j && !a.aborted && (N.push(...V, ...q, ...await o.responseMessages), h.forEach(({ name: e }) => U.add(e)), B = K && P.sha256 ? {
376
- responseId: K,
377
- reference: P.sha256
378
- } : null);
379
- } while (X);
380
- m({ type: "done" });
381
- } catch (e) {
382
- console.log("[planning-assistant]", String(e)), m({
383
- type: "error",
384
- text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
385
- });
386
- } finally {
387
- let e = {
388
- inputTokens: v?.inputTokens ?? D(d.map((e) => e.inputTokens)),
389
- outputTokens: v?.outputTokens ?? D(d.map((e) => e.outputTokens)),
390
- totalTokens: v?.totalTokens ?? D(d.map((e) => e.totalTokens))
391
- }, n = Object.values(e).some((e) => e !== null), r = w && !j && !a.aborted && Object.values(e).every((e) => e !== null) && d.every((e) => Object.values(e).every((e) => e !== null));
392
- console.log(`[planning-assistant] usage ${JSON.stringify({
393
- provider: t.provider,
394
- model: t.model,
395
- status: n ? r ? "complete" : "partial" : "unavailable",
396
- ...e,
397
- diagnostics: {
398
- version: 1,
399
- details: k(c),
400
- modelCalls: l,
401
- requests: h,
402
- reference: P,
403
- planState: F,
404
- decisions: W,
405
- referenceAcquisitionMs: I,
406
- firstTextMs: u,
407
- turnMs: performance.now() - s
408
- }
409
- })}`);
410
- }
411
- }, X = async (e) => {
412
- if (c || p.aborted) throw Error("The planning assistant is suspended.");
413
- if (d) throw Error("An assistant turn is already running.");
414
- d = Y(e);
415
- try {
416
- await d;
417
- } finally {
418
- d = void 0, f = void 0;
419
- }
420
- };
421
- s.callbacks.onPlanningAssistantPrompt = X;
422
- let Z = async (e) => {
423
- e === "isolation" ? (c = !0, f?.abort(/* @__PURE__ */ Error("The assistant changed mode.")), d && await Promise.allSettled([d]), await s.planningAssistantOutput({
424
- type: "availability",
425
- available: !1
426
- })) : !p.aborted && !l && (c = !1, m({
427
- type: "images",
428
- enabled: t.readsImages
429
- }), m({
430
- type: "availability",
431
- available: !0
432
- }));
433
- };
434
- s.callbacks.onPlanningAssistantModeChange = Z;
435
- let ae = async () => {
436
- l = !0, c = !0, f?.abort(/* @__PURE__ */ Error("The planning assistant stopped.")), d && await Promise.allSettled([d]), await s.stopPlanningAssistant?.(u), s.callbacks.onPlanningAssistantPrompt === X && (s.callbacks.onPlanningAssistantPrompt = void 0, await s.planningAssistantOutput({
437
- type: "availability",
438
- available: !1
439
- })), s.callbacks.onPlanningAssistantModeChange === Z && (s.callbacks.onPlanningAssistantModeChange = void 0), p.removeEventListener("abort", $);
440
- }, oe, Q = () => oe ??= ae(), $ = () => {
441
- Q();
442
- };
443
- if (p.addEventListener("abort", $, { once: !0 }), p.aborted) await Q();
444
- else return await s.setPlanningAssistantModel?.({
445
- model: t.model,
446
- readsImages: t.readsImages,
447
- responsesProvider: o(t) ?? void 0
448
- }, u), s.getExternalObjectLibraryContext && J(), m({
449
- type: "images",
450
- enabled: t.readsImages
451
- }), m({
452
- type: "availability",
453
- available: !0
454
- }), {
455
- suspend: () => Z("isolation"),
456
- resume: () => Z("planner"),
457
- dispose: Q
109
+ let f, p = () => {
110
+ m();
111
+ }, m = () => f ??= (async () => {
112
+ n.removeEventListener("abort", p), await r.stopPlanningAssistant?.(s), await d();
113
+ })();
114
+ if (n.addEventListener("abort", p, { once: !0 }), n.aborted) await m();
115
+ else return {
116
+ suspend: async () => {
117
+ f || await r.suspendPlanningAssistant?.();
118
+ },
119
+ resume: async () => {
120
+ f || await r.resumePlanningAssistant?.();
121
+ },
122
+ dispose: m
458
123
  };
459
- }, z = 5e3, B = async ({ serverUrl: e, authorization: t }) => {
124
+ }, D = 5e3, O = async ({ serverUrl: e, authorization: t }) => {
460
125
  let n = t ? { Authorization: t } : {}, r;
461
126
  try {
462
127
  let t = await fetch(`${e}/backends/list`, {
463
128
  headers: n,
464
- signal: AbortSignal.timeout(z)
129
+ signal: AbortSignal.timeout(D)
465
130
  });
466
131
  r = t.ok ? await t.json() : [];
467
132
  } catch (e) {
468
133
  return console.warn("No HI model proxy: the backend list failed", e), {};
469
134
  }
470
135
  if (!Array.isArray(r) || r.length !== 1) return {};
471
- let [{ enableAIPlanning: i, enableAIRendering: a }] = r, o = `${e}/api/ai/v1`;
136
+ let [{ enableAIPlanning: i, enableAIRendering: a, enableAIDecisions: o }] = r, s = `${e}/api/ai/v1`;
472
137
  return {
473
138
  ...i === !0 && { chat: {
474
139
  provider: "openai-compatible",
475
- baseUrl: o,
140
+ baseUrl: s,
476
141
  model: "planning",
477
142
  headers: n,
478
143
  responses: !0,
479
144
  readsImages: !0
480
145
  } },
481
146
  ...a === !0 && { rendering: {
482
- baseUrl: o,
147
+ baseUrl: s,
483
148
  model: "rendering",
484
149
  headers: n
150
+ } },
151
+ ...o === !0 && { decisions: {
152
+ baseUrl: s,
153
+ model: "decision",
154
+ headers: n
485
155
  } }
486
156
  };
487
- }, V = (e = "1:1") => {
157
+ }, k = (e = "1:1") => {
488
158
  let [t, n] = e.split(":").map(Number);
489
159
  return t === n ? "1024x1024" : t > n ? "1536x1024" : "1024x1536";
490
- }, H = async (e) => (await fetch(e)).blob(), U = async (e, t, { baseUrl: n, model: r, headers: i }) => {
491
- let { prompt: a, image: o, aspect: s } = JSON.parse(e.body), c = await H(o), l = new FormData();
492
- l.append("model", r), l.append("prompt", a), l.append("size", V(s)), l.append("quality", "medium"), l.append("output_format", "png"), l.append("image", c, `scene.${c.type.split("/")[1]}`);
160
+ }, A = async (e) => (await fetch(e)).blob(), j = async (e, t, { baseUrl: n, model: r, headers: i }) => {
161
+ let { prompt: a, image: o, aspect: s } = JSON.parse(e.body), c = await A(o), l = new FormData();
162
+ l.append("model", r), l.append("prompt", a), l.append("size", k(s)), l.append("quality", "medium"), l.append("output_format", "png"), l.append("image", c, `scene.${c.type.split("/")[1]}`);
493
163
  let u = await fetch(`${n}/images/edits`, {
494
164
  method: "POST",
495
165
  headers: i,
@@ -498,10 +168,38 @@ var s = (e, t) => t === e.libraryId ? e : {
498
168
  });
499
169
  if (!u.ok) return u;
500
170
  let { data: d } = await u.json(), f = d?.[0]?.b64_json, p = new FormData();
501
- return f ? p.append("image", await H(`data:image/png;base64,${f}`)) : p.append("text", "The endpoint returned no image"), new Response(p);
502
- }, W = {
171
+ return f ? p.append("image", await A(`data:image/png;base64,${f}`)) : p.append("text", "The endpoint returned no image"), new Response(p);
172
+ }, M = {
173
+ png: "image/png",
174
+ jpg: "image/jpeg"
175
+ }, N = (e, t, { baseUrl: n, model: r, headers: i }) => {
176
+ let { state: a, questions: o, assets: s = {} } = JSON.parse(e.body);
177
+ return fetch(`${n}/decisions`, {
178
+ method: "POST",
179
+ headers: {
180
+ ...i,
181
+ "Content-Type": "application/json"
182
+ },
183
+ body: JSON.stringify({
184
+ model: r,
185
+ input: [{
186
+ type: "text",
187
+ text: JSON.stringify(a)
188
+ }, ...Object.entries(s).flatMap(([e, t]) => [{
189
+ type: "text",
190
+ text: e
191
+ }, {
192
+ type: "image",
193
+ data: t.data_base64,
194
+ mime_type: M[t.format]
195
+ }])],
196
+ questions: o
197
+ }),
198
+ signal: t
199
+ });
200
+ }, P = {
503
201
  HIDE: "hide",
504
202
  SHOW_ATTRIBUTES: "attributes",
505
203
  SHOW_ARTICLES: "articles"
506
204
  };
507
- export { W as HI_PANEL_ACTION, C as cleanupHi, g as createHiLibraryCallbacks, w as createHiMcpTools, p as libLoadArticleCatalog, h as libLoadCalcScript, m as libLoadMasterData, a as loadChatModel, y as omGetRequest, v as omPostRequest, u as registerLegacyUrlFormat, U as requestImageEdits, B as resolveHiModelProxy, S as setupHi, R as startPlanningAssistant, d as unregisterLegacyUrlFormat };
205
+ export { P as HI_PANEL_ACTION, C as cleanupHi, g as createHiLibraryCallbacks, w as createHiMcpTools, p as libLoadArticleCatalog, h as libLoadCalcScript, m as libLoadMasterData, n as loadChatModel, y as omGetRequest, v as omPostRequest, u as registerLegacyUrlFormat, N as requestDecisions, j as requestImageEdits, O as resolveHiModelProxy, S as setupHi, E as startPlanningAssistant, d as unregisterLegacyUrlFormat };