@jini-ai/ui 0.6.23 → 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 (78) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/features/admin-widgets/components/ImagePreviewModal.d.ts +3 -3
  3. package/dist/features/admin-widgets/components/ImagePreviewModal.js +3 -1
  4. package/dist/features/admin-widgets/components/InfoTip.d.ts +2 -2
  5. package/dist/features/admin-widgets/components/InfoTip.js +3 -1
  6. package/dist/features/admin-widgets/components/SeeMore/SeeMore.d.ts +2 -2
  7. package/dist/features/admin-widgets/components/SeeMore/SeeMore.js +3 -1
  8. package/dist/features/admin-widgets/components/Select/Select.d.ts +2 -2
  9. package/dist/features/admin-widgets/components/Select/Select.js +12 -8
  10. package/dist/features/admin-widgets/components/SuggestInput/SuggestInput.d.ts +2 -2
  11. package/dist/features/admin-widgets/components/SuggestInput/SuggestInput.js +3 -1
  12. package/dist/features/execution/react/components/SearchableModelSelect.d.ts +5 -5
  13. package/dist/features/execution/react/components/SearchableModelSelect.js +4 -2
  14. package/dist/features/interactive-ui/providers/shadcn/checkbox-field.d.ts +3 -2
  15. package/dist/features/interactive-ui/providers/shadcn/checkbox-field.js +5 -2
  16. package/dist/features/interactive-ui/providers/shadcn/select-field.d.ts +4 -2
  17. package/dist/features/interactive-ui/providers/shadcn/select-field.js +9 -2
  18. package/dist/features/interactive-ui/providers/shadcn/select.d.ts +5 -3
  19. package/dist/features/interactive-ui/providers/shadcn/select.js +9 -4
  20. package/dist/features/mcp-ui/cards.d.ts +12 -0
  21. package/dist/features/mcp-ui/cards.js +8 -0
  22. package/dist/features/mcp-ui/credential-card.d.ts +34 -0
  23. package/dist/features/mcp-ui/credential-card.js +42 -0
  24. package/dist/features/mcp-ui/secret-card.d.ts +2 -16
  25. package/dist/features/mcp-ui/sign-in-card.d.ts +57 -0
  26. package/dist/features/mcp-ui/sign-in-card.js +67 -0
  27. package/dist/features/mcp-ui/surfaces/access-approval.d.ts +15 -0
  28. package/dist/features/mcp-ui/surfaces/access-approval.js +17 -0
  29. package/dist/features/mcp-ui/surfaces/bridge.d.ts +2 -8
  30. package/dist/features/mcp-ui/surfaces/confirmation.d.ts +9 -8
  31. package/dist/features/mcp-ui/surfaces/confirmation.js +23 -8
  32. package/dist/features/mcp-ui/surfaces/document.d.ts +3 -22
  33. package/dist/features/mcp-ui/surfaces/document.js +4 -0
  34. package/dist/features/mcp-ui/surfaces/fields.d.ts +2 -74
  35. package/dist/features/mcp-ui/surfaces/form.d.ts +2 -42
  36. package/dist/features/mcp-ui/surfaces/index.d.ts +1 -0
  37. package/dist/features/mcp-ui/surfaces/index.js +1 -0
  38. package/dist/features/mcp-ui/surfaces/outcome.d.ts +2 -39
  39. package/dist/features/mcp-ui/surfaces/outcome.js +25 -2
  40. package/dist/features/mcp-ui/surfaces/select.d.ts +2 -7
  41. package/dist/features/mcp-ui/surfaces/structured-details.d.ts +2 -19
  42. package/dist/features/mcp-ui/surfaces/text-input.d.ts +2 -5
  43. package/dist/features/mcp-ui/surfaces/tokens.d.ts +2 -2
  44. package/dist/features/panel-kit/failure-channel.d.ts +25 -0
  45. package/dist/features/panel-kit/failure-channel.js +36 -0
  46. package/dist/features/panel-kit/index.d.ts +2 -0
  47. package/dist/features/panel-kit/index.js +1 -0
  48. package/dist/features/site-card/SiteCard.d.ts +40 -0
  49. package/dist/features/site-card/SiteCard.js +15 -0
  50. package/dist/features/site-card/SiteListToolbar.d.ts +28 -0
  51. package/dist/features/site-card/SiteListToolbar.js +15 -0
  52. package/dist/features/site-card/index.d.ts +5 -0
  53. package/dist/features/site-card/index.js +5 -0
  54. package/dist/features/site-card/site-card.css +136 -0
  55. package/dist/features/site-card/site-list-view.d.ts +53 -0
  56. package/dist/features/site-card/site-list-view.js +62 -0
  57. package/dist/features/site-card/use-site-list-view.hooks.d.ts +24 -0
  58. package/dist/features/site-card/use-site-list-view.hooks.js +26 -0
  59. package/dist/features/tab-strip/react/components/TabStrip.d.ts +3 -2
  60. package/dist/features/tab-strip/react/components/TabStrip.js +5 -2
  61. package/dist/features/tab-strip/react/components/TabStripItem.d.ts +3 -2
  62. package/dist/features/tab-strip/react/components/TabStripItem.js +5 -2
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.js +3 -0
  65. package/dist/react/components/CustomSelect.d.ts +5 -3
  66. package/dist/react/components/CustomSelect.js +18 -11
  67. package/dist/react/components/PillButton.d.ts +3 -2
  68. package/dist/react/components/PillButton.js +5 -2
  69. package/dist/react/components/PopoverItem.d.ts +3 -2
  70. package/dist/react/components/PopoverItem.js +5 -2
  71. package/dist/react/components/PopoverMenu.d.ts +3 -2
  72. package/dist/react/components/PopoverMenu.js +5 -2
  73. package/dist/react/components/select-popover.d.ts +8 -2
  74. package/dist/react/components/select-popover.js +8 -3
  75. package/dist/react/hooks/useAgentHandle.d.ts +17 -0
  76. package/dist/react/hooks/useAgentHandle.js +17 -0
  77. package/dist/styles/admin.css +1 -0
  78. package/package.json +38 -12
