@iota-uz/sdk 0.4.34 → 0.4.36
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/dist/applet/core.cjs +157 -0
- package/dist/applet/core.cjs.map +1 -1
- package/dist/applet/core.d.cts +16 -1
- package/dist/applet/core.d.ts +16 -1
- package/dist/applet/core.mjs +156 -1
- package/dist/applet/core.mjs.map +1 -1
- package/dist/applet/host.d.cts +2 -31
- package/dist/applet/host.d.ts +2 -31
- package/dist/bichat/index.cjs +403 -7
- package/dist/bichat/index.cjs.map +1 -1
- package/dist/bichat/index.d.cts +227 -2
- package/dist/bichat/index.d.ts +227 -2
- package/dist/bichat/index.mjs +397 -8
- package/dist/bichat/index.mjs.map +1 -1
- package/dist/index.cjs +157 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +156 -124
- package/dist/index.mjs.map +1 -1
- package/dist/rpc-fh942_dj.d.cts +31 -0
- package/dist/rpc-fh942_dj.d.ts +31 -0
- package/package.json +4 -1
- package/tailwind/compiled.css +1 -1
package/dist/bichat/index.mjs
CHANGED
|
@@ -3003,7 +3003,10 @@ var ChatMachine = class {
|
|
|
3003
3003
|
)
|
|
3004
3004
|
});
|
|
3005
3005
|
const normalized = normalizeRPCError(err, "Failed to send message");
|
|
3006
|
-
this._updateInput({
|
|
3006
|
+
this._updateInput({
|
|
3007
|
+
message: content,
|
|
3008
|
+
inputError: normalized.userMessage
|
|
3009
|
+
});
|
|
3007
3010
|
this._updateMessaging({
|
|
3008
3011
|
streamError: normalized.userMessage,
|
|
3009
3012
|
streamErrorRetryable: normalized.retryable
|
|
@@ -12677,7 +12680,9 @@ function ModelSelector() {
|
|
|
12677
12680
|
}, [currentModel, models, setModel]);
|
|
12678
12681
|
useEffect(() => {
|
|
12679
12682
|
const handler = (e) => {
|
|
12680
|
-
|
|
12683
|
+
const isModifierPressed = e.metaKey || e.ctrlKey;
|
|
12684
|
+
const isShortcutKey = e.code === "KeyM" || e.key.toLowerCase() === "m";
|
|
12685
|
+
if (isModifierPressed && e.shiftKey && !e.altKey && isShortcutKey) {
|
|
12681
12686
|
e.preventDefault();
|
|
12682
12687
|
rotateModel();
|
|
12683
12688
|
}
|
|
@@ -17053,6 +17058,140 @@ function useStreaming2(options = {}) {
|
|
|
17053
17058
|
reset
|
|
17054
17059
|
};
|
|
17055
17060
|
}
|
|
17061
|
+
var TERMINAL = /* @__PURE__ */ new Set([
|
|
17062
|
+
"completed",
|
|
17063
|
+
"cancelled",
|
|
17064
|
+
"failed"
|
|
17065
|
+
]);
|
|
17066
|
+
function useActiveRuns(dataSource, options = {}) {
|
|
17067
|
+
const [runs, setRuns] = useState({});
|
|
17068
|
+
const [ready, setReady] = useState(false);
|
|
17069
|
+
const onErrorRef = useRef(options.onError);
|
|
17070
|
+
onErrorRef.current = options.onError;
|
|
17071
|
+
const enabled = options.enabled ?? true;
|
|
17072
|
+
const retainTerminalMs = options.retainTerminalMs ?? 0;
|
|
17073
|
+
const emptyStateTimeoutMs = options.emptyStateTimeoutMs ?? 250;
|
|
17074
|
+
useEffect(() => {
|
|
17075
|
+
if (!enabled) {
|
|
17076
|
+
return;
|
|
17077
|
+
}
|
|
17078
|
+
if (!dataSource.subscribeActiveRuns) {
|
|
17079
|
+
return;
|
|
17080
|
+
}
|
|
17081
|
+
const controller = new AbortController();
|
|
17082
|
+
let stagingTimer;
|
|
17083
|
+
const staging = {};
|
|
17084
|
+
let sawSnapshotRow = false;
|
|
17085
|
+
const pendingTerminalTimers = /* @__PURE__ */ new Map();
|
|
17086
|
+
const flushSnapshot = () => {
|
|
17087
|
+
setRuns((prev) => ({ ...prev, ...staging }));
|
|
17088
|
+
setReady(true);
|
|
17089
|
+
stagingTimer = void 0;
|
|
17090
|
+
};
|
|
17091
|
+
const subscription = dataSource.subscribeActiveRuns({
|
|
17092
|
+
signal: controller.signal,
|
|
17093
|
+
onError: (evt) => onErrorRef.current?.(evt),
|
|
17094
|
+
onEvent: (evt) => {
|
|
17095
|
+
if (evt.event === "snapshot") {
|
|
17096
|
+
sawSnapshotRow = true;
|
|
17097
|
+
const pending2 = pendingTerminalTimers.get(evt.sessionId);
|
|
17098
|
+
if (pending2 !== void 0) {
|
|
17099
|
+
clearTimeout(pending2);
|
|
17100
|
+
pendingTerminalTimers.delete(evt.sessionId);
|
|
17101
|
+
}
|
|
17102
|
+
staging[evt.sessionId] = {
|
|
17103
|
+
runId: evt.runId,
|
|
17104
|
+
status: evt.status,
|
|
17105
|
+
updatedAt: evt.updatedAt
|
|
17106
|
+
};
|
|
17107
|
+
if (stagingTimer === void 0) {
|
|
17108
|
+
stagingTimer = setTimeout(flushSnapshot, 16);
|
|
17109
|
+
}
|
|
17110
|
+
return;
|
|
17111
|
+
}
|
|
17112
|
+
if (TERMINAL.has(evt.status)) {
|
|
17113
|
+
if (retainTerminalMs <= 0) {
|
|
17114
|
+
setRuns((prev) => {
|
|
17115
|
+
if (!(evt.sessionId in prev)) {
|
|
17116
|
+
return prev;
|
|
17117
|
+
}
|
|
17118
|
+
const next = { ...prev };
|
|
17119
|
+
delete next[evt.sessionId];
|
|
17120
|
+
return next;
|
|
17121
|
+
});
|
|
17122
|
+
return;
|
|
17123
|
+
}
|
|
17124
|
+
setRuns((prev) => ({
|
|
17125
|
+
...prev,
|
|
17126
|
+
[evt.sessionId]: {
|
|
17127
|
+
runId: evt.runId,
|
|
17128
|
+
status: evt.status,
|
|
17129
|
+
updatedAt: evt.updatedAt
|
|
17130
|
+
}
|
|
17131
|
+
}));
|
|
17132
|
+
const existing = pendingTerminalTimers.get(evt.sessionId);
|
|
17133
|
+
if (existing !== void 0) {
|
|
17134
|
+
clearTimeout(existing);
|
|
17135
|
+
}
|
|
17136
|
+
const handle = setTimeout(() => {
|
|
17137
|
+
pendingTerminalTimers.delete(evt.sessionId);
|
|
17138
|
+
setRuns((prev) => {
|
|
17139
|
+
if (!(evt.sessionId in prev)) {
|
|
17140
|
+
return prev;
|
|
17141
|
+
}
|
|
17142
|
+
const next = { ...prev };
|
|
17143
|
+
delete next[evt.sessionId];
|
|
17144
|
+
return next;
|
|
17145
|
+
});
|
|
17146
|
+
}, retainTerminalMs);
|
|
17147
|
+
pendingTerminalTimers.set(evt.sessionId, handle);
|
|
17148
|
+
return;
|
|
17149
|
+
}
|
|
17150
|
+
const pending = pendingTerminalTimers.get(evt.sessionId);
|
|
17151
|
+
if (pending !== void 0) {
|
|
17152
|
+
clearTimeout(pending);
|
|
17153
|
+
pendingTerminalTimers.delete(evt.sessionId);
|
|
17154
|
+
}
|
|
17155
|
+
setRuns((prev) => ({
|
|
17156
|
+
...prev,
|
|
17157
|
+
[evt.sessionId]: {
|
|
17158
|
+
runId: evt.runId,
|
|
17159
|
+
status: evt.status,
|
|
17160
|
+
updatedAt: evt.updatedAt
|
|
17161
|
+
}
|
|
17162
|
+
}));
|
|
17163
|
+
}
|
|
17164
|
+
});
|
|
17165
|
+
subscription?.catch((err) => {
|
|
17166
|
+
if (controller.signal.aborted) {
|
|
17167
|
+
return;
|
|
17168
|
+
}
|
|
17169
|
+
const surface = err instanceof Event ? err : new Event("error");
|
|
17170
|
+
onErrorRef.current?.(surface);
|
|
17171
|
+
});
|
|
17172
|
+
const readyTimeout = setTimeout(() => {
|
|
17173
|
+
if (!sawSnapshotRow) {
|
|
17174
|
+
setReady(true);
|
|
17175
|
+
}
|
|
17176
|
+
}, emptyStateTimeoutMs);
|
|
17177
|
+
return () => {
|
|
17178
|
+
controller.abort();
|
|
17179
|
+
if (stagingTimer !== void 0) {
|
|
17180
|
+
clearTimeout(stagingTimer);
|
|
17181
|
+
}
|
|
17182
|
+
clearTimeout(readyTimeout);
|
|
17183
|
+
for (const handle of pendingTerminalTimers.values()) {
|
|
17184
|
+
clearTimeout(handle);
|
|
17185
|
+
}
|
|
17186
|
+
pendingTerminalTimers.clear();
|
|
17187
|
+
};
|
|
17188
|
+
}, [dataSource, enabled, retainTerminalMs, emptyStateTimeoutMs]);
|
|
17189
|
+
const status = useCallback(
|
|
17190
|
+
(sessionId) => runs[sessionId]?.status,
|
|
17191
|
+
[runs]
|
|
17192
|
+
);
|
|
17193
|
+
return { runs, ready, status };
|
|
17194
|
+
}
|
|
17056
17195
|
|
|
17057
17196
|
// ui/src/bichat/index.ts
|
|
17058
17197
|
init_useTranslation();
|
|
@@ -19122,6 +19261,8 @@ function toStreamEvent(chunk) {
|
|
|
19122
19261
|
return chunk.sessionId ? { type: "user_message", sessionId: chunk.sessionId } : null;
|
|
19123
19262
|
case "interrupt":
|
|
19124
19263
|
return chunk.interrupt ? { type: "interrupt", interrupt: chunk.interrupt, sessionId: chunk.sessionId } : null;
|
|
19264
|
+
case "text_block_end":
|
|
19265
|
+
return { type: "text_block_end", seq: chunk.textBlockSeq ?? 0 };
|
|
19125
19266
|
case "done":
|
|
19126
19267
|
return { type: "done", sessionId: chunk.sessionId, generationMs: chunk.generationMs };
|
|
19127
19268
|
case "error":
|
|
@@ -19131,6 +19272,90 @@ function toStreamEvent(chunk) {
|
|
|
19131
19272
|
}
|
|
19132
19273
|
}
|
|
19133
19274
|
|
|
19275
|
+
// ui/src/bichat/utils/eventNames.ts
|
|
19276
|
+
var STREAM_EVENT_TYPES = [
|
|
19277
|
+
"chunk",
|
|
19278
|
+
"content",
|
|
19279
|
+
"thinking",
|
|
19280
|
+
"tool_start",
|
|
19281
|
+
"tool_end",
|
|
19282
|
+
"text_block_end",
|
|
19283
|
+
"snapshot",
|
|
19284
|
+
"interrupt",
|
|
19285
|
+
"citation",
|
|
19286
|
+
"usage",
|
|
19287
|
+
"ping",
|
|
19288
|
+
"stream_started",
|
|
19289
|
+
"done",
|
|
19290
|
+
"cancelled",
|
|
19291
|
+
"error",
|
|
19292
|
+
"failed"
|
|
19293
|
+
];
|
|
19294
|
+
var TERMINAL_STREAM_EVENT_TYPES = [
|
|
19295
|
+
"done",
|
|
19296
|
+
"cancelled",
|
|
19297
|
+
"error",
|
|
19298
|
+
"failed"
|
|
19299
|
+
];
|
|
19300
|
+
function isTerminalEvent(name) {
|
|
19301
|
+
return TERMINAL_STREAM_EVENT_TYPES.includes(name);
|
|
19302
|
+
}
|
|
19303
|
+
|
|
19304
|
+
// ui/src/bichat/data/openManagedEventSource.ts
|
|
19305
|
+
function openManagedEventSource(opts) {
|
|
19306
|
+
const graceMs = opts.connectGraceMs ?? 500;
|
|
19307
|
+
return new Promise((resolve, reject) => {
|
|
19308
|
+
const startedAt = Date.now();
|
|
19309
|
+
const es = new EventSource(opts.url, {
|
|
19310
|
+
withCredentials: opts.withCredentials ?? true
|
|
19311
|
+
});
|
|
19312
|
+
let settled = false;
|
|
19313
|
+
let sawEvent = false;
|
|
19314
|
+
const settle = (err) => {
|
|
19315
|
+
if (settled) {
|
|
19316
|
+
return;
|
|
19317
|
+
}
|
|
19318
|
+
settled = true;
|
|
19319
|
+
es.close();
|
|
19320
|
+
if (err) {
|
|
19321
|
+
reject(err);
|
|
19322
|
+
} else {
|
|
19323
|
+
resolve();
|
|
19324
|
+
}
|
|
19325
|
+
};
|
|
19326
|
+
if (opts.signal) {
|
|
19327
|
+
if (opts.signal.aborted) {
|
|
19328
|
+
settle();
|
|
19329
|
+
return;
|
|
19330
|
+
}
|
|
19331
|
+
opts.signal.addEventListener("abort", () => settle(), { once: true });
|
|
19332
|
+
}
|
|
19333
|
+
const forward = (name) => (evt) => {
|
|
19334
|
+
sawEvent = true;
|
|
19335
|
+
let parsed;
|
|
19336
|
+
try {
|
|
19337
|
+
parsed = JSON.parse(evt.data);
|
|
19338
|
+
} catch {
|
|
19339
|
+
parsed = { __unparseable: true, raw: String(evt.data) };
|
|
19340
|
+
}
|
|
19341
|
+
try {
|
|
19342
|
+
opts.onMessage(name, parsed);
|
|
19343
|
+
} catch {
|
|
19344
|
+
}
|
|
19345
|
+
};
|
|
19346
|
+
for (const name of opts.events) {
|
|
19347
|
+
es.addEventListener(name, forward(name));
|
|
19348
|
+
}
|
|
19349
|
+
es.onerror = (evt) => {
|
|
19350
|
+
opts.onError?.(evt);
|
|
19351
|
+
if (graceMs > 0 && !sawEvent && Date.now() - startedAt < graceMs) {
|
|
19352
|
+
const err = opts.onConnectError ? opts.onConnectError(evt) : new Error("EventSource failed to connect before first event");
|
|
19353
|
+
settle(err);
|
|
19354
|
+
}
|
|
19355
|
+
};
|
|
19356
|
+
});
|
|
19357
|
+
}
|
|
19358
|
+
|
|
19134
19359
|
// ui/src/bichat/data/AttachmentUploader.ts
|
|
19135
19360
|
init_chartSpec();
|
|
19136
19361
|
var MIME_TO_EXTENSION = {
|
|
@@ -19385,6 +19610,26 @@ async function ensureAttachmentUpload(attachment, context, uploadFileFn) {
|
|
|
19385
19610
|
}
|
|
19386
19611
|
|
|
19387
19612
|
// ui/src/bichat/data/MessageTransport.ts
|
|
19613
|
+
var RunEventsConnectError = class extends Error {
|
|
19614
|
+
constructor(message, cause) {
|
|
19615
|
+
super(message);
|
|
19616
|
+
this.name = "RunEventsConnectError";
|
|
19617
|
+
this.cause = cause;
|
|
19618
|
+
}
|
|
19619
|
+
};
|
|
19620
|
+
function generateRequestId() {
|
|
19621
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
19622
|
+
return crypto.randomUUID();
|
|
19623
|
+
}
|
|
19624
|
+
const bytes = new Uint8Array(16);
|
|
19625
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
19626
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
19627
|
+
}
|
|
19628
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
19629
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
19630
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
19631
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
19632
|
+
}
|
|
19388
19633
|
async function* sendMessage(deps, sessionId, content, attachments = [], signal, options) {
|
|
19389
19634
|
const abortController = new AbortController();
|
|
19390
19635
|
let onExternalAbort;
|
|
@@ -19412,12 +19657,14 @@ async function* sendMessage(deps, sessionId, content, attachments = [], signal,
|
|
|
19412
19657
|
sessionId,
|
|
19413
19658
|
attachmentCount: streamAttachments.length
|
|
19414
19659
|
});
|
|
19660
|
+
const requestId = options?.requestId ?? generateRequestId();
|
|
19415
19661
|
const payload = {
|
|
19416
19662
|
sessionId,
|
|
19417
19663
|
content,
|
|
19418
19664
|
debugMode: options?.debugMode ?? false,
|
|
19419
19665
|
replaceFromMessageId: options?.replaceFromMessageID,
|
|
19420
|
-
attachments: streamAttachments
|
|
19666
|
+
attachments: streamAttachments,
|
|
19667
|
+
requestId
|
|
19421
19668
|
};
|
|
19422
19669
|
if (options?.reasoningEffort) {
|
|
19423
19670
|
payload.reasoningEffort = options.reasoningEffort;
|
|
@@ -19458,10 +19705,14 @@ async function* sendMessage(deps, sessionId, content, attachments = [], signal,
|
|
|
19458
19705
|
} catch (err) {
|
|
19459
19706
|
if (err instanceof Error) {
|
|
19460
19707
|
if (err.name === "AbortError") {
|
|
19461
|
-
|
|
19462
|
-
|
|
19463
|
-
|
|
19464
|
-
|
|
19708
|
+
if (connectionTimedOut) {
|
|
19709
|
+
yield {
|
|
19710
|
+
type: "error",
|
|
19711
|
+
error: `Stream request timed out after ${deps.streamConnectTimeoutMs}ms`
|
|
19712
|
+
};
|
|
19713
|
+
} else {
|
|
19714
|
+
throw err;
|
|
19715
|
+
}
|
|
19465
19716
|
} else {
|
|
19466
19717
|
yield {
|
|
19467
19718
|
type: "error",
|
|
@@ -19585,6 +19836,67 @@ async function resumeStream(deps, sessionId, runId, onChunk, signal) {
|
|
|
19585
19836
|
}
|
|
19586
19837
|
}
|
|
19587
19838
|
}
|
|
19839
|
+
function subscribeRunEvents(deps, sessionId, runId, options) {
|
|
19840
|
+
const base = buildStreamUrl(deps, "/events");
|
|
19841
|
+
const qs = new URLSearchParams({ sessionId, runId });
|
|
19842
|
+
const url = `${base}?${qs.toString()}`;
|
|
19843
|
+
const withCursor = options.lastEventId ? `${url}&${new URLSearchParams({ lastEventId: options.lastEventId }).toString()}` : url;
|
|
19844
|
+
const settleController = new AbortController();
|
|
19845
|
+
if (options.signal) {
|
|
19846
|
+
if (options.signal.aborted) {
|
|
19847
|
+
settleController.abort();
|
|
19848
|
+
} else {
|
|
19849
|
+
options.signal.addEventListener("abort", () => settleController.abort(), {
|
|
19850
|
+
once: true
|
|
19851
|
+
});
|
|
19852
|
+
}
|
|
19853
|
+
}
|
|
19854
|
+
return openManagedEventSource({
|
|
19855
|
+
url: withCursor,
|
|
19856
|
+
events: STREAM_EVENT_TYPES,
|
|
19857
|
+
withCredentials: true,
|
|
19858
|
+
signal: settleController.signal,
|
|
19859
|
+
onError: options.onError,
|
|
19860
|
+
onConnectError: (evt) => new RunEventsConnectError(
|
|
19861
|
+
"EventSource failed to connect before first event",
|
|
19862
|
+
evt
|
|
19863
|
+
),
|
|
19864
|
+
onMessage: (name, data) => {
|
|
19865
|
+
if (typeof data === "object" && data !== null && data.__unparseable) {
|
|
19866
|
+
options.onChunk({
|
|
19867
|
+
type: "error",
|
|
19868
|
+
error: `Failed to parse event: ${data.raw}`
|
|
19869
|
+
});
|
|
19870
|
+
return;
|
|
19871
|
+
}
|
|
19872
|
+
const parsed = data;
|
|
19873
|
+
if (!parsed.type) {
|
|
19874
|
+
parsed.type = name;
|
|
19875
|
+
}
|
|
19876
|
+
options.onChunk(parsed);
|
|
19877
|
+
if (isTerminalEvent(name) || isTerminalEvent(String(parsed.type))) {
|
|
19878
|
+
settleController.abort();
|
|
19879
|
+
}
|
|
19880
|
+
}
|
|
19881
|
+
});
|
|
19882
|
+
}
|
|
19883
|
+
function subscribeActiveRuns(deps, options) {
|
|
19884
|
+
const url = buildStreamUrl(deps, "/active-runs");
|
|
19885
|
+
return openManagedEventSource({
|
|
19886
|
+
url,
|
|
19887
|
+
events: ["snapshot", "update"],
|
|
19888
|
+
withCredentials: true,
|
|
19889
|
+
signal: options.signal,
|
|
19890
|
+
onError: options.onError,
|
|
19891
|
+
onMessage: (name, data) => {
|
|
19892
|
+
if (typeof data !== "object" || data === null || data.__unparseable) {
|
|
19893
|
+
return;
|
|
19894
|
+
}
|
|
19895
|
+
const body = data;
|
|
19896
|
+
options.onEvent({ event: name, ...body });
|
|
19897
|
+
}
|
|
19898
|
+
});
|
|
19899
|
+
}
|
|
19588
19900
|
async function submitQuestionAnswers(callRPC, sessionId, questionId, answers) {
|
|
19589
19901
|
try {
|
|
19590
19902
|
const flatAnswers = {};
|
|
@@ -19853,6 +20165,39 @@ var HttpDataSource = class {
|
|
|
19853
20165
|
signal
|
|
19854
20166
|
);
|
|
19855
20167
|
}
|
|
20168
|
+
/**
|
|
20169
|
+
* Open a native EventSource against GET /stream/events for the given
|
|
20170
|
+
* run. Used by components that want browser-native auto-reconnect
|
|
20171
|
+
* with Last-Event-ID (tab close, wifi drop, device switch). Prefer
|
|
20172
|
+
* over resumeStream when tailing an already-running generation that
|
|
20173
|
+
* another tab started.
|
|
20174
|
+
*/
|
|
20175
|
+
subscribeRunEvents(sessionId, runId, options) {
|
|
20176
|
+
return subscribeRunEvents(
|
|
20177
|
+
{
|
|
20178
|
+
baseUrl: this.config.baseUrl,
|
|
20179
|
+
streamEndpoint: this.config.streamEndpoint
|
|
20180
|
+
},
|
|
20181
|
+
sessionId,
|
|
20182
|
+
runId,
|
|
20183
|
+
options
|
|
20184
|
+
);
|
|
20185
|
+
}
|
|
20186
|
+
/**
|
|
20187
|
+
* Subscribe to the per-tenant active-run fan-out
|
|
20188
|
+
* (GET /stream/active-runs). Never resolves until the caller aborts
|
|
20189
|
+
* via the signal; use from a top-level component (sidebar container)
|
|
20190
|
+
* that mounts for the lifetime of the chat app.
|
|
20191
|
+
*/
|
|
20192
|
+
subscribeActiveRuns(options) {
|
|
20193
|
+
return subscribeActiveRuns(
|
|
20194
|
+
{
|
|
20195
|
+
baseUrl: this.config.baseUrl,
|
|
20196
|
+
streamEndpoint: this.config.streamEndpoint
|
|
20197
|
+
},
|
|
20198
|
+
options
|
|
20199
|
+
);
|
|
20200
|
+
}
|
|
19856
20201
|
async *sendMessage(sessionId, content, attachments = [], signal, options) {
|
|
19857
20202
|
this.abortController = new AbortController();
|
|
19858
20203
|
let onExternalAbort;
|
|
@@ -19926,6 +20271,50 @@ function createHttpDataSource(config) {
|
|
|
19926
20271
|
return new HttpDataSource(config);
|
|
19927
20272
|
}
|
|
19928
20273
|
|
|
19929
|
-
|
|
20274
|
+
// ui/src/bichat/utils/textBlocks.ts
|
|
20275
|
+
function splitIntoTextBlocks(content, offsets) {
|
|
20276
|
+
if (!content) {
|
|
20277
|
+
return [];
|
|
20278
|
+
}
|
|
20279
|
+
if (!offsets || offsets.length === 0) {
|
|
20280
|
+
return [{ seq: 0, content }];
|
|
20281
|
+
}
|
|
20282
|
+
const sanitized = [...offsets].map((n) => Math.max(0, Math.min(Math.floor(n), content.length))).sort((a, b) => a - b);
|
|
20283
|
+
const blocks = [];
|
|
20284
|
+
let cursor = 0;
|
|
20285
|
+
for (let i = 0; i < sanitized.length; i++) {
|
|
20286
|
+
const end = sanitized[i];
|
|
20287
|
+
if (end <= cursor) {
|
|
20288
|
+
continue;
|
|
20289
|
+
}
|
|
20290
|
+
const slice = content.slice(cursor, end);
|
|
20291
|
+
if (slice) {
|
|
20292
|
+
blocks.push({ seq: blocks.length, content: slice });
|
|
20293
|
+
}
|
|
20294
|
+
cursor = end;
|
|
20295
|
+
}
|
|
20296
|
+
if (cursor < content.length) {
|
|
20297
|
+
blocks.push({ seq: blocks.length, content: content.slice(cursor) });
|
|
20298
|
+
}
|
|
20299
|
+
return blocks;
|
|
20300
|
+
}
|
|
20301
|
+
function readTextBlockOffsets(partialMetadata) {
|
|
20302
|
+
if (!partialMetadata) {
|
|
20303
|
+
return [];
|
|
20304
|
+
}
|
|
20305
|
+
const raw = partialMetadata["text_block_offsets"];
|
|
20306
|
+
if (!Array.isArray(raw)) {
|
|
20307
|
+
return [];
|
|
20308
|
+
}
|
|
20309
|
+
const out = [];
|
|
20310
|
+
for (const entry of raw) {
|
|
20311
|
+
if (typeof entry === "number" && Number.isFinite(entry) && entry >= 0) {
|
|
20312
|
+
out.push(Math.floor(entry));
|
|
20313
|
+
}
|
|
20314
|
+
}
|
|
20315
|
+
return out;
|
|
20316
|
+
}
|
|
20317
|
+
|
|
20318
|
+
export { ATTACHMENT_ACCEPT_ATTRIBUTE, ActionButton, ActivityTrace, Alert_default as Alert, AllChatsList, ArchiveBanner_default as ArchiveBanner, ArchivedChatList, AssistantMessage, AssistantTurnView, MemoizedAttachmentGrid as AttachmentGrid, AttachmentPreview_default as AttachmentPreview, AttachmentUpload_default as AttachmentUpload, Avatar, AvatarStack, BiChatLayout, Bubble, CHART_VISUAL, ChartCard, ChatHeader, ChatMachine, ChatSession, ChatSessionProvider, MemoizedCodeBlock as CodeBlock, CodeOutputsPanel, CompactionDoodle, ConfigProvider, ConfirmModal, ConfirmationStep, DateGroupHeader, DebugPanel, DefaultErrorContent, DownloadCard, MemoizedEditableText as EditableText, MemoizedEmptyState as EmptyState, ErrorBoundary, HttpDataSource, ImageModal, InlineQuestionForm, InteractiveTableCard, IotaContextProvider, ListItemSkeleton, MemoizedLoadingSpinner as LoadingSpinner, MemoizedMarkdownRenderer as MarkdownRenderer, MessageActions, MessageInput, MessageList, MessageRole, ModelSelector, PermissionGuard, QuestionForm, QuestionStep, RateLimiter, RetryActionArea, RunEventsConnectError, STREAM_EVENT_TYPES, ScreenReaderAnnouncer, ScrollToBottomButton, MemoizedSearchInput as SearchInput, SessionArtifactList, SessionArtifactPreview, SessionArtifactsPanel, SessionItem_default as SessionItem, SessionMembersModal, SessionSkeleton, Sidebar2 as Sidebar, MemoizedSkeleton as Skeleton, SkeletonAvatar, SkeletonCard, SkeletonGroup, SkeletonText, SkipLink, Slot, SourcesPanel, StreamError, StreamingCursor, SystemMessage, TERMINAL_STREAM_EVENT_TYPES, TabbedChartGroup, TabbedTableGroup, TableExportButton, TableWithExport, ThemeProvider, Toast, ToastContainer, TouchContextMenu, Turn, TurnBubble, MemoizedTypingIndicator as TypingIndicator, MemoizedUserAvatar as UserAvatar, MemoizedUserFilter as UserFilter, UserMessage, UserTurnView, WelcomeContent, addCSRFHeader, backdropVariants, buttonVariants, convertToBase64, createDataUrl, createHeadersWithCSRF, createHttpDataSource, darkTheme, dropdownVariants, errorMessageVariants, fadeInUpVariants, fadeInVariants, floatingButtonVariants, formatFileSize, getCSRFToken, getFileVisual, getToolLabel, getValidChildren, groupSessionsByDate, groupSteps, hasPermission, isImageMimeType, isPermissionDeniedError, isTerminalEvent, lightTheme, listItemVariants, messageContainerVariants, messageVariants, parseBichatStream, parseBichatStreamEvents, parseSSEStream, readTextBlockOffsets, scaleFadeVariants, sessionItemVariants, splitIntoTextBlocks, staggerContainerVariants, toErrorDisplay, typingDotVariants, useActionButtonContext, useActiveRuns, useAttachments, useAutoScroll, useAvatarContext, useBichatRouter, useBubbleContext, useChatInput, useChatMessaging, useChatSession, useConfig, useDataTable, useFocusTrap, useHttpDataSourceConfigFromApplet, useImageGallery, useIotaContext, useKeyboardShortcuts, useLongPress, useMarkdownCopy, useMessageActions, useModalLock, useOptionalChatMessaging, useRequiredConfig, useScrollToBottom, useSidebarState, useStreaming2 as useStreaming, useTheme, useToast, useTranslation, useTurnContext, validateAttachmentFile, validateFileCount, validateImageFile, verbTransitionVariants };
|
|
19930
20319
|
//# sourceMappingURL=index.mjs.map
|
|
19931
20320
|
//# sourceMappingURL=index.mjs.map
|