@jini-ai/ui 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.
- package/CHANGELOG.md +27 -0
- package/dist/features/admin-widgets/components/ImagePreviewModal.d.ts +3 -3
- package/dist/features/admin-widgets/components/ImagePreviewModal.js +3 -1
- package/dist/features/admin-widgets/components/InfoTip.d.ts +2 -2
- package/dist/features/admin-widgets/components/InfoTip.js +3 -1
- package/dist/features/admin-widgets/components/SeeMore/SeeMore.d.ts +2 -2
- package/dist/features/admin-widgets/components/SeeMore/SeeMore.js +3 -1
- package/dist/features/admin-widgets/components/Select/Select.d.ts +2 -2
- package/dist/features/admin-widgets/components/Select/Select.js +12 -8
- package/dist/features/admin-widgets/components/SuggestInput/SuggestInput.d.ts +2 -2
- package/dist/features/admin-widgets/components/SuggestInput/SuggestInput.js +3 -1
- package/dist/features/execution/react/components/SearchableModelSelect.d.ts +5 -5
- package/dist/features/execution/react/components/SearchableModelSelect.js +4 -2
- package/dist/features/interactive-ui/providers/shadcn/checkbox-field.d.ts +3 -2
- package/dist/features/interactive-ui/providers/shadcn/checkbox-field.js +5 -2
- package/dist/features/interactive-ui/providers/shadcn/select-field.d.ts +4 -2
- package/dist/features/interactive-ui/providers/shadcn/select-field.js +9 -2
- package/dist/features/interactive-ui/providers/shadcn/select.d.ts +5 -3
- package/dist/features/interactive-ui/providers/shadcn/select.js +9 -4
- package/dist/features/mcp-ui/cards.d.ts +12 -0
- package/dist/features/mcp-ui/cards.js +8 -0
- package/dist/features/mcp-ui/credential-card.d.ts +34 -0
- package/dist/features/mcp-ui/credential-card.js +42 -0
- package/dist/features/mcp-ui/secret-card.d.ts +2 -16
- package/dist/features/mcp-ui/secret-card.js +4 -1
- package/dist/features/mcp-ui/sign-in-card.d.ts +57 -0
- package/dist/features/mcp-ui/sign-in-card.js +67 -0
- package/dist/features/mcp-ui/surfaces/access-approval.d.ts +15 -0
- package/dist/features/mcp-ui/surfaces/access-approval.js +17 -0
- package/dist/features/mcp-ui/surfaces/bridge.d.ts +2 -8
- package/dist/features/mcp-ui/surfaces/confirmation.d.ts +9 -8
- package/dist/features/mcp-ui/surfaces/confirmation.js +24 -9
- package/dist/features/mcp-ui/surfaces/document.d.ts +18 -27
- package/dist/features/mcp-ui/surfaces/document.js +21 -7
- package/dist/features/mcp-ui/surfaces/fields.d.ts +2 -74
- package/dist/features/mcp-ui/surfaces/form.d.ts +2 -42
- package/dist/features/mcp-ui/surfaces/index.d.ts +1 -0
- package/dist/features/mcp-ui/surfaces/index.js +1 -0
- package/dist/features/mcp-ui/surfaces/outcome.d.ts +2 -39
- package/dist/features/mcp-ui/surfaces/outcome.js +25 -2
- package/dist/features/mcp-ui/surfaces/select.d.ts +2 -7
- package/dist/features/mcp-ui/surfaces/structured-details.d.ts +2 -19
- package/dist/features/mcp-ui/surfaces/text-input.d.ts +2 -5
- package/dist/features/mcp-ui/surfaces/tokens.d.ts +2 -2
- package/dist/features/panel-kit/failure-channel.d.ts +25 -0
- package/dist/features/panel-kit/failure-channel.js +36 -0
- package/dist/features/panel-kit/index.d.ts +2 -0
- package/dist/features/panel-kit/index.js +1 -0
- package/dist/features/site-card/SiteCard.d.ts +40 -0
- package/dist/features/site-card/SiteCard.js +15 -0
- package/dist/features/site-card/SiteListToolbar.d.ts +28 -0
- package/dist/features/site-card/SiteListToolbar.js +15 -0
- package/dist/features/site-card/index.d.ts +5 -0
- package/dist/features/site-card/index.js +5 -0
- package/dist/features/site-card/site-card.css +136 -0
- package/dist/features/site-card/site-list-view.d.ts +53 -0
- package/dist/features/site-card/site-list-view.js +62 -0
- package/dist/features/site-card/use-site-list-view.hooks.d.ts +24 -0
- package/dist/features/site-card/use-site-list-view.hooks.js +26 -0
- package/dist/features/tab-strip/react/components/TabStrip.d.ts +3 -2
- package/dist/features/tab-strip/react/components/TabStrip.js +5 -2
- package/dist/features/tab-strip/react/components/TabStripItem.d.ts +3 -2
- package/dist/features/tab-strip/react/components/TabStripItem.js +5 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/react/components/CustomSelect.d.ts +5 -3
- package/dist/react/components/CustomSelect.js +18 -11
- package/dist/react/components/PillButton.d.ts +3 -2
- package/dist/react/components/PillButton.js +5 -2
- package/dist/react/components/PopoverItem.d.ts +3 -2
- package/dist/react/components/PopoverItem.js +5 -2
- package/dist/react/components/PopoverMenu.d.ts +3 -2
- package/dist/react/components/PopoverMenu.js +5 -2
- package/dist/react/components/SecretInput.d.ts +3 -2
- package/dist/react/components/SecretInput.js +6 -3
- package/dist/react/components/select-popover.d.ts +8 -2
- package/dist/react/components/select-popover.js +8 -3
- package/dist/react/hooks/useAgentHandle.d.ts +17 -0
- package/dist/react/hooks/useAgentHandle.js +17 -0
- package/dist/styles/admin.css +1 -0
- package/package.json +38 -12
|
@@ -0,0 +1,57 @@
|
|
|
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 { type SurfaceExchangeStore, type ToolExecutionContext, type ToolExecutionOptions } from '@jini-ai/core';
|
|
4
|
+
import { type SurfaceOutcomeSpec } from './surfaces/outcome.js';
|
|
5
|
+
import type { UIResource, UIResourceUri } from './resource.js';
|
|
6
|
+
export type SignInCardState = {
|
|
7
|
+
state: 'waiting';
|
|
8
|
+
signInUrl: string;
|
|
9
|
+
exchangeId?: string;
|
|
10
|
+
} | {
|
|
11
|
+
state: 'connected' | 'skipped';
|
|
12
|
+
};
|
|
13
|
+
/** Host-owned wording and identity; no connection-provider or product types enter the engine. */
|
|
14
|
+
export interface SignInCardSpec {
|
|
15
|
+
uri: UIResourceUri;
|
|
16
|
+
toolId: string;
|
|
17
|
+
app: NonNullable<SurfaceOutcomeSpec['app']>;
|
|
18
|
+
waiting: {
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
message: string;
|
|
22
|
+
openLinkLabel: string;
|
|
23
|
+
cancelLabel: string;
|
|
24
|
+
};
|
|
25
|
+
connected: {
|
|
26
|
+
title: string;
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
skipped: {
|
|
30
|
+
title: string;
|
|
31
|
+
message: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Render the three states under one URI so the last emission replaces the waiting card.
|
|
35
|
+
* @complexity O(h) time/space in rendered HTML. @overallScore 99; Low: copy safety is host-owned. */
|
|
36
|
+
export declare function buildSignInCard(required: SignInCardSpec & SignInCardState, _optional?: {}): UIResource;
|
|
37
|
+
/** Park one connection watcher; Skip cancels only that watcher, never the enclosing run.
|
|
38
|
+
* OAuth callbacks and credential custody remain with the injected connection owner.
|
|
39
|
+
* @complexity One bounded connection wait, one exchange and at most two emissions.
|
|
40
|
+
* @overallScore 99; Low: connection callbacks must honor their abort signal. */
|
|
41
|
+
export declare function waitAtSignInCard<Result extends {
|
|
42
|
+
status: string;
|
|
43
|
+
}>(required: {
|
|
44
|
+
surfaceExchanges: Pick<SurfaceExchangeStore, 'open'>;
|
|
45
|
+
ctx: ToolExecutionContext;
|
|
46
|
+
toolId: string;
|
|
47
|
+
card: (state: SignInCardState) => UIResource;
|
|
48
|
+
missingEmitterMessage: string;
|
|
49
|
+
skippedResult: () => Result;
|
|
50
|
+
connect: (input: {
|
|
51
|
+
signal: AbortSignal;
|
|
52
|
+
showSignIn: (input: {
|
|
53
|
+
signInUrl: string;
|
|
54
|
+
}) => Promise<void>;
|
|
55
|
+
}) => Promise<Result>;
|
|
56
|
+
}, optional?: ToolExecutionOptions): Promise<Result>;
|
|
57
|
+
//# sourceMappingURL=sign-in-card.d.ts.map
|
|
@@ -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,
|
|
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
|
|
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,14 +135,17 @@ 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
|
-
renderActions(confirmationActions(spec).map((action) => (affirmative.has(action.id) ? { ...action, disabled: true } : action))),
|
|
148
|
+
renderActions(confirmationActions(spec).map((action) => (affirmative.has(action.id) ? { ...action, disabled: true } : action)), { humanOnly: true }),
|
|
141
149
|
renderStatusRegion(),
|
|
142
150
|
]
|
|
143
151
|
.filter((fragment) => fragment !== '')
|
|
@@ -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(
|
|
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,
|
|
@@ -179,16 +160,26 @@ export interface SurfaceAction {
|
|
|
179
160
|
* `script-src 'unsafe-inline'`-equivalent allowance for attributes specifically, and a host is free
|
|
180
161
|
* to apply a stricter CSP to the frame than this package can see.
|
|
181
162
|
*
|
|
182
|
-
*
|
|
163
|
+
* Ordinary buttons also carry the `@jini-ai/agentic` `data-agent-*` markup convention
|
|
183
164
|
* ({@link AGENT_ELEMENT_ATTRIBUTE} et al.) — but this tagging is advisory, not the thing that makes
|
|
184
165
|
* a surface's actions reachable by `page.find_elements`/`page.click`. Those capabilities resolve a
|
|
185
166
|
* handle by scanning `document`/`contentDocument`, and this document renders inside a `srcdoc`
|
|
186
167
|
* iframe sandboxed to `allow-scripts` alone (`MCP_UI_VIEW_SANDBOX` — no `allow-same-origin`,
|
|
187
168
|
* deliberately), which gives it an opaque origin no ancestor document can read into. So this tagging
|
|
188
169
|
* is real for a driver that reaches INTO the frame directly — `frameLocator` in Playwright, proven
|
|
189
|
-
* end to end against exactly this markup — and inert for anything scanning the parent page. Making
|
|
190
|
-
* surface's actions visible to `page.find_elements` needs a second, parent-DOM-side echo
|
|
191
|
-
*
|
|
170
|
+
* end to end against exactly this markup — and inert for anything scanning the parent page. Making an
|
|
171
|
+
* ordinary surface's actions visible to `page.find_elements` needs a second, parent-DOM-side echo
|
|
172
|
+
* of that action list. Human-only decisions are intentionally excluded from addressing even
|
|
173
|
+
* inside the frame: confirmation buttons are private and their runtime still requires trusted clicks.
|
|
174
|
+
*
|
|
175
|
+
* @param actions - Action descriptions; the legacy array argument is retained for caller compatibility.
|
|
176
|
+
* @param options - Human-only rows omit agent addressing and mark every decision private.
|
|
177
|
+
* @returns Escaped HTML without executing actions or changing their runtime click gates.
|
|
178
|
+
* @complexity O(n) time and space in the emitted markup length.
|
|
179
|
+
* @overallScore 98/100
|
|
180
|
+
* @qualityFindings Low: The legacy array-first signature remains a compatibility exception to object arguments.
|
|
192
181
|
*/
|
|
193
|
-
export declare function renderActions(actions: readonly SurfaceAction[]
|
|
182
|
+
export declare function renderActions(actions: readonly SurfaceAction[], { humanOnly }?: {
|
|
183
|
+
humanOnly?: boolean;
|
|
184
|
+
}): string;
|
|
194
185
|
//# sourceMappingURL=document.d.ts.map
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* builders because the CSS that styles them lives here — splitting the markup from the only
|
|
12
12
|
* stylesheet that can reach it is how a "generic" fragment quietly becomes unstyled in one caller.
|
|
13
13
|
*/
|
|
14
|
-
import { AGENT_ELEMENT_ATTRIBUTE, AGENT_LABEL_ATTRIBUTE, AGENT_ROLE_ATTRIBUTE } from '@jini-ai/agentic';
|
|
14
|
+
import { AGENT_ELEMENT_ATTRIBUTE, AGENT_LABEL_ATTRIBUTE, AGENT_PRIVATE_ATTRIBUTE, AGENT_ROLE_ATTRIBUTE } from '@jini-ai/agentic';
|
|
15
15
|
import { escapeHtml } from '../escape.js';
|
|
16
16
|
import { SURFACE_BRIDGE_GLOBAL, renderBridgeScript } from './bridge.js';
|
|
17
17
|
import { renderTokenBlock } from './tokens.js';
|
|
@@ -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;
|
|
@@ -429,18 +433,26 @@ export function fieldDescribedBy(spec) {
|
|
|
429
433
|
* `script-src 'unsafe-inline'`-equivalent allowance for attributes specifically, and a host is free
|
|
430
434
|
* to apply a stricter CSP to the frame than this package can see.
|
|
431
435
|
*
|
|
432
|
-
*
|
|
436
|
+
* Ordinary buttons also carry the `@jini-ai/agentic` `data-agent-*` markup convention
|
|
433
437
|
* ({@link AGENT_ELEMENT_ATTRIBUTE} et al.) — but this tagging is advisory, not the thing that makes
|
|
434
438
|
* a surface's actions reachable by `page.find_elements`/`page.click`. Those capabilities resolve a
|
|
435
439
|
* handle by scanning `document`/`contentDocument`, and this document renders inside a `srcdoc`
|
|
436
440
|
* iframe sandboxed to `allow-scripts` alone (`MCP_UI_VIEW_SANDBOX` — no `allow-same-origin`,
|
|
437
441
|
* deliberately), which gives it an opaque origin no ancestor document can read into. So this tagging
|
|
438
442
|
* is real for a driver that reaches INTO the frame directly — `frameLocator` in Playwright, proven
|
|
439
|
-
* end to end against exactly this markup — and inert for anything scanning the parent page. Making
|
|
440
|
-
* surface's actions visible to `page.find_elements` needs a second, parent-DOM-side echo
|
|
441
|
-
*
|
|
443
|
+
* end to end against exactly this markup — and inert for anything scanning the parent page. Making an
|
|
444
|
+
* ordinary surface's actions visible to `page.find_elements` needs a second, parent-DOM-side echo
|
|
445
|
+
* of that action list. Human-only decisions are intentionally excluded from addressing even
|
|
446
|
+
* inside the frame: confirmation buttons are private and their runtime still requires trusted clicks.
|
|
447
|
+
*
|
|
448
|
+
* @param actions - Action descriptions; the legacy array argument is retained for caller compatibility.
|
|
449
|
+
* @param options - Human-only rows omit agent addressing and mark every decision private.
|
|
450
|
+
* @returns Escaped HTML without executing actions or changing their runtime click gates.
|
|
451
|
+
* @complexity O(n) time and space in the emitted markup length.
|
|
452
|
+
* @overallScore 98/100
|
|
453
|
+
* @qualityFindings Low: The legacy array-first signature remains a compatibility exception to object arguments.
|
|
442
454
|
*/
|
|
443
|
-
export function renderActions(actions) {
|
|
455
|
+
export function renderActions(actions, { humanOnly = false } = {}) {
|
|
444
456
|
const buttons = actions
|
|
445
457
|
.map((action) => {
|
|
446
458
|
const variant = action.variant ?? 'neutral';
|
|
@@ -454,7 +466,9 @@ export function renderActions(actions) {
|
|
|
454
466
|
// would accept. That is unenforced on purpose (see the function doc above: `page.find_elements`
|
|
455
467
|
// can never reach this document to resolve it either way), so failing loudly here would refuse
|
|
456
468
|
// markup for a reason that can never matter to the one consumer that can actually query it.
|
|
457
|
-
|
|
469
|
+
const addressing = humanOnly ? AGENT_PRIVATE_ATTRIBUTE
|
|
470
|
+
: `${AGENT_ELEMENT_ATTRIBUTE}="mcpui-action-${escapeHtml(action.id)}" ${AGENT_ROLE_ATTRIBUTE}="button" ${AGENT_LABEL_ATTRIBUTE}="${label}"`;
|
|
471
|
+
return ` <button type="${action.type ?? 'button'}" class="mcpui-button${variantClass}" data-mcpui-action="${escapeHtml(action.id)}" ${addressing}${action.disabled === true ? ' disabled' : ''}>${label}</button>`;
|
|
458
472
|
})
|
|
459
473
|
.join('\n');
|
|
460
474
|
return `<div class="mcpui-actions">\n${buttons}\n</div>`;
|
|
@@ -1,77 +1,6 @@
|
|
|
1
|
-
import {
|
|
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
|