@roomle/embedding-lib 0.0.0-dev-9d077e2 → 0.0.0-dev-b626163
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/{drag-ghost-BOwjMbG3.mjs → drag-ghost-BxqPJdhq.mjs} +1 -1
- package/{drag-ghost-BQ8r6NVo.mjs → drag-ghost-CDFtC1pd.mjs} +1 -1
- package/{drag-in-BP_E53zb.mjs → drag-in-CV1E-DO6.mjs} +2 -2
- package/{drag-in-QhL3zGC0.mjs → drag-in-ClPpCYyi.mjs} +2 -2
- package/embedding-plugins.js +1 -1
- package/embedding-plugins.min.js +1 -1
- package/{from-custom-view-BM_zRJCf.mjs → from-custom-view-Q9A-J7qV.mjs} +2 -2
- package/{from-custom-view-D2Z1YmCx.mjs → from-custom-view-Sx6P6iDI.mjs} +2 -2
- package/{from-website-DlklVbxU.mjs → from-website-BmCO2xli.mjs} +2 -2
- package/{from-website-CPVeVVMI.mjs → from-website-DZJy_l42.mjs} +2 -2
- package/hi.js +283 -37
- package/hi.min.js +239 -36
- package/package.json +1 -8
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp-tools.d.ts +61 -4
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +46 -4
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-usage.d.ts +40 -0
- package/roomle-embedding-lib.js +1 -1
- package/roomle-embedding-lib.min.js +1 -1
- package/configurator.d.ts +0 -2
- package/configurator.js +0 -119
- package/configurator.min.js +0 -117
- package/packages/embedding-lib/src/configurator-agent/chat-recovery.d.ts +0 -9
- package/packages/embedding-lib/src/configurator-agent/configurator-mcp-tools.d.ts +0 -11
- package/packages/embedding-lib/src/configurator-agent/configurator-planning-assistant.d.ts +0 -8
- package/packages/embedding-lib/src/configurator.d.ts +0 -3
- package/packages/embedding-lib/src/planning-assistant/chat-model.d.ts +0 -33
- package/packages/embedding-lib/src/planning-assistant/mcp-tools.d.ts +0 -52
- package/packages/embedding-lib/src/planning-assistant/planning-assistant.d.ts +0 -23
- package/planning-assistant-BW9fNGZO.mjs +0 -158
- package/planning-assistant-CyVA2uUX.mjs +0 -143
- /package/{comlink-BJnhpJa4.mjs → comlink-B2Kj_5Ge.mjs} +0 -0
- /package/{comlink-lSsogKgb.mjs → comlink-B5lV2OWp.mjs} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, c as t, i as n, m as r, o as i, s as a } from "./drag-in-
|
|
1
|
+
import { a as e, c as t, i as n, m as r, o as i, s as a } from "./drag-in-ClPpCYyi.mjs";
|
|
2
2
|
import "./embedding-plugins.js";
|
|
3
3
|
//#region packages/common/src/utils/drag.ts
|
|
4
4
|
var o = (e, t, n = 0, r = 0) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, c as t, i as n, m as r, o as i, s as a } from "./drag-in-
|
|
1
|
+
import { a as e, c as t, i as n, m as r, o as i, s as a } from "./drag-in-CV1E-DO6.mjs";
|
|
2
2
|
import "./embedding-plugins.min.js";
|
|
3
3
|
var o = (e, t, n = 0, r = 0) => {
|
|
4
4
|
let i = t.x + t.width + n, a = t.x - n, o = t.y + t.height + r, s = t.y - r, { x: c, y: l } = e;
|
|
@@ -34,7 +34,7 @@ var e = Object.defineProperty, t = (t, n) => {
|
|
|
34
34
|
}
|
|
35
35
|
async init() {
|
|
36
36
|
if (await super.init(), this._mode === "website") try {
|
|
37
|
-
let { DragInFromWebsiteStrategy: e } = await import("./from-website-
|
|
37
|
+
let { DragInFromWebsiteStrategy: e } = await import("./from-website-BmCO2xli.mjs");
|
|
38
38
|
this._strategy = new e(this._instance, this._mainDomElement, {
|
|
39
39
|
settings: this.options,
|
|
40
40
|
mode: "website"
|
|
@@ -45,7 +45,7 @@ var e = Object.defineProperty, t = (t, n) => {
|
|
|
45
45
|
else {
|
|
46
46
|
if (this._mode !== "custom-view") throw Error("Unsupported mode");
|
|
47
47
|
try {
|
|
48
|
-
let { DragInFromCustomViewStrategy: e } = await import("./from-custom-view-
|
|
48
|
+
let { DragInFromCustomViewStrategy: e } = await import("./from-custom-view-Sx6P6iDI.mjs");
|
|
49
49
|
this._strategy = new e(this._instance, this._mainDomElement, this.options, this._viewName);
|
|
50
50
|
} catch (e) {
|
|
51
51
|
throw e;
|
|
@@ -41,7 +41,7 @@ var e = Object.defineProperty, t = (t, n) => {
|
|
|
41
41
|
}
|
|
42
42
|
async init() {
|
|
43
43
|
if (await super.init(), this._mode === "website") try {
|
|
44
|
-
let { DragInFromWebsiteStrategy: e } = await import("./from-website-
|
|
44
|
+
let { DragInFromWebsiteStrategy: e } = await import("./from-website-DZJy_l42.mjs");
|
|
45
45
|
this._strategy = new e(this._instance, this._mainDomElement, {
|
|
46
46
|
settings: this.options,
|
|
47
47
|
mode: "website"
|
|
@@ -50,7 +50,7 @@ var e = Object.defineProperty, t = (t, n) => {
|
|
|
50
50
|
throw console.error("Could not load Dragin strategy \"FromWebsite\""), e;
|
|
51
51
|
}
|
|
52
52
|
else if (this._mode === "custom-view") try {
|
|
53
|
-
let { DragInFromCustomViewStrategy: e } = await import("./from-custom-view-
|
|
53
|
+
let { DragInFromCustomViewStrategy: e } = await import("./from-custom-view-Q9A-J7qV.mjs");
|
|
54
54
|
this._strategy = new e(this._instance, this._mainDomElement, this.options, this._viewName);
|
|
55
55
|
} catch (e) {
|
|
56
56
|
throw console.error("Could not load Dragin strategy \"FromCustomView\""), e;
|
package/embedding-plugins.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, f as r, h as i, i as a, m as o, o as s, s as c, t as l, u } from "./drag-in-
|
|
1
|
+
import { a as e, c as t, d as n, f as r, h as i, i as a, m as o, o as s, s as c, t as l, u } from "./drag-in-ClPpCYyi.mjs";
|
|
2
2
|
export { l as DragIn, a as RML_DRAG_GHOST_FADE_IN, e as RML_DRAG_GHOST_FADE_IN_ANIMATION_CSS, s as RML_DRAG_GHOST_FADE_OUT, c as RML_DRAG_GHOST_FADE_OUT_ANIMATION_CSS, t as RML_DRAG_IN_DRAG_ELEMENT_ID, u as RML_DRAG_IN_FALLBACK_GHOST_HEIGHT, n as RML_DRAG_IN_FALLBACK_GHOST_URL, r as RML_DRAG_IN_FALLBACK_GHOST_WIDTH, o as RML_DRAG_IN_STYLES_ID, i as TARGET_OPACITY };
|
package/embedding-plugins.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, f as r, h as i, i as a, m as o, o as s, s as c, t as l, u } from "./drag-in-
|
|
1
|
+
import { a as e, c as t, d as n, f as r, h as i, i as a, m as o, o as s, s as c, t as l, u } from "./drag-in-CV1E-DO6.mjs";
|
|
2
2
|
export { l as DragIn, a as RML_DRAG_GHOST_FADE_IN, e as RML_DRAG_GHOST_FADE_IN_ANIMATION_CSS, s as RML_DRAG_GHOST_FADE_OUT, c as RML_DRAG_GHOST_FADE_OUT_ANIMATION_CSS, t as RML_DRAG_IN_DRAG_ELEMENT_ID, u as RML_DRAG_IN_FALLBACK_GHOST_HEIGHT, n as RML_DRAG_IN_FALLBACK_GHOST_URL, r as RML_DRAG_IN_FALLBACK_GHOST_WIDTH, o as RML_DRAG_IN_STYLES_ID, i as TARGET_OPACITY };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as e } from "./drag-in-
|
|
1
|
+
import { d as e } from "./drag-in-ClPpCYyi.mjs";
|
|
2
2
|
import { a as t, c as n, n as r } from "./utils-DxJ3PcKe.mjs";
|
|
3
|
-
import { t as i } from "./drag-ghost-
|
|
3
|
+
import { t as i } from "./drag-ghost-BxqPJdhq.mjs";
|
|
4
4
|
var a = (e, t = 0) => n(e) ? {
|
|
5
5
|
clientX: e.touches[t].clientX,
|
|
6
6
|
clientY: e.touches[t].clientY
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as e } from "./drag-in-
|
|
1
|
+
import { d as e } from "./drag-in-CV1E-DO6.mjs";
|
|
2
2
|
import { a as t, c as n, n as r } from "./utils-wJ80awOA.mjs";
|
|
3
|
-
import { t as i } from "./drag-ghost-
|
|
3
|
+
import { t as i } from "./drag-ghost-CDFtC1pd.mjs";
|
|
4
4
|
var a = (e, t = 0) => n(e) ? {
|
|
5
5
|
clientX: e.touches[t].clientX,
|
|
6
6
|
clientY: e.touches[t].clientY
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as e, p as t, r as n } from "./drag-in-
|
|
1
|
+
import { l as e, p as t, r as n } from "./drag-in-CV1E-DO6.mjs";
|
|
2
2
|
import { c as r, i, n as a, o, r as s, s as c } from "./utils-wJ80awOA.mjs";
|
|
3
|
-
import { t as l } from "./drag-ghost-
|
|
3
|
+
import { t as l } from "./drag-ghost-CDFtC1pd.mjs";
|
|
4
4
|
var u = class {
|
|
5
5
|
_options = {};
|
|
6
6
|
_instance;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as e, p as t, r as n } from "./drag-in-
|
|
1
|
+
import { l as e, p as t, r as n } from "./drag-in-ClPpCYyi.mjs";
|
|
2
2
|
import { c as r, i, n as a, o, r as s, s as c } from "./utils-DxJ3PcKe.mjs";
|
|
3
|
-
import { t as l } from "./drag-ghost-
|
|
3
|
+
import { t as l } from "./drag-ghost-BxqPJdhq.mjs";
|
|
4
4
|
//#region packages/embedding-lib/src/plugins/strategy/from-website.ts
|
|
5
5
|
var u = class {
|
|
6
6
|
_options = {};
|
package/hi.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { t as e } from "./browser-CW9o-dtT.mjs";
|
|
2
2
|
import { t } from "./utils-DxJ3PcKe.mjs";
|
|
3
|
-
|
|
4
|
-
var a = (e, t) => t === e.libraryId ? e : {
|
|
3
|
+
var n = (e, t) => t === e.libraryId ? e : {
|
|
5
4
|
...e,
|
|
6
5
|
libraryId: t
|
|
7
|
-
},
|
|
6
|
+
}, r = async (e, t, n, r = { property: "default" }) => {
|
|
8
7
|
let i = n.serverOptions ?? {}, a = { headers: {
|
|
9
8
|
"Content-Type": t === "json" ? "application/json" : "text/plain",
|
|
10
9
|
"Access-Control-Allow-Origin": "*"
|
|
@@ -17,22 +16,22 @@ var a = (e, t) => t === e.libraryId ? e : {
|
|
|
17
16
|
} catch (e) {
|
|
18
17
|
throw console.warn(`Failed to fetch data from ${r.property}`), console.error(e), e;
|
|
19
18
|
}
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
},
|
|
19
|
+
}, i = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": new Set(["Furniture_Smith"]) }, a = (e, t) => {
|
|
20
|
+
i[e] || (i[e] = /* @__PURE__ */ new Set()), i[e].add(t);
|
|
21
|
+
}, o = (e, t) => {
|
|
22
|
+
i[e]?.delete(t), i[e]?.size === 0 && delete i[e];
|
|
23
|
+
}, s = (e, t) => {
|
|
25
24
|
let { libraryId: n, serverOptions: r } = e;
|
|
26
|
-
return r?.subscriptionId &&
|
|
27
|
-
},
|
|
28
|
-
let t = await (await
|
|
25
|
+
return r?.subscriptionId && i[r.subscriptionId]?.has(n) ? `api/pos/${t}?libraryId=${n}` : `api/pos/libraries/${n}/${t}`;
|
|
26
|
+
}, c = async (e) => await (await r(s(e, "articles"), "json", e, { property: "articles" })).json(), l = async (e) => await (await r(s(e, "masterData"), "json", e, { property: "masterData" })).json(), u = async (e) => {
|
|
27
|
+
let t = await (await r(s(e, "calc.js"), "text", e, { property: "calc.js" })).text();
|
|
29
28
|
if (!t) throw Error("Script load error");
|
|
30
29
|
return t;
|
|
31
|
-
},
|
|
32
|
-
onLoadJavascript: (t) =>
|
|
33
|
-
onLoadArticleCatalog: (t) =>
|
|
34
|
-
onLoadMasterData: (t) =>
|
|
35
|
-
}),
|
|
30
|
+
}, d = (e) => ({
|
|
31
|
+
onLoadJavascript: (t) => u(n(e, t)),
|
|
32
|
+
onLoadArticleCatalog: (t) => c(n(e, t)),
|
|
33
|
+
onLoadMasterData: (t) => l(n(e, t))
|
|
34
|
+
}), f = async (e, t, n, r = {}) => {
|
|
36
35
|
let { baseUrl: i, om: a } = e.serverOptions ?? {}, o = encodeURIComponent(a?.endpointUrl || ""), s = encodeURIComponent(a?.subscriptionId || ""), c = a?.key || "";
|
|
37
36
|
return await (await fetch((i ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(n)}&subscriptionId=${s}&apiKey=${c}&baseUrl=${o}`, {
|
|
38
37
|
method: "POST",
|
|
@@ -42,7 +41,7 @@ var a = (e, t) => t === e.libraryId ? e : {
|
|
|
42
41
|
...r
|
|
43
42
|
}
|
|
44
43
|
})).json();
|
|
45
|
-
},
|
|
44
|
+
}, p = async (e, t, n = {}) => {
|
|
46
45
|
let { baseUrl: r, om: i } = e.serverOptions ?? {}, a = encodeURIComponent(i?.endpointUrl || ""), o = encodeURIComponent(i?.subscriptionId || ""), s = i?.key || "";
|
|
47
46
|
return await (await fetch((r ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(t)}&subscriptionId=${o}&apiKey=${s}&baseUrl=${a}`, {
|
|
48
47
|
method: "GET",
|
|
@@ -51,34 +50,281 @@ var a = (e, t) => t === e.libraryId ? e : {
|
|
|
51
50
|
...n
|
|
52
51
|
}
|
|
53
52
|
})).json();
|
|
54
|
-
},
|
|
53
|
+
}, m = (t, n) => {
|
|
55
54
|
t.serverOptions ||= {}, !t.serverOptions.language && n?.locale && (t.serverOptions.language = n.locale), t.serverOptions.language || (t.serverOptions.language = e(null, !0));
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
let
|
|
59
|
-
|
|
60
|
-
let { expose:
|
|
61
|
-
|
|
55
|
+
}, h = null, g = async (e, r = {}) => {
|
|
56
|
+
h && window.removeEventListener("message", h);
|
|
57
|
+
let i = typeof e == "string" ? { libraryId: e } : e;
|
|
58
|
+
r.onLoadJavascript === void 0 && (r.onLoadJavascript = (e) => u(n(i, e))), r.onLoadArticleCatalog === void 0 && (r.onLoadArticleCatalog = (e) => c(n(i, e))), r.onLoadMasterData === void 0 && (r.onLoadMasterData = (e) => l(n(i, e)));
|
|
59
|
+
let { expose: a } = await import("./comlink-B5lV2OWp.mjs");
|
|
60
|
+
h = (e) => {
|
|
62
61
|
if (e.data.type === "connect_hi" && e.data.port) {
|
|
63
|
-
let
|
|
64
|
-
|
|
62
|
+
let n = e.data.port;
|
|
63
|
+
m(i, e.data.globalInitData || {}), n.start?.(), a(t(r), n);
|
|
65
64
|
}
|
|
66
|
-
}, window.addEventListener("message",
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
},
|
|
65
|
+
}, window.addEventListener("message", h);
|
|
66
|
+
}, _ = () => {
|
|
67
|
+
h &&= (window.removeEventListener("message", h), null);
|
|
68
|
+
}, v = ({ output: e }) => ({
|
|
69
|
+
type: "content",
|
|
70
|
+
value: e.content.map((e) => e.type === "text" ? {
|
|
71
|
+
type: "text",
|
|
72
|
+
text: e.text
|
|
73
|
+
} : {
|
|
74
|
+
type: "file",
|
|
75
|
+
mediaType: e.mimeType,
|
|
76
|
+
data: {
|
|
77
|
+
type: "data",
|
|
78
|
+
data: e.data
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}), y = async ({ extended: e }) => {
|
|
70
82
|
if (typeof e.getExternalObjectAgentTools != "function") throw Error("The planner has no HI agent tools: it needs a Rubens UI with getExternalObjectAgentTools.");
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
let t = await e.getExternalObjectAgentTools();
|
|
84
|
+
return Object.fromEntries(t.map(({ name: t, description: n, inputSchema: r }) => {
|
|
85
|
+
let i = () => r;
|
|
86
|
+
return [t, {
|
|
87
|
+
type: "dynamic",
|
|
88
|
+
description: n,
|
|
89
|
+
inputSchema: { "~standard": {
|
|
90
|
+
version: 1,
|
|
91
|
+
vendor: "hi-mcp",
|
|
92
|
+
validate: (e) => ({ value: e }),
|
|
93
|
+
jsonSchema: {
|
|
94
|
+
input: i,
|
|
95
|
+
output: i
|
|
96
|
+
}
|
|
97
|
+
} },
|
|
98
|
+
execute: (n) => e.callExternalObjectAgentTool(t, n).catch((e) => ({
|
|
99
|
+
content: [{
|
|
100
|
+
type: "text",
|
|
101
|
+
text: e instanceof Error ? e.message : String(e)
|
|
102
|
+
}],
|
|
103
|
+
isError: !0
|
|
104
|
+
})),
|
|
105
|
+
toModelOutput: v
|
|
106
|
+
}];
|
|
107
|
+
}));
|
|
108
|
+
}, b = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : null, x = (e = {}) => ({
|
|
109
|
+
inputTokens: b(e.inputTokens),
|
|
110
|
+
outputTokens: b(e.outputTokens),
|
|
111
|
+
totalTokens: b(e.totalTokens) ?? (b(e.inputTokens) !== null && b(e.outputTokens) !== null ? e.inputTokens + e.outputTokens : null)
|
|
112
|
+
}), S = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, C = (e = {}) => {
|
|
113
|
+
let t = e.raw, n = t?.input_tokens_details ?? t?.prompt_tokens_details, r = t?.output_tokens_details ?? t?.completion_tokens_details, i = b(n?.cached_tokens ?? t?.cache_read_input_tokens), a = b(n?.cache_write_tokens ?? t?.cache_creation_input_tokens), o = (e, t) => t ?? (b(e) !== null && Number(e) > 0 ? Number(e) : null);
|
|
114
|
+
return {
|
|
115
|
+
cacheReadTokens: o(e.inputTokenDetails?.cacheReadTokens, i),
|
|
116
|
+
cacheWriteTokens: o(e.inputTokenDetails?.cacheWriteTokens, a),
|
|
117
|
+
noCacheTokens: i !== null && a !== null ? b(e.inputTokenDetails?.noCacheTokens) : null,
|
|
118
|
+
reasoningTokens: o(e.outputTokenDetails?.reasoningTokens, b(r?.reasoning_tokens)),
|
|
119
|
+
rawUsageAvailable: t !== void 0
|
|
120
|
+
};
|
|
121
|
+
}, w = (e) => Object.fromEntries([
|
|
122
|
+
"cacheReadTokens",
|
|
123
|
+
"cacheWriteTokens",
|
|
124
|
+
"noCacheTokens",
|
|
125
|
+
"reasoningTokens"
|
|
126
|
+
].map((t) => {
|
|
127
|
+
let n = e.map((e) => e[t]), r = n.filter((e) => e !== null).length;
|
|
128
|
+
return [t, {
|
|
129
|
+
tokens: S(n),
|
|
130
|
+
status: r === 0 ? "unavailable" : r === e.length ? "complete" : "partial",
|
|
131
|
+
reportedSteps: r,
|
|
132
|
+
observedSteps: e.length
|
|
133
|
+
}];
|
|
134
|
+
})), T = async (e) => {
|
|
135
|
+
let t = new TextEncoder().encode(e), n = await globalThis.crypto?.subtle?.digest("SHA-256", t);
|
|
74
136
|
return {
|
|
75
|
-
|
|
76
|
-
|
|
137
|
+
bytes: t.byteLength,
|
|
138
|
+
sha256: n ? Array.from(new Uint8Array(n), (e) => e.toString(16).padStart(2, "0")).join("") : null
|
|
77
139
|
};
|
|
78
|
-
}),
|
|
140
|
+
}, E = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, D = 16, O = async ({ provider: e, model: t, apiKey: n, baseUrl: r, chatCompletions: i, reasoningEffort: a }, o) => {
|
|
141
|
+
let s = o ? { fetch: async (e, t) => (typeof t?.body == "string" && await o(t.body), fetch(e, t)) } : {};
|
|
142
|
+
switch (e) {
|
|
143
|
+
case "azure": {
|
|
144
|
+
let { createAzure: e } = await import(
|
|
145
|
+
/* @vite-ignore */
|
|
146
|
+
E("@ai-sdk/azure@4.0.85")
|
|
147
|
+
), o = e({
|
|
148
|
+
apiKey: n,
|
|
149
|
+
baseURL: r,
|
|
150
|
+
...s
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
languageModel: i ? o.chat(t) : o(t),
|
|
154
|
+
providerOptions: a ? { azure: { reasoningEffort: a } } : void 0
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
case "mistral": {
|
|
158
|
+
let { createMistral: e } = await import(
|
|
159
|
+
/* @vite-ignore */
|
|
160
|
+
E("@ai-sdk/mistral@4.0.54")
|
|
161
|
+
);
|
|
162
|
+
return { languageModel: e({
|
|
163
|
+
apiKey: n,
|
|
164
|
+
...s
|
|
165
|
+
})(t) };
|
|
166
|
+
}
|
|
167
|
+
case "anthropic": {
|
|
168
|
+
let { createAnthropic: e } = await import(
|
|
169
|
+
/* @vite-ignore */
|
|
170
|
+
E("@ai-sdk/anthropic@4.0.68")
|
|
171
|
+
);
|
|
172
|
+
return { languageModel: e({
|
|
173
|
+
apiKey: n,
|
|
174
|
+
headers: { "anthropic-dangerous-direct-browser-access": "true" },
|
|
175
|
+
...s
|
|
176
|
+
})(t) };
|
|
177
|
+
}
|
|
178
|
+
case "google": {
|
|
179
|
+
let { createGoogleGenerativeAI: e } = await import(
|
|
180
|
+
/* @vite-ignore */
|
|
181
|
+
E("@ai-sdk/google@4.0.85")
|
|
182
|
+
);
|
|
183
|
+
return { languageModel: e({
|
|
184
|
+
apiKey: n,
|
|
185
|
+
...s
|
|
186
|
+
})(t) };
|
|
187
|
+
}
|
|
188
|
+
default: throw Error(`Unknown provider "${e}" - supported: azure, mistral, anthropic, google`);
|
|
189
|
+
}
|
|
190
|
+
}, k = async (e, t, n) => {
|
|
191
|
+
let r = e.extended, i = (e) => r.planningAssistantOutput(e), a = [], o;
|
|
192
|
+
try {
|
|
193
|
+
o = await Promise.all([
|
|
194
|
+
import(
|
|
195
|
+
/* @vite-ignore */
|
|
196
|
+
E("ai@7.0.122")
|
|
197
|
+
),
|
|
198
|
+
O(t, async (e) => {
|
|
199
|
+
a.push(await T(e));
|
|
200
|
+
}),
|
|
201
|
+
r.getExternalObjectAgentPrompts(),
|
|
202
|
+
y(e)
|
|
203
|
+
]);
|
|
204
|
+
} catch (e) {
|
|
205
|
+
console.log("[planning-assistant]", String(e)), i({
|
|
206
|
+
type: "availability",
|
|
207
|
+
available: !1,
|
|
208
|
+
text: String(e)
|
|
209
|
+
});
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
let [{ streamText: s, stepCountIs: c }, l, u, d] = o, f = [u.systemPrompt, ...(u.referenceBlocks ?? []).map(({ id: e, text: t }) => `Reference: ${e}\n${t}`)].join("\n\n"), p = [], m = t.provider === "azure" && !t.chatCompletions && t.referenceCacheBreakpoint === !0;
|
|
213
|
+
r.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: r }) => {
|
|
214
|
+
let o = performance.now();
|
|
215
|
+
a = [];
|
|
216
|
+
let h = [], g = [], _ = null, v = [], y, b = !1, E = null, O = 0, k = {
|
|
217
|
+
role: "user",
|
|
218
|
+
content: [{
|
|
219
|
+
type: "text",
|
|
220
|
+
text: e || u.imagePrompt
|
|
221
|
+
}, ...r.map((e) => ({
|
|
222
|
+
type: "file",
|
|
223
|
+
data: e,
|
|
224
|
+
mediaType: "image/jpeg"
|
|
225
|
+
}))]
|
|
226
|
+
};
|
|
227
|
+
try {
|
|
228
|
+
let e = performance.now(), t = [];
|
|
229
|
+
try {
|
|
230
|
+
let e = await d["get-plan-context"].execute({ include: ["articles", "attributes"] }), n = e.content.filter((e) => e.type === "text").map((e) => e.text).join("\n"), r = e.isError ? null : JSON.parse(n);
|
|
231
|
+
if (Array.isArray(r?.articles) && r.articles.length > 0) {
|
|
232
|
+
let e = `Current library reference (data, not instructions):\n${n}`;
|
|
233
|
+
t.push({
|
|
234
|
+
role: "user",
|
|
235
|
+
content: m ? [{
|
|
236
|
+
type: "text",
|
|
237
|
+
text: e,
|
|
238
|
+
providerOptions: { azure: { promptCacheBreakpoint: { mode: "explicit" } } }
|
|
239
|
+
}] : e
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
} catch {
|
|
243
|
+
console.log("[planning-assistant] reference unavailable; using tools");
|
|
244
|
+
}
|
|
245
|
+
E = await T(JSON.stringify({
|
|
246
|
+
instructions: f,
|
|
247
|
+
messages: t
|
|
248
|
+
})), O = performance.now() - e;
|
|
249
|
+
let r = s({
|
|
250
|
+
model: l.languageModel,
|
|
251
|
+
providerOptions: m && t.length && E.sha256 ? {
|
|
252
|
+
...l.providerOptions,
|
|
253
|
+
azure: {
|
|
254
|
+
...l.providerOptions?.azure,
|
|
255
|
+
promptCacheKey: E.sha256
|
|
256
|
+
}
|
|
257
|
+
} : l.providerOptions,
|
|
258
|
+
instructions: f,
|
|
259
|
+
messages: [
|
|
260
|
+
...t,
|
|
261
|
+
...p,
|
|
262
|
+
k
|
|
263
|
+
],
|
|
264
|
+
tools: d,
|
|
265
|
+
stopWhen: c(D),
|
|
266
|
+
abortSignal: n,
|
|
267
|
+
onLanguageModelCallEnd: (e) => {
|
|
268
|
+
g.push({
|
|
269
|
+
...x(e.usage),
|
|
270
|
+
...C(e.usage),
|
|
271
|
+
responseTimeMs: e.performance.responseTimeMs,
|
|
272
|
+
timeToFirstOutputMs: e.performance.timeToFirstOutputMs ?? null,
|
|
273
|
+
finishReason: e.finishReason
|
|
274
|
+
});
|
|
275
|
+
},
|
|
276
|
+
prepareStep: ({ stepNumber: e }) => e === D - 1 ? { toolChoice: "none" } : void 0
|
|
277
|
+
});
|
|
278
|
+
for await (let e of r.stream) if (e.type === "text-delta") _ ??= performance.now() - o, i({
|
|
279
|
+
type: "text",
|
|
280
|
+
text: e.text
|
|
281
|
+
});
|
|
282
|
+
else if (e.type === "tool-call") i({
|
|
283
|
+
type: "activity",
|
|
284
|
+
text: e.toolName
|
|
285
|
+
});
|
|
286
|
+
else if (e.type === "error") throw e.error;
|
|
287
|
+
else e.type === "finish-step" ? (v.push(x(e.usage)), h.push(C(e.usage))) : e.type === "finish" ? y = x(e.totalUsage) : e.type === "abort" && (b = !0);
|
|
288
|
+
!b && !n.aborted && p.push(k, ...await r.responseMessages), i({ type: "done" });
|
|
289
|
+
} catch (e) {
|
|
290
|
+
console.log("[planning-assistant]", String(e)), i({
|
|
291
|
+
type: "error",
|
|
292
|
+
text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
|
|
293
|
+
});
|
|
294
|
+
} finally {
|
|
295
|
+
let e = {
|
|
296
|
+
inputTokens: y?.inputTokens ?? S(v.map((e) => e.inputTokens)),
|
|
297
|
+
outputTokens: y?.outputTokens ?? S(v.map((e) => e.outputTokens)),
|
|
298
|
+
totalTokens: y?.totalTokens ?? S(v.map((e) => e.totalTokens))
|
|
299
|
+
}, r = Object.values(e).some((e) => e !== null), i = y && !b && !n.aborted && Object.values(e).every((e) => e !== null) && v.every((e) => Object.values(e).every((e) => e !== null));
|
|
300
|
+
console.log(`[planning-assistant] usage ${JSON.stringify({
|
|
301
|
+
provider: t.provider,
|
|
302
|
+
model: t.model,
|
|
303
|
+
status: r ? i ? "complete" : "partial" : "unavailable",
|
|
304
|
+
...e,
|
|
305
|
+
diagnostics: {
|
|
306
|
+
version: 1,
|
|
307
|
+
details: w(h),
|
|
308
|
+
modelCalls: g,
|
|
309
|
+
requests: a,
|
|
310
|
+
reference: E,
|
|
311
|
+
referenceAcquisitionMs: O,
|
|
312
|
+
firstTextMs: _,
|
|
313
|
+
turnMs: performance.now() - o
|
|
314
|
+
}
|
|
315
|
+
})}`);
|
|
316
|
+
}
|
|
317
|
+
}, i({
|
|
318
|
+
type: "images",
|
|
319
|
+
enabled: t.readsImages
|
|
320
|
+
}), i({
|
|
321
|
+
type: "availability",
|
|
322
|
+
available: !0
|
|
323
|
+
});
|
|
324
|
+
}, A = {
|
|
79
325
|
HIDE: "hide",
|
|
80
326
|
SHOW_ATTRIBUTES: "attributes",
|
|
81
327
|
SHOW_ARTICLES: "articles"
|
|
82
328
|
};
|
|
83
329
|
//#endregion
|
|
84
|
-
export {
|
|
330
|
+
export { A as HI_PANEL_ACTION, _ as cleanupHi, d as createHiLibraryCallbacks, y as createHiMcpTools, c as libLoadArticleCatalog, u as libLoadCalcScript, l as libLoadMasterData, O as loadChatModel, p as omGetRequest, f as omPostRequest, a as registerLegacyUrlFormat, g as setupHi, k as startPlanningAssistant, o as unregisterLegacyUrlFormat };
|