@roomle/embedding-lib 11.0.0-alpha.6 → 11.0.0-alpha.8

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 (69) hide show
  1. package/THIRD-PARTY-NOTICES.txt +1 -1
  2. package/ai.js +6 -6
  3. package/ai.min.js +5 -4
  4. package/{browser-D6M-d6y5.mjs → browser-Cys-y5Hy.mjs} +1 -2
  5. package/chat-model-B7BO8IhK.mjs +212 -0
  6. package/chat-model-XYf503pT.mjs +213 -0
  7. package/coerce-CuLRCRlo.mjs +6 -0
  8. package/coerce-Dup0o-HR.mjs +7 -0
  9. package/{comlink-CG3f9q6z.mjs → comlink-7u13Z2ZH.mjs} +2 -3
  10. package/{comlink-hSUzCx9j.mjs → comlink-DKhvPU0o.mjs} +1 -1
  11. package/configurator.js +3 -4
  12. package/configurator.min.js +2 -2
  13. package/construction.js +278 -24
  14. package/construction.min.js +284 -27
  15. package/continuation-CswXtOus.mjs +10 -0
  16. package/continuation-NclHDSgS.mjs +9 -0
  17. package/{dist-Cm3aF4sf.mjs → dist-7-X7Xqsl.mjs} +851 -919
  18. package/{dist-BQaw78-_.mjs → dist-BMxyw-Zs.mjs} +411 -405
  19. package/{dist-0WZWTj8T.mjs → dist-BU022PnG.mjs} +4 -9
  20. package/{dist-DkR6G9Kj.mjs → dist-BY8OLJ2p.mjs} +1 -1
  21. package/{dist-6TznX-Ae.mjs → dist-BZSd56sr.mjs} +3850 -3942
  22. package/{dist-70R0b5Mq.mjs → dist-Ba3J8AjB.mjs} +400 -390
  23. package/{dist-CTS0DDwt.mjs → dist-CbQKC1xX.mjs} +1590 -1616
  24. package/{dist-BmOBP9h9.mjs → dist-CiybWJvs.mjs} +44 -41
  25. package/{dist-CPG4atmb.mjs → dist-CkZuNdCU.mjs} +6 -4
  26. package/{dist-Bt1FopV4.mjs → dist-D2ZAAHGn.mjs} +1058 -1042
  27. package/{dist-BWNv7qW9.mjs → dist-DjsS42rR.mjs} +916 -962
  28. package/{dist-9UI7dzwc.mjs → dist-Jcq_kKKT.mjs} +403 -393
  29. package/{dist-D0XFfKEL.mjs → dist-S9sLSjZ4.mjs} +3112 -3104
  30. package/{dist-BV-32IEX.mjs → dist-XECXrV5Q.mjs} +1497 -1558
  31. package/{dist-Bc2s-kJZ.mjs → dist-a5_BIeaS.mjs} +45 -51
  32. package/{dist-Crrp-Bno.mjs → dist-bQAJDeYc.mjs} +698 -748
  33. package/docs/md/web/embedding/CHANGELOG.md +19 -64
  34. package/{drag-ghost-BpIDzSdK.mjs → drag-ghost-QZelgA-_.mjs} +2 -3
  35. package/{drag-ghost-Bhb0_67G.mjs → drag-ghost-VmgSWLva.mjs} +5 -7
  36. package/{drag-in-mE_ozj_Q.mjs → drag-in-Cd_67tzS.mjs} +4 -5
  37. package/{drag-in-CGBG4wEk.mjs → drag-in-DlDsgY4T.mjs} +3 -3
  38. package/embedding-plugins.js +1 -2
  39. package/embedding-plugins.min.js +1 -2
  40. package/{experimental-evaluation-FzKFGoye.mjs → experimental-evaluation-B4hKMgFH.mjs} +19 -38
  41. package/{experimental-evaluation-DczxmJme.mjs → experimental-evaluation-DmqghFSx.mjs} +1 -1
  42. package/{from-custom-view-B3fIWMox.mjs → from-custom-view-6HMD_sPe.mjs} +5 -4
  43. package/{from-custom-view-B3HCOhdT.mjs → from-custom-view-BRFynafo.mjs} +16 -16
  44. package/{from-website-DaTahmvJ.mjs → from-website-Dl1VN4h7.mjs} +5 -6
  45. package/{from-website-DUQ9USj1.mjs → from-website-iZzauH4C.mjs} +3 -3
  46. package/hi.js +188 -197
  47. package/hi.min.js +193 -194
  48. package/mcp-tools-BLB7pCga.mjs +42 -0
  49. package/mcp-tools-BirFT2R0.mjs +41 -0
  50. package/package.json +1 -1
  51. package/packages/web-sdk/packages/assistant.d.ts +1 -0
  52. package/packages/web-sdk/packages/common-core/src/planning-assistant/runtime.d.ts +4 -1
  53. package/packages/web-sdk/packages/common-core/src/planning-assistant.d.ts +3 -0
  54. package/rolldown-runtime--db92txo.mjs +10 -0
  55. package/rolldown-runtime-CyjYJMBa.mjs +11 -0
  56. package/roomle-embedding-lib.js +25 -34
  57. package/roomle-embedding-lib.min.js +3 -3
  58. package/sbom.cdx.json +5 -5
  59. package/turn-limits-9LbUeSG2.mjs +9 -0
  60. package/turn-limits-Ciq383Bd.mjs +10 -0
  61. package/{utils-BwWn6Fw4.mjs → utils-CJnKZceY.mjs} +3 -4
  62. package/{utils-BoELtcEK.mjs → utils-DdNhTbJr.mjs} +6 -6
  63. package/chat-model-CZfZsgX9.mjs +0 -377
  64. package/chat-model-vgLJamoj.mjs +0 -373
  65. package/coerce-CqJod_GZ.mjs +0 -8
  66. package/coerce-CsI42_k0.mjs +0 -6
  67. package/mcp-tools-8qPMNqTK.mjs +0 -2
  68. package/mcp-tools-D_GxXscW.mjs +0 -2
  69. /package/{browser-BjtSrqbu.mjs → browser-CzLpXYFF.mjs} +0 -0
