@nxisai/agent-harness 0.2.3 → 0.3.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/README.md +94 -6
- package/dist/a2ui/stepper.d.ts +1 -1
- package/dist/a2ui/stepper.d.ts.map +1 -1
- package/dist/a2ui/stepper.js +2 -2
- package/dist/a2ui/stepper.js.map +1 -1
- package/dist/engine.d.ts +1 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +1 -0
- package/dist/engine.js.map +1 -1
- package/dist/harness/harness.d.ts +38 -0
- package/dist/harness/harness.d.ts.map +1 -1
- package/dist/harness/harness.js +127 -4
- package/dist/harness/harness.js.map +1 -1
- package/dist/harness/renderer.d.ts +30 -0
- package/dist/harness/renderer.d.ts.map +1 -1
- package/dist/harness/steps.d.ts +101 -0
- package/dist/harness/steps.d.ts.map +1 -0
- package/dist/harness/steps.js +102 -0
- package/dist/harness/steps.js.map +1 -0
- package/dist/harness/tools/action-tools.d.ts +213 -0
- package/dist/harness/tools/action-tools.d.ts.map +1 -0
- package/dist/harness/tools/action-tools.js +724 -0
- package/dist/harness/tools/action-tools.js.map +1 -0
- package/dist/harness/tools/bridge.d.ts.map +1 -1
- package/dist/harness/tools/bridge.js +28 -2
- package/dist/harness/tools/bridge.js.map +1 -1
- package/dist/harness/tools/discovery.d.ts +2 -1
- package/dist/harness/tools/discovery.d.ts.map +1 -1
- package/dist/harness/tools/discovery.js +1 -1
- package/dist/harness/tools/discovery.js.map +1 -1
- package/dist/harness/tools/pending-action.d.ts +55 -0
- package/dist/harness/tools/pending-action.d.ts.map +1 -0
- package/dist/harness/tools/pending-action.js +93 -0
- package/dist/harness/tools/pending-action.js.map +1 -0
- package/dist/harness/tools/resume.d.ts +92 -0
- package/dist/harness/tools/resume.d.ts.map +1 -0
- package/dist/harness/tools/resume.js +84 -0
- package/dist/harness/tools/resume.js.map +1 -0
- package/dist/harness/tools/schema.js +29 -2
- package/dist/harness/tools/schema.js.map +1 -1
- package/dist/harness/tools/site-actions.d.ts +69 -0
- package/dist/harness/tools/site-actions.d.ts.map +1 -0
- package/dist/harness/tools/site-actions.js +310 -0
- package/dist/harness/tools/site-actions.js.map +1 -0
- package/dist/harness/tools/source.d.ts +44 -5
- package/dist/harness/tools/source.d.ts.map +1 -1
- package/dist/harness/tools/source.js +58 -9
- package/dist/harness/tools/source.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/proxy.d.ts +5 -0
- package/dist/providers/proxy.d.ts.map +1 -1
- package/dist/providers/proxy.js +16 -1
- package/dist/providers/proxy.js.map +1 -1
- package/dist/providers/types.d.ts +15 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/types.d.ts +7 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/agent-fullscreen.d.ts.map +1 -1
- package/dist/ui/agent-fullscreen.js +771 -36
- package/dist/ui/agent-fullscreen.js.map +1 -1
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/journey.d.ts +33 -0
- package/dist/ui/journey.d.ts.map +1 -0
- package/dist/ui/journey.js +27 -0
- package/dist/ui/journey.js.map +1 -0
- package/dist/ui/tailwind.generated.d.ts +1 -1
- package/dist/ui/tailwind.generated.d.ts.map +1 -1
- package/dist/ui/tailwind.generated.js +1 -1
- package/dist/ui/tailwind.generated.js.map +1 -1
- package/dist/webmcp-contract.d.ts +6 -2
- package/dist/webmcp-contract.d.ts.map +1 -1
- package/docs/remote-providers.md +196 -0
- package/docs/single-vs-multi-agent-dark.svg +78 -0
- package/docs/single-vs-multi-agent.svg +78 -0
- package/docs/turn-routing-dark.svg +52 -0
- package/docs/turn-routing.svg +52 -0
- package/package.json +3 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches every Schema.org Action on the site through typed retrieval.
|
|
3
|
+
*
|
|
4
|
+
* The page's own script registers tools only for the actions in the current
|
|
5
|
+
* page's JSON-LD. The site's MCP server holds them all, so an agent opened on
|
|
6
|
+
* any page can learn what the rest of the site offers. This module fetches and
|
|
7
|
+
* normalises that list; turning it into tools is a separate step.
|
|
8
|
+
*
|
|
9
|
+
* Records arrive with expanded IRI keys (`https://schema.org/name`) where a
|
|
10
|
+
* page carries compact ones (`name`), so both spellings are read, as the
|
|
11
|
+
* page's script does.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
16
|
+
import type { McpServerInfo } from '../../types.js';
|
|
17
|
+
import type { NxisAction } from '../../webmcp-contract.js';
|
|
18
|
+
/**
|
|
19
|
+
* Read one typed-retrieval record as an action.
|
|
20
|
+
*
|
|
21
|
+
* @param raw - A record as returned by `nxis_query`.
|
|
22
|
+
* @returns The action with bare types and compact keys, or null when the record
|
|
23
|
+
* is not an Action or lacks an `@id`, a name, or a target with an HTTP method.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseAction(raw: unknown): NxisAction | null;
|
|
26
|
+
/**
|
|
27
|
+
* Whether two URLs name the same page, ignoring the query and fragment.
|
|
28
|
+
*
|
|
29
|
+
* A form is the same form whether it was reached with tracking parameters or
|
|
30
|
+
* without.
|
|
31
|
+
*/
|
|
32
|
+
export declare function samePage(a: string | undefined, b: string | undefined): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether an action's form is on the page currently open.
|
|
35
|
+
*
|
|
36
|
+
* @param action - The action to place.
|
|
37
|
+
* @param href - The current page. Defaults to the browser's.
|
|
38
|
+
*/
|
|
39
|
+
export declare function sameActionPage(action: NxisAction, href?: string): boolean;
|
|
40
|
+
/** Options for {@link loadSiteActions}. */
|
|
41
|
+
export interface SiteActionsOptions {
|
|
42
|
+
/**
|
|
43
|
+
* The origin actions must belong to. Defaults to the page's own.
|
|
44
|
+
*
|
|
45
|
+
* An action whose page is on any other origin is dropped.
|
|
46
|
+
*/
|
|
47
|
+
origin?: string;
|
|
48
|
+
/** Where the list is cached between page loads. Defaults to `sessionStorage`; null disables. */
|
|
49
|
+
storage?: Storage | null;
|
|
50
|
+
/** How long a cached list is reused, in milliseconds. Defaults to ten minutes. */
|
|
51
|
+
ttlMs?: number;
|
|
52
|
+
/** The clock, for tests. */
|
|
53
|
+
now?: () => number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Every Action on the site that can be carried out from this origin.
|
|
57
|
+
*
|
|
58
|
+
* Reuses a list fetched in the same tab within the last ten minutes, so moving
|
|
59
|
+
* between pages costs one request per session rather than one per page.
|
|
60
|
+
*
|
|
61
|
+
* @param client - A connected client for the site's MCP server. The query is a
|
|
62
|
+
* public read and needs no key.
|
|
63
|
+
* @param info - The server's details; its endpoint keys the cache.
|
|
64
|
+
* @param opts - Origin, cache and clock overrides.
|
|
65
|
+
* @returns The actions, each once, in the order the server returned them.
|
|
66
|
+
* @throws When the query itself fails. The caller decides whether that matters.
|
|
67
|
+
*/
|
|
68
|
+
export declare function loadSiteActions(client: Client, info: Pick<McpServerInfo, 'endpoint'>, opts?: SiteActionsOptions): Promise<NxisAction[]>;
|
|
69
|
+
//# sourceMappingURL=site-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-actions.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/site-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EACV,UAAU,EAKX,MAAM,0BAA0B,CAAC;AA8BlC;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAyB3D;AA2DD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAS9E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAGzE;AAsHD,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,EACrC,IAAI,GAAE,kBAAuB,GAC5B,OAAO,CAAC,UAAU,EAAE,CAAC,CA8BvB"}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
const SCHEMA_NS = 'https://schema.org/';
|
|
2
|
+
const NXIS_NS = 'https://nxis.ai/ns#';
|
|
3
|
+
/** The server caps a page of results at this many. */
|
|
4
|
+
const PAGE_LIMIT = 100;
|
|
5
|
+
/** A guard against a server that keeps returning page tokens. */
|
|
6
|
+
const MAX_PAGES = 10;
|
|
7
|
+
/** How long a fetched list is reused across page loads in the same tab. */
|
|
8
|
+
const CACHE_TTL_MS = 10 * 60 * 1000;
|
|
9
|
+
const CACHE_PREFIX = 'nxis:site-actions:v1:';
|
|
10
|
+
const VALUE_TYPES = ['string', 'number', 'integer', 'boolean', 'date', 'file'];
|
|
11
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
12
|
+
/** A schema.org property, by compact term or expanded IRI. */
|
|
13
|
+
const schemaValue = (o, prop) => o[prop] ?? o[SCHEMA_NS + prop];
|
|
14
|
+
/** An nxis extension property, by compact term or expanded IRI. */
|
|
15
|
+
const nxisValue = (o, prop) => o[`nxis:${prop}`] ?? o[NXIS_NS + prop];
|
|
16
|
+
const str = (v) => (typeof v === 'string' ? v : undefined);
|
|
17
|
+
const num = (v) => (typeof v === 'number' ? v : undefined);
|
|
18
|
+
/** `https://schema.org/InteractAction` → `InteractAction`. */
|
|
19
|
+
const bareType = (t) => t.replace(/^.*[/#]/, '');
|
|
20
|
+
/**
|
|
21
|
+
* Read one typed-retrieval record as an action.
|
|
22
|
+
*
|
|
23
|
+
* @param raw - A record as returned by `nxis_query`.
|
|
24
|
+
* @returns The action with bare types and compact keys, or null when the record
|
|
25
|
+
* is not an Action or lacks an `@id`, a name, or a target with an HTTP method.
|
|
26
|
+
*/
|
|
27
|
+
export function parseAction(raw) {
|
|
28
|
+
if (!isObj(raw))
|
|
29
|
+
return null;
|
|
30
|
+
const rawType = str(raw['@type']);
|
|
31
|
+
if (!rawType)
|
|
32
|
+
return null;
|
|
33
|
+
const type = bareType(rawType);
|
|
34
|
+
if (!type.endsWith('Action'))
|
|
35
|
+
return null;
|
|
36
|
+
const id = str(raw['@id']);
|
|
37
|
+
const name = str(schemaValue(raw, 'name'));
|
|
38
|
+
const target = parseEntryPoint(schemaValue(raw, 'target'));
|
|
39
|
+
if (!id || !name || !target)
|
|
40
|
+
return null;
|
|
41
|
+
// Inputs live under `nxis:input`: schema.org has no `input` on Action.
|
|
42
|
+
const rawInput = nxisValue(raw, 'input');
|
|
43
|
+
const input = (Array.isArray(rawInput) ? rawInput : [])
|
|
44
|
+
.map(parseInput)
|
|
45
|
+
.filter((i) => i !== null);
|
|
46
|
+
const action = { '@type': type, '@id': id, name, target };
|
|
47
|
+
const description = str(schemaValue(raw, 'description'));
|
|
48
|
+
if (description)
|
|
49
|
+
action.description = description;
|
|
50
|
+
if (input.length)
|
|
51
|
+
action.input = input;
|
|
52
|
+
const extractedAt = str(nxisValue(raw, 'extractedAt'));
|
|
53
|
+
if (extractedAt)
|
|
54
|
+
action['nxis:extractedAt'] = extractedAt;
|
|
55
|
+
return action;
|
|
56
|
+
}
|
|
57
|
+
function parseEntryPoint(raw) {
|
|
58
|
+
if (!isObj(raw))
|
|
59
|
+
return null;
|
|
60
|
+
const httpMethod = str(schemaValue(raw, 'httpMethod'))?.toUpperCase();
|
|
61
|
+
if (!httpMethod)
|
|
62
|
+
return null;
|
|
63
|
+
const target = { '@type': 'EntryPoint', httpMethod };
|
|
64
|
+
const urlTemplate = str(schemaValue(raw, 'urlTemplate'));
|
|
65
|
+
if (urlTemplate)
|
|
66
|
+
target.urlTemplate = urlTemplate;
|
|
67
|
+
const encodingType = str(schemaValue(raw, 'encodingType'));
|
|
68
|
+
if (encodingType)
|
|
69
|
+
target.encodingType = encodingType;
|
|
70
|
+
const kind = nxisValue(raw, 'targetKind');
|
|
71
|
+
if (kind === 'selfPage' || kind === 'clientSide')
|
|
72
|
+
target['nxis:targetKind'] = kind;
|
|
73
|
+
const pageUrl = str(nxisValue(raw, 'pageUrl'));
|
|
74
|
+
if (pageUrl)
|
|
75
|
+
target['nxis:pageUrl'] = pageUrl;
|
|
76
|
+
if (nxisValue(raw, 'jsHandled') === true)
|
|
77
|
+
target['nxis:jsHandled'] = true;
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
80
|
+
function parseInput(raw) {
|
|
81
|
+
if (!isObj(raw))
|
|
82
|
+
return null;
|
|
83
|
+
const valueName = str(schemaValue(raw, 'valueName'));
|
|
84
|
+
if (!valueName)
|
|
85
|
+
return null;
|
|
86
|
+
const declared = str(nxisValue(raw, 'valueType'));
|
|
87
|
+
const spec = {
|
|
88
|
+
'@type': 'PropertyValueSpecification',
|
|
89
|
+
valueName,
|
|
90
|
+
'nxis:valueType': declared && VALUE_TYPES.includes(declared) ? declared : 'string',
|
|
91
|
+
};
|
|
92
|
+
const description = str(schemaValue(raw, 'description'));
|
|
93
|
+
if (description)
|
|
94
|
+
spec.description = description;
|
|
95
|
+
if (schemaValue(raw, 'valueRequired') === true)
|
|
96
|
+
spec.valueRequired = true;
|
|
97
|
+
const defaultValue = str(schemaValue(raw, 'defaultValue'));
|
|
98
|
+
if (defaultValue !== undefined)
|
|
99
|
+
spec.defaultValue = defaultValue;
|
|
100
|
+
for (const key of ['valueMinLength', 'valueMaxLength', 'minValue', 'maxValue', 'stepValue']) {
|
|
101
|
+
const v = num(schemaValue(raw, key));
|
|
102
|
+
if (v !== undefined)
|
|
103
|
+
spec[key] = v;
|
|
104
|
+
}
|
|
105
|
+
const valuePattern = str(schemaValue(raw, 'valuePattern'));
|
|
106
|
+
if (valuePattern)
|
|
107
|
+
spec.valuePattern = valuePattern;
|
|
108
|
+
if (schemaValue(raw, 'multipleValues') === true)
|
|
109
|
+
spec.multipleValues = true;
|
|
110
|
+
if (schemaValue(raw, 'readonlyValue') === true)
|
|
111
|
+
spec.readonlyValue = true;
|
|
112
|
+
const rawOptions = nxisValue(raw, 'valueOption');
|
|
113
|
+
const options = [];
|
|
114
|
+
for (const o of Array.isArray(rawOptions) ? rawOptions : []) {
|
|
115
|
+
if (!isObj(o))
|
|
116
|
+
continue;
|
|
117
|
+
const value = str(schemaValue(o, 'value'));
|
|
118
|
+
if (value === undefined)
|
|
119
|
+
continue;
|
|
120
|
+
const label = str(schemaValue(o, 'name'));
|
|
121
|
+
options.push(label ? { '@type': 'nxis:ValueOption', value, name: label } : { '@type': 'nxis:ValueOption', value });
|
|
122
|
+
}
|
|
123
|
+
if (options.length)
|
|
124
|
+
spec['nxis:valueOption'] = options;
|
|
125
|
+
return spec;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Whether two URLs name the same page, ignoring the query and fragment.
|
|
129
|
+
*
|
|
130
|
+
* A form is the same form whether it was reached with tracking parameters or
|
|
131
|
+
* without.
|
|
132
|
+
*/
|
|
133
|
+
export function samePage(a, b) {
|
|
134
|
+
if (!a || !b)
|
|
135
|
+
return false;
|
|
136
|
+
try {
|
|
137
|
+
const x = new URL(a, b);
|
|
138
|
+
const y = new URL(b, a);
|
|
139
|
+
return x.origin === y.origin && x.pathname === y.pathname;
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Whether an action's form is on the page currently open.
|
|
147
|
+
*
|
|
148
|
+
* @param action - The action to place.
|
|
149
|
+
* @param href - The current page. Defaults to the browser's.
|
|
150
|
+
*/
|
|
151
|
+
export function sameActionPage(action, href) {
|
|
152
|
+
const here = href ?? (typeof location === 'undefined' ? undefined : location.href);
|
|
153
|
+
return samePage(action.target['nxis:pageUrl'], here);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Whether an action can be carried out from this site.
|
|
157
|
+
*
|
|
158
|
+
* Actions run by filling the form on their own page, so the harness may later
|
|
159
|
+
* navigate to `nxis:pageUrl`. A record naming another origin, whether stale or
|
|
160
|
+
* tampered with, must never send the visitor there.
|
|
161
|
+
*/
|
|
162
|
+
function onOrigin(action, origin) {
|
|
163
|
+
const pageUrl = action.target['nxis:pageUrl'];
|
|
164
|
+
if (!pageUrl)
|
|
165
|
+
return false;
|
|
166
|
+
try {
|
|
167
|
+
return new URL(pageUrl, origin).origin === origin;
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The records in a tool result, whether structured or JSON text.
|
|
175
|
+
*
|
|
176
|
+
* Typed loosely because the SDK's result type also admits the legacy
|
|
177
|
+
* `{ toolResult }` shape, which carries neither.
|
|
178
|
+
*/
|
|
179
|
+
function readResults(result) {
|
|
180
|
+
const text = (Array.isArray(result.content) ? result.content : [])
|
|
181
|
+
.map((c) => (isObj(c) && typeof c.text === 'string' ? c.text : ''))
|
|
182
|
+
.join('');
|
|
183
|
+
if (result.isError)
|
|
184
|
+
throw new Error(text || 'nxis_query failed');
|
|
185
|
+
let body = result.structuredContent;
|
|
186
|
+
if (!isObj(body)) {
|
|
187
|
+
try {
|
|
188
|
+
body = JSON.parse(text);
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
throw new Error('nxis_query returned a response that is not JSON');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const b = body;
|
|
195
|
+
return {
|
|
196
|
+
results: Array.isArray(b.results) ? b.results : [],
|
|
197
|
+
nextPageToken: str(b.next_page_token) || undefined,
|
|
198
|
+
total: num(b.total),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Query every Action record on the server.
|
|
203
|
+
*
|
|
204
|
+
* `schema_type: "Action"` does not yet expand to subtypes on the server, so
|
|
205
|
+
* this matches on `@type` instead and filters the results here. When the server
|
|
206
|
+
* supports the Action hierarchy, only this function needs to change.
|
|
207
|
+
*/
|
|
208
|
+
async function queryActionRecords(client) {
|
|
209
|
+
const records = [];
|
|
210
|
+
let pageToken;
|
|
211
|
+
let total;
|
|
212
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
213
|
+
const result = await client.callTool({
|
|
214
|
+
name: 'nxis_query',
|
|
215
|
+
arguments: {
|
|
216
|
+
filter: {
|
|
217
|
+
schema_type: '',
|
|
218
|
+
field_filters: [{ path: '@type', operator: 'CONTAINS', value: 'Action' }],
|
|
219
|
+
},
|
|
220
|
+
limit: PAGE_LIMIT,
|
|
221
|
+
...(pageToken ? { page_token: pageToken } : {}),
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
const read = readResults(result);
|
|
225
|
+
records.push(...read.results);
|
|
226
|
+
total = read.total ?? total;
|
|
227
|
+
pageToken = read.nextPageToken;
|
|
228
|
+
if (!pageToken)
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
if (total !== undefined && records.length < total) {
|
|
232
|
+
console.warn(`[nxis-mcp] site actions truncated: fetched ${records.length} of ${total} — ` +
|
|
233
|
+
'the server returned no further pages');
|
|
234
|
+
}
|
|
235
|
+
return records;
|
|
236
|
+
}
|
|
237
|
+
/** The tab's session storage, or null where it is unavailable or blocked. */
|
|
238
|
+
function defaultStorage() {
|
|
239
|
+
try {
|
|
240
|
+
return typeof sessionStorage === 'undefined' ? null : sessionStorage;
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function readCache(storage, key, now, ttl) {
|
|
247
|
+
if (!storage)
|
|
248
|
+
return null;
|
|
249
|
+
try {
|
|
250
|
+
const entry = JSON.parse(storage.getItem(key) || 'null');
|
|
251
|
+
if (!entry || !Array.isArray(entry.actions) || typeof entry.fetchedAt !== 'number')
|
|
252
|
+
return null;
|
|
253
|
+
if (now - entry.fetchedAt > ttl || entry.fetchedAt > now)
|
|
254
|
+
return null;
|
|
255
|
+
return entry.actions;
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function writeCache(storage, key, entry) {
|
|
262
|
+
try {
|
|
263
|
+
storage?.setItem(key, JSON.stringify(entry));
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
// Full or blocked storage costs a refetch on the next page, nothing more.
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Every Action on the site that can be carried out from this origin.
|
|
271
|
+
*
|
|
272
|
+
* Reuses a list fetched in the same tab within the last ten minutes, so moving
|
|
273
|
+
* between pages costs one request per session rather than one per page.
|
|
274
|
+
*
|
|
275
|
+
* @param client - A connected client for the site's MCP server. The query is a
|
|
276
|
+
* public read and needs no key.
|
|
277
|
+
* @param info - The server's details; its endpoint keys the cache.
|
|
278
|
+
* @param opts - Origin, cache and clock overrides.
|
|
279
|
+
* @returns The actions, each once, in the order the server returned them.
|
|
280
|
+
* @throws When the query itself fails. The caller decides whether that matters.
|
|
281
|
+
*/
|
|
282
|
+
export async function loadSiteActions(client, info, opts = {}) {
|
|
283
|
+
const origin = opts.origin ?? location.origin;
|
|
284
|
+
const storage = opts.storage === undefined ? defaultStorage() : opts.storage;
|
|
285
|
+
const now = (opts.now ?? Date.now)();
|
|
286
|
+
const key = CACHE_PREFIX + info.endpoint;
|
|
287
|
+
const cached = readCache(storage, key, now, opts.ttlMs ?? CACHE_TTL_MS);
|
|
288
|
+
if (cached)
|
|
289
|
+
return cached;
|
|
290
|
+
const seen = new Set();
|
|
291
|
+
const actions = [];
|
|
292
|
+
let offOrigin = 0;
|
|
293
|
+
for (const record of await queryActionRecords(client)) {
|
|
294
|
+
const action = parseAction(record);
|
|
295
|
+
if (!action || seen.has(action['@id']))
|
|
296
|
+
continue;
|
|
297
|
+
seen.add(action['@id']);
|
|
298
|
+
if (!onOrigin(action, origin)) {
|
|
299
|
+
offOrigin++;
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
actions.push(action);
|
|
303
|
+
}
|
|
304
|
+
if (offOrigin) {
|
|
305
|
+
console.warn(`[nxis-mcp] ignored ${offOrigin} site action(s) whose page is not on ${origin}`);
|
|
306
|
+
}
|
|
307
|
+
writeCache(storage, key, { fetchedAt: now, actions });
|
|
308
|
+
return actions;
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=site-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-actions.js","sourceRoot":"","sources":["../../../src/harness/tools/site-actions.ts"],"names":[],"mappings":"AAwBA,MAAM,SAAS,GAAG,qBAAqB,CAAC;AACxC,MAAM,OAAO,GAAG,qBAAqB,CAAC;AAEtC,sDAAsD;AACtD,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,iEAAiE;AACjE,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,2EAA2E;AAC3E,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACpC,MAAM,YAAY,GAAG,uBAAuB,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AO,MAAM,CAAC;IAE1B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,MAAM,IAAI,MAAM,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtD,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAAE,SAAS;QACjD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACxB,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;YAC9B,SAAS,EAAE,CAAC;YACZ,SAAS;QACX,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CAAC,IAAI,CACV,sBAAsB,SAAS,wCAAwC,MAAM,EAAE,CAChF,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;IACtD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -15,14 +15,30 @@
|
|
|
15
15
|
import { registerRemoteTools, type BridgeOptions } from './bridge.js';
|
|
16
16
|
import { connectMcp } from './client.js';
|
|
17
17
|
import { discoverMcpServer } from './discovery.js';
|
|
18
|
+
import { loadSiteActions, type SiteActionsOptions } from './site-actions.js';
|
|
18
19
|
import type { ModelContext } from '../../types.js';
|
|
20
|
+
import type { NxisAction } from '../../webmcp-contract.js';
|
|
19
21
|
/** The outcome of {@link connectTools}. */
|
|
20
22
|
export interface ConnectResult {
|
|
21
23
|
/** The registry the tools were registered into, or null if none was found. */
|
|
22
24
|
modelContext: ModelContext | null;
|
|
23
25
|
/** Remote tool names bridged in. Empty when discovery failed or was skipped. */
|
|
24
26
|
remoteTools: string[];
|
|
25
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Every Action on the site, from any page, that belongs to this origin.
|
|
29
|
+
*
|
|
30
|
+
* Empty when discovery failed, the query failed, or it was turned off with
|
|
31
|
+
* {@link ConnectOptions.siteActions}.
|
|
32
|
+
*/
|
|
33
|
+
siteActions: NxisAction[];
|
|
34
|
+
/**
|
|
35
|
+
* The tools registered for {@link siteActions}.
|
|
36
|
+
*
|
|
37
|
+
* Fewer than the actions: those that share a name and a set of fields become
|
|
38
|
+
* one tool that chooses between them.
|
|
39
|
+
*/
|
|
40
|
+
siteTools: string[];
|
|
41
|
+
/** Why remote tools or site actions are absent, when they are. Never fatal. */
|
|
26
42
|
warning?: string;
|
|
27
43
|
}
|
|
28
44
|
/**
|
|
@@ -45,6 +61,13 @@ export interface ConnectOptions {
|
|
|
45
61
|
fallback?: boolean;
|
|
46
62
|
/** Override which of the server's tools are bridged in. */
|
|
47
63
|
accept?: BridgeOptions['accept'];
|
|
64
|
+
/**
|
|
65
|
+
* Fetch the site's Actions from every page, not only this one.
|
|
66
|
+
*
|
|
67
|
+
* Defaults to true. Pass false to skip the query, or an options object to
|
|
68
|
+
* override the origin check or the cache.
|
|
69
|
+
*/
|
|
70
|
+
siteActions?: boolean | SiteActionsOptions;
|
|
48
71
|
}
|
|
49
72
|
/**
|
|
50
73
|
* Wait for a tool registry, then bridge in a remote MCP server's tools.
|
|
@@ -54,12 +77,28 @@ export interface ConnectOptions {
|
|
|
54
77
|
* page's own tools working, and a site with no MCP server is an ordinary case
|
|
55
78
|
* rather than an error.
|
|
56
79
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
80
|
+
* Connects each registry once. A second call for the same registry, such as a
|
|
81
|
+
* page script and the element both connecting, returns the first call's result
|
|
82
|
+
* rather than registering the same tools again, which a native `modelContext`
|
|
83
|
+
* rejects as a duplicate.
|
|
84
|
+
*
|
|
85
|
+
* @param apiKey - Key for the remote server's private tools. Public tools need
|
|
86
|
+
* none, and the element never supplies one: a key readable in the page is a
|
|
87
|
+
* published key. Pass one only where it is short-lived and scoped, such as a
|
|
88
|
+
* token your backend mints per session.
|
|
89
|
+
* @param opts - Timeout, local-registry fallback, and a tool filter. Only the
|
|
90
|
+
* first call's options apply to a registry.
|
|
60
91
|
* @returns The registry, the remote tools bridged in, and any warning.
|
|
61
92
|
*/
|
|
62
93
|
export declare function connectTools(apiKey?: string, opts?: ConnectOptions): Promise<ConnectResult>;
|
|
63
|
-
export { discoverMcpServer, connectMcp, registerRemoteTools };
|
|
94
|
+
export { discoverMcpServer, connectMcp, registerRemoteTools, loadSiteActions };
|
|
95
|
+
export { registerSiteActionTools, buildSiteActionTools, withoutShadowedTools, handoffFor, findPageTool, awaitPageTool, pageToolRef, siteToolName, selectSiteTools, } from './action-tools.js';
|
|
96
|
+
export { resumePendingAction } from './resume.js';
|
|
97
|
+
export type { ResumeOutcome, ResumeOptions } from './resume.js';
|
|
98
|
+
export type { SiteActionTool, Handoff, PageToolRef } from './action-tools.js';
|
|
99
|
+
export { savePendingAction, takePendingAction, clearPendingAction, } from './pending-action.js';
|
|
100
|
+
export type { PendingAction } from './pending-action.js';
|
|
101
|
+
export { parseAction, samePage, sameActionPage } from './site-actions.js';
|
|
102
|
+
export type { SiteActionsOptions } from './site-actions.js';
|
|
64
103
|
export { ensureModelContext, LocalModelContext } from './local-context.js';
|
|
65
104
|
//# sourceMappingURL=source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO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,EAAE,OAAO,GAAG,kBAAkB,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,YAAY,CAChC,MAAM,CAAC,EAAE,MAAM,EACf,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,aAAa,CAAC,CAmBxB;AAgDD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC;AAC/E,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -16,6 +16,8 @@ import { registerRemoteTools } from './bridge.js';
|
|
|
16
16
|
import { ensureModelContext } from './local-context.js';
|
|
17
17
|
import { connectMcp } from './client.js';
|
|
18
18
|
import { discoverMcpServer } from './discovery.js';
|
|
19
|
+
import { loadSiteActions } from './site-actions.js';
|
|
20
|
+
import { registerSiteActionTools } from './action-tools.js';
|
|
19
21
|
const READY_TIMEOUT_MS = 20000;
|
|
20
22
|
const POLL_INTERVAL_MS = 200;
|
|
21
23
|
/** The page's model context, from either of the two places it may appear. */
|
|
@@ -55,9 +57,17 @@ export function waitForModelContext(timeout = READY_TIMEOUT_MS) {
|
|
|
55
57
|
* page's own tools working, and a site with no MCP server is an ordinary case
|
|
56
58
|
* rather than an error.
|
|
57
59
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
60
|
+
* Connects each registry once. A second call for the same registry, such as a
|
|
61
|
+
* page script and the element both connecting, returns the first call's result
|
|
62
|
+
* rather than registering the same tools again, which a native `modelContext`
|
|
63
|
+
* rejects as a duplicate.
|
|
64
|
+
*
|
|
65
|
+
* @param apiKey - Key for the remote server's private tools. Public tools need
|
|
66
|
+
* none, and the element never supplies one: a key readable in the page is a
|
|
67
|
+
* published key. Pass one only where it is short-lived and scoped, such as a
|
|
68
|
+
* token your backend mints per session.
|
|
69
|
+
* @param opts - Timeout, local-registry fallback, and a tool filter. Only the
|
|
70
|
+
* first call's options apply to a registry.
|
|
61
71
|
* @returns The registry, the remote tools bridged in, and any warning.
|
|
62
72
|
*/
|
|
63
73
|
export async function connectTools(apiKey, opts = {}) {
|
|
@@ -67,23 +77,62 @@ export async function connectTools(apiKey, opts = {}) {
|
|
|
67
77
|
return {
|
|
68
78
|
modelContext: null,
|
|
69
79
|
remoteTools: [],
|
|
80
|
+
siteActions: [],
|
|
81
|
+
siteTools: [],
|
|
70
82
|
warning: 'WebMCP (document.modelContext) unavailable — no tools registered.',
|
|
71
83
|
};
|
|
72
84
|
}
|
|
85
|
+
let connection = connections.get(mc);
|
|
86
|
+
if (!connection) {
|
|
87
|
+
connection = connectRegistry(mc, apiKey, opts);
|
|
88
|
+
connections.set(mc, connection);
|
|
89
|
+
}
|
|
90
|
+
return connection;
|
|
91
|
+
}
|
|
92
|
+
/** One connection per registry, shared by every caller. */
|
|
93
|
+
const connections = new WeakMap();
|
|
94
|
+
async function connectRegistry(mc, apiKey, opts) {
|
|
95
|
+
let info;
|
|
96
|
+
let client;
|
|
97
|
+
let remoteTools;
|
|
73
98
|
try {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return { modelContext: mc, remoteTools };
|
|
99
|
+
info = await discoverMcpServer();
|
|
100
|
+
client = await connectMcp(info, apiKey);
|
|
101
|
+
remoteTools = await registerRemoteTools(client, mc, info, { accept: opts.accept });
|
|
78
102
|
}
|
|
79
103
|
catch (err) {
|
|
80
104
|
return {
|
|
81
105
|
modelContext: mc,
|
|
82
106
|
remoteTools: [],
|
|
83
|
-
|
|
107
|
+
siteActions: [],
|
|
108
|
+
siteTools: [],
|
|
109
|
+
warning: `remote tool bootstrap failed — on-page tools still work: ${errorText(err)}`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (opts.siteActions === false) {
|
|
113
|
+
return { modelContext: mc, remoteTools, siteActions: [], siteTools: [] };
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const siteOpts = typeof opts.siteActions === 'object' ? opts.siteActions : {};
|
|
117
|
+
const siteActions = await loadSiteActions(client, info, siteOpts);
|
|
118
|
+
const siteTools = await registerSiteActionTools(mc, siteActions);
|
|
119
|
+
return { modelContext: mc, remoteTools, siteActions, siteTools };
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
return {
|
|
123
|
+
modelContext: mc,
|
|
124
|
+
remoteTools,
|
|
125
|
+
siteActions: [],
|
|
126
|
+
siteTools: [],
|
|
127
|
+
warning: `site actions unavailable — this page's own actions still work: ${errorText(err)}`,
|
|
84
128
|
};
|
|
85
129
|
}
|
|
86
130
|
}
|
|
87
|
-
|
|
131
|
+
const errorText = (err) => String(err?.message || err);
|
|
132
|
+
export { discoverMcpServer, connectMcp, registerRemoteTools, loadSiteActions };
|
|
133
|
+
export { registerSiteActionTools, buildSiteActionTools, withoutShadowedTools, handoffFor, findPageTool, awaitPageTool, pageToolRef, siteToolName, selectSiteTools, } from './action-tools.js';
|
|
134
|
+
export { resumePendingAction } from './resume.js';
|
|
135
|
+
export { savePendingAction, takePendingAction, clearPendingAction, } from './pending-action.js';
|
|
136
|
+
export { parseAction, samePage, sameActionPage } from './site-actions.js';
|
|
88
137
|
export { ensureModelContext, LocalModelContext } from './local-context.js';
|
|
89
138
|
//# sourceMappingURL=source.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../../src/harness/tools/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,mBAAmB,EAAsB,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../../src/harness/tools/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,mBAAmB,EAAsB,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAA2B,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAK5D,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AA0B7B,6EAA6E;AAC7E,SAAS,eAAe;IACtB,OAAO,QAAQ,CAAC,YAAY,IAAI,SAAS,CAAC,YAAY,IAAI,IAAI,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAO,GAAG,gBAAgB;IAC5D,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC;IACpC,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ICON_MENU, ICON_TRASH, ICON_STOP, ICON_COPY, ICON_PENCIL, ICON_REDO, ICON_CHECK_MARK, } from './engine.js';
|
|
47
47
|
export type { AgentEngineOptions, ChatMessage, ToolDef, GenerationUsage, ParsedToolCall, ProgressDetail, PreloadMode, } from './engine.js';
|
|
48
48
|
export { connectTools, waitForModelContext } from './harness/tools/source.js';
|
|
49
|
-
export
|
|
49
|
+
export { buildSiteActionTools, registerSiteActionTools, withoutShadowedTools, handoffFor, findPageTool, awaitPageTool, pageToolRef, siteToolName, sanitizeToolName, selectSiteTools, DEFAULT_SITE_TOOL_LIMIT, } from './harness/tools/action-tools.js';
|
|
50
|
+
export { beginJourney, currentJourney, journeySteps, onJourneyChange, recordStep, restoreJourney, } from './harness/steps.js';
|
|
51
|
+
export type { AgentStep, AgentStepId, AgentStepStatus } from './harness/steps.js';
|
|
52
|
+
export { resumePendingAction } from './harness/tools/resume.js';
|
|
53
|
+
export type { ResumeOutcome, ResumeOptions } from './harness/tools/resume.js';
|
|
54
|
+
export type { SiteActionTool, Handoff, PageToolRef } from './harness/tools/action-tools.js';
|
|
55
|
+
export { savePendingAction, takePendingAction, clearPendingAction, PENDING_TTL_MS, } from './harness/tools/pending-action.js';
|
|
56
|
+
export type { PendingAction } from './harness/tools/pending-action.js';
|
|
57
|
+
export { loadSiteActions, parseAction } from './harness/tools/site-actions.js';
|
|
58
|
+
export type { ConnectResult, ConnectOptions, SiteActionsOptions } from './harness/tools/source.js';
|
|
50
59
|
export type { BridgeOptions } from './harness/tools/bridge.js';
|
|
51
60
|
export type { JsonSchema, ModelContext, ModelContextTool, ModelContextToolInfo, ModelContextToolResponse, McpServerInfo, NxisConfig, } from './types.js';
|
|
52
61
|
export type { NxisAction, NxisEntryPoint, NxisPropertyValueSpecification, NxisValueOption, } from './webmcp-contract.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names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