@streamoid/agent 0.6.25 → 0.6.27

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/index.d.ts CHANGED
@@ -197,11 +197,44 @@ export interface ConversationSearchDialogProps {
197
197
  }
198
198
 
199
199
  /** "Search or Ask CXO" — the command dialog a host opens from its sidebar's
200
- * search trigger, identical in every product. */
200
+ * search trigger, identical in every product. The presentation only; see
201
+ * {@link AskCxoDialog} for the same thing with the host wiring done. */
201
202
  export declare function ConversationSearchDialog(
202
203
  props: ConversationSearchDialogProps,
203
204
  ): ReactElement;
204
205
 
206
+ export interface AskCxoDialogProps
207
+ extends Pick<
208
+ ConversationSearchDialogProps,
209
+ | 'workspaceId'
210
+ | 'search'
211
+ | 'onClose'
212
+ | 'placeholder'
213
+ | 'emptyStateTitle'
214
+ | 'emptyStateDescription'
215
+ > {
216
+ /** Show the chat panel. `chatId` is the conversation the user picked out of
217
+ * the results, or `null` when they asked something new — hand that `null`
218
+ * straight to the panel's `chatId` and let the chat create the conversation
219
+ * itself. */
220
+ onOpenChat(chatId: string | null): void;
221
+ /** Drop the Ask row and Enter-to-ask, leaving a plain conversation search. */
222
+ searchOnly?: boolean;
223
+ }
224
+
225
+ /**
226
+ * "Search or Ask CXO", wired the fast way — PREFER THIS over
227
+ * {@link ConversationSearchDialog}.
228
+ *
229
+ * Both hosts that wired `onAsk` by hand got it wrong the same two ways: they
230
+ * awaited the send before opening the panel (2.655s of nothing, measured on
231
+ * artifax.test) and then handed the panel a conversation id the server had not
232
+ * seen, which costs another spinner and a `/messages` fetch that returns
233
+ * nothing. This asks for one callback — "show the chat, on this conversation or
234
+ * on nothing" — and does the rest. Nothing in it touches the network.
235
+ */
236
+ export declare function AskCxoDialog(props: AskCxoDialogProps): ReactElement;
237
+
205
238
  /** Input for {@link startConversation}. */
