@jini-ai/agentic 0.1.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/LICENSE +201 -0
- package/dist/ag-ui.d.ts +82 -0
- package/dist/ag-ui.d.ts.map +1 -0
- package/dist/ag-ui.js +56 -0
- package/dist/ag-ui.js.map +1 -0
- package/dist/agui/encoder.d.ts +50 -0
- package/dist/agui/encoder.d.ts.map +1 -0
- package/dist/agui/encoder.js +97 -0
- package/dist/agui/encoder.js.map +1 -0
- package/dist/agui/events.d.ts +59 -0
- package/dist/agui/events.d.ts.map +1 -0
- package/dist/agui/events.js +15 -0
- package/dist/agui/events.js.map +1 -0
- package/dist/capability.d.ts +81 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +79 -0
- package/dist/capability.js.map +1 -0
- package/dist/dom/dom-page-driver.d.ts +29 -0
- package/dist/dom/dom-page-driver.d.ts.map +1 -0
- package/dist/dom/dom-page-driver.js +557 -0
- package/dist/dom/dom-page-driver.js.map +1 -0
- package/dist/dom/index.d.ts +17 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +17 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/dom/model-context.d.ts +54 -0
- package/dist/dom/model-context.d.ts.map +1 -0
- package/dist/dom/model-context.js +36 -0
- package/dist/dom/model-context.js.map +1 -0
- package/dist/element-handles.d.ts +99 -0
- package/dist/element-handles.d.ts.map +1 -0
- package/dist/element-handles.js +39 -0
- package/dist/element-handles.js.map +1 -0
- package/dist/gen-ui/encoder.d.ts +50 -0
- package/dist/gen-ui/encoder.d.ts.map +1 -0
- package/dist/gen-ui/encoder.js +97 -0
- package/dist/gen-ui/encoder.js.map +1 -0
- package/dist/gen-ui/events.d.ts +59 -0
- package/dist/gen-ui/events.d.ts.map +1 -0
- package/dist/gen-ui/events.js +15 -0
- package/dist/gen-ui/events.js.map +1 -0
- package/dist/gen-ui/index.d.ts +18 -0
- package/dist/gen-ui/index.d.ts.map +1 -0
- package/dist/gen-ui/index.js +17 -0
- package/dist/gen-ui/index.js.map +1 -0
- package/dist/guards.d.ts +91 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +181 -0
- package/dist/guards.js.map +1 -0
- package/dist/handle.d.ts +41 -0
- package/dist/handle.d.ts.map +1 -0
- package/dist/handle.js +41 -0
- package/dist/handle.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-ui-apps.d.ts +133 -0
- package/dist/mcp-ui-apps.d.ts.map +1 -0
- package/dist/mcp-ui-apps.js +134 -0
- package/dist/mcp-ui-apps.js.map +1 -0
- package/dist/mcp-ui.d.ts +133 -0
- package/dist/mcp-ui.d.ts.map +1 -0
- package/dist/mcp-ui.js +134 -0
- package/dist/mcp-ui.js.map +1 -0
- package/dist/page-capabilities.d.ts +14 -0
- package/dist/page-capabilities.d.ts.map +1 -0
- package/dist/page-capabilities.js +129 -0
- package/dist/page-capabilities.js.map +1 -0
- package/dist/page-driver.d.ts +107 -0
- package/dist/page-driver.d.ts.map +1 -0
- package/dist/page-driver.js +2 -0
- package/dist/page-driver.js.map +1 -0
- package/dist/page-executor.d.ts +87 -0
- package/dist/page-executor.d.ts.map +1 -0
- package/dist/page-executor.js +288 -0
- package/dist/page-executor.js.map +1 -0
- package/dist/webmcp.d.ts +81 -0
- package/dist/webmcp.d.ts.map +1 -0
- package/dist/webmcp.js +67 -0
- package/dist/webmcp.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,2FAA2F;AAC3F,MAAM,WAAW,eAAe;IAC9B,wCAAwC;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,gDAAgD;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guards.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module guards
|
|
3
|
+
*
|
|
4
|
+
* The refusals that must hold on every surface, expressed over plain descriptors rather than
|
|
5
|
+
* DOM nodes so they are testable in Node and reusable from any framework binding.
|
|
6
|
+
*
|
|
7
|
+
* Both guards here answer review findings that an allowlist alone does not cover: a generic
|
|
8
|
+
* filler will happily type into a password or card-number field even when that field carries a
|
|
9
|
+
* legitimate handle, and `data-agent-label` is page-authored text that reaches a model as if
|
|
10
|
+
* the host had written it.
|
|
11
|
+
*/
|
|
12
|
+
/** Input types no automated caller may ever write to. */
|
|
13
|
+
const DENIED_TYPES = new Set(['password', 'hidden', 'file', 'image']);
|
|
14
|
+
/** Autocomplete tokens covering credentials, payment instruments and one-time codes. */
|
|
15
|
+
const DENIED_AUTOCOMPLETE = new Set([
|
|
16
|
+
'current-password', 'new-password', 'one-time-code',
|
|
17
|
+
'cc-number', 'cc-exp', 'cc-exp-month', 'cc-exp-year', 'cc-csc', 'cc-name', 'cc-type',
|
|
18
|
+
]);
|
|
19
|
+
/**
|
|
20
|
+
* Substrings in `name`/`id` that indicate a secret even when type/autocomplete are unset.
|
|
21
|
+
*
|
|
22
|
+
* Matched against {@link squashSeparators}'d text, so the multi-word entries catch the separator
|
|
23
|
+
* spellings people actually use. `api_key`, `api-key` and `apiKey` are all the same field; a
|
|
24
|
+
* literal-substring match sees only the last one, which is the least common of the three.
|
|
25
|
+
*/
|
|
26
|
+
const SUSPICIOUS_NAME = /(?:password|passwd|secret|token|csrf|xsrf|otp|cvv|cvc|ssn|creditcard|cardnumber|apikey|ccnumber|cardnum|accountnumber|routing|iban|sortcode|securitycode|passphrase|privatekey|clientsecret|accesskey|secretkey|recoverycode|backupcode|mfa)/i;
|
|
27
|
+
// Deliberately NOT added as bare substrings, even though both are real PCI/banking terms
|
|
28
|
+
// ("pin", "PAN" — Primary Account Number): they collide with ordinary field names once
|
|
29
|
+
// separators are squashed out. `shipping` contains "pin"; `company` contains "pan". Adding
|
|
30
|
+
// either here would refuse a large share of legitimate, non-sensitive fields. See
|
|
31
|
+
// guards.test.ts's "does not refuse ordinary fields that happen to contain pin/pan as a
|
|
32
|
+
// substring" test — it exists specifically so a future edit cannot add either back silently.
|
|
33
|
+
/**
|
|
34
|
+
* Drops everything that is not a letter or digit, so separator conventions do not decide whether
|
|
35
|
+
* a guard fires. Over-matching is the safe direction here and is the point: this guard fails
|
|
36
|
+
* closed, and the cost of a false positive is a field an agent must leave to the user.
|
|
37
|
+
*
|
|
38
|
+
* Normalizes before squashing rather than after, because the naive squash used to *delete* any
|
|
39
|
+
* character outside ASCII `[a-z0-9]` instead of folding it. Deleting, not folding, is the bug:
|
|
40
|
+
* replacing one letter of a trigger word with a look-alike codepoint (fullwidth, accented, …)
|
|
41
|
+
* used to remove that letter from the squashed string entirely, so `password` (fullwidth
|
|
42
|
+
* U+FF50 `p`) squashed to `assword` and matched nothing. NFKC folds that class of look-alike —
|
|
43
|
+
* fullwidth/halfwidth forms, and the Latin compatibility block — to its ordinary ASCII form
|
|
44
|
+
* before the letter can be deleted. The NFD pass afterward strips combining marks so an accented
|
|
45
|
+
* letter (`á` → `a` + combining acute) folds the same way once the mark itself is dropped.
|
|
46
|
+
*
|
|
47
|
+
* This does NOT close the general homoglyph class. NFKC has no cross-script confusables table:
|
|
48
|
+
* Cyrillic `а` (U+0430) and Greek `ο` (U+03BF) stay distinct codepoints from Latin `a`/`o` after
|
|
49
|
+
* NFKC, so `pаssword` (Cyrillic а) still squashes to something other than `password` and still
|
|
50
|
+
* bypasses `SUSPICIOUS_NAME`. Closing that would need an explicit confusables-folding table
|
|
51
|
+
* (e.g. Unicode TR39's) mapping each look-alike script's letters onto Latin before squashing —
|
|
52
|
+
* deliberately not built here; see the "known limit" test in guards.test.ts for the concrete gap.
|
|
53
|
+
*/
|
|
54
|
+
function squashSeparators(value) {
|
|
55
|
+
const foldedWidth = value.normalize('NFKC');
|
|
56
|
+
const withoutMarks = foldedWidth.normalize('NFD').replace(/\p{M}/gu, '');
|
|
57
|
+
return withoutMarks.replace(/[^a-z0-9]/gi, '');
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Input types that hold no text.
|
|
61
|
+
*
|
|
62
|
+
* Writing to one succeeds mechanically and accomplishes nothing: setting `value` on a checkbox
|
|
63
|
+
* changes the string submitted *if* it is ticked, and leaves `checked` alone. The caller is told
|
|
64
|
+
* the fill worked and the box is still clear — a false success, which is worse than a refusal
|
|
65
|
+
* because it is never retried.
|
|
66
|
+
*/
|
|
67
|
+
const NON_TEXT_TYPES = new Set(['checkbox', 'radio', 'submit', 'reset', 'button']);
|
|
68
|
+
/**
|
|
69
|
+
* Why this field's current value must not be reported back to a caller, or `null` when reading
|
|
70
|
+
* it is safe.
|
|
71
|
+
*
|
|
72
|
+
* Reading is the strictly more dangerous direction: writing into a password box gives an agent
|
|
73
|
+
* nothing, whereas reading one out hands over the secret itself. So every secrecy signal the fill
|
|
74
|
+
* guard uses applies here identically — type, autocomplete token, and a name or id that indicates
|
|
75
|
+
* a credential or anti-forgery token — and none of them may be relaxed for reads.
|
|
76
|
+
*
|
|
77
|
+
* @param field - The field's attributes.
|
|
78
|
+
* @returns The first secrecy refusal, or `null` when the value may be reported.
|
|
79
|
+
*/
|
|
80
|
+
export function findFieldReadRefusal(field) {
|
|
81
|
+
const type = field.type?.toLowerCase();
|
|
82
|
+
if (type !== undefined && DENIED_TYPES.has(type))
|
|
83
|
+
return 'denied-type';
|
|
84
|
+
const autocomplete = field.autocomplete?.toLowerCase();
|
|
85
|
+
if (autocomplete !== undefined) {
|
|
86
|
+
// The real grammar is space-separated tokens, but a comma-joined value
|
|
87
|
+
// (`"new-password,current-password"`) is markup an attacker-controlled page can trivially
|
|
88
|
+
// emit even though real browsers won't autofill it correctly either — splitting on
|
|
89
|
+
// whitespace alone turned the whole string into one unrecognized token, so the field still
|
|
90
|
+
// worked as a plain text input while looking unguarded.
|
|
91
|
+
for (const token of autocomplete.split(/[\s,]+/)) {
|
|
92
|
+
if (DENIED_AUTOCOMPLETE.has(token))
|
|
93
|
+
return 'denied-autocomplete';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (SUSPICIOUS_NAME.test(squashSeparators(field.name ?? ''))
|
|
97
|
+
|| SUSPICIOUS_NAME.test(squashSeparators(field.id ?? ''))
|
|
98
|
+
// `name`/`id` are the *machine* names; a form builder or CMS that emits `name="field_47"`
|
|
99
|
+
// next to a visible "Card number" label left the guard nothing to judge until this existed.
|
|
100
|
+
|| SUSPICIOUS_NAME.test(squashSeparators(field.accessibleLabel ?? ''))) {
|
|
101
|
+
return 'suspicious-name';
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Why an automated fill must be refused for this field, or `null` when it is safe to write.
|
|
107
|
+
*
|
|
108
|
+
* Fails closed on anything that looks like a credential, payment instrument, one-time code, or
|
|
109
|
+
* anti-forgery token, independent of whether the field carries an agent handle. Tagging a
|
|
110
|
+
* password box does not make it fillable. Every secrecy refusal is also a fill refusal — a field
|
|
111
|
+
* whose contents an agent may not read is certainly not one it may overwrite — and two further
|
|
112
|
+
* refusals cover fields that are simply not writable.
|
|
113
|
+
*
|
|
114
|
+
* @param field - The field's attributes.
|
|
115
|
+
* @returns The first refusal reason, or `null` when the field may be filled.
|
|
116
|
+
*/
|
|
117
|
+
export function findFieldFillRefusal(field) {
|
|
118
|
+
const secrecy = findFieldReadRefusal(field);
|
|
119
|
+
if (secrecy !== null)
|
|
120
|
+
return secrecy;
|
|
121
|
+
const type = field.type?.toLowerCase();
|
|
122
|
+
if (type !== undefined && NON_TEXT_TYPES.has(type))
|
|
123
|
+
return 'not-text';
|
|
124
|
+
if (field.readOnly === true)
|
|
125
|
+
return 'read-only';
|
|
126
|
+
if (field.disabled === true)
|
|
127
|
+
return 'disabled';
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
const FIELD_REFUSAL_MESSAGES = {
|
|
131
|
+
'denied-type': 'this field type can never be filled by an agent',
|
|
132
|
+
'denied-autocomplete': 'this field holds a credential or payment instrument',
|
|
133
|
+
'suspicious-name': 'this field name indicates a secret or anti-forgery token',
|
|
134
|
+
'not-text': 'this control holds no text — activate it with the click verb instead of filling it',
|
|
135
|
+
'read-only': 'this field is read-only',
|
|
136
|
+
disabled: 'this field is disabled',
|
|
137
|
+
};
|
|
138
|
+
const FIELD_READ_REFUSAL_MESSAGES = {
|
|
139
|
+
'denied-type': 'this field type is never readable by an agent',
|
|
140
|
+
'denied-autocomplete': 'this field holds a credential or payment instrument',
|
|
141
|
+
'suspicious-name': 'this field name indicates a secret or anti-forgery token',
|
|
142
|
+
};
|
|
143
|
+
/** Model-readable reason for a refusal, so a blocked fill explains itself instead of failing opaquely. */
|
|
144
|
+
export function describeFieldRefusal(refusal) {
|
|
145
|
+
return FIELD_REFUSAL_MESSAGES[refusal];
|
|
146
|
+
}
|
|
147
|
+
/** Model-readable reason a value was withheld, so a caller knows the field has contents it may not see rather than assuming it is empty. */
|
|
148
|
+
export function describeFieldReadRefusal(refusal) {
|
|
149
|
+
return FIELD_READ_REFUSAL_MESSAGES[refusal];
|
|
150
|
+
}
|
|
151
|
+
/** Default cap on page-authored text handed to a model. */
|
|
152
|
+
export const MAX_AGENT_LABEL_LENGTH = 200;
|
|
153
|
+
/**
|
|
154
|
+
* C0/C1 control characters plus the Unicode bidirectional and invisible formatting ranges.
|
|
155
|
+
*
|
|
156
|
+
* The bidi overrides matter as much as the control codes: `U+202E` and friends let page text
|
|
157
|
+
* render one way and read another, which is a direct way to smuggle a different instruction
|
|
158
|
+
* into whatever reads the label back.
|
|
159
|
+
*/
|
|
160
|
+
const CONTROL_AND_BIDI =
|
|
161
|
+
// eslint-disable-next-line no-control-regex
|
|
162
|
+
/[\u0000-\u001F\u007F-\u009F\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u2069\uFEFF]/g;
|
|
163
|
+
/**
|
|
164
|
+
* Normalizes page-authored text before it reaches a model.
|
|
165
|
+
*
|
|
166
|
+
* Strips control characters (including the bidirectional overrides used to make text render
|
|
167
|
+
* differently from how it reads), collapses whitespace, and caps the length. The result is still
|
|
168
|
+
* untrusted *content* — this only bounds it; it does not make it safe to follow as instruction.
|
|
169
|
+
*
|
|
170
|
+
* @param raw - Text read off the page, e.g. a `data-agent-label`.
|
|
171
|
+
* @param maxLength - Cap, defaulting to {@link MAX_AGENT_LABEL_LENGTH}.
|
|
172
|
+
* @returns The bounded text and whether anything was cut.
|
|
173
|
+
*/
|
|
174
|
+
export function normalizeAgentLabel(raw, maxLength = MAX_AGENT_LABEL_LENGTH) {
|
|
175
|
+
const stripped = raw.replace(CONTROL_AND_BIDI, ' ');
|
|
176
|
+
const collapsed = stripped.replace(/\s+/g, ' ').trim();
|
|
177
|
+
if (collapsed.length <= maxLength)
|
|
178
|
+
return { text: collapsed, truncated: false };
|
|
179
|
+
return { text: collapsed.slice(0, maxLength), truncated: true };
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAwBH,yDAAyD;AACzD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEtE,wFAAwF;AACxF,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,kBAAkB,EAAE,cAAc,EAAE,eAAe;IACnD,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS;CACrF,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,eAAe,GACnB,+OAA+O,CAAC;AAElP,yFAAyF;AACzF,uFAAuF;AACvF,2FAA2F;AAC3F,kFAAkF;AACl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IAChE,OAAO,2BAA2B,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,2DAA2D;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,gBAAgB;AACpB,4CAA4C;AAC5C,yFAAyF,CAAC;AAO5F;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW,EAAE,SAAS,GAAG,sBAAsB;IACjF,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACvD,IAAI,SAAS,CAAC,MAAM,IAAI,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAChF,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAClE,CAAC"}
|
package/dist/handle.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module handle
|
|
3
|
+
*
|
|
4
|
+
* `agentHandle('save')` — the attribute props a component spreads onto its root element to
|
|
5
|
+
* publish itself under this package's `data-agent-*` markup convention (see
|
|
6
|
+
* `element-handles.ts`), without the caller having to know the attribute names or re-derive the
|
|
7
|
+
* handle-validity rule itself.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately pure data, no DOM: this returns a plain object of string attributes, spreadable by
|
|
10
|
+
* React (`<button {...agentHandle('save')}>`), Vue, Svelte, or any renderer that accepts arbitrary
|
|
11
|
+
* attribute props on an element. That is what lets it live in this package's universal root
|
|
12
|
+
* rather than `./dom` — nothing here touches `document` or any browser global.
|
|
13
|
+
*/
|
|
14
|
+
import { AGENT_ELEMENT_ATTRIBUTE, AGENT_LABEL_ATTRIBUTE, AGENT_PAGE_ATTRIBUTE, AGENT_ROLE_ATTRIBUTE, type AgentElementRole } from './element-handles.js';
|
|
15
|
+
/** Optional markup to attach alongside the handle itself. */
|
|
16
|
+
export interface AgentHandleOptions {
|
|
17
|
+
/** What verb applies to this element — see {@link AgentElementRole}. */
|
|
18
|
+
readonly role?: AgentElementRole;
|
|
19
|
+
/** Stable, page-authored ontology for this element (e.g. `"Full name"`). Never live text. */
|
|
20
|
+
readonly label?: string;
|
|
21
|
+
/** Which published page this element belongs to, for a multi-page host. */
|
|
22
|
+
readonly page?: string;
|
|
23
|
+
}
|
|
24
|
+
/** The attribute props {@link agentHandle} returns, ready to spread onto an element. */
|
|
25
|
+
export type AgentHandleProps = {
|
|
26
|
+
readonly [AGENT_ELEMENT_ATTRIBUTE]: string;
|
|
27
|
+
} & Partial<Record<typeof AGENT_ROLE_ATTRIBUTE | typeof AGENT_LABEL_ATTRIBUTE | typeof AGENT_PAGE_ATTRIBUTE, string>>;
|
|
28
|
+
/**
|
|
29
|
+
* Builds the attribute props that publish `handle` as an agent-addressable element.
|
|
30
|
+
*
|
|
31
|
+
* @param handle - The handle to publish. Must satisfy {@link isValidElementHandle} — this
|
|
32
|
+
* function reuses that exact rule rather than a second, possibly-diverging check, since an
|
|
33
|
+
* adversarial probe already confirmed it rejects quotes, brackets, backslashes, unicode and
|
|
34
|
+
* overlong handles (see `element-handles.ts`).
|
|
35
|
+
* @param options - Optional role/label/page markup.
|
|
36
|
+
* @returns Attribute props to spread onto the element that should carry this handle.
|
|
37
|
+
* @throws If `handle` is not a valid element handle — never publishes a handle a caller (`page.*`
|
|
38
|
+
* capabilities, `resolveHandleSelector`) could not later resolve.
|
|
39
|
+
*/
|
|
40
|
+
export declare function agentHandle(handle: string, options?: AgentHandleOptions): AgentHandleProps;
|
|
41
|
+
//# sourceMappingURL=handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EAEpB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,6DAA6D;AAC7D,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACjC,6FAA6F;IAC7F,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wFAAwF;AACxF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAC5C,GAAG,OAAO,CACT,MAAM,CACJ,OAAO,oBAAoB,GAAG,OAAO,qBAAqB,GAAG,OAAO,oBAAoB,EACxF,MAAM,CACP,CACF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,gBAAgB,CAY9F"}
|
package/dist/handle.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module handle
|
|
3
|
+
*
|
|
4
|
+
* `agentHandle('save')` — the attribute props a component spreads onto its root element to
|
|
5
|
+
* publish itself under this package's `data-agent-*` markup convention (see
|
|
6
|
+
* `element-handles.ts`), without the caller having to know the attribute names or re-derive the
|
|
7
|
+
* handle-validity rule itself.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately pure data, no DOM: this returns a plain object of string attributes, spreadable by
|
|
10
|
+
* React (`<button {...agentHandle('save')}>`), Vue, Svelte, or any renderer that accepts arbitrary
|
|
11
|
+
* attribute props on an element. That is what lets it live in this package's universal root
|
|
12
|
+
* rather than `./dom` — nothing here touches `document` or any browser global.
|
|
13
|
+
*/
|
|
14
|
+
import { AGENT_ELEMENT_ATTRIBUTE, AGENT_LABEL_ATTRIBUTE, AGENT_PAGE_ATTRIBUTE, AGENT_ROLE_ATTRIBUTE, isValidElementHandle, } from './element-handles.js';
|
|
15
|
+
/**
|
|
16
|
+
* Builds the attribute props that publish `handle` as an agent-addressable element.
|
|
17
|
+
*
|
|
18
|
+
* @param handle - The handle to publish. Must satisfy {@link isValidElementHandle} — this
|
|
19
|
+
* function reuses that exact rule rather than a second, possibly-diverging check, since an
|
|
20
|
+
* adversarial probe already confirmed it rejects quotes, brackets, backslashes, unicode and
|
|
21
|
+
* overlong handles (see `element-handles.ts`).
|
|
22
|
+
* @param options - Optional role/label/page markup.
|
|
23
|
+
* @returns Attribute props to spread onto the element that should carry this handle.
|
|
24
|
+
* @throws If `handle` is not a valid element handle — never publishes a handle a caller (`page.*`
|
|
25
|
+
* capabilities, `resolveHandleSelector`) could not later resolve.
|
|
26
|
+
*/
|
|
27
|
+
export function agentHandle(handle, options = {}) {
|
|
28
|
+
if (!isValidElementHandle(handle)) {
|
|
29
|
+
throw new Error(`invalid element handle "${handle.slice(0, 128)}": `
|
|
30
|
+
+ 'handles are lowercase words joined by single hyphens, and are never CSS selectors');
|
|
31
|
+
}
|
|
32
|
+
const props = { [AGENT_ELEMENT_ATTRIBUTE]: handle };
|
|
33
|
+
if (options.role !== undefined)
|
|
34
|
+
props[AGENT_ROLE_ATTRIBUTE] = options.role;
|
|
35
|
+
if (options.label !== undefined)
|
|
36
|
+
props[AGENT_LABEL_ATTRIBUTE] = options.label;
|
|
37
|
+
if (options.page !== undefined)
|
|
38
|
+
props[AGENT_PAGE_ATTRIBUTE] = options.page;
|
|
39
|
+
return props;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,GAErB,MAAM,sBAAsB,CAAC;AAsB9B;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,UAA8B,EAAE;IAC1E,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,2BAA2B,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK;cAClD,mFAAmF,CACtF,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAA2B,EAAE,CAAC,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5E,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,KAAK,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3E,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;QAAE,KAAK,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC;IAC9E,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,KAAK,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3E,OAAO,KAAyB,CAAC;AACnC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jini-ai/agentic — the framework-free half of agent control.
|
|
3
|
+
*
|
|
4
|
+
* Everything an outside caller needs to drive a Jini frontend, with no React, no DOM, and no
|
|
5
|
+
* transport: the capability vocabulary, the two shipped manifests, the `data-agent-*` markup
|
|
6
|
+
* convention, and the refusals that must hold everywhere.
|
|
7
|
+
*
|
|
8
|
+
* Framework bindings (`@jini-ai/chat-react`, via `@jini-ai/agentic/dom`'s `createDomPageDriver`, and
|
|
9
|
+
* any Vue/Svelte sibling) import from here and add only the wiring their framework needs.
|
|
10
|
+
* Server-side hosts (an HTTP route table, an MCP stdio server) import the same manifests, so the
|
|
11
|
+
* two can never drift apart.
|
|
12
|
+
*
|
|
13
|
+
* What is deliberately NOT here: how an action reaches a page. That is a transport concern —
|
|
14
|
+
* same-document in a real site like a CMS, `postMessage` when a host embeds an untrusted
|
|
15
|
+
* preview in a sandboxed frame. The verbs are identical either way. Also not here: any product's
|
|
16
|
+
* OWN capabilities (`@jini-ai/chat-core`'s `chat.*` verbs stay in chat-core, which depends on this
|
|
17
|
+
* package for the vocabulary rather than the other way around) — see this package's
|
|
18
|
+
* source-map.md for why the split is real rather than a wholesale relocation.
|
|
19
|
+
*/
|
|
20
|
+
export { findCapability, findCapabilityInputError, availableCapabilities, type CapabilityDef, type CapabilityInputSchema, type CapabilityRisk, type CapabilitySurface, } from './capability.js';
|
|
21
|
+
export type { PageDriver, FindElementsFilter } from './page-driver.js';
|
|
22
|
+
export { executePageCapability, projectElementState, DEFAULT_HIGHLIGHT_MS, MAX_HIGHLIGHT_MS, MAX_STATEFUL_ELEMENTS, type FindElementsResult, type PageElementResult, type PageSummary, type PageWriteObservation, } from './page-executor.js';
|
|
23
|
+
export { PAGE_CAPABILITIES } from './page-capabilities.js';
|
|
24
|
+
export { AGENT_ELEMENT_ATTRIBUTE, AGENT_ROLE_ATTRIBUTE, AGENT_LABEL_ATTRIBUTE, AGENT_PAGE_ATTRIBUTE, AGENT_ELEMENT_ROLES, isValidElementHandle, resolveHandleSelector, type AgentElementRole, type AgentElementDescriptor, type AgentElementRawState, type AgentElementState, } from './element-handles.js';
|
|
25
|
+
export { agentHandle, type AgentHandleOptions, type AgentHandleProps } from './handle.js';
|
|
26
|
+
export { findFieldFillRefusal, findFieldReadRefusal, describeFieldRefusal, describeFieldReadRefusal, normalizeAgentLabel, MAX_AGENT_LABEL_LENGTH, type FieldDescriptor, type FieldRefusal, type FieldReadRefusal, type NormalizedLabel, } from './guards.js';
|
|
27
|
+
/**
|
|
28
|
+
* Protocol adapters, named for what they derive from.
|
|
29
|
+
*
|
|
30
|
+
* Each is a ONE-WAY projection out of the neutral core: they import `capability.js`, and nothing
|
|
31
|
+
* imports back. That direction is the whole point — if the core ever imported an adapter, the
|
|
32
|
+
* protocol we happened to build against would leak into the vocabulary and the layer would stop
|
|
33
|
+
* being neutral. None of them opens a connection or touches a browser global; a framework
|
|
34
|
+
* binding owns transport and host access.
|
|
35
|
+
*/
|
|
36
|
+
export { toWebMcpTool, toWebMcpTools, WebMcpConfirmationRequiredError, type WebMcpToolRegistration, type WebMcpUserInteraction, type RequestUserInteraction, type ToWebMcpToolOptions, } from './webmcp.js';
|
|
37
|
+
/**
|
|
38
|
+
* Genuine AG-UI: the {@link CapabilityDef} → AG-UI *frontend tool* projection. Real conformance —
|
|
39
|
+
* it emits the protocol's own `parameters` field name (not `inputSchema`) and its canonical
|
|
40
|
+
* `TOOL_CALL_START`/`TOOL_CALL_ARGS`/`TOOL_CALL_END` event names, all three of which appear in
|
|
41
|
+
* AG-UI's published `EventType` enum.
|
|
42
|
+
*/
|
|
43
|
+
export { toAgUiTool, toAgUiTools, createAgUiToolResult, AG_UI_TOOL_CALL_EVENTS, type AgUiTool, type AgUiToolResultMessage, } from './ag-ui.js';
|
|
44
|
+
/**
|
|
45
|
+
* Jini's **own** run-stream surface protocol, from `./gen-ui/` — six event kinds and the encoder
|
|
46
|
+
* that produces them (folded in 2026-07-26 from the standalone `@jini-ai/agui` package, plan §3a).
|
|
47
|
+
*
|
|
48
|
+
* Renamed from `./agui/` on 2026-07-27, because this is NOT AG-UI. The real Agent-User Interaction
|
|
49
|
+
* Protocol (https://github.com/ag-ui-protocol/ag-ui) carries a 33-member `SCREAMING_SNAKE` event
|
|
50
|
+
* enum — `RUN_STARTED`, `TEXT_MESSAGE_CONTENT`, `STATE_DELTA`, `STEP_STARTED`, `REASONING_*` — and
|
|
51
|
+
* shares **zero** event names with the six dotted-lowercase kinds in `./gen-ui/events.ts`, which
|
|
52
|
+
* are a de-branded port of one product's internal run-event adapter. Carrying the AG-UI name on
|
|
53
|
+
* them asserted a conformance that does not exist.
|
|
54
|
+
*
|
|
55
|
+
* `./ag-ui.ts` above was wrongly folded in with them on 2026-07-26 and moved back out on the 27th:
|
|
56
|
+
* it is the one file here that really does speak AG-UI, so merging it with these six was the exact
|
|
57
|
+
* inversion of the truth.
|
|
58
|
+
*
|
|
59
|
+
* The exported symbols below still carry `Agui`/`AGUI` prefixes: renaming those crosses into
|
|
60
|
+
* `@jini-ai/http` (whose `RUN_STREAM_ROUTE_PATH` is `/api/runs/:runId/agui-stream`) and
|
|
61
|
+
* `@jini-ai/protocol`, so it is deliberately not bundled with this directory move.
|
|
62
|
+
*/
|
|
63
|
+
export { createAguiEncoder, type AguiEncodeContext, type AguiEncoder, type AGUIAgentMessageEvent, type AGUIEvent, type AGUIEventBase, type AGUIEventKind, type AGUIRunLifecycleEvent, type AGUIStateUpdateEvent, type AGUISurfaceRequestedEvent, type AGUISurfaceRespondedEvent, type AGUIToolCallEvent, } from './gen-ui/index.js';
|
|
64
|
+
export { MCP_UI_VIEW_METHODS, MCP_UI_HOST_NOTIFICATIONS, MCP_UI_SANDBOX_NOTE, JINI_PAGE_ACTION_METHOD, JSON_RPC_ERROR_CODES, isJsonRpcMessage, isJsonRpcRequest, createJsonRpcRequest, createJsonRpcNotification, createJsonRpcResult, createJsonRpcError, createPageActionRequest, type JsonRpcMessage, type JsonRpcRequest, type JsonRpcNotification, type JsonRpcResponse, type JsonRpcError, } from './mcp-ui-apps.js';
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,iBA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ACtB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jini-ai/agentic — the framework-free half of agent control.
|
|
3
|
+
*
|
|
4
|
+
* Everything an outside caller needs to drive a Jini frontend, with no React, no DOM, and no
|
|
5
|
+
* transport: the capability vocabulary, the two shipped manifests, the `data-agent-*` markup
|
|
6
|
+
* convention, and the refusals that must hold everywhere.
|
|
7
|
+
*
|
|
8
|
+
* Framework bindings (`@jini-ai/chat-react`, via `@jini-ai/agentic/dom`'s `createDomPageDriver`, and
|
|
9
|
+
* any Vue/Svelte sibling) import from here and add only the wiring their framework needs.
|
|
10
|
+
* Server-side hosts (an HTTP route table, an MCP stdio server) import the same manifests, so the
|
|
11
|
+
* two can never drift apart.
|
|
12
|
+
*
|
|
13
|
+
* What is deliberately NOT here: how an action reaches a page. That is a transport concern —
|
|
14
|
+
* same-document in a real site like a CMS, `postMessage` when a host embeds an untrusted
|
|
15
|
+
* preview in a sandboxed frame. The verbs are identical either way. Also not here: any product's
|
|
16
|
+
* OWN capabilities (`@jini-ai/chat-core`'s `chat.*` verbs stay in chat-core, which depends on this
|
|
17
|
+
* package for the vocabulary rather than the other way around) — see this package's
|
|
18
|
+
* source-map.md for why the split is real rather than a wholesale relocation.
|
|
19
|
+
*/
|
|
20
|
+
export { findCapability, findCapabilityInputError, availableCapabilities, } from './capability.js';
|
|
21
|
+
export { executePageCapability, projectElementState, DEFAULT_HIGHLIGHT_MS, MAX_HIGHLIGHT_MS, MAX_STATEFUL_ELEMENTS, } from './page-executor.js';
|
|
22
|
+
export { PAGE_CAPABILITIES } from './page-capabilities.js';
|
|
23
|
+
export { AGENT_ELEMENT_ATTRIBUTE, AGENT_ROLE_ATTRIBUTE, AGENT_LABEL_ATTRIBUTE, AGENT_PAGE_ATTRIBUTE, AGENT_ELEMENT_ROLES, isValidElementHandle, resolveHandleSelector, } from './element-handles.js';
|
|
24
|
+
export { agentHandle } from './handle.js';
|
|
25
|
+
export { findFieldFillRefusal, findFieldReadRefusal, describeFieldRefusal, describeFieldReadRefusal, normalizeAgentLabel, MAX_AGENT_LABEL_LENGTH, } from './guards.js';
|
|
26
|
+
/**
|
|
27
|
+
* Protocol adapters, named for what they derive from.
|
|
28
|
+
*
|
|
29
|
+
* Each is a ONE-WAY projection out of the neutral core: they import `capability.js`, and nothing
|
|
30
|
+
* imports back. That direction is the whole point — if the core ever imported an adapter, the
|
|
31
|
+
* protocol we happened to build against would leak into the vocabulary and the layer would stop
|
|
32
|
+
* being neutral. None of them opens a connection or touches a browser global; a framework
|
|
33
|
+
* binding owns transport and host access.
|
|
34
|
+
*/
|
|
35
|
+
export { toWebMcpTool, toWebMcpTools, WebMcpConfirmationRequiredError, } from './webmcp.js';
|
|
36
|
+
/**
|
|
37
|
+
* Genuine AG-UI: the {@link CapabilityDef} → AG-UI *frontend tool* projection. Real conformance —
|
|
38
|
+
* it emits the protocol's own `parameters` field name (not `inputSchema`) and its canonical
|
|
39
|
+
* `TOOL_CALL_START`/`TOOL_CALL_ARGS`/`TOOL_CALL_END` event names, all three of which appear in
|
|
40
|
+
* AG-UI's published `EventType` enum.
|
|
41
|
+
*/
|
|
42
|
+
export { toAgUiTool, toAgUiTools, createAgUiToolResult, AG_UI_TOOL_CALL_EVENTS, } from './ag-ui.js';
|
|
43
|
+
/**
|
|
44
|
+
* Jini's **own** run-stream surface protocol, from `./gen-ui/` — six event kinds and the encoder
|
|
45
|
+
* that produces them (folded in 2026-07-26 from the standalone `@jini-ai/agui` package, plan §3a).
|
|
46
|
+
*
|
|
47
|
+
* Renamed from `./agui/` on 2026-07-27, because this is NOT AG-UI. The real Agent-User Interaction
|
|
48
|
+
* Protocol (https://github.com/ag-ui-protocol/ag-ui) carries a 33-member `SCREAMING_SNAKE` event
|
|
49
|
+
* enum — `RUN_STARTED`, `TEXT_MESSAGE_CONTENT`, `STATE_DELTA`, `STEP_STARTED`, `REASONING_*` — and
|
|
50
|
+
* shares **zero** event names with the six dotted-lowercase kinds in `./gen-ui/events.ts`, which
|
|
51
|
+
* are a de-branded port of one product's internal run-event adapter. Carrying the AG-UI name on
|
|
52
|
+
* them asserted a conformance that does not exist.
|
|
53
|
+
*
|
|
54
|
+
* `./ag-ui.ts` above was wrongly folded in with them on 2026-07-26 and moved back out on the 27th:
|
|
55
|
+
* it is the one file here that really does speak AG-UI, so merging it with these six was the exact
|
|
56
|
+
* inversion of the truth.
|
|
57
|
+
*
|
|
58
|
+
* The exported symbols below still carry `Agui`/`AGUI` prefixes: renaming those crosses into
|
|
59
|
+
* `@jini-ai/http` (whose `RUN_STREAM_ROUTE_PATH` is `/api/runs/:runId/agui-stream`) and
|
|
60
|
+
* `@jini-ai/protocol`, so it is deliberately not bundled with this directory move.
|
|
61
|
+
*/
|
|
62
|
+
export { createAguiEncoder, } from './gen-ui/index.js';
|
|
63
|
+
export { MCP_UI_VIEW_METHODS, MCP_UI_HOST_NOTIFICATIONS, MCP_UI_SANDBOX_NOTE, JINI_PAGE_ACTION_METHOD, JSON_RPC_ERROR_CODES, isJsonRpcMessage, isJsonRpcRequest, createJsonRpcRequest, createJsonRpcNotification, createJsonRpcResult, createJsonRpcError, createPageActionRequest, } from './mcp-ui-apps.js';
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,qBAAqB,GAKtB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,GAKtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,GAKtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAkD,MAAM,aAAa,CAAC;AAE1F,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,GAKvB,MAAM,aAAa,CAAC;AAErB;;;;;;;;GAQG;AACH,OAAO,EACL,YAAY,EACZ,aAAa,EACb,+BAA+B,GAKhC,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,OAAO,EACL,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,sBAAsB,GAGvB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EACL,iBAAiB,GAYlB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,GAMxB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module mcp-ui
|
|
3
|
+
*
|
|
4
|
+
* The MCP Apps (`mcp-ui`) envelope: JSON-RPC 2.0 over `postMessage` between a host and a
|
|
5
|
+
* sandboxed iframe View.
|
|
6
|
+
*
|
|
7
|
+
* MCP Apps became the first official MCP extension (SEP-1865) on 2026-01-26. Jini borrows its
|
|
8
|
+
* **envelope and lifecycle** rather than inventing a message format, because the hard parts are
|
|
9
|
+
* already settled there: request/response correlation by `id`, and the ordering rule that a host
|
|
10
|
+
* MUST NOT send any request or notification to a View before receiving `initialized` — which is
|
|
11
|
+
* the fix for the "posted before the iframe was listening" race.
|
|
12
|
+
*
|
|
13
|
+
* Two deliberate divergences, both load-bearing:
|
|
14
|
+
*
|
|
15
|
+
* 1. **Direction.** MCP Apps is View→Host: the embedded UI calls tools. Host→View is a *fixed*
|
|
16
|
+
* lifecycle set ({@link MCP_UI_HOST_NOTIFICATIONS}) with no generic "host asks the View to do
|
|
17
|
+
* something". Jini's page verbs therefore ride as an explicitly-namespaced extension
|
|
18
|
+
* ({@link JINI_PAGE_ACTION_METHOD}) — ours, not the spec's, and named so no one mistakes it.
|
|
19
|
+
* 2. **Sandbox.** The spec mandates `sandbox="allow-scripts allow-same-origin"`, which is safe
|
|
20
|
+
* *there* because the View is served from a separate origin behind a sandbox proxy. A host
|
|
21
|
+
* serving preview content from its own origin must NOT copy that line: `allow-same-origin`
|
|
22
|
+
* would hand the embedded document access to the host's origin. See
|
|
23
|
+
* {@link MCP_UI_SANDBOX_NOTE}.
|
|
24
|
+
*
|
|
25
|
+
* No transport here — this package touches no browser globals. These are pure builders and
|
|
26
|
+
* parsers; the binding that owns the iframe does the posting.
|
|
27
|
+
*/
|
|
28
|
+
/** Method names the View may call on the Host. From the 2026-01-26 specification. */
|
|
29
|
+
export declare const MCP_UI_VIEW_METHODS: {
|
|
30
|
+
readonly initialize: "ui/initialize";
|
|
31
|
+
readonly callTool: "tools/call";
|
|
32
|
+
readonly readResource: "resources/read";
|
|
33
|
+
readonly log: "notifications/message";
|
|
34
|
+
readonly openLink: "ui/open-link";
|
|
35
|
+
readonly sendMessage: "ui/message";
|
|
36
|
+
readonly requestDisplayMode: "ui/request-display-mode";
|
|
37
|
+
readonly updateModelContext: "ui/update-model-context";
|
|
38
|
+
readonly ping: "ping";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Notifications the Host may send the View. This is the complete host→view surface in the
|
|
42
|
+
* specification — note that none of them is a generic page action.
|
|
43
|
+
*/
|
|
44
|
+
export declare const MCP_UI_HOST_NOTIFICATIONS: {
|
|
45
|
+
readonly initialized: "ui/notifications/initialized";
|
|
46
|
+
readonly toolInputPartial: "ui/notifications/tool-input-partial";
|
|
47
|
+
readonly toolInput: "ui/notifications/tool-input";
|
|
48
|
+
readonly toolResult: "ui/notifications/tool-result";
|
|
49
|
+
readonly toolCancelled: "ui/notifications/tool-cancelled";
|
|
50
|
+
readonly sizeChanged: "ui/notifications/size-changed";
|
|
51
|
+
readonly hostContextChanged: "ui/notifications/host-context-changed";
|
|
52
|
+
readonly teardown: "ui/resource-teardown";
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Jini's page-action extension. **Not part of MCP Apps** — the namespace is explicit so it can
|
|
56
|
+
* never be mistaken for a spec method, and so a compliant host that does not understand it
|
|
57
|
+
* rejects it as unknown rather than silently mis-handling it.
|
|
58
|
+
*/
|
|
59
|
+
export declare const JINI_PAGE_ACTION_METHOD = "x-jini/page-action";
|
|
60
|
+
/**
|
|
61
|
+
* Why a host serving preview content from its own origin must not copy the spec's sandbox line.
|
|
62
|
+
* Kept as an exported string so the reason travels with the code that would otherwise be
|
|
63
|
+
* cargo-culted.
|
|
64
|
+
*/
|
|
65
|
+
export declare const MCP_UI_SANDBOX_NOTE: string;
|
|
66
|
+
export interface JsonRpcRequest {
|
|
67
|
+
readonly jsonrpc: '2.0';
|
|
68
|
+
readonly id: number | string;
|
|
69
|
+
readonly method: string;
|
|
70
|
+
readonly params?: Record<string, unknown>;
|
|
71
|
+
}
|
|
72
|
+
export interface JsonRpcNotification {
|
|
73
|
+
readonly jsonrpc: '2.0';
|
|
74
|
+
readonly method: string;
|
|
75
|
+
readonly params?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
export interface JsonRpcError {
|
|
78
|
+
readonly code: number;
|
|
79
|
+
readonly message: string;
|
|
80
|
+
readonly data?: unknown;
|
|
81
|
+
}
|
|
82
|
+
export interface JsonRpcResponse {
|
|
83
|
+
readonly jsonrpc: '2.0';
|
|
84
|
+
readonly id: number | string;
|
|
85
|
+
readonly result?: unknown;
|
|
86
|
+
readonly error?: JsonRpcError;
|
|
87
|
+
}
|
|
88
|
+
export type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcResponse;
|
|
89
|
+
/** JSON-RPC 2.0 reserved codes, used so a View's failures read the same as any other client's. */
|
|
90
|
+
export declare const JSON_RPC_ERROR_CODES: {
|
|
91
|
+
readonly parseError: -32700;
|
|
92
|
+
readonly invalidRequest: -32600;
|
|
93
|
+
readonly methodNotFound: -32601;
|
|
94
|
+
readonly invalidParams: -32602;
|
|
95
|
+
readonly internalError: -32603;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Whether an arbitrary value is a JSON-RPC 2.0 message.
|
|
99
|
+
*
|
|
100
|
+
* Messages arriving over `postMessage` are attacker-influenced input — any page able to reach the
|
|
101
|
+
* frame can post anything. Validate before dispatch; never trust the shape.
|
|
102
|
+
*
|
|
103
|
+
* @param value - The raw `event.data`.
|
|
104
|
+
* @returns True when the value is a well-formed JSON-RPC message.
|
|
105
|
+
*/
|
|
106
|
+
export declare function isJsonRpcMessage(value: unknown): value is JsonRpcMessage;
|
|
107
|
+
/** Whether a validated message expects a response (as opposed to being a notification). */
|
|
108
|
+
export declare function isJsonRpcRequest(message: JsonRpcMessage): message is JsonRpcRequest;
|
|
109
|
+
/**
|
|
110
|
+
* Builds a request.
|
|
111
|
+
*
|
|
112
|
+
* @param id - Correlation id, unique per in-flight request. Doubles as the idempotency key: a
|
|
113
|
+
* transport that redelivers (an SSE reconnect, a repeated post) must not execute twice.
|
|
114
|
+
* @param method - Method name.
|
|
115
|
+
* @param params - Optional parameters.
|
|
116
|
+
*/
|
|
117
|
+
export declare function createJsonRpcRequest(id: number | string, method: string, params?: Record<string, unknown>): JsonRpcRequest;
|
|
118
|
+
/** Builds a notification — no `id`, so no response is expected or allowed. */
|
|
119
|
+
export declare function createJsonRpcNotification(method: string, params?: Record<string, unknown>): JsonRpcNotification;
|
|
120
|
+
/** Builds a success response for `id`. */
|
|
121
|
+
export declare function createJsonRpcResult(id: number | string, result: unknown): JsonRpcResponse;
|
|
122
|
+
/** Builds an error response for `id`. */
|
|
123
|
+
export declare function createJsonRpcError(id: number | string, code: number, message: string, data?: unknown): JsonRpcResponse;
|
|
124
|
+
/**
|
|
125
|
+
* Builds a Jini page-action request.
|
|
126
|
+
*
|
|
127
|
+
* @param id - Correlation/idempotency id.
|
|
128
|
+
* @param capabilityId - A `page.*` capability id.
|
|
129
|
+
* @param input - Capability arguments.
|
|
130
|
+
* @returns The namespaced extension request.
|
|
131
|
+
*/
|
|
132
|
+
export declare function createPageActionRequest(id: number | string, capabilityId: string, input: Record<string, unknown>): JsonRpcRequest;
|
|
133
|
+
//# sourceMappingURL=mcp-ui-apps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-ui-apps.d.ts","sourceRoot":"","sources":["../src/mcp-ui-apps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,qFAAqF;AACrF,eAAO,MAAM,mBAAmB;;;;;;;;;;CAUtB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;CAS5B,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,uBAA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