@roomle/embedding-lib 0.0.0-dev-20f436f → 0.0.0-dev-86c52f1

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 (76) hide show
  1. package/THIRD-PARTY-NOTICES.txt +2 -2
  2. package/ai-model-host-CS8tMlto.mjs +144 -0
  3. package/ai-model-host-D_b_GVlC.mjs +145 -0
  4. package/ai.js +1 -128
  5. package/ai.min.js +1 -126
  6. package/{browser-D6M-d6y5.mjs → browser-Cys-y5Hy.mjs} +1 -2
  7. package/chat-model-DooKwd8I.mjs +117 -0
  8. package/chat-model-KHuz1Ej9.mjs +118 -0
  9. package/coerce-CuLRCRlo.mjs +6 -0
  10. package/coerce-Dup0o-HR.mjs +7 -0
  11. package/{comlink-CG3f9q6z.mjs → comlink-7u13Z2ZH.mjs} +2 -3
  12. package/{comlink-hSUzCx9j.mjs → comlink-DKhvPU0o.mjs} +1 -1
  13. package/configurator.js +3 -4
  14. package/configurator.min.js +2 -2
  15. package/construction.js +17865 -37
  16. package/construction.min.js +17536 -41
  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-70R0b5Mq.mjs → dist-Ba3J8AjB.mjs} +400 -390
  22. package/{dist-CTS0DDwt.mjs → dist-CbQKC1xX.mjs} +1590 -1616
  23. package/{dist-BmOBP9h9.mjs → dist-CiybWJvs.mjs} +44 -41
  24. package/{dist-CPG4atmb.mjs → dist-CkZuNdCU.mjs} +6 -4
  25. package/{dist-Bt1FopV4.mjs → dist-D2ZAAHGn.mjs} +1058 -1042
  26. package/{dist-BWNv7qW9.mjs → dist-DjsS42rR.mjs} +916 -962
  27. package/{dist-9UI7dzwc.mjs → dist-Jcq_kKKT.mjs} +403 -393
  28. package/{dist-BV-32IEX.mjs → dist-XECXrV5Q.mjs} +1497 -1558
  29. package/{dist-Bc2s-kJZ.mjs → dist-a5_BIeaS.mjs} +45 -51
  30. package/{dist-Crrp-Bno.mjs → dist-bQAJDeYc.mjs} +698 -748
  31. package/{drag-ghost-BpIDzSdK.mjs → drag-ghost-QZelgA-_.mjs} +2 -3
  32. package/{drag-ghost-Bhb0_67G.mjs → drag-ghost-VmgSWLva.mjs} +5 -7
  33. package/{drag-in-mE_ozj_Q.mjs → drag-in-Cd_67tzS.mjs} +4 -5
  34. package/{drag-in-CGBG4wEk.mjs → drag-in-DlDsgY4T.mjs} +3 -3
  35. package/embedding-plugins.js +1 -2
  36. package/embedding-plugins.min.js +1 -2
  37. package/{experimental-evaluation-FzKFGoye.mjs → experimental-evaluation-B4hKMgFH.mjs} +19 -38
  38. package/{experimental-evaluation-DczxmJme.mjs → experimental-evaluation-DmqghFSx.mjs} +1 -1
  39. package/{from-custom-view-B3fIWMox.mjs → from-custom-view-6HMD_sPe.mjs} +5 -4
  40. package/{from-custom-view-B3HCOhdT.mjs → from-custom-view-BRFynafo.mjs} +16 -16
  41. package/{from-website-DaTahmvJ.mjs → from-website-Dl1VN4h7.mjs} +5 -6
  42. package/{from-website-DUQ9USj1.mjs → from-website-iZzauH4C.mjs} +3 -3
  43. package/hi.js +80 -428
  44. package/hi.min.js +75 -376
  45. package/mcp-tools-C6O2gQZW.mjs +41 -0
  46. package/mcp-tools-m_3IX0vB.mjs +40 -0
  47. package/package.json +1 -1
  48. package/packages/embedding-lib/src/ai-model-host.d.ts +34 -0
  49. package/packages/embedding-lib/src/ai.d.ts +11 -27
  50. package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +11 -19
  51. package/packages/web-sdk/packages/assistant.d.ts +3 -1
  52. package/packages/web-sdk/packages/common-core/src/planning-assistant/chat-recovery.d.ts +5 -1
  53. package/packages/web-sdk/packages/common-core/src/planning-assistant/continuation.d.ts +5 -3
  54. package/packages/web-sdk/packages/common-core/src/planning-assistant/runtime.d.ts +4 -1
  55. package/packages/web-sdk/packages/common-core/src/planning-assistant/types.d.ts +2 -0
  56. package/packages/web-sdk/packages/common-core/src/planning-assistant/usage.d.ts +31 -0
  57. package/packages/web-sdk/packages/common-core/src/planning-assistant.d.ts +19 -1
  58. package/rolldown-runtime--db92txo.mjs +10 -0
  59. package/rolldown-runtime-CyjYJMBa.mjs +11 -0
  60. package/roomle-embedding-lib.js +25 -34
  61. package/roomle-embedding-lib.min.js +3 -3
  62. package/sbom.cdx.json +5 -5
  63. package/usage-C3HE9yXi.mjs +33 -0
  64. package/usage-CYqDPQOx.mjs +34 -0
  65. package/{utils-BwWn6Fw4.mjs → utils-CJnKZceY.mjs} +3 -4
  66. package/{utils-BoELtcEK.mjs → utils-DdNhTbJr.mjs} +6 -6
  67. package/chat-model-C1ov616e.mjs +0 -377
  68. package/chat-model-CifTV-8H.mjs +0 -373
  69. package/coerce-CqJod_GZ.mjs +0 -8
  70. package/coerce-CsI42_k0.mjs +0 -6
  71. package/dist-6TznX-Ae.mjs +0 -17514
  72. package/dist-D0XFfKEL.mjs +0 -17079
  73. package/mcp-tools-CC8DTfZA.mjs +0 -2
  74. package/mcp-tools-CfJ_ue_2.mjs +0 -2
  75. package/packages/embedding-lib/src/homag-intelligence/hi-planning-usage.d.ts +0 -54
  76. /package/{browser-BjtSrqbu.mjs → browser-CzLpXYFF.mjs} +0 -0
