@roomle/embedding-lib 10.0.0 → 11.0.0-alpha.10

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