@roomle/embedding-lib 0.0.0-dev-0d51f54 → 0.0.0-dev-62f145e
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.js +84 -15
- package/ai.min.js +82 -13
- package/{chat-model-gyIajfDW.mjs → chat-model-C1ov616e.mjs} +135 -85
- package/{chat-model-DKlWonm6.mjs → chat-model-CifTV-8H.mjs} +137 -86
- package/configurator.js +6 -5
- package/configurator.min.js +6 -5
- package/construction.js +6 -5
- package/construction.min.js +6 -5
- package/{dist-Cmx_tCV5.mjs → dist-9UI7dzwc.mjs} +1 -1
- package/{dist-CjIZv2gB.mjs → dist-BQaw78-_.mjs} +1 -1
- package/{dist-Cxe4osFc.mjs → dist-BWNv7qW9.mjs} +1 -1
- package/{dist-BsVeWZ8R.mjs → dist-BmOBP9h9.mjs} +1 -1
- package/{dist-CnTUCpLZ.mjs → dist-CTS0DDwt.mjs} +1 -1
- package/{dist-DCzWWudD.mjs → dist-Cm3aF4sf.mjs} +1 -1
- package/{drag-ghost-B24KVqgc.mjs → drag-ghost-Bhb0_67G.mjs} +1 -1
- package/{drag-ghost-C1WS2KmW.mjs → drag-ghost-BpIDzSdK.mjs} +1 -1
- package/{drag-in-CWHSbwvG.mjs → drag-in-CGBG4wEk.mjs} +2 -2
- package/{drag-in-O5uwMddL.mjs → drag-in-mE_ozj_Q.mjs} +2 -2
- package/embedding-plugins.js +1 -1
- package/embedding-plugins.min.js +1 -1
- package/{from-custom-view-CxmIIsHU.mjs → from-custom-view-B3HCOhdT.mjs} +2 -2
- package/{from-custom-view-BgmiWIEN.mjs → from-custom-view-B3fIWMox.mjs} +2 -2
- package/{from-website-B8qFEG_R.mjs → from-website-DUQ9USj1.mjs} +2 -2
- package/{from-website-CvcnHmr2.mjs → from-website-DaTahmvJ.mjs} +2 -2
- package/hi.js +215 -169
- package/hi.min.js +313 -270
- package/mcp-tools-CC8DTfZA.mjs +2 -0
- package/mcp-tools-CfJ_ue_2.mjs +2 -0
- package/package.json +1 -1
- package/packages/common/src/utils/ai-model-relay.d.ts +22 -2
- package/packages/embedding-lib/src/ai.d.ts +3 -1
- package/packages/embedding-lib/src/hi.d.ts +1 -1
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +14 -2
- package/packages/embedding-lib/src/planning-assistant/chat-model.d.ts +1 -1
- package/packages/web-sdk/packages/assistant.d.ts +1 -0
- package/packages/web-sdk/packages/common-core/src/planning-assistant/chat-model.d.ts +1 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/continuation.d.ts +5 -0
- package/packages/web-sdk/packages/common-core/src/planning-assistant/mcp-tools.d.ts +3 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/runtime.d.ts +3 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/types.d.ts +6 -2
- package/roomle-embedding-lib.js +1 -1
- package/roomle-embedding-lib.min.js +1 -1
- package/sbom.cdx.json +5 -5
- /package/{comlink-m82YLjsS.mjs → comlink-CG3f9q6z.mjs} +0 -0
- /package/{comlink-BYqErFai.mjs → comlink-hSUzCx9j.mjs} +0 -0
- /package/{dist-wPZpiGiu.mjs → dist-0WZWTj8T.mjs} +0 -0
- /package/{dist-Ur4DqwwC.mjs → dist-70R0b5Mq.mjs} +0 -0
- /package/{dist-CZbrRF4T.mjs → dist-Bc2s-kJZ.mjs} +0 -0
- /package/{dist-BI_3AeI-.mjs → dist-CPG4atmb.mjs} +0 -0
- /package/{dist-Dr3LcjP6.mjs → dist-Crrp-Bno.mjs} +0 -0
- /package/{dist-CGgFMwb1.mjs → dist-DkR6G9Kj.mjs} +0 -0
- /package/{experimental-evaluation-DPkDk-5A.mjs → experimental-evaluation-DczxmJme.mjs} +0 -0
- /package/{experimental-evaluation-DyONuPyk.mjs → experimental-evaluation-FzKFGoye.mjs} +0 -0
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 62f145ebcaf9b83cefa7120a945bdd02f1e4912c
|
|
2
|
+
Generated 2026-11-15
|
|
3
3
|
|
|
4
4
|
This product includes the following third-party components.
|
|
5
5
|
|
package/ai.js
CHANGED
|
@@ -1,10 +1,52 @@
|
|
|
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";
|
|
2
3
|
//#region packages/common/src/utils/ai-model-relay.ts
|
|
3
|
-
var
|
|
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
|
+
},
|
|
4
45
|
request: async (n, r) => {
|
|
5
46
|
let i = new AbortController();
|
|
6
47
|
r.onmessage = () => i.abort();
|
|
7
48
|
try {
|
|
49
|
+
if (!e.onAiModelRequest) throw Error("The host has no rendering model.");
|
|
8
50
|
let r = await e.onAiModelRequest(n, i.signal);
|
|
9
51
|
if (r.status === 0) throw TypeError("The host answered without a status");
|
|
10
52
|
let a = await r.arrayBuffer();
|
|
@@ -25,36 +67,63 @@ var e = "roomle_ai_model_connect", t = () => import("./comlink-m82YLjsS.mjs"), n
|
|
|
25
67
|
return !1;
|
|
26
68
|
}
|
|
27
69
|
}
|
|
28
|
-
}),
|
|
70
|
+
}), a = (e, t, a) => {
|
|
29
71
|
let o = [], s = async (s) => {
|
|
30
72
|
let [c] = s.ports;
|
|
31
|
-
if (s.source !==
|
|
73
|
+
if (s.source !== e || s.origin !== t || s.data?.type !== n || !c) return;
|
|
32
74
|
o.push(c);
|
|
33
|
-
let l = await
|
|
34
|
-
l.expose(
|
|
75
|
+
let l = await r();
|
|
76
|
+
l.expose(i(a, l), c);
|
|
35
77
|
};
|
|
36
78
|
return window.addEventListener("message", s), () => {
|
|
37
79
|
window.removeEventListener("message", s), o.forEach((e) => e.close());
|
|
38
80
|
};
|
|
39
|
-
},
|
|
40
|
-
if (
|
|
41
|
-
|
|
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));
|
|
42
106
|
try {
|
|
43
|
-
await
|
|
44
|
-
auth: !!
|
|
45
|
-
...
|
|
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 }
|
|
46
115
|
});
|
|
47
116
|
} catch (e) {
|
|
48
|
-
throw
|
|
117
|
+
throw s.stop(), e;
|
|
49
118
|
}
|
|
50
119
|
return {
|
|
51
120
|
signOut: async () => {
|
|
52
|
-
|
|
121
|
+
s.isCurrent() && await n.ui.signOutAiModel();
|
|
53
122
|
},
|
|
54
123
|
stop: async () => {
|
|
55
|
-
|
|
124
|
+
s.isCurrent() && (s.stop(), await n.ui.setAiModelHost(null));
|
|
56
125
|
}
|
|
57
126
|
};
|
|
58
127
|
};
|
|
59
128
|
//#endregion
|
|
60
|
-
export {
|
|
129
|
+
export { o as serveAiModelRequests };
|
package/ai.min.js
CHANGED
|
@@ -1,17 +1,81 @@
|
|
|
1
1
|
/*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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) => {
|
|
5
28
|
let r = [], i = async (i) => {
|
|
6
29
|
let [a] = i.ports;
|
|
7
30
|
if (i.source !== e || i.origin !== t || i.data?.type !== "roomle_ai_model_connect" || !a) return;
|
|
8
31
|
r.push(a);
|
|
9
|
-
let o = await import("./comlink-
|
|
10
|
-
o.expose(((e, { transfer: t }) => ({
|
|
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
|
+
},
|
|
11
74
|
request: async (n, r) => {
|
|
12
75
|
let i = new AbortController();
|
|
13
76
|
r.onmessage = () => i.abort();
|
|
14
77
|
try {
|
|
78
|
+
if (!e.onAiModelRequest) throw Error("The host has no rendering model.");
|
|
15
79
|
let r = await e.onAiModelRequest(n, i.signal);
|
|
16
80
|
if (r.status === 0) throw TypeError("The host answered without a status");
|
|
17
81
|
let a = await r.arrayBuffer();
|
|
@@ -37,22 +101,27 @@ var e = async (e, { features: t, ...n }) => {
|
|
|
37
101
|
return window.addEventListener("message", i), () => {
|
|
38
102
|
window.removeEventListener("message", i), r.forEach((e) => e.close());
|
|
39
103
|
};
|
|
40
|
-
})(e, t,
|
|
104
|
+
})(e, t, a));
|
|
41
105
|
try {
|
|
42
|
-
await
|
|
43
|
-
auth: !!
|
|
44
|
-
...
|
|
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 }
|
|
45
114
|
});
|
|
46
115
|
} catch (e) {
|
|
47
|
-
throw
|
|
116
|
+
throw o.stop(), e;
|
|
48
117
|
}
|
|
49
118
|
return {
|
|
50
119
|
signOut: async () => {
|
|
51
|
-
|
|
120
|
+
o.isCurrent() && await n.ui.signOutAiModel();
|
|
52
121
|
},
|
|
53
122
|
stop: async () => {
|
|
54
|
-
|
|
123
|
+
o.isCurrent() && (o.stop(), await n.ui.setAiModelHost(null));
|
|
55
124
|
}
|
|
56
125
|
};
|
|
57
126
|
};
|
|
58
|
-
export {
|
|
127
|
+
export { n as serveAiModelRequests };
|
|
@@ -37,31 +37,34 @@ var t = "The images of this result follow in the next message.", n = (e) => e.fl
|
|
|
37
37
|
...t,
|
|
38
38
|
prompt: n(t.prompt)
|
|
39
39
|
})
|
|
40
|
-
}), i = async ({ provider: e, model: t, apiKey: n, baseUrl: i, headers: a, chatCompletions: o, responses: s,
|
|
41
|
-
let
|
|
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
42
|
switch (e) {
|
|
43
|
+
case "host":
|
|
44
|
+
if (!d) throw Error("The host assistant model is unavailable.");
|
|
45
|
+
return { languageModel: d };
|
|
43
46
|
case "openai": {
|
|
44
|
-
let { createOpenAI: e } = await import("./dist-
|
|
47
|
+
let { createOpenAI: e } = await import("./dist-BWNv7qW9.mjs");
|
|
45
48
|
return { languageModel: e({
|
|
46
49
|
apiKey: n,
|
|
47
|
-
...
|
|
50
|
+
...f
|
|
48
51
|
})(t) };
|
|
49
52
|
}
|
|
50
53
|
case "azure": {
|
|
51
|
-
let { createAzure: e } = await import("./dist-
|
|
54
|
+
let { createAzure: e } = await import("./dist-Crrp-Bno.mjs"), r = e({
|
|
52
55
|
apiKey: n,
|
|
53
56
|
baseURL: i,
|
|
54
|
-
...
|
|
57
|
+
...f
|
|
55
58
|
});
|
|
56
59
|
return {
|
|
57
60
|
languageModel: o ? r.chat(t) : r(t),
|
|
58
|
-
providerOptions:
|
|
61
|
+
providerOptions: l ? { azure: { reasoningEffort: l } } : void 0
|
|
59
62
|
};
|
|
60
63
|
}
|
|
61
64
|
case "openai-compatible": {
|
|
62
65
|
if (!i) throw Error("The provider \"openai-compatible\" needs a baseUrl");
|
|
63
66
|
if (s) {
|
|
64
|
-
let { createOpenAI: e } = await import("./dist-
|
|
67
|
+
let { createOpenAI: e } = await import("./dist-BWNv7qW9.mjs"), r = {
|
|
65
68
|
...!n && !a?.Authorization ? { Authorization: void 0 } : {},
|
|
66
69
|
...a
|
|
67
70
|
};
|
|
@@ -70,44 +73,44 @@ var t = "The images of this result follow in the next message.", n = (e) => e.fl
|
|
|
70
73
|
baseURL: i,
|
|
71
74
|
apiKey: n ?? "none",
|
|
72
75
|
headers: r,
|
|
73
|
-
...
|
|
76
|
+
...f
|
|
74
77
|
}).responses(t),
|
|
75
|
-
providerOptions: { openai: {
|
|
78
|
+
providerOptions: { openai: c ? { store: !0 } : {
|
|
76
79
|
store: !1,
|
|
77
80
|
forceReasoning: !0
|
|
78
81
|
} }
|
|
79
82
|
};
|
|
80
83
|
}
|
|
81
|
-
let { createOpenAICompatible: e } = await import("./dist-
|
|
84
|
+
let { createOpenAICompatible: e } = await import("./dist-0WZWTj8T.mjs");
|
|
82
85
|
return { languageModel: r(e({
|
|
83
86
|
name: "openai-compatible",
|
|
84
87
|
baseURL: i,
|
|
85
88
|
apiKey: n,
|
|
86
89
|
headers: a,
|
|
87
90
|
includeUsage: !0,
|
|
88
|
-
...
|
|
91
|
+
...f
|
|
89
92
|
})(t)) };
|
|
90
93
|
}
|
|
91
94
|
case "mistral": {
|
|
92
|
-
let { createMistral: e } = await import("./dist-
|
|
95
|
+
let { createMistral: e } = await import("./dist-Bc2s-kJZ.mjs");
|
|
93
96
|
return { languageModel: r(e({
|
|
94
97
|
apiKey: n,
|
|
95
|
-
...
|
|
98
|
+
...f
|
|
96
99
|
})(t)) };
|
|
97
100
|
}
|
|
98
101
|
case "anthropic": {
|
|
99
|
-
let { createAnthropic: e } = await import("./dist-
|
|
102
|
+
let { createAnthropic: e } = await import("./dist-CTS0DDwt.mjs");
|
|
100
103
|
return { languageModel: e({
|
|
101
104
|
apiKey: n,
|
|
102
105
|
headers: { "anthropic-dangerous-direct-browser-access": "true" },
|
|
103
|
-
...
|
|
106
|
+
...f
|
|
104
107
|
})(t) };
|
|
105
108
|
}
|
|
106
109
|
case "google": {
|
|
107
|
-
let { createGoogleGenerativeAI: e } = await import("./dist-
|
|
110
|
+
let { createGoogleGenerativeAI: e } = await import("./dist-Cm3aF4sf.mjs");
|
|
108
111
|
return { languageModel: e({
|
|
109
112
|
apiKey: n,
|
|
110
|
-
...
|
|
113
|
+
...f
|
|
111
114
|
})(t) };
|
|
112
115
|
}
|
|
113
116
|
default: throw Error(`Unknown provider "${e}" - supported: azure, openai, openai-compatible, mistral, anthropic, google`);
|
|
@@ -140,69 +143,116 @@ var t = "The images of this result follow in the next message.", n = (e) => e.fl
|
|
|
140
143
|
output: s
|
|
141
144
|
}
|
|
142
145
|
} },
|
|
143
|
-
execute: (n) => t(e, n).catch((e) => ({
|
|
146
|
+
execute: async (n, r) => (r?.abortSignal?.throwIfAborted(), t(e, n).catch((e) => ({
|
|
144
147
|
content: [{
|
|
145
148
|
type: "text",
|
|
146
149
|
text: e instanceof Error ? e.message : String(e)
|
|
147
150
|
}],
|
|
148
151
|
isError: !0
|
|
149
|
-
})),
|
|
152
|
+
}))),
|
|
150
153
|
toModelOutput: a
|
|
151
154
|
}];
|
|
152
|
-
})), s = (e =
|
|
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 = {}) => ({
|
|
153
162
|
inputTokens: e.inputTokens ?? null,
|
|
154
163
|
outputTokens: e.outputTokens ?? null,
|
|
155
164
|
totalTokens: e.totalTokens ?? (e.inputTokens !== void 0 && e.outputTokens !== void 0 ? e.inputTokens + e.outputTokens : null)
|
|
156
|
-
}),
|
|
157
|
-
let
|
|
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([
|
|
158
167
|
import("./dist-6TznX-Ae.mjs").then((e) => e.t),
|
|
159
|
-
i(t),
|
|
168
|
+
i(t, void 0, l),
|
|
160
169
|
a()
|
|
161
170
|
]);
|
|
162
171
|
n.throwIfAborted();
|
|
163
|
-
let [{ streamText:
|
|
164
|
-
return async ({ text:
|
|
165
|
-
let l = [],
|
|
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 = {
|
|
166
175
|
role: "user",
|
|
167
176
|
content: [{
|
|
168
177
|
type: "text",
|
|
169
|
-
text:
|
|
170
|
-
}, ...
|
|
178
|
+
text: n || v.imagePrompt
|
|
179
|
+
}, ...i.map((e) => ({
|
|
171
180
|
type: "file",
|
|
172
181
|
data: e,
|
|
173
182
|
mediaType: "image/jpeg"
|
|
174
183
|
}))]
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
let
|
|
184
|
+
}, O = o?.recovery(y), k = new AbortController(), A = () => k.abort(c.reason);
|
|
185
|
+
c.addEventListener("abort", A, { once: !0 }), c.aborted && A();
|
|
186
|
+
let j = o ? setTimeout(() => k.abort(/* @__PURE__ */ Error("The assistant turn exceeded five minutes.")), o.timeoutMs) : void 0;
|
|
178
187
|
try {
|
|
179
|
-
let e =
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
+
D
|
|
197
|
+
], n = b ? w : void 0, i, a = 0, s = !1, p = [], T, A;
|
|
198
|
+
do {
|
|
199
|
+
T = void 0;
|
|
200
|
+
let b = [], x = a, w = n;
|
|
201
|
+
A = h({
|
|
202
|
+
model: _.languageModel,
|
|
203
|
+
providerOptions: _.providerOptions,
|
|
204
|
+
instructions: v.systemPrompt,
|
|
205
|
+
messages: s ? [...t, ...p].map(d) : [...t, ...p],
|
|
206
|
+
tools: O?.tools ?? y,
|
|
207
|
+
stopWhen: g(16 - x),
|
|
208
|
+
abortSignal: o ? k.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, D] : 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 A.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 = f(e.totalUsage);
|
|
247
|
+
else if (e.type === "abort" && (E = !0, o)) throw k.signal.reason ?? /* @__PURE__ */ Error("Turn aborted");
|
|
248
|
+
T && (p.push(...b), n = void 0, s = !0);
|
|
249
|
+
} while (T);
|
|
250
|
+
if (k.signal.aborted) throw k.signal.reason;
|
|
251
|
+
x.push(D, ...p, ...await A.responseMessages), w = i, r({ type: "done" });
|
|
203
252
|
} catch (t) {
|
|
204
|
-
|
|
205
|
-
n
|
|
253
|
+
w = void 0;
|
|
254
|
+
let n = O?.summary();
|
|
255
|
+
n && x.push(D, {
|
|
206
256
|
role: "assistant",
|
|
207
257
|
content: n
|
|
208
258
|
}), r({
|
|
@@ -211,21 +261,21 @@ var t = "The images of this result follow in the next message.", n = (e) => e.fl
|
|
|
211
261
|
text: `The planning assistant failed: ${t instanceof Error ? t.message : String(t)}${n ? `\n\n${n}` : ""}`
|
|
212
262
|
});
|
|
213
263
|
} finally {
|
|
214
|
-
clearTimeout(
|
|
264
|
+
clearTimeout(j), c.removeEventListener("abort", A);
|
|
215
265
|
let e = {
|
|
216
|
-
inputTokens:
|
|
217
|
-
outputTokens:
|
|
218
|
-
totalTokens:
|
|
219
|
-
},
|
|
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 = m && !E && !k.signal.aborted && Object.values(e).every((e) => e !== null) && l.every((e) => Object.values(e).every((e) => e !== null));
|
|
220
270
|
console.log(`[planning-assistant] usage ${JSON.stringify({
|
|
221
271
|
provider: t.provider,
|
|
222
272
|
model: t.model,
|
|
223
|
-
status:
|
|
273
|
+
status: n ? r ? "complete" : "partial" : "unavailable",
|
|
224
274
|
...e
|
|
225
275
|
})}`);
|
|
226
276
|
}
|
|
227
277
|
};
|
|
228
|
-
},
|
|
278
|
+
}, h = {
|
|
229
279
|
undo: "Undo",
|
|
230
280
|
redo: "Redo",
|
|
231
281
|
"change-component-parameter": "Component parameter change",
|
|
@@ -242,14 +292,14 @@ var t = "The images of this result follow in the next message.", n = (e) => e.fl
|
|
|
242
292
|
"get-docking-positions": "Docking positions read",
|
|
243
293
|
"get-component-docking-positions": "Component docking positions read",
|
|
244
294
|
"get-delete-impact": "Delete impact read"
|
|
245
|
-
},
|
|
295
|
+
}, g = new Set(Object.keys(h).filter((e) => e.startsWith("get-"))), _ = (e) => {
|
|
246
296
|
if (e instanceof Error) return e.message;
|
|
247
297
|
try {
|
|
248
298
|
return typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
|
|
249
299
|
} catch {
|
|
250
300
|
return Object.prototype.toString.call(e);
|
|
251
301
|
}
|
|
252
|
-
},
|
|
302
|
+
}, v = (e) => {
|
|
253
303
|
if (e?.structuredContent !== void 0) return e.structuredContent;
|
|
254
304
|
let t = e?.content?.filter((e) => e.type === "text").map((e) => e.text).join("\n");
|
|
255
305
|
if (t === void 0) return e;
|
|
@@ -258,8 +308,8 @@ var t = "The images of this result follow in the next message.", n = (e) => e.fl
|
|
|
258
308
|
} catch {
|
|
259
309
|
return t;
|
|
260
310
|
}
|
|
261
|
-
},
|
|
262
|
-
if (!e || typeof e != "object") return e == null ? [] : [
|
|
311
|
+
}, y = (e) => {
|
|
312
|
+
if (!e || typeof e != "object") return e == null ? [] : [_(e)];
|
|
263
313
|
let t = [];
|
|
264
314
|
for (let n of [
|
|
265
315
|
"applied",
|
|
@@ -268,11 +318,11 @@ var t = "The images of this result follow in the next message.", n = (e) => e.fl
|
|
|
268
318
|
"confirmed",
|
|
269
319
|
"canUndo",
|
|
270
320
|
"canRedo"
|
|
271
|
-
]) e[n] !== void 0 && t.push(`${n}: ${
|
|
272
|
-
return e.hint && t.push(
|
|
273
|
-
},
|
|
321
|
+
]) e[n] !== void 0 && t.push(`${n}: ${_(e[n])}`);
|
|
322
|
+
return e.hint && t.push(_(e.hint)), t;
|
|
323
|
+
}, b = (e, t = {
|
|
274
324
|
subject: "configuration",
|
|
275
|
-
readTools:
|
|
325
|
+
readTools: g
|
|
276
326
|
}) => {
|
|
277
327
|
let n = [];
|
|
278
328
|
return {
|
|
@@ -281,17 +331,17 @@ var t = "The images of this result follow in the next message.", n = (e) => e.fl
|
|
|
281
331
|
let r = t.execute.bind(t);
|
|
282
332
|
return [e, {
|
|
283
333
|
...t,
|
|
284
|
-
execute: async (t) => {
|
|
285
|
-
let
|
|
334
|
+
execute: async (t, i) => {
|
|
335
|
+
let a = {
|
|
286
336
|
toolName: e,
|
|
287
337
|
status: "pending"
|
|
288
338
|
};
|
|
289
|
-
n.push(
|
|
339
|
+
n.push(a);
|
|
290
340
|
try {
|
|
291
|
-
let e = await r(t);
|
|
292
|
-
return
|
|
341
|
+
let e = await r(t, i);
|
|
342
|
+
return a.result = e, a.status = "returned", e;
|
|
293
343
|
} catch (e) {
|
|
294
|
-
throw
|
|
344
|
+
throw a.error = e, a.status = "threw", e;
|
|
295
345
|
}
|
|
296
346
|
}
|
|
297
347
|
}];
|
|
@@ -300,22 +350,22 @@ var t = "The images of this result follow in the next message.", n = (e) => e.fl
|
|
|
300
350
|
let e = ["The assistant's reply was interrupted. Any text above is incomplete."];
|
|
301
351
|
if (!n.length) return e.push(`No tool ran, so the ${t.subject} was not changed.`), e.join("\n\n");
|
|
302
352
|
for (let r of n) {
|
|
303
|
-
let n =
|
|
353
|
+
let n = h[r.toolName] ?? r.toolName;
|
|
304
354
|
if (t.readTools.has(r.toolName)) {
|
|
305
|
-
let i = r.status === "returned" && !r.result?.isError, a = i ?
|
|
355
|
+
let i = r.status === "returned" && !r.result?.isError, a = i ? v(r.result) : void 0;
|
|
306
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}.`);
|
|
307
357
|
continue;
|
|
308
358
|
}
|
|
309
359
|
if (r.status === "returned" && !r.result?.isError) {
|
|
310
|
-
let i =
|
|
360
|
+
let i = v(r.result);
|
|
311
361
|
if (i?.confirmed === !1) {
|
|
312
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.`);
|
|
313
363
|
continue;
|
|
314
364
|
}
|
|
315
|
-
let a =
|
|
365
|
+
let a = y(i);
|
|
316
366
|
e.push(`- Completed ${n}: ${a.length ? a.join("; ") : "the tool returned successfully."}`);
|
|
317
367
|
} else {
|
|
318
|
-
let i = r.status === "threw" ?
|
|
368
|
+
let i = r.status === "threw" ? _(r.error) : r.status === "returned" ? _(v(r.result)) : "no result was received";
|
|
319
369
|
e.push(`- Unconfirmed ${n}: ${i}. Check the ${t.subject} before trying this operation again.`);
|
|
320
370
|
}
|
|
321
371
|
}
|
|
@@ -324,4 +374,4 @@ var t = "The images of this result follow in the next message.", n = (e) => e.fl
|
|
|
324
374
|
};
|
|
325
375
|
};
|
|
326
376
|
//#endregion
|
|
327
|
-
export { i,
|
|
377
|
+
export { o as a, s as i, m as n, i as o, c as r, b as t };
|