@@ -1,5 +1,5 @@
1
- Third-party software notices for @roomle/embedding-lib 20f436f6f1b7177fa02b2f62e4b1385d0f03bf67
2
- Generated 2026-11-16
1
+ Third-party software notices for @roomle/embedding-lib 86c52f1f43c1147a49cb31260028e311eb5f5051
2
+ Generated 2026-11-21
3
3
 
4
4
  This product includes the following third-party components.
5
5
 
@@ -0,0 +1,144 @@
1
+
2
+ import { n as e, o as t } from "./usage-C3HE9yXi.mjs";
3
+ import { t as n } from "./chat-model-DooKwd8I.mjs";
4
+ var r = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), o = (e, t) => {
5
+ let n = (a.get(e) ?? Promise.resolve()).then(t, t);
6
+ return a.set(e, n.catch(() => {})), n;
7
+ }, s = (t) => e(t).then((e) => {}, () => {}), c = async (e, { features: r, model: i, ...a }) => {
8
+ i && (a.assistantModel = await (async (e) => {
9
+ let t = await n(e, s), r = (e) => Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(t.providerOptions ?? {}), ...Object.keys(e.providerOptions ?? {})])].map((n) => [n, {
10
+ ...e.providerOptions?.[n],
11
+ ...t.providerOptions?.[n]
12
+ }]));
13
+ return {
14
+ generate: async (e, n) => t.languageModel.doGenerate({
15
+ ...e,
16
+ providerOptions: r(e),
17
+ abortSignal: n
18
+ }),
19
+ stream: async (e, n) => (await t.languageModel.doStream({
20
+ ...e,
21
+ providerOptions: r(e),
22
+ abortSignal: n
23
+ })).stream
24
+ };
25
+ })(i), r = [.../* @__PURE__ */ new Set([
26
+ ...r ?? [],
27
+ "configuration-assistant",
28
+ ...a.onAiModelRequest ? ["lifestyle-rendering"] : []
29
+ ])]);
30
+ let o = e.startRelay("ai", (e, t) => ((e, t, n) => {
31
+ let r = [], i = async (i) => {
32
+ let [a] = i.ports;
33
+ if (i.source !== e || i.origin !== t || i.data?.type !== "roomle_ai_model_connect" || !a) return;
34
+ r.push(a);
35
+ let o = await import("./comlink-DKhvPU0o.mjs");
36
+ o.expose(((e, { transfer: t, proxy: n }) => ({
37
+ generate: async (t, n) => {
38
+ let r = new AbortController();
39
+ n.onmessage = () => r.abort();
40
+ try {
41
+ if (!e.assistantModel) throw Error("The host has no assistant model.");
42
+ let { request: n, response: i, ...a } = await e.assistantModel.generate(t, r.signal);
43
+ return a;
44
+ } finally {
45
+ n.close();
46
+ }
47
+ },
48
+ stream: async (t, r) => {
49
+ let i = new AbortController(), a;
50
+ r.onmessage = () => {
51
+ i.abort(), a?.cancel().catch(() => {});
52
+ };
53
+ try {
54
+ if (!e.assistantModel) throw Error("The host has no assistant model.");
55
+ return a = (await e.assistantModel.stream(t, i.signal)).getReader(), n({
56
+ read: async () => {
57
+ try {
58
+ let e = await a.read();
59
+ return e.done && r.close(), e;
60
+ } catch (e) {
61
+ throw r.close(), e;
62
+ }
63
+ },
64
+ cancel: async () => {
65
+ i.abort();
66
+ try {
67
+ await a.cancel();
68
+ } finally {
69
+ r.close();
70
+ }
71
+ }
72
+ });
73
+ } catch (e) {
74
+ throw r.close(), e;
75
+ }
76
+ },
77
+ request: async (n, r) => {
78
+ let i = new AbortController();
79
+ r.onmessage = () => i.abort();
80
+ try {
81
+ if (!e.onAiModelRequest) throw Error("The host has no rendering model.");
82
+ let r = await e.onAiModelRequest(n, i.signal);
83
+ if (r.status === 0) throw TypeError("The host answered without a status");
84
+ let a = await r.arrayBuffer();
85
+ return t({
86
+ status: r.status,
87
+ statusText: r.statusText,
88
+ headers: [...r.headers],
89
+ body: a
90
+ }, [a]);
91
+ } finally {
92
+ r.close();
93
+ }
94
+ },
95
+ auth: async (t, n) => {
96
+ try {
97
+ return !e.onRequestAiModelAuth || !0 === await e.onRequestAiModelAuth(t, n);
98
+ } catch {
99
+ return !1;
100
+ }
101
+ }
102
+ }))(n, o), a);
103
+ };
104
+ return window.addEventListener("message", i), () => {
105
+ window.removeEventListener("message", i), r.forEach((e) => e.close());
106
+ };
107
+ })(e, t, a));
108
+ try {
109
+ await e.ui.setAiModelHost({
110
+ auth: !!a.onRequestAiModelAuth,
111
+ ...i && { assistantModel: {
112
+ model: i.model,
113
+ readsImages: i.readsImages,
114
+ responsesProvider: t(i) ?? void 0
115
+ } },
116
+ ...r && { features: r }
117
+ });
118
+ } catch (e) {
119
+ throw o.stop(), e;
120
+ }
121
+ return {
122
+ signOut: async () => {
123
+ o.isCurrent() && await e.ui.signOutAiModel();
124
+ },
125
+ stop: async () => {
126
+ o.isCurrent() && (o.stop(), await e.ui.setAiModelHost(null));
127
+ }
128
+ };
129
+ }, l = async (e, t) => {
130
+ if (t.features?.length === 0) throw Error("serveAiModelRequests: features is empty; leave it out to serve every feature");
131
+ return i.set(e, t), o(e, () => c(e, {
132
+ ...t,
133
+ model: t.model ?? r.get(e)
134
+ }));
135
+ }, u = async (e, t) => {
136
+ r.set(e, t), await o(e, async () => {
137
+ let n = i.get(e);
138
+ n?.model || await c(e, {
139
+ ...n,
140
+ model: t
141
+ });
142
+ });
143
+ };
144
+ export { l as n, u as t };
@@ -0,0 +1,145 @@
1
+
2
+ import { n as e, o as t } from "./usage-CYqDPQOx.mjs";
3
+ import { t as n } from "./chat-model-KHuz1Ej9.mjs";
4
+ // packages/common/src/utils/ai-model-relay.ts
5
+ var r = "roomle_ai_model_connect", i = () => import("./comlink-7u13Z2ZH.mjs"), a = (e, { transfer: t, proxy: n }) => ({
6
+ generate: async (t, n) => {
7
+ let r = new AbortController();
8
+ n.onmessage = () => r.abort();
9
+ try {
10
+ if (!e.assistantModel) throw Error("The host has no assistant model.");
11
+ let { request: n, response: i, ...a } = await e.assistantModel.generate(t, r.signal);
12
+ return a;
13
+ } finally {
14
+ n.close();
15
+ }
16
+ },
17
+ stream: async (t, r) => {
18
+ let i = new AbortController(), a;
19
+ r.onmessage = () => {
20
+ i.abort(), a?.cancel().catch(() => void 0);
21
+ };
22
+ try {
23
+ if (!e.assistantModel) throw Error("The host has no assistant model.");
24
+ return a = (await e.assistantModel.stream(t, i.signal)).getReader(), n({
25
+ read: async () => {
26
+ try {
27
+ let e = await a.read();
28
+ return e.done && r.close(), e;
29
+ } catch (e) {
30
+ throw r.close(), e;
31
+ }
32
+ },
33
+ cancel: async () => {
34
+ i.abort();
35
+ try {
36
+ await a.cancel();
37
+ } finally {
38
+ r.close();
39
+ }
40
+ }
41
+ });
42
+ } catch (e) {
43
+ throw r.close(), e;
44
+ }
45
+ },
46
+ request: async (n, r) => {
47
+ let i = new AbortController();
48
+ r.onmessage = () => i.abort();
49
+ try {
50
+ if (!e.onAiModelRequest) throw Error("The host has no rendering model.");
51
+ let r = await e.onAiModelRequest(n, i.signal);
52
+ if (r.status === 0) throw TypeError("The host answered without a status");
53
+ let a = await r.arrayBuffer();
54
+ return t({
55
+ status: r.status,
56
+ statusText: r.statusText,
57
+ headers: [...r.headers],
58
+ body: a
59
+ }, [a]);
60
+ } finally {
61
+ r.close();
62
+ }
63
+ },
64
+ auth: async (t, n) => {
65
+ try {
66
+ return !e.onRequestAiModelAuth || await e.onRequestAiModelAuth(t, n) === !0;
67
+ } catch {
68
+ return !1;
69
+ }
70
+ }
71
+ }), o = (e, t, n) => {
72
+ let o = [], s = async (s) => {
73
+ let [c] = s.ports;
74
+ if (s.source !== e || s.origin !== t || s.data?.type !== r || !c) return;
75
+ o.push(c);
76
+ let l = await i();
77
+ l.expose(a(n, l), c);
78
+ };
79
+ return window.addEventListener("message", s), () => {
80
+ window.removeEventListener("message", s), o.forEach((e) => e.close());
81
+ };
82
+ }, s = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), u = (e, t) => {
83
+ let n = (l.get(e) ?? Promise.resolve()).then(t, t);
84
+ return l.set(e, n.catch(() => void 0)), n;
85
+ }, d = (t) => e(t).then((e) => console.log(`[planning-assistant] request ${JSON.stringify(e)}`), () => void 0), f = async (e) => {
86
+ let t = await n(e, d), r = (e) => Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(t.providerOptions ?? {}), ...Object.keys(e.providerOptions ?? {})])].map((n) => [n, {
87
+ ...e.providerOptions?.[n],
88
+ ...t.providerOptions?.[n]
89
+ }]));
90
+ return {
91
+ generate: async (e, n) => t.languageModel.doGenerate({
92
+ ...e,
93
+ providerOptions: r(e),
94
+ abortSignal: n
95
+ }),
96
+ stream: async (e, n) => (await t.languageModel.doStream({
97
+ ...e,
98
+ providerOptions: r(e),
99
+ abortSignal: n
100
+ })).stream
101
+ };
102
+ }, p = async (e, { features: n, model: r, ...i }) => {
103
+ r && (i.assistantModel = await f(r), n = [.../* @__PURE__ */ new Set([
104
+ ...n ?? [],
105
+ "configuration-assistant",
106
+ ...i.onAiModelRequest ? ["lifestyle-rendering"] : []
107
+ ])]);
108
+ let a = e.startRelay("ai", (e, t) => o(e, t, i));
109
+ try {
110
+ await e.ui.setAiModelHost({
111
+ auth: !!i.onRequestAiModelAuth,
112
+ ...r && { assistantModel: {
113
+ model: r.model,
114
+ readsImages: r.readsImages,
115
+ responsesProvider: t(r) ?? void 0
116
+ } },
117
+ ...n && { features: n }
118
+ });
119
+ } catch (e) {
120
+ throw a.stop(), e;
121
+ }
122
+ return {
123
+ signOut: async () => {
124
+ a.isCurrent() && await e.ui.signOutAiModel();
125
+ },
126
+ stop: async () => {
127
+ a.isCurrent() && (a.stop(), await e.ui.setAiModelHost(null));
128
+ }
129
+ };
130
+ }, m = async (e, t) => {
131
+ if (t.features?.length === 0) throw Error("serveAiModelRequests: features is empty; leave it out to serve every feature");
132
+ return c.set(e, t), u(e, () => p(e, {
133
+ ...t,
134
+ model: t.model ?? s.get(e)
135
+ }));
136
+ }, h = async (e, t) => {
137
+ s.set(e, t), await u(e, async () => {
138
+ let n = c.get(e);
139
+ n?.model || await p(e, {
140
+ ...n,
141
+ model: t
142
+ });
143
+ });
144
+ };
145
+ export { m as n, h as t };
package/ai.js CHANGED
@@ -1,129 +1,2 @@
1
1
  /*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
2
- import { o as e, r as t } from "./chat-model-C1ov616e.mjs";
3
- //#region packages/common/src/utils/ai-model-relay.ts
4
- var n = "roomle_ai_model_connect", r = () => import("./comlink-CG3f9q6z.mjs"), i = (e, { transfer: t, proxy: n }) => ({
5
- generate: async (t, n) => {
6
- let r = new AbortController();
7
- n.onmessage = () => r.abort();
8
- try {
9
- if (!e.assistantModel) throw Error("The host has no assistant model.");
10
- let { request: n, response: i, ...a } = await e.assistantModel.generate(t, r.signal);
11
- return a;
12
- } finally {
13
- n.close();
14
- }
15
- },
16
- stream: async (t, r) => {
17
- let i = new AbortController(), a;
18
- r.onmessage = () => {
19
- i.abort(), a?.cancel().catch(() => void 0);
20
- };
21
- try {
22
- if (!e.assistantModel) throw Error("The host has no assistant model.");
23
- return a = (await e.assistantModel.stream(t, i.signal)).getReader(), n({
24
- read: async () => {
25
- try {
26
- let e = await a.read();
27
- return e.done && r.close(), e;
28
- } catch (e) {
29
- throw r.close(), e;
30
- }
31
- },
32
- cancel: async () => {
33
- i.abort();
34
- try {
35
- await a.cancel();
36
- } finally {
37
- r.close();
38
- }
39
- }
40
- });
41
- } catch (e) {
42
- throw r.close(), e;
43
- }
44
- },
45
- request: async (n, r) => {
46
- let i = new AbortController();
47
- r.onmessage = () => i.abort();
48
- try {
49
- if (!e.onAiModelRequest) throw Error("The host has no rendering model.");
50
- let r = await e.onAiModelRequest(n, i.signal);
51
- if (r.status === 0) throw TypeError("The host answered without a status");
52
- let a = await r.arrayBuffer();
53
- return t({
54
- status: r.status,
55
- statusText: r.statusText,
56
- headers: [...r.headers],
57
- body: a
58
- }, [a]);
59
- } finally {
60
- r.close();
61
- }
62
- },
63
- auth: async (t, n) => {
64
- try {
65
- return !e.onRequestAiModelAuth || await e.onRequestAiModelAuth(t, n) === !0;
66
- } catch {
67
- return !1;
68
- }
69
- }
70
- }), a = (e, t, a) => {
71
- let o = [], s = async (s) => {
72
- let [c] = s.ports;
73
- if (s.source !== e || s.origin !== t || s.data?.type !== n || !c) return;
74
- o.push(c);
75
- let l = await r();
76
- l.expose(i(a, l), c);
77
- };
78
- return window.addEventListener("message", s), () => {
79
- window.removeEventListener("message", s), o.forEach((e) => e.close());
80
- };
81
- }, o = async (n, { features: r, model: i, ...o }) => {
82
- if (r?.length === 0) throw Error("serveAiModelRequests: features is empty; leave it out to serve every feature");
83
- if (i) {
84
- let t = await e(i), n = (e) => Object.fromEntries([...new Set([...Object.keys(t.providerOptions ?? {}), ...Object.keys(e.providerOptions ?? {})])].map((n) => [n, {
85
- ...t.providerOptions?.[n],
86
- ...e.providerOptions?.[n]
87
- }]));
88
- o.assistantModel = {
89
- generate: async (e, r) => t.languageModel.doGenerate({
90
- ...e,
91
- providerOptions: n(e),
92
- abortSignal: r
93
- }),
94
- stream: async (e, r) => (await t.languageModel.doStream({
95
- ...e,
96
- providerOptions: n(e),
97
- abortSignal: r
98
- })).stream
99
- }, r = [...new Set([
100
- ...r ?? [],
101
- "configuration-assistant",
102
- ...o.onAiModelRequest ? ["lifestyle-rendering"] : []
103
- ])];
104
- }
105
- let s = n.startRelay("ai", (e, t) => a(e, t, o));
106
- try {
107
- await n.ui.setAiModelHost({
108
- auth: !!o.onRequestAiModelAuth,
109
- ...i && { assistantModel: {
110
- model: i.model,
111
- readsImages: i.readsImages,
112
- responsesProvider: t(i) ?? void 0
113
- } },
114
- ...r && { features: r }
115
- });
116
- } catch (e) {
117
- throw s.stop(), e;
118
- }
119
- return {
120
- signOut: async () => {
121
- s.isCurrent() && await n.ui.signOutAiModel();
122
- },
123
- stop: async () => {
124
- s.isCurrent() && (s.stop(), await n.ui.setAiModelHost(null));
125
- }
126
- };
127
- };
128
- //#endregion
129
- export { o as serveAiModelRequests };
2
+ export { n as serveAiModelRequests } from "./ai-model-host-D_b_GVlC.mjs";
package/ai.min.js CHANGED
@@ -1,127 +1,2 @@
1
1
  /*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
2
- import { o as e, r as t } from "./chat-model-CifTV-8H.mjs";
3
- var n = async (n, { features: r, model: i, ...a }) => {
4
- if (r?.length === 0) throw Error("serveAiModelRequests: features is empty; leave it out to serve every feature");
5
- if (i) {
6
- let t = await e(i), n = (e) => Object.fromEntries([...new Set([...Object.keys(t.providerOptions ?? {}), ...Object.keys(e.providerOptions ?? {})])].map((n) => [n, {
7
- ...t.providerOptions?.[n],
8
- ...e.providerOptions?.[n]
9
- }]));
10
- a.assistantModel = {
11
- generate: async (e, r) => t.languageModel.doGenerate({
12
- ...e,
13
- providerOptions: n(e),
14
- abortSignal: r
15
- }),
16
- stream: async (e, r) => (await t.languageModel.doStream({
17
- ...e,
18
- providerOptions: n(e),
19
- abortSignal: r
20
- })).stream
21
- }, r = [...new Set([
22
- ...r ?? [],
23
- "configuration-assistant",
24
- ...a.onAiModelRequest ? ["lifestyle-rendering"] : []
25
- ])];
26
- }
27
- let o = n.startRelay("ai", (e, t) => ((e, t, n) => {
28
- let r = [], i = async (i) => {
29
- let [a] = i.ports;
30
- if (i.source !== e || i.origin !== t || i.data?.type !== "roomle_ai_model_connect" || !a) return;
31
- r.push(a);
32
- let o = await import("./comlink-hSUzCx9j.mjs");
33
- o.expose(((e, { transfer: t, proxy: n }) => ({
34
- generate: async (t, n) => {
35
- let r = new AbortController();
36
- n.onmessage = () => r.abort();
37
- try {
38
- if (!e.assistantModel) throw Error("The host has no assistant model.");
39
- let { request: n, response: i, ...a } = await e.assistantModel.generate(t, r.signal);
40
- return a;
41
- } finally {
42
- n.close();
43
- }
44
- },
45
- stream: async (t, r) => {
46
- let i = new AbortController(), a;
47
- r.onmessage = () => {
48
- i.abort(), a?.cancel().catch(() => {});
49
- };
50
- try {
51
- if (!e.assistantModel) throw Error("The host has no assistant model.");
52
- return a = (await e.assistantModel.stream(t, i.signal)).getReader(), n({
53
- read: async () => {
54
- try {
55
- let e = await a.read();
56
- return e.done && r.close(), e;
57
- } catch (e) {
58
- throw r.close(), e;
59
- }
60
- },
61
- cancel: async () => {
62
- i.abort();
63
- try {
64
- await a.cancel();
65
- } finally {
66
- r.close();
67
- }
68
- }
69
- });
70
- } catch (e) {
71
- throw r.close(), e;
72
- }
73
- },
74
- request: async (n, r) => {
75
- let i = new AbortController();
76
- r.onmessage = () => i.abort();
77
- try {
78
- if (!e.onAiModelRequest) throw Error("The host has no rendering model.");
79
- let r = await e.onAiModelRequest(n, i.signal);
80
- if (r.status === 0) throw TypeError("The host answered without a status");
81
- let a = await r.arrayBuffer();
82
- return t({
83
- status: r.status,
84
- statusText: r.statusText,
85
- headers: [...r.headers],
86
- body: a
87
- }, [a]);
88
- } finally {
89
- r.close();
90
- }
91
- },
92
- auth: async (t, n) => {
93
- try {
94
- return !e.onRequestAiModelAuth || !0 === await e.onRequestAiModelAuth(t, n);
95
- } catch {
96
- return !1;
97
- }
98
- }
99
- }))(n, o), a);
100
- };
101
- return window.addEventListener("message", i), () => {
102
- window.removeEventListener("message", i), r.forEach((e) => e.close());
103
- };
104
- })(e, t, a));
105
- try {
106
- await n.ui.setAiModelHost({
107
- auth: !!a.onRequestAiModelAuth,
108
- ...i && { assistantModel: {
109
- model: i.model,
110
- readsImages: i.readsImages,
111
- responsesProvider: t(i) ?? void 0
112
- } },
113
- ...r && { features: r }
114
- });
115
- } catch (e) {
116
- throw o.stop(), e;
117
- }
118
- return {
119
- signOut: async () => {
120
- o.isCurrent() && await n.ui.signOutAiModel();
121
- },
122
- stop: async () => {
123
- o.isCurrent() && (o.stop(), await n.ui.setAiModelHost(null));
124
- }
125
- };
126
- };
127
- export { n as serveAiModelRequests };
2
+ export { n as serveAiModelRequests } from "./ai-model-host-CS8tMlto.mjs";
@@ -1,5 +1,5 @@
1
1
 
2
- //#region packages/common/src/utils/browser.ts
2
+ // packages/common/src/utils/browser.ts
3
3
  var e = [
4
4
  "language",
5
5
  "browserLanguage",
@@ -15,5 +15,4 @@ var e = [
15
15
  }
16
16
  return "en";
17
17
  };
18
- //#endregion
19
18
  export { n as t };
@@ -0,0 +1,117 @@
1
+
2
+ var e = (e) => e.flatMap((e) => {
3
+ if (e.role !== "tool") return [e];
4
+ let t = [], n = e.content.map((e) => {
5
+ if (e.type !== "tool-result" || e.output.type !== "content") return e;
6
+ let n = e.output.value.filter((e) => e.type === "file");
7
+ return n.length ? (t.push(...n), {
8
+ ...e,
9
+ output: {
10
+ ...e.output,
11
+ value: [...e.output.value.filter((e) => e.type !== "file"), {
12
+ type: "text",
13
+ text: "The images of this result follow in the next message."
14
+ }]
15
+ }
16
+ }) : e;
17
+ });
18
+ return t.length ? [{
19
+ ...e,
20
+ content: n
21
+ }, {
22
+ role: "user",
23
+ content: t
24
+ }] : [e];
25
+ }), t = (t) => ({
26
+ specificationVersion: t.specificationVersion,
27
+ provider: t.provider,
28
+ modelId: t.modelId,
29
+ supportedUrls: t.supportedUrls,
30
+ doGenerate: (n) => t.doGenerate({
31
+ ...n,
32
+ prompt: e(n.prompt)
33
+ }),
34
+ doStream: (n) => t.doStream({
35
+ ...n,
36
+ prompt: e(n.prompt)
37
+ })
38
+ }), n = async ({ provider: e, model: n, apiKey: r, baseUrl: i, headers: a, chatCompletions: o, responses: s, storedResponses: c, reasoningEffort: l }, u, d) => {
39
+ let f = u ? { fetch: new Proxy(fetch, { apply: async (e, t, n) => (typeof n[1]?.body == "string" && await u(n[1].body), fetch(...n)) }) } : {};
40
+ switch (e) {
41
+ case "host":
42
+ if (!d) throw Error("The host assistant model is unavailable.");
43
+ return { languageModel: d };
44
+ case "openai": {
45
+ let { createOpenAI: e } = await import("./dist-Jcq_kKKT.mjs");
46
+ return { languageModel: e({
47
+ apiKey: r,
48
+ ...f
49
+ })(n) };
50
+ }
51
+ case "azure": {
52
+ let { createAzure: e } = await import("./dist-Ba3J8AjB.mjs"), t = e({
53
+ apiKey: r,
54
+ baseURL: i,
55
+ ...f
56
+ });
57
+ return {
58
+ languageModel: o ? t.chat(n) : t(n),
59
+ providerOptions: l ? { azure: { reasoningEffort: l } } : void 0
60
+ };
61
+ }
62
+ case "openai-compatible": {
63
+ if (!i) throw Error("The provider \"openai-compatible\" needs a baseUrl");
64
+ if (s) {
65
+ let { createOpenAI: e } = await import("./dist-Jcq_kKKT.mjs");
66
+ return {
67
+ languageModel: e({
68
+ baseURL: i,
69
+ apiKey: r ?? "none",
70
+ headers: {
71
+ ...r || a?.Authorization ? {} : { Authorization: void 0 },
72
+ ...a
73
+ },
74
+ ...f
75
+ }).responses(n),
76
+ providerOptions: { openai: c ? { store: !0 } : {
77
+ store: !1,
78
+ forceReasoning: !0
79
+ } }
80
+ };
81
+ }
82
+ let { createOpenAICompatible: e } = await import("./dist-BY8OLJ2p.mjs");
83
+ return { languageModel: t(e({
84
+ name: "openai-compatible",
85
+ baseURL: i,
86
+ apiKey: r,
87
+ headers: a,
88
+ includeUsage: !0,
89
+ ...f
90
+ })(n)) };
91
+ }
92
+ case "mistral": {
93
+ let { createMistral: e } = await import("./dist-CkZuNdCU.mjs");
94
+ return { languageModel: t(e({
95
+ apiKey: r,
96
+ ...f
97
+ })(n)) };
98
+ }
99
+ case "anthropic": {
100
+ let { createAnthropic: e } = await import("./dist-CiybWJvs.mjs");
101
+ return { languageModel: e({
102
+ apiKey: r,
103
+ headers: { "anthropic-dangerous-direct-browser-access": "true" },
104
+ ...f
105
+ })(n) };
106
+ }
107
+ case "google": {
108
+ let { createGoogleGenerativeAI: e } = await import("./dist-BMxyw-Zs.mjs");
109
+ return { languageModel: e({
110
+ apiKey: r,
111
+ ...f
112
+ })(n) };
113
+ }
114
+ default: throw Error(`Unknown provider "${e}" - supported: azure, openai, openai-compatible, mistral, anthropic, google`);
115
+ }
116
+ };
117
+ export { n as t };