@helpai/elements 0.59.0 → 0.59.2
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/elements-web-component.esm.js +19 -19
- package/elements-web-component.esm.js.map +3 -3
- package/elements.cjs.js +19 -19
- package/elements.cjs.js.map +3 -3
- package/elements.esm.js +19 -19
- package/elements.esm.js.map +3 -3
- package/elements.js +19 -19
- package/elements.js.map +3 -3
- package/index.d.ts +1 -1
- package/index.mjs +43 -20
- package/package.json +1 -1
- package/schema.d.ts +26 -26
- package/web-component.mjs +43 -20
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, H as HandshakeResponse, L as Link, S as ServerConfig, b as SiteConfig, W as WidgetConfig, c as WidgetConfigPartial, d as WidgetSettings, e as WidgetSettingsPartial } from './deployment-
|
|
1
|
+
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, H as HandshakeResponse, L as Link, S as ServerConfig, b as SiteConfig, W as WidgetConfig, c as WidgetConfigPartial, d as WidgetSettings, e as WidgetSettingsPartial } from './deployment-BAOjO2dQ.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
package/index.mjs
CHANGED
|
@@ -29,7 +29,7 @@ var BRAND = {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// src/core/version.ts
|
|
32
|
-
var ELEMENTS_VERSION = true ? "0.59.
|
|
32
|
+
var ELEMENTS_VERSION = true ? "0.59.2" : "0.0.0-dev";
|
|
33
33
|
var ELEMENTS_VERSION_PARAM = "_ev";
|
|
34
34
|
|
|
35
35
|
// src/i18n/strings.ts
|
|
@@ -2149,6 +2149,22 @@ var DEFAULT_PATHS = {
|
|
|
2149
2149
|
submitForm: "/pai/submit-form"
|
|
2150
2150
|
};
|
|
2151
2151
|
var CONTEXT_PARAM = "context";
|
|
2152
|
+
function parseSuggestions(data) {
|
|
2153
|
+
const raw = data?.suggestions;
|
|
2154
|
+
if (!Array.isArray(raw)) return [];
|
|
2155
|
+
const out = [];
|
|
2156
|
+
for (const item of raw) {
|
|
2157
|
+
if (!item || typeof item !== "object") continue;
|
|
2158
|
+
const { id, label, text } = item;
|
|
2159
|
+
if (typeof label !== "string" || !label) continue;
|
|
2160
|
+
out.push({
|
|
2161
|
+
id: typeof id === "string" && id ? id : `s${out.length}`,
|
|
2162
|
+
label,
|
|
2163
|
+
text: typeof text === "string" && text ? text : label
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
return out;
|
|
2167
|
+
}
|
|
2152
2168
|
function buildSendMessageRequest(params) {
|
|
2153
2169
|
const wire = params.messages.map((m) => ({
|
|
2154
2170
|
// Use the backend's id when known (adopted from the stream's `start` chunk)
|
|
@@ -2226,6 +2242,7 @@ function messageToWireParts(m) {
|
|
|
2226
2242
|
var log6 = logger.scope("transport");
|
|
2227
2243
|
var MAX_RESUME_ATTEMPTS = 3;
|
|
2228
2244
|
var RESUME_BACKOFF_MS = 400;
|
|
2245
|
+
var POST_FINISH_DRAIN_MS = 5e3;
|
|
2229
2246
|
var CONTENT_CACHE_TTL_MS = 6e4;
|
|
2230
2247
|
var CONVERSATIONS_CACHE_TTL_MS = 1e4;
|
|
2231
2248
|
var MAX_REQUEST_RETRIES = 3;
|
|
@@ -2240,6 +2257,15 @@ function retryAfterMs(headers) {
|
|
|
2240
2257
|
const ms = Number.isFinite(secs) ? secs * 1e3 : Date.parse(raw) - Date.now();
|
|
2241
2258
|
return Number.isFinite(ms) && ms >= 0 ? Math.min(ms, 3e4) : null;
|
|
2242
2259
|
}
|
|
2260
|
+
function followupsFromMessages(messages) {
|
|
2261
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
2262
|
+
const m = messages[i];
|
|
2263
|
+
if (!m || m.role !== "assistant") continue;
|
|
2264
|
+
const part = m.parts.find((p36) => p36.type === "data-suggestions");
|
|
2265
|
+
return part?.type === "data-suggestions" ? parseSuggestions(part.data) : void 0;
|
|
2266
|
+
}
|
|
2267
|
+
return void 0;
|
|
2268
|
+
}
|
|
2243
2269
|
function sleep(ms, signal7) {
|
|
2244
2270
|
return new Promise((resolve) => {
|
|
2245
2271
|
if (signal7?.aborted) return resolve();
|
|
@@ -2486,7 +2512,10 @@ var AgentTransport = class {
|
|
|
2486
2512
|
canContinue: res.canContinue ?? true,
|
|
2487
2513
|
messages,
|
|
2488
2514
|
agent: res.agent,
|
|
2489
|
-
|
|
2515
|
+
// The latest turn's model follow-ups are persisted ON the assistant message (a `data-suggestions`
|
|
2516
|
+
// part), not in a top-level field — read them off there, falling back to any server-provided
|
|
2517
|
+
// top-level `suggestions` (e.g. resume chips) when the last turn carried none.
|
|
2518
|
+
suggestions: followupsFromMessages(messages) ?? res.suggestions
|
|
2490
2519
|
};
|
|
2491
2520
|
}
|
|
2492
2521
|
/**
|
|
@@ -2726,6 +2755,8 @@ var AgentTransport = class {
|
|
|
2726
2755
|
* (a drop), so the caller can attempt a resume.
|
|
2727
2756
|
*/
|
|
2728
2757
|
async *drain(source, seenIds, ctrl) {
|
|
2758
|
+
let terminal = false;
|
|
2759
|
+
let watchdog;
|
|
2729
2760
|
try {
|
|
2730
2761
|
for await (const evt of source) {
|
|
2731
2762
|
if (ctrl.signal.aborted) return true;
|
|
@@ -2734,14 +2765,19 @@ var AgentTransport = class {
|
|
|
2734
2765
|
seenIds.add(evt.eventId);
|
|
2735
2766
|
}
|
|
2736
2767
|
yield evt;
|
|
2737
|
-
if (evt.chunk.type === "finish" || evt.chunk.type === "error")
|
|
2768
|
+
if (evt.chunk.type === "finish" || evt.chunk.type === "error") {
|
|
2769
|
+
terminal = true;
|
|
2770
|
+
watchdog ?? (watchdog = setTimeout(() => ctrl.abort(), POST_FINISH_DRAIN_MS));
|
|
2771
|
+
}
|
|
2738
2772
|
}
|
|
2739
2773
|
} catch (err) {
|
|
2740
2774
|
if (ctrl.signal.aborted) return true;
|
|
2741
2775
|
if (err instanceof StreamError && err.status !== void 0) throw err;
|
|
2742
2776
|
log6.debug("stream segment dropped", { err });
|
|
2777
|
+
} finally {
|
|
2778
|
+
if (watchdog) clearTimeout(watchdog);
|
|
2743
2779
|
}
|
|
2744
|
-
return
|
|
2780
|
+
return terminal;
|
|
2745
2781
|
}
|
|
2746
2782
|
/** Abort + fire-and-forget POST to `/pai/cancel-stream`. Idempotent. */
|
|
2747
2783
|
cancelStream(ctrl, conversationId) {
|
|
@@ -2969,6 +3005,9 @@ function fromWireMessage(w) {
|
|
|
2969
3005
|
mediaType: part.mediaType
|
|
2970
3006
|
};
|
|
2971
3007
|
}
|
|
3008
|
+
if (part.type === "data-suggestions") {
|
|
3009
|
+
return null;
|
|
3010
|
+
}
|
|
2972
3011
|
if (part.type.startsWith("tool-")) {
|
|
2973
3012
|
return {
|
|
2974
3013
|
kind: "tool",
|
|
@@ -6840,22 +6879,6 @@ function ConversationList({
|
|
|
6840
6879
|
// src/ui/suggestions.tsx
|
|
6841
6880
|
import { jsx as jsx22 } from "preact/jsx-runtime";
|
|
6842
6881
|
var p19 = BRAND.cssPrefix;
|
|
6843
|
-
function parseSuggestions(data) {
|
|
6844
|
-
const raw = data?.suggestions;
|
|
6845
|
-
if (!Array.isArray(raw)) return [];
|
|
6846
|
-
const out = [];
|
|
6847
|
-
for (const item of raw) {
|
|
6848
|
-
if (!item || typeof item !== "object") continue;
|
|
6849
|
-
const { id, label, text } = item;
|
|
6850
|
-
if (typeof label !== "string" || !label) continue;
|
|
6851
|
-
out.push({
|
|
6852
|
-
id: typeof id === "string" && id ? id : `s${out.length}`,
|
|
6853
|
-
label,
|
|
6854
|
-
text: typeof text === "string" && text ? text : label
|
|
6855
|
-
});
|
|
6856
|
-
}
|
|
6857
|
-
return out;
|
|
6858
|
-
}
|
|
6859
6882
|
function Suggestions({ suggestions, onPick }) {
|
|
6860
6883
|
if (suggestions.length === 0) return null;
|
|
6861
6884
|
return /* @__PURE__ */ jsx22("div", { class: `${p19}-suggestions`, role: "group", "aria-label": "Suggested replies", children: suggestions.map((s, i) => /* @__PURE__ */ jsx22(
|
package/package.json
CHANGED
package/schema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, E as Endpoints, H as HandshakeResponse, L as Link, P as PAGE_AREA_SUGGESTIONS, f as PageContext, S as ServerConfig, b as SiteConfig, U as UserContext, W as WidgetConfig, c as WidgetConfigPartial, d as WidgetSettings, e as WidgetSettingsPartial, g as assetSchema, h as blocksConfigSchema, i as connectionConfigPartialSchema, j as connectionConfigSchema, k as cssColorSchema, l as cssLengthSchema, m as endpointsSchema, n as handshakeResponseSchema, o as linkSchema, p as localeSchema, q as pageContextSchema, s as serverConfigSchema, r as siteConfigSchema, u as userContextSchema, t as uuid7Schema, w as widgetConfigPartialSchema, v as widgetConfigSchema, x as widgetSettingsPartialSchema, y as widgetSettingsSchema } from './deployment-
|
|
1
|
+
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, E as Endpoints, H as HandshakeResponse, L as Link, P as PAGE_AREA_SUGGESTIONS, f as PageContext, S as ServerConfig, b as SiteConfig, U as UserContext, W as WidgetConfig, c as WidgetConfigPartial, d as WidgetSettings, e as WidgetSettingsPartial, g as assetSchema, h as blocksConfigSchema, i as connectionConfigPartialSchema, j as connectionConfigSchema, k as cssColorSchema, l as cssLengthSchema, m as endpointsSchema, n as handshakeResponseSchema, o as linkSchema, p as localeSchema, q as pageContextSchema, s as serverConfigSchema, r as siteConfigSchema, u as userContextSchema, t as uuid7Schema, w as widgetConfigPartialSchema, v as widgetConfigSchema, x as widgetSettingsPartialSchema, y as widgetSettingsSchema } from './deployment-BAOjO2dQ.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -56,9 +56,9 @@ declare const presentationSchema: z.ZodObject<{
|
|
|
56
56
|
inset: z.ZodOptional<z.ZodString>;
|
|
57
57
|
initialSize: z.ZodDefault<z.ZodEnum<{
|
|
58
58
|
fullscreen: "fullscreen";
|
|
59
|
+
normal: "normal";
|
|
59
60
|
expanded: "expanded";
|
|
60
61
|
auto: "auto";
|
|
61
|
-
normal: "normal";
|
|
62
62
|
}>>;
|
|
63
63
|
autoSizeBreakpoint: z.ZodDefault<z.ZodNumber>;
|
|
64
64
|
}, z.core.$loose>>;
|
|
@@ -242,9 +242,9 @@ type LauncherOptions = z.infer<typeof launcherOptionsSchema>;
|
|
|
242
242
|
|
|
243
243
|
declare const initialSizeSchema: z.ZodEnum<{
|
|
244
244
|
fullscreen: "fullscreen";
|
|
245
|
+
normal: "normal";
|
|
245
246
|
expanded: "expanded";
|
|
246
247
|
auto: "auto";
|
|
247
|
-
normal: "normal";
|
|
248
248
|
}>;
|
|
249
249
|
declare const resizeOptionsSchema: z.ZodObject<{
|
|
250
250
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -271,9 +271,9 @@ declare const sizeOptionsSchema: z.ZodObject<{
|
|
|
271
271
|
inset: z.ZodOptional<z.ZodString>;
|
|
272
272
|
initialSize: z.ZodDefault<z.ZodEnum<{
|
|
273
273
|
fullscreen: "fullscreen";
|
|
274
|
+
normal: "normal";
|
|
274
275
|
expanded: "expanded";
|
|
275
276
|
auto: "auto";
|
|
276
|
-
normal: "normal";
|
|
277
277
|
}>>;
|
|
278
278
|
autoSizeBreakpoint: z.ZodDefault<z.ZodNumber>;
|
|
279
279
|
}, z.core.$loose>;
|
|
@@ -325,40 +325,40 @@ type FeatureFlags = z.infer<typeof featureFlagsSchema>;
|
|
|
325
325
|
*/
|
|
326
326
|
|
|
327
327
|
declare const actionNameSchema: z.ZodEnum<{
|
|
328
|
-
close: "close";
|
|
329
328
|
expand: "expand";
|
|
330
329
|
fullscreen: "fullscreen";
|
|
331
|
-
|
|
332
|
-
theme: "theme";
|
|
330
|
+
close: "close";
|
|
333
331
|
language: "language";
|
|
332
|
+
theme: "theme";
|
|
334
333
|
textSize: "textSize";
|
|
335
334
|
history: "history";
|
|
335
|
+
clear: "clear";
|
|
336
336
|
sound: "sound";
|
|
337
337
|
}>;
|
|
338
338
|
type ActionName = z.infer<typeof actionNameSchema>;
|
|
339
339
|
declare const headerActionsSchema: z.ZodArray<z.ZodEnum<{
|
|
340
|
-
close: "close";
|
|
341
340
|
expand: "expand";
|
|
342
341
|
fullscreen: "fullscreen";
|
|
343
|
-
|
|
344
|
-
theme: "theme";
|
|
342
|
+
close: "close";
|
|
345
343
|
language: "language";
|
|
344
|
+
theme: "theme";
|
|
346
345
|
textSize: "textSize";
|
|
347
346
|
history: "history";
|
|
347
|
+
clear: "clear";
|
|
348
348
|
sound: "sound";
|
|
349
349
|
}>>;
|
|
350
350
|
type HeaderActions = z.infer<typeof headerActionsSchema>;
|
|
351
351
|
/** Section wrapper — `actions` list wrapped under `header` in the dashboard form. */
|
|
352
352
|
declare const headerSchema: z.ZodObject<{
|
|
353
353
|
actions: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
354
|
-
close: "close";
|
|
355
354
|
expand: "expand";
|
|
356
355
|
fullscreen: "fullscreen";
|
|
357
|
-
|
|
358
|
-
theme: "theme";
|
|
356
|
+
close: "close";
|
|
359
357
|
language: "language";
|
|
358
|
+
theme: "theme";
|
|
360
359
|
textSize: "textSize";
|
|
361
360
|
history: "history";
|
|
361
|
+
clear: "clear";
|
|
362
362
|
sound: "sound";
|
|
363
363
|
}>>>;
|
|
364
364
|
}, z.core.$loose>;
|
|
@@ -374,33 +374,33 @@ type HeaderOptions = z.infer<typeof headerSchema>;
|
|
|
374
374
|
*/
|
|
375
375
|
|
|
376
376
|
declare const feedbackEventSchema: z.ZodEnum<{
|
|
377
|
-
voiceStart: "voiceStart";
|
|
378
|
-
voiceStop: "voiceStop";
|
|
379
377
|
error: "error";
|
|
380
378
|
messageReceived: "messageReceived";
|
|
381
379
|
messageSent: "messageSent";
|
|
380
|
+
voiceStart: "voiceStart";
|
|
381
|
+
voiceStop: "voiceStop";
|
|
382
382
|
}>;
|
|
383
383
|
type FeedbackEvent = z.infer<typeof feedbackEventSchema>;
|
|
384
384
|
declare const soundOptionsSchema: z.ZodObject<{
|
|
385
385
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
386
386
|
volume: z.ZodDefault<z.ZodNumber>;
|
|
387
387
|
events: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
388
|
-
voiceStart: "voiceStart";
|
|
389
|
-
voiceStop: "voiceStop";
|
|
390
388
|
error: "error";
|
|
391
389
|
messageReceived: "messageReceived";
|
|
392
390
|
messageSent: "messageSent";
|
|
391
|
+
voiceStart: "voiceStart";
|
|
392
|
+
voiceStop: "voiceStop";
|
|
393
393
|
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>>;
|
|
394
394
|
}, z.core.$loose>;
|
|
395
395
|
type SoundOptions = z.infer<typeof soundOptionsSchema>;
|
|
396
396
|
declare const hapticsOptionsSchema: z.ZodObject<{
|
|
397
397
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
398
398
|
events: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
399
|
-
voiceStart: "voiceStart";
|
|
400
|
-
voiceStop: "voiceStop";
|
|
401
399
|
error: "error";
|
|
402
400
|
messageReceived: "messageReceived";
|
|
403
401
|
messageSent: "messageSent";
|
|
402
|
+
voiceStart: "voiceStart";
|
|
403
|
+
voiceStop: "voiceStop";
|
|
404
404
|
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodArray<z.ZodNumber>]>>>;
|
|
405
405
|
}, z.core.$loose>;
|
|
406
406
|
type HapticsOptions = z.infer<typeof hapticsOptionsSchema>;
|
|
@@ -409,21 +409,21 @@ declare const feedbackSchema: z.ZodObject<{
|
|
|
409
409
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
410
410
|
volume: z.ZodDefault<z.ZodNumber>;
|
|
411
411
|
events: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
412
|
-
voiceStart: "voiceStart";
|
|
413
|
-
voiceStop: "voiceStop";
|
|
414
412
|
error: "error";
|
|
415
413
|
messageReceived: "messageReceived";
|
|
416
414
|
messageSent: "messageSent";
|
|
415
|
+
voiceStart: "voiceStart";
|
|
416
|
+
voiceStop: "voiceStop";
|
|
417
417
|
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>>;
|
|
418
418
|
}, z.core.$loose>>;
|
|
419
419
|
haptics: z.ZodOptional<z.ZodObject<{
|
|
420
420
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
421
421
|
events: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
422
|
-
voiceStart: "voiceStart";
|
|
423
|
-
voiceStop: "voiceStop";
|
|
424
422
|
error: "error";
|
|
425
423
|
messageReceived: "messageReceived";
|
|
426
424
|
messageSent: "messageSent";
|
|
425
|
+
voiceStart: "voiceStart";
|
|
426
|
+
voiceStop: "voiceStop";
|
|
427
427
|
}> & z.core.$partial, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodArray<z.ZodNumber>]>>>;
|
|
428
428
|
}, z.core.$loose>>;
|
|
429
429
|
}, z.core.$loose>;
|
|
@@ -858,18 +858,18 @@ type I18nOptions = z.infer<typeof i18nSchema>;
|
|
|
858
858
|
*/
|
|
859
859
|
|
|
860
860
|
declare const moduleLayoutSchema: z.ZodEnum<{
|
|
861
|
-
home: "home";
|
|
862
861
|
chat: "chat";
|
|
863
862
|
help: "help";
|
|
863
|
+
home: "home";
|
|
864
864
|
news: "news";
|
|
865
865
|
}>;
|
|
866
866
|
type ModuleLayout = z.infer<typeof moduleLayoutSchema>;
|
|
867
867
|
declare const moduleSchema: z.ZodObject<{
|
|
868
868
|
label: z.ZodString;
|
|
869
869
|
layout: z.ZodEnum<{
|
|
870
|
-
home: "home";
|
|
871
870
|
chat: "chat";
|
|
872
871
|
help: "help";
|
|
872
|
+
home: "home";
|
|
873
873
|
news: "news";
|
|
874
874
|
}>;
|
|
875
875
|
contentTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -895,9 +895,9 @@ type ModuleOptions = z.infer<typeof moduleSchema>;
|
|
|
895
895
|
declare const modulesSchema: z.ZodArray<z.ZodObject<{
|
|
896
896
|
label: z.ZodString;
|
|
897
897
|
layout: z.ZodEnum<{
|
|
898
|
-
home: "home";
|
|
899
898
|
chat: "chat";
|
|
900
899
|
help: "help";
|
|
900
|
+
home: "home";
|
|
901
901
|
news: "news";
|
|
902
902
|
}>;
|
|
903
903
|
contentTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
package/web-component.mjs
CHANGED
|
@@ -1934,7 +1934,7 @@ function createAuth(opts) {
|
|
|
1934
1934
|
}
|
|
1935
1935
|
|
|
1936
1936
|
// src/core/version.ts
|
|
1937
|
-
var ELEMENTS_VERSION = true ? "0.59.
|
|
1937
|
+
var ELEMENTS_VERSION = true ? "0.59.2" : "0.0.0-dev";
|
|
1938
1938
|
var ELEMENTS_VERSION_PARAM = "_ev";
|
|
1939
1939
|
|
|
1940
1940
|
// src/stream/types.ts
|
|
@@ -2108,6 +2108,22 @@ var DEFAULT_PATHS = {
|
|
|
2108
2108
|
submitForm: "/pai/submit-form"
|
|
2109
2109
|
};
|
|
2110
2110
|
var CONTEXT_PARAM = "context";
|
|
2111
|
+
function parseSuggestions(data) {
|
|
2112
|
+
const raw = data?.suggestions;
|
|
2113
|
+
if (!Array.isArray(raw)) return [];
|
|
2114
|
+
const out = [];
|
|
2115
|
+
for (const item of raw) {
|
|
2116
|
+
if (!item || typeof item !== "object") continue;
|
|
2117
|
+
const { id, label, text } = item;
|
|
2118
|
+
if (typeof label !== "string" || !label) continue;
|
|
2119
|
+
out.push({
|
|
2120
|
+
id: typeof id === "string" && id ? id : `s${out.length}`,
|
|
2121
|
+
label,
|
|
2122
|
+
text: typeof text === "string" && text ? text : label
|
|
2123
|
+
});
|
|
2124
|
+
}
|
|
2125
|
+
return out;
|
|
2126
|
+
}
|
|
2111
2127
|
function buildSendMessageRequest(params) {
|
|
2112
2128
|
const wire = params.messages.map((m) => ({
|
|
2113
2129
|
// Use the backend's id when known (adopted from the stream's `start` chunk)
|
|
@@ -2185,6 +2201,7 @@ function messageToWireParts(m) {
|
|
|
2185
2201
|
var log5 = logger.scope("transport");
|
|
2186
2202
|
var MAX_RESUME_ATTEMPTS = 3;
|
|
2187
2203
|
var RESUME_BACKOFF_MS = 400;
|
|
2204
|
+
var POST_FINISH_DRAIN_MS = 5e3;
|
|
2188
2205
|
var CONTENT_CACHE_TTL_MS = 6e4;
|
|
2189
2206
|
var CONVERSATIONS_CACHE_TTL_MS = 1e4;
|
|
2190
2207
|
var MAX_REQUEST_RETRIES = 3;
|
|
@@ -2199,6 +2216,15 @@ function retryAfterMs(headers) {
|
|
|
2199
2216
|
const ms = Number.isFinite(secs) ? secs * 1e3 : Date.parse(raw) - Date.now();
|
|
2200
2217
|
return Number.isFinite(ms) && ms >= 0 ? Math.min(ms, 3e4) : null;
|
|
2201
2218
|
}
|
|
2219
|
+
function followupsFromMessages(messages) {
|
|
2220
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
2221
|
+
const m = messages[i];
|
|
2222
|
+
if (!m || m.role !== "assistant") continue;
|
|
2223
|
+
const part = m.parts.find((p36) => p36.type === "data-suggestions");
|
|
2224
|
+
return part?.type === "data-suggestions" ? parseSuggestions(part.data) : void 0;
|
|
2225
|
+
}
|
|
2226
|
+
return void 0;
|
|
2227
|
+
}
|
|
2202
2228
|
function sleep(ms, signal7) {
|
|
2203
2229
|
return new Promise((resolve) => {
|
|
2204
2230
|
if (signal7?.aborted) return resolve();
|
|
@@ -2445,7 +2471,10 @@ var AgentTransport = class {
|
|
|
2445
2471
|
canContinue: res.canContinue ?? true,
|
|
2446
2472
|
messages,
|
|
2447
2473
|
agent: res.agent,
|
|
2448
|
-
|
|
2474
|
+
// The latest turn's model follow-ups are persisted ON the assistant message (a `data-suggestions`
|
|
2475
|
+
// part), not in a top-level field — read them off there, falling back to any server-provided
|
|
2476
|
+
// top-level `suggestions` (e.g. resume chips) when the last turn carried none.
|
|
2477
|
+
suggestions: followupsFromMessages(messages) ?? res.suggestions
|
|
2449
2478
|
};
|
|
2450
2479
|
}
|
|
2451
2480
|
/**
|
|
@@ -2685,6 +2714,8 @@ var AgentTransport = class {
|
|
|
2685
2714
|
* (a drop), so the caller can attempt a resume.
|
|
2686
2715
|
*/
|
|
2687
2716
|
async *drain(source, seenIds, ctrl) {
|
|
2717
|
+
let terminal = false;
|
|
2718
|
+
let watchdog;
|
|
2688
2719
|
try {
|
|
2689
2720
|
for await (const evt of source) {
|
|
2690
2721
|
if (ctrl.signal.aborted) return true;
|
|
@@ -2693,14 +2724,19 @@ var AgentTransport = class {
|
|
|
2693
2724
|
seenIds.add(evt.eventId);
|
|
2694
2725
|
}
|
|
2695
2726
|
yield evt;
|
|
2696
|
-
if (evt.chunk.type === "finish" || evt.chunk.type === "error")
|
|
2727
|
+
if (evt.chunk.type === "finish" || evt.chunk.type === "error") {
|
|
2728
|
+
terminal = true;
|
|
2729
|
+
watchdog ?? (watchdog = setTimeout(() => ctrl.abort(), POST_FINISH_DRAIN_MS));
|
|
2730
|
+
}
|
|
2697
2731
|
}
|
|
2698
2732
|
} catch (err) {
|
|
2699
2733
|
if (ctrl.signal.aborted) return true;
|
|
2700
2734
|
if (err instanceof StreamError && err.status !== void 0) throw err;
|
|
2701
2735
|
log5.debug("stream segment dropped", { err });
|
|
2736
|
+
} finally {
|
|
2737
|
+
if (watchdog) clearTimeout(watchdog);
|
|
2702
2738
|
}
|
|
2703
|
-
return
|
|
2739
|
+
return terminal;
|
|
2704
2740
|
}
|
|
2705
2741
|
/** Abort + fire-and-forget POST to `/pai/cancel-stream`. Idempotent. */
|
|
2706
2742
|
cancelStream(ctrl, conversationId) {
|
|
@@ -2928,6 +2964,9 @@ function fromWireMessage(w) {
|
|
|
2928
2964
|
mediaType: part.mediaType
|
|
2929
2965
|
};
|
|
2930
2966
|
}
|
|
2967
|
+
if (part.type === "data-suggestions") {
|
|
2968
|
+
return null;
|
|
2969
|
+
}
|
|
2931
2970
|
if (part.type.startsWith("tool-")) {
|
|
2932
2971
|
return {
|
|
2933
2972
|
kind: "tool",
|
|
@@ -6799,22 +6838,6 @@ function ConversationList({
|
|
|
6799
6838
|
// src/ui/suggestions.tsx
|
|
6800
6839
|
import { jsx as jsx22 } from "preact/jsx-runtime";
|
|
6801
6840
|
var p19 = BRAND.cssPrefix;
|
|
6802
|
-
function parseSuggestions(data) {
|
|
6803
|
-
const raw = data?.suggestions;
|
|
6804
|
-
if (!Array.isArray(raw)) return [];
|
|
6805
|
-
const out = [];
|
|
6806
|
-
for (const item of raw) {
|
|
6807
|
-
if (!item || typeof item !== "object") continue;
|
|
6808
|
-
const { id, label, text } = item;
|
|
6809
|
-
if (typeof label !== "string" || !label) continue;
|
|
6810
|
-
out.push({
|
|
6811
|
-
id: typeof id === "string" && id ? id : `s${out.length}`,
|
|
6812
|
-
label,
|
|
6813
|
-
text: typeof text === "string" && text ? text : label
|
|
6814
|
-
});
|
|
6815
|
-
}
|
|
6816
|
-
return out;
|
|
6817
|
-
}
|
|
6818
6841
|
function Suggestions({ suggestions, onPick }) {
|
|
6819
6842
|
if (suggestions.length === 0) return null;
|
|
6820
6843
|
return /* @__PURE__ */ jsx22("div", { class: `${p19}-suggestions`, role: "group", "aria-label": "Suggested replies", children: suggestions.map((s, i) => /* @__PURE__ */ jsx22(
|