@roomle/embedding-lib 9.0.0-alpha.9 → 9.1.0-alpha.1
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 +764 -0
- package/{browser-BxG7yIaK.mjs → browser-D6As4Zxr.mjs} +1 -0
- package/{browser-CW9o-dtT.mjs → browser-zrjtYpL8.mjs} +1 -0
- package/coerce-CqJod_GZ.mjs +8 -0
- package/coerce-CsI42_k0.mjs +6 -0
- package/{comlink-B5lV2OWp.mjs → comlink-Cmiqa2s0.mjs} +1 -0
- package/{comlink-B2Kj_5Ge.mjs → comlink-Dc3LZUoi.mjs} +1 -0
- package/configurator.d.ts +2 -0
- package/configurator.js +29 -0
- package/configurator.min.js +27 -0
- package/dist-5jYYtT4q.mjs +8216 -0
- package/dist-B9yy8ym8.mjs +5512 -0
- package/dist-BV-32IEX.mjs +8128 -0
- package/dist-Bb2L1Zel.mjs +6045 -0
- package/dist-Bo3WzRdf.mjs +6223 -0
- package/dist-Bt1FopV4.mjs +7594 -0
- package/dist-C5fKJXpB.mjs +5598 -0
- package/dist-COgAdYY1.mjs +7554 -0
- package/dist-CXemOs84.mjs +849 -0
- package/dist-CqP0aX0A.mjs +866 -0
- package/dist-CqpDM10w.mjs +1179 -0
- package/dist-D0kh4WfT.mjs +7721 -0
- package/dist-D5HdKuwj.mjs +1221 -0
- package/dist-DJtonrDM.mjs +16906 -0
- package/dist-GTk8ppiK.mjs +8380 -0
- package/dist-XEy6Tk_Y.mjs +17341 -0
- package/docs/md/web/embedding/CHANGELOG.md +285 -4
- package/{drag-ghost-CDFtC1pd.mjs → drag-ghost-D7FnWbO4.mjs} +2 -1
- package/{drag-ghost-BxqPJdhq.mjs → drag-ghost-yXe7c8jA.mjs} +2 -1
- package/{drag-in-ClPpCYyi.mjs → drag-in-BiEe2Lgv.mjs} +15 -20
- package/{drag-in-CV1E-DO6.mjs → drag-in-t7T6Pqwc.mjs} +10 -15
- package/embedding-plugins.js +2 -1
- package/embedding-plugins.min.js +2 -1
- package/experimental-evaluation-BgWFolud.mjs +1074 -0
- package/experimental-evaluation-D56MbtjO.mjs +970 -0
- package/{from-custom-view-Sx6P6iDI.mjs → from-custom-view-CTBapIc6.mjs} +31 -30
- package/{from-custom-view-Q9A-J7qV.mjs → from-custom-view-xbjgsLll.mjs} +32 -31
- package/{from-website-DZJy_l42.mjs → from-website-DUPMQPl6.mjs} +24 -23
- package/{from-website-BmCO2xli.mjs → from-website-JwG7Ic_U.mjs} +24 -23
- package/hi.js +249 -150
- package/hi.min.js +211 -134
- package/mcp-tools-CJ7j_FI2.mjs +151 -0
- package/mcp-tools-D__M74CZ.mjs +153 -0
- package/package.json +12 -1
- package/packages/embedding-lib/src/configurator-agent/configurator-mcp-tools.d.ts +4 -0
- package/packages/embedding-lib/src/configurator-agent/configurator-planning-assistant.d.ts +13 -0
- package/packages/embedding-lib/src/configurator.d.ts +3 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp-tools.d.ts +4 -61
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +9 -32
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-usage.d.ts +54 -0
- package/packages/embedding-lib/src/planning-assistant/chat-model.d.ts +1 -0
- package/packages/embedding-lib/src/planning-assistant/mcp-tools.d.ts +2 -0
- package/packages/web-sdk/packages/assistant.d.ts +3 -0
- package/packages/web-sdk/packages/common-core/src/agent-tools/mcp-tool-types.d.ts +30 -0
- package/packages/web-sdk/packages/common-core/src/planning-assistant/chat-model.d.ts +8 -0
- package/packages/web-sdk/packages/common-core/src/planning-assistant/mcp-tools.d.ts +52 -0
- package/packages/web-sdk/packages/common-core/src/planning-assistant/types.d.ts +35 -0
- package/roomle-embedding-lib.js +43 -45
- package/roomle-embedding-lib.min.js +39 -41
- package/sbom.cdx.json +405 -0
- package/{utils-wJ80awOA.mjs → utils-CAAGdgk8.mjs} +1 -0
- package/{utils-DxJ3PcKe.mjs → utils-WeolMfC5.mjs} +1 -0
package/hi.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { t } from "./
|
|
3
|
-
|
|
1
|
+
/*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
|
|
2
|
+
import { t as e } from "./browser-zrjtYpL8.mjs";
|
|
3
|
+
import { t } from "./utils-WeolMfC5.mjs";
|
|
4
|
+
import { n, t as r } from "./mcp-tools-D__M74CZ.mjs";
|
|
5
|
+
var i = (e, t) => t === e.libraryId ? e : {
|
|
4
6
|
...e,
|
|
5
7
|
libraryId: t
|
|
6
|
-
},
|
|
8
|
+
}, a = async (e, t, n, r = { property: "default" }) => {
|
|
7
9
|
let i = n.serverOptions ?? {}, a = { headers: {
|
|
8
10
|
"Content-Type": t === "json" ? "application/json" : "text/plain",
|
|
9
11
|
"Access-Control-Allow-Origin": "*"
|
|
@@ -16,22 +18,22 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
16
18
|
} catch (e) {
|
|
17
19
|
throw console.warn(`Failed to fetch data from ${r.property}`), console.error(e), e;
|
|
18
20
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
},
|
|
21
|
+
}, o = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": new Set(["Furniture_Smith"]) }, s = (e, t) => {
|
|
22
|
+
o[e] || (o[e] = /* @__PURE__ */ new Set()), o[e].add(t);
|
|
23
|
+
}, c = (e, t) => {
|
|
24
|
+
o[e]?.delete(t), o[e]?.size === 0 && delete o[e];
|
|
25
|
+
}, l = (e, t) => {
|
|
24
26
|
let { libraryId: n, serverOptions: r } = e;
|
|
25
|
-
return r?.subscriptionId &&
|
|
26
|
-
},
|
|
27
|
-
let t = await (await
|
|
27
|
+
return r?.subscriptionId && o[r.subscriptionId]?.has(n) ? `api/pos/${t}?libraryId=${n}` : `api/pos/libraries/${n}/${t}`;
|
|
28
|
+
}, u = async (e) => await (await a(l(e, "articles"), "json", e, { property: "articles" })).json(), d = async (e) => await (await a(l(e, "masterData"), "json", e, { property: "masterData" })).json(), f = async (e) => {
|
|
29
|
+
let t = await (await a(l(e, "calc.js"), "text", e, { property: "calc.js" })).text();
|
|
28
30
|
if (!t) throw Error("Script load error");
|
|
29
31
|
return t;
|
|
30
|
-
},
|
|
31
|
-
onLoadJavascript: (t) =>
|
|
32
|
-
onLoadArticleCatalog: (t) =>
|
|
33
|
-
onLoadMasterData: (t) =>
|
|
34
|
-
}),
|
|
32
|
+
}, p = (e) => ({
|
|
33
|
+
onLoadJavascript: (t) => f(i(e, t)),
|
|
34
|
+
onLoadArticleCatalog: (t) => u(i(e, t)),
|
|
35
|
+
onLoadMasterData: (t) => d(i(e, t))
|
|
36
|
+
}), m = async (e, t, n, r = {}) => {
|
|
35
37
|
let { baseUrl: i, om: a } = e.serverOptions ?? {}, o = encodeURIComponent(a?.endpointUrl || ""), s = encodeURIComponent(a?.subscriptionId || ""), c = a?.key || "";
|
|
36
38
|
return await (await fetch((i ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(n)}&subscriptionId=${s}&apiKey=${c}&baseUrl=${o}`, {
|
|
37
39
|
method: "POST",
|
|
@@ -41,7 +43,7 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
41
43
|
...r
|
|
42
44
|
}
|
|
43
45
|
})).json();
|
|
44
|
-
},
|
|
46
|
+
}, h = async (e, t, n = {}) => {
|
|
45
47
|
let { baseUrl: r, om: i } = e.serverOptions ?? {}, a = encodeURIComponent(i?.endpointUrl || ""), o = encodeURIComponent(i?.subscriptionId || ""), s = i?.key || "";
|
|
46
48
|
return await (await fetch((r ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(t)}&subscriptionId=${o}&apiKey=${s}&baseUrl=${a}`, {
|
|
47
49
|
method: "GET",
|
|
@@ -50,173 +52,270 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
50
52
|
...n
|
|
51
53
|
}
|
|
52
54
|
})).json();
|
|
53
|
-
},
|
|
55
|
+
}, g = (t, n) => {
|
|
54
56
|
t.serverOptions ||= {}, !t.serverOptions.language && n?.locale && (t.serverOptions.language = n.locale), t.serverOptions.language || (t.serverOptions.language = e(null, !0));
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
let { expose: a } = await import("./comlink-
|
|
60
|
-
|
|
57
|
+
}, _ = null, v = async (e, n = {}) => {
|
|
58
|
+
_ && window.removeEventListener("message", _);
|
|
59
|
+
let r = typeof e == "string" ? { libraryId: e } : e;
|
|
60
|
+
n.onLoadJavascript === void 0 && (n.onLoadJavascript = (e) => f(i(r, e))), n.onLoadArticleCatalog === void 0 && (n.onLoadArticleCatalog = (e) => u(i(r, e))), n.onLoadMasterData === void 0 && (n.onLoadMasterData = (e) => d(i(r, e)));
|
|
61
|
+
let { expose: a } = await import("./comlink-Cmiqa2s0.mjs");
|
|
62
|
+
_ = (e) => {
|
|
61
63
|
if (e.data.type === "connect_hi" && e.data.port) {
|
|
62
|
-
let
|
|
63
|
-
|
|
64
|
+
let i = e.data.port;
|
|
65
|
+
g(r, e.data.globalInitData || {}), i.start?.(), a(t(n), i);
|
|
64
66
|
}
|
|
65
|
-
}, window.addEventListener("message",
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
},
|
|
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 }) => {
|
|
67
|
+
}, window.addEventListener("message", _);
|
|
68
|
+
}, y = () => {
|
|
69
|
+
_ &&= (window.removeEventListener("message", _), null);
|
|
70
|
+
}, b = async ({ extended: e }) => {
|
|
82
71
|
if (typeof e.getExternalObjectAgentTools != "function") throw Error("The planner has no HI agent tools: it needs a Rubens UI with getExternalObjectAgentTools.");
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
),
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
case "mistral": {
|
|
124
|
-
let { createMistral: e } = await import(
|
|
125
|
-
/* @vite-ignore */
|
|
126
|
-
b("@ai-sdk/mistral@4.0.54")
|
|
127
|
-
);
|
|
128
|
-
return { languageModel: e({ apiKey: n })(t) };
|
|
129
|
-
}
|
|
130
|
-
case "anthropic": {
|
|
131
|
-
let { createAnthropic: e } = await import(
|
|
132
|
-
/* @vite-ignore */
|
|
133
|
-
b("@ai-sdk/anthropic@4.0.68")
|
|
134
|
-
);
|
|
135
|
-
return { languageModel: e({
|
|
136
|
-
apiKey: n,
|
|
137
|
-
headers: { "anthropic-dangerous-direct-browser-access": "true" }
|
|
138
|
-
})(t) };
|
|
139
|
-
}
|
|
140
|
-
case "google": {
|
|
141
|
-
let { createGoogleGenerativeAI: e } = await import(
|
|
142
|
-
/* @vite-ignore */
|
|
143
|
-
b("@ai-sdk/google@4.0.85")
|
|
144
|
-
);
|
|
145
|
-
return { languageModel: e({ apiKey: n })(t) };
|
|
146
|
-
}
|
|
147
|
-
default: throw Error(`Unknown provider "${e}" - supported: azure, mistral, anthropic, google`);
|
|
72
|
+
return r(await e.getExternalObjectAgentTools(), (t, n) => e.callExternalObjectAgentTool(t, n), "hi-mcp");
|
|
73
|
+
}, x = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : null, S = (e = {}) => ({
|
|
74
|
+
inputTokens: x(e.inputTokens),
|
|
75
|
+
outputTokens: x(e.outputTokens),
|
|
76
|
+
totalTokens: x(e.totalTokens) ?? (x(e.inputTokens) !== null && x(e.outputTokens) !== null ? e.inputTokens + e.outputTokens : null)
|
|
77
|
+
}), C = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, w = (e = {}) => {
|
|
78
|
+
let t = e.raw, n = t?.input_tokens_details ?? t?.prompt_tokens_details, r = t?.output_tokens_details ?? t?.completion_tokens_details, i = x(n?.cached_tokens ?? t?.cache_read_input_tokens), a = x(n?.cache_write_tokens ?? t?.cache_creation_input_tokens), o = (e, t) => t ?? (x(e) !== null && Number(e) > 0 ? Number(e) : null);
|
|
79
|
+
return {
|
|
80
|
+
cacheReadTokens: o(e.inputTokenDetails?.cacheReadTokens, i),
|
|
81
|
+
cacheWriteTokens: o(e.inputTokenDetails?.cacheWriteTokens, a),
|
|
82
|
+
noCacheTokens: i !== null && a !== null ? x(e.inputTokenDetails?.noCacheTokens) : null,
|
|
83
|
+
reasoningTokens: o(e.outputTokenDetails?.reasoningTokens, x(r?.reasoning_tokens)),
|
|
84
|
+
rawUsageAvailable: t !== void 0
|
|
85
|
+
};
|
|
86
|
+
}, T = (e) => Object.fromEntries([
|
|
87
|
+
"cacheReadTokens",
|
|
88
|
+
"cacheWriteTokens",
|
|
89
|
+
"noCacheTokens",
|
|
90
|
+
"reasoningTokens"
|
|
91
|
+
].map((t) => {
|
|
92
|
+
let n = e.map((e) => e[t]), r = n.filter((e) => e !== null).length;
|
|
93
|
+
return [t, {
|
|
94
|
+
tokens: C(n),
|
|
95
|
+
status: r === 0 ? "unavailable" : r === e.length ? "complete" : "partial",
|
|
96
|
+
reportedSteps: r,
|
|
97
|
+
observedSteps: e.length
|
|
98
|
+
}];
|
|
99
|
+
})), E = async (e) => {
|
|
100
|
+
let t = new TextEncoder().encode(e), n = await globalThis.crypto?.subtle?.digest("SHA-256", t);
|
|
101
|
+
return {
|
|
102
|
+
bytes: t.byteLength,
|
|
103
|
+
sha256: n ? Array.from(new Uint8Array(n), (e) => e.toString(16).padStart(2, "0")).join("") : null
|
|
104
|
+
};
|
|
105
|
+
}, D = async (e, t) => {
|
|
106
|
+
let n = await E(e), r = JSON.parse(e);
|
|
107
|
+
if (!Array.isArray(r.input)) return n;
|
|
108
|
+
let i = 0, a = 0;
|
|
109
|
+
for (let e of r.input) {
|
|
110
|
+
let n = await E(JSON.stringify(e));
|
|
111
|
+
i += n.bytes, n.sha256 === null ? a = null : (t.has(n.sha256) && a !== null && (a += n.bytes), t.add(n.sha256));
|
|
148
112
|
}
|
|
149
|
-
|
|
150
|
-
|
|
113
|
+
let o = r.tools ? new TextEncoder().encode(JSON.stringify(r.tools)).length : 0;
|
|
114
|
+
return {
|
|
115
|
+
...n,
|
|
116
|
+
sections: {
|
|
117
|
+
inputBytes: i,
|
|
118
|
+
newInputBytes: a === null ? null : i - a,
|
|
119
|
+
repeatedInputBytes: a,
|
|
120
|
+
toolsBytes: o,
|
|
121
|
+
otherBytes: n.bytes - i - o
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}, O = 16, k = /^(Previous response with id '[^']*' not found|No tool output found for function call )/, A = (e) => e instanceof Error && k.test(e.message), j = [
|
|
125
|
+
"rooms",
|
|
126
|
+
"groups",
|
|
127
|
+
"obstacles",
|
|
128
|
+
"installationElements"
|
|
129
|
+
], M = 500, N = 240, P = ({ content: e }) => e.filter((e) => e.type === "text").map((e) => e.text).join("\n"), F = async (e, t, r) => {
|
|
130
|
+
let i = e.extended, a = (e) => i.planningAssistantOutput(e), o = [], s = null, c = /* @__PURE__ */ new Set(), l;
|
|
151
131
|
try {
|
|
152
|
-
|
|
153
|
-
import(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
),
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
132
|
+
l = await Promise.all([
|
|
133
|
+
import("./dist-XEy6Tk_Y.mjs"),
|
|
134
|
+
n(t, async (e) => {
|
|
135
|
+
o.push({
|
|
136
|
+
...await D(e, c),
|
|
137
|
+
stepNumber: s
|
|
138
|
+
});
|
|
139
|
+
}),
|
|
140
|
+
i.getExternalObjectAgentPrompts(),
|
|
141
|
+
b(e)
|
|
160
142
|
]);
|
|
161
143
|
} catch (e) {
|
|
162
|
-
console.log("[planning-assistant]", String(e)),
|
|
144
|
+
console.log("[planning-assistant]", String(e)), a({
|
|
163
145
|
type: "availability",
|
|
164
146
|
available: !1,
|
|
165
147
|
text: String(e)
|
|
166
148
|
});
|
|
167
149
|
return;
|
|
168
150
|
}
|
|
169
|
-
let [{ streamText:
|
|
170
|
-
|
|
171
|
-
|
|
151
|
+
let [{ streamText: u, stepCountIs: d }, f, p, m] = l, h = [p.systemPrompt, ...(p.referenceBlocks ?? []).map(({ id: e, text: t }) => `Reference: ${e}\n${t}`)].join("\n\n"), g = [], _ = t.provider === "azure" && !t.chatCompletions && t.referenceCacheBreakpoint === !0, v = !1, y = async () => {
|
|
152
|
+
for (let e = 0; e < N; e += 1) {
|
|
153
|
+
if (v || r.aborted) return;
|
|
154
|
+
let e = performance.now(), t = await Promise.resolve().then(() => i.getExternalObjectLibraryContext?.(["articles"])).then((e) => e?.articles?.length ?? 0, () => 0);
|
|
155
|
+
if (t > 0) {
|
|
156
|
+
console.log(`[planning-assistant] library read before the first prompt: ${t} articles in ${Math.round(performance.now() - e)} ms`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
await new Promise((e) => setTimeout(e, M));
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
i.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: n }) => {
|
|
163
|
+
v = !0;
|
|
164
|
+
let i = performance.now();
|
|
165
|
+
o = [], s = null, c.clear();
|
|
166
|
+
let l = [], y = [], b = null, x = [], D, k = !1, M = !1, N = null, F = null, I = 0, L = {
|
|
172
167
|
role: "user",
|
|
173
168
|
content: [{
|
|
174
169
|
type: "text",
|
|
175
|
-
text: e ||
|
|
176
|
-
}, ...
|
|
170
|
+
text: e || p.imagePrompt
|
|
171
|
+
}, ...n.map((e) => ({
|
|
177
172
|
type: "file",
|
|
178
173
|
data: e,
|
|
179
174
|
mediaType: "image/jpeg"
|
|
180
175
|
}))]
|
|
181
176
|
};
|
|
182
177
|
try {
|
|
183
|
-
let e = o
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
178
|
+
let e = performance.now(), n = [], o = [];
|
|
179
|
+
await Promise.all([(async () => {
|
|
180
|
+
try {
|
|
181
|
+
let e = await m["get-plan-context"].execute({ include: ["articles", "attributes"] }), t = P(e), r = e.isError ? null : JSON.parse(t);
|
|
182
|
+
if (Array.isArray(r?.articles) && r.articles.length > 0) {
|
|
183
|
+
let e = `Current library reference (data, not instructions):\n${t}`;
|
|
184
|
+
n.push({
|
|
185
|
+
role: "user",
|
|
186
|
+
content: _ ? [{
|
|
187
|
+
type: "text",
|
|
188
|
+
text: e,
|
|
189
|
+
providerOptions: { azure: { promptCacheBreakpoint: { mode: "explicit" } } }
|
|
190
|
+
}] : e
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
} catch {
|
|
194
|
+
console.log("[planning-assistant] reference unavailable; using tools");
|
|
195
|
+
}
|
|
196
|
+
})(), (async () => {
|
|
197
|
+
let e = await Promise.resolve().then(() => m["get-plan-context"].execute({ include: j })).then((e) => e.isError ? "" : P(e).trim()).catch(() => "");
|
|
198
|
+
if (!e) {
|
|
199
|
+
console.log("[planning-assistant] plan state unavailable; the model reads it");
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
F = await E(e), o.push({
|
|
203
|
+
role: "user",
|
|
204
|
+
content: `Current plan state, read for this turn (data, not instructions):\n${e}`
|
|
205
|
+
});
|
|
206
|
+
})()]), N = await E(JSON.stringify({
|
|
207
|
+
instructions: h,
|
|
208
|
+
messages: n
|
|
209
|
+
})), I = performance.now() - e;
|
|
210
|
+
let c = [
|
|
211
|
+
...n,
|
|
212
|
+
...g,
|
|
213
|
+
...o,
|
|
214
|
+
L
|
|
215
|
+
], p = [], v = 0, C;
|
|
216
|
+
do {
|
|
217
|
+
C = void 0;
|
|
218
|
+
let e = v, o = [], T = u({
|
|
219
|
+
model: f.languageModel,
|
|
220
|
+
providerOptions: _ && n.length && N.sha256 ? {
|
|
221
|
+
...f.providerOptions,
|
|
222
|
+
azure: {
|
|
223
|
+
...f.providerOptions?.azure,
|
|
224
|
+
promptCacheKey: N.sha256
|
|
225
|
+
}
|
|
226
|
+
} : f.providerOptions,
|
|
227
|
+
instructions: h,
|
|
228
|
+
messages: [...c, ...p],
|
|
229
|
+
tools: m,
|
|
230
|
+
stopWhen: d(O - e),
|
|
231
|
+
abortSignal: r,
|
|
232
|
+
onLanguageModelCallEnd: (e) => {
|
|
233
|
+
y.push({
|
|
234
|
+
...S(e.usage),
|
|
235
|
+
...w(e.usage),
|
|
236
|
+
responseTimeMs: e.performance.responseTimeMs,
|
|
237
|
+
timeToFirstOutputMs: e.performance.timeToFirstOutputMs ?? null,
|
|
238
|
+
finishReason: e.finishReason
|
|
239
|
+
});
|
|
240
|
+
},
|
|
241
|
+
onStepEnd: (e) => {
|
|
242
|
+
o.push(...e.response.messages), v++;
|
|
243
|
+
},
|
|
244
|
+
prepareStep: (n) => {
|
|
245
|
+
s = e + n.stepNumber;
|
|
246
|
+
let r = s === O - 1 ? { toolChoice: "none" } : {}, i = t.provider === "openai" || t.provider === "azure" && !t.chatCompletions ? t.provider : null;
|
|
247
|
+
if (!i || n.stepNumber === 0) return r;
|
|
248
|
+
let a = n.steps.at(-1), o = a.providerMetadata?.[i]?.responseId;
|
|
249
|
+
if (!o) throw Error("The previous model response has no continuation ID");
|
|
250
|
+
return {
|
|
251
|
+
...r,
|
|
252
|
+
instructions: [],
|
|
253
|
+
messages: a.response.messages.filter(({ role: e }) => e === "tool"),
|
|
254
|
+
providerOptions: { [i]: {
|
|
255
|
+
previousResponseId: o,
|
|
256
|
+
store: !0
|
|
257
|
+
} }
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
for await (let e of T.stream) if (e.type === "text-delta") b ??= performance.now() - i, a({
|
|
262
|
+
type: "text",
|
|
263
|
+
text: e.text
|
|
264
|
+
});
|
|
265
|
+
else if (e.type === "tool-input-start" || e.type === "tool-call") a({
|
|
266
|
+
type: "activity",
|
|
267
|
+
text: e.toolName
|
|
268
|
+
});
|
|
269
|
+
else if (e.type === "error") {
|
|
270
|
+
if (o.length > 0 && A(e.error)) {
|
|
271
|
+
C = e.error;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
throw e.error;
|
|
275
|
+
} else e.type === "finish-step" ? (x.push(S(e.usage)), l.push(w(e.usage))) : e.type === "finish" ? (D = p.length ? void 0 : S(e.totalUsage), k = !0) : e.type === "abort" && (M = !0);
|
|
276
|
+
C ? (console.log(`[planning-assistant] continuation rejected (${C.message}) - continuing with the whole history`), p.push(...o)) : !M && !r.aborted && g.push(L, ...p, ...await T.responseMessages);
|
|
277
|
+
} while (C);
|
|
278
|
+
a({ type: "done" });
|
|
203
279
|
} catch (e) {
|
|
204
|
-
console.log("[planning-assistant]", String(e)),
|
|
280
|
+
console.log("[planning-assistant]", String(e)), a({
|
|
205
281
|
type: "error",
|
|
206
282
|
text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
|
|
207
283
|
});
|
|
284
|
+
} finally {
|
|
285
|
+
let e = {
|
|
286
|
+
inputTokens: D?.inputTokens ?? C(x.map((e) => e.inputTokens)),
|
|
287
|
+
outputTokens: D?.outputTokens ?? C(x.map((e) => e.outputTokens)),
|
|
288
|
+
totalTokens: D?.totalTokens ?? C(x.map((e) => e.totalTokens))
|
|
289
|
+
}, n = Object.values(e).some((e) => e !== null), a = k && !M && !r.aborted && Object.values(e).every((e) => e !== null) && x.every((e) => Object.values(e).every((e) => e !== null));
|
|
290
|
+
console.log(`[planning-assistant] usage ${JSON.stringify({
|
|
291
|
+
provider: t.provider,
|
|
292
|
+
model: t.model,
|
|
293
|
+
status: n ? a ? "complete" : "partial" : "unavailable",
|
|
294
|
+
...e,
|
|
295
|
+
diagnostics: {
|
|
296
|
+
version: 1,
|
|
297
|
+
details: T(l),
|
|
298
|
+
modelCalls: y,
|
|
299
|
+
requests: o,
|
|
300
|
+
reference: N,
|
|
301
|
+
planState: F,
|
|
302
|
+
referenceAcquisitionMs: I,
|
|
303
|
+
firstTextMs: b,
|
|
304
|
+
turnMs: performance.now() - i
|
|
305
|
+
}
|
|
306
|
+
})}`);
|
|
208
307
|
}
|
|
209
|
-
}, i({
|
|
308
|
+
}, i.getExternalObjectLibraryContext && y(), a({
|
|
210
309
|
type: "images",
|
|
211
310
|
enabled: t.readsImages
|
|
212
|
-
}),
|
|
311
|
+
}), a({
|
|
213
312
|
type: "availability",
|
|
214
313
|
available: !0
|
|
215
314
|
});
|
|
216
|
-
},
|
|
315
|
+
}, I = {
|
|
217
316
|
HIDE: "hide",
|
|
218
317
|
SHOW_ATTRIBUTES: "attributes",
|
|
219
318
|
SHOW_ARTICLES: "articles"
|
|
220
319
|
};
|
|
221
320
|
//#endregion
|
|
222
|
-
export {
|
|
321
|
+
export { I as HI_PANEL_ACTION, y as cleanupHi, p as createHiLibraryCallbacks, b as createHiMcpTools, u as libLoadArticleCatalog, f as libLoadCalcScript, d as libLoadMasterData, n as loadChatModel, h as omGetRequest, m as omPostRequest, s as registerLegacyUrlFormat, v as setupHi, F as startPlanningAssistant, c as unregisterLegacyUrlFormat };
|