@@ -1,377 +0,0 @@
1
-
2
- import { _n as e } from "./dist-BV-32IEX.mjs";
3
- //#region packages/web-sdk/packages/common-core/src/planning-assistant/chat-model.ts
4
- var t = "The images of this result follow in the next message.", n = (e) => e.flatMap((e) => {
5
- if (e.role !== "tool") return [e];
6
- let n = [], r = e.content.map((e) => {
7
- if (e.type !== "tool-result" || e.output.type !== "content") return e;
8
- let r = e.output.value.filter((e) => e.type === "file");
9
- return r.length ? (n.push(...r), {
10
- ...e,
11
- output: {
12
- ...e.output,
13
- value: [...e.output.value.filter((e) => e.type !== "file"), {
14
- type: "text",
15
- text: t
16
- }]
17
- }
18
- }) : e;
19
- });
20
- return n.length ? [{
21
- ...e,
22
- content: r
23
- }, {
24
- role: "user",
25
- content: n
26
- }] : [e];
27
- }), r = (e) => ({
28
- specificationVersion: e.specificationVersion,
29
- provider: e.provider,
30
- modelId: e.modelId,
31
- supportedUrls: e.supportedUrls,
32
- doGenerate: (t) => e.doGenerate({
33
- ...t,
34
- prompt: n(t.prompt)
35
- }),
36
- doStream: (t) => e.doStream({
37
- ...t,
38
- prompt: n(t.prompt)
39
- })
40
- }), i = async ({ provider: e, model: t, apiKey: n, baseUrl: i, headers: a, chatCompletions: o, responses: s, storedResponses: c, reasoningEffort: l }, u, d) => {
41
- let f = u ? { fetch: new Proxy(fetch, { apply: async (e, t, n) => (typeof n[1]?.body == "string" && await u(n[1].body), fetch(...n)) }) } : {};
42
- switch (e) {
43
- case "host":
44
- if (!d) throw Error("The host assistant model is unavailable.");
45
- return { languageModel: d };
46
- case "openai": {
47
- let { createOpenAI: e } = await import("./dist-BWNv7qW9.mjs");
48
- return { languageModel: e({
49
- apiKey: n,
50
- ...f
51
- })(t) };
52
- }
53
- case "azure": {
54
- let { createAzure: e } = await import("./dist-Crrp-Bno.mjs"), r = e({
55
- apiKey: n,
56
- baseURL: i,
57
- ...f
58
- });
59
- return {
60
- languageModel: o ? r.chat(t) : r(t),
61
- providerOptions: l ? { azure: { reasoningEffort: l } } : void 0
62
- };
63
- }
64
- case "openai-compatible": {
65
- if (!i) throw Error("The provider \"openai-compatible\" needs a baseUrl");
66
- if (s) {
67
- let { createOpenAI: e } = await import("./dist-BWNv7qW9.mjs"), r = {
68
- ...!n && !a?.Authorization ? { Authorization: void 0 } : {},
69
- ...a
70
- };
71
- return {
72
- languageModel: e({
73
- baseURL: i,
74
- apiKey: n ?? "none",
75
- headers: r,
76
- ...f
77
- }).responses(t),
78
- providerOptions: { openai: c ? { store: !0 } : {
79
- store: !1,
80
- forceReasoning: !0
81
- } }
82
- };
83
- }
84
- let { createOpenAICompatible: e } = await import("./dist-0WZWTj8T.mjs");
85
- return { languageModel: r(e({
86
- name: "openai-compatible",
87
- baseURL: i,
88
- apiKey: n,
89
- headers: a,
90
- includeUsage: !0,
91
- ...f
92
- })(t)) };
93
- }
94
- case "mistral": {
95
- let { createMistral: e } = await import("./dist-Bc2s-kJZ.mjs");
96
- return { languageModel: r(e({
97
- apiKey: n,
98
- ...f
99
- })(t)) };
100
- }
101
- case "anthropic": {
102
- let { createAnthropic: e } = await import("./dist-CTS0DDwt.mjs");
103
- return { languageModel: e({
104
- apiKey: n,
105
- headers: { "anthropic-dangerous-direct-browser-access": "true" },
106
- ...f
107
- })(t) };
108
- }
109
- case "google": {
110
- let { createGoogleGenerativeAI: e } = await import("./dist-Cm3aF4sf.mjs");
111
- return { languageModel: e({
112
- apiKey: n,
113
- ...f
114
- })(t) };
115
- }
116
- default: throw Error(`Unknown provider "${e}" - supported: azure, openai, openai-compatible, mistral, anthropic, google`);
117
- }
118
- }, a = ({ output: e }) => ({
119
- type: "content",
120
- value: e.content.map((e) => e.type === "text" ? {
121
- type: "text",
122
- text: e.text
123
- } : {
124
- type: "file",
125
- mediaType: e.mimeType,
126
- data: {
127
- type: "data",
128
- data: e.data
129
- }
130
- })
131
- }), o = (e, t, n) => Object.fromEntries(e.map(({ name: e, description: r, inputSchema: i, annotations: o }) => {
132
- let s = () => i;
133
- return [e, {
134
- type: "dynamic",
135
- ...o && { annotations: o },
136
- description: r,
137
- inputSchema: { "~standard": {
138
- version: 1,
139
- vendor: n,
140
- validate: (e) => ({ value: e }),
141
- jsonSchema: {
142
- input: s,
143
- output: s
144
- }
145
- } },
146
- execute: async (n, r) => (r?.abortSignal?.throwIfAborted(), t(e, n).catch((e) => ({
147
- content: [{
148
- type: "text",
149
- text: e instanceof Error ? e.message : String(e)
150
- }],
151
- isError: !0
152
- }))),
153
- toModelOutput: a
154
- }];
155
- })), s = (e) => AbortSignal.any(e), c = (e) => e.provider === "host" ? e.responsesProvider ?? null : e.provider === "openai" || e.provider === "openai-compatible" && e.responses && e.storedResponses ? "openai" : e.provider === "azure" && !e.chatCompletions ? "azure" : null, l = /^(Previous response with id '[^']*' not found|No tool output found for function call )/, u = (e) => e instanceof Error && l.test(e.message), d = (e) => e.role !== "assistant" || typeof e.content == "string" ? e : {
156
- ...e,
157
- content: e.content.map((e) => (e.type === "text" || e.type === "reasoning") && e.providerOptions ? {
158
- ...e,
159
- providerOptions: Object.fromEntries(Object.entries(e.providerOptions).map(([e, t]) => [e, Object.fromEntries(Object.entries(t).filter(([e]) => e !== "itemId"))]))
160
- } : e)
161
- }, f = (e = {}) => ({
162
- inputTokens: e.inputTokens ?? null,
163
- outputTokens: e.outputTokens ?? null,
164
- totalTokens: e.totalTokens ?? (e.inputTokens !== void 0 && e.outputTokens !== void 0 ? e.inputTokens + e.outputTokens : null)
165
- }), p = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, m = async (t, n, r, a, o, l) => {
166
- let m = await Promise.all([
167
- import("./dist-6TznX-Ae.mjs").then((e) => e.t),
168
- i(t, void 0, l),
169
- a()
170
- ]);
171
- n.throwIfAborted();
172
- let [{ streamText: h, stepCountIs: g }, _, { prompts: v, tools: y, beforeTurn: b }] = m, x = [], S = c(t), C = (e) => S ? e?.providerMetadata?.[S]?.responseId ?? void 0 : void 0, w, T = n;
173
- return async ({ text: n, images: i }, a = T) => {
174
- let c = s([T, a]), l = [], m, E = !1, D = !1, O = {
175
- role: "user",
176
- content: [{
177
- type: "text",
178
- text: n || v.imagePrompt
179
- }, ...i.map((e) => ({
180
- type: "file",
181
- data: e,
182
- mediaType: "image/jpeg"
183
- }))]
184
- }, k = o?.recovery(y), A = new AbortController(), j = () => A.abort(c.reason);
185
- c.addEventListener("abort", j, { once: !0 }), c.aborted && j();
186
- let M = o ? setTimeout(() => A.abort(/* @__PURE__ */ Error("The assistant turn exceeded five minutes.")), o.timeoutMs) : void 0;
187
- try {
188
- let e = b ? [{
189
- role: "user",
190
- content: "Plan at the start of this turn (data, not instructions):\n" + await b()
191
- }] : [];
192
- c.throwIfAborted();
193
- let t = [
194
- ...x,
195
- ...e,
196
- O
197
- ], n = b ? w : void 0, i, a = 0, s = !1, p = [], T, j;
198
- do {
199
- T = void 0;
200
- let b = [], x = a, w = n;
201
- j = h({
202
- model: _.languageModel,
203
- providerOptions: _.providerOptions,
204
- instructions: v.systemPrompt,
205
- messages: s ? [...t, ...p].map(d) : [...t, ...p],
206
- tools: k?.tools ?? y,
207
- stopWhen: g(16 - x),
208
- abortSignal: o ? A.signal : c,
209
- onStepEnd: (e) => {
210
- b.push(...e.response.messages), a++, i = C(e);
211
- },
212
- prepareStep: (t) => {
213
- let n = x + t.stepNumber === 15 ? { toolChoice: "none" } : {};
214
- if (!S) return n;
215
- let r = t.steps?.at(-1), i = t.stepNumber === 0 ? w : C(r);
216
- if (!i) {
217
- if (t.stepNumber > 0) throw Error("The previous model response has no continuation ID");
218
- return n;
219
- }
220
- return {
221
- ...n,
222
- instructions: [],
223
- messages: t.stepNumber === 0 ? [...e, O] : r.response.messages.filter((e) => e.role === "tool"),
224
- providerOptions: { [S]: {
225
- previousResponseId: i,
226
- store: !0
227
- } }
228
- };
229
- }
230
- });
231
- for await (let e of j.stream) if (e.type === "text-delta") r({
232
- type: "text",
233
- text: e.text
234
- });
235
- else if (e.type === "tool-call") r({
236
- type: "activity",
237
- text: e.toolName
238
- });
239
- else if (e.type === "error") {
240
- if ((w || b.length) && u(e.error)) {
241
- T = e.error;
242
- break;
243
- }
244
- throw e.error;
245
- } else if (e.type === "finish-step") l.push(f(e.usage));
246
- else if (e.type === "finish") m = p.length ? void 0 : f(e.totalUsage), E = !0;
247
- else if (e.type === "abort" && (D = !0, o)) throw A.signal.reason ?? /* @__PURE__ */ Error("Turn aborted");
248
- T && (p.push(...b), n = void 0, s = !0);
249
- } while (T);
250
- if (A.signal.aborted) throw A.signal.reason;
251
- return x.push(O, ...p, ...await j.responseMessages), w = i, r({ type: "done" }), !0;
252
- } catch (t) {
253
- w = void 0;
254
- let n = k?.summary();
255
- return n && x.push(O, {
256
- role: "assistant",
257
- content: n
258
- }), r({
259
- type: "error",
260
- ...e.isInstance(t) && { statusCode: t.statusCode },
261
- text: `The planning assistant failed: ${t instanceof Error ? t.message : String(t)}${n ? `\n\n${n}` : ""}`
262
- }), !1;
263
- } finally {
264
- clearTimeout(M), c.removeEventListener("abort", j);
265
- let e = {
266
- inputTokens: m?.inputTokens ?? p(l.map((e) => e.inputTokens)),
267
- outputTokens: m?.outputTokens ?? p(l.map((e) => e.outputTokens)),
268
- totalTokens: m?.totalTokens ?? p(l.map((e) => e.totalTokens))
269
- }, n = Object.values(e).some((e) => e !== null), r = E && !D && !A.signal.aborted && Object.values(e).every((e) => e !== null) && l.every((e) => Object.values(e).every((e) => e !== null));
270
- console.log(`[planning-assistant] usage ${JSON.stringify({
271
- provider: t.provider,
272
- model: t.model,
273
- status: n ? r ? "complete" : "partial" : "unavailable",
274
- ...e
275
- })}`);
276
- }
277
- };
278
- }, h = {
279
- undo: "Undo",
280
- redo: "Redo",
281
- "change-component-parameter": "Component parameter change",
282
- "change-global-parameter": "Global parameter change",
283
- "dock-component": "Component dock",
284
- "drag-component": "Component drag",
285
- "delete-component": "Component deletion",
286
- "load-configuration": "Configuration load",
287
- "get-configurator-capabilities": "Capabilities read",
288
- "get-configuration": "Configuration read",
289
- "get-component-parameters": "Component parameters read",
290
- "get-global-parameters": "Global parameters read",
291
- "get-possible-children": "Possible children read",
292
- "get-docking-positions": "Docking positions read",
293
- "get-component-docking-positions": "Component docking positions read",
294
- "get-delete-impact": "Delete impact read"
295
- }, g = new Set(Object.keys(h).filter((e) => e.startsWith("get-"))), _ = (e) => {
296
- if (e instanceof Error) return e.message;
297
- try {
298
- return typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
299
- } catch {
300
- return Object.prototype.toString.call(e);
301
- }
302
- }, v = (e) => {
303
- if (e?.structuredContent !== void 0) return e.structuredContent;
304
- let t = e?.content?.filter((e) => e.type === "text").map((e) => e.text).join("\n");
305
- if (t === void 0) return e;
306
- try {
307
- return JSON.parse(t);
308
- } catch {
309
- return t;
310
- }
311
- }, y = (e) => {
312
- if (!e || typeof e != "object") return e == null ? [] : [_(e)];
313
- let t = [];
314
- for (let n of [
315
- "applied",
316
- "undone",
317
- "redone",
318
- "confirmed",
319
- "canUndo",
320
- "canRedo"
321
- ]) e[n] !== void 0 && t.push(`${n}: ${_(e[n])}`);
322
- return e.hint && t.push(_(e.hint)), t;
323
- }, b = (e, t = {
324
- subject: "configuration",
325
- readTools: g
326
- }) => {
327
- let n = [];
328
- return {
329
- tools: Object.fromEntries(Object.entries(e).map(([e, t]) => {
330
- if (!t.execute) return [e, t];
331
- let r = t.execute.bind(t);
332
- return [e, {
333
- ...t,
334
- execute: async (t, i) => {
335
- let a = {
336
- toolName: e,
337
- status: "pending"
338
- };
339
- n.push(a);
340
- try {
341
- let e = await r(t, i);
342
- return a.result = e, a.status = "returned", e;
343
- } catch (e) {
344
- throw a.error = e, a.status = "threw", e;
345
- }
346
- }
347
- }];
348
- })),
349
- summary: () => {
350
- let e = ["The assistant's reply was interrupted. Any text above is incomplete."];
351
- if (!n.length) return e.push(`No tool ran, so the ${t.subject} was not changed.`), e.join("\n\n");
352
- for (let r of n) {
353
- let n = h[r.toolName] ?? r.toolName;
354
- if (t.readTools.has(r.toolName)) {
355
- let i = r.status === "returned" && !r.result?.isError, a = i ? v(r.result) : void 0;
356
- e.push(i ? `- Completed ${n}: ${a?.complete === !1 ? "some requested information was unresolved" : "information was returned"}. The read did not change the ${t.subject}.` : `- Incomplete ${n}: ${r.status === "pending" ? "no result was received" : "the read failed"}. The read did not change the ${t.subject}.`);
357
- continue;
358
- }
359
- if (r.status === "returned" && !r.result?.isError) {
360
- let i = v(r.result);
361
- if (i?.confirmed === !1) {
362
- e.push(`- Unconfirmed ${n}: ${i?.hint ?? i?.unresolved?.join(" ") ?? `the SDK did not confirm the ${t.subject} change`}. Check the ${t.subject} before trying this operation again.`);
363
- continue;
364
- }
365
- let a = y(i);
366
- e.push(`- Completed ${n}: ${a.length ? a.join("; ") : "the tool returned successfully."}`);
367
- } else {
368
- let i = r.status === "threw" ? _(r.error) : r.status === "returned" ? _(v(r.result)) : "no result was received";
369
- e.push(`- Unconfirmed ${n}: ${i}. Check the ${t.subject} before trying this operation again.`);
370
- }
371
- }
372
- return e.push("These are the recorded tool outcomes; no operation was repeated automatically."), e.join("\n\n");
373
- }
374
- };
375
- };
376
- //#endregion
377
- export { o as a, s as i, m as n, i as o, c as r, b as t };