@roomle/embedding-lib 0.0.0-dev-0d51f54 → 0.0.0-dev-d29f634
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { c as e, i as t, n, o as r, r as i, s as a } from "./utils-BwWn6Fw4.mjs";
|
|
3
|
-
import { l as o, p as s, r as c } from "./drag-in-
|
|
4
|
-
import { t as l } from "./drag-ghost-
|
|
3
|
+
import { l as o, p as s, r as c } from "./drag-in-mE_ozj_Q.mjs";
|
|
4
|
+
import { t as l } from "./drag-ghost-Bhb0_67G.mjs";
|
|
5
5
|
//#region packages/embedding-lib/src/plugins/strategy/from-website.ts
|
|
6
6
|
var u = class {
|
|
7
7
|
_options = {};
|
package/hi.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
|
|
2
2
|
import { t as e } from "./browser-D6M-d6y5.mjs";
|
|
3
3
|
import { t } from "./utils-BwWn6Fw4.mjs";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { a as n, i as r, o as i, r as a } from "./chat-model-C1ov616e.mjs";
|
|
5
|
+
import "./mcp-tools-CfJ_ue_2.mjs";
|
|
6
|
+
var o = (e, t) => t === e.libraryId ? e : {
|
|
6
7
|
...e,
|
|
7
8
|
libraryId: t
|
|
8
|
-
},
|
|
9
|
+
}, s = async (e, t, n, r = { property: "default" }) => {
|
|
9
10
|
let i = n.serverOptions ?? {}, a = { headers: {
|
|
10
11
|
"Content-Type": t === "json" ? "application/json" : "text/plain",
|
|
11
12
|
"Access-Control-Allow-Origin": "*"
|
|
@@ -18,22 +19,22 @@ var i = (e, t) => t === e.libraryId ? e : {
|
|
|
18
19
|
} catch (e) {
|
|
19
20
|
throw console.warn(`Failed to fetch data from ${r.property}`), console.error(e), e;
|
|
20
21
|
}
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
},
|
|
22
|
+
}, c = { "e2fe8b3d-da31-4a20-92ab-ab6e3839300e": new Set(["Furniture_Smith"]) }, l = (e, t) => {
|
|
23
|
+
c[e] || (c[e] = /* @__PURE__ */ new Set()), c[e].add(t);
|
|
24
|
+
}, u = (e, t) => {
|
|
25
|
+
c[e]?.delete(t), c[e]?.size === 0 && delete c[e];
|
|
26
|
+
}, d = (e, t) => {
|
|
26
27
|
let { libraryId: n, serverOptions: r } = e;
|
|
27
|
-
return r?.subscriptionId &&
|
|
28
|
-
},
|
|
29
|
-
let t = await (await
|
|
28
|
+
return r?.subscriptionId && c[r.subscriptionId]?.has(n) ? `api/pos/${t}?libraryId=${n}` : `api/pos/libraries/${n}/${t}`;
|
|
29
|
+
}, f = async (e) => await (await s(d(e, "articles"), "json", e, { property: "articles" })).json(), p = async (e) => await (await s(d(e, "masterData"), "json", e, { property: "masterData" })).json(), m = async (e) => {
|
|
30
|
+
let t = await (await s(d(e, "calc.js"), "text", e, { property: "calc.js" })).text();
|
|
30
31
|
if (!t) throw Error("Script load error");
|
|
31
32
|
return t;
|
|
32
|
-
},
|
|
33
|
-
onLoadJavascript: (t) =>
|
|
34
|
-
onLoadArticleCatalog: (t) =>
|
|
35
|
-
onLoadMasterData: (t) =>
|
|
36
|
-
}),
|
|
33
|
+
}, h = (e) => ({
|
|
34
|
+
onLoadJavascript: (t) => m(o(e, t)),
|
|
35
|
+
onLoadArticleCatalog: (t) => f(o(e, t)),
|
|
36
|
+
onLoadMasterData: (t) => p(o(e, t))
|
|
37
|
+
}), g = async (e, t, n, r = {}) => {
|
|
37
38
|
let { baseUrl: i, om: a } = e.serverOptions ?? {}, o = encodeURIComponent(a?.endpointUrl || ""), s = encodeURIComponent(a?.subscriptionId || ""), c = a?.key || "";
|
|
38
39
|
return await (await fetch((i ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(n)}&subscriptionId=${s}&apiKey=${c}&baseUrl=${o}`, {
|
|
39
40
|
method: "POST",
|
|
@@ -43,7 +44,7 @@ var i = (e, t) => t === e.libraryId ? e : {
|
|
|
43
44
|
...r
|
|
44
45
|
}
|
|
45
46
|
})).json();
|
|
46
|
-
},
|
|
47
|
+
}, _ = async (e, t, n = {}) => {
|
|
47
48
|
let { baseUrl: r, om: i } = e.serverOptions ?? {}, a = encodeURIComponent(i?.endpointUrl || ""), o = encodeURIComponent(i?.subscriptionId || ""), s = i?.key || "";
|
|
48
49
|
return await (await fetch((r ?? "https://europe-west3-rml-showcases.cloudfunctions.net/proxy_request?url=") + `${encodeURIComponent(t)}&subscriptionId=${o}&apiKey=${s}&baseUrl=${a}`, {
|
|
49
50
|
method: "GET",
|
|
@@ -52,38 +53,38 @@ var i = (e, t) => t === e.libraryId ? e : {
|
|
|
52
53
|
...n
|
|
53
54
|
}
|
|
54
55
|
})).json();
|
|
55
|
-
},
|
|
56
|
+
}, v = (t, n) => {
|
|
56
57
|
t.serverOptions ||= {}, !t.serverOptions.language && n?.locale && (t.serverOptions.language = n.locale), t.serverOptions.language || (t.serverOptions.language = e(null, !0));
|
|
57
|
-
},
|
|
58
|
-
|
|
58
|
+
}, y = null, b = async (e, n = {}) => {
|
|
59
|
+
y && window.removeEventListener("message", y);
|
|
59
60
|
let r = typeof e == "string" ? { libraryId: e } : e;
|
|
60
|
-
n.onLoadJavascript === void 0 && (n.onLoadJavascript = (e) =>
|
|
61
|
-
let { expose:
|
|
62
|
-
|
|
61
|
+
n.onLoadJavascript === void 0 && (n.onLoadJavascript = (e) => m(o(r, e))), n.onLoadArticleCatalog === void 0 && (n.onLoadArticleCatalog = (e) => f(o(r, e))), n.onLoadMasterData === void 0 && (n.onLoadMasterData = (e) => p(o(r, e)));
|
|
62
|
+
let { expose: i } = await import("./comlink-CG3f9q6z.mjs");
|
|
63
|
+
y = (e) => {
|
|
63
64
|
if (e.data.type === "connect_hi" && e.data.port) {
|
|
64
|
-
let
|
|
65
|
-
|
|
65
|
+
let a = e.data.port;
|
|
66
|
+
v(r, e.data.globalInitData || {}), a.start?.(), i(t(n), a);
|
|
66
67
|
}
|
|
67
|
-
}, window.addEventListener("message",
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
},
|
|
68
|
+
}, window.addEventListener("message", y);
|
|
69
|
+
}, x = () => {
|
|
70
|
+
y &&= (window.removeEventListener("message", y), null);
|
|
71
|
+
}, S = async ({ extended: e }) => {
|
|
71
72
|
if (typeof e.getExternalObjectAgentTools != "function") throw Error("The planner has no HI agent tools: it needs a Rubens UI with getExternalObjectAgentTools.");
|
|
72
|
-
return
|
|
73
|
-
},
|
|
74
|
-
inputTokens:
|
|
75
|
-
outputTokens:
|
|
76
|
-
totalTokens:
|
|
77
|
-
}),
|
|
78
|
-
let t = e.raw, n = t?.input_tokens_details ?? t?.prompt_tokens_details, r = t?.output_tokens_details ?? t?.completion_tokens_details, i =
|
|
73
|
+
return n(await e.getExternalObjectAgentTools(), (t, n) => e.callExternalObjectAgentTool(t, n), "hi-mcp");
|
|
74
|
+
}, C = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : null, w = (e = {}) => ({
|
|
75
|
+
inputTokens: C(e.inputTokens),
|
|
76
|
+
outputTokens: C(e.outputTokens),
|
|
77
|
+
totalTokens: C(e.totalTokens) ?? (C(e.inputTokens) !== null && C(e.outputTokens) !== null ? e.inputTokens + e.outputTokens : null)
|
|
78
|
+
}), T = (e) => e.some((e) => e !== null) ? e.reduce((e, t) => e + (t ?? 0), 0) : null, E = (e = {}) => {
|
|
79
|
+
let t = e.raw, n = t?.input_tokens_details ?? t?.prompt_tokens_details, r = t?.output_tokens_details ?? t?.completion_tokens_details, i = C(n?.cached_tokens ?? t?.cache_read_input_tokens), a = C(n?.cache_write_tokens ?? t?.cache_creation_input_tokens), o = (e, t) => t ?? (C(e) !== null && Number(e) > 0 ? Number(e) : null);
|
|
79
80
|
return {
|
|
80
81
|
cacheReadTokens: o(e.inputTokenDetails?.cacheReadTokens, i),
|
|
81
82
|
cacheWriteTokens: o(e.inputTokenDetails?.cacheWriteTokens, a),
|
|
82
|
-
noCacheTokens: i !== null && a !== null ?
|
|
83
|
-
reasoningTokens: o(e.outputTokenDetails?.reasoningTokens,
|
|
83
|
+
noCacheTokens: i !== null && a !== null ? C(e.inputTokenDetails?.noCacheTokens) : null,
|
|
84
|
+
reasoningTokens: o(e.outputTokenDetails?.reasoningTokens, C(r?.reasoning_tokens)),
|
|
84
85
|
rawUsageAvailable: t !== void 0
|
|
85
86
|
};
|
|
86
|
-
},
|
|
87
|
+
}, D = (e) => Object.fromEntries([
|
|
87
88
|
"cacheReadTokens",
|
|
88
89
|
"cacheWriteTokens",
|
|
89
90
|
"noCacheTokens",
|
|
@@ -91,23 +92,23 @@ var i = (e, t) => t === e.libraryId ? e : {
|
|
|
91
92
|
].map((t) => {
|
|
92
93
|
let n = e.map((e) => e[t]), r = n.filter((e) => e !== null).length;
|
|
93
94
|
return [t, {
|
|
94
|
-
tokens:
|
|
95
|
+
tokens: T(n),
|
|
95
96
|
status: r === 0 ? "unavailable" : r === e.length ? "complete" : "partial",
|
|
96
97
|
reportedSteps: r,
|
|
97
98
|
observedSteps: e.length
|
|
98
99
|
}];
|
|
99
|
-
})),
|
|
100
|
+
})), O = async (e) => {
|
|
100
101
|
let t = new TextEncoder().encode(e), n = await globalThis.crypto?.subtle?.digest("SHA-256", t);
|
|
101
102
|
return {
|
|
102
103
|
bytes: t.byteLength,
|
|
103
104
|
sha256: n ? Array.from(new Uint8Array(n), (e) => e.toString(16).padStart(2, "0")).join("") : null
|
|
104
105
|
};
|
|
105
|
-
},
|
|
106
|
-
let n = await
|
|
106
|
+
}, k = async (e, t) => {
|
|
107
|
+
let n = await O(e), r = JSON.parse(e);
|
|
107
108
|
if (!Array.isArray(r.input)) return n;
|
|
108
109
|
let i = 0, a = 0;
|
|
109
110
|
for (let e of r.input) {
|
|
110
|
-
let n = await
|
|
111
|
+
let n = await O(JSON.stringify(e));
|
|
111
112
|
i += n.bytes, n.sha256 === null ? a = null : (t.has(n.sha256) && a !== null && (a += n.bytes), t.add(n.sha256));
|
|
112
113
|
}
|
|
113
114
|
let o = r.tools ? new TextEncoder().encode(JSON.stringify(r.tools)).length : 0;
|
|
@@ -121,75 +122,75 @@ var i = (e, t) => t === e.libraryId ? e : {
|
|
|
121
122
|
otherBytes: n.bytes - i - o
|
|
122
123
|
}
|
|
123
124
|
};
|
|
124
|
-
},
|
|
125
|
+
}, A = 16, j = (e) => {
|
|
125
126
|
let t = [e?.present.length ? `- Confirmed: ${e.present.join(", ")}` : "", e?.absent.length ? `- Not present / false: ${e.absent.join(", ")}` : ""].filter(Boolean);
|
|
126
127
|
return t.length === 0 ? "" : `Observed in the photo (high-confidence cues; verify against the image):\n\n${t.join("\n")}`;
|
|
127
|
-
},
|
|
128
|
-
let n =
|
|
128
|
+
}, ee = (e, t) => {
|
|
129
|
+
let n = j(t);
|
|
129
130
|
return n ? `${e.replace(/\n*$/, "\n")}\n---\n\n${n}` : e;
|
|
130
|
-
},
|
|
131
|
+
}, M = /^(Previous response with id '[^']*' not found|No tool output found for function call )/, te = (e) => e instanceof Error && M.test(e.message), ne = (e) => e.role !== "assistant" || typeof e.content == "string" ? e : {
|
|
131
132
|
...e,
|
|
132
133
|
content: e.content.map((e) => (e.type === "text" || e.type === "reasoning") && e.providerOptions ? {
|
|
133
134
|
...e,
|
|
134
135
|
providerOptions: Object.fromEntries(Object.entries(e.providerOptions).map(([e, t]) => [e, Object.fromEntries(Object.entries(t).filter(([e]) => e !== "itemId"))]))
|
|
135
136
|
} : e)
|
|
136
|
-
},
|
|
137
|
+
}, re = [
|
|
137
138
|
"rooms",
|
|
138
139
|
"groups",
|
|
139
140
|
"obstacles",
|
|
140
141
|
"installationElements"
|
|
141
|
-
], N = 500, P = 240, F = 1500, I = ({ content: e }) => e.filter((e) => e.type === "text").map((e) => e.text).join("\n"), L = async (e, t,
|
|
142
|
-
let
|
|
142
|
+
], N = 500, P = 240, F = 1500, I = ({ content: e }) => e.filter((e) => e.type === "text").map((e) => e.text).join("\n"), L = async (e, t, n) => {
|
|
143
|
+
let o = e.extended, s = !1, c = !1, l = crypto.randomUUID(), u, d, f = n, p = (e) => !s && !f.aborted ? o.planningAssistantOutput(e) : void 0, m = [], h = null, g = /* @__PURE__ */ new Set(), _;
|
|
143
144
|
try {
|
|
144
|
-
|
|
145
|
+
_ = await Promise.all([
|
|
145
146
|
import("./dist-6TznX-Ae.mjs").then((e) => e.t),
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...await
|
|
149
|
-
stepNumber:
|
|
147
|
+
i(t, async (e) => {
|
|
148
|
+
m.push({
|
|
149
|
+
...await k(e, g),
|
|
150
|
+
stepNumber: h
|
|
150
151
|
});
|
|
151
152
|
}),
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
o.getExternalObjectAgentPrompts(),
|
|
154
|
+
S(e)
|
|
154
155
|
]);
|
|
155
156
|
} catch (e) {
|
|
156
|
-
console.log("[planning-assistant]", String(e)),
|
|
157
|
+
console.log("[planning-assistant]", String(e)), p({
|
|
157
158
|
type: "availability",
|
|
158
159
|
available: !1,
|
|
159
160
|
text: String(e)
|
|
160
161
|
});
|
|
161
162
|
return;
|
|
162
163
|
}
|
|
163
|
-
let [{ streamText:
|
|
164
|
-
let
|
|
165
|
-
if (
|
|
164
|
+
let [{ streamText: v, stepCountIs: y }, b, x, C] = _, M = [x.systemPrompt, ...(x.referenceBlocks ?? []).map(({ id: e, text: t }) => `Reference: ${e}\n${t}`)].join("\n\n"), L = [], R = t.provider === "azure" && !t.chatCompletions && t.referenceCacheBreakpoint === !0, z = a(t), B = null, V = 0, H = [], U = /* @__PURE__ */ new Set(), W = !1, G = async (e, n, r, i) => {
|
|
165
|
+
let a = performance.now();
|
|
166
|
+
if (W || !o.getExternalObjectAgentDecisions) return null;
|
|
166
167
|
let s;
|
|
167
168
|
try {
|
|
168
|
-
let c =
|
|
169
|
+
let c = o.getExternalObjectAgentDecisions({
|
|
169
170
|
text: e,
|
|
170
171
|
images: n,
|
|
171
172
|
earlier: r,
|
|
172
173
|
...t.decisionApiKey && { apiKey: t.decisionApiKey },
|
|
173
|
-
...
|
|
174
|
-
}).then((e) => (e?.refused && (
|
|
174
|
+
...i.length > 0 && { held: i }
|
|
175
|
+
}).then((e) => (e?.refused && (W = !0), e), () => null), l = await Promise.race([c, new Promise((e) => {
|
|
175
176
|
s = setTimeout(() => e("late"), F);
|
|
176
177
|
})]);
|
|
177
178
|
return {
|
|
178
|
-
ms: performance.now() -
|
|
179
|
+
ms: performance.now() - a,
|
|
179
180
|
decisions: l === "late" ? null : l,
|
|
180
181
|
late: l === "late"
|
|
181
182
|
};
|
|
182
183
|
} finally {
|
|
183
184
|
clearTimeout(s);
|
|
184
185
|
}
|
|
185
|
-
},
|
|
186
|
+
}, K = () => new Set(L.flatMap((e) => e.role === "assistant" && Array.isArray(e.content) ? e.content.flatMap((e) => {
|
|
186
187
|
let t = e.type === "tool-call" && e.toolName === "get-skill" ? e.input : void 0;
|
|
187
188
|
return t && t.file === void 0 ? [String(t.name)] : [];
|
|
188
|
-
}) : [])),
|
|
189
|
-
let t =
|
|
190
|
-
return (await Promise.all(e.filter((e) => !
|
|
189
|
+
}) : [])), ie = async (e) => {
|
|
190
|
+
let t = K();
|
|
191
|
+
return (await Promise.all(e.filter((e) => !U.has(e) && !t.has(e)).map(async (e) => {
|
|
191
192
|
try {
|
|
192
|
-
let t = await
|
|
193
|
+
let t = await C["get-skill"].execute({ name: e });
|
|
193
194
|
return t.isError ? null : {
|
|
194
195
|
name: e,
|
|
195
196
|
text: I(t)
|
|
@@ -198,33 +199,34 @@ var i = (e, t) => t === e.libraryId ? e : {
|
|
|
198
199
|
return null;
|
|
199
200
|
}
|
|
200
201
|
}))).filter((e) => e !== null);
|
|
201
|
-
},
|
|
202
|
+
}, q = !1, J = async () => {
|
|
202
203
|
for (let e = 0; e < P; e += 1) {
|
|
203
|
-
if (
|
|
204
|
-
let e = performance.now(), t = await Promise.resolve().then(() =>
|
|
204
|
+
if (q || n.aborted) return;
|
|
205
|
+
let e = performance.now(), t = await Promise.resolve().then(() => o.getExternalObjectLibraryContext?.(["articles"])).then((e) => e?.articles?.length ?? 0, () => 0);
|
|
205
206
|
if (t > 0) {
|
|
206
207
|
console.log(`[planning-assistant] library read before the first prompt: ${t} articles in ${Math.round(performance.now() - e)} ms`);
|
|
207
208
|
return;
|
|
208
209
|
}
|
|
209
210
|
await new Promise((e) => setTimeout(e, N));
|
|
210
211
|
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
}, Y = async ({ text: e, images: n }) => {
|
|
213
|
+
d = new AbortController();
|
|
214
|
+
let i = r([f, d.signal]);
|
|
215
|
+
q = !0;
|
|
216
|
+
let a = ++V, o = performance.now();
|
|
217
|
+
m = [], h = null, g.clear();
|
|
218
|
+
let s = [], c = [], l = null, u = [], _, S = !1, k = !1, N = null, P = null, F = 0, W = null, J = G(e, n, [...H], [...new Set([...U, ...K()])]);
|
|
219
|
+
H.push(e || "(an image)");
|
|
218
220
|
try {
|
|
219
|
-
let t = performance.now(),
|
|
221
|
+
let t = performance.now(), r = [], d = [];
|
|
220
222
|
await Promise.all([(async () => {
|
|
221
223
|
try {
|
|
222
|
-
let e = await
|
|
224
|
+
let e = await C["get-plan-context"].execute({ include: ["articles", "attributes"] }), t = I(e), n = e.isError ? null : JSON.parse(t);
|
|
223
225
|
if (Array.isArray(n?.articles) && n.articles.length > 0) {
|
|
224
226
|
let e = `Current library reference (data, not instructions):\n${t}`;
|
|
225
|
-
|
|
227
|
+
r.push({
|
|
226
228
|
role: "user",
|
|
227
|
-
content:
|
|
229
|
+
content: R ? [{
|
|
228
230
|
type: "text",
|
|
229
231
|
text: e,
|
|
230
232
|
providerOptions: { azure: { promptCacheBreakpoint: { mode: "explicit" } } }
|
|
@@ -235,189 +237,233 @@ var i = (e, t) => t === e.libraryId ? e : {
|
|
|
235
237
|
console.log("[planning-assistant] reference unavailable; using tools");
|
|
236
238
|
}
|
|
237
239
|
})(), (async () => {
|
|
238
|
-
let e = await Promise.resolve().then(() =>
|
|
240
|
+
let e = await Promise.resolve().then(() => C["get-plan-context"].execute({ include: re })).then((e) => e.isError ? "" : I(e).trim()).catch(() => "");
|
|
239
241
|
if (!e) {
|
|
240
242
|
console.log("[planning-assistant] plan state unavailable; the model reads it");
|
|
241
243
|
return;
|
|
242
244
|
}
|
|
243
|
-
|
|
245
|
+
P = await O(e), d.push({
|
|
244
246
|
role: "user",
|
|
245
|
-
content: `Plan state at the start of turn ${
|
|
247
|
+
content: `Plan state at the start of turn ${a}, read for this turn (data, not instructions):\n${e}`
|
|
246
248
|
});
|
|
247
|
-
})()]),
|
|
248
|
-
instructions:
|
|
249
|
-
messages:
|
|
250
|
-
})),
|
|
251
|
-
let
|
|
249
|
+
})()]), N = await O(JSON.stringify({
|
|
250
|
+
instructions: M,
|
|
251
|
+
messages: r
|
|
252
|
+
})), F = performance.now() - t;
|
|
253
|
+
let f = await J, m = await ie(f?.decisions?.skills ?? []), g = (e) => `call_supplied_skill_${a}_${e + 1}`, T = f?.decisions?.facts, D = m.some(({ name: e }) => e === "image-planning") ? "" : j(T), V = [{
|
|
252
254
|
role: "user",
|
|
253
255
|
content: [
|
|
254
256
|
{
|
|
255
257
|
type: "text",
|
|
256
|
-
text: e ||
|
|
258
|
+
text: e || x.imagePrompt
|
|
257
259
|
},
|
|
258
260
|
...n.map((e) => ({
|
|
259
261
|
type: "file",
|
|
260
262
|
data: e,
|
|
261
263
|
mediaType: "image/jpeg"
|
|
262
264
|
})),
|
|
263
|
-
...
|
|
265
|
+
...D ? [{
|
|
264
266
|
type: "text",
|
|
265
|
-
text:
|
|
267
|
+
text: D
|
|
266
268
|
}] : []
|
|
267
269
|
]
|
|
268
|
-
}, ...
|
|
270
|
+
}, ...m.length ? [{
|
|
269
271
|
role: "assistant",
|
|
270
|
-
content:
|
|
272
|
+
content: m.map((e, t) => ({
|
|
271
273
|
type: "tool-call",
|
|
272
|
-
toolCallId:
|
|
274
|
+
toolCallId: g(t),
|
|
273
275
|
toolName: "get-skill",
|
|
274
276
|
input: { name: e.name }
|
|
275
277
|
}))
|
|
276
278
|
}, {
|
|
277
279
|
role: "tool",
|
|
278
|
-
content:
|
|
280
|
+
content: m.map((e, t) => ({
|
|
279
281
|
type: "tool-result",
|
|
280
|
-
toolCallId:
|
|
282
|
+
toolCallId: g(t),
|
|
281
283
|
toolName: "get-skill",
|
|
282
284
|
output: {
|
|
283
285
|
type: "content",
|
|
284
286
|
value: [{
|
|
285
287
|
type: "text",
|
|
286
|
-
text: e.name === "image-planning" ?
|
|
288
|
+
text: e.name === "image-planning" ? ee(e.text, T) : e.text
|
|
287
289
|
}]
|
|
288
290
|
}
|
|
289
291
|
}))
|
|
290
292
|
}] : []];
|
|
291
|
-
|
|
293
|
+
m.length > 0 && p({
|
|
292
294
|
type: "activity",
|
|
293
|
-
text:
|
|
294
|
-
}),
|
|
295
|
-
ms:
|
|
296
|
-
late:
|
|
297
|
-
answers:
|
|
298
|
-
...
|
|
299
|
-
refused:
|
|
300
|
-
skipped:
|
|
301
|
-
supplied:
|
|
295
|
+
text: m.map(({ name: e }) => e).join(", ")
|
|
296
|
+
}), W = f && {
|
|
297
|
+
ms: f.ms,
|
|
298
|
+
late: f.late,
|
|
299
|
+
answers: f.decisions?.answers ?? null,
|
|
300
|
+
...T && { facts: T },
|
|
301
|
+
refused: f.decisions?.refused ?? !1,
|
|
302
|
+
skipped: f.decisions?.skipped ?? !1,
|
|
303
|
+
supplied: m.map(({ name: e }) => e)
|
|
302
304
|
};
|
|
303
305
|
let H = [
|
|
304
|
-
...
|
|
305
|
-
...
|
|
306
|
-
...
|
|
307
|
-
...
|
|
308
|
-
],
|
|
306
|
+
...r,
|
|
307
|
+
...L,
|
|
308
|
+
...d,
|
|
309
|
+
...V
|
|
310
|
+
], G = B && d.length > 0 && N.sha256 === B.reference ? B.responseId : void 0, K, q = [], Y = 0, X, Z = !1;
|
|
309
311
|
do {
|
|
310
|
-
|
|
311
|
-
let e =
|
|
312
|
-
model:
|
|
313
|
-
providerOptions:
|
|
314
|
-
...
|
|
312
|
+
X = void 0;
|
|
313
|
+
let e = Y, t = G, n = [], a = v({
|
|
314
|
+
model: b.languageModel,
|
|
315
|
+
providerOptions: R && r.length && N.sha256 ? {
|
|
316
|
+
...b.providerOptions,
|
|
315
317
|
azure: {
|
|
316
|
-
...
|
|
317
|
-
promptCacheKey:
|
|
318
|
+
...b.providerOptions?.azure,
|
|
319
|
+
promptCacheKey: N.sha256
|
|
318
320
|
}
|
|
319
|
-
} :
|
|
320
|
-
instructions:
|
|
321
|
-
messages:
|
|
322
|
-
tools:
|
|
323
|
-
stopWhen:
|
|
324
|
-
abortSignal:
|
|
321
|
+
} : b.providerOptions,
|
|
322
|
+
instructions: M,
|
|
323
|
+
messages: Z ? [...H, ...q].map(ne) : [...H, ...q],
|
|
324
|
+
tools: C,
|
|
325
|
+
stopWhen: y(A - e),
|
|
326
|
+
abortSignal: i,
|
|
325
327
|
onLanguageModelCallEnd: (e) => {
|
|
326
|
-
|
|
327
|
-
...S(e.usage),
|
|
328
|
+
c.push({
|
|
328
329
|
...w(e.usage),
|
|
330
|
+
...E(e.usage),
|
|
329
331
|
responseTimeMs: e.performance.responseTimeMs,
|
|
330
332
|
timeToFirstOutputMs: e.performance.timeToFirstOutputMs ?? null,
|
|
331
333
|
finishReason: e.finishReason
|
|
332
334
|
});
|
|
333
335
|
},
|
|
334
336
|
onStepEnd: (e) => {
|
|
335
|
-
n.push(...e.response.messages),
|
|
337
|
+
n.push(...e.response.messages), Y++, K = z ? e.providerMetadata?.[z]?.responseId ?? void 0 : void 0;
|
|
336
338
|
},
|
|
337
339
|
prepareStep: (n) => {
|
|
338
|
-
|
|
339
|
-
let r =
|
|
340
|
-
if (!
|
|
340
|
+
h = e + n.stepNumber;
|
|
341
|
+
let r = h === A - 1 ? { toolChoice: "none" } : {};
|
|
342
|
+
if (!z) return r;
|
|
341
343
|
if (n.stepNumber === 0) return t ? {
|
|
342
344
|
...r,
|
|
343
345
|
instructions: [],
|
|
344
|
-
messages: [...
|
|
345
|
-
providerOptions: { [
|
|
346
|
+
messages: [...d, ...V],
|
|
347
|
+
providerOptions: { [z]: {
|
|
346
348
|
previousResponseId: t,
|
|
347
349
|
store: !0
|
|
348
350
|
} }
|
|
349
351
|
} : r;
|
|
350
|
-
let i = n.steps.at(-1), a = i.providerMetadata?.[
|
|
352
|
+
let i = n.steps.at(-1), a = i.providerMetadata?.[z]?.responseId;
|
|
351
353
|
if (!a) throw Error("The previous model response has no continuation ID");
|
|
352
354
|
return {
|
|
353
355
|
...r,
|
|
354
356
|
instructions: [],
|
|
355
357
|
messages: i.response.messages.filter(({ role: e }) => e === "tool"),
|
|
356
|
-
providerOptions: { [
|
|
358
|
+
providerOptions: { [z]: {
|
|
357
359
|
previousResponseId: a,
|
|
358
360
|
store: !0
|
|
359
361
|
} }
|
|
360
362
|
};
|
|
361
363
|
}
|
|
362
364
|
});
|
|
363
|
-
for await (let e of
|
|
365
|
+
for await (let e of a.stream) if (e.type === "text-delta") l ??= performance.now() - o, p({
|
|
364
366
|
type: "text",
|
|
365
367
|
text: e.text
|
|
366
368
|
});
|
|
367
|
-
else if (e.type === "tool-input-start" || e.type === "tool-call")
|
|
369
|
+
else if (e.type === "tool-input-start" || e.type === "tool-call") p({
|
|
368
370
|
type: "activity",
|
|
369
371
|
text: e.toolName
|
|
370
372
|
});
|
|
371
373
|
else if (e.type === "error") {
|
|
372
|
-
if ((n.length > 0 || t) &&
|
|
373
|
-
|
|
374
|
+
if ((n.length > 0 || t) && te(e.error)) {
|
|
375
|
+
X = e.error;
|
|
374
376
|
break;
|
|
375
377
|
}
|
|
376
378
|
throw e.error;
|
|
377
|
-
} else e.type === "finish-step" ? (
|
|
378
|
-
|
|
379
|
-
responseId:
|
|
380
|
-
reference:
|
|
379
|
+
} else e.type === "finish-step" ? (u.push(w(e.usage)), s.push(E(e.usage))) : e.type === "finish" ? (_ = q.length ? void 0 : w(e.totalUsage), S = !0) : e.type === "abort" && (k = !0);
|
|
380
|
+
X ? (console.log(`[planning-assistant] continuation rejected (${X.message}) - continuing with the whole history`), q.push(...n), G = void 0, Z = !0) : !k && !i.aborted && (L.push(...V, ...q, ...await a.responseMessages), m.forEach(({ name: e }) => U.add(e)), B = K && N.sha256 ? {
|
|
381
|
+
responseId: K,
|
|
382
|
+
reference: N.sha256
|
|
381
383
|
} : null);
|
|
382
|
-
} while (
|
|
383
|
-
|
|
384
|
+
} while (X);
|
|
385
|
+
p({ type: "done" });
|
|
384
386
|
} catch (e) {
|
|
385
|
-
console.log("[planning-assistant]", String(e)),
|
|
387
|
+
console.log("[planning-assistant]", String(e)), p({
|
|
386
388
|
type: "error",
|
|
387
389
|
text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
|
|
388
390
|
});
|
|
389
391
|
} finally {
|
|
390
392
|
let e = {
|
|
391
|
-
inputTokens:
|
|
392
|
-
outputTokens:
|
|
393
|
-
totalTokens:
|
|
394
|
-
}, n = Object.values(e).some((e) => e !== null),
|
|
393
|
+
inputTokens: _?.inputTokens ?? T(u.map((e) => e.inputTokens)),
|
|
394
|
+
outputTokens: _?.outputTokens ?? T(u.map((e) => e.outputTokens)),
|
|
395
|
+
totalTokens: _?.totalTokens ?? T(u.map((e) => e.totalTokens))
|
|
396
|
+
}, n = Object.values(e).some((e) => e !== null), r = S && !k && !i.aborted && Object.values(e).every((e) => e !== null) && u.every((e) => Object.values(e).every((e) => e !== null));
|
|
395
397
|
console.log(`[planning-assistant] usage ${JSON.stringify({
|
|
396
398
|
provider: t.provider,
|
|
397
399
|
model: t.model,
|
|
398
|
-
status: n ?
|
|
400
|
+
status: n ? r ? "complete" : "partial" : "unavailable",
|
|
399
401
|
...e,
|
|
400
402
|
diagnostics: {
|
|
401
403
|
version: 1,
|
|
402
|
-
details:
|
|
403
|
-
modelCalls:
|
|
404
|
-
requests:
|
|
405
|
-
reference:
|
|
406
|
-
planState:
|
|
407
|
-
decisions:
|
|
408
|
-
referenceAcquisitionMs:
|
|
409
|
-
firstTextMs:
|
|
410
|
-
turnMs: performance.now() -
|
|
404
|
+
details: D(s),
|
|
405
|
+
modelCalls: c,
|
|
406
|
+
requests: m,
|
|
407
|
+
reference: N,
|
|
408
|
+
planState: P,
|
|
409
|
+
decisions: W,
|
|
410
|
+
referenceAcquisitionMs: F,
|
|
411
|
+
firstTextMs: l,
|
|
412
|
+
turnMs: performance.now() - o
|
|
411
413
|
}
|
|
412
414
|
})}`);
|
|
413
415
|
}
|
|
414
|
-
},
|
|
416
|
+
}, X = async (e) => {
|
|
417
|
+
if (s || f.aborted) throw Error("The planning assistant is suspended.");
|
|
418
|
+
if (u) throw Error("An assistant turn is already running.");
|
|
419
|
+
u = Y(e);
|
|
420
|
+
try {
|
|
421
|
+
await u;
|
|
422
|
+
} finally {
|
|
423
|
+
u = void 0, d = void 0;
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
o.callbacks.onPlanningAssistantPrompt = X;
|
|
427
|
+
let Z = async (e) => {
|
|
428
|
+
e === "isolation" ? (s = !0, d?.abort(/* @__PURE__ */ Error("The assistant changed mode.")), u && await Promise.allSettled([u]), await o.planningAssistantOutput({
|
|
429
|
+
type: "availability",
|
|
430
|
+
available: !1
|
|
431
|
+
})) : !f.aborted && !c && (s = !1, p({
|
|
432
|
+
type: "images",
|
|
433
|
+
enabled: t.readsImages
|
|
434
|
+
}), p({
|
|
435
|
+
type: "availability",
|
|
436
|
+
available: !0
|
|
437
|
+
}));
|
|
438
|
+
};
|
|
439
|
+
o.callbacks.onPlanningAssistantModeChange = Z;
|
|
440
|
+
let Q = async () => {
|
|
441
|
+
c || (c = !0, s = !0, d?.abort(/* @__PURE__ */ Error("The planning assistant stopped.")), u && await Promise.allSettled([u]), o.callbacks.onPlanningAssistantPrompt === X && (o.callbacks.onPlanningAssistantPrompt = void 0), o.callbacks.onPlanningAssistantModeChange === Z && (o.callbacks.onPlanningAssistantModeChange = void 0), await o.stopPlanningAssistant?.(l), await o.planningAssistantOutput({
|
|
442
|
+
type: "availability",
|
|
443
|
+
available: !1
|
|
444
|
+
}), f.removeEventListener("abort", $));
|
|
445
|
+
}, $ = () => {
|
|
446
|
+
Q();
|
|
447
|
+
};
|
|
448
|
+
if (f.addEventListener("abort", $, { once: !0 }), f.aborted) {
|
|
449
|
+
await Q();
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
return await o.setPlanningAssistantModel?.({
|
|
453
|
+
model: t.model,
|
|
454
|
+
readsImages: t.readsImages,
|
|
455
|
+
responsesProvider: a(t) ?? void 0
|
|
456
|
+
}, l), o.getExternalObjectLibraryContext && J(), p({
|
|
415
457
|
type: "images",
|
|
416
458
|
enabled: t.readsImages
|
|
417
|
-
}),
|
|
459
|
+
}), p({
|
|
418
460
|
type: "availability",
|
|
419
461
|
available: !0
|
|
420
|
-
})
|
|
462
|
+
}), {
|
|
463
|
+
suspend: () => Z("isolation"),
|
|
464
|
+
resume: () => Z("planner"),
|
|
465
|
+
dispose: Q
|
|
466
|
+
};
|
|
421
467
|
}, R = 5e3, z = async ({ serverUrl: e, authorization: t }) => {
|
|
422
468
|
let n = t ? { Authorization: t } : {}, r;
|
|
423
469
|
try {
|
|
@@ -467,4 +513,4 @@ var i = (e, t) => t === e.libraryId ? e : {
|
|
|
467
513
|
SHOW_ARTICLES: "articles"
|
|
468
514
|
};
|
|
469
515
|
//#endregion
|
|
470
|
-
export { U as HI_PANEL_ACTION,
|
|
516
|
+
export { U as HI_PANEL_ACTION, x as cleanupHi, h as createHiLibraryCallbacks, S as createHiMcpTools, f as libLoadArticleCatalog, m as libLoadCalcScript, p as libLoadMasterData, i as loadChatModel, _ as omGetRequest, g as omPostRequest, l as registerLegacyUrlFormat, H as requestImageEdits, z as resolveHiModelProxy, b as setupHi, L as startPlanningAssistant, u as unregisterLegacyUrlFormat };
|