@@ -0,0 +1,67 @@
1
+ /** External authorization uses openLink, never a tool invocation. Skip answers only the held
2
+ * exchange; replacing the same URI reports the actual connection without leaving a live link. */
3
+ import { SURFACE_DISMISSED_PARAM, SURFACE_EXCHANGE_ID_PARAM, } from '@jini-ai/core';
4
+ import { buildOutcomeSurface } from './surfaces/outcome.js';
5
+ /** Render the three states under one URI so the last emission replaces the waiting card.
6
+ * @complexity O(h) time/space in rendered HTML. @overallScore 99; Low: copy safety is host-owned. */
7
+ export function buildSignInCard(required, _optional = {}) {
8
+ const { uri, app, state } = required;
9
+ if (state !== 'waiting')
10
+ return buildOutcomeSurface({
11
+ uri, app, ...required[state], state: state === 'connected' ? 'success' : 'partial',
12
+ preferredFrameSize: ['100%', '200px'],
13
+ });
14
+ const { cancelLabel, ...copy } = required.waiting;
15
+ return buildOutcomeSurface({
16
+ uri, app, ...copy, state: 'partial', openLinkUrl: required.signInUrl,
17
+ ...(required.exchangeId ? { cancel: { label: cancelLabel, toolName: required.toolId,
18
+ params: { [SURFACE_EXCHANGE_ID_PARAM]: required.exchangeId, [SURFACE_DISMISSED_PARAM]: true } } } : {}),
19
+ preferredFrameSize: ['100%', '280px'],
20
+ });
21
+ }
22
+ /** Park one connection watcher; Skip cancels only that watcher, never the enclosing run.
23
+ * OAuth callbacks and credential custody remain with the injected connection owner.
24
+ * @complexity One bounded connection wait, one exchange and at most two emissions.
25
+ * @overallScore 99; Low: connection callbacks must honor their abort signal. */
26
+ export async function waitAtSignInCard(required, optional = {}) {
27
+ const { surfaceExchanges, ctx, toolId, card, connect } = required;
28
+ const waiting = new AbortController();
29
+ const signal = AbortSignal.any([ctx.signal, waiting.signal]);
30
+ let exchange;
31
+ let skipped = false;
32
+ const closeOnAbort = () => exchange?.close({});
33
+ ctx.signal.addEventListener('abort', closeOnAbort, { once: true });
34
+ try {
35
+ ctx.signal.throwIfAborted();
36
+ const result = await connect({ signal, showSignIn: async ({ signInUrl }) => {
37
+ if (!optional.emitSurface)
38
+ throw new Error(required.missingEmitterMessage);
39
+ ctx.signal.throwIfAborted();
40
+ exchange = surfaceExchanges.open({ binding: { toolId, principalId: ctx.principal.id, channel: 'mcp-ui' }, emit: optional.emitSurface });
41
+ // Register before emission: a fast click may answer while the emitter is still awaiting I/O.
42
+ void exchange.receive({}).then(answer => {
43
+ skipped = answer.status === 'received' && answer.params[SURFACE_DISMISSED_PARAM] === true;
44
+ waiting.abort();
45
+ });
46
+ await exchange.send({ emission: { channel: 'mcp-ui', payload: { resource: card({ state: 'waiting', signInUrl, exchangeId: exchange.id }) } } });
47
+ } });
48
+ if (skipped) {
49
+ await sendFinalCard({ exchange, card, state: 'skipped' });
50
+ return required.skippedResult();
51
+ }
52
+ if (result.status === 'connected')
53
+ await sendFinalCard({ exchange, card, state: 'connected' });
54
+ return result;
55
+ }
56
+ finally {
57
+ ctx.signal.removeEventListener('abort', closeOnAbort);
58
+ exchange?.close({});
59
+ waiting.abort();
60
+ }
61
+ }
62
+ /** A failed human-visible update must never turn a real connection into a tool failure.
63
+ * @complexity O(h), one emission. @overallScore 99; Low: final transport failure is best effort. */
64
+ async function sendFinalCard({ exchange, card, state }, _optional = {}) {
65
+ await exchange?.send({ emission: { channel: 'mcp-ui', payload: { resource: card({ state }) } } }).catch(() => undefined);
66
+ }
67
+ //# sourceMappingURL=sign-in-card.js.map
@@ -0,0 +1,15 @@
1
+ /** Fixed access disclosures share the confirmation surface's trusted, single-use click gates. */
2
+ import { type AccessApprovalDescription } from '@jini-ai/core';
3
+ import type { SurfaceDetail } from './document.js';
4
+ /** Show resource names and fixed before/after grants without opaque binding identifiers.
5
+ * The access snapshot and confirmation exchange retain the exact scope and revision.
6
+ * The shared structured-detail renderer escapes all caller-controlled labels and values.
7
+ * @throws ToolInputError for a proposal outside the shared resource/byte bounds.
8
+ * @complexity O(n) in disclosure bytes, with at most 128 resources; no I/O.
9
+ */
10
+ export declare function accessApprovalDetails({ access }: {
11
+ access: AccessApprovalDescription;
12
+ }, { omitIds }?: {
13
+ omitIds?: readonly string[];
14
+ }): readonly SurfaceDetail[];
15
+ //# sourceMappingURL=access-approval.d.ts.map
@@ -0,0 +1,17 @@
1
+ /** Fixed access disclosures share the confirmation surface's trusted, single-use click gates. */
2
+ import { snapshotAccessApproval } from '@jini-ai/core';
3
+ /** Show resource names and fixed before/after grants without opaque binding identifiers.
4
+ * The access snapshot and confirmation exchange retain the exact scope and revision.
5
+ * The shared structured-detail renderer escapes all caller-controlled labels and values.
6
+ * @throws ToolInputError for a proposal outside the shared resource/byte bounds.
7
+ * @complexity O(n) in disclosure bytes, with at most 128 resources; no I/O.
8
+ */
9
+ export function accessApprovalDetails({ access }, { omitIds = [] } = {}) {
10
+ // `omitIds` is presentation only: a card that already states a resource's facts in its own details
11
+ // leaves the repeat out. The snapshot the approval binds to is never filtered.
12
+ return snapshotAccessApproval({ access }).resources.filter(resource => !omitIds.includes(resource.id)).flatMap(resource => [
13
+ { label: 'Resource', value: resource.label },
14
+ { label: resource.label, previous: resource.previous, value: resource.proposed },
15
+ ]);
16
+ }
17
+ //# sourceMappingURL=access-approval.js.map
@@ -1,3 +1,5 @@
1
+ import type { BridgeScriptSpec } from '@jini-ai/core/contracts/cards';
2
+ export type { BridgeScriptSpec } from '@jini-ai/core/contracts/cards';
1
3
  /**
2
4
  * The global a surface's own script reaches the protocol through.
3
5
  *
@@ -10,14 +12,6 @@ export declare const SURFACE_BRIDGE_GLOBAL = "jiniMcpUi";
10
12
  * tell "the Host never answered `ui/initialize`" apart from "the surface's own script threw".
11
13
  */
12
14
  export declare const SURFACE_HANDSHAKE_FAILED_ATTRIBUTE = "data-mcpui-handshake-failed";
13
- export interface BridgeScriptSpec {
14
- /** Reported to the Host as `appInfo.name` in `ui/initialize`. */
15
- readonly appName: string;
16
- /** Reported to the Host as `appInfo.version`. */
17
- readonly appVersion: string;
18
- /** Defaults to {@link MCP_UI_PROTOCOL_VERSION}. */
19
- readonly protocolVersion?: string;
20
- }
21
15
  /**
22
16
  * Renders the View-side protocol bridge as JavaScript source.
23
17
  *
@@ -1,3 +1,5 @@
1
+ import type { ConfirmationToolAction } from '@jini-ai/core/contracts/cards';
2
+ export type { ConfirmationToolAction } from '@jini-ai/core/contracts/cards';
1
3
  /**
2
4
  * @module features/mcp-ui/surfaces/confirmation
3
5
  *
@@ -31,13 +33,6 @@ import { type UIResource, type UIResourceUri } from '../resource.js';
31
33
  import { type SurfaceDetail, type SurfaceStatusText } from './document.js';
32
34
  import type { BridgeScriptSpec } from './bridge.js';
33
35
  import type { SurfaceTokenName } from './tokens.js';
34
- /** A button that calls a tool when clicked. */
35
- export interface ConfirmationToolAction {
36
- readonly label: string;
37
- readonly toolName: string;
38
- /** Passed verbatim as the tool's `arguments`. The only safe home for a confirmation token. */
39
- readonly params: Readonly<Record<string, unknown>>;
40
- }
41
36
  /**
42
37
  * A further affirmative button beside confirm, such as "Allow for this chat" next to "Allow" — see
43
38
  * {@link ConfirmationSurfaceSpec.alternatives}.
@@ -61,6 +56,8 @@ export interface ConfirmationChoice {
61
56
  readonly id: string;
62
57
  readonly label: string;
63
58
  readonly hint?: string;
59
+ /** Initial selection supplied by the host; still requires a trusted affirmative click. */
60
+ readonly checked?: boolean;
64
61
  }