206
239
  export interface StartConversationInput {
207
240
  workspaceId: string;
@@ -209,19 +242,30 @@ export interface StartConversationInput {
209
242
  email: string;
210
243
  /** The user's first message. Trimmed; empty is rejected. */
211
244
  prompt: string;
245
+ /** The background send failed. Nothing waits for it, so this is the only way
246
+ * to hear about a message that never reached the server. */
247
+ onSendFailed?(error: unknown): void;
212
248
  }
213
249
 
214
250
  /**
215
- * Start a NEW conversation from a first message and return its id — for a host
216
- * that has a question but no chat open yet (the dialog's Ask row). Hand the id
217
- * back to the panel through `adapters.chatId`.
251
+ * Start a NEW conversation from a first message and return its id.
252
+ *
253
+ * @deprecated Use {@link AskCxoDialog}, or {@link enqueueChatPrompt} directly.
254
+ * The id this returns is for a conversation the SERVER HAS NOT SEEN YET, and a
255
+ * host that passes it to the panel lands on the panel's "open an existing
256
+ * conversation" path: blank transcript, full-column spinner, and a `/messages`
257
+ * fetch for a conversation that has none — 714ms of it on artifax.test.
258
+ *
259
+ * It also no longer waits for the send. It used to await the POST before
260
+ * resolving, which bought a full round trip (2.655s, measured) for an id
261
+ * generated client-side on the line above. So the returned id is no longer a
262
+ * receipt: it means "this is the conversation your message is on its way to".
263
+ * `null` still means the inputs were incomplete and nothing was sent; a
264
+ * rejection is reported through `onSendFailed`.
218
265
  *
219
266
  * Delegates to the same send path the chat itself uses, so `enc_token`,
220
267
  * `color_mode` and `host_context` are filled in from inside the bundle; a host
221
268
  * cannot see those and should not try to send them itself.
222
- *
223
- * Resolves `null` when the inputs are incomplete or the send fails, so a caller
224
- * can show "could not start this chat" without unpacking an error.
225
269
  */
226
270
  export declare function startConversation(
227
271
  input: StartConversationInput,
package/dist/index.js CHANGED
@@ -133695,7 +133695,7 @@ function MoreBriefsBrowser({
133695
133695
  {
133696
133696
  text: "Edit",
133697
133697
  variant: "default",
133698
- icon: /* @__PURE__ */ jsx(SiconPencil, { className: "size-4", style: { color: "var(--alias-text-and-icons-primary)" } }),
133698
+ icon: /* @__PURE__ */ jsx(SiconPencil, { className: "size-4", style: { color: "var(--alias-text---icons-primary, var(--alias-text-and-icons-primary))" } }),
133699
133699
  onClick: () => kt(an)
133700
133700
  }
133701
133701
  ),
@@ -133704,7 +133704,7 @@ function MoreBriefsBrowser({
133704
133704
  {
133705
133705
  text: "Delete",
133706
133706
  variant: "error",
133707
- icon: /* @__PURE__ */ jsx(SiconTrash2, { className: "size-4", style: { color: "var(--alias-text-and-icons-error)" } }),
133707
+ icon: /* @__PURE__ */ jsx(SiconTrash2, { className: "size-4", style: { color: "var(--alias-text---icons-error, var(--alias-text-and-icons-error))" } }),
133708
133708
  onClick: () => Ke(an.quick_prompt_id)
133709
133709
  }
133710
133710
  )
@@ -137386,32 +137386,65 @@ function ConversationSearchDialog({
137386
137386
  }
137387
137387
  );
137388
137388
  }
137389
+ function AskCxoDialog({
137390
+ onOpenChat: e,
137391
+ onClose: t,
137392
+ searchOnly: n = !1,
137393
+ placeholder: o = "Search or Ask CXO",
137394
+ emptyStateTitle: s = "Search or start a chat",
137395
+ emptyStateDescription: l = "Type to search existing conversations, or press Enter to ask CXO.",
137396
+ ...c
137397
+ }) {
137398
+ const f = useCallback(
137399
+ (g) => {
137400
+ e(null), enqueueChatPrompt({ prompt: g, forceNewConversation: !0 });
137401
+ },
137402
+ [e]
137403
+ ), h = useCallback(
137404
+ (g) => {
137405
+ e(g.conversation_id), t();
137406
+ },
137407
+ [e, t]
137408
+ );
137409
+ return /* @__PURE__ */ jsx(
137410
+ ConversationSearchDialog,
137411
+ {
137412
+ ...c,
137413
+ onClose: t,
137414
+ onSelectResult: h,
137415
+ onAsk: n ? void 0 : f,
137416
+ placeholder: o,
137417
+ emptyStateTitle: s,
137418
+ emptyStateDescription: l
137419
+ }
137420
+ );
137421
+ }
137389
137422
  async function startConversation({
137390
137423
  workspaceId: e,
137391
137424
  userId: t,
137392
137425
  email: n,
137393
- prompt: o
137426
+ prompt: o,
137427
+ onSendFailed: s
137394
137428
  }) {
137395
- const s = o.trim();
137396
- if (!e || !t || !n || !s) return null;
137397
- const l = uuidv7();
137398
- try {
137399
- return await sendMessageToAgent(
137400
- e,
137401
- t,
137402
- n,
137403
- l,
137404
- s,
137405
- !1,
137406
- { clientMessageId: uuidv7() }
137407
- ), l;
137408
- } catch {
137409
- return null;
137410
- }
137429
+ const l = o.trim();
137430
+ if (!e || !t || !n || !l) return null;
137431
+ const c = uuidv7();
137432
+ return sendMessageToAgent(
137433
+ e,
137434
+ t,
137435
+ n,
137436
+ c,
137437
+ l,
137438
+ !1,
137439
+ { clientMessageId: uuidv7() }
137440
+ ).catch((f) => {
137441
+ s?.(f);
137442
+ }), c;
137411
137443
  }
137412
137444
  export {
137413
137445
  AgentChatShell,
137414
137446
  AgentPanel,
137447
+ AskCxoDialog,
137415
137448
  ConversationSearchDialog,
137416
137449
  enqueueChatPrompt,
137417
137450
  startConversation