@happyvertical/smrt-web 0.43.10 → 0.44.1
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/AGENTS.md +93 -1
- package/dist/chunks/intents-BUTyN7YQ.js +390 -0
- package/dist/chunks/intents-BUTyN7YQ.js.map +1 -0
- package/dist/chunks/{src-n14q6RHC.js → src-D1ZtD6Bt.js} +54 -24
- package/dist/chunks/{src-n14q6RHC.js.map → src-D1ZtD6Bt.js.map} +1 -1
- package/dist/index.d.ts +320 -0
- package/dist/index.js +3 -2
- package/dist/intents.d.ts +300 -0
- package/dist/intents.js +2 -0
- package/dist/webmcp.d.ts +244 -0
- package/dist/webmcp.js +2 -2
- package/package.json +7 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c as capabilityAnnotations, l as resolveDeclaredCapability, n as compileViewIntentToolSpec, s as WEBMCP_TOOL_EFFECTS } from "./intents-BUTyN7YQ.js";
|
|
1
2
|
import { createCollection } from "@tanstack/db";
|
|
2
3
|
import { QueryClient } from "@tanstack/query-core";
|
|
3
4
|
import { queryCollectionOptions } from "@tanstack/query-db-collection";
|
|
@@ -2194,11 +2195,45 @@ function registerWebMcpTools(definitions, options = {}) {
|
|
|
2194
2195
|
function registrationDisposer(dispose, ready) {
|
|
2195
2196
|
return Object.assign(dispose, { ready });
|
|
2196
2197
|
}
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2198
|
+
function registerWebMcpBespokeTool(spec, options = {}) {
|
|
2199
|
+
const { allowedEffects } = validateExposurePolicy(options);
|
|
2200
|
+
const ctx = getModelContext();
|
|
2201
|
+
if (!ctx) return registrationDisposer(() => {}, Promise.resolve());
|
|
2202
|
+
const semantics = actionSemantics("bespoke", bespokeDeclaredSemantics(spec.annotations));
|
|
2203
|
+
if (!allowedEffects.has(semantics.effect)) return registrationDisposer(() => {}, Promise.resolve());
|
|
2204
|
+
const controller = new AbortController();
|
|
2205
|
+
let disposed = false;
|
|
2206
|
+
const dispose = () => {
|
|
2207
|
+
disposed = true;
|
|
2208
|
+
controller.abort();
|
|
2209
|
+
};
|
|
2210
|
+
let registration;
|
|
2211
|
+
try {
|
|
2212
|
+
registration = ctx.registerTool({
|
|
2213
|
+
name: spec.name,
|
|
2214
|
+
description: spec.description,
|
|
2215
|
+
inputSchema: spec.inputSchema,
|
|
2216
|
+
annotations: annotationsFor(semantics),
|
|
2217
|
+
execute: guardedExecute({
|
|
2218
|
+
name: spec.name,
|
|
2219
|
+
effect: semantics.effect
|
|
2220
|
+
}, allowedEffects, () => disposed, spec.execute)
|
|
2221
|
+
}, { signal: controller.signal });
|
|
2222
|
+
} catch (error) {
|
|
2223
|
+
dispose();
|
|
2224
|
+
throw error;
|
|
2225
|
+
}
|
|
2226
|
+
const ready = Promise.resolve(registration).catch((error) => {
|
|
2227
|
+
dispose();
|
|
2228
|
+
throw error;
|
|
2229
|
+
});
|
|
2230
|
+
ready.catch(() => void 0);
|
|
2231
|
+
return registrationDisposer(dispose, ready);
|
|
2232
|
+
}
|
|
2233
|
+
function registerViewIntent(intent, binding, options = {}) {
|
|
2234
|
+
return registerWebMcpBespokeTool(compileViewIntentToolSpec(intent, binding), options);
|
|
2235
|
+
}
|
|
2236
|
+
var VALID_EFFECTS = WEBMCP_TOOL_EFFECTS;
|
|
2202
2237
|
var NAMESPACE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
2203
2238
|
function validateExposurePolicy(options) {
|
|
2204
2239
|
const effects = options.effects ?? ["read"];
|
|
@@ -2219,7 +2254,7 @@ function selectProspectiveTools(definitions, options, exposure) {
|
|
|
2219
2254
|
const tools = [];
|
|
2220
2255
|
for (const definition of stableDefinitions) {
|
|
2221
2256
|
if (isCanonicalToolDefinition(definition)) {
|
|
2222
|
-
const semantics =
|
|
2257
|
+
const semantics = resolveDeclaredCapability(definition);
|
|
2223
2258
|
if (!allowedEffects.has(semantics.effect)) continue;
|
|
2224
2259
|
if (options.filter && !options.filterTool) throw new Error("[smrt-web] canonical WebMCP definitions require filterTool when filter is configured");
|
|
2225
2260
|
const stableDefinition2 = snapshotCanonicalDefinition(definition, semantics);
|
|
@@ -2288,17 +2323,18 @@ function actionSemantics(action, declared) {
|
|
|
2288
2323
|
idempotent: true,
|
|
2289
2324
|
openWorld: false
|
|
2290
2325
|
};
|
|
2291
|
-
default:
|
|
2292
|
-
const effect = VALID_EFFECTS.includes(declared.effect) ? declared.effect : "destructive";
|
|
2293
|
-
return {
|
|
2294
|
-
effect,
|
|
2295
|
-
destructive: effect !== "read",
|
|
2296
|
-
idempotent: declared.idempotent ?? false,
|
|
2297
|
-
openWorld: declared.openWorld ?? true
|
|
2298
|
-
};
|
|
2299
|
-
}
|
|
2326
|
+
default: return resolveDeclaredCapability(declared);
|
|
2300
2327
|
}
|
|
2301
2328
|
}
|
|
2329
|
+
function bespokeDeclaredSemantics(annotations) {
|
|
2330
|
+
if (!annotations) return {};
|
|
2331
|
+
const effect = annotations.destructiveHint === true ? "destructive" : annotations.readOnlyHint === true ? "read" : annotations.destructiveHint === false ? "write" : void 0;
|
|
2332
|
+
return {
|
|
2333
|
+
...effect ? { effect } : {},
|
|
2334
|
+
...annotations.idempotentHint !== void 0 ? { idempotent: annotations.idempotentHint } : {},
|
|
2335
|
+
...annotations.openWorldHint !== void 0 ? { openWorld: annotations.openWorldHint } : {}
|
|
2336
|
+
};
|
|
2337
|
+
}
|
|
2302
2338
|
function snapshotRoute(route) {
|
|
2303
2339
|
return route ? snapshotValue(route) : void 0;
|
|
2304
2340
|
}
|
|
@@ -2359,13 +2395,7 @@ function validateProspectiveTools(tools, maxTools) {
|
|
|
2359
2395
|
}
|
|
2360
2396
|
}
|
|
2361
2397
|
function annotationsFor(tool) {
|
|
2362
|
-
return
|
|
2363
|
-
readOnlyHint: tool.effect === "read",
|
|
2364
|
-
destructiveHint: tool.destructive,
|
|
2365
|
-
idempotentHint: tool.idempotent,
|
|
2366
|
-
openWorldHint: tool.openWorld,
|
|
2367
|
-
untrustedContentHint: true
|
|
2368
|
-
};
|
|
2398
|
+
return capabilityAnnotations(tool);
|
|
2369
2399
|
}
|
|
2370
2400
|
function guardedExecute(tool, allowedEffects, isDisposed, execute) {
|
|
2371
2401
|
return (args) => {
|
|
@@ -2998,6 +3028,6 @@ function createSmrtCollection(definition, options) {
|
|
|
2998
3028
|
return handle;
|
|
2999
3029
|
}
|
|
3000
3030
|
//#endregion
|
|
3001
|
-
export {
|
|
3031
|
+
export { MAX_SMRT_WEB_DATA_QUERY_OFFSET as A, offlineOutbox as C, MAX_SMRT_WEB_DATA_QUERY_CONTAINER_ITEMS as D, wipeDurableStore as E, MAX_SMRT_WEB_DATA_QUERY_WARNINGS as F, executeSmrtWebDataQuery as I, normalizeSmrtWebDataQueryResult as L, MAX_SMRT_WEB_DATA_QUERY_RESULT_BYTES as M, MAX_SMRT_WEB_DATA_QUERY_ROWS as N, MAX_SMRT_WEB_DATA_QUERY_FACETS as O, MAX_SMRT_WEB_DATA_QUERY_STRING_LENGTH as P, runWrapMutation as R, getOutboxHandle as S, registerDurableResource as T, createSmrtWebEventSubscriber as _, createSmrtWebClient as a, DEFAULT_PERSIST_DEBOUNCE_MS as b, newLocalId as c, unwrapListResult as d, validateSmrtWebClient as f, createUpdateState as g, registerWebMcpTools as h, createSmrtCollection as i, MAX_SMRT_WEB_DATA_QUERY_PAGE_LIMIT as j, MAX_SMRT_WEB_DATA_QUERY_FACET_VALUES as k, throwIfSmrtWebError as l, registerWebMcpBespokeTool as m, buildListQuery as n, getEngineCollection as o, registerViewIntent as p, createDefinitionFetchers as r, invalidateSmrtWebCollections as s, SmrtWebRequestError as t, unwrapItemResult as u, liveInvalidation as v, durableStoreNamespace as w, persistCollection as x, createSmrtWebQuery as y };
|
|
3002
3032
|
|
|
3003
|
-
//# sourceMappingURL=src-
|
|
3033
|
+
//# sourceMappingURL=src-D1ZtD6Bt.js.map
|