@jini-ai/chat 0.6.22 → 0.7.0

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +8 -0
  3. package/dist/core/accepted-input.d.ts +1 -1
  4. package/dist/core/accepted-input.js +5 -4
  5. package/dist/core/assistant-client/ag-ui-transport.js +9 -3
  6. package/dist/core/assistant-client/transport.js +15 -8
  7. package/dist/core/durable-projection.js +8 -1
  8. package/dist/core/durable-runs/ports.d.ts +4 -1
  9. package/dist/core/question-answer.js +2 -1
  10. package/dist/core/turn-usage.d.ts +1 -1
  11. package/dist/core/turn-usage.js +4 -5
  12. package/dist/embed-widget/browser/frontend-session-bridge.d.ts +18 -0
  13. package/dist/embed-widget/browser/frontend-session-bridge.js +27 -0
  14. package/dist/react/components/AttachmentTray.d.ts +4 -1
  15. package/dist/react/components/AttachmentTray.js +20 -5
  16. package/dist/react/components/Composer.d.ts +3 -1
  17. package/dist/react/components/Composer.js +16 -14
  18. package/dist/react/components/ComposerDiscovery.d.ts +2 -0
  19. package/dist/react/components/ComposerDiscovery.js +4 -3
  20. package/dist/react/components/ConversationList.d.ts +4 -2
  21. package/dist/react/components/ConversationList.js +16 -7
  22. package/dist/react/components/CopyMessageButton.d.ts +3 -1
  23. package/dist/react/components/CopyMessageButton.js +3 -2
  24. package/dist/react/components/FolderChips.d.ts +3 -1
  25. package/dist/react/components/FolderChips.js +8 -5
  26. package/dist/react/components/MessageList.js +1 -1
  27. package/dist/react/components/MessageRow.js +13 -6
  28. package/dist/react/components/ToolCard.js +7 -7
  29. package/dist/react/components/ToolCard.rules.d.ts +5 -0
  30. package/dist/react/components/ToolCard.rules.js +9 -2
  31. package/dist/react/components/mcp-ui-surface-state.js +11 -0
  32. package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +1 -1
  33. package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +39 -28
  34. package/dist/react/features/chat-pane/components/ChatPane.js +20 -8
  35. package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +2 -1
  36. package/dist/react/features/chat-pane/components/RuntimeDropUp.js +11 -6
  37. package/dist/react/features/chat-pane/create-frontend-request-caller.d.ts +23 -0
  38. package/dist/react/features/chat-pane/create-frontend-request-caller.js +56 -0
  39. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +2 -0
  40. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +16 -0
  41. package/dist/react/features/chat-pane/rules.d.ts +22 -1
  42. package/dist/react/features/chat-pane/rules.js +36 -10
  43. package/dist/react/features/chat-pane/styles.d.ts +1 -1
  44. package/dist/react/features/chat-pane/styles.js +32 -39
  45. package/dist/react/features/chat-pane/surface-recovery-stream.d.ts +11 -3
  46. package/dist/react/features/chat-pane/surface-recovery-stream.js +28 -18
  47. package/dist/react/features/chat-pane/types.d.ts +13 -0
  48. package/dist/react/index.d.ts +5 -2
  49. package/dist/react/index.js +2 -1
  50. package/dist/react/styles/chat-settings.css +149 -0
  51. package/dist/server/durable-runs/recover.js +43 -6
  52. package/package.json +21 -18
package/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ ## 0.7.0
2
+
3
+ ### Patch Changes
4
+
5
+ - Updated dependencies [8fe045b]
6
+ - Updated dependencies [41ff2ff]
7
+ - Updated dependencies [a266ba8]
8
+ - Updated dependencies [39cf677]
9
+ - Updated dependencies [2364f89]
10
+ - Updated dependencies [27063ef]
11
+ - Updated dependencies [6ab1d81]
12
+ - Updated dependencies [699b478]
13
+ - Updated dependencies [1cf0306]
14
+ - Updated dependencies [39cf677]
15
+ - @jini-ai/core@0.7.0
16
+ - @jini-ai/ui@0.7.0
17
+ - @jini-ai/db@0.7.0
18
+ - @jini-ai/agent-runtime@0.7.0
19
+ - @jini-ai/agentic@0.7.0
20
+ - @jini-ai/diagnostics@0.7.0
21
+ - @jini-ai/protocol@0.7.0
22
+
23
+ ## 0.6.23
24
+
25
+ - Security hardening.
26
+
1
27
  ## 0.6.22
2
28
 
3
29
  - The full CLI access notice shows once per conversation, also after replay or remount.
package/README.md CHANGED
@@ -258,3 +258,11 @@ uses the same fetch for upload and partial-upload cleanup; omission uses
258
258
  inherit the failed upload's cancellation. Upload quotas and its 30-second batch
259
259
  deadline are unchanged. Browser timeout reasons remain native; platform is no
260
260
  longer a dependency of this package.
261
+
262
+ ## Optional chat settings presentation
263
+
264
+ React hosts can import `@jini-ai/chat/react/styles/chat-settings.css` for
265
+ `ChatSettingsDialog` and `ChatSettingsSegmented`. The stylesheet includes standalone
266
+ colors, controls, keyboard focus, and bounded scrolling. Bind its
267
+ `--jini-chat-settings-*` custom properties to the host theme when needed; no
268
+ reference or host stylesheet is required for the settings presentation.
@@ -74,7 +74,7 @@ export declare function projectAcceptedInputEvents({ events }: {
74
74
  events: readonly AgentEvent[];
75
75
  }, options?: AcceptedInputProjectionOptions): AgentEvent[];
76
76
  /** The sole transcript-to-recall projection. A merged queued turn retains its original inputs.
77
- * @returns Accepted inputs once by id/alias, in send order; pending input is excluded.
77
+ * @returns Accepted inputs once by id/alias, in send order; unaccepted pending input is excluded.
78
78
  * @complexity O(m + e + i + a) time/space for messages, events, inputs and aliases; no I/O.
79
79
  * @example acceptedInputsFromMessages({ messages });
80
80
  */
@@ -275,7 +275,7 @@ function projectEvents({ events }, options) {
275
275
  return projected;
276
276
  }
277
277
  /** The sole transcript-to-recall projection. A merged queued turn retains its original inputs.
278
- * @returns Accepted inputs once by id/alias, in send order; pending input is excluded.
278
+ * @returns Accepted inputs once by id/alias, in send order; unaccepted pending input is excluded.
279
279
  * @complexity O(m + e + i + a) time/space for messages, events, inputs and aliases; no I/O.
280
280
  * @example acceptedInputsFromMessages({ messages });
281
281
  */
