@roomle/embedding-lib 0.0.0-dev-d66646c → 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.
- package/THIRD-PARTY-NOTICES.txt +2 -2
- package/ai-model-host-CS8tMlto.mjs +144 -0
- package/ai-model-host-D_b_GVlC.mjs +145 -0
- package/ai.js +1 -128
- package/ai.min.js +1 -127
- package/construction.js +17615 -143
- package/construction.min.js +17291 -155
- package/hi.js +78 -421
- package/hi.min.js +73 -377
- package/package.json +1 -1
- package/packages/embedding-lib/src/ai-model-host.d.ts +34 -0
- package/packages/embedding-lib/src/ai.d.ts +11 -27
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +9 -20
- package/packages/web-sdk/packages/assistant.d.ts +1 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/usage.d.ts +15 -0
- package/sbom.cdx.json +5 -5
- package/usage-C3HE9yXi.mjs +33 -0
- package/usage-CYqDPQOx.mjs +34 -0
- package/continuation-COcMrXyj.mjs +0 -14
- package/continuation-D2hsmYf1.mjs +0 -13
- 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 -48
- package/usage-CgXarvBY.mjs +0 -16
- package/usage-c8evaONq.mjs +0 -17
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 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
|
-
|
|
3
|
-
import { n as t } from "./continuation-COcMrXyj.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 { n as serveAiModelRequests } from "./ai-model-host-D_b_GVlC.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-D2hsmYf1.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 { n as serveAiModelRequests } from "./ai-model-host-CS8tMlto.mjs";
|