@happyvertical/smrt-app-mcp 0.60.18 → 0.61.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.
Files changed (38) hide show
  1. package/AGENTS.md +12 -0
  2. package/README.md +40 -0
  3. package/agents/runtime-loading.md +21 -0
  4. package/dist/__smrt-register__.d.ts +2 -0
  5. package/dist/__smrt-register__.d.ts.map +1 -0
  6. package/dist/audit-store.d.ts +53 -0
  7. package/dist/audit-store.d.ts.map +1 -0
  8. package/dist/audit-store.js +149 -0
  9. package/dist/audit-store.js.map +1 -0
  10. package/dist/audit.d.ts +59 -0
  11. package/dist/audit.d.ts.map +1 -0
  12. package/dist/chunks/{protocol-BRQji5k_.js → defaults-i3kpRFpB.js} +190 -149
  13. package/dist/chunks/defaults-i3kpRFpB.js.map +1 -0
  14. package/dist/chunks/{errors-XG_zn1pP.js → errors-C704k8Mv.js} +3 -2
  15. package/dist/chunks/errors-C704k8Mv.js.map +1 -0
  16. package/dist/chunks/protocol-D_O2WaCO.js +153 -0
  17. package/dist/chunks/protocol-D_O2WaCO.js.map +1 -0
  18. package/dist/errors.d.ts +2 -0
  19. package/dist/errors.d.ts.map +1 -1
  20. package/dist/host-operations.js +1 -1
  21. package/dist/index.d.ts +2 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +4 -3
  24. package/dist/index.js.map +1 -1
  25. package/dist/manifest.json +435 -3
  26. package/dist/server.d.ts +39 -0
  27. package/dist/server.d.ts.map +1 -1
  28. package/dist/smrt-knowledge.json +174 -8
  29. package/dist/smrt-knowledge.okf.md +17 -4
  30. package/dist/sveltekit.d.ts +1 -1
  31. package/dist/sveltekit.d.ts.map +1 -1
  32. package/dist/sveltekit.js +4 -3
  33. package/dist/sveltekit.js.map +1 -1
  34. package/dist/workflow-tools.d.ts +14 -0
  35. package/dist/workflow-tools.d.ts.map +1 -1
  36. package/package.json +14 -6
  37. package/dist/chunks/errors-XG_zn1pP.js.map +0 -1
  38. package/dist/chunks/protocol-BRQji5k_.js.map +0 -1
@@ -12,6 +12,7 @@ var McpAccessError = class extends Error {
12
12
  metadata;
13
13
  };
14
14
  var MCP_TOOL_NOT_FOUND_CODE = "mcp_tool_not_found";
15
+ var MCP_CONFIRM_REQUIRED_CODE = "confirm_required";
15
16
  var MCP_AUTHENTICATION_REQUIRED_CODE = "mcp_authentication_required";
16
17
  var MCP_TOOL_EXECUTION_FAILED_CODE = "mcp_tool_execution_failed";
17
18
  var MCP_TOOL_EXECUTION_FAILED_MESSAGE = "Workflow execution failed.";
@@ -68,6 +69,6 @@ function authoredMcpToolError(error, mapError) {
68
69
  } catch {}
69
70
  }
70
71
  //#endregion
71
- export { MCP_TOOL_NOT_FOUND_CODE as a, authoredMcpToolError as c, MCP_TOOL_EXECUTION_FAILED_CODE as i, safeMcpToolError as l, MCP_ORIGIN_DENIED_CODE as n, McpAccessError as o, MCP_TOOL_ACCESS_DENIED_CODE as r, McpToolError as s, MCP_AUTHENTICATION_REQUIRED_CODE as t };
72
+ export { MCP_TOOL_EXECUTION_FAILED_CODE as a, McpToolError as c, MCP_TOOL_ACCESS_DENIED_CODE as i, authoredMcpToolError as l, MCP_CONFIRM_REQUIRED_CODE as n, MCP_TOOL_NOT_FOUND_CODE as o, MCP_ORIGIN_DENIED_CODE as r, McpAccessError as s, MCP_AUTHENTICATION_REQUIRED_CODE as t, safeMcpToolError as u };
72
73
 