@@ -288,15 +288,16 @@ export function acceptedInputsFromMessages({ messages }, _options = {}) {
288
288
  * @complexity O(e + i) time/space for the message's events and expanded inputs; no effects.
289
289
  */
290
290
  function inputsFromMessage({ message }, _options = {}) {
291
- if (message.inputPending)
292
- return [];
293
291
  // Queue constituents travel in events_json, already preserved by the existing chat store.
292
+ // A confirmed queue receipt predates its later run start: that carrier may still be pending.
294
293
  const receipts = projectAcceptedInputEvents({ events: message.events ?? [] }).flatMap(event => {
295
294
  const input = acceptedInputEvent({ event });
296
- if (!input)
295
+ if (!input || (message.inputPending && input.data.optimistic))
297
296
  return [];
298
297
  return receiptInputs({ receipt: input });
299
298
  });
299
+ if (message.inputPending && receipts.length === 0)
300
+ return [];
300
301
  if (message.role !== 'user' || receipts.length > 0)
301
302
  return receipts;
302
303
  return [{ id: message.id, text: message.content, ...(message.folders ? { folders: message.folders } : {}) }];
@@ -1,10 +1,16 @@
1
1
  import { EventType } from "@ag-ui/core";
2
2
  import { createAgUiToAgentTranslationState, translateAgUiEventToAgentEvent } from "../ag-ui/entry.js";
3
- /** Only the originating attachment can authorize page execution. Read its token for every turn;
4
- * caller-supplied tool definitions never authorize or execute a transcript event. */
3
+ /** Only the originating attachment can authorize page execution. Read its token and tab for every
4
+ * turn; caller-supplied tool definitions never authorize or execute a transcript event.
5
+ * @complexity O(1) time and space.
6
+ * @overallScore 100 */
5
7
  function frontendBinding({ input }, _options = {}) {
6
8
  const token = input.context?.["frontendBindToken"];
7
- return typeof token === "string" && token.length > 0 ? { frontendBindToken: token } : {};
9
+ const tabId = input.context?.["frontendTabId"];
10
+ return {
11
+ ...(typeof token === "string" && token.length > 0 ? { frontendBindToken: token } : {}),
12
+ ...(typeof tabId === "string" && tabId.length > 0 ? { frontendTabId: tabId } : {}),
13
+ };
8
14
  }
9
15
  /** Bind the official client without adding its dependency to every chat consumer. */
10
16
  export function createAgUiRunClient({ ports }, _options = {}) {
@@ -458,18 +458,25 @@ export function createAssistantTransportClient({ ports }, _options = {}) {
458
458
  * and a spread would let any future `runContext` key silently shadow it — an identity field being
459
459
  * overwritten by a UI prop is not a failure mode worth leaving open to save one line.
460
460
  *
461
- * Returns `{}` (omitting the field entirely) when absent, which is a normal state, not an error:
461
+ * The tab id accompanies the token so the host can verify the session owner before binding.
462
+ * @complexity O(1) time and space.
463
+ * @overallScore 100
464
+ * Returns `{}` (omitting the fields entirely) when absent, which is a normal state, not an error:
462
465
  * the daemon treats a run with no bind token as one with no screen to drive
463
466
  * (`agent-daemon-server.ts`).
464
467
  */
465
- function frontendBindTokenField(input) {
468
+ function frontendBindingFields(input) {
466
469
  const frontendBindToken = input.context?.["frontendBindToken"];
467
- return typeof frontendBindToken === "string" && frontendBindToken.length > 0 ? { frontendBindToken } : {};
470
+ const frontendTabId = input.context?.["frontendTabId"];
471
+ return {
472
+ ...(typeof frontendBindToken === "string" && frontendBindToken.length > 0 ? { frontendBindToken } : {}),
473
+ ...(typeof frontendTabId === "string" && frontendTabId.length > 0 ? { frontendTabId } : {}),
474
+ };
468
475
  }
469
476
  /**
470
477
  * The Local CLI picker's live model selection, from `ChatPane`'s `runContext` prop
471
478
  * (`AssistantDock.tsx`'s `resolveRunContext`). Same "read by name, not spread" reasoning as
472
- * {@link frontendBindTokenField} above, and the same "omit when absent" convention. Forwarded as an
479
+ * {@link frontendBindingFields} above, and the same "omit when absent" convention. Forwarded as an
473
480
  * opaque string — `agent-daemon-server.ts` forwards it the same way, and `AgentExecutor.run()`'s
474
481
  * def-level `buildArgs` is what decides what an absent or `'default'` value means for a given CLI
475
482
  * (`@jini-ai/agent-runtime`'s `models.ts`/`resolveModelForAgent`).
@@ -498,7 +505,7 @@ export function createAssistantTransportClient({ ports }, _options = {}) {
498
505
  * re-validated paths via `AttachmentStore.claim()`. Nothing on this side of the wire is trusted; the
499
506
  * id is inert until the daemon claims it.
500
507
  *
501
- * Returns `{}`, same convention as {@link frontendBindTokenField} above — a run with no attachments
508
+ * Returns `{}`, same convention as {@link frontendBindingFields} above — a run with no attachments
502
509
  * is the overwhelmingly common case and should not carry a key for it.
503
510
  */
504
511
  function attachmentIdsField(input) {
@@ -509,7 +516,7 @@ export function createAssistantTransportClient({ ports }, _options = {}) {
509
516
  /**
510
517
  * Opaque Agent Plugin ids (`plugin.json`'s own `name`, e.g. `"ui-ux-design"`) the operator has
511
518
  * pinned as composer chips — `AssistantDock.tsx`'s `useSelectedAgentPlugins`, threaded here via
512
- * `ChatPane`'s `runContext` prop the same way {@link frontendBindTokenField}/{@link modelField}
519
+ * `ChatPane`'s `runContext` prop the same way {@link frontendBindingFields}/{@link modelField}
513
520
  * above already are. Same "read by name, not spread" and "omit when absent" conventions as those
514
521
  * two fields: this is not the plugin's CONTENT, only a reference to it —
515
522
  * `agent-daemon-server.ts`'s `onStarted` is where a ref gets resolved against the real installed
@@ -528,7 +535,7 @@ export function createAssistantTransportClient({ ports }, _options = {}) {
528
535
  }
529
536
  /**
530
537
  * The active conversation id, from `ChatPane`'s `runContext` prop (`AssistantDock.tsx`'s
531
- * `chats.activeId`, the same `useRunContext` seam {@link frontendBindTokenField}/{@link modelField}/
538
+ * `chats.activeId`, the same `useRunContext` seam {@link frontendBindingFields}/{@link modelField}/
532
539
  * {@link pluginRefIdsField} above already ride). Lets `agent-daemon-server.ts`'s `onStarted` resume
533
540
  * this conversation's agent-CLI session across turns instead of spawning cold every time
534
541
  * (`server/inbound/assistant/agent-session-resume.ts`) — see that file's own doc. Returns `{}`, same
@@ -581,7 +588,7 @@ export function createAssistantTransportClient({ ports }, _options = {}) {
581
588
  // daemon JSON boundary. Replaying an old signal reports another paste on every later turn.
582
589
  ...(newestUserMessage({ history: input.history }, {})?.secretRedaction?.secretRedacted ? { secretRedacted: true } : {}),
583
590
  assistantMessageId: input.assistantMessageId,
584
- ...frontendBindTokenField(input),
591
+ ...frontendBindingFields(input),
585
592
  ...modelField(input),
586
593
  ...reasoningField(input),
587
594
  ...attachmentIdsField(input),
@@ -85,9 +85,16 @@ export function terminalMessageNotice({ message }, _optional = {}) {
85
85
  const notice = message.events?.filter((event) => event.kind === 'status' &&
86
86
  (event.code === 'run_terminal' || /failed|stopped|restarted|could not|not logged in|cancell?ed/i.test(event.label))).at(-1);
87
87
  if (notice?.kind === 'status')
88
- return [notice.label, notice.detail].filter(Boolean).join(' ').replace(/Send your message again to retry\.?/gi, '').trim();
88
+ return terminalStatusText({ notice, canceled: message.runStatus === 'canceled' });
89
89
  return message.runStatus === 'failed' ? 'This turn failed.' : 'Stopped.';
90
90
  }
91
+ /** Cancellation is an ordinary decision; saved process diagnostics remain available to the host.
92
+ * Keep meaningful stop/recovery explanations while hiding CLI exit metadata. O(n) notice text. */
93
+ function terminalStatusText({ notice, canceled }) {
94
+ const label = canceled && /^(?:Run )?cancell?ed[.!]?$/i.test(notice.label) ? 'Canceled.' : notice.label;
95
+ const detail = canceled && /^exit code (?:none|-?\d+), signal (?:none|SIG[A-Z0-9]+), resumable (?:yes|no)(?:[., ]|$)/i.test(notice.detail ?? '') ? undefined : notice.detail;
96
+ return [label, detail].filter(Boolean).join(' ').replace(/Send your message again to retry\.?/gi, '').trim();
97
+ }
91
98
  /** The first answer has no earlier segment to divide, even if startup was retried. Only saved
92
99
  * visible text can justify a Continued divider; the recovery marker still records the attempt. */
93
100
  export function recoveredRunEvents({ saved }, { notice = 'visible' } = {}) {
@@ -1,5 +1,5 @@
1
1
  import type { AgentEvent, ChatMessage } from "../index.js";
2
- import type { RunRef, RunSettlement } from "./run-contracts.js";
2
+ import type { RunProgress, RunRef, RunSettlement } from "./run-contracts.js";
3
3
  export interface AcceptedRunRequest {
4
4
  readonly agentId?: string;
5
5
  readonly contextRef: string;
@@ -122,6 +122,9 @@ export interface RecoveryPorts {
122
122
  run: DurableRun;
123
123
  request: AcceptedRunRequest;
124
124
  }, optional: {}) => Promise<void>;
125
+ /** Save a launch-response diagnostic without declaring the uncertain attempt dead. Uses the
126
+ * host's existing fenced ledger checkpoint; no new storage format or polling is required. */
127
+ readonly checkpoint?: (required: RunProgress, optional: {}) => Promise<boolean>;
125
128
  readonly cancelAttempt: (required: DurableRun, optional: {}) => Promise<void>;
126
129
  readonly verifyChildDead: (required: {
127
130
  pid: number;
@@ -29,7 +29,8 @@ function selectedAnswerText({ result, input }, _options = {}) {
29
29
  if (typeof result.choice === 'string')
30
30
  labels.push(optionLabel({ group: question.singleSelect ?? question, value: result.choice }));
31
31
  if (Array.isArray(result.selections)) {
32
- labels.push(...selectionLabels({ selections: result.selections, question }));
32
+ for (const label of selectionLabels({ selections: result.selections, question }))
33
+ labels.push(label);
33
34
  }
34
35
  if (labels.length > 0)
35
36
  return labels.join(', ');
@@ -40,7 +40,7 @@ export declare function turnUsage({ events }: {
40
40
  agentId?: string;
41
41
  }): UsageEvent | undefined;
42
42
  /** Derive per-turn charges and prefix totals from persisted events_json, for live and reloaded
43
- * chats alike. A single reply's duration is the message's elapsed run time, from send to finish.
43
+ * chats alike. A single reply keeps its reported duration; elapsed run time fills a missing one.
44
44
  * A message with mid-run replies also gets per-reply `segments`. O(e + m) for e events
45
45
  * and m messages; no per-row transcript scans or I/O.
46
46
  * @example conversationUsage({ messages: savedMessages }).get('assistant-2') */
@@ -113,7 +113,7 @@ function addUsage({ total, usage }, _optional = {}) {
113
113
  return next;
114
114
  }
115
115
  /** Derive per-turn charges and prefix totals from persisted events_json, for live and reloaded
116
- * chats alike. A single reply's duration is the message's elapsed run time, from send to finish.
116
+ * chats alike. A single reply keeps its reported duration; elapsed run time fills a missing one.
117
117
  * A message with mid-run replies also gets per-reply `segments`. O(e + m) for e events
118
118
  * and m messages; no per-row transcript scans or I/O.
119
119
  * @example conversationUsage({ messages: savedMessages }).get('assistant-2') */
@@ -157,11 +157,10 @@ function messageUsage({ message, sessions, totalCostUsd }, _optional = {}) {
157
157
  }
158
158
  return { usage, segments, totalCostUsd: prefixTotal };
159
159
  }
160
- /** Time one reply from the person's send (`startedAt`) to the run's end, the same way for every CLI.
161
- * A CLI's own reported duration leaves out its start-up wait (Claude Code said 42 s for a turn that took
162
- * 46.5 s from send to finish), so it is only the fallback when the timestamps are missing or invalid. */
160
+ /** Fill a single reply's missing duration from send/end timestamps. Reported CLI duration wins,
161
+ * including zero: it measures the runtime's work rather than the host's startup wait. */
163
162
  function fillRunDuration({ usage, message }, _optional = {}) {
164
- if (message.startedAt === undefined || message.endedAt === undefined)
163
+ if (usage.durationMs !== undefined || message.startedAt === undefined || message.endedAt === undefined)
165
164
  return;
166
165
  const durationMs = message.endedAt - message.startedAt;
167
166
  if (Number.isFinite(durationMs) && durationMs >= 0)
@@ -109,4 +109,22 @@ export declare function openFetchFrontendStream({ url, headers }: {
109
109
  fetch?: typeof globalThis.fetch;
110
110
  reconnectMs?: number;
111
111
  }): Pick<EventSource, 'addEventListener' | 'close'>;
112
+ export interface FrontendNavigationGuard {
113
+ noteNavigation(): void;
114
+ preparePageInput(required: {
115
+ action: ChatPaneAgentToolAction;
116
+ }): Record<string, unknown>;
117
+ onBeforeResponse(required: {
118
+ action: ChatPaneAgentToolAction;
119
+ output: unknown;
120
+ }): unknown;
121
+ }
122
+ /** Fence a protected browser effect to the exact view in which its human card was proposed.
123
+ * Hosts call noteNavigation synchronously for every navigation, including a return to an old URL.
124
+ * Internal metadata is checked and removed before the page capability's public schema sees it.
125
+ * @returns Existing bridge callbacks plus the host-owned navigation notification.
126
+ * @complexity O(input keys) time/space per prepared action; O(1) retained revision counter.
127
+ * @overallScore 100
128
+ */
129
+ export declare function createFrontendNavigationGuard(_required: Record<string, never>, _optional?: Record<string, never>): FrontendNavigationGuard;
112
130
  //# sourceMappingURL=frontend-session-bridge.d.ts.map
@@ -454,4 +454,31 @@ async function assertFrontendResponse({ response, invocationId, body, scoped, re
454
454
  throw new Error('Page invocation expired or was cancelled; no action was taken');
455
455
  }
456
456
  }
457
+ /** Fence a protected browser effect to the exact view in which its human card was proposed.
458
+ * Hosts call noteNavigation synchronously for every navigation, including a return to an old URL.
459
+ * Internal metadata is checked and removed before the page capability's public schema sees it.
460
+ * @returns Existing bridge callbacks plus the host-owned navigation notification.
461
+ * @complexity O(input keys) time/space per prepared action; O(1) retained revision counter.
462
+ * @overallScore 100
463
+ */
464
+ export function createFrontendNavigationGuard(_required, _optional = {}) {
465
+ let revision = 0;
466
+ return {
467
+ noteNavigation: () => { revision += 1; },
468
+ preparePageInput: ({ action }) => {
469
+ const { __frontendNavigationRevision: expected, ...input } = action.input;
470
+ if (Object.hasOwn(action.input, '__frontendNavigationRevision') && (!Number.isSafeInteger(expected) || expected !== revision)) {
471
+ throw new Error('The page changed while confirmation was pending; propose this action again.');
472
+ }
473
+ return input;
474
+ },
475
+ onBeforeResponse: ({ action, output }) => {
476
+ if (action.capabilityId !== 'page.find_elements')
477
+ return output;
478
+ if (output === null || typeof output !== 'object' || Array.isArray(output))
479
+ return output;
480
+ return { ...output, navigationRevision: revision };
481
+ },
482
+ };
483
+ }
457
484
  //# sourceMappingURL=frontend-session-bridge.js.map
@@ -3,8 +3,11 @@ import { type ObjectUrlPort } from './SentAttachment.hooks.js';
3
3
  import { formatAttachmentSize } from './attachment-size.js';
4
4
  export { formatAttachmentSize };
5
5
  export type AttachmentTrayProps = AttachmentTraySlot & {
6
+ agentHandle?: string | false | undefined;
6
7
  /** Blob-URL port for chip thumbnails; defaults to the platform's (see `SentAttachment.hooks.ts`). */
7
8
  objectUrls?: ObjectUrlPort | undefined;
9
+ /** An upload is still running: shows a spinning placeholder chip after the staged ones. */
10
+ uploading?: boolean | undefined;
8
11
  };
9
- export declare function AttachmentTray({ attachments, onRemove, renderItem, objectUrls }: AttachmentTrayProps): import("react").JSX.Element | null;
12
+ export declare function AttachmentTray({ agentHandle, attachments, onRemove, renderItem, objectUrls, uploading }: AttachmentTrayProps): import("react").JSX.Element | null;
10
13
  //# sourceMappingURL=AttachmentTray.d.ts.map
@@ -1,4 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * @module AttachmentTray
4
+ *
5
+ * Renders staged composer attachments as removable chips. A dumb,
6
+ * props-in/JSX-out implementation of the `AttachmentTraySlot` shape from
7
+ * `ADS-memory/reports/jini-port/recon/r4b-webui-design.md` §2 — a host can pass its own
8
+ * `renderItem` for exotic attachment kinds (screenshots, Figma frames, ...)
9
+ * and this component falls back to the built-in chip otherwise.
10
+ *
11
+ * The built-in chip shows a thumbnail for an image this browser staged (the same preview cache a
12
+ * sent message's thumbnail reads) and opens the shared `AttachmentPreviewModal`, with previous/next
13
+ * across the staged images - before sending, the operator can check which screenshots are going.
14
+ */
15
+ import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
2
16
  import { useT } from '../hooks/context.js';
3
17
  import { Icon } from './Icon.js';
4
18
  import { AttachmentPreviewModal } from './AttachmentPreviewModal.js';
@@ -8,18 +22,19 @@ import { useSentAttachmentThumbnail } from './SentAttachment.hooks.js';
8
22
  import { formatAttachmentSize } from './attachment-size.js';
9
23
  // Re-exported: callers and tests have always imported it from here.
10
24
  export { formatAttachmentSize };
11
- export function AttachmentTray({ attachments, onRemove, renderItem, objectUrls }) {
25
+ export function AttachmentTray({ agentHandle, attachments, onRemove, renderItem, objectUrls, uploading = false }) {
26
+ const base = agentHandle || undefined;
12
27
  const t = useT();
13
28
  const gallery = useAttachmentGallery({ attachments });
14
- if (attachments.length === 0)
29
+ if (attachments.length === 0 && !uploading)
15
30
  return null;
16
- return (_jsxs("div", { className: "jini-attachment-tray", "data-testid": "composer-attachment-tray", children: [attachments.map((a) => (_jsxs("div", { className: "jini-attachment-chip", "data-testid": "attachment-chip", "data-attachment-kind": a.kind, "data-attachment-name": a.name, children: [renderItem ? renderItem(a) : _jsx(DefaultAttachmentChip, { attachment: a, onOpen: gallery.open, objectUrls: objectUrls }), _jsx("button", { type: "button", className: "jini-attachment-remove", onClick: () => onRemove(a.path), title: t('Remove {name}', { name: a.name }), "aria-label": t('Remove {name}', { name: a.name }), children: _jsx(Icon, { name: "close", size: 12 }) })] }, a.path))), gallery.opened ? (_jsx(AttachmentPreviewModal, { attachment: gallery.opened, onClose: gallery.close, navigation: gallery.navigation })) : null] }));
31
+ return (_jsxs("div", { className: "jini-attachment-tray", "data-testid": "composer-attachment-tray", children: [attachments.map((a) => (_jsxs("div", { className: "jini-attachment-chip", "data-testid": "attachment-chip", "data-attachment-kind": a.kind, "data-attachment-name": a.name, children: [renderItem ? renderItem(a) : _jsx(DefaultAttachmentChip, { base: base, attachment: a, onOpen: gallery.open, objectUrls: objectUrls }), _jsx("button", { ...agentHandleProps({}, { base, action: `remove-${agentHandleSegment({ value: a.path })}`, role: 'button', label: t('Remove {name}', { name: a.name }) }), type: "button", className: "jini-attachment-remove", onClick: () => onRemove(a.path), title: t('Remove {name}', { name: a.name }), "aria-label": t('Remove {name}', { name: a.name }), children: _jsx(Icon, { name: "close", size: 12 }) })] }, a.path))), uploading ? (_jsxs("div", { className: "jini-attachment-chip is-uploading", "data-testid": "attachment-uploading-chip", children: [_jsx("span", { className: "jini-attachment-chip-icon", children: _jsx(Icon, { name: "spinner", size: 15 }) }), _jsx("span", { className: "jini-attachment-chip-copy", children: _jsx("span", { className: "jini-attachment-chip-name", children: t('Uploading…') }) })] })) : null, gallery.opened ? (_jsx(AttachmentPreviewModal, { attachment: gallery.opened, onClose: gallery.close, navigation: gallery.navigation })) : null] }));
17
32
  }
18
- function DefaultAttachmentChip({ attachment, onOpen, objectUrls }) {
33
+ function DefaultAttachmentChip({ base, attachment, onOpen, objectUrls }) {
19
34
  const t = useT();
20
35
  const { thumbnailUrl, onThumbnailError } = useSentAttachmentThumbnail({ attachment }, objectUrls === undefined ? {} : { objectUrls });
21
36
  const size = formatAttachmentSize({ size: attachment.size });
22
37
  const label = thumbnailUrl && isOpaqueAttachmentName({ name: attachment.name }) ? t('Image') : attachment.name;
23
- return (_jsxs("button", { type: "button", className: "jini-attachment-chip-body", onClick: () => onOpen(attachment), title: t('Open {name}', { name: attachment.name }), "aria-label": t('Open {name}', { name: attachment.name }), children: [thumbnailUrl ? (_jsx("img", { className: "jini-attachment-chip-thumb", src: thumbnailUrl, alt: "", onError: onThumbnailError })) : (_jsx("span", { className: `jini-attachment-chip-icon is-${attachment.kind}`, children: _jsx(Icon, { name: attachment.kind === 'image' ? 'image' : 'file', size: 15 }) })), _jsxs("span", { className: "jini-attachment-chip-copy", children: [_jsx("span", { className: "jini-attachment-chip-name", children: label }), size ? _jsx("small", { className: "jini-attachment-chip-size", children: size }) : null] })] }));
38
+ return (_jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: `open-${agentHandleSegment({ value: attachment.path })}`, role: 'button', label: t('Open {name}', { name: attachment.name }) }), className: "jini-attachment-chip-body", onClick: () => onOpen(attachment), title: t('Open {name}', { name: attachment.name }), "aria-label": t('Open {name}', { name: attachment.name }), children: [thumbnailUrl ? (_jsx("img", { className: "jini-attachment-chip-thumb", src: thumbnailUrl, alt: "", onError: onThumbnailError })) : (_jsx("span", { className: `jini-attachment-chip-icon is-${attachment.kind}`, children: _jsx(Icon, { name: attachment.kind === 'image' ? 'image' : 'file', size: 15 }) })), _jsxs("span", { className: "jini-attachment-chip-copy", children: [_jsx("span", { className: "jini-attachment-chip-name", children: label }), size ? _jsx("small", { className: "jini-attachment-chip-size", children: size }) : null] })] }));
24
39
  }
25
40
  //# sourceMappingURL=AttachmentTray.js.map
@@ -1,6 +1,8 @@
1
1
  import type { UseComposerResult } from '../hooks/useComposer.js';
2
2
  import type { ComposerSlots } from '../slots.js';
3
3
  export interface ComposerProps {
4
+ /** Stable automation base; false suppresses every package-owned control handle. */
5
+ agentHandle?: string | false | undefined;
4
6
  composer: UseComposerResult;
5
7
  onSend: () => void;
6
8
  disabled?: boolean;
@@ -71,5 +73,5 @@ export interface ComposerProps {
71
73
  * @complexity Time/space: O(n) in rendered attachments and supplied menu items.
72
74
  * @overallScore 100/100
73
75
  */
74
- export declare function Composer({ composer, onSend, disabled, sendDisabled, sendDisabledReason, sendDisabledReasonId, placeholder, slots, attachmentPicker, running, onCancel, onInterrupt, workingDirectory, onChangeWorkingDirectory, onPickWorkingDirectory, }: ComposerProps): import("react").JSX.Element;
76
+ export declare function Composer({ agentHandle, composer, onSend, disabled, sendDisabled, sendDisabledReason, sendDisabledReasonId, placeholder, slots, attachmentPicker, running, onCancel, onInterrupt, workingDirectory, onChangeWorkingDirectory, onPickWorkingDirectory, }: ComposerProps): import("react").JSX.Element;
75
77
  //# sourceMappingURL=Composer.d.ts.map
@@ -15,7 +15,8 @@ import { formatErrorForLog } from '@jini-ai/core';
15
15
  */
16
16
  import { FolderChips } from './FolderChips.js';
17
17
  import { useEffect, useLayoutEffect, useRef, useState, } from 'react';
18
- import { RemixIcon } from '@jini-ai/ui';
18
+ import { RemixIcon, useAgentHandle } from '@jini-ai/ui';
19
+ import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
19
20
  import { useT } from '../hooks/context.js';
20
21
  import { useComposerHistoryKeys } from '../hooks/useComposerHistoryKeys.hooks.js';
21
22
  import { AttachmentTray } from './AttachmentTray.js';
@@ -67,7 +68,8 @@ function runComposerHostEffect(effectName, effect, onSettled, onResolved) {
67
68
  * @complexity Time/space: O(n) in rendered attachments and supplied menu items.
68
69
  * @overallScore 100/100
69
70
  */
70
- export function Composer({ composer, onSend, disabled = false, sendDisabled = false, sendDisabledReason, sendDisabledReasonId, placeholder, slots, attachmentPicker, running = false, onCancel, onInterrupt, workingDirectory, onChangeWorkingDirectory, onPickWorkingDirectory, }) {
71
+ export function Composer({ agentHandle, composer, onSend, disabled = false, sendDisabled = false, sendDisabledReason, sendDisabledReasonId, placeholder, slots, attachmentPicker, running = false, onCancel, onInterrupt, workingDirectory, onChangeWorkingDirectory, onPickWorkingDirectory, }) {
72
+ const base = useAgentHandle({ agentHandle });
71
73
  const t = useT();
72
74
  const attachmentInputRef = useRef(null);
73
75
  const textareaRef = useRef(null);
@@ -322,14 +324,14 @@ export function Composer({ composer, onSend, disabled = false, sendDisabled = fa
322
324
  event.preventDefault();
323
325
  runComposerHostEffect('attachmentPicker.onFiles', () => attachmentPicker.onFiles(files));
324
326
  }
325
- return (_jsxs("div", { className: "jini-composer", children: [_jsx(AccessorySlot, { className: "jini-composer-leading", children: leadingAccessories }), _jsxs("div", { className: "jini-composer-attachments", children: [_jsx(AttachmentTray, { attachments: composer.attachments, onRemove: composer.removeAttachment }), _jsx(FolderChips, { folders: composer.folders, onRemove: composer.removeFolder })] }), _jsx("textarea", { ref: textareaRef, className: "jini-composer-input", value: composer.draft, placeholder: placeholder ?? t('Send a message…'), disabled: disabled, onChange: (e) => {
327
+ return (_jsxs("div", { className: "jini-composer", children: [_jsx(AccessorySlot, { className: "jini-composer-leading", children: leadingAccessories }), _jsxs("div", { className: "jini-composer-attachments", children: [_jsx(AttachmentTray, { agentHandle: base, attachments: composer.attachments, onRemove: composer.removeAttachment, uploading: attachmentPicker?.uploading === true }), _jsx(FolderChips, { agentHandle: base, folders: composer.folders, onRemove: composer.removeFolder })] }), _jsx("textarea", { ...agentHandleProps({}, { base, action: 'draft', role: 'field', label: t('Message draft') }), ref: textareaRef, className: "jini-composer-input", value: composer.draft, placeholder: placeholder ?? t('Send a message…'), disabled: disabled, onChange: (e) => {
326
328
  composer.setDraft(e.target.value);
327
329
  setSlashActiveIndex(0);
328
330
  setDismissedSlashDraft(null);
329
331
  }, onKeyDown: handleKeyDown,
330
332
  // Draft persistence is debounced (see `DRAFT_PERSIST_DEBOUNCE_MS`); leaving the field is a
331
333
  // natural point to make it durable now.
332
- onBlur: () => composer.flushDraft?.(), onPaste: handleAttachmentPaste, ...slashTextareaAria(slashOpen, slashActiveOption), rows: 3 }), slashOpen ? (_jsx(ComposerSlashMenu, { matches: slash.matches, activeIndex: slashActiveOption, onSelect: selectSlashItem, showFilterHint: slash.showFilterHint, style: slashMenuPosition, t: t })) : null, _jsxs("div", { className: "jini-composer-footer", children: [_jsx(ComposerAttachButton, { attachmentPicker: attachmentPicker, hidden: hasDiscoveryItems, disabled: disabled, inputRef: attachmentInputRef, onChange: handleAttachmentChange, t: t }), _jsx(ComposerDiscoveryMenu, { groups: discoveryGroups, open: discoveryMenuOpen, disabled: disabled, ...(attachmentPicker ? { attachmentPicker } : {}), attachmentInputRef: attachmentInputRef, onToggle: () => setDiscoveryMenuOpen((open) => !open), onClose: () => setDiscoveryMenuOpen(false), onSelect: selectPlusItem, onAttachmentChange: handleAttachmentChange, style: discoveryMenuPosition, t: t }), _jsx(AccessorySlot, { className: "jini-composer-footer-leading", children: footerLeadingAccessory }), _jsx(ComposerWorkdirControl, { workingDirectory: workingDirectory, onChangeWorkingDirectory: onChangeWorkingDirectory, onPickWorkingDirectory: onPickWorkingDirectory, disabled: disabled, open: workdirOpen, draft: workdirDraft, position: workdirPosition, onToggle: toggleWorkdir, onDraftChange: setWorkdirDraft, onConfirm: confirmWorkdir, onClose: () => setWorkdirOpen(false), t: t }), _jsxs("div", { className: "jini-composer-footer-trailing", children: [_jsx(AccessorySlot, { className: "jini-composer-footer-accessories", children: footerAccessories }), _jsx(ComposerPlusMenu, { items: plusMenuItems, t: t }), _jsx(ComposerSendGroup, { running: running, disabled: disabled, sendDisabled: sendDisabled, canSubmit: composer.canSubmit, onSend: onSend, onCancel: onCancel, sendDisabledReason: sendDisabledReason, sendDisabledReasonId: sendDisabledReasonId, t: t })] })] })] }));
334
+ onBlur: () => composer.flushDraft?.(), onPaste: handleAttachmentPaste, ...slashTextareaAria(slashOpen, slashActiveOption), rows: 3 }), slashOpen ? (_jsx(ComposerSlashMenu, { base: base, matches: slash.matches, activeIndex: slashActiveOption, onSelect: selectSlashItem, showFilterHint: slash.showFilterHint, style: slashMenuPosition, t: t })) : null, _jsxs("div", { className: "jini-composer-footer", children: [_jsx(ComposerAttachButton, { base: base, attachmentPicker: attachmentPicker, hidden: hasDiscoveryItems, disabled: disabled, inputRef: attachmentInputRef, onChange: handleAttachmentChange, t: t }), _jsx(ComposerDiscoveryMenu, { base: base, groups: discoveryGroups, open: discoveryMenuOpen, disabled: disabled, ...(attachmentPicker ? { attachmentPicker } : {}), attachmentInputRef: attachmentInputRef, onToggle: () => setDiscoveryMenuOpen((open) => !open), onClose: () => setDiscoveryMenuOpen(false), onSelect: selectPlusItem, onAttachmentChange: handleAttachmentChange, style: discoveryMenuPosition, t: t }), _jsx(AccessorySlot, { className: "jini-composer-footer-leading", children: footerLeadingAccessory }), _jsx(ComposerWorkdirControl, { base: base, workingDirectory: workingDirectory, onChangeWorkingDirectory: onChangeWorkingDirectory, onPickWorkingDirectory: onPickWorkingDirectory, disabled: disabled, open: workdirOpen, draft: workdirDraft, position: workdirPosition, onToggle: toggleWorkdir, onDraftChange: setWorkdirDraft, onConfirm: confirmWorkdir, onClose: () => setWorkdirOpen(false), t: t }), _jsxs("div", { className: "jini-composer-footer-trailing", children: [_jsx(AccessorySlot, { className: "jini-composer-footer-accessories", children: footerAccessories }), _jsx(ComposerPlusMenu, { base: base, items: plusMenuItems, t: t }), _jsx(ComposerSendGroup, { base: base, running: running, disabled: disabled, sendDisabled: sendDisabled, canSubmit: composer.canSubmit, onSend: onSend, onCancel: onCancel, sendDisabledReason: sendDisabledReason, sendDisabledReasonId: sendDisabledReasonId, t: t })] })] })] }));
333
335
  }
334
336
  function anyPopoverOpen({ discoveryMenuOpen, slashOpen, workdirOpen }) {
335
337
  return discoveryMenuOpen || slashOpen || workdirOpen;
@@ -366,19 +368,19 @@ function AccessorySlot({ className, children }) {
366
368
  return children ? _jsx("div", { className: className, children: children }) : null;
367
369
  }
368
370
  /** The plain paperclip, shown only when there is no "+" discovery menu to carry attaching instead. */
369
- function ComposerAttachButton({ attachmentPicker, hidden, disabled, inputRef, onChange, t }) {
371
+ function ComposerAttachButton({ base, attachmentPicker, hidden, disabled, inputRef, onChange, t }) {
370
372
  if (!attachmentPicker || hidden)
371
373
  return null;
372
374
  const uploading = attachmentPicker.uploading;
373
375
  const label = t(uploading ? 'Attaching files…' : 'Attach files');
374
- return (_jsxs("div", { className: "jini-composer-attachment-picker", children: [_jsx("input", { ref: inputRef, className: "jini-composer-file-input", "data-testid": "composer-attachment-input", type: "file", multiple: true, "aria-label": t('Attach files'), accept: attachmentPicker.accept, disabled: disabled || uploading, onChange: onChange }), _jsx("button", { type: "button", className: "jini-composer-attach", disabled: disabled || uploading, onClick: () => inputRef.current?.click(), title: label, "aria-label": label, children: _jsx(RemixIcon, { name: uploading ? 'refresh-line' : 'add-line', size: 20, ...(uploading ? { className: 'jini-composer-spinner' } : {}) }) })] }));
376
+ return (_jsxs("div", { className: "jini-composer-attachment-picker", children: [_jsx("input", { ref: inputRef, className: "jini-composer-file-input", "data-testid": "composer-attachment-input", type: "file", multiple: true, "aria-label": t('Attach files'), accept: attachmentPicker.accept, disabled: disabled || uploading, onChange: onChange }), _jsx("button", { type: "button", ...agentHandleProps({}, { base, action: 'attach', role: 'button', label }), className: "jini-composer-attach", disabled: disabled || uploading, onClick: () => inputRef.current?.click(), title: label, "aria-label": label, children: _jsx(RemixIcon, { name: uploading ? 'refresh-line' : 'add-line', size: 20, ...(uploading ? { className: 'jini-composer-spinner' } : {}) }) })] }));
375
377
  }
376
- function ComposerWorkdirControl({ workingDirectory, onChangeWorkingDirectory, onPickWorkingDirectory, disabled, open, draft, position, onToggle, onDraftChange, onConfirm, onClose, t }) {
378
+ function ComposerWorkdirControl({ base, workingDirectory, onChangeWorkingDirectory, onPickWorkingDirectory, disabled, open, draft, position, onToggle, onDraftChange, onConfirm, onClose, t }) {
377
379
  if (!onChangeWorkingDirectory && !onPickWorkingDirectory)
378
380
  return null;
379
- return (_jsxs("div", { className: "jini-composer-workdir", "data-testid": "composer-workdir", children: [_jsx("button", { type: "button", className: "jini-composer-attach", "data-testid": "composer-workdir-trigger", disabled: disabled, onClick: onPickWorkingDirectory ? () => onPickWorkingDirectory() : onToggle, ...(onPickWorkingDirectory ? {} : { 'aria-haspopup': 'dialog', 'aria-expanded': open }), title: workingDirectory ?? t('Set working directory'), "aria-label": workingDirectory
381
+ return (_jsxs("div", { className: "jini-composer-workdir", "data-testid": "composer-workdir", children: [_jsx("button", { type: "button", className: "jini-composer-attach", ...agentHandleProps({}, { base, action: 'workdir', role: 'button', label: t('Set working directory') }), "data-testid": "composer-workdir-trigger", disabled: disabled, onClick: onPickWorkingDirectory ? () => onPickWorkingDirectory() : onToggle, ...(onPickWorkingDirectory ? {} : { 'aria-haspopup': 'dialog', 'aria-expanded': open }), title: workingDirectory ?? t('Set working directory'), "aria-label": workingDirectory
380
382
  ? t('Working directory: {dir}', { dir: workingDirectory })
381
- : t('Set working directory'), children: _jsx(RemixIcon, { name: "folder-line", size: 20 }) }), !onPickWorkingDirectory && open ? (_jsxs("div", { className: "jini-composer-workdir-panel", "data-testid": "composer-workdir-panel", role: "dialog", "aria-label": t('Working directory'), style: position, children: [_jsx("input", { type: "text", className: "jini-composer-workdir-input", "data-testid": "composer-workdir-input", value: draft, onChange: (e) => onDraftChange(e.target.value), onKeyDown: (e) => {
383
+ : t('Set working directory'), children: _jsx(RemixIcon, { name: "folder-line", size: 20 }) }), !onPickWorkingDirectory && open ? (_jsxs("div", { className: "jini-composer-workdir-panel", "data-testid": "composer-workdir-panel", role: "dialog", "aria-label": t('Working directory'), style: position, children: [_jsx("input", { type: "text", className: "jini-composer-workdir-input", ...agentHandleProps({}, { base, action: 'workdir-path', role: 'field', label: t('Working directory path') }), "data-testid": "composer-workdir-input", value: draft, onChange: (e) => onDraftChange(e.target.value), onKeyDown: (e) => {
382
384
  if (e.key === 'Enter') {
383
385
  e.preventDefault();
384
386
  onConfirm();
@@ -388,19 +390,19 @@ function ComposerWorkdirControl({ workingDirectory, onChangeWorkingDirectory, on
388
390
  e.preventDefault();
389
391
  onClose();
390
392
  }
391
- }, placeholder: t('Working directory path'), "aria-label": t('Working directory path'), autoFocus: true }), _jsx("button", { type: "button", className: "jini-composer-workdir-confirm", "data-testid": "composer-workdir-confirm", onClick: onConfirm, children: t('Set') })] })) : null] }));
393
+ }, placeholder: t('Working directory path'), "aria-label": t('Working directory path'), autoFocus: true }), _jsx("button", { type: "button", className: "jini-composer-workdir-confirm", ...agentHandleProps({}, { base, action: 'workdir-set', role: 'button', label: t('Set working directory') }), "data-testid": "composer-workdir-confirm", onClick: onConfirm, children: t('Set') })] })) : null] }));
392
394
  }
393
- function ComposerPlusMenu({ items, t }) {
395
+ function ComposerPlusMenu({ base, items, t }) {
394
396
  if (!items || items.length === 0)
395
397
  return null;
396
- return (_jsx("div", { className: "jini-composer-plus-menu", children: items.map((item) => (_jsxs("button", { type: "button", className: "jini-composer-plus-item", onClick: () => runComposerHostEffect('plusMenuItems.onSelect', () => item.onSelect()), title: t(item.label), children: [item.icon ?? null, _jsx("span", { children: t(item.label) })] }, item.id))) }));
398
+ return (_jsx("div", { className: "jini-composer-plus-menu", children: items.map((item) => (_jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: `extra-${agentHandleSegment({ value: item.id })}`, role: 'button', label: t(item.label) }), className: "jini-composer-plus-item", onClick: () => runComposerHostEffect('plusMenuItems.onSelect', () => item.onSelect()), title: t(item.label), children: [item.icon ?? null, _jsx("span", { children: t(item.label) })] }, item.id))) }));
397
399
  }
398
- function ComposerSendGroup({ running, disabled, sendDisabled, canSubmit, onSend, onCancel, sendDisabledReason, sendDisabledReasonId, t }) {
400
+ function ComposerSendGroup({ base, running, disabled, sendDisabled, canSubmit, onSend, onCancel, sendDisabledReason, sendDisabledReasonId, t }) {
399
401
  const canSend = !disabled && !sendDisabled && canSubmit;
400
402
  return (
401
403
  // While a run streams, Send sits beside Stop once there is something to send: a message
402
404
  // sent mid-run goes to the running agent (or next, if it cannot take it now). One group so
403
405
  // the footer's space-between keeps the two together at the trailing edge.
404
- _jsxs("span", { className: "jini-composer-send-group", children: [!running || canSend ? (_jsx("button", { type: "button", className: "jini-composer-send", disabled: !canSend, onClick: onSend, title: sendDisabledReason ?? t('Send'), "aria-label": t('Send'), "aria-describedby": sendDisabledReasonId, children: _jsx(RemixIcon, { name: "send-plane-2-line", size: 16 }) })) : null, running ? (_jsx("button", { type: "button", className: "jini-composer-send jini-composer-send--stop", onClick: onCancel, title: t('Stop run'), "aria-label": t('Stop run'), children: _jsx(RemixIcon, { name: "stop-fill", size: 14 }) })) : null] }));
406
+ _jsxs("span", { className: "jini-composer-send-group", children: [!running || canSend ? (_jsx("button", { ...agentHandleProps({}, { base, action: 'send', role: 'button', label: t('Send') }), type: "button", className: "jini-composer-send", disabled: !canSend, onClick: onSend, title: sendDisabledReason ?? t('Send'), "aria-label": t('Send'), "aria-describedby": sendDisabledReasonId, children: _jsx(RemixIcon, { name: "send-plane-2-line", size: 16 }) })) : null, running ? (_jsx("button", { ...agentHandleProps({}, { base, action: 'stop', role: 'button', label: t('Stop run') }), type: "button", className: "jini-composer-send jini-composer-send--stop", onClick: onCancel, title: t('Stop run'), "aria-label": t('Stop run'), children: _jsx(RemixIcon, { name: "stop-fill", size: 14 }) })) : null] }));
405
407
  }
406
408
  //# sourceMappingURL=Composer.js.map
@@ -7,6 +7,7 @@ interface AttachmentPicker {
7
7
  uploading?: boolean;
8
8
  }
9
9
  export interface ComposerDiscoveryMenuProps {
10
+ base?: string | undefined;
10
11
  groups: readonly ComposerDiscoveryGroup[];
11
12
  open: boolean;
12
13
  disabled: boolean;
@@ -27,6 +28,7 @@ export interface ComposerDiscoveryMenuProps {
27
28
  /** Generic grouped add-menu; the host owns all inventory labels and items. */
28
29
  export declare function ComposerDiscoveryMenu(props: ComposerDiscoveryMenuProps): import("react").JSX.Element | null;
29
30
  export interface ComposerSlashMenuProps {
31
+ base?: string | undefined;
30
32
  matches: readonly ComposerDiscoveryMatch[];
31
33
  activeIndex: number;
32
34
  onSelect: (item: ComposerDiscoveryItem) => void;
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { RemixIcon } from '@jini-ai/ui';
3
+ import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
3
4
  /** Generic grouped add-menu; the host owns all inventory labels and items. */
4
5
  export function ComposerDiscoveryMenu(props) {
5
6
  const hasItems = props.groups.some((group) => group.items.length > 0);
@@ -10,13 +11,13 @@ export function ComposerDiscoveryMenu(props) {
10
11
  return;
11
12
  event.preventDefault();
12
13
  props.onClose();
13
- }, children: [props.attachmentPicker ? (_jsx("input", { ref: props.attachmentInputRef, className: "jini-composer-file-input", "data-testid": "composer-attachment-input", type: "file", multiple: true, "aria-label": props.t('Attach files'), accept: props.attachmentPicker.accept, disabled: props.disabled || props.attachmentPicker.uploading, onChange: props.onAttachmentChange })) : null, _jsx("button", { type: "button", className: "jini-composer-attach", disabled: props.disabled, onClick: props.onToggle, "aria-expanded": props.open, "aria-haspopup": "menu", title: props.t('Add context'), "aria-label": props.t('Add context'), children: _jsx(RemixIcon, { name: "add-line", size: 20 }) }), props.open ? (_jsxs("div", { className: "jini-composer-discovery-menu", style: props.style, role: "menu", "aria-label": props.t('Add context'), children: [props.attachmentPicker ? (_jsxs("div", { className: "jini-composer-discovery-group", role: "group", "aria-label": props.t('Files'), children: [_jsx("span", { className: "jini-composer-discovery-group-label", children: props.t('Files') }), _jsx("button", { type: "button", role: "menuitem", className: "jini-composer-discovery-item", disabled: props.disabled || props.attachmentPicker.uploading, onClick: () => {
14
+ }, children: [props.attachmentPicker ? (_jsx("input", { ref: props.attachmentInputRef, className: "jini-composer-file-input", "data-testid": "composer-attachment-input", type: "file", multiple: true, "aria-label": props.t('Attach files'), accept: props.attachmentPicker.accept, disabled: props.disabled || props.attachmentPicker.uploading, onChange: props.onAttachmentChange })) : null, _jsx("button", { type: "button", ...agentHandleProps({}, { base: props.base, action: 'discovery', role: 'button', label: props.t('Add context') }), className: "jini-composer-attach", disabled: props.disabled, onClick: props.onToggle, "aria-expanded": props.open, "aria-haspopup": "menu", title: props.t('Add context'), "aria-label": props.t('Add context'), children: _jsx(RemixIcon, { name: "add-line", size: 20 }) }), props.open ? (_jsxs("div", { className: "jini-composer-discovery-menu", style: props.style, role: "menu", "aria-label": props.t('Add context'), children: [props.attachmentPicker ? (_jsxs("div", { className: "jini-composer-discovery-group", role: "group", "aria-label": props.t('Files'), children: [_jsx("span", { className: "jini-composer-discovery-group-label", children: props.t('Files') }), _jsx("button", { type: "button", role: "menuitem", ...agentHandleProps({}, { base: props.base, action: 'attach', role: 'button', label: props.t('Attach files') }), className: "jini-composer-discovery-item", disabled: props.disabled || props.attachmentPicker.uploading, onClick: () => {
14
15
  props.onClose();
15
16
  props.attachmentInputRef.current?.click();
16
17
  }, children: props.t(props.attachmentPicker.uploading ? 'Attaching files…' : 'Attach files') })] })) : null, props.groups.map((group) => group.items.length > 0 ? (_jsxs("div", { className: "jini-composer-discovery-group", role: "group", "aria-label": props.t(group.label), children: [_jsx("span", { className: "jini-composer-discovery-group-label", children: props.t(group.label) }), group.items.map((item) => {
17
18
  const description = item.description ? props.t(item.description) : undefined;
18
19
  const descriptionId = description ? `jini-composer-discovery-desc-${item.id}` : undefined;
19
- return (_jsxs("button", { type: "button", role: "menuitem", className: "jini-composer-discovery-item", "aria-describedby": descriptionId, onClick: () => props.onSelect(item), children: [_jsx("span", { children: props.t(item.label) }), description ? (_jsx("small", { id: descriptionId, className: "jini-composer-discovery-description", children: description })) : null] }, item.id));
20
+ return (_jsxs("button", { type: "button", role: "menuitem", ...agentHandleProps({}, { base: props.base, action: `discover-${agentHandleSegment({ value: group.id })}-${agentHandleSegment({ value: item.id })}`, role: 'button', label: props.t(item.label) }), className: "jini-composer-discovery-item", "aria-describedby": descriptionId, onClick: () => props.onSelect(item), children: [_jsx("span", { children: props.t(item.label) }), description ? (_jsx("small", { id: descriptionId, className: "jini-composer-discovery-description", children: description })) : null] }, item.id));
20
21
  })] }, group.id)) : null)] })) : null] }));
21
22
  }
22
23
  /** Keyboard navigation is owned by Composer so focus stays in the textarea. */
@@ -32,7 +33,7 @@ export function ComposerSlashMenu(props) {
32
33
  _jsx("div", { className: "jini-composer-discovery-group-label", role: "presentation", children: props.t('Keep typing to narrow the list') })) : null, props.matches.map((match, index) => {
33
34
  const description = props.t(match.item.description ?? match.groupLabel);
34
35
  const descriptionId = `jini-composer-slash-option-${index}-desc`;
35
- return (_jsxs("button", { id: `jini-composer-slash-option-${index}`, type: "button", role: "option", "aria-selected": index === props.activeIndex, "aria-describedby": descriptionId, className: `jini-composer-discovery-item${index === props.activeIndex ? ' is-active' : ''}`, onMouseDown: (event) => event.preventDefault(), onClick: () => props.onSelect(match.item), children: [_jsxs("span", { children: [props.t(match.item.label), match.item.argument ? (_jsxs("code", { className: "jini-composer-slash-argument", children: [" ", match.item.argument.placeholder] })) : null, match.item.needsConfirmation ? (_jsxs("small", { className: "jini-composer-slash-confirm-badge", children: [" ", props.t('Confirm')] })) : null] }), _jsx("small", { id: descriptionId, className: "jini-composer-discovery-description", children: description })] }, `${match.groupId}:${match.item.id}`));
36
+ return (_jsxs("button", { id: `jini-composer-slash-option-${index}`, ...agentHandleProps({}, { base: props.base, action: `command-${agentHandleSegment({ value: match.groupId })}-${agentHandleSegment({ value: match.item.id })}`, role: 'button', label: props.t(match.item.label) }), type: "button", role: "option", "aria-selected": index === props.activeIndex, "aria-describedby": descriptionId, className: `jini-composer-discovery-item${index === props.activeIndex ? ' is-active' : ''}`, onMouseDown: (event) => event.preventDefault(), onClick: () => props.onSelect(match.item), children: [_jsxs("span", { children: [props.t(match.item.label), match.item.argument ? (_jsxs("code", { className: "jini-composer-slash-argument", children: [" ", match.item.argument.placeholder] })) : null, match.item.needsConfirmation ? (_jsxs("small", { className: "jini-composer-slash-confirm-badge", children: [" ", props.t('Confirm')] })) : null] }), _jsx("small", { id: descriptionId, className: "jini-composer-discovery-description", children: description })] }, `${match.groupId}:${match.item.id}`));
36
37
  })] }));
37
38
  }
38
39
  //# sourceMappingURL=ComposerDiscovery.js.map
@@ -10,8 +10,10 @@ export interface ConversationListProps {
10
10
  activeConversationId: string | null;
11
11
  onSelect: (id: string) => void;
12
12
  onCreate: () => void | Promise<void>;
13
- onDelete: (id: string) => void | Promise<void>;
14
- onRename: (id: string, title: string) => void | Promise<void>;
13
+ /** Omit to hide deletion controls. */
14
+ onDelete?: (id: string) => void | Promise<void>;
15
+ /** Omit to hide renaming controls and its double-click shortcut. */
16
+ onRename?: (id: string, title: string) => void | Promise<void>;
15
17
  /**
16
18
  * Server-backed search. Omit for the built-in client filter.
17
19
  *