65
62
  export interface ConfirmationSurfaceSpec {
66
63
  readonly title: string;
@@ -73,7 +70,7 @@ export interface ConfirmationSurfaceSpec {
73
70
  readonly details: readonly SurfaceDetail[];
74
71
  };
75
72
  /**
76
- * Optional per-row checkboxes, rendered unchecked between the details and the warning. Ticking one
73
+ * Optional per-row checkboxes, unchecked by default between the details and the warning. Ticking one
77
74
  * never confirms anything by itself — the same property the module doc opens with, extended to a
78
75
  * second input: a tick reaches a tool call ONLY by riding along on confirm's own trusted,
79
76
  * past-dwell click, merged into {@link ConfirmationToolAction.params} under {@link choicesParam}
@@ -81,6 +78,8 @@ export interface ConfirmationSurfaceSpec {
81
78
  * params confirm posts are byte-identical to a spec written before this field existed.
82
79
  */
83
80
  readonly choices?: readonly ConfirmationChoice[];
81
+ /** Render the shared checklist layout with this accessible group label. */
82
+ readonly choicesLabel?: string;
84
83
  /**
85
84
  * The params key the ticked ids are posted under, merged into (never replacing) `confirm.params`.
86
85
  * Defaults to `"overwrite"`.
@@ -88,6 +87,8 @@ export interface ConfirmationSurfaceSpec {
88
87
  readonly choicesParam?: string;
89
88
  /** A callout above the buttons — the consequence that is not obvious from the details alone. */
90
89
  readonly warning?: string;
90
+ /** Plain explanatory text above the buttons, in a neutral box; `warning` stays the red callout for real danger. */
91
+ readonly notice?: string;
91
92
  /** Styles the affirmative button as destructive. Affects presentation only; it changes no behavior. */
92
93
  readonly danger?: boolean;
93
94
  readonly confirm: ConfirmationToolAction;
@@ -31,6 +31,7 @@ import { createUIResource } from '../resource.js';
31
31
  import { escapeHtml, escapeJsValue } from '../escape.js';
32
32
  import { DEFAULT_SURFACE_STATUS_TEXT, SURFACE_SCRIPT_PRELUDE, renderActions, renderDetailList, renderStatusRegion, renderSurfaceDocument, renderSurfaceHeader, } from './document.js';
33
33
  import { renderCheckbox } from './checkbox.js';
34
+ import { renderChoiceGroup } from './choice-group.js';
34
35
  /**
35
36
  * How long the dialog must have been visible before a confirm click counts, in ms. A click sooner
36
37
  * than a person could have read the dialog is ignored — the same dwell browsers put on permission
@@ -55,7 +56,7 @@ function isToolAction(action) {
55
56
  return action !== undefined && 'toolName' in action;
56
57
  }
57
58
  /**
58
- * Renders the optional choice checkboxes, one unchecked box per {@link ConfirmationChoice}.
59
+ * Renders the optional choice checkboxes, one box per {@link ConfirmationChoice}.
59
60
  *
60
61
  * Named `choice-<index>` in the DOM — never by `choice.id`, which is caller data and may contain
61
62
  * characters `fieldElementId`'s `name` validation rejects — with the real id carried on the
@@ -63,7 +64,7 @@ function isToolAction(action) {
63
64
  *
64
65
  * @returns `''` for an empty list, matching every other optional fragment in this document.
65
66
  */
66
- function renderChoices(choices) {
67
+ function renderChoices(choices, label) {
67
68
  if (choices.length === 0)
68
69
  return '';
69
70
  // Ticked state is keyed by id, so two boxes sharing one would tick and report as one.
@@ -74,10 +75,14 @@ function renderChoices(choices) {
74
75
  }
75
76
  seen.add(choice.id);
76
77
  }
78
+ if (label !== undefined)
79
+ return renderChoiceGroup({ name: 'confirmation-choices', label, selection: 'multiple',
80
+ options: choices.map(choice => ({ value: choice.id, label: choice.hint === undefined ? choice.label : `${choice.label} — ${choice.hint}` })), value: choices.filter(choice => choice.checked === true).map(choice => choice.id) });
77
81
  const boxes = choices
78
82
  .map((choice, index) => renderCheckbox({
79
83
  name: `choice-${index}`,
80
84
  label: choice.label,
85
+ ...(choice.checked === undefined ? {} : { value: choice.checked }),
81
86
  ...(choice.hint === undefined ? {} : { hint: choice.hint }),
82
87
  dataAttribute: { name: 'data-mcpui-choice', value: choice.id },
83
88
  }))
@@ -130,11 +135,14 @@ function assertChoicesParamFree(spec, required) {
130
135
  function confirmationBodyHtml(spec, required) {
131
136
  const { affirmative } = required;
132
137
  const warning = spec.warning === undefined ? '' : `<p class="mcpui-warning">${escapeHtml(spec.warning)}</p>`;
138
+ // Styled inline, from the same tokens, so the shared stylesheet (and every pinned card digest) stays as it was.
139
+ const notice = spec.notice === undefined ? '' : `<p class="mcpui-notice" style="margin:14px 0 0;padding:9px 11px;border:1px solid var(--jini-mcpui-border);border-radius:var(--jini-mcpui-radius-md);background:var(--jini-mcpui-panel);color:var(--jini-mcpui-text)">${escapeHtml(spec.notice)}</p>`;
133
140
  return [
134
141
  renderSurfaceHeader(spec.description === undefined ? { title: spec.title } : { title: spec.title, description: spec.description }),
135
142
  renderDetailList(spec.details ?? []),
136
143
  spec.detailDisclosure === undefined ? '' : `<details class="mcpui-detail-disclosure mcpui-technical-details"><summary aria-expanded="false">${escapeHtml(spec.detailDisclosure.label)}</summary>${renderDetailList(spec.detailDisclosure.details)}</details>`,
137
- renderChoices(spec.choices ?? []),
144
+ renderChoices(spec.choices ?? [], spec.choicesLabel),
145
+ notice,
138
146
  warning,
139
147
  // Confirm starts disabled; the script enables it once the dwell has run out.
140
148
  renderActions(confirmationActions(spec).map((action) => (affirmative.has(action.id) ? { ...action, disabled: true } : action)), { humanOnly: true }),
@@ -163,7 +171,12 @@ function confirmationPlan(spec, required) {
163
171
  }
164
172
  /** The inline runtime script: dwell, visibility, locking and tool calls. @complexity O(s) in the script length. */
165
173
  function confirmationScript(required) {
166
- const { plan, text, choicesParam, affirmative } = required;
174
+ const { plan, text, choicesParam, affirmative, groupedChoices, initiallyCheckedIds } = required;
175
+ const checkedSeed = initiallyCheckedIds.length === 0 ? '' : `
176
+ var initiallyCheckedIds = ${escapeJsValue(initiallyCheckedIds)};
177
+ for (var d = 0; d < initiallyCheckedIds.length; d++) checkedIds[initiallyCheckedIds[d]] = true;`;
178
+ const groupedChoiceIdentity = groupedChoices ? `
179
+ if (!choiceInputs[c].hasAttribute("data-mcpui-choice")) choiceInputs[c].setAttribute("data-mcpui-choice", choiceInputs[c].value);` : '';
167
180
  return `(function () {
168
181
  "use strict";
169
182
  ${SURFACE_SCRIPT_PRELUDE}
@@ -234,9 +247,9 @@ ${SURFACE_SCRIPT_PRELUDE}
234
247
  // the buttons, extended to the one other interactive element this document can contain. Keyed by
235
248
  // \`data-mcpui-choice\` (the caller's id), not DOM order, so a checkbox reordering upstream could
236
249
  // never silently swap which id a tick reports.
237
- var choiceInputs = Array.prototype.slice.call(document.querySelectorAll("[data-mcpui-choice]"));
238
- var checkedIds = {};
239
- for (var c = 0; c < choiceInputs.length; c++) {
250
+ var choiceInputs = Array.prototype.slice.call(document.querySelectorAll(${escapeJsValue(groupedChoices ? '[data-mcpui-choice], .mcpui-choice-group input' : '[data-mcpui-choice]')}));
251
+ var checkedIds = Object.create(null);${checkedSeed}
252
+ for (var c = 0; c < choiceInputs.length; c++) {${groupedChoiceIdentity}
240
253
  choiceInputs[c].addEventListener("change", onChoiceChange);
241
254
  }
242
255
 
@@ -325,7 +338,9 @@ export function renderConfirmationDocument(spec) {
325
338
  return renderSurfaceDocument({
326
339
  title: spec.title,
327
340
  bodyHtml: confirmationBodyHtml(spec, { affirmative }),
328
- script: confirmationScript({ plan: confirmationPlan(spec, { alternatives }), text, choicesParam, affirmative }),
341
+ script: confirmationScript({ plan: confirmationPlan(spec, { alternatives }), text, choicesParam, affirmative,
342
+ groupedChoices: spec.choicesLabel !== undefined,
343
+ initiallyCheckedIds: (spec.choices ?? []).filter(choice => choice.checked === true).map(choice => choice.id) }),
329
344
  app: spec.app ?? DEFAULT_APP,
330
345
  ...(spec.lang === undefined ? {} : { lang: spec.lang }),
331
346
  ...(spec.tokens === undefined ? {} : { tokens: spec.tokens }),
@@ -1,3 +1,5 @@
1
+ import type { SurfaceStatusText } from '@jini-ai/core/contracts/cards';
2
+ export type { SurfaceStatusText } from '@jini-ai/core/contracts/cards';
1
3
  import { type BridgeScriptSpec } from './bridge.js';
2
4
  import { type SurfaceTokenName } from './tokens.js';
3
5
  import { type SurfaceDetail } from './structured-details.js';
@@ -10,7 +12,7 @@ export type { SurfaceDetail } from './structured-details.js';
10
12
  * be a color no caller could reskin. `var(--x, fallback)` appears only where a value is genuinely
11
13
  * optional.
12
14
  */
13
- export declare const SURFACE_BASE_CSS = "*, *::before, *::after { box-sizing: border-box; }\nhtml, body { margin: 0; padding: 0; }\nbody {\n /* Transparent, not var(--jini-mcpui-bg): this document has no page of its own to paint. It is an\n allow-scripts-only sandboxed iframe embedded directly in a host's chat transcript, and html's\n background is left at its (also transparent) initial value, so the host's own pane shows\n straight through to .mcpui-surface below rather than through a second, unrelated rectangle of\n fill color sitting between the two. --jini-mcpui-bg stays declared for a caller styling\n something else via extraCss -- nothing in this stylesheet reads it anymore. */\n background: transparent;\n color: var(--jini-mcpui-text);\n font-family: var(--jini-mcpui-font);\n font-size: 14px;\n line-height: 1.5;\n padding: 16px;\n -webkit-font-smoothing: antialiased;\n}\n.mcpui-surface {\n background: linear-gradient(135deg,\n color-mix(in srgb, var(--jini-mcpui-accent) 5%, var(--jini-mcpui-panel)) 0%,\n var(--jini-mcpui-panel) 60%);\n border: 1px solid color-mix(in srgb, var(--jini-mcpui-accent) 18%, var(--jini-mcpui-border));\n border-radius: var(--jini-mcpui-radius-md);\n box-shadow: var(--jini-mcpui-surface-shadow);\n padding: 18px 20px 16px;\n max-width: 640px;\n margin: 0 auto;\n}\n.mcpui-title {\n margin: 0;\n font-size: 16px;\n font-weight: 600;\n letter-spacing: -0.01em;\n color: var(--jini-mcpui-text-strong);\n}\n.mcpui-description { margin: 6px 0 0; color: var(--jini-mcpui-text-muted); }\n/* fit-content(40%), not max-content: one long label used to take the whole row and squeeze every\n value to one character per line. Labels wrap at 40% instead. */\n.mcpui-details {\n display: grid;\n grid-template-columns: fit-content(40%) minmax(0, 1fr);\n gap: 4px 14px;\n margin: 14px 0 0;\n}\n.mcpui-details dt { color: var(--jini-mcpui-text-soft); font-weight: 500; overflow-wrap: anywhere; }\n.mcpui-details dd { margin: 0; overflow-wrap: anywhere; color: var(--jini-mcpui-text); }\n.mcpui-details dt .mcpui-hint { display: block; font-weight: 400; }\n/* A nested group (a tool's input fields) gets the card's full width, not the narrow value column. */\n.mcpui-details > dt:has(+ dd > .mcpui-detail-group),\n.mcpui-details > dd:has(> .mcpui-detail-group) { grid-column: 1 / -1; }\n.mcpui-details > dt:has(+ dd > .mcpui-detail-group) { margin-bottom: 6px; }\n.mcpui-details-outcome { display: flex; flex-direction: column; gap: 8px; }\n.mcpui-outcome-row { display: flex; align-items: flex-start; gap: 14px; }\n.mcpui-outcome-row dt { flex: 1; min-width: 0; overflow-wrap: anywhere; }\n.mcpui-outcome-row dt .mcpui-hint { display: block; font-weight: 400; }\n.mcpui-outcome-row dd { flex: 1; min-width: 0; }\n/* Capped so a long status cannot squeeze the label back to one character per line; the full text\n stays in the cell's title. */\n.mcpui-outcome-row dd.mcpui-detail-status {\n flex: 0 1 auto; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\n}\n/* Frames up to 480px: stack each label above its value so the value gets the full width.\n Outcome lists keep their own row layout. */\n@media (max-width: 480px) {\n .mcpui-details:not(.mcpui-details-outcome) { grid-template-columns: minmax(0, 1fr); row-gap: 0; }\n .mcpui-details:not(.mcpui-details-outcome) dd { margin-bottom: 8px; }\n}\n/* The iframe has 16px body padding on each side: 352px viewport = 320px card. Stacked, the value\n has the full width, so it wraps between words instead of truncating. */\n@media (max-width: 352px) {\n .mcpui-outcome-row { flex-direction: column; gap: 2px; }\n .mcpui-outcome-row dd.mcpui-detail-status { max-width: 100%; white-space: normal; overflow-wrap: normal; }\n}\n.mcpui-code {\n margin: 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n max-height: 16em;\n overflow: auto;\n font-family: var(--jini-mcpui-font-mono);\n font-size: 12.5px;\n line-height: 1.45;\n padding: 6px 8px;\n border: 1px solid var(--jini-mcpui-border);\n border-radius: var(--jini-mcpui-radius-sm);\n background: var(--jini-mcpui-bg);\n}\n.mcpui-warning {\n margin: 14px 0 0;\n padding: 9px 11px;\n border-radius: var(--jini-mcpui-radius-md);\n border: 1px solid var(--jini-mcpui-danger);\n background: var(--jini-mcpui-danger-tint);\n color: var(--jini-mcpui-text-strong);\n}\n.mcpui-fields { display: flex; flex-direction: column; gap: 12px; margin: 16px 0 0; border: 0; padding: 0; }\n.mcpui-field { display: flex; flex-direction: column; gap: 4px; }\n.mcpui-field-inline { flex-direction: row; align-items: flex-start; gap: 8px; }\n.mcpui-label { font-weight: 500; color: var(--jini-mcpui-text-strong); }\n.mcpui-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }\n.mcpui-required { color: var(--jini-mcpui-accent); margin-left: 2px; }\n.mcpui-hint { color: var(--jini-mcpui-text-soft); font-size: 13px; }\n.mcpui-input, .mcpui-select, .mcpui-textarea {\n font: inherit;\n color: var(--jini-mcpui-text);\n background: var(--jini-mcpui-panel);\n border: 1px solid color-mix(in srgb, var(--jini-mcpui-accent) 14%, var(--jini-mcpui-border-strong));\n border-radius: var(--jini-mcpui-radius-sm);\n padding: 7px 9px;\n width: 100%;\n min-width: 0;\n}\n.mcpui-textarea { resize: vertical; min-height: 72px; font-family: var(--jini-mcpui-font); }\n/* A secret control's eye toggle sits inside the field's right edge. The control is padded so long\n values never run under it; the button is a 40px tap target centred on the input, transparent,\n so it overhangs the ~36px input invisibly instead of resizing the field. */\n.mcpui-secret { position: relative; display: flex; flex-direction: column; }\n.mcpui-secret > .mcpui-input, .mcpui-secret > .mcpui-textarea { padding-right: 44px; }\n.mcpui-secret-toggle {\n position: absolute;\n top: 50%;\n right: 0;\n width: 40px;\n height: 40px;\n margin-top: -20px;\n padding: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border: 0;\n border-radius: var(--jini-mcpui-radius-sm);\n background: transparent;\n color: var(--jini-mcpui-text-soft);\n cursor: pointer;\n}\n.mcpui-secret > .mcpui-textarea + .mcpui-secret-toggle { top: 0; margin-top: -2px; }\n.mcpui-secret-toggle:hover:not([disabled]) { color: var(--jini-mcpui-text-strong); }\n.mcpui-secret-toggle[disabled] { opacity: 0.55; cursor: default; }\n.mcpui-secret-toggle:focus-visible { outline: 2px solid var(--jini-mcpui-accent-ring); outline-offset: -6px; }\n.mcpui-secret-toggle[aria-pressed=\"true\"] .mcpui-secret-icon-show,\n.mcpui-secret-toggle:not([aria-pressed=\"true\"]) .mcpui-secret-icon-hide { display: none; }\n.mcpui-checkbox { margin: 3px 0 0; accent-color: var(--jini-mcpui-accent); }\n.mcpui-choice-group { border: 0; padding: 0; margin: 0; min-width: 0; }\n.mcpui-choice { display: flex; flex-direction: row; align-items: flex-start; gap: 8px; margin: 6px 0 0; }\n.mcpui-choice-label { color: var(--jini-mcpui-text); font-weight: 400; }\n.mcpui-input:focus-visible, .mcpui-select:focus-visible, .mcpui-textarea:focus-visible,\n.mcpui-checkbox:focus-visible, .mcpui-button:focus-visible {\n outline: 2px solid var(--jini-mcpui-accent-ring);\n outline-offset: 1px;\n border-color: var(--jini-mcpui-accent);\n}\n.mcpui-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; }\n.mcpui-button {\n font: inherit;\n font-weight: 500;\n padding: 7px 15px;\n border-radius: var(--jini-mcpui-radius-pill);\n border: 1px solid color-mix(in srgb, var(--jini-mcpui-accent) 14%, var(--jini-mcpui-border-strong));\n background: var(--jini-mcpui-panel);\n color: var(--jini-mcpui-text);\n cursor: pointer;\n}\n.mcpui-button:hover:not([disabled]) { background: var(--jini-mcpui-accent-tint); }\n.mcpui-button-primary {\n background: var(--jini-mcpui-accent);\n border-color: var(--jini-mcpui-accent);\n color: var(--jini-mcpui-accent-ink);\n}\n.mcpui-button-primary:hover:not([disabled]) { background: var(--jini-mcpui-accent-hover); border-color: var(--jini-mcpui-accent-hover); }\n.mcpui-button-danger {\n background: var(--jini-mcpui-danger);\n border-color: var(--jini-mcpui-danger);\n color: var(--jini-mcpui-panel);\n}\n.mcpui-button-danger:hover:not([disabled]) { background: var(--jini-mcpui-danger-hover); border-color: var(--jini-mcpui-danger-hover); }\n.mcpui-button[disabled] { opacity: 0.55; cursor: default; }\n.mcpui-status { margin: 12px 0 0; min-height: 1.4em; color: var(--jini-mcpui-text-muted); }\n.mcpui-status[data-state=\"failed\"], .mcpui-status[data-state=\"invalid\"], .mcpui-status[data-state=\"expired\"] { color: var(--jini-mcpui-danger); }\n.mcpui-status[data-state=\"done\"] { color: var(--jini-mcpui-text-strong); }\n/* Neither a plain success nor a failure \u2014 e.g. an outcome surface reporting \"uploaded, not yet\n reachable\" (outcome.ts's own state: partial). Distinct from both --jini-mcpui-danger (would\n wrongly read as \"this failed\") and --jini-mcpui-text-strong (would wrongly read as \"this is\n fully done\"); the accent token reads as \"worth a second look\" without asserting either. */\n.mcpui-status[data-state=\"partial\"] { color: var(--jini-mcpui-accent); }\n.mcpui-code { font-family: var(--jini-mcpui-font-mono); font-size: 13px; color: var(--jini-mcpui-text-faint); }";
15
+ export declare const SURFACE_BASE_CSS = "*, *::before, *::after { box-sizing: border-box; }\nhtml, body { margin: 0; padding: 0; }\nbody {\n /* Transparent, not var(--jini-mcpui-bg): this document has no page of its own to paint. It is an\n allow-scripts-only sandboxed iframe embedded directly in a host's chat transcript, and html's\n background is left at its (also transparent) initial value, so the host's own pane shows\n straight through to .mcpui-surface below rather than through a second, unrelated rectangle of\n fill color sitting between the two. --jini-mcpui-bg stays declared for a caller styling\n something else via extraCss -- nothing in this stylesheet reads it anymore. */\n background: transparent;\n color: var(--jini-mcpui-text);\n font-family: var(--jini-mcpui-font);\n font-size: 14px;\n line-height: 1.5;\n padding: 16px;\n -webkit-font-smoothing: antialiased;\n}\n.mcpui-surface {\n background: linear-gradient(135deg,\n color-mix(in srgb, var(--jini-mcpui-accent) 5%, var(--jini-mcpui-panel)) 0%,\n var(--jini-mcpui-panel) 60%);\n border: 1px solid color-mix(in srgb, var(--jini-mcpui-accent) 18%, var(--jini-mcpui-border));\n border-radius: var(--jini-mcpui-radius-md);\n box-shadow: var(--jini-mcpui-surface-shadow);\n padding: 18px 20px 16px;\n max-width: 640px;\n margin: 0 auto;\n}\n.mcpui-title {\n margin: 0;\n font-size: 16px;\n font-weight: 600;\n letter-spacing: -0.01em;\n color: var(--jini-mcpui-text-strong);\n}\n.mcpui-description { margin: 6px 0 0; color: var(--jini-mcpui-text-muted); }\n/* fit-content(40%), not max-content: one long label used to take the whole row and squeeze every\n value to one character per line. Labels wrap at 40% instead. */\n.mcpui-details {\n display: grid;\n grid-template-columns: fit-content(40%) minmax(0, 1fr);\n gap: 4px 14px;\n margin: 14px 0 0;\n}\n.mcpui-details dt { color: var(--jini-mcpui-text-soft); font-weight: 500; overflow-wrap: anywhere; }\n.mcpui-details dd { margin: 0; overflow-wrap: anywhere; color: var(--jini-mcpui-text); }\n.mcpui-details dt .mcpui-hint { display: block; font-weight: 400; }\n/* A nested group (a tool's input fields) gets the card's full width, not the narrow value column. */\n.mcpui-details > dt:has(+ dd > .mcpui-detail-group),\n.mcpui-details > dd:has(> .mcpui-detail-group) { grid-column: 1 / -1; }\n.mcpui-details > dt:has(+ dd > .mcpui-detail-group) { margin-bottom: 6px; }\n.mcpui-details-outcome { display: flex; flex-direction: column; gap: 8px; }\n.mcpui-outcome-row { display: flex; align-items: flex-start; gap: 14px; }\n.mcpui-outcome-row dt { flex: 1; min-width: 0; overflow-wrap: anywhere; }\n.mcpui-outcome-row dt .mcpui-hint { display: block; font-weight: 400; }\n.mcpui-outcome-row dd { flex: 1; min-width: 0; }\n/* Capped so a long status cannot squeeze the label back to one character per line; the full text\n stays in the cell's title. */\n.mcpui-outcome-row dd.mcpui-detail-status {\n flex: 0 1 auto; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\n}\n/* Frames up to 480px: stack each label above its value so the value gets the full width.\n Outcome lists keep their own row layout. */\n@media (max-width: 480px) {\n .mcpui-details:not(.mcpui-details-outcome) { grid-template-columns: minmax(0, 1fr); row-gap: 0; }\n .mcpui-details:not(.mcpui-details-outcome) dd { margin-bottom: 8px; }\n}\n/* The iframe has 16px body padding on each side: 352px viewport = 320px card. Stacked, the value\n has the full width, so it wraps between words instead of truncating. */\n@media (max-width: 352px) {\n .mcpui-outcome-row { flex-direction: column; gap: 2px; }\n .mcpui-outcome-row dd.mcpui-detail-status { max-width: 100%; white-space: normal; overflow-wrap: normal; }\n}\n/* A finger needs 44px; a mouse keeps the compact layout. */\n@media (pointer: coarse) {\n .mcpui-input, .mcpui-select, .mcpui-textarea, .mcpui-button { min-height: 44px; }\n}\n.mcpui-code {\n margin: 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n max-height: 16em;\n overflow: auto;\n font-family: var(--jini-mcpui-font-mono);\n font-size: 12.5px;\n line-height: 1.45;\n padding: 6px 8px;\n border: 1px solid var(--jini-mcpui-border);\n border-radius: var(--jini-mcpui-radius-sm);\n background: var(--jini-mcpui-bg);\n}\n.mcpui-warning {\n margin: 14px 0 0;\n padding: 9px 11px;\n border-radius: var(--jini-mcpui-radius-md);\n border: 1px solid var(--jini-mcpui-danger);\n background: var(--jini-mcpui-danger-tint);\n color: var(--jini-mcpui-text-strong);\n}\n.mcpui-fields { display: flex; flex-direction: column; gap: 12px; margin: 16px 0 0; border: 0; padding: 0; }\n.mcpui-field { display: flex; flex-direction: column; gap: 4px; }\n.mcpui-field-inline { flex-direction: row; align-items: flex-start; gap: 8px; }\n.mcpui-label { font-weight: 500; color: var(--jini-mcpui-text-strong); }\n.mcpui-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }\n.mcpui-required { color: var(--jini-mcpui-accent); margin-left: 2px; }\n.mcpui-hint { color: var(--jini-mcpui-text-soft); font-size: 13px; }\n.mcpui-input, .mcpui-select, .mcpui-textarea {\n font: inherit;\n color: var(--jini-mcpui-text);\n background: var(--jini-mcpui-panel);\n border: 1px solid color-mix(in srgb, var(--jini-mcpui-accent) 14%, var(--jini-mcpui-border-strong));\n border-radius: var(--jini-mcpui-radius-sm);\n padding: 7px 9px;\n width: 100%;\n min-width: 0;\n}\n.mcpui-textarea { resize: vertical; min-height: 72px; font-family: var(--jini-mcpui-font); }\n/* A secret control's eye toggle sits inside the field's right edge. The control is padded so long\n values never run under it; the button is a 40px tap target centred on the input, transparent,\n so it overhangs the ~36px input invisibly instead of resizing the field. */\n.mcpui-secret { position: relative; display: flex; flex-direction: column; }\n.mcpui-secret > .mcpui-input, .mcpui-secret > .mcpui-textarea { padding-right: 44px; }\n.mcpui-secret-toggle {\n position: absolute;\n top: 50%;\n right: 0;\n width: 40px;\n height: 40px;\n margin-top: -20px;\n padding: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border: 0;\n border-radius: var(--jini-mcpui-radius-sm);\n background: transparent;\n color: var(--jini-mcpui-text-soft);\n cursor: pointer;\n}\n.mcpui-secret > .mcpui-textarea + .mcpui-secret-toggle { top: 0; margin-top: -2px; }\n.mcpui-secret-toggle:hover:not([disabled]) { color: var(--jini-mcpui-text-strong); }\n.mcpui-secret-toggle[disabled] { opacity: 0.55; cursor: default; }\n.mcpui-secret-toggle:focus-visible { outline: 2px solid var(--jini-mcpui-accent-ring); outline-offset: -6px; }\n.mcpui-secret-toggle[aria-pressed=\"true\"] .mcpui-secret-icon-show,\n.mcpui-secret-toggle:not([aria-pressed=\"true\"]) .mcpui-secret-icon-hide { display: none; }\n.mcpui-checkbox { margin: 3px 0 0; accent-color: var(--jini-mcpui-accent); }\n.mcpui-choice-group { border: 0; padding: 0; margin: 0; min-width: 0; }\n.mcpui-choice { display: flex; flex-direction: row; align-items: flex-start; gap: 8px; margin: 6px 0 0; }\n.mcpui-choice-label { color: var(--jini-mcpui-text); font-weight: 400; }\n.mcpui-input:focus-visible, .mcpui-select:focus-visible, .mcpui-textarea:focus-visible,\n.mcpui-checkbox:focus-visible, .mcpui-button:focus-visible {\n outline: 2px solid var(--jini-mcpui-accent-ring);\n outline-offset: 1px;\n border-color: var(--jini-mcpui-accent);\n}\n.mcpui-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; }\n.mcpui-button {\n font: inherit;\n font-weight: 500;\n padding: 7px 15px;\n border-radius: var(--jini-mcpui-radius-pill);\n border: 1px solid color-mix(in srgb, var(--jini-mcpui-accent) 14%, var(--jini-mcpui-border-strong));\n background: var(--jini-mcpui-panel);\n color: var(--jini-mcpui-text);\n cursor: pointer;\n}\n.mcpui-button:hover:not([disabled]) { background: var(--jini-mcpui-accent-tint); }\n.mcpui-button-primary {\n background: var(--jini-mcpui-accent);\n border-color: var(--jini-mcpui-accent);\n color: var(--jini-mcpui-accent-ink);\n}\n.mcpui-button-primary:hover:not([disabled]) { background: var(--jini-mcpui-accent-hover); border-color: var(--jini-mcpui-accent-hover); }\n.mcpui-button-danger {\n background: var(--jini-mcpui-danger);\n border-color: var(--jini-mcpui-danger);\n color: var(--jini-mcpui-panel);\n}\n.mcpui-button-danger:hover:not([disabled]) { background: var(--jini-mcpui-danger-hover); border-color: var(--jini-mcpui-danger-hover); }\n.mcpui-button[disabled] { opacity: 0.55; cursor: default; }\n.mcpui-status { margin: 12px 0 0; min-height: 1.4em; color: var(--jini-mcpui-text-muted); }\n.mcpui-status[data-state=\"failed\"], .mcpui-status[data-state=\"invalid\"], .mcpui-status[data-state=\"expired\"] { color: var(--jini-mcpui-danger); }\n.mcpui-status[data-state=\"done\"] { color: var(--jini-mcpui-text-strong); }\n/* Neither a plain success nor a failure \u2014 e.g. an outcome surface reporting \"uploaded, not yet\n reachable\" (outcome.ts's own state: partial). Distinct from both --jini-mcpui-danger (would\n wrongly read as \"this failed\") and --jini-mcpui-text-strong (would wrongly read as \"this is\n fully done\"); the accent token reads as \"worth a second look\" without asserting either. */\n.mcpui-status[data-state=\"partial\"] { color: var(--jini-mcpui-accent); }\n.mcpui-code { font-family: var(--jini-mcpui-font-mono); font-size: 13px; color: var(--jini-mcpui-text-faint); }";
14
16
  /**
15
17
  * The Content-Security-Policy every generated surface declares in its own `<head>`.
16
18
  *
@@ -85,27 +87,6 @@ export declare function renderStatusRegion(): string;
85
87
  export declare const SURFACE_NOT_PENDING_ERROR_CODE = "SURFACE_NOT_PENDING";
86
88
  /** The id {@link renderStatusRegion} emits and {@link SURFACE_SCRIPT_PRELUDE} looks up. */
87
89
  export declare const SURFACE_STATUS_ELEMENT_ID = "mcpui-status";
88
- /**
89
- * Every user-visible string a surface's script writes at runtime.
90
- *
91
- * Surfaces are HTML strings built outside React, so `features/i18n`'s `useT` cannot reach them — a
92
- * translated surface is one whose builder was handed translated text. These are the defaults for a
93
- * caller that has none.
94
- */
95
- export interface SurfaceStatusText {
96
- /** Shown while a tool call is in flight. */
97
- readonly working: string;
98
- /** Shown when the call resolves. */
99
- readonly done: string;
100
- /** Prefixed to the Host's own error message when the call rejects. */
101
- readonly failedPrefix: string;
102
- /** Shown when the human dismisses a surface that has no cancel tool to call. */
103
- readonly dismissed: string;
104
- /** Prefixed to the comma-joined labels of unfilled required fields. */
105
- readonly missingPrefix: string;
106
- /** Shown when the Host says the dialog is no longer pending; the buttons stay disabled. */
107
- readonly expired: string;
108
- }
109
90
  export declare const DEFAULT_SURFACE_STATUS_TEXT: SurfaceStatusText;
110
91
  /**
111
92
  * The JavaScript preamble every surface script opens with: the bridge handle, the status region,
@@ -97,6 +97,10 @@ body {
97
97
  .mcpui-outcome-row { flex-direction: column; gap: 2px; }
98
98
  .mcpui-outcome-row dd.mcpui-detail-status { max-width: 100%; white-space: normal; overflow-wrap: normal; }
99
99
  }
100
+ /* A finger needs 44px; a mouse keeps the compact layout. */
101
+ @media (pointer: coarse) {
102
+ .mcpui-input, .mcpui-select, .mcpui-textarea, .mcpui-button { min-height: 44px; }
103
+ }
100
104
  .mcpui-code {
101
105
  margin: 0;
102
106
  white-space: pre-wrap;
@@ -1,77 +1,6 @@
1
- import { type SelectOption } from './select.js';
1
+ import type { SurfaceField } from '@jini-ai/core/contracts/cards';
2
+ export type { StringField, NumberField, BooleanField, EnumField, MultiEnumField, SurfaceField } from '@jini-ai/core/contracts/cards';
2
3
  import { type SecretInputText } from './text-input.js';
3
- interface SurfaceFieldBase {
4
- /** HTML `name`, DOM `id` suffix, and the params key the value is posted under. */
5
- readonly name: string;
6
- readonly label: string;
7
- /** Help text, wired up with `aria-describedby`. */
8
- readonly hint?: string;
9
- readonly required?: boolean;
10
- /** Waive on an exact choice or an alternative control; headerNames restricts entered headers. Kept secrets are validated by the host. */
11
- readonly requiredUnless?: {
12
- readonly field: string;
13
- readonly equals: string;
14
- readonly orPresent?: string;
15
- readonly headerNames?: readonly string[];
16
- };
17
- /** Require only while the controlling public field matches one of these choices. */
18
- readonly requiredWhen?: {
19
- readonly field: string;
20
- readonly in: readonly string[];
21
- };
22
- readonly disabled?: boolean;
23
- }
24
- export interface StringField extends SurfaceFieldBase {
25
- readonly kind: 'string';
26
- /** A sealed saved value satisfies validation while the requirement remains visible. */
27
- readonly hasSavedValue?: boolean;
28
- readonly value?: string;
29
- readonly placeholder?: string;
30
- readonly multiline?: boolean;
31
- readonly rows?: number;
32
- /** Renders as a masked input or multiline textarea; pre-filled values are forbidden.
33
- * See {@link TextInputProps.secret}. */
34
- readonly secret?: boolean;
35
- }
36
- export interface NumberField extends SurfaceFieldBase {
37
- readonly kind: 'number';
38
- readonly value?: number;
39
- readonly placeholder?: string;
40
- readonly min?: number;
41
- readonly max?: number;
42
- readonly step?: number;
43
- }
44
- export interface BooleanField extends SurfaceFieldBase {
45
- readonly kind: 'boolean';
46
- readonly value?: boolean;
47
- }
48
- export interface EnumField extends SurfaceFieldBase {
49
- readonly kind: 'enum';
50
- readonly value?: string;
51
- readonly options: readonly SelectOption[];
52
- readonly placeholder?: string;
53
- /**
54
- * How the same one-of-N value is drawn. `select` (the default) hides the options until opened —
55
- * right for a long list; `radio` shows them all at once — right for a short one the human is
56
- * meant to compare before choosing. Presentation only: both post one string under `name`, and
57
- * both read back through the same `control.value` path, so `kind` stays `'enum'` either way.
58
- */
59
- readonly presentation?: 'select' | 'radio';
60
- }
61
- /**
62
- * A pick-any-number-of-N field.
63
- *
64
- * Its own kind rather than a flag on {@link EnumField}, because it is the only field whose value is
65
- * an **array** — `form.ts`'s `readField` and `isBlank` both branch on that, and no `presentation`
66
- * discriminator would have told them to.
67
- */
68
- export interface MultiEnumField extends SurfaceFieldBase {
69
- readonly kind: 'multi-enum';
70
- /** Pre-checked values. Unknown entries check nothing rather than erroring. */
71
- readonly value?: readonly string[];
72
- readonly options: readonly SelectOption[];
73
- }
74
- export type SurfaceField = StringField | NumberField | BooleanField | EnumField | MultiEnumField;
75
4
  /** Presentation the form decides for a field, not part of the field's own data. */
76
5
  export interface FieldRenderOptions {
77
6
  /** The label repeats the card title: keep it as the accessible name, but don't show it twice. */
@@ -109,5 +38,4 @@ export interface FieldReadSpec {
109
38
  }
110
39
  /** Projects fields to runtime validation data; conditional requirements also carry their guidance. */
111
40
  export declare function toFieldReadSpecs(fields: readonly SurfaceField[]): readonly FieldReadSpec[];
112
- export {};
113
41
  //# sourceMappingURL=fields.d.ts.map
@@ -1,3 +1,5 @@
1
+ import type { FormSurfaceSpec } from '@jini-ai/core/contracts/cards';
2
+ export type { FormSurfaceSpec } from '@jini-ai/core/contracts/cards';
1
3
  /**
2
4
  * @module features/mcp-ui/surfaces/form
3
5
  *
@@ -24,48 +26,6 @@
24
26
  * `boolean` reads `checked`, and `string`/`enum` pass through.
25
27
  */
26
28
  import { type UIResource, type UIResourceUri } from '../resource.js';
27
- import { type SurfaceDetail, type SurfaceStatusText } from './document.js';
28
- import { type SurfaceField } from './fields.js';
29
- import type { BridgeScriptSpec } from './bridge.js';
30
- import type { SurfaceTokenName } from './tokens.js';
31
- import { type SecretInputText } from './text-input.js';
32
- export interface FormSurfaceSpec {
33
- readonly title: string;
34
- /** Resource framing carried through host form projections; ignored by HTML rendering. */
35
- readonly preferredFrameSize?: readonly [string, string];
36
- readonly description?: string;
37
- /** Read-only context shown above the fields — what the input is *about*. */
38
- readonly details?: readonly SurfaceDetail[];
39
- readonly fields: readonly SurfaceField[];
40
- /** Callout above the buttons. */
41
- readonly warning?: string;
42
- /** Styles the submit button as destructive. */
43
- readonly danger?: boolean;
44
- readonly submitLabel: string;
45
- /** Alternative submit buttons collect the same fields, with explicit action params. */
46
- readonly additionalSubmitActions?: readonly {
47
- readonly id: string;
48
- readonly label: string;
49
- readonly params: Readonly<Record<string, unknown>>;
50
- }[];
51
- /** The tool the collected values are sent to. */
52
- readonly toolName: string;
53
- /**
54
- * Merged UNDER the collected field values, so a field can never be shadowed by a base param it
55
- * shares a name with. Where a confirmation token belongs when the form is a confirmation.
56
- */
57
- readonly baseParams?: Readonly<Record<string, unknown>>;
58
- /** Omit for a form with no cancel button. Give it a tool name to notify the server of the dismissal. */
59
- readonly cancel?: {
60
- readonly label: string;
61
- readonly toolName?: string;
62
- readonly params?: Readonly<Record<string, unknown>>;
63
- };
64
- readonly text?: Partial<SurfaceStatusText & SecretInputText>;
65
- readonly app?: BridgeScriptSpec;
66
- readonly lang?: string;
67
- readonly tokens?: Partial<Record<SurfaceTokenName, string>>;
68
- }
69
29
  /**
70
30
  * Renders the form dialog as a complete, self-contained HTML document.
71
31
  *
@@ -11,4 +11,5 @@ export * from './select.js';
11
11
  export * from './text-input.js';
12
12
  export * from './tokens.js';
13
13
  export * from './tool-approval.js';
14
+ export * from './access-approval.js';
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -11,4 +11,5 @@ export * from './select.js';
11
11
  export * from './text-input.js';
12
12
  export * from './tokens.js';
13
13
  export * from './tool-approval.js';
14
+ export * from './access-approval.js';
14
15
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,5 @@
1
+ import type { SurfaceOutcomeSpec } from '@jini-ai/core/contracts/cards';
2
+ export type { SurfaceOutcomeSpec } from '@jini-ai/core/contracts/cards';
1
3
  /**
2
4
  * @module features/mcp-ui/surfaces/outcome
3
5
  *
@@ -46,45 +48,6 @@
46
48
  * navigating. Ordinary completed outcomes retain their read-only contract.
47
49
  */
48
50
  import { type UIResource, type UIResourceUri } from '../resource.js';
49
- import { type SurfaceDetail } from './document.js';
50
- import type { ConfirmationToolAction } from './confirmation.js';
51
- import type { BridgeScriptSpec } from './bridge.js';
52
- import type { SurfaceTokenName } from './tokens.js';
53
- export interface SurfaceOutcomeSpec {
54
- readonly title: string;
55
- /** Resource framing carried through host outcome projections; ignored by HTML rendering. */
56
- readonly preferredFrameSize?: readonly [string, string];
57
- readonly description?: string;
58
- /** The facts of what actually happened — same shape as a confirmation's own `details`, but
59
- * reporting the RESULT (e.g. the real URL, the real status) rather than what was proposed. */
60
- readonly details?: readonly SurfaceDetail[];
61
- /**
62
- * Styles the status line and, when {@link openLinkUrl} is also present, the open-link button.
63
- * THREE states, not a boolean — matching this package's own callers, which distinguish a genuine
64
- * partial outcome (e.g. a downstream product's static-publish "uploaded, but not yet confirmed reachable") from
65
- * both a plain success and a plain failure specifically so neither is misreported: folding
66
- * `'partial'` into `'success'` would claim something is live when it may not be reachable yet;
67
- * folding it into `'failure'` would hide that the operation itself did NOT fail (nothing needs
68
- * retrying, only a separate follow-up step). See `document.ts`'s own `[data-state="partial"]` rule
69
- * for why this needs a third visual state as well as a third value here, not merely a third string
70
- * that renders identically to one of the other two.
71
- */
72
- readonly state: 'success' | 'partial' | 'failure';
73
- /** The one human-facing sentence explaining the outcome — the actionable message on failure, or a
74
- * short confirmation on success. Never a raw credential or provider response body; that boundary
75
- * is the CALLER's responsibility (this builder only renders what it is given). */
76
- readonly message: string;
77
- /** When present, renders one button ("Open site" by default) that calls the bridge's `openLink`.
78
- * Only meaningful alongside `state: 'success'` — a caller should not supply this for a failure. */
79
- readonly openLinkUrl?: string;
80
- readonly openLinkLabel?: string;
81
- /** A pending external action may be skipped through its existing surface exchange. */
82
- readonly cancel?: ConfirmationToolAction;
83
- /** Identity reported to the Host in `ui/initialize`. Defaults to a generic one. */
84
- readonly app?: BridgeScriptSpec;
85
- readonly lang?: string;
86
- readonly tokens?: Partial<Record<SurfaceTokenName, string>>;
87
- }
88
51
  /**
89
52
  * Renders the outcome document as a complete, self-contained HTML document.
90
53
  *
@@ -51,6 +51,9 @@ import { DEFAULT_SURFACE_STATUS_TEXT, renderActions, renderDetailList, renderSur
51
51
  const DEFAULT_APP = { appName: 'jini-mcp-ui-outcome', appVersion: '1' };
52
52
  const DEFAULT_OPEN_LINK_LABEL = 'Open site';
53
53
  const OPEN_LINK_ACTION_ID = 'open-link';
54
+ /** How long a sign-in card waits for the Host to answer an open-link request. The bridge keeps an
55
+ * unanswered request forever, so without this deadline the card would ignore every later click. */
56
+ const OPEN_LINK_TIMEOUT_MS = 30_000;
54
57
  /** The status region's `data-state` for an outcome state. @complexity O(1). */
55
58
  function statusStateOf(state) {
56
59
  if (state === 'success')
@@ -81,11 +84,24 @@ ${SURFACE_SCRIPT_PRELUDE}
81
84
  var TEXT = ${escapeJsValue(DEFAULT_SURFACE_STATUS_TEXT)};
82
85
  var CANCEL = ${escapeJsValue(spec.cancel)};
83
86
  var OPEN_URL = ${escapeJsValue(spec.openLinkUrl ?? null)};
87
+ var OPEN_TIMEOUT_MS = ${OPEN_LINK_TIMEOUT_MS};
88
+ var OPEN_TIMEOUT_TEXT = ${escapeJsValue(`The link did not open within ${OPEN_LINK_TIMEOUT_MS / 1000} seconds. Try again.`)};
84
89
  var locked = false;
90
+ var opening = null;
85
91
  function onClick(event) {
86
92
  if (event.isTrusted !== true || locked) return;
87
93
  if (event.currentTarget.getAttribute("data-mcpui-action") === "open-link") {
88
- api.openLink(OPEN_URL);
94
+ // A repeat click while the Host is still opening the link reuses that request, not a second window.
95
+ if (opening) return;
96
+ var timer;
97
+ opening = Promise.race([
98
+ api.openLink(OPEN_URL).then(function (result) {
99
+ if (result && result.isError) throw new Error("Could not open the link.");
100
+ }),
101
+ new Promise(function (_resolve, reject) {
102
+ timer = setTimeout(function () { reject(new Error(OPEN_TIMEOUT_TEXT)); }, OPEN_TIMEOUT_MS);
103
+ }),
104
+ ]).catch(reportCallFailure).then(function () { clearTimeout(timer); opening = null; });
89
105
  return;
90
106
  }
91
107
  locked = true;
@@ -107,8 +123,15 @@ function outcomeScript(openLinkUrl) {
107
123
  "use strict";
108
124
  ${SURFACE_SCRIPT_PRELUDE}
109
125
  var OPEN_URL = ${escapeJsValue(openLinkUrl)};
126
+ var OUTCOME = statusNode.textContent;
127
+ // A refused or failed open keeps the outcome (it still happened) and says what to do instead.
128
+ function reportOpenFailure() {
129
+ statusNode.textContent = OUTCOME + " The link did not open. Try again, or copy this address into your browser: " + OPEN_URL;
130
+ }
110
131
  for (var i = 0; i < actionButtons.length; i++) {
111
- actionButtons[i].addEventListener("click", function () { api.openLink(OPEN_URL); });
132
+ actionButtons[i].addEventListener("click", function () {
133
+ api.openLink(OPEN_URL).then(function (result) { if (result && result.isError) reportOpenFailure(); }, reportOpenFailure);
134
+ });
112
135
  }
113
136
  }());`;
114
137
  }
@@ -1,10 +1,5 @@
1
- export interface SelectOption {
2
- /** The value posted back. */
3
- readonly value: string;
4
- /** What the human reads. Defaults to `value`. */
5
- readonly label?: string;
6
- readonly disabled?: boolean;
7
- }
1
+ import type { SelectOption } from '@jini-ai/core/contracts/cards';
2
+ export type { SelectOption } from '@jini-ai/core/contracts/cards';
8
3
  export interface SelectProps {
9
4
  /** HTML `name`, DOM `id` suffix, and the params key the value is posted under. */
10
5
  readonly name: string;