@roomle/embedding-lib 11.0.0-alpha.12 → 11.0.0-alpha.13
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.
- package/THIRD-PARTY-NOTICES.txt +2 -2
- package/ai-model-host-CaiYrZkh.mjs +152 -0
- package/ai-model-host-HAJONHCj.mjs +156 -0
- package/ai.js +1 -128
- package/ai.min.js +1 -127
- package/chat-model-DooKwd8I.mjs +117 -0
- package/chat-model-KHuz1Ej9.mjs +118 -0
- package/configurator.js +2 -2
- package/configurator.min.js +2 -2
- package/construction.js +17718 -162
- package/construction.min.js +17397 -177
- package/docs/md/web/embedding/CHANGELOG.md +93 -4
- package/hi.js +91 -393
- package/hi.min.js +88 -351
- package/{mcp-tools-BLB7pCga.mjs → mcp-tools-C6O2gQZW.mjs} +0 -1
- package/{mcp-tools-BirFT2R0.mjs → mcp-tools-m_3IX0vB.mjs} +0 -1
- package/package.json +1 -1
- package/packages/common/src/utils/ai-model-relay.d.ts +1 -1
- package/packages/embedding-lib/src/ai-model-host.d.ts +36 -0
- package/packages/embedding-lib/src/ai.d.ts +11 -27
- package/packages/embedding-lib/src/hi.d.ts +1 -0
- package/packages/embedding-lib/src/homag-intelligence/decisions.d.ts +7 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-model-proxy.d.ts +4 -1
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +9 -19
- package/packages/web-sdk/packages/assistant.d.ts +2 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/chat-recovery.d.ts +5 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/continuation.d.ts +5 -3
- package/packages/web-sdk/packages/common-core/src/planning-assistant/usage.d.ts +31 -0
- package/roomle-embedding-lib.js +37 -37
- package/roomle-embedding-lib.min.js +30 -30
- package/sbom.cdx.json +5 -5
- package/usage-C3HE9yXi.mjs +33 -0
- package/usage-CYqDPQOx.mjs +34 -0
- package/chat-model-B7BO8IhK.mjs +0 -212
- package/chat-model-XYf503pT.mjs +0 -213
- package/continuation-CswXtOus.mjs +0 -10
- package/continuation-NclHDSgS.mjs +0 -9
- package/dist-BZSd56sr.mjs +0 -17422
- package/dist-S9sLSjZ4.mjs +0 -17087
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-usage.d.ts +0 -54
- package/turn-limits-9LbUeSG2.mjs +0 -9
- package/turn-limits-Ciq383Bd.mjs +0 -10
package/THIRD-PARTY-NOTICES.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
Third-party software notices for @roomle/embedding-lib
|
|
2
|
-
Generated 2026-11-
|
|
1
|
+
Third-party software notices for @roomle/embedding-lib 93f20163218d63379df63e3c01e075d80ebb597a
|
|
2
|
+
Generated 2026-11-25
|
|
3
3
|
|
|
4
4
|
This product includes the following third-party components.
|
|
5
5
|
|
|
@@ -0,0 +1,152 @@
|
|
|
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 = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap(), c = (t) => e(t).then((e) => {}, () => {}), l = async (e) => {
|
|
5
|
+
e && !s.has(e) && s.set(e, await (async (e) => {
|
|
6
|
+
let t = await n(e, c), r = (e) => Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(t.providerOptions ?? {}), ...Object.keys(e.providerOptions ?? {})])].map((n) => [n, {
|
|
7
|
+
...e.providerOptions?.[n],
|
|
8
|
+
...t.providerOptions?.[n]
|
|
9
|
+
}]));
|
|
10
|
+
return {
|
|
11
|
+
generate: async (e, n) => t.languageModel.doGenerate({
|
|
12
|
+
...e,
|
|
13
|
+
providerOptions: r(e),
|
|
14
|
+
abortSignal: n
|
|
15
|
+
}),
|
|
16
|
+
stream: async (e, n) => (await t.languageModel.doStream({
|
|
17
|
+
...e,
|
|
18
|
+
providerOptions: r(e),
|
|
19
|
+
abortSignal: n
|
|
20
|
+
})).stream
|
|
21
|
+
};
|
|
22
|
+
})(e));
|
|
23
|
+
}, u = async (e) => {
|
|
24
|
+
let n = i.get(e), a = n?.model ?? r.get(e);
|
|
25
|
+
if (!n && !a) return o.get(e)?.stop(), o.delete(e), void await e.ui.setAiModelHost(null);
|
|
26
|
+
let { features: c, model: l, ...u } = n ?? {}, d = a && s.get(a), f = a ? [.../* @__PURE__ */ new Set([
|
|
27
|
+
...c ?? [],
|
|
28
|
+
"configuration-assistant",
|
|
29
|
+
...!c && u.onAiModelRequest ? ["lifestyle-rendering"] : []
|
|
30
|
+
])] : c, p = 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, {
|
|
108
|
+
...u,
|
|
109
|
+
...d && { assistantModel: d }
|
|
110
|
+
}));
|
|
111
|
+
o.set(e, p);
|
|
112
|
+
try {
|
|
113
|
+
await e.ui.setAiModelHost({
|
|
114
|
+
auth: !!u.onRequestAiModelAuth,
|
|
115
|
+
...a && { assistantModel: {
|
|
116
|
+
model: a.model,
|
|
117
|
+
readsImages: a.readsImages,
|
|
118
|
+
responsesProvider: t(a) ?? void 0
|
|
119
|
+
} },
|
|
120
|
+
...f && { features: f }
|
|
121
|
+
});
|
|
122
|
+
} catch (e) {
|
|
123
|
+
throw p.stop(), e;
|
|
124
|
+
}
|
|
125
|
+
}, d = async (e, t) => {
|
|
126
|
+
if (t.features?.length === 0) throw Error("serveAiModelRequests: features is empty; leave it out to serve every feature");
|
|
127
|
+
let n = { ...t };
|
|
128
|
+
a.set(e, n), await l(n.model);
|
|
129
|
+
let r = () => i.get(e) === n && !0 === o.get(e)?.isCurrent(), s = {
|
|
130
|
+
signOut: async () => {
|
|
131
|
+
r() && await e.ui.signOutAiModel();
|
|
132
|
+
},
|
|
133
|
+
stop: async () => {
|
|
134
|
+
r() && (i.delete(e), await u(e));
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
if (a.get(e) !== n) return s;
|
|
138
|
+
i.set(e, n);
|
|
139
|
+
try {
|
|
140
|
+
await u(e);
|
|
141
|
+
} catch (t) {
|
|
142
|
+
throw i.get(e) === n && i.delete(e), t;
|
|
143
|
+
}
|
|
144
|
+
return s;
|
|
145
|
+
}, f = async (e, t) => {
|
|
146
|
+
await l(t), r.set(e, t);
|
|
147
|
+
let n = i.get(e);
|
|
148
|
+
return n?.model ? n.model : (await u(e), t);
|
|
149
|
+
}, p = async (e, t) => {
|
|
150
|
+
r.get(e) === t && (r.delete(e), i.get(e)?.model || await u(e));
|
|
151
|
+
};
|
|
152
|
+
export { p as n, d as r, f as t };
|
|
@@ -0,0 +1,156 @@
|
|
|
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 = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), f = (t) => e(t).then((e) => console.log(`[planning-assistant] request ${JSON.stringify(e)}`), () => void 0), p = async (e) => {
|
|
83
|
+
let t = await n(e, f), r = (e) => Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(t.providerOptions ?? {}), ...Object.keys(e.providerOptions ?? {})])].map((n) => [n, {
|
|
84
|
+
...e.providerOptions?.[n],
|
|
85
|
+
...t.providerOptions?.[n]
|
|
86
|
+
}]));
|
|
87
|
+
return {
|
|
88
|
+
generate: async (e, n) => t.languageModel.doGenerate({
|
|
89
|
+
...e,
|
|
90
|
+
providerOptions: r(e),
|
|
91
|
+
abortSignal: n
|
|
92
|
+
}),
|
|
93
|
+
stream: async (e, n) => (await t.languageModel.doStream({
|
|
94
|
+
...e,
|
|
95
|
+
providerOptions: r(e),
|
|
96
|
+
abortSignal: n
|
|
97
|
+
})).stream
|
|
98
|
+
};
|
|
99
|
+
}, m = async (e) => {
|
|
100
|
+
e && !d.has(e) && d.set(e, await p(e));
|
|
101
|
+
}, h = async (e) => {
|
|
102
|
+
let n = c.get(e), r = n?.model ?? s.get(e);
|
|
103
|
+
if (!n && !r) {
|
|
104
|
+
u.get(e)?.stop(), u.delete(e), await e.ui.setAiModelHost(null);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
let { features: i, model: a, ...l } = n ?? {}, f = r && d.get(r), p = r ? [.../* @__PURE__ */ new Set([
|
|
108
|
+
...i ?? [],
|
|
109
|
+
"configuration-assistant",
|
|
110
|
+
...!i && l.onAiModelRequest ? ["lifestyle-rendering"] : []
|
|
111
|
+
])] : i, m = e.startRelay("ai", (e, t) => o(e, t, {
|
|
112
|
+
...l,
|
|
113
|
+
...f && { assistantModel: f }
|
|
114
|
+
}));
|
|
115
|
+
u.set(e, m);
|
|
116
|
+
try {
|
|
117
|
+
await e.ui.setAiModelHost({
|
|
118
|
+
auth: !!l.onRequestAiModelAuth,
|
|
119
|
+
...r && { assistantModel: {
|
|
120
|
+
model: r.model,
|
|
121
|
+
readsImages: r.readsImages,
|
|
122
|
+
responsesProvider: t(r) ?? void 0
|
|
123
|
+
} },
|
|
124
|
+
...p && { features: p }
|
|
125
|
+
});
|
|
126
|
+
} catch (e) {
|
|
127
|
+
throw m.stop(), e;
|
|
128
|
+
}
|
|
129
|
+
}, g = async (e, t) => {
|
|
130
|
+
if (t.features?.length === 0) throw Error("serveAiModelRequests: features is empty; leave it out to serve every feature");
|
|
131
|
+
let n = { ...t };
|
|
132
|
+
l.set(e, n), await m(n.model);
|
|
133
|
+
let r = () => c.get(e) === n && u.get(e)?.isCurrent() === !0, i = {
|
|
134
|
+
signOut: async () => {
|
|
135
|
+
r() && await e.ui.signOutAiModel();
|
|
136
|
+
},
|
|
137
|
+
stop: async () => {
|
|
138
|
+
r() && (c.delete(e), await h(e));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
if (l.get(e) !== n) return i;
|
|
142
|
+
c.set(e, n);
|
|
143
|
+
try {
|
|
144
|
+
await h(e);
|
|
145
|
+
} catch (t) {
|
|
146
|
+
throw c.get(e) === n && c.delete(e), t;
|
|
147
|
+
}
|
|
148
|
+
return i;
|
|
149
|
+
}, _ = async (e, t) => {
|
|
150
|
+
await m(t), s.set(e, t);
|
|
151
|
+
let n = c.get(e);
|
|
152
|
+
return n?.model ? n.model : (await h(e), t);
|
|
153
|
+
}, v = async (e, t) => {
|
|
154
|
+
s.get(e) === t && (s.delete(e), c.get(e)?.model || await h(e));
|
|
155
|
+
};
|
|
156
|
+
export { v as n, g as r, _ 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
|
-
|
|
3
|
-
import { n as t } from "./continuation-CswXtOus.mjs";
|
|
4
|
-
// packages/common/src/utils/ai-model-relay.ts
|
|
5
|
-
var n = "roomle_ai_model_connect", r = () => import("./comlink-7u13Z2ZH.mjs"), i = (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
|
-
}), a = (e, t, a) => {
|
|
72
|
-
let o = [], s = async (s) => {
|
|
73
|
-
let [c] = s.ports;
|
|
74
|
-
if (s.source !== e || s.origin !== t || s.data?.type !== n || !c) return;
|
|
75
|
-
o.push(c);
|
|
76
|
-
let l = await r();
|
|
77
|
-
l.expose(i(a, l), c);
|
|
78
|
-
};
|
|
79
|
-
return window.addEventListener("message", s), () => {
|
|
80
|
-
window.removeEventListener("message", s), o.forEach((e) => e.close());
|
|
81
|
-
};
|
|
82
|
-
}, o = async (n, { features: r, model: i, ...o }) => {
|
|
83
|
-
if (r?.length === 0) throw Error("serveAiModelRequests: features is empty; leave it out to serve every feature");
|
|
84
|
-
if (i) {
|
|
85
|
-
let t = await e(i), n = (e) => Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(t.providerOptions ?? {}), ...Object.keys(e.providerOptions ?? {})])].map((n) => [n, {
|
|
86
|
-
...e.providerOptions?.[n],
|
|
87
|
-
...t.providerOptions?.[n]
|
|
88
|
-
}]));
|
|
89
|
-
o.assistantModel = {
|
|
90
|
-
generate: async (e, r) => t.languageModel.doGenerate({
|
|
91
|
-
...e,
|
|
92
|
-
providerOptions: n(e),
|
|
93
|
-
abortSignal: r
|
|
94
|
-
}),
|
|
95
|
-
stream: async (e, r) => (await t.languageModel.doStream({
|
|
96
|
-
...e,
|
|
97
|
-
providerOptions: n(e),
|
|
98
|
-
abortSignal: r
|
|
99
|
-
})).stream
|
|
100
|
-
}, r = [.../* @__PURE__ */ new Set([
|
|
101
|
-
...r ?? [],
|
|
102
|
-
"configuration-assistant",
|
|
103
|
-
...o.onAiModelRequest ? ["lifestyle-rendering"] : []
|
|
104
|
-
])];
|
|
105
|
-
}
|
|
106
|
-
let s = n.startRelay("ai", (e, t) => a(e, t, o));
|
|
107
|
-
try {
|
|
108
|
-
await n.ui.setAiModelHost({
|
|
109
|
-
auth: !!o.onRequestAiModelAuth,
|
|
110
|
-
...i && { assistantModel: {
|
|
111
|
-
model: i.model,
|
|
112
|
-
readsImages: i.readsImages,
|
|
113
|
-
responsesProvider: t(i) ?? void 0
|
|
114
|
-
} },
|
|
115
|
-
...r && { features: r }
|
|
116
|
-
});
|
|
117
|
-
} catch (e) {
|
|
118
|
-
throw s.stop(), e;
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
signOut: async () => {
|
|
122
|
-
s.isCurrent() && await n.ui.signOutAiModel();
|
|
123
|
-
},
|
|
124
|
-
stop: async () => {
|
|
125
|
-
s.isCurrent() && (s.stop(), await n.ui.setAiModelHost(null));
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
export { o as serveAiModelRequests };
|
|
2
|
+
export { r as serveAiModelRequests } from "./ai-model-host-HAJONHCj.mjs";
|
package/ai.min.js
CHANGED
|
@@ -1,128 +1,2 @@
|
|
|
1
1
|
/*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
|
|
2
|
-
|
|
3
|
-
import { n as t } from "./continuation-NclHDSgS.mjs";
|
|
4
|
-
var n = async (n, { features: r, model: i, ...a }) => {
|
|
5
|
-
if (r?.length === 0) throw Error("serveAiModelRequests: features is empty; leave it out to serve every feature");
|
|
6
|
-
if (i) {
|
|
7
|
-
let t = await e(i), n = (e) => Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(t.providerOptions ?? {}), ...Object.keys(e.providerOptions ?? {})])].map((n) => [n, {
|
|
8
|
-
...e.providerOptions?.[n],
|
|
9
|
-
...t.providerOptions?.[n]
|
|
10
|
-
}]));
|
|
11
|
-
a.assistantModel = {
|
|
12
|
-
generate: async (e, r) => t.languageModel.doGenerate({
|
|
13
|
-
...e,
|
|
14
|
-
providerOptions: n(e),
|
|
15
|
-
abortSignal: r
|
|
16
|
-
}),
|
|
17
|
-
stream: async (e, r) => (await t.languageModel.doStream({
|
|
18
|
-
...e,
|
|
19
|
-
providerOptions: n(e),
|
|
20
|
-
abortSignal: r
|
|
21
|
-
})).stream
|
|
22
|
-
}, r = [.../* @__PURE__ */ new Set([
|
|
23
|
-
...r ?? [],
|
|
24
|
-
"configuration-assistant",
|
|
25
|
-
...a.onAiModelRequest ? ["lifestyle-rendering"] : []
|
|
26
|
-
])];
|
|
27
|
-
}
|
|
28
|
-
let o = n.startRelay("ai", (e, t) => ((e, t, n) => {
|
|
29
|
-
let r = [], i = async (i) => {
|
|
30
|
-
let [a] = i.ports;
|
|
31
|
-
if (i.source !== e || i.origin !== t || i.data?.type !== "roomle_ai_model_connect" || !a) return;
|
|
32
|
-
r.push(a);
|
|
33
|
-
let o = await import("./comlink-DKhvPU0o.mjs");
|
|
34
|
-
o.expose(((e, { transfer: t, proxy: n }) => ({
|
|
35
|
-
generate: async (t, n) => {
|
|
36
|
-
let r = new AbortController();
|
|
37
|
-
n.onmessage = () => r.abort();
|
|
38
|
-
try {
|
|
39
|
-
if (!e.assistantModel) throw Error("The host has no assistant model.");
|
|
40
|
-
let { request: n, response: i, ...a } = await e.assistantModel.generate(t, r.signal);
|
|
41
|
-
return a;
|
|
42
|
-
} finally {
|
|
43
|
-
n.close();
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
stream: async (t, r) => {
|
|
47
|
-
let i = new AbortController(), a;
|
|
48
|
-
r.onmessage = () => {
|
|
49
|
-
i.abort(), a?.cancel().catch(() => {});
|
|
50
|
-
};
|
|
51
|
-
try {
|
|
52
|
-
if (!e.assistantModel) throw Error("The host has no assistant model.");
|
|
53
|
-
return a = (await e.assistantModel.stream(t, i.signal)).getReader(), n({
|
|
54
|
-
read: async () => {
|
|
55
|
-
try {
|
|
56
|
-
let e = await a.read();
|
|
57
|
-
return e.done && r.close(), e;
|
|
58
|
-
} catch (e) {
|
|
59
|
-
throw r.close(), e;
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
cancel: async () => {
|
|
63
|
-
i.abort();
|
|
64
|
-
try {
|
|
65
|
-
await a.cancel();
|
|
66
|
-
} finally {
|
|
67
|
-
r.close();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
} catch (e) {
|
|
72
|
-
throw r.close(), e;
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
request: async (n, r) => {
|
|
76
|
-
let i = new AbortController();
|
|
77
|
-
r.onmessage = () => i.abort();
|
|
78
|
-
try {
|
|
79
|
-
if (!e.onAiModelRequest) throw Error("The host has no rendering model.");
|
|
80
|
-
let r = await e.onAiModelRequest(n, i.signal);
|
|
81
|
-
if (r.status === 0) throw TypeError("The host answered without a status");
|
|
82
|
-
let a = await r.arrayBuffer();
|
|
83
|
-
return t({
|
|
84
|
-
status: r.status,
|
|
85
|
-
statusText: r.statusText,
|
|
86
|
-
headers: [...r.headers],
|
|
87
|
-
body: a
|
|
88
|
-
}, [a]);
|
|
89
|
-
} finally {
|
|
90
|
-
r.close();
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
auth: async (t, n) => {
|
|
94
|
-
try {
|
|
95
|
-
return !e.onRequestAiModelAuth || !0 === await e.onRequestAiModelAuth(t, n);
|
|
96
|
-
} catch {
|
|
97
|
-
return !1;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}))(n, o), a);
|
|
101
|
-
};
|
|
102
|
-
return window.addEventListener("message", i), () => {
|
|
103
|
-
window.removeEventListener("message", i), r.forEach((e) => e.close());
|
|
104
|
-
};
|
|
105
|
-
})(e, t, a));
|
|
106
|
-
try {
|
|
107
|
-
await n.ui.setAiModelHost({
|
|
108
|
-
auth: !!a.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 o.stop(), e;
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
signOut: async () => {
|
|
121
|
-
o.isCurrent() && await n.ui.signOutAiModel();
|
|
122
|
-
},
|
|
123
|
-
stop: async () => {
|
|
124
|
-
o.isCurrent() && (o.stop(), await n.ui.setAiModelHost(null));
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
export { n as serveAiModelRequests };
|
|
2
|
+
export { r as serveAiModelRequests } from "./ai-model-host-CaiYrZkh.mjs";
|
|
@@ -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 };
|