@roomle/embedding-lib 0.0.0-dev-432119f → 0.0.0-dev-130245d
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/hi.js +78 -65
- package/hi.min.js +77 -63
- package/package.json +1 -1
package/hi.js
CHANGED
|
@@ -156,7 +156,7 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
156
156
|
otherBytes: n.bytes - i - o
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
|
-
}, D = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, O = 16, k = async ({ provider: e, model: t, apiKey: n, baseUrl: r, chatCompletions: i, reasoningEffort: a }, o) => {
|
|
159
|
+
}, D = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, 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 = async ({ provider: e, model: t, apiKey: n, baseUrl: r, chatCompletions: i, reasoningEffort: a }, o) => {
|
|
160
160
|
let s = o ? { fetch: async (e, t) => (typeof t?.body == "string" && await o(t.body), fetch(e, t)) } : {};
|
|
161
161
|
switch (e) {
|
|
162
162
|
case "openai": {
|
|
@@ -216,7 +216,7 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
216
216
|
}
|
|
217
217
|
default: throw Error(`Unknown provider "${e}" - supported: azure, openai, mistral, anthropic, google`);
|
|
218
218
|
}
|
|
219
|
-
},
|
|
219
|
+
}, M = async (e, t, n) => {
|
|
220
220
|
let r = e.extended, i = (e) => r.planningAssistantOutput(e), a = [], o = null, s = /* @__PURE__ */ new Set(), c;
|
|
221
221
|
try {
|
|
222
222
|
c = await Promise.all([
|
|
@@ -224,7 +224,7 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
224
224
|
/* @vite-ignore */
|
|
225
225
|
D("ai@7.0.122")
|
|
226
226
|
),
|
|
227
|
-
|
|
227
|
+
j(t, async (e) => {
|
|
228
228
|
a.push({
|
|
229
229
|
...await E(e, s),
|
|
230
230
|
stepNumber: o
|
|
@@ -245,7 +245,7 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
245
245
|
r.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: r }) => {
|
|
246
246
|
let c = performance.now();
|
|
247
247
|
a = [], o = null, s.clear();
|
|
248
|
-
let _ = [], v = [], y = null, b = [], E, D = !1, k = null,
|
|
248
|
+
let _ = [], v = [], y = null, b = [], E, D = !1, k = !1, j = null, M = 0, N = {
|
|
249
249
|
role: "user",
|
|
250
250
|
content: [{
|
|
251
251
|
type: "text",
|
|
@@ -274,65 +274,78 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
274
274
|
} catch {
|
|
275
275
|
console.log("[planning-assistant] reference unavailable; using tools");
|
|
276
276
|
}
|
|
277
|
-
|
|
277
|
+
j = await T(JSON.stringify({
|
|
278
278
|
instructions: m,
|
|
279
279
|
messages: r
|
|
280
|
-
})),
|
|
281
|
-
let a =
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
280
|
+
})), M = performance.now() - e;
|
|
281
|
+
let a = [
|
|
282
|
+
...r,
|
|
283
|
+
...h,
|
|
284
|
+
N
|
|
285
|
+
], s = [], f = 0, S;
|
|
286
|
+
do {
|
|
287
|
+
S = void 0;
|
|
288
|
+
let e = f, w = [], T = l({
|
|
289
|
+
model: d.languageModel,
|
|
290
|
+
providerOptions: g && r.length && j.sha256 ? {
|
|
291
|
+
...d.providerOptions,
|
|
292
|
+
azure: {
|
|
293
|
+
...d.providerOptions?.azure,
|
|
294
|
+
promptCacheKey: j.sha256
|
|
295
|
+
}
|
|
296
|
+
} : d.providerOptions,
|
|
297
|
+
instructions: m,
|
|
298
|
+
messages: [...a, ...s],
|
|
299
|
+
tools: p,
|
|
300
|
+
stopWhen: u(O - e),
|
|
301
|
+
abortSignal: n,
|
|
302
|
+
onLanguageModelCallEnd: (e) => {
|
|
303
|
+
v.push({
|
|
304
|
+
...x(e.usage),
|
|
305
|
+
...C(e.usage),
|
|
306
|
+
responseTimeMs: e.performance.responseTimeMs,
|
|
307
|
+
timeToFirstOutputMs: e.performance.timeToFirstOutputMs ?? null,
|
|
308
|
+
finishReason: e.finishReason
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
onStepEnd: (e) => {
|
|
312
|
+
w.push(...e.response.messages), f++;
|
|
313
|
+
},
|
|
314
|
+
prepareStep: (n) => {
|
|
315
|
+
o = e + n.stepNumber;
|
|
316
|
+
let r = o === O - 1 ? { toolChoice: "none" } : {}, i = t.provider === "openai" || t.provider === "azure" && !t.chatCompletions ? t.provider : null;
|
|
317
|
+
if (!i || n.stepNumber === 0) return r;
|
|
318
|
+
let a = n.steps.at(-1), s = a.providerMetadata?.[i]?.responseId;
|
|
319
|
+
if (!s) throw Error("The previous model response has no continuation ID");
|
|
320
|
+
return {
|
|
321
|
+
...r,
|
|
322
|
+
instructions: [],
|
|
323
|
+
messages: a.response.messages.filter(({ role: e }) => e === "tool"),
|
|
324
|
+
providerOptions: { [i]: {
|
|
325
|
+
previousResponseId: s,
|
|
326
|
+
store: !0
|
|
327
|
+
} }
|
|
328
|
+
};
|
|
288
329
|
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
prepareStep: (e) => {
|
|
309
|
-
o = e.stepNumber;
|
|
310
|
-
let n = o === O - 1 ? { toolChoice: "none" } : {}, r = t.provider === "openai" || t.provider === "azure" && !t.chatCompletions ? t.provider : null;
|
|
311
|
-
if (!r || o === 0) return n;
|
|
312
|
-
let i = e.steps.at(-1), a = i.providerMetadata?.[r]?.responseId;
|
|
313
|
-
if (!a) throw Error("The previous model response has no continuation ID");
|
|
314
|
-
return {
|
|
315
|
-
...n,
|
|
316
|
-
instructions: [],
|
|
317
|
-
messages: i.response.messages.filter(({ role: e }) => e === "tool"),
|
|
318
|
-
providerOptions: { [r]: {
|
|
319
|
-
previousResponseId: a,
|
|
320
|
-
store: !0
|
|
321
|
-
} }
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
for await (let e of a.stream) if (e.type === "text-delta") y ??= performance.now() - c, i({
|
|
326
|
-
type: "text",
|
|
327
|
-
text: e.text
|
|
328
|
-
});
|
|
329
|
-
else if (e.type === "tool-call") i({
|
|
330
|
-
type: "activity",
|
|
331
|
-
text: e.toolName
|
|
332
|
-
});
|
|
333
|
-
else if (e.type === "error") throw e.error;
|
|
334
|
-
else e.type === "finish-step" ? (b.push(x(e.usage)), _.push(C(e.usage))) : e.type === "finish" ? E = x(e.totalUsage) : e.type === "abort" && (D = !0);
|
|
335
|
-
!D && !n.aborted && h.push(j, ...await a.responseMessages), i({ type: "done" });
|
|
330
|
+
});
|
|
331
|
+
for await (let e of T.stream) if (e.type === "text-delta") y ??= performance.now() - c, i({
|
|
332
|
+
type: "text",
|
|
333
|
+
text: e.text
|
|
334
|
+
});
|
|
335
|
+
else if (e.type === "tool-call") i({
|
|
336
|
+
type: "activity",
|
|
337
|
+
text: e.toolName
|
|
338
|
+
});
|
|
339
|
+
else if (e.type === "error") {
|
|
340
|
+
if (w.length > 0 && A(e.error)) {
|
|
341
|
+
S = e.error;
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
throw e.error;
|
|
345
|
+
} else e.type === "finish-step" ? (b.push(x(e.usage)), _.push(C(e.usage))) : e.type === "finish" ? (E = s.length ? void 0 : x(e.totalUsage), D = !0) : e.type === "abort" && (k = !0);
|
|
346
|
+
S ? (console.log(`[planning-assistant] continuation rejected (${S.message}) - continuing with the whole history`), s.push(...w)) : !k && !n.aborted && h.push(N, ...s, ...await T.responseMessages);
|
|
347
|
+
} while (S);
|
|
348
|
+
i({ type: "done" });
|
|
336
349
|
} catch (e) {
|
|
337
350
|
console.log("[planning-assistant]", String(e)), i({
|
|
338
351
|
type: "error",
|
|
@@ -343,7 +356,7 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
343
356
|
inputTokens: E?.inputTokens ?? S(b.map((e) => e.inputTokens)),
|
|
344
357
|
outputTokens: E?.outputTokens ?? S(b.map((e) => e.outputTokens)),
|
|
345
358
|
totalTokens: E?.totalTokens ?? S(b.map((e) => e.totalTokens))
|
|
346
|
-
}, r = Object.values(e).some((e) => e !== null), i =
|
|
359
|
+
}, r = Object.values(e).some((e) => e !== null), i = D && !k && !n.aborted && Object.values(e).every((e) => e !== null) && b.every((e) => Object.values(e).every((e) => e !== null));
|
|
347
360
|
console.log(`[planning-assistant] usage ${JSON.stringify({
|
|
348
361
|
provider: t.provider,
|
|
349
362
|
model: t.model,
|
|
@@ -354,8 +367,8 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
354
367
|
details: w(_),
|
|
355
368
|
modelCalls: v,
|
|
356
369
|
requests: a,
|
|
357
|
-
reference:
|
|
358
|
-
referenceAcquisitionMs:
|
|
370
|
+
reference: j,
|
|
371
|
+
referenceAcquisitionMs: M,
|
|
359
372
|
firstTextMs: y,
|
|
360
373
|
turnMs: performance.now() - c
|
|
361
374
|
}
|
|
@@ -368,10 +381,10 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
368
381
|
type: "availability",
|
|
369
382
|
available: !0
|
|
370
383
|
});
|
|
371
|
-
},
|
|
384
|
+
}, N = {
|
|
372
385
|
HIDE: "hide",
|
|
373
386
|
SHOW_ATTRIBUTES: "attributes",
|
|
374
387
|
SHOW_ARTICLES: "articles"
|
|
375
388
|
};
|
|
376
389
|
//#endregion
|
|
377
|
-
export {
|
|
390
|
+
export { N as HI_PANEL_ACTION, _ as cleanupHi, d as createHiLibraryCallbacks, y as createHiMcpTools, c as libLoadArticleCatalog, u as libLoadCalcScript, l as libLoadMasterData, j as loadChatModel, p as omGetRequest, f as omPostRequest, a as registerLegacyUrlFormat, g as setupHi, M as startPlanningAssistant, o as unregisterLegacyUrlFormat };
|
package/hi.min.js
CHANGED
|
@@ -144,7 +144,7 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
144
144
|
otherBytes: n.bytes - i - o
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
|
-
}, T = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, E = async ({ provider: e, model: t, apiKey: n, baseUrl: r, chatCompletions: i, reasoningEffort: a }, o) => {
|
|
147
|
+
}, T = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, E = /^(Previous response with id '[^']*' not found|No tool output found for function call )/, D = (e) => e instanceof Error && E.test(e.message), O = async ({ provider: e, model: t, apiKey: n, baseUrl: r, chatCompletions: i, reasoningEffort: a }, o) => {
|
|
148
148
|
let s = o ? { fetch: async (e, t) => (typeof t?.body == "string" && await o(t.body), fetch(e, t)) } : {};
|
|
149
149
|
switch (e) {
|
|
150
150
|
case "openai": {
|
|
@@ -189,12 +189,12 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
189
189
|
}
|
|
190
190
|
default: throw Error(`Unknown provider "${e}" - supported: azure, openai, mistral, anthropic, google`);
|
|
191
191
|
}
|
|
192
|
-
},
|
|
192
|
+
}, k = async (e, t, n) => {
|
|
193
193
|
let r = e.extended, i = (e) => r.planningAssistantOutput(e), a = [], o = null, s = /* @__PURE__ */ new Set(), c;
|
|
194
194
|
try {
|
|
195
195
|
c = await Promise.all([
|
|
196
196
|
import(T("ai@7.0.122")),
|
|
197
|
-
|
|
197
|
+
O(t, async (e) => {
|
|
198
198
|
a.push({
|
|
199
199
|
...await w(e, s),
|
|
200
200
|
stepNumber: o
|
|
@@ -215,7 +215,7 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
215
215
|
r.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: r }) => {
|
|
216
216
|
let c = performance.now();
|
|
217
217
|
a = [], o = null, s.clear();
|
|
218
|
-
let _ = [], v = [], y = null, w = [], T, E = !1,
|
|
218
|
+
let _ = [], v = [], y = null, w = [], T, E = !1, O = !1, k = null, A = {
|
|
219
219
|
role: "user",
|
|
220
220
|
content: [{
|
|
221
221
|
type: "text",
|
|
@@ -242,67 +242,81 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
} catch {}
|
|
245
|
-
|
|
245
|
+
k = await C(JSON.stringify({
|
|
246
246
|
instructions: m,
|
|
247
247
|
messages: r
|
|
248
248
|
})), performance.now() - e;
|
|
249
|
-
let a =
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
249
|
+
let a = [
|
|
250
|
+
...r,
|
|
251
|
+
...h,
|
|
252
|
+
A
|
|
253
|
+
], s = [], f, x = 0;
|
|
254
|
+
do {
|
|
255
|
+
f = void 0;
|
|
256
|
+
let e = x, C = [], j = l({
|
|
257
|
+
model: d.languageModel,
|
|
258
|
+
providerOptions: g && r.length && k.sha256 ? {
|
|
259
|
+
...d.providerOptions,
|
|
260
|
+
azure: {
|
|
261
|
+
...d.providerOptions?.azure,
|
|
262
|
+
promptCacheKey: k.sha256
|
|
263
|
+
}
|
|
264
|
+
} : d.providerOptions,
|
|
265
|
+
instructions: m,
|
|
266
|
+
messages: [...a, ...s],
|
|
267
|
+
tools: p,
|
|
268
|
+
stopWhen: u(16 - e),
|
|
269
|
+
abortSignal: n,
|
|
270
|
+
onLanguageModelCallEnd: (e) => {
|
|
271
|
+
v.push({
|
|
272
|
+
...b(e.usage),
|
|
273
|
+
...S(e.usage),
|
|
274
|
+
responseTimeMs: e.performance.responseTimeMs,
|
|
275
|
+
timeToFirstOutputMs: e.performance.timeToFirstOutputMs ?? null,
|
|
276
|
+
finishReason: e.finishReason
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
onStepEnd: (e) => {
|
|
280
|
+
C.push(...e.response.messages), x++;
|
|
281
|
+
},
|
|
282
|
+
prepareStep: (n) => {
|
|
283
|
+
o = e + n.stepNumber;
|
|
284
|
+
let r = o === 15 ? { toolChoice: "none" } : {}, i = t.provider === "openai" || t.provider === "azure" && !t.chatCompletions ? t.provider : null;
|
|
285
|
+
if (!i || n.stepNumber === 0) return r;
|
|
286
|
+
let a = n.steps.at(-1), s = a.providerMetadata?.[i]?.responseId;
|
|
287
|
+
if (!s) throw Error("The previous model response has no continuation ID");
|
|
288
|
+
return {
|
|
289
|
+
...r,
|
|
290
|
+
instructions: [],
|
|
291
|
+
messages: a.response.messages.filter(({ role: e }) => e === "tool"),
|
|
292
|
+
providerOptions: { [i]: {
|
|
293
|
+
previousResponseId: s,
|
|
294
|
+
store: !0
|
|
295
|
+
} }
|
|
296
|
+
};
|
|
256
297
|
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
},
|
|
276
|
-
prepareStep: (e) => {
|
|
277
|
-
o = e.stepNumber;
|
|
278
|
-
let n = o === 15 ? { toolChoice: "none" } : {}, r = t.provider === "openai" || t.provider === "azure" && !t.chatCompletions ? t.provider : null;
|
|
279
|
-
if (!r || o === 0) return n;
|
|
280
|
-
let i = e.steps.at(-1), a = i.providerMetadata?.[r]?.responseId;
|
|
281
|
-
if (!a) throw Error("The previous model response has no continuation ID");
|
|
282
|
-
return {
|
|
283
|
-
...n,
|
|
284
|
-
instructions: [],
|
|
285
|
-
messages: i.response.messages.filter(({ role: e }) => e === "tool"),
|
|
286
|
-
providerOptions: { [r]: {
|
|
287
|
-
previousResponseId: a,
|
|
288
|
-
store: !0
|
|
289
|
-
} }
|
|
290
|
-
};
|
|
298
|
+
});
|
|
299
|
+
for await (let e of j.stream) if (e.type === "text-delta") y ??= performance.now() - c, i({
|
|
300
|
+
type: "text",
|
|
301
|
+
text: e.text
|
|
302
|
+
});
|
|
303
|
+
else if (e.type === "tool-call") i({
|
|
304
|
+
type: "activity",
|
|
305
|
+
text: e.toolName
|
|
306
|
+
});
|
|
307
|
+
else {
|
|
308
|
+
if (e.type === "error") {
|
|
309
|
+
if (C.length > 0 && D(e.error)) {
|
|
310
|
+
f = e.error;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
throw e.error;
|
|
314
|
+
}
|
|
315
|
+
e.type === "finish-step" ? (w.push(b(e.usage)), _.push(S(e.usage))) : e.type === "finish" ? (T = s.length ? void 0 : b(e.totalUsage), E = !0) : e.type === "abort" && (O = !0);
|
|
291
316
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
text: e.text
|
|
296
|
-
});
|
|
297
|
-
else if (e.type === "tool-call") i({
|
|
298
|
-
type: "activity",
|
|
299
|
-
text: e.toolName
|
|
300
|
-
});
|
|
301
|
-
else {
|
|
302
|
-
if (e.type === "error") throw e.error;
|
|
303
|
-
e.type === "finish-step" ? (w.push(b(e.usage)), _.push(S(e.usage))) : e.type === "finish" ? T = b(e.totalUsage) : e.type === "abort" && (E = !0);
|
|
304
|
-
}
|
|
305
|
-
E || n.aborted || h.push(O, ...await a.responseMessages), i({ type: "done" });
|
|
317
|
+
f ? s.push(...C) : O || n.aborted || h.push(A, ...s, ...await j.responseMessages);
|
|
318
|
+
} while (f);
|
|
319
|
+
i({ type: "done" });
|
|
306
320
|
} catch (e) {
|
|
307
321
|
i({
|
|
308
322
|
type: "error",
|
|
@@ -314,7 +328,7 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
314
328
|
outputTokens: T?.outputTokens ?? x(w.map((e) => e.outputTokens)),
|
|
315
329
|
totalTokens: T?.totalTokens ?? x(w.map((e) => e.totalTokens))
|
|
316
330
|
};
|
|
317
|
-
Object.values(e).some((e) => e !== null),
|
|
331
|
+
Object.values(e).some((e) => e !== null), E && !O && !n.aborted && Object.values(e).every((e) => e !== null) && w.every((e) => Object.values(e).every((e) => e !== null));
|
|
318
332
|
}
|
|
319
333
|
}, i({
|
|
320
334
|
type: "images",
|
|
@@ -323,9 +337,9 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
323
337
|
type: "availability",
|
|
324
338
|
available: !0
|
|
325
339
|
});
|
|
326
|
-
},
|
|
340
|
+
}, A = {
|
|
327
341
|
HIDE: "hide",
|
|
328
342
|
SHOW_ATTRIBUTES: "attributes",
|
|
329
343
|
SHOW_ARTICLES: "articles"
|
|
330
344
|
};
|
|
331
|
-
export {
|
|
345
|
+
export { A as HI_PANEL_ACTION, g as cleanupHi, d as createHiLibraryCallbacks, v as createHiMcpTools, c as libLoadArticleCatalog, u as libLoadCalcScript, l as libLoadMasterData, O as loadChatModel, p as omGetRequest, f as omPostRequest, a as registerLegacyUrlFormat, h as setupHi, k as startPlanningAssistant, o as unregisterLegacyUrlFormat };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roomle/embedding-lib",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-130245d",
|
|
4
4
|
"description": "This is a small library which can be used to communicate with the Roomle Configurator. ES modules only (browser-compatible).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./roomle-embedding-lib.js",
|