73
- //# sourceMappingURL=errors-XG_zn1pP.js.map
74
+ //# sourceMappingURL=errors-C704k8Mv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-C704k8Mv.js","names":[],"sources":["../../src/errors.ts"],"sourcesContent":["/** Machine-readable code for a principal policy denial. */\nexport const MCP_TOOL_ACCESS_DENIED_CODE = 'mcp_tool_access_denied';\n\n/** Machine-readable code for a request refused by the endpoint's origin check. */\nexport const MCP_ORIGIN_DENIED_CODE = 'mcp_origin_denied';\n\n/**\n * Metadata that is safe to expose for an app-MCP access failure. Policy\n * implementations must not place principal, scope, tool, or internal-error\n * details here.\n */\nexport interface McpAccessErrorMetadata {\n code?: string;\n retryable?: boolean;\n}\n\n/**\n * Error returned by the MCP app server when a caller tries to use a tool\n * they are not allowed to access. The HTTP layer should map `status` onto\n * the response status code.\n */\nexport class McpAccessError extends Error {\n constructor(\n readonly status: number,\n message: string,\n readonly metadata: McpAccessErrorMetadata = {},\n ) {\n super(message);\n this.name = 'McpAccessError';\n }\n}\n\n/** Stable code for a request naming a tool this server does not publish. */\nexport const MCP_TOOL_NOT_FOUND_CODE = 'mcp_tool_not_found';\n\n/** Stable code for a gated tool called without `arguments.confirm === true`. */\nexport const MCP_CONFIRM_REQUIRED_CODE = 'confirm_required';\n\n/** Stable code for a tool call that needs an authenticated principal. */\nexport const MCP_AUTHENTICATION_REQUIRED_CODE = 'mcp_authentication_required';\n\n/** Stable code for an unmapped handler failure; carries no internals. */\nexport const MCP_TOOL_EXECUTION_FAILED_CODE = 'mcp_tool_execution_failed';\n\n/** The generic message an unmapped handler failure returns. */\nexport const MCP_TOOL_EXECUTION_FAILED_MESSAGE = 'Workflow execution failed.';\n\n/** The agent-safe projection of a tool failure: a stable code and a message. */\nexport interface McpToolErrorInfo {\n code: string;\n message: string;\n /** Optional JSON-safe, non-sensitive structured detail. */\n details?: Record<string, unknown>;\n}\n\n/**\n * Throw from a workflow tool handler to hand the calling agent a typed,\n * authored failure. The `code` and `message` (and optional `details`) reach\n * the agent verbatim, so they must be safe to disclose: never put records,\n * credentials, stack traces, or other tenants' data in them. Any other\n * thrown value stays behind the generic failure message.\n */\nexport class McpToolError extends Error {\n readonly code: string;\n readonly details?: Record<string, unknown>;\n constructor(\n code: string,\n message: string,\n details?: Record<string, unknown>,\n ) {\n super(message);\n this.name = 'McpToolError';\n this.code = code;\n if (details !== undefined) this.details = details;\n }\n}\n\n/** Per-tool mapping of a handler failure to a safe code and message. */\nexport type McpToolErrorMapper = (\n error: unknown,\n) => McpToolErrorInfo | null | undefined;\n\nconst SAFE_CODE = /^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;\nconst MAX_SAFE_MESSAGE_LENGTH = 500;\nconst MAX_SAFE_DETAILS_BYTES = 4096;\n\nconst GENERIC_TOOL_ERROR: Readonly<McpToolErrorInfo> = Object.freeze({\n code: MCP_TOOL_EXECUTION_FAILED_CODE,\n message: MCP_TOOL_EXECUTION_FAILED_MESSAGE,\n});\n\nfunction validInfo(value: unknown): McpToolErrorInfo | undefined {\n if (!value || typeof value !== 'object') return undefined;\n const { code, message, details } = value as Record<string, unknown>;\n if (typeof code !== 'string' || !SAFE_CODE.test(code)) return undefined;\n if (\n typeof message !== 'string' ||\n !message.trim() ||\n message.length > MAX_SAFE_MESSAGE_LENGTH\n ) {\n return undefined;\n }\n const info: McpToolErrorInfo = { code, message };\n if (details !== undefined) {\n try {\n if (\n !details ||\n typeof details !== 'object' ||\n Array.isArray(details) ||\n typeof JSON.stringify(details) !== 'string' ||\n JSON.stringify(details).length > MAX_SAFE_DETAILS_BYTES\n ) {\n return undefined;\n }\n info.details = JSON.parse(JSON.stringify(details));\n } catch {\n return undefined;\n }\n }\n return info;\n}\n\n/**\n * Resolve a thrown value to the information that may reach an agent. Never\n * throws: a thrown {@link McpToolError} or a valid `mapError` result yields its\n * safe code and message; anything else (including a throwing or malformed\n * mapper) yields the generic failure.\n */\nexport function safeMcpToolError(\n error: unknown,\n mapError?: McpToolErrorMapper,\n): McpToolErrorInfo {\n return authoredMcpToolError(error, mapError) ?? { ...GENERIC_TOOL_ERROR };\n}\n\n/**\n * The authored (opt-in) safe error for a thrown value: a valid\n * {@link McpToolError} or `mapError` result, else `undefined`. Only this form\n * is typed on the MCP wire; an unmapped failure keeps the generic result.\n */\nexport function authoredMcpToolError(\n error: unknown,\n mapError?: McpToolErrorMapper,\n): McpToolErrorInfo | undefined {\n try {\n if (error instanceof McpToolError) {\n const info = validInfo({\n code: error.code,\n message: error.message,\n details: error.details,\n });\n if (info) return info;\n } else if (mapError) {\n const info = validInfo(mapError(error));\n if (info) return info;\n }\n } catch {\n // A mapper failure falls back to the generic message.\n }\n return undefined;\n}\n"],"mappings":";AACO,IAAM,8BAA8B;AAGpC,IAAM,yBAAyB;AAiB/B,IAAM,iBAAN,cAA6B,MAAM;CACxC,YACW,QACT,SACS,WAAmC,CAAC,GAC7C;EACA,MAAM,OAAO;EAJJ,KAAA,SAAA;EAEA,KAAA,WAAA;EAGT,KAAK,OAAO;CACd;CANW;CAEA;AAKb;AAGO,IAAM,0BAA0B;AAGhC,IAAM,4BAA4B;AAGlC,IAAM,mCAAmC;AAGzC,IAAM,iCAAiC;AAGvC,IAAM,oCAAoC;AAiB1C,IAAM,eAAN,cAA2B,MAAM;CAC7B;CACA;CACT,YACE,MACA,SACA,SACA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,IAAI,YAAY,KAAA,GAAW,KAAK,UAAU;CAC5C;AACF;AAOA,IAAM,YAAY;AAClB,IAAM,0BAA0B;AAChC,IAAM,yBAAyB;AAE/B,IAAM,qBAAiD,OAAO,OAAO;CACnE,MAAM;CACN,SAAS;AACX,CAAC;AAED,SAAS,UAAU,OAA8C;CAC/D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO,KAAA;CAChD,MAAM,EAAE,MAAM,SAAS,YAAY;CACnC,IAAI,OAAO,SAAS,YAAY,CAAC,UAAU,KAAK,IAAI,GAAG,OAAO,KAAA;CAC9D,IACE,OAAO,YAAY,YACnB,CAAC,QAAQ,KAAK,KACd,QAAQ,SAAS,yBAEjB;CAEF,MAAM,OAAyB;EAAE;EAAM;CAAQ;CAC/C,IAAI,YAAY,KAAA,GACd,IAAI;EACF,IACE,CAAC,WACD,OAAO,YAAY,YACnB,MAAM,QAAQ,OAAO,KACrB,OAAO,KAAK,UAAU,OAAO,MAAM,YACnC,KAAK,UAAU,OAAO,CAAA,CAAE,SAAS,wBAEjC;EAEF,KAAK,UAAU,KAAK,MAAM,KAAK,UAAU,OAAO,CAAC;CACnD,QAAQ;EACN;CACF;CAEF,OAAO;AACT;AAQO,SAAS,iBACd,OACA,UACkB;CAClB,OAAO,qBAAqB,OAAO,QAAQ,KAAK,EAAE,GAAG,mBAAmB;AAC1E;AAOO,SAAS,qBACd,OACA,UAC8B;CAC9B,IAAI;EACF,IAAI,iBAAiB,cAAc;GACjC,MAAM,OAAO,UAAU;IACrB,MAAM,MAAM;IACZ,SAAS,MAAM;IACf,SAAS,MAAM;GACjB,CAAC;GACD,IAAI,MAAM,OAAO;EACnB,OAAA,IAAW,UAAU;GACnB,MAAM,OAAO,UAAU,SAAS,KAAK,CAAC;GACtC,IAAI,MAAM,OAAO;EACnB;CACF,QAAQ,CAER;AAEF"}
@@ -0,0 +1,153 @@
1
+ import { c as compareMcpToolNames } from "./defaults-i3kpRFpB.js";
2
+ import { s as McpAccessError } from "./errors-C704k8Mv.js";
3
+ import { ProtocolError, ProtocolErrorCode, Server } from "@modelcontextprotocol/server";
4
+ //#region \0rolldown/runtime.js
5
+ var __defProp = Object.defineProperty;
6
+ var __exportAll = (all, no_symbols) => {
7
+ let target = {};
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ return target;
14
+ };
15
+ //#endregion
16
+ //#region src/protocol.ts
17
+ var protocol_exports = /* @__PURE__ */ __exportAll({
18
+ MCP_TASKS_EXTENSION: () => MCP_TASKS_EXTENSION,
19
+ createMcpProtocolServer: () => createMcpProtocolServer,
20
+ createMcpProtocolServerForRequest: () => createMcpProtocolServerForRequest
21
+ });
22
+ var MCP_TASKS_EXTENSION = "io.modelcontextprotocol/tasks";
23
+ var DEFAULT_TOOL_LIST_CACHE_HINT = {
24
+ ttlMs: 864e5,
25
+ cacheScope: "private"
26
+ };
27
+ async function createMcpProtocolServerForRequest(appServer, options = {}) {
28
+ const principal = options.principal ?? null;
29
+ let extensions = {};
30
+ if (options.extensions) try {
31
+ const tools = await appServer.listTools({ principal });
32
+ const projected = await options.extensions({
33
+ principal,
34
+ tools
35
+ });
36
+ assertExtensionMetadata(projected);
37
+ if (Object.hasOwn(projected, "io.modelcontextprotocol/tasks")) throw new TypeError("Reserved extension.");
38
+ extensions = structuredClone(projected);
39
+ } catch {
40
+ throw new ProtocolError(ProtocolErrorCode.InternalError, "Extension discovery unavailable.");
41
+ }
42
+ return protocolServer(appServer, { principal }, extensions);
43
+ }
44
+ async function resolvePrincipal(option, context) {
45
+ if (typeof option === "function") return await option(context) ?? null;
46
+ return option ?? null;
47
+ }
48
+ function createMcpProtocolServer(appServer, options = {}) {
49
+ if ("extensions" in options) throw new TypeError("Extension discovery requires createMcpProtocolServerForRequest.");
50
+ return protocolServer(appServer, options, {});
51
+ }
52
+ function protocolServer(appServer, options, extensions) {
53
+ const tasksEnabled = appServer.tasksEnabled && typeof options.principal !== "function" && Boolean(options.principal?.id);
54
+ const server = new Server(appServer.serverInfo, {
55
+ capabilities: {
56
+ tools: {},
57
+ ...appServer.listResources && appServer.readResource ? { resources: {} } : {},
58
+ ...tasksEnabled || Object.keys(extensions).length ? { extensions: {
59
+ ...extensions,
60
+ ...tasksEnabled ? { [MCP_TASKS_EXTENSION]: {} } : {}
61
+ } } : {}
62
+ },
63
+ cacheHints: { "tools/list": DEFAULT_TOOL_LIST_CACHE_HINT }
64
+ });
65
+ server.setRequestHandler("tools/list", async (_request, context) => {
66
+ const principal = await resolvePrincipal(options.principal, context);
67
+ const cacheHint = await appServer.getToolsListCacheHint?.() ?? DEFAULT_TOOL_LIST_CACHE_HINT;
68
+ return {
69
+ tools: [...await appServer.listTools({ principal })].sort((left, right) => compareMcpToolNames(left.name, right.name)),
70
+ ...cacheHint
71
+ };
72
+ });
73
+ if (appServer.listResources && appServer.readResource) {
74
+ server.setRequestHandler("resources/list", async (_request, context) => ({
75
+ resources: await appServer.listResources({ principal: await resolvePrincipal(options.principal, context) }),
76
+ ttlMs: 0,
77
+ cacheScope: "private"
78
+ }));
79
+ server.setRequestHandler("resources/read", async (request, context) => {
80
+ try {
81
+ return {
82
+ contents: [await appServer.readResource({
83
+ uri: request.params.uri,
84
+ principal: await resolvePrincipal(options.principal, context)
85
+ })],
86
+ ttlMs: 0,
87
+ cacheScope: "private"
88
+ };
89
+ } catch (error) {
90
+ if (error instanceof McpAccessError) throw new ProtocolError(ProtocolErrorCode.InvalidParams, "MCP resource is not available.");
91
+ throw error;
92
+ }
93
+ });
94
+ }
95
+ server.setRequestHandler("tools/call", async (request, context) => {
96
+ try {
97
+ return await appServer.callTool({
98
+ name: request.params.name,
99
+ arguments: request.params.arguments,
100
+ principal: await resolvePrincipal(options.principal, context)
101
+ });
102
+ } catch (error) {
103
+ if (error instanceof McpAccessError) {
104
+ const { code, retryable } = error.metadata;
105
+ throw new ProtocolError(error.status === 404 ? ProtocolErrorCode.InvalidParams : ProtocolErrorCode.InvalidRequest, error.message, {
106
+ ...typeof code === "string" ? { code } : {},
107
+ ...typeof retryable === "boolean" ? { retryable } : {}
108
+ });
109
+ }
110
+ throw error;
111
+ }
112
+ });
113
+ return server;
114
+ }
115
+ function assertExtensionMetadata(value) {
116
+ let budget = 65536;
117
+ const visit = (v, depth) => {
118
+ if (--budget < 0 || depth > 16) throw new TypeError("Extension metadata exceeds limits.");
119
+ if (v === null || typeof v === "boolean") return;
120
+ if (typeof v === "number" && Number.isFinite(v)) return;
121
+ if (typeof v === "string") {
122
+ budget -= new TextEncoder().encode(v).length;
123
+ if (budget < 0) throw new TypeError("Extension metadata exceeds limits.");
124
+ return;
125
+ }
126
+ if (Array.isArray(v)) {
127
+ if (v.length > 1024) throw new TypeError("Extension array exceeds limits.");
128
+ for (const item of v) visit(item, depth + 1);
129
+ return;
130
+ }
131
+ if (!v || typeof v !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(v))) throw new TypeError("Expected plain extension object.");
132
+ const names = Object.keys(v);
133
+ if (names.length > 256) throw new TypeError("Extension object exceeds limits.");
134
+ for (const name of names) {
135
+ if ([
136
+ "__proto__",
137
+ "constructor",
138
+ "prototype"
139
+ ].includes(name)) throw new TypeError("Unsafe extension key.");
140
+ const descriptor = Object.getOwnPropertyDescriptor(v, name);
141
+ if (!descriptor || !("value" in descriptor)) throw new TypeError("Expected inert extension metadata.");
142
+ visit(name, depth + 1);
143
+ visit(descriptor.value, depth + 1);
144
+ }
145
+ };
146
+ visit(value, 0);
147
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Expected extension map.");
148
+ for (const [name, entry] of Object.entries(value)) if (!name.trim() || !entry || typeof entry !== "object" || Array.isArray(entry)) throw new TypeError("Expected named extension object.");
149
+ }
150
+ //#endregion
151
+ export { createMcpProtocolServerForRequest as n, protocol_exports as r, createMcpProtocolServer as t };
152
+
153
+ //# sourceMappingURL=protocol-D_O2WaCO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-D_O2WaCO.js","names":[],"sources":["../../src/protocol.ts"],"sourcesContent":["/** MCP SDK v2 protocol adapter for the framework-neutral app server core. */\n\nimport type { MCPTool } from '@happyvertical/smrt-core/generators/mcp';\nimport {\n type CallToolResult,\n type JSONObject,\n ProtocolError,\n ProtocolErrorCode,\n Server,\n type ServerContext,\n type Tool,\n} from '@modelcontextprotocol/server';\nimport { McpAccessError } from './errors.js';\nimport type { McpAppPrincipal, McpAppServer } from './server.js';\nimport { compareMcpToolNames } from './tools.js';\n\nexport const MCP_TASKS_EXTENSION = 'io.modelcontextprotocol/tasks';\n\nconst DEFAULT_TOOL_LIST_CACHE_HINT = {\n ttlMs: 86_400_000,\n cacheScope: 'private' as const,\n};\n\nexport interface McpProtocolServerOptions {\n /** Resolve the authenticated application principal for each MCP request. */\n principal?:\n | McpAppPrincipal\n | null\n | ((\n context: ServerContext,\n ) => McpAppPrincipal | null | Promise<McpAppPrincipal | null>);\n}\n\n/** Request-bound options for asynchronous catalog extension projection. */\nexport interface McpProtocolRequestOptions {\n principal?: McpAppPrincipal | null;\n /** Optional inert extension metadata, recomputed from this request's authorized catalog. */\n extensions?: (context: {\n principal: McpAppPrincipal | null;\n tools: readonly MCPTool[];\n }) =>\n | Record<string, Record<string, unknown>>\n | Promise<Record<string, Record<string, unknown>>>;\n}\n\n/** Prepare native capabilities before the SDK HTTP factory installs discovery handlers. */\nexport async function createMcpProtocolServerForRequest(\n appServer: McpAppServer,\n options: McpProtocolRequestOptions = {},\n): Promise<Server> {\n const principal = options.principal ?? null;\n let extensions: Record<string, JSONObject> = {};\n if (options.extensions) {\n try {\n const tools = await appServer.listTools({ principal });\n const projected = await options.extensions({ principal, tools });\n assertExtensionMetadata(projected);\n if (Object.hasOwn(projected, MCP_TASKS_EXTENSION))\n throw new TypeError('Reserved extension.');\n extensions = structuredClone(projected);\n } catch {\n throw new ProtocolError(\n ProtocolErrorCode.InternalError,\n 'Extension discovery unavailable.',\n );\n }\n }\n return protocolServer(appServer, { principal }, extensions);\n}\n\nasync function resolvePrincipal(\n option: McpProtocolServerOptions['principal'],\n context: ServerContext,\n): Promise<McpAppPrincipal | null> {\n if (typeof option === 'function') return (await option(context)) ?? null;\n return option ?? null;\n}\n\n/**\n * Adapt an app MCP core to the SDK v2 low-level server protocol.\n *\n * Transport ownership remains with the caller. In particular, this does not\n * add a production HTTP endpoint; it is safe to compose with `serveStdio` or\n * `createMcpHandler` in a deployment that supplies its own authentication.\n */\nexport function createMcpProtocolServer(\n appServer: McpAppServer,\n options: McpProtocolServerOptions = {},\n): Server {\n if ('extensions' in options) {\n throw new TypeError(\n 'Extension discovery requires createMcpProtocolServerForRequest.',\n );\n }\n return protocolServer(appServer, options, {});\n}\n\nfunction protocolServer(\n appServer: McpAppServer,\n options: McpProtocolServerOptions,\n extensions: Record<string, JSONObject>,\n): Server {\n // Task lifecycle records are owner-scoped. Unlike ordinary public read-only\n // tools, they cannot be safely exposed without a stable principal id.\n const tasksEnabled =\n appServer.tasksEnabled &&\n typeof options.principal !== 'function' &&\n Boolean(options.principal?.id);\n const server = new Server(appServer.serverInfo, {\n capabilities: {\n tools: {},\n ...(appServer.listResources && appServer.readResource\n ? { resources: {} }\n : {}),\n ...(tasksEnabled || Object.keys(extensions).length\n ? {\n extensions: {\n ...extensions,\n ...(tasksEnabled ? { [MCP_TASKS_EXTENSION]: {} } : {}),\n },\n }\n : {}),\n } as never,\n cacheHints: { 'tools/list': DEFAULT_TOOL_LIST_CACHE_HINT },\n });\n\n server.setRequestHandler('tools/list', async (_request, context) => {\n const principal = await resolvePrincipal(options.principal, context);\n const cacheHint =\n (await appServer.getToolsListCacheHint?.()) ??\n DEFAULT_TOOL_LIST_CACHE_HINT;\n return {\n tools: [...(await appServer.listTools({ principal }))].sort(\n (left, right) => compareMcpToolNames(left.name, right.name),\n ) as Tool[],\n ...cacheHint,\n };\n });\n\n if (appServer.listResources && appServer.readResource) {\n server.setRequestHandler('resources/list', async (_request, context) => ({\n resources: await appServer.listResources!({\n principal: await resolvePrincipal(options.principal, context),\n }),\n ttlMs: 0,\n cacheScope: 'private',\n }));\n server.setRequestHandler('resources/read', async (request, context) => {\n try {\n return {\n contents: [\n await appServer.readResource!({\n uri: request.params.uri,\n principal: await resolvePrincipal(options.principal, context),\n }),\n ],\n ttlMs: 0,\n cacheScope: 'private',\n };\n } catch (error) {\n if (error instanceof McpAccessError)\n throw new ProtocolError(\n ProtocolErrorCode.InvalidParams,\n 'MCP resource is not available.',\n );\n throw error;\n }\n });\n }\n\n server.setRequestHandler('tools/call', async (request, context) => {\n try {\n return (await appServer.callTool({\n name: request.params.name,\n arguments: request.params.arguments,\n principal: await resolvePrincipal(options.principal, context),\n })) as CallToolResult;\n } catch (error) {\n if (error instanceof McpAccessError) {\n const { code, retryable } = error.metadata;\n throw new ProtocolError(\n error.status === 404\n ? ProtocolErrorCode.InvalidParams\n : ProtocolErrorCode.InvalidRequest,\n error.message,\n {\n ...(typeof code === 'string' ? { code } : {}),\n ...(typeof retryable === 'boolean' ? { retryable } : {}),\n },\n );\n }\n throw error;\n }\n });\n\n return server;\n}\n\n/** Bound plugin discovery metadata without allowing executable values or provider-specific types. */\nfunction assertExtensionMetadata(\n value: unknown,\n): asserts value is Record<string, JSONObject> {\n let budget = 65536;\n const visit = (v: unknown, depth: number): void => {\n if (--budget < 0 || depth > 16)\n throw new TypeError('Extension metadata exceeds limits.');\n if (v === null || typeof v === 'boolean') return;\n if (typeof v === 'number' && Number.isFinite(v)) return;\n if (typeof v === 'string') {\n budget -= new TextEncoder().encode(v).length;\n if (budget < 0) throw new TypeError('Extension metadata exceeds limits.');\n return;\n }\n if (Array.isArray(v)) {\n if (v.length > 1024)\n throw new TypeError('Extension array exceeds limits.');\n for (const item of v) visit(item, depth + 1);\n return;\n }\n if (\n !v ||\n typeof v !== 'object' ||\n ![Object.prototype, null].includes(Object.getPrototypeOf(v))\n )\n throw new TypeError('Expected plain extension object.');\n const names = Object.keys(v);\n if (names.length > 256)\n throw new TypeError('Extension object exceeds limits.');\n for (const name of names) {\n if (['__proto__', 'constructor', 'prototype'].includes(name))\n throw new TypeError('Unsafe extension key.');\n const descriptor = Object.getOwnPropertyDescriptor(v, name);\n if (!descriptor || !('value' in descriptor))\n throw new TypeError('Expected inert extension metadata.');\n visit(name, depth + 1);\n visit(descriptor.value, depth + 1);\n }\n };\n visit(value, 0);\n if (!value || typeof value !== 'object' || Array.isArray(value))\n throw new TypeError('Expected extension map.');\n for (const [name, entry] of Object.entries(value)) {\n if (\n !name.trim() ||\n !entry ||\n typeof entry !== 'object' ||\n Array.isArray(entry)\n )\n throw new TypeError('Expected named extension object.');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBO,IAAM,sBAAsB;AAEnC,IAAM,+BAA+B;CACnC,OAAO;CACP,YAAY;AACd;AAyBA,eAAsB,kCACpB,WACA,UAAqC,CAAC,GACrB;CACjB,MAAM,YAAY,QAAQ,aAAa;CACvC,IAAI,aAAyC,CAAC;CAC9C,IAAI,QAAQ,YACV,IAAI;EACF,MAAM,QAAQ,MAAM,UAAU,UAAU,EAAE,UAAU,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IACE,CAAC,KAAK,KAAK,KACX,CAAC,SACD,OAAO,UAAU,YACjB,MAAM,QAAQ,KAAK,GAEnB,MAAM,IAAI,UAAU,kCAAkC;AAE5D"}
package/dist/errors.d.ts CHANGED
@@ -23,6 +23,8 @@ export declare class McpAccessError extends Error {
23
23
  }
24
24
  /** Stable code for a request naming a tool this server does not publish. */
25
25
  export declare const MCP_TOOL_NOT_FOUND_CODE = "mcp_tool_not_found";
26
+ /** Stable code for a gated tool called without `arguments.confirm === true`. */
27
+ export declare const MCP_CONFIRM_REQUIRED_CODE = "confirm_required";
26
28
  /** Stable code for a tool call that needs an authenticated principal. */
27
29
  export declare const MCP_AUTHENTICATION_REQUIRED_CODE = "mcp_authentication_required";
28
30
  /** Stable code for an unmapped handler failure; carries no internals. */
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,eAAO,MAAM,2BAA2B,2BAA2B,CAAC;AAEpE,kFAAkF;AAClF,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,KAAK;IAErC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAEvB,QAAQ,CAAC,QAAQ,EAAE,sBAAsB;gBAFhC,MAAM,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM,EACN,QAAQ,GAAE,sBAA2B;CAKjD;AAED,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAE5D,yEAAyE;AACzE,eAAO,MAAM,gCAAgC,gCAAgC,CAAC;AAE9E,yEAAyE;AACzE,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAE1E,+DAA+D;AAC/D,eAAO,MAAM,iCAAiC,+BAA+B,CAAC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AAS,CAiB9B"}
@@ -1,4 +1,4 @@
1
- import { l as safeMcpToolError, s as McpToolError } from "./chunks/errors-XG_zn1pP.js";
1
+ import { c as McpToolError, u as safeMcpToolError } from "./chunks/errors-C704k8Mv.js";
2
2
  //#region src/host-operations.ts
3
3
  function defineHostOperationTool(definition) {
4
4
  if (typeof definition.handler !== "function") throw new TypeError("Host operation handler must be a function.");
package/dist/index.d.ts CHANGED
@@ -21,9 +21,10 @@
21
21
  *
22
22
  * @packageDocumentation
23
23
  */
24
+ export { createInMemoryMcpAuditSink, type McpAuditOutcome, type McpAuditQuery, type McpAuditRecord, type McpAuditSink, mcpArgumentKeyNames, mcpAuditRecordFromEvent, } from './audit.js';
24
25
  export { continueMcpWorkflow, createMcpContinuationTool, type McpWorkflowContinuation, } from './continuation.js';
25
26
  export { type CreateDefaultMcpAppServerOptions, createDefaultMcpAppServer, DEFAULT_MCP_APP_SERVER_INFO, type McpAppModel, type McpPrincipalScopePolicyOptions, mcpAllowedClassNames, mcpPrincipalScopePolicy, } from './defaults.js';
26
- export { MCP_AUTHENTICATION_REQUIRED_CODE, MCP_ORIGIN_DENIED_CODE, MCP_TOOL_ACCESS_DENIED_CODE, MCP_TOOL_EXECUTION_FAILED_CODE, MCP_TOOL_NOT_FOUND_CODE, McpAccessError, type McpAccessErrorMetadata, McpToolError, type McpToolErrorInfo, type McpToolErrorMapper, safeMcpToolError, } from './errors.js';
27
+ export { MCP_AUTHENTICATION_REQUIRED_CODE, MCP_CONFIRM_REQUIRED_CODE, MCP_ORIGIN_DENIED_CODE, MCP_TOOL_ACCESS_DENIED_CODE, MCP_TOOL_EXECUTION_FAILED_CODE, MCP_TOOL_NOT_FOUND_CODE, McpAccessError, type McpAccessErrorMetadata, McpToolError, type McpToolErrorInfo, type McpToolErrorMapper, safeMcpToolError, } from './errors.js';
27
28
  export { createSameOriginSessionCaller, defineHostOperationTool, executeHostOperation, type HostOperationCaller, type HostOperationContext, type HostOperationDescriptor, HostOperationError, type HostOperationToolDefinition, type HostOperationWebMcpSpec, type SameOriginSessionCallerOptions, toMcpWorkflowTool, toWebMcpSpec, } from './host-operations.js';
28
29
  export { createMcpProtocolServer, createMcpProtocolServerForRequest, type McpProtocolRequestOptions, type McpProtocolServerOptions, } from './protocol.js';
29
30
  export { MCP_APP_RESOURCE_MAX_BYTES, MCP_APP_RESOURCE_MIME, type McpAppResource, type McpAppResourceContent, type McpAppResourceCsp, type McpAppResourceDefinition, type McpResourcePolicy, prepareMcpAppResource, } from './resources.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,uBAAuB,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,gCAAgC,EACrC,yBAAyB,EACzB,2BAA2B,EAC3B,KAAK,WAAW,EAChB,KAAK,8BAA8B,EACnC,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gCAAgC,EAChC,sBAAsB,EACtB,2BAA2B,EAC3B,8BAA8B,EAC9B,uBAAuB,EACvB,cAAc,EACd,KAAK,sBAAsB,EAC3B,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,kBAAkB,EAClB,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,iBAAiB,EACjB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,EACvB,iCAAiC,EACjC,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,GAC9B,MAAM,eAAe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zB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,aAAa,EAClB,kBAAkB,EAClB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,GAC/B,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- import { a as MCP_TOOL_NOT_FOUND_CODE, i as MCP_TOOL_EXECUTION_FAILED_CODE, l as safeMcpToolError, n as MCP_ORIGIN_DENIED_CODE, o as McpAccessError, r as MCP_TOOL_ACCESS_DENIED_CODE, s as McpToolError, t as MCP_AUTHENTICATION_REQUIRED_CODE } from "./chunks/errors-XG_zn1pP.js";
2
- import { _ as MCP_APP_RESOURCE_MAX_BYTES, a as createDefaultMcpAppServer, b as createMcpWorkflowTool, c as createMcpAppServer, d as isAllowedCoreTool, f as isPublicMcpTool, g as mcpToolEffect, h as matchesToolPattern, i as DEFAULT_MCP_APP_SERVER_INFO, l as MCP_TOOL_EFFECTS, m as isReadOnlyToolName, n as createMcpProtocolServer, o as mcpAllowedClassNames, p as isPublicToolName, r as createMcpProtocolServerForRequest, s as mcpPrincipalScopePolicy, u as classNamePrefixes, v as MCP_APP_RESOURCE_MIME, y as prepareMcpAppResource } from "./chunks/protocol-BRQji5k_.js";
1
+ import { n as createMcpProtocolServerForRequest, t as createMcpProtocolServer } from "./chunks/protocol-D_O2WaCO.js";
2
+ import { _ as prepareMcpAppResource, a as createMcpAppServer, b as mcpArgumentKeyNames, d as isPublicToolName, f as isReadOnlyToolName, g as MCP_APP_RESOURCE_MIME, h as MCP_APP_RESOURCE_MAX_BYTES, i as mcpPrincipalScopePolicy, l as isAllowedCoreTool, m as mcpToolEffect, n as createDefaultMcpAppServer, o as MCP_TOOL_EFFECTS, p as matchesToolPattern, r as mcpAllowedClassNames, s as classNamePrefixes, t as DEFAULT_MCP_APP_SERVER_INFO, u as isPublicMcpTool, v as createMcpWorkflowTool, x as mcpAuditRecordFromEvent, y as createInMemoryMcpAuditSink } from "./chunks/defaults-i3kpRFpB.js";
3
+ import { a as MCP_TOOL_EXECUTION_FAILED_CODE, c as McpToolError, i as MCP_TOOL_ACCESS_DENIED_CODE, n as MCP_CONFIRM_REQUIRED_CODE, o as MCP_TOOL_NOT_FOUND_CODE, r as MCP_ORIGIN_DENIED_CODE, s as McpAccessError, t as MCP_AUTHENTICATION_REQUIRED_CODE, u as safeMcpToolError } from "./chunks/errors-C704k8Mv.js";
3
4
  import { HostOperationError, createSameOriginSessionCaller, defineHostOperationTool, executeHostOperation, toMcpWorkflowTool, toWebMcpSpec } from "./host-operations.js";
4
5
  import { getActiveJobExecutionContext, isRunnerExecutionContext } from "@happyvertical/smrt-jobs";
5
6
  //#region src/continuation.ts
@@ -71,6 +72,6 @@ function createMcpContinuationTool(options) {
71
72
  return definition;
72
73
  }
73
74
  //#endregion
74
- export { DEFAULT_MCP_APP_SERVER_INFO, HostOperationError, MCP_APP_RESOURCE_MAX_BYTES, MCP_APP_RESOURCE_MIME, MCP_AUTHENTICATION_REQUIRED_CODE, MCP_ORIGIN_DENIED_CODE, MCP_TOOL_ACCESS_DENIED_CODE, MCP_TOOL_EFFECTS, MCP_TOOL_EXECUTION_FAILED_CODE, MCP_TOOL_NOT_FOUND_CODE, McpAccessError, McpToolError, classNamePrefixes, continueMcpWorkflow, createDefaultMcpAppServer, createMcpAppServer, createMcpContinuationTool, createMcpProtocolServer, createMcpProtocolServerForRequest, createMcpWorkflowTool, createSameOriginSessionCaller, defineHostOperationTool, executeHostOperation, isAllowedCoreTool, isPublicMcpTool, isPublicToolName, isReadOnlyToolName, matchesToolPattern, mcpAllowedClassNames, mcpPrincipalScopePolicy, mcpToolEffect, prepareMcpAppResource, safeMcpToolError, toMcpWorkflowTool, toWebMcpSpec };
75
+ export { DEFAULT_MCP_APP_SERVER_INFO, HostOperationError, MCP_APP_RESOURCE_MAX_BYTES, MCP_APP_RESOURCE_MIME, MCP_AUTHENTICATION_REQUIRED_CODE, MCP_CONFIRM_REQUIRED_CODE, MCP_ORIGIN_DENIED_CODE, MCP_TOOL_ACCESS_DENIED_CODE, MCP_TOOL_EFFECTS, MCP_TOOL_EXECUTION_FAILED_CODE, MCP_TOOL_NOT_FOUND_CODE, McpAccessError, McpToolError, classNamePrefixes, continueMcpWorkflow, createDefaultMcpAppServer, createInMemoryMcpAuditSink, createMcpAppServer, createMcpContinuationTool, createMcpProtocolServer, createMcpProtocolServerForRequest, createMcpWorkflowTool, createSameOriginSessionCaller, defineHostOperationTool, executeHostOperation, isAllowedCoreTool, isPublicMcpTool, isPublicToolName, isReadOnlyToolName, matchesToolPattern, mcpAllowedClassNames, mcpArgumentKeyNames, mcpAuditRecordFromEvent, mcpPrincipalScopePolicy, mcpToolEffect, prepareMcpAppResource, safeMcpToolError, toMcpWorkflowTool, toWebMcpSpec };
75
76
 
76
77
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/continuation.ts"],"sourcesContent":["import {\n getActiveJobExecutionContext,\n isRunnerExecutionContext,\n type McpTaskContinuation,\n type McpTaskStore,\n} from '@happyvertical/smrt-jobs';\nimport { McpAccessError } from './errors.js';\nimport type { McpAppPrincipal } from './server.js';\nimport {\n createMcpWorkflowTool,\n type McpWorkflowToolDefinition,\n} from './workflow-tools.js';\n\n/** Server-owned immutable review reference; contains no permission snapshot. */\nexport interface McpWorkflowContinuation extends McpTaskContinuation {\n /** Application review page, including the application's own authentication. */\n reviewUrl: string;\n}\n\n/**\n * Compose a durable job with its owning workflow. The host answer is only an\n * input hint. `applyReviewed` must call the owning immutable review/revision and\n * idempotency API, rechecking domain approval inside that transaction.\n * No host callback or server session survives suspension.\n */\nexport async function continueMcpWorkflow<T>(options: {\n binding: McpWorkflowContinuation;\n inputSchema: Record<string, unknown>;\n applyReviewed: (\n input: unknown,\n binding: Readonly<McpTaskContinuation>,\n ) => Promise<T>;\n}): Promise<T> {\n const context = getActiveJobExecutionContext();\n if (!context || !isRunnerExecutionContext(context) || !context.task) {\n throw new Error('Durable workflow requires an active MCP task');\n }\n const url = new URL(options.binding.reviewUrl);\n const loopback =\n url.protocol === 'http:' &&\n ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);\n if (\n (url.protocol !== 'https:' && !loopback) ||\n url.username ||\n url.password\n ) {\n throw new Error('Workflow review URL must use HTTPS without credentials');\n }\n await context.task.assertAuthorized();\n const binding = Object.freeze({\n recordId: options.binding.recordId,\n revision: options.binding.revision,\n inputKey: options.binding.inputKey,\n });\n const input = await context.task.requestContinuation(binding, {\n schema: options.inputSchema,\n reviewUrl: url.href,\n });\n await context.task.assertAuthorized();\n return options.applyReviewed(input, binding);\n}\n\n/**\n * Declare the ordinary tool fallback for hosts without elicitation. `storeFor`\n * must return a store bound to the supplied verified actor and active tenant;\n * the application policy callback resolves current read authority.\n */\nexport function createMcpContinuationTool(options: {\n name: string;\n storeFor: (\n principal: McpAppPrincipal,\n ) => Promise<Pick<McpTaskStore, 'getContinuation'>>;\n authorize: (principal: McpAppPrincipal, taskId: string) => Promise<boolean>;\n}): McpWorkflowToolDefinition {\n const definition: McpWorkflowToolDefinition = {\n name: options.name,\n description:\n 'Read the current input form or human review URL for your waiting workflow task.',\n effect: 'read',\n idempotent: true,\n openWorld: false,\n inputSchema: {\n type: 'object',\n properties: { taskId: { type: 'string', minLength: 1, maxLength: 256 } },\n required: ['taskId'],\n additionalProperties: false,\n },\n outputSchema: {\n type: 'object',\n properties: {\n continuation: { anyOf: [{ type: 'object' }, { type: 'null' }] },\n },\n required: ['continuation'],\n additionalProperties: false,\n },\n async execute(context) {\n const taskId = context.arguments.taskId;\n const principal = context.principal;\n try {\n if (\n !principal ||\n typeof taskId !== 'string' ||\n !taskId ||\n taskId.length > 256 ||\n !(await options.authorize(principal, taskId))\n )\n throw new Error('Denied');\n const store = await options.storeFor(principal);\n const data = { continuation: await store.getContinuation(taskId) };\n return {\n content: [{ type: 'text', text: JSON.stringify(data) }],\n structuredContent: data,\n };\n } catch {\n throw new McpAccessError(403, 'Tool access denied');\n }\n },\n };\n createMcpWorkflowTool(definition);\n return definition;\n}\n"],"mappings":";;;;;AAyBA,eAAsB,oBAAuB,SAO9B;CACb,MAAM,UAAU,6BAA6B;CAC7C,IAAI,CAAC,WAAW,CAAC,yBAAyB,OAAO,KAAK,CAAC,QAAQ,MAC7D,MAAM,IAAI,MAAM,8CAA8C;CAEhE,MAAM,MAAM,IAAI,IAAI,QAAQ,QAAQ,SAAS;CAC7C,MAAM,WACJ,IAAI,aAAa,WACjB;EAAC;EAAa;EAAa;CAAO,CAAA,CAAE,SAAS,IAAI,QAAQ;CAC3D,IACG,IAAI,aAAa,YAAY,CAAC,YAC/B,IAAI,YACJ,IAAI,UAEJ,MAAM,IAAI,MAAM,wDAAwD;CAE1E,MAAM,QAAQ,KAAK,iBAAiB;CACpC,MAAM,UAAU,OAAO,OAAO;EAC5B,UAAU,QAAQ,QAAQ;EAC1B,UAAU,QAAQ,QAAQ;EAC1B,UAAU,QAAQ,QAAQ;CAC5B,CAAC;CACD,MAAM,QAAQ,MAAM,QAAQ,KAAK,oBAAoB,SAAS;EAC5D,QAAQ,QAAQ;EAChB,WAAW,IAAI;CACjB,CAAC;CACD,MAAM,QAAQ,KAAK,iBAAiB;CACpC,OAAO,QAAQ,cAAc,OAAO,OAAO;AAC7C;AAOO,SAAS,0BAA0B,SAMZ;CAC5B,MAAM,aAAwC;EAC5C,MAAM,QAAQ;EACd,aACE;EACF,QAAQ;EACR,YAAY;EACZ,WAAW;EACX,aAAa;GACX,MAAM;GACN,YAAY,EAAE,QAAQ;IAAE,MAAM;IAAU,WAAW;IAAG,WAAW;GAAI,EAAE;GACvE,UAAU,CAAC,QAAQ;GACnB,sBAAsB;EACxB;EACA,cAAc;GACZ,MAAM;GACN,YAAY,EACV,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM,SAAS,GAAG,EAAE,MAAM,OAAO,CAAC,EAAE,EAChE;GACA,UAAU,CAAC,cAAc;GACzB,sBAAsB;EACxB;EACA,MAAM,QAAQ,SAAS;GACrB,MAAM,SAAS,QAAQ,UAAU;GACjC,MAAM,YAAY,QAAQ;GAC1B,IAAI;IACF,IACE,CAAC,aACD,OAAO,WAAW,YAClB,CAAC,UACD,OAAO,SAAS,OAChB,CAAE,MAAM,QAAQ,UAAU,WAAW,MAAM,GAE3C,MAAM,IAAI,MAAM,QAAQ;IAE1B,MAAM,OAAO,EAAE,cAAc,OAAM,MADf,QAAQ,SAAS,SAAS,EAAA,CACL,gBAAgB,MAAM,EAAE;IACjE,OAAO;KACL,SAAS,CAAC;MAAE,MAAM;MAAQ,MAAM,KAAK,UAAU,IAAI;KAAE,CAAC;KACtD,mBAAmB;IACrB;GACF,QAAQ;IACN,MAAM,IAAI,eAAe,KAAK,oBAAoB;GACpD;EACF;CACF;CACA,sBAAsB,UAAU;CAChC,OAAO;AACT"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/continuation.ts"],"sourcesContent":["import {\n getActiveJobExecutionContext,\n isRunnerExecutionContext,\n type McpTaskContinuation,\n type McpTaskStore,\n} from '@happyvertical/smrt-jobs';\nimport { McpAccessError } from './errors.js';\nimport type { McpAppPrincipal } from './server.js';\nimport {\n createMcpWorkflowTool,\n type McpWorkflowToolDefinition,\n} from './workflow-tools.js';\n\n/** Server-owned immutable review reference; contains no permission snapshot. */\nexport interface McpWorkflowContinuation extends McpTaskContinuation {\n /** Application review page, including the application's own authentication. */\n reviewUrl: string;\n}\n\n/**\n * Compose a durable job with its owning workflow. The host answer is only an\n * input hint. `applyReviewed` must call the owning immutable review/revision and\n * idempotency API, rechecking domain approval inside that transaction.\n * No host callback or server session survives suspension.\n */\nexport async function continueMcpWorkflow<T>(options: {\n binding: McpWorkflowContinuation;\n inputSchema: Record<string, unknown>;\n applyReviewed: (\n input: unknown,\n binding: Readonly<McpTaskContinuation>,\n ) => Promise<T>;\n}): Promise<T> {\n const context = getActiveJobExecutionContext();\n if (!context || !isRunnerExecutionContext(context) || !context.task) {\n throw new Error('Durable workflow requires an active MCP task');\n }\n const url = new URL(options.binding.reviewUrl);\n const loopback =\n url.protocol === 'http:' &&\n ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);\n if (\n (url.protocol !== 'https:' && !loopback) ||\n url.username ||\n url.password\n ) {\n throw new Error('Workflow review URL must use HTTPS without credentials');\n }\n await context.task.assertAuthorized();\n const binding = Object.freeze({\n recordId: options.binding.recordId,\n revision: options.binding.revision,\n inputKey: options.binding.inputKey,\n });\n const input = await context.task.requestContinuation(binding, {\n schema: options.inputSchema,\n reviewUrl: url.href,\n });\n await context.task.assertAuthorized();\n return options.applyReviewed(input, binding);\n}\n\n/**\n * Declare the ordinary tool fallback for hosts without elicitation. `storeFor`\n * must return a store bound to the supplied verified actor and active tenant;\n * the application policy callback resolves current read authority.\n */\nexport function createMcpContinuationTool(options: {\n name: string;\n storeFor: (\n principal: McpAppPrincipal,\n ) => Promise<Pick<McpTaskStore, 'getContinuation'>>;\n authorize: (principal: McpAppPrincipal, taskId: string) => Promise<boolean>;\n}): McpWorkflowToolDefinition {\n const definition: McpWorkflowToolDefinition = {\n name: options.name,\n description:\n 'Read the current input form or human review URL for your waiting workflow task.',\n effect: 'read',\n idempotent: true,\n openWorld: false,\n inputSchema: {\n type: 'object',\n properties: { taskId: { type: 'string', minLength: 1, maxLength: 256 } },\n required: ['taskId'],\n additionalProperties: false,\n },\n outputSchema: {\n type: 'object',\n properties: {\n continuation: { anyOf: [{ type: 'object' }, { type: 'null' }] },\n },\n required: ['continuation'],\n additionalProperties: false,\n },\n async execute(context) {\n const taskId = context.arguments.taskId;\n const principal = context.principal;\n try {\n if (\n !principal ||\n typeof taskId !== 'string' ||\n !taskId ||\n taskId.length > 256 ||\n !(await options.authorize(principal, taskId))\n )\n throw new Error('Denied');\n const store = await options.storeFor(principal);\n const data = { continuation: await store.getContinuation(taskId) };\n return {\n content: [{ type: 'text', text: JSON.stringify(data) }],\n structuredContent: data,\n };\n } catch {\n throw new McpAccessError(403, 'Tool access denied');\n }\n },\n };\n createMcpWorkflowTool(definition);\n return definition;\n}\n"],"mappings":";;;;;;AAyBA,eAAsB,oBAAuB,SAO9B;CACb,MAAM,UAAU,6BAA6B;CAC7C,IAAI,CAAC,WAAW,CAAC,yBAAyB,OAAO,KAAK,CAAC,QAAQ,MAC7D,MAAM,IAAI,MAAM,8CAA8C;CAEhE,MAAM,MAAM,IAAI,IAAI,QAAQ,QAAQ,SAAS;CAC7C,MAAM,WACJ,IAAI,aAAa,WACjB;EAAC;EAAa;EAAa;CAAO,CAAA,CAAE,SAAS,IAAI,QAAQ;CAC3D,IACG,IAAI,aAAa,YAAY,CAAC,YAC/B,IAAI,YACJ,IAAI,UAEJ,MAAM,IAAI,MAAM,wDAAwD;CAE1E,MAAM,QAAQ,KAAK,iBAAiB;CACpC,MAAM,UAAU,OAAO,OAAO;EAC5B,UAAU,QAAQ,QAAQ;EAC1B,UAAU,QAAQ,QAAQ;EAC1B,UAAU,QAAQ,QAAQ;CAC5B,CAAC;CACD,MAAM,QAAQ,MAAM,QAAQ,KAAK,oBAAoB,SAAS;EAC5D,QAAQ,QAAQ;EAChB,WAAW,IAAI;CACjB,CAAC;CACD,MAAM,QAAQ,KAAK,iBAAiB;CACpC,OAAO,QAAQ,cAAc,OAAO,OAAO;AAC7C;AAOO,SAAS,0BAA0B,SAMZ;CAC5B,MAAM,aAAwC;EAC5C,MAAM,QAAQ;EACd,aACE;EACF,QAAQ;EACR,YAAY;EACZ,WAAW;EACX,aAAa;GACX,MAAM;GACN,YAAY,EAAE,QAAQ;IAAE,MAAM;IAAU,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