@walkeros/mcp 4.0.1-next-1778230564486 → 4.0.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/dist/index.js +2 -2
- package/dist/stdio.js +5 -5
- package/dist/stdio.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -960,7 +960,7 @@ async function feedbackHandlerBody(client, input) {
|
|
|
960
960
|
const isAnonymous = explicitAnonymous ?? anonymous ?? true;
|
|
961
961
|
await client.submitFeedback(text, {
|
|
962
962
|
anonymous: isAnonymous,
|
|
963
|
-
version: "4.0.1
|
|
963
|
+
version: "4.0.1"
|
|
964
964
|
});
|
|
965
965
|
return mcpResult5({ ok: true });
|
|
966
966
|
} catch (error) {
|
|
@@ -1741,7 +1741,7 @@ var NPM_SEARCH_URL = "https://registry.npmjs.org/-/v1/search";
|
|
|
1741
1741
|
var JSDELIVR_BASE = "https://cdn.jsdelivr.net/npm";
|
|
1742
1742
|
var WALKEROS_JSON_PATH = "dist/walkerOS.json";
|
|
1743
1743
|
var CACHE_TTL = 5 * 60 * 1e3;
|
|
1744
|
-
var CLIENT_HEADER = "walkeros-mcp/4.0.1
|
|
1744
|
+
var CLIENT_HEADER = "walkeros-mcp/4.0.1";
|
|
1745
1745
|
var cache;
|
|
1746
1746
|
function normalizePlatform(platform) {
|
|
1747
1747
|
if (platform == null) return [];
|
package/dist/stdio.js
CHANGED
|
@@ -679,7 +679,7 @@ var NPM_SEARCH_URL = "https://registry.npmjs.org/-/v1/search";
|
|
|
679
679
|
var JSDELIVR_BASE = "https://cdn.jsdelivr.net/npm";
|
|
680
680
|
var WALKEROS_JSON_PATH = "dist/walkerOS.json";
|
|
681
681
|
var CACHE_TTL = 5 * 60 * 1e3;
|
|
682
|
-
var CLIENT_HEADER = "walkeros-mcp/4.0.1
|
|
682
|
+
var CLIENT_HEADER = "walkeros-mcp/4.0.1";
|
|
683
683
|
var cache;
|
|
684
684
|
function normalizePlatform(platform) {
|
|
685
685
|
if (platform == null) return [];
|
|
@@ -1121,7 +1121,7 @@ async function feedbackHandlerBody(client, input) {
|
|
|
1121
1121
|
const isAnonymous = explicitAnonymous ?? anonymous ?? true;
|
|
1122
1122
|
await client.submitFeedback(text, {
|
|
1123
1123
|
anonymous: isAnonymous,
|
|
1124
|
-
version: "4.0.1
|
|
1124
|
+
version: "4.0.1"
|
|
1125
1125
|
});
|
|
1126
1126
|
return mcpResult8({ ok: true });
|
|
1127
1127
|
} catch (error) {
|
|
@@ -2755,7 +2755,7 @@ var HttpToolClient = class {
|
|
|
2755
2755
|
};
|
|
2756
2756
|
|
|
2757
2757
|
// src/stdio.ts
|
|
2758
|
-
setClientContext({ type: "mcp", version: "4.0.1
|
|
2758
|
+
setClientContext({ type: "mcp", version: "4.0.1" });
|
|
2759
2759
|
process.on("uncaughtException", (err) => {
|
|
2760
2760
|
const emitter = getMcpEmitterSingleton();
|
|
2761
2761
|
if (emitter) {
|
|
@@ -2775,7 +2775,7 @@ process.on("unhandledRejection", (reason) => {
|
|
|
2775
2775
|
async function main() {
|
|
2776
2776
|
const server = createWalkerOSMcpServer({
|
|
2777
2777
|
client: new HttpToolClient(),
|
|
2778
|
-
version: "4.0.1
|
|
2778
|
+
version: "4.0.1"
|
|
2779
2779
|
});
|
|
2780
2780
|
const transport = new StdioServerTransport();
|
|
2781
2781
|
await server.connect(transport);
|
|
@@ -2785,7 +2785,7 @@ main().catch(async (error) => {
|
|
|
2785
2785
|
try {
|
|
2786
2786
|
const emitter = await createMcpEmitter({
|
|
2787
2787
|
clientInfo: void 0,
|
|
2788
|
-
packageVersion: "4.0.1
|
|
2788
|
+
packageVersion: "4.0.1"
|
|
2789
2789
|
});
|
|
2790
2790
|
await emitter.emitError("startup");
|
|
2791
2791
|
} catch {
|
package/dist/stdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/stdio.ts","../src/server.ts","../src/tools/validate.ts","../src/schemas/output.ts","../src/user-data.ts","../src/tools/bundle.ts","../src/tools/simulate.ts","../src/tools/push.ts","../src/tools/examples.ts","../src/tools/package.ts","../src/catalog.ts","../src/tools/flow-load.ts","../src/tools/feedback.ts","../src/tools/auth.ts","../src/tools/project-manage.ts","../src/types.ts","../src/tools/flow-manage.ts","../src/ui-parts.ts","../src/tools/deploy-manage.ts","../src/tools/_resolvers.ts","../src/resources/package-schemas.ts","../src/resources/references.ts","../src/prompts/add-step.ts","../src/prompts/setup-mapping.ts","../src/prompts/manage-contract.ts","../src/instructions.ts","../src/telemetry.ts","../src/http-tool-client.ts"],"sourcesContent":["import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { setClientContext } from '@walkeros/cli';\n\nimport { createWalkerOSMcpServer, getMcpEmitterSingleton } from './server.js';\nimport { HttpToolClient } from './http-tool-client.js';\nimport { createMcpEmitter } from './telemetry.js';\n\ndeclare const __VERSION__: string;\n\nsetClientContext({ type: 'mcp', version: __VERSION__ });\n\n// Hook process-level error channels so we can emit `error throw` before the\n// process tears down. Both handlers look up the emitter lazily: if the MCP\n// handshake never completed, no emitter exists and we silently skip.\n// We don't call process.exit — stdio transport already propagates failures\n// up to the parent client via the JSON-RPC channel.\nprocess.on('uncaughtException', (err) => {\n const emitter = getMcpEmitterSingleton();\n if (emitter) {\n emitter.emitError('uncaught').catch(() => {});\n }\n console.error('Uncaught exception in Flow MCP server:', err);\n});\n\nprocess.on('unhandledRejection', (reason) => {\n const emitter = getMcpEmitterSingleton();\n if (emitter) {\n emitter.emitError('unhandledRejection').catch(() => {});\n }\n console.error('Unhandled rejection in Flow MCP server:', reason);\n});\n\nasync function main() {\n const server = createWalkerOSMcpServer({\n client: new HttpToolClient(),\n version: __VERSION__,\n });\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error('walkerOS Flow MCP server running on stdio');\n}\n\nmain().catch(async (error) => {\n // Startup failure — no client handshake happened, so there's no emitter in\n // the module singleton. Build a one-shot emitter with an unknown client so\n // the error is still visible to telemetry.\n try {\n const emitter = await createMcpEmitter({\n clientInfo: undefined,\n packageVersion: __VERSION__,\n });\n await emitter.emitError('startup');\n } catch {\n // swallow — telemetry must never mask the original startup error\n }\n console.error('Failed to start Flow MCP server:', error);\n process.exit(1);\n});\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport type { ToolClient } from './tool-client.js';\nimport { registerFlowValidateTool } from './tools/validate.js';\nimport { registerFlowBundleTool } from './tools/bundle.js';\nimport { registerFlowSimulateTool } from './tools/simulate.js';\nimport { registerFlowPushTool } from './tools/push.js';\nimport { registerFlowExamplesTool } from './tools/examples.js';\nimport {\n registerPackageSearchTool,\n registerGetPackageSchemaTool,\n} from './tools/package.js';\nimport { registerFlowLoadTool } from './tools/flow-load.js';\nimport { registerFeedbackTool } from './tools/feedback.js';\nimport { registerAuthTool } from './tools/auth.js';\nimport { registerProjectManageTool } from './tools/project-manage.js';\nimport { registerFlowManageTool } from './tools/flow-manage.js';\nimport { registerDeployTool } from './tools/deploy-manage.js';\nimport { registerPackageSchemaResources } from './resources/package-schemas.js';\nimport { registerReferenceResources } from './resources/references.js';\nimport { registerAddStepPrompt } from './prompts/add-step.js';\nimport { registerSetupMappingPrompt } from './prompts/setup-mapping.js';\nimport { registerManageContractPrompt } from './prompts/manage-contract.js';\nimport { SERVER_INSTRUCTIONS } from './instructions.js';\nimport { createMcpEmitter, type McpEmitter } from './telemetry.js';\n\nexport interface Logger {\n debug?(message: string, meta?: Record<string, unknown>): void;\n info?(message: string, meta?: Record<string, unknown>): void;\n warn?(message: string, meta?: Record<string, unknown>): void;\n error?(message: string, meta?: Record<string, unknown>): void;\n}\n\nexport interface CreateServerOptions {\n client: ToolClient;\n logger?: Logger;\n version?: string;\n catalogBaseUrl?: string;\n}\n\n/**\n * Module-scoped singleton emitter, populated once the MCP `initialize`\n * handshake completes and clientInfo is known. The stdio entrypoint reads\n * this to emit process-level `error throw` events from uncaughtException /\n * unhandledRejection hooks, where the Server instance isn't in scope.\n */\nlet currentEmitter: McpEmitter | undefined;\n\nexport function getMcpEmitterSingleton(): McpEmitter | undefined {\n return currentEmitter;\n}\n\n/**\n * Internal: reset for tests that want a clean slate between cases.\n * Not exported from the package.\n */\nexport function __resetMcpEmitterSingletonForTesting(): void {\n currentEmitter = undefined;\n}\n\n/**\n * Minimal shape of a `_registeredTools` entry we rely on for handler\n * wrapping. Typed locally to avoid leaking SDK internals while keeping\n * strict typing on the handler signature.\n */\ntype WrappableRegisteredTool = {\n handler: (...args: unknown[]) => unknown;\n};\n\ntype RegisteredToolsRecord = Record<string, WrappableRegisteredTool>;\n\n/**\n * Wrap every already-registered tool handler with telemetry. The wrapper\n * emits `cmd invoke` with outcome + timing, swallowing any telemetry error\n * so it never surfaces to the tool caller. We look up the emitter lazily at\n * call time so wrapping can happen before the emitter is created.\n */\nfunction wrapRegisteredToolsWithTelemetry(server: McpServer): void {\n const internal = server as unknown as {\n _registeredTools: RegisteredToolsRecord;\n };\n const tools = internal._registeredTools;\n if (!tools) return;\n for (const [toolName, tool] of Object.entries(tools)) {\n const original = tool.handler;\n tool.handler = async (...args: unknown[]): Promise<unknown> => {\n const start = Date.now();\n try {\n const result = await original(...args);\n const emitter = currentEmitter;\n if (emitter) {\n emitter\n .emitInvoke(toolName, 'success', Date.now() - start)\n .catch(() => {});\n }\n return result;\n } catch (err) {\n const emitter = currentEmitter;\n if (emitter) {\n emitter\n .emitInvoke(toolName, 'error', Date.now() - start)\n .catch(() => {});\n }\n throw err;\n }\n };\n }\n}\n\nexport function createWalkerOSMcpServer(opts: CreateServerOptions): McpServer {\n const packageVersion = opts.version ?? '0.0.0';\n const server = new McpServer(\n {\n name: 'walkeros-flow',\n version: packageVersion,\n },\n { instructions: SERVER_INSTRUCTIONS },\n );\n\n registerAuthTool(server, opts.client);\n registerProjectManageTool(server, opts.client);\n registerFlowManageTool(server, opts.client);\n registerDeployTool(server, opts.client);\n registerFeedbackTool(server, opts.client);\n\n registerFlowValidateTool(server);\n registerFlowBundleTool(server);\n registerFlowSimulateTool(server);\n registerFlowPushTool(server);\n registerFlowExamplesTool(server);\n registerFlowLoadTool(server);\n\n registerPackageSearchTool(server);\n registerGetPackageSchemaTool(server);\n\n registerPackageSchemaResources(server);\n registerReferenceResources(server);\n registerAddStepPrompt(server);\n registerSetupMappingPrompt(server);\n registerManageContractPrompt(server);\n\n wrapRegisteredToolsWithTelemetry(server);\n\n // MCP SDK fires `oninitialized` after the `initialized` notification, which\n // follows a successful `initialize` request. At that point `getClientVersion`\n // returns the negotiated client identity. We create the emitter here and\n // emit `mcp start`, so consent, debug, and endpoint resolution happen lazily\n // at the moment a real client connects.\n const priorOnInitialized = server.server.oninitialized;\n server.server.oninitialized = () => {\n try {\n priorOnInitialized?.();\n } catch {\n // existing handler must not prevent telemetry setup\n }\n const clientInfo = server.server.getClientVersion();\n void createMcpEmitter({\n clientInfo,\n packageVersion,\n })\n .then(async (emitter) => {\n currentEmitter = emitter;\n await emitter.emitStart();\n })\n .catch(() => {\n // telemetry must never break the server; swallow setup/emit errors.\n });\n };\n\n return server;\n}\n","import { validate } from '@walkeros/cli';\nimport type { ValidateResult } from '@walkeros/cli';\nimport { schemas } from '@walkeros/cli/dev';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { ValidateOutputShape } from '../schemas/output.js';\nimport { wrapUserData } from '../user-data.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\nfunction wrapIssueMessages(result: ValidateResult): ValidateResult {\n return {\n ...result,\n errors: result.errors.map((e) => ({\n ...e,\n message: wrapUserData(e.message),\n })),\n warnings: result.warnings.map((w) => ({\n ...w,\n message: wrapUserData(w.message),\n })),\n };\n}\n\nconst TITLE = 'Validate Flow';\nconst DESCRIPTION =\n 'Validate walkerOS events, flow configurations, mapping rules, or data contracts. ' +\n 'Accepts JSON strings, file paths, or URLs as input. ' +\n 'Returns validation results with errors, warnings, and details.';\n\nconst inputSchema = schemas.ValidateInputShape;\n\nconst annotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nexport function createFlowValidateToolSpec(): ToolSpec {\n return {\n name: 'flow_validate',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowValidateHandlerBody(input),\n };\n}\n\nasync function flowValidateHandlerBody(input: unknown) {\n const {\n type,\n input: validateInput,\n flow,\n path,\n } = (input ?? {}) as {\n type: 'contract' | 'event' | 'flow' | 'mapping';\n input: string;\n flow?: string;\n path?: string;\n };\n try {\n const result: ValidateResult = await validate(type, validateInput, {\n flow,\n path,\n });\n const hints = result.valid\n ? {\n next: [\n 'Use flow_simulate to test event flow',\n 'Use flow_bundle to build',\n ],\n }\n : {\n next: [\n 'Fix errors above, then run flow_validate again',\n 'Read walkeros://reference/flow-schema for correct structure',\n ],\n };\n return mcpResult(wrapIssueMessages(result), hints);\n } catch (error) {\n return mcpError(\n error,\n 'Check the input parameter — expected a JSON string, file path, or URL',\n );\n }\n}\n\nexport function registerFlowValidateTool(server: McpServer) {\n const spec = createFlowValidateToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema: ValidateOutputShape,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\n\n// CLI tool output shapes\nexport const ValidateOutputShape = {\n valid: z.boolean().describe('Whether validation passed'),\n type: z\n .union([\n z.enum(['contract', 'entry', 'event', 'flow', 'mapping']),\n z.string().regex(/^(destinations|sources|transformers)\\.\\w+$/),\n ])\n .describe('What was validated'),\n errors: z\n .array(\n z.object({\n path: z.string(),\n message: z.string(),\n value: z.unknown().optional(),\n code: z.string().optional(),\n }),\n )\n .describe('Validation errors'),\n warnings: z\n .array(\n z.object({\n path: z.string(),\n message: z.string(),\n suggestion: z.string().optional(),\n }),\n )\n .describe('Validation warnings'),\n details: z\n .record(z.string(), z.unknown())\n .describe('Additional validation details'),\n};\n\nexport const BundleOutputShape = {\n success: z.boolean().describe('Whether bundling succeeded'),\n totalSize: z.number().optional().describe('Total bundle size in bytes'),\n buildTime: z.number().optional().describe('Build time in milliseconds'),\n packages: z\n .array(\n z.object({\n name: z.string(),\n size: z.number(),\n }),\n )\n .optional()\n .describe('Per-package size breakdown'),\n treeshakingEffective: z\n .boolean()\n .optional()\n .describe('Whether tree-shaking was effective'),\n message: z.string().optional().describe('Status message'),\n};\n\nexport const SimulateOutputShape = {\n success: z.boolean().describe('Whether simulation succeeded'),\n error: z.string().optional().describe('Error message if failed'),\n summary: z.string().describe('One-line result summary'),\n destinations: z\n .record(\n z.string(),\n z.object({\n received: z\n .boolean()\n .describe('Whether destination received the event'),\n calls: z.number().describe('Number of API calls made'),\n payload: z\n .unknown()\n .optional()\n .describe('All intercepted API calls (only when verbose: true)'),\n }),\n )\n .optional()\n .describe('Per-destination results'),\n capturedEvents: z\n .array(z.record(z.string(), z.unknown()))\n .optional()\n .describe('Events captured by source simulation'),\n duration: z.number().optional().describe('Simulation duration in ms'),\n};\n\nexport const PushOutputShape = {\n success: z.boolean().describe('Whether push succeeded'),\n elbResult: z.unknown().optional().describe('Push result from the collector'),\n duration: z.number().describe('Push duration in milliseconds'),\n error: z.string().optional().describe('Error message if push failed'),\n};\n\n// Examples List output shape\nexport const ExamplesListOutputShape = {\n flow: z.string().describe('Flow name'),\n count: z.number().describe('Number of examples found'),\n examples: z\n .array(\n z.object({\n step: z.string().describe('Step location (e.g., \"destination.gtag\")'),\n stepType: z\n .enum(['source', 'transformer', 'destination'])\n .describe('Step type'),\n stepName: z.string().describe('Step name'),\n exampleName: z.string().describe('Example name'),\n title: z.string().optional().describe('Human-readable title if set'),\n description: z\n .string()\n .optional()\n .describe('Short human-readable description'),\n public: z\n .boolean()\n .optional()\n .describe(\n 'Whether the example is public (defaults to true if omitted)',\n ),\n hasIn: z.boolean().describe('Whether the example has an input value'),\n hasOut: z.boolean().describe('Whether the example has an output value'),\n hasMapping: z\n .boolean()\n .describe('Whether the example has a mapping configuration'),\n hasTrigger: z\n .boolean()\n .describe('Whether the example has trigger metadata'),\n in: z.unknown().optional().describe('Input event data'),\n out: z.unknown().optional().describe('Expected output data'),\n mapping: z\n .unknown()\n .optional()\n .describe('Mapping configuration for destinations'),\n trigger: z\n .object({\n type: z.string().optional(),\n options: z.unknown().optional(),\n })\n .optional()\n .describe('Trigger metadata for source simulation'),\n }),\n )\n .describe('Step examples'),\n};\n","/**\n * Wraps a user-writable string in `<user_data>…</user_data>` so the chat\n * assistant treats it as data, never as instructions. Inner `</user_data>`\n * sequences are mangled (`</user_data_>`) so a malicious string can't close\n * the envelope early.\n *\n * Idempotent: a string that is already a well-formed envelope with no inner\n * `</user_data>` is returned unchanged.\n */\nexport function wrapUserData(s: string): string {\n const alreadyWrapped =\n s.startsWith('<user_data>') &&\n s.endsWith('</user_data>') &&\n s.slice(11, -12).indexOf('</user_data>') === -1;\n if (alreadyWrapped) return s;\n const neutralised = s.replace(/<\\/user_data>/g, '</user_data_>');\n return `<user_data>${neutralised}</user_data>`;\n}\n\nexport interface RedactOptions {\n /** Return `true` to skip wrapping for a given object key. Only invoked for\n * string values on object entries — not for array elements or scalar\n * roots. Use to keep ids / slugs / dates literal. */\n skip?: (key: string) => boolean;\n}\n\n/**\n * Recursively walks `value` and returns a deep-copied structure where every\n * string leaf has been passed through `wrapUserData`. Pass `skip` to exclude\n * specific keys (e.g. `id`) from wrapping.\n */\nexport function redactNestedStrings<T>(value: T, opts?: RedactOptions): T {\n return walk(value, opts) as T;\n}\n\nfunction walk(value: unknown, opts?: RedactOptions): unknown {\n if (typeof value === 'string') return wrapUserData(value);\n if (Array.isArray(value)) return value.map((v) => walk(v, opts));\n if (value && typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n if (opts?.skip?.(k) && typeof v === 'string') {\n out[k] = v;\n } else {\n out[k] = walk(v, opts);\n }\n }\n return out;\n }\n return value;\n}\n","import { bundle } from '@walkeros/cli';\nimport { schemas } from '@walkeros/cli/dev';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { BundleOutputShape } from '../schemas/output.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\nconst TITLE = 'Bundle Flow';\nconst DESCRIPTION =\n 'Bundle a walkerOS flow configuration into deployable JavaScript. ' +\n 'Resolves all destinations, sources, and transformers, then outputs ' +\n 'a tree-shaken production bundle. Returns bundle statistics.';\n\nconst inputSchema = {\n ...schemas.BundleInputShape,\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createFlowBundleToolSpec(): ToolSpec {\n return {\n name: 'flow_bundle',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowBundleHandlerBody(input),\n };\n}\n\nasync function flowBundleHandlerBody(input: unknown) {\n const { configPath, flow, stats, output } = (input ?? {}) as {\n configPath: string;\n flow?: string;\n stats?: boolean;\n output?: string;\n };\n try {\n const result = await bundle(configPath, {\n flowName: flow,\n stats: stats ?? true,\n buildOverrides: output ? { output } : undefined,\n });\n\n if (!result) {\n return mcpResult(\n { success: false, message: 'Bundle produced no output' },\n {\n warnings: [\n 'The build returned no result. The flow may be empty or misconfigured.',\n ],\n next: ['Run flow_validate to check your configuration'],\n },\n );\n }\n\n const output_ = result as unknown as Record<string, unknown>;\n\n return mcpResult(\n { success: true, ...output_ },\n {\n next: [\n 'Use flow_simulate to test',\n 'Use deploy_manage with action \"deploy\" to publish',\n ],\n },\n );\n } catch (error) {\n return mcpError(error, 'Run flow_validate for detailed error messages');\n }\n}\n\nexport function registerFlowBundleTool(server: McpServer) {\n const spec = createFlowBundleToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema: BundleOutputShape,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport {\n simulateSource,\n simulateTransformer,\n simulateDestination,\n} from '@walkeros/cli';\nimport type { PushResult } from '@walkeros/cli';\nimport { schemas } from '@walkeros/cli/dev';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { SimulateOutputShape } from '../schemas/output.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\ninterface DestinationSummary {\n received: boolean;\n calls: number;\n payload?: unknown;\n}\n\nconst TITLE = 'Simulate Flow';\nconst DESCRIPTION =\n 'Simulate events through a walkerOS flow without making real API calls. ' +\n 'For destinations: event is a walkerOS event { name: \"entity action\", data: {...} }. ' +\n 'For sources: event is { content: ..., trigger?: { type?, options? }, env?: {...} }. ' +\n 'Use step to target a specific step. ' +\n 'Use flow_examples to discover available test data. ' +\n 'IMPORTANT: Destinations with require (e.g. require: [\"consent\"]) stay pending until ' +\n 'that collector event fires — simulation will error \"not found\" if require is not satisfied. ' +\n 'Remove require from config or provide consent/user events before simulating. ' +\n 'Separately, destinations with consent (e.g. consent: { marketing: true }) only receive ' +\n 'events where the event includes matching consent. ' +\n 'Mapping transforms event names and data at the destination level. ' +\n 'Policy redacts or injects fields before mapping runs.';\n\nconst inputSchema = {\n configPath: schemas.SimulateInputShape.configPath,\n event: z\n .union([z.record(z.string(), z.unknown()), z.string()])\n .optional()\n .describe(\n 'For destinations: { name, data, consent? }. Include consent (e.g. { marketing: true }) ' +\n 'to satisfy destination consent requirements. ' +\n 'For sources: { content, trigger?, env? }. ' +\n 'Can also be a JSON string or file path.',\n ),\n flow: schemas.SimulateInputShape.flow,\n platform: schemas.SimulateInputShape.platform,\n step: schemas.SimulateInputShape.step,\n verbose: z\n .boolean()\n .optional()\n .describe('Include full payload per destination (default: false)'),\n};\n\nconst annotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nexport function createFlowSimulateToolSpec(): ToolSpec {\n return {\n name: 'flow_simulate',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowSimulateHandlerBody(input),\n };\n}\n\nasync function flowSimulateHandlerBody(input: unknown) {\n const { configPath, event, flow, platform, step, verbose } = (input ??\n {}) as {\n configPath: string;\n event?: Record<string, unknown> | string;\n flow?: string;\n platform?: 'web' | 'server';\n step?: string;\n verbose?: boolean;\n };\n try {\n if (!event) {\n throw new Error(\n 'event is required. For sources provide { content, trigger? }, for destinations provide { name, data }.',\n );\n }\n\n if (!step) {\n throw new Error(\n 'step is required. Specify a target like \"source.browser\", \"destination.gtag\", or \"transformer.demo\".',\n );\n }\n\n // Resolve string event input (JSON string)\n let resolvedEvent: unknown = event;\n if (typeof event === 'string') {\n try {\n resolvedEvent = JSON.parse(event);\n } catch {\n throw new Error(\n 'Event string must be valid JSON. Got: ' + event.substring(0, 50),\n );\n }\n }\n\n // Parse step into type and id\n const dotIndex = step.indexOf('.');\n if (dotIndex === -1) {\n throw new Error(\n `Invalid step format \"${step}\". Use \"type.name\" (e.g. \"source.browser\", \"destination.gtag\").`,\n );\n }\n const stepType = step.substring(0, dotIndex);\n const stepId = step.substring(dotIndex + 1);\n\n let result: PushResult;\n\n switch (stepType) {\n case 'source':\n result = await simulateSource(configPath, resolvedEvent, {\n sourceId: stepId,\n flow,\n silent: true,\n });\n break;\n\n case 'transformer':\n result = await simulateTransformer(\n configPath,\n resolvedEvent as import('@walkeros/core').WalkerOS.DeepPartialEvent,\n {\n transformerId: stepId,\n flow,\n silent: true,\n },\n );\n break;\n\n case 'destination':\n result = await simulateDestination(\n configPath,\n resolvedEvent as import('@walkeros/core').WalkerOS.DeepPartialEvent,\n {\n destinationId: stepId,\n flow,\n silent: true,\n },\n );\n break;\n\n default:\n throw new Error(\n `Unknown step type \"${stepType}\". Use \"source\", \"transformer\", or \"destination\".`,\n );\n }\n\n // Source simulation returns captured events\n if (result.captured && result.captured.length > 0) {\n const eventCount = result.captured.length;\n const summary = `Source captured ${eventCount} event${eventCount !== 1 ? 's' : ''}`;\n\n return mcpResult(\n {\n success: result.success,\n error: result.error,\n summary,\n capturedEvents: result.captured,\n duration: result.duration,\n },\n {\n next:\n eventCount > 0\n ? [\n 'Use flow_simulate with a destination step to test downstream processing',\n ]\n : [\n 'Check source package examples with package_get, verify trigger type matches',\n ],\n },\n );\n }\n\n // Destination/transformer simulation\n const destinations: Record<string, DestinationSummary> = {};\n\n // Build destinations summary from elbResult.done\n if (\n result.elbResult &&\n typeof result.elbResult === 'object' &&\n 'done' in result.elbResult &&\n result.elbResult.done\n ) {\n const done = result.elbResult.done as Record<string, unknown>;\n for (const name of Object.keys(done)) {\n destinations[name] = { received: true, calls: 0 };\n }\n }\n\n // Also check usage (call tracking from mock envs)\n if (result.usage) {\n for (const [name, calls] of Object.entries(result.usage)) {\n const summary: DestinationSummary = {\n received: calls.length > 0,\n calls: calls.length,\n };\n if (verbose && calls.length > 0) {\n summary.payload = calls;\n }\n destinations[name] = summary;\n }\n }\n\n const destCount = Object.keys(destinations).length;\n const receivedCount = Object.values(destinations).filter(\n (d) => d.received,\n ).length;\n\n const warnings: string[] = [];\n if (stepType === 'destination' && destCount === 0) {\n warnings.push(\n 'Destination did not receive the event. Common causes: ' +\n '(1) destination config has consent: { marketing: true } but event lacks matching consent, ' +\n '(2) mapping rules do not match the event name, ' +\n '(3) policy redacted required fields. ' +\n 'Add consent to the event: { name: \"...\", data: {...}, consent: { marketing: true } }.',\n );\n }\n\n const summary =\n stepType === 'transformer'\n ? `Transformer processed event`\n : `${receivedCount}/${destCount} destinations received the event`;\n\n const resultObj = {\n success: result.success,\n error: result.error,\n summary,\n destinations: destCount > 0 ? destinations : undefined,\n duration: result.duration,\n };\n\n return mcpResult(resultObj, {\n next: ['Use flow_bundle to build for production'],\n ...(warnings.length > 0 ? { warnings } : {}),\n });\n } catch (error) {\n const msg = error instanceof Error ? error.message : '';\n let hint = 'Run flow_validate for detailed error messages';\n if (msg.includes('not found in collector')) {\n hint =\n 'If this destination has require: [\"consent\"] or require: [\"user\"], it stays ' +\n 'pending until that event fires. For simulation, either remove require from ' +\n 'the config or simulate with a flow that omits require on the target destination.';\n }\n return mcpError(error, hint);\n }\n}\n\nexport function registerFlowSimulateTool(server: McpServer) {\n const spec = createFlowSimulateToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema: SimulateOutputShape,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport { push } from '@walkeros/cli';\nimport type { PushResult } from '@walkeros/cli';\nimport { schemas } from '@walkeros/cli/dev';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { PushOutputShape } from '../schemas/output.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\nconst TITLE = 'Push Events';\nconst DESCRIPTION =\n 'Push a real event through a walkerOS flow to actual destinations. ' +\n 'Makes real API calls to real endpoints. ' +\n 'Best suited for server-side flows — web flows should use flow_simulate for testing.';\n\nconst inputSchema = {\n configPath: schemas.PushInputShape.configPath,\n event: z\n .record(z.string(), z.unknown())\n .describe(\n 'Event object, e.g. { name: \"page view\", data: { title: \"Home\" } }',\n ),\n flow: schemas.PushInputShape.flow,\n platform: schemas.PushInputShape.platform,\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createFlowPushToolSpec(): ToolSpec {\n return {\n name: 'flow_push',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowPushHandlerBody(input),\n };\n}\n\nasync function flowPushHandlerBody(input: unknown) {\n const { configPath, event, flow, platform } = (input ?? {}) as {\n configPath: string;\n event: Record<string, unknown>;\n flow?: string;\n platform?: 'web' | 'server';\n };\n try {\n const result: PushResult = await push(configPath, event, {\n json: true,\n flow,\n platform,\n });\n\n if (!result.success) {\n return mcpError(\n new Error(result.error || 'Push failed'),\n 'Check destination configuration and connectivity.',\n );\n }\n\n return mcpResult(result);\n } catch (error) {\n return mcpError(\n error,\n 'Check configPath and event format. For web flows, use flow_simulate.',\n );\n }\n}\n\nexport function registerFlowPushTool(server: McpServer) {\n const spec = createFlowPushToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema: PushOutputShape,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport { loadJsonConfig } from '@walkeros/cli';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport type { Flow } from '@walkeros/core';\nimport { ExamplesListOutputShape } from '../schemas/output.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\nconst TITLE = 'Flow Examples';\nconst DESCRIPTION =\n 'List all step examples in a walkerOS flow configuration. ' +\n 'Shows example names, step locations, and in/out shapes. ' +\n 'Use this to discover available test fixtures and simulation data.';\n\nconst inputSchema = {\n configPath: z\n .string()\n .min(1)\n .describe('Path to flow configuration file, URL, or inline JSON string'),\n flow: z.string().optional().describe('Flow name for multi-flow configs'),\n step: z\n .string()\n .optional()\n .describe('Filter to a specific step (e.g., \"destination.gtag\")'),\n full: z\n .boolean()\n .optional()\n .describe(\n 'Return full in/out/mapping data for each example (default: false, returns metadata only)',\n ),\n includeHidden: z\n .boolean()\n .optional()\n .describe(\n 'Include examples marked public: false (default: false). Set true for test/debug discovery.',\n ),\n};\n\nconst annotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nexport function createFlowExamplesToolSpec(): ToolSpec {\n return {\n name: 'flow_examples',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowExamplesHandlerBody(input),\n };\n}\n\nasync function flowExamplesHandlerBody(input: unknown) {\n const { configPath, flow, step, full, includeHidden } = (input ?? {}) as {\n configPath: string;\n flow?: string;\n step?: string;\n full?: boolean;\n includeHidden?: boolean;\n };\n try {\n const rawConfig = await loadJsonConfig<Flow.Json>(configPath);\n\n // Resolve flow name\n const flowNames = Object.keys(rawConfig.flows || {});\n const flowName =\n flow || (flowNames.length === 1 ? flowNames[0] : undefined);\n\n if (!flowName) {\n throw new Error(\n `Multiple flows found. Specify flow parameter. Available: ${flowNames.join(', ')}`,\n );\n }\n\n const flowSettings = rawConfig.flows[flowName];\n if (!flowSettings) {\n throw new Error(`Flow \"${flowName}\" not found`);\n }\n\n // Collect all examples\n const examples: Array<{\n step: string;\n stepType: string;\n stepName: string;\n exampleName: string;\n title?: string;\n description?: string;\n public?: boolean;\n hasIn: boolean;\n hasOut: boolean;\n hasMapping: boolean;\n hasTrigger: boolean;\n in?: unknown;\n out?: unknown;\n mapping?: unknown;\n trigger?: unknown;\n }> = [];\n\n const stepTypes = [\n { key: 'sources' as const, type: 'source' },\n { key: 'transformers' as const, type: 'transformer' },\n { key: 'destinations' as const, type: 'destination' },\n ];\n\n for (const { key, type } of stepTypes) {\n const refs = flowSettings[key] || {};\n for (const [name, ref] of Object.entries(refs)) {\n if (!ref.examples) continue;\n\n // Apply step filter\n if (step && `${type}.${name}` !== step) continue;\n\n for (const [exName, ex] of Object.entries(\n ref.examples as Flow.StepExamples,\n )) {\n if (!includeHidden && ex.public === false) continue;\n examples.push({\n step: `${type}.${name}`,\n stepType: type,\n stepName: name,\n exampleName: exName,\n title: ex.title,\n description: ex.description,\n public: ex.public,\n hasIn: ex.in !== undefined,\n hasOut: ex.out !== undefined,\n hasMapping: ex.mapping !== undefined,\n hasTrigger: ex.trigger !== undefined,\n ...(full\n ? {\n in: ex.in,\n out: ex.out,\n mapping: ex.mapping,\n trigger: ex.trigger,\n }\n : {}),\n });\n }\n }\n }\n\n const result = {\n flow: flowName,\n count: examples.length,\n examples,\n };\n\n const hints: { next: string[]; warnings?: string[] } = {\n next: ['Use flow_simulate with step and event to simulate'],\n };\n if (examples.length === 0) {\n hints.warnings = [\n 'No examples found. Add examples to step entries in your flow config for testing.',\n ];\n }\n return mcpResult(result, hints);\n } catch (error) {\n return mcpError(error, 'Check configPath — expected a flow.json file');\n }\n}\n\nexport function registerFlowExamplesTool(server: McpServer) {\n const spec = createFlowExamplesToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema: ExamplesListOutputShape,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { fetchPackage, mcpResult, mcpError } from '@walkeros/core';\nimport { mergeConfigSchema } from '@walkeros/core/dev';\nimport { fetchCatalog, normalizePlatform, CLIENT_HEADER } from '../catalog.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\n/**\n * Resolve the walkerOS app base URL for MCP outbound calls.\n *\n * Env-only by design: the MCP runs in an editor with explicit `.mcp.json`\n * env. No config-file precedence (which is what `@walkeros/cli`'s\n * `resolveAppUrl()` does for the `walkeros` CLI binary). Hard-cut:\n * `APP_URL` is no longer recognized.\n */\nexport function getPackageBaseUrl(): string | undefined {\n return process.env.WALKEROS_APP_URL || undefined;\n}\n\n// ---------- package_search ----------\n\nconst SEARCH_TITLE = 'Search Package';\nconst SEARCH_DESCRIPTION =\n 'Start here for package discovery. Never guess package names: use this tool first to find exact names. ' +\n 'Without package name: returns catalog filtered by type/platform. ' +\n 'With package name: returns metadata, hint keys, and example summaries.';\n\nconst searchInputSchema = {\n package: z\n .string()\n .min(1)\n .optional()\n .describe(\n 'Exact npm package name for detailed lookup (e.g., @walkeros/web-destination-snowplow)',\n ),\n type: z\n .enum(['source', 'destination', 'transformer', 'store'])\n .optional()\n .describe('Filter by package type (browse mode)'),\n platform: z\n .enum(['web', 'server'])\n .optional()\n .describe('Filter by platform (browse mode, includes universal packages)'),\n version: z\n .string()\n .optional()\n .describe('Package version for detailed lookup (default: latest)'),\n};\n\nconst searchAnnotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nexport function createPackageSearchToolSpec(): ToolSpec {\n return {\n name: 'package_search',\n title: SEARCH_TITLE,\n description: SEARCH_DESCRIPTION,\n inputSchema: searchInputSchema,\n annotations: searchAnnotations,\n handler: (input) => packageSearchHandlerBody(input),\n };\n}\n\nasync function packageSearchHandlerBody(input: unknown) {\n const {\n package: packageName,\n type,\n platform,\n version,\n } = (input ?? {}) as {\n package?: string;\n type?: 'source' | 'destination' | 'transformer' | 'store';\n platform?: 'web' | 'server';\n version?: string;\n };\n const baseUrl = getPackageBaseUrl();\n\n // Browse mode: no package specified → return catalog\n if (!packageName) {\n const catalog = await fetchCatalog({ type, platform, baseUrl });\n const result = { catalog, count: catalog.length };\n return mcpResult(result, {\n next: ['Use package_get for schemas and examples'],\n });\n }\n\n // Lookup mode: fetch specific package details\n try {\n const info = await fetchPackage(packageName, {\n version,\n baseUrl,\n client: CLIENT_HEADER,\n });\n\n const result = {\n package: info.packageName,\n version: info.version,\n description: info.description,\n type: info.type,\n platform: normalizePlatform(info.platform),\n hintKeys: info.hintKeys,\n exampleSummaries: info.exampleSummaries,\n };\n\n return mcpResult(result, {\n next: ['Use package_get for schemas and examples'],\n });\n } catch (error) {\n return mcpError(\n error,\n 'Package not found. Use package_search without parameters to browse available packages.',\n );\n }\n}\n\nexport function registerPackageSearchTool(server: McpServer) {\n const spec = createPackageSearchToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // No outputSchema: browse mode returns {catalog, count}, lookup returns metadata — incompatible shapes\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n\n// ---------- package_get ----------\n\nconst GET_TITLE = 'Get Package';\nconst GET_DESCRIPTION =\n 'Requires exact package name: do not guess names, use package_search first to find them. ' +\n 'Returns schemas + hint texts + example summaries by default (lightweight). ' +\n 'Use section parameter for full content: \"hints\" (with code blocks), \"examples\" (full in/out data), or \"all\".';\n\nconst getInputSchema = {\n package: z\n .string()\n .min(1)\n .describe(\n 'Exact npm package name (e.g., @walkeros/web-destination-snowplow)',\n ),\n version: z.string().optional().describe('Package version (default: latest)'),\n section: z\n .enum(['hints', 'examples', 'all'])\n .optional()\n .describe(\n 'Section to expand with full content. Default: summary view with schemas + hint texts + example descriptions',\n ),\n};\n\nconst getAnnotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: true,\n} as const;\n\nexport function createPackageGetToolSpec(): ToolSpec {\n return {\n name: 'package_get',\n title: GET_TITLE,\n description: GET_DESCRIPTION,\n inputSchema: getInputSchema,\n annotations: getAnnotations,\n handler: (input) => packageGetHandlerBody(input),\n };\n}\n\nasync function packageGetHandlerBody(input: unknown) {\n const {\n package: packageName,\n version,\n section,\n } = (input ?? {}) as {\n package: string;\n version?: string;\n section?: 'hints' | 'examples' | 'all';\n };\n const baseUrl = getPackageBaseUrl();\n\n try {\n const info = await fetchPackage(packageName, {\n version,\n baseUrl,\n client: CLIENT_HEADER,\n });\n\n // Build merged schemas: base config + package settings → schemas.config\n const mergedSchemas: Record<string, unknown> = {};\n\n if (info.type) {\n mergedSchemas.config = mergeConfigSchema(\n info.type as 'source' | 'destination' | 'transformer' | 'store',\n info.schemas as Record<string, Record<string, unknown>>,\n );\n }\n\n // Keep non-settings schemas as siblings (mapping, ga4, tagger, etc.)\n for (const [key, value] of Object.entries(info.schemas)) {\n if (key !== 'settings') {\n mergedSchemas[key] = value;\n }\n }\n\n const result: Record<string, unknown> = {\n package: info.packageName,\n version: info.version,\n type: info.type,\n platform: normalizePlatform(info.platform),\n schemas: mergedSchemas,\n };\n\n // Hints\n if (info.hints) {\n if (section === 'hints' || section === 'all') {\n result.hints = info.hints;\n } else {\n const hintSummary: Record<string, { text: string }> = {};\n for (const [key, hint] of Object.entries(info.hints)) {\n const h = hint as { text: string };\n hintSummary[key] = { text: h.text };\n }\n result.hints = hintSummary;\n }\n }\n\n // Examples\n if (section === 'examples' || section === 'all') {\n result.examples = info.examples;\n } else {\n result.exampleSummaries = info.exampleSummaries;\n }\n\n return mcpResult(result);\n } catch (error) {\n return mcpError(\n error,\n 'Use package_search to browse available package names.',\n );\n }\n}\n\nexport function registerGetPackageSchemaTool(server: McpServer) {\n const spec = createPackageGetToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // No outputSchema: removed to avoid SDK -32602 crashes on unexpected field values\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","// __VERSION__ is replaced at build time by tsup's `define` (see tsup.config.ts).\n// In tests, it's set on globalThis (see src/__tests__/support/version.ts).\ndeclare const __VERSION__: string;\n\nconst NPM_SEARCH_URL = 'https://registry.npmjs.org/-/v1/search';\nconst JSDELIVR_BASE = 'https://cdn.jsdelivr.net/npm';\nconst WALKEROS_JSON_PATH = 'dist/walkerOS.json';\nconst CACHE_TTL = 5 * 60 * 1000;\n\nexport const CLIENT_HEADER = 'walkeros-mcp/' + __VERSION__;\n\nexport interface CatalogEntry {\n name: string;\n version: string;\n description?: string;\n type: string;\n platform: string[];\n}\n\nlet cache: { entries: CatalogEntry[]; timestamp: number } | undefined;\n\nexport function clearCatalogCache() {\n cache = undefined;\n}\n\nexport function normalizePlatform(platform?: unknown): string[] {\n if (platform == null) return [];\n if (typeof platform === 'string') {\n return platform === 'universal' ? ['web', 'server'] : [platform];\n }\n if (Array.isArray(platform)) {\n return platform.filter((v): v is string => typeof v === 'string');\n }\n return [];\n}\n\nexport async function fetchCatalog(filters?: {\n type?: string;\n platform?: string;\n baseUrl?: string;\n}): Promise<CatalogEntry[]> {\n if (cache && Date.now() - cache.timestamp < CACHE_TTL) {\n return applyFilters(cache.entries, filters);\n }\n\n let entries: CatalogEntry[];\n try {\n entries = filters?.baseUrl\n ? await fetchCatalogFrom(filters.baseUrl, filters)\n : await fetchFromNpm();\n } catch {\n try {\n entries = await fetchFromNpm();\n } catch {\n return [];\n }\n }\n\n cache = { entries, timestamp: Date.now() };\n\n return applyFilters(entries, filters);\n}\n\nasync function fetchCatalogFrom(\n baseUrl: string,\n filters?: { type?: string; platform?: string },\n): Promise<CatalogEntry[]> {\n const params = new URLSearchParams();\n if (filters?.type) params.set('type', filters.type);\n if (filters?.platform) params.set('platform', filters.platform);\n\n const url = `${baseUrl}/api/packages${params.toString() ? `?${params}` : ''}`;\n const res = await fetch(url, {\n signal: AbortSignal.timeout(15000),\n headers: { 'X-Walkeros-Client': CLIENT_HEADER },\n });\n if (!res.ok) throw new Error(`Catalog fetch failed: ${res.status}`);\n\n const data = (await res.json()) as { catalog: CatalogEntry[] };\n return data.catalog;\n}\n\nasync function fetchFromNpm(): Promise<CatalogEntry[]> {\n const res = await fetch(`${NPM_SEARCH_URL}?text=@walkeros/&size=250`, {\n signal: AbortSignal.timeout(10000),\n headers: { 'X-Walkeros-Client': CLIENT_HEADER },\n });\n if (!res.ok) throw new Error(`npm search failed: ${res.status}`);\n\n const data = (await res.json()) as {\n objects: Array<{\n package: { name: string; version: string; description?: string };\n }>;\n };\n\n const metaResults = await Promise.allSettled(\n data.objects.map((obj) => enrichWithMeta(obj.package)),\n );\n\n return metaResults\n .filter(\n (r): r is PromiseFulfilledResult<CatalogEntry | undefined> =>\n r.status === 'fulfilled',\n )\n .map((r) => r.value)\n .filter((entry): entry is CatalogEntry => entry !== undefined);\n}\n\nasync function enrichWithMeta(pkg: {\n name: string;\n version: string;\n description?: string;\n}): Promise<CatalogEntry | undefined> {\n try {\n const res = await fetch(\n `${JSDELIVR_BASE}/${pkg.name}@${pkg.version}/${WALKEROS_JSON_PATH}`,\n {\n signal: AbortSignal.timeout(5000),\n headers: { 'X-Walkeros-Client': CLIENT_HEADER },\n },\n );\n if (!res.ok) return undefined;\n\n const json = (await res.json()) as { $meta?: Record<string, unknown> };\n const meta = json.$meta;\n if (!meta || typeof meta.type !== 'string') return undefined;\n\n return {\n name: pkg.name,\n version: pkg.version,\n description: pkg.description,\n type: meta.type,\n platform: normalizePlatform(meta.platform),\n };\n } catch {\n return undefined;\n }\n}\n\nfunction applyFilters(\n entries: CatalogEntry[],\n filters?: { type?: string; platform?: string },\n): CatalogEntry[] {\n let results = entries;\n if (filters?.type) {\n results = results.filter((e) => e.type === filters.type);\n }\n if (filters?.platform) {\n // Empty platform means platform-agnostic → matches any filter\n results = results.filter(\n (e) => e.platform.length === 0 || e.platform.includes(filters.platform!),\n );\n }\n return results;\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { loadJsonConfig } from '@walkeros/cli';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { redactNestedStrings } from '../user-data.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\nconst KEEP_LITERAL = new Set([\n 'id',\n 'flowId',\n 'projectId',\n 'version',\n 'slug',\n 'createdAt',\n 'updatedAt',\n 'deletedAt',\n]);\nconst keepLiteral = (key: string) => KEEP_LITERAL.has(key);\n\nconst WEB_SKELETON = {\n version: 4,\n flows: {\n default: {\n config: { platform: 'web', bundle: { packages: {} } },\n sources: {},\n destinations: {},\n },\n },\n};\n\nconst SERVER_SKELETON = {\n version: 4,\n flows: {\n default: {\n config: { platform: 'server', bundle: { packages: {} } },\n sources: {},\n destinations: {},\n },\n },\n};\n\nconst TITLE = 'Load or Create Flow';\nconst DESCRIPTION =\n 'Load an existing flow configuration from a local file path, URL, or walkerOS API (by flow ID). ' +\n 'Or create a new empty flow by specifying a platform (web or server). ' +\n 'Use the add-step prompt to add sources, destinations, transformers, or stores to the flow.';\n\nconst inputSchema = {\n source: z\n .string()\n .optional()\n .describe(\n 'Flow source: local file path (./flow.json), URL (https://...), ' +\n 'inline JSON string, or API flow ID (cfg_...). Omit to create a new flow.',\n ),\n platform: z\n .enum(['web', 'server'])\n .optional()\n .describe(\n 'Platform for new flows. Required when source is omitted. ' +\n 'web = browser tracking, server = Node.js HTTP.',\n ),\n};\n\nconst outputSchema = {\n version: z.number().describe('Flow config version'),\n flows: z.record(z.string(), z.unknown()).describe('Flow entries'),\n};\n\nconst annotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: true,\n} as const;\n\nexport function createFlowLoadToolSpec(): ToolSpec {\n return {\n name: 'flow_load',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowLoadHandlerBody(input),\n };\n}\n\nasync function flowLoadHandlerBody(input: unknown) {\n const { source, platform } = (input ?? {}) as {\n source?: string;\n platform?: 'web' | 'server';\n };\n try {\n if (source) {\n const config = await loadJsonConfig(source);\n return mcpResult(redactNestedStrings(config, { skip: keepLiteral }), {\n next: ['Use flow_validate to check', 'Use add-step prompt to modify'],\n });\n }\n\n if (!platform) {\n return mcpError(\n new Error(\n 'Provide source (file path, URL, or flow ID) to load existing flow, ' +\n 'or platform (web/server) to create a new one.',\n ),\n );\n }\n\n const skeleton = platform === 'web' ? WEB_SKELETON : SERVER_SKELETON;\n return mcpResult(skeleton, {\n next: [\n 'Read walkeros://reference/flow-schema for config structure',\n 'Use add-step prompt to add sources and destinations',\n ],\n });\n } catch (error) {\n const msg = error instanceof Error ? error.message : '';\n if (msg.includes('not found') || msg.includes('ENOENT'))\n return mcpError(error, 'Check configPath — expected a flow.json file');\n return mcpError(error);\n }\n}\n\nexport function registerFlowLoadTool(server: McpServer) {\n const spec = createFlowLoadToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\n\nimport type { ToolClient } from '../tool-client.js';\nimport type { ToolSpec } from '../tool-spec.js';\n\ndeclare const __VERSION__: string;\n\nconst TITLE = 'Send Feedback';\nconst DESCRIPTION = 'Send feedback about walkerOS';\n\nconst inputSchema = {\n text: z.string().describe('Your feedback text'),\n anonymous: z\n .boolean()\n .optional()\n .describe(\n 'Include user/project info? false = include, true = anonymous. Only needed on first call if not yet configured.',\n ),\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createFeedbackToolSpec(client: ToolClient): ToolSpec {\n return {\n name: 'feedback',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => feedbackHandlerBody(client, input),\n };\n}\n\nasync function feedbackHandlerBody(client: ToolClient, input: unknown) {\n const { text, anonymous: explicitAnonymous } = (input ?? {}) as {\n text: string;\n anonymous?: boolean;\n };\n try {\n let anonymous = client.getFeedbackPreference();\n\n if (anonymous === undefined && explicitAnonymous === undefined) {\n return mcpResult(\n { needsConsent: true },\n {\n next: [\n 'Ask the user if they want to include their info',\n 'Call feedback again with anonymous: true or false',\n ],\n },\n );\n }\n\n if (anonymous === undefined && explicitAnonymous !== undefined) {\n anonymous = explicitAnonymous;\n client.setFeedbackPreference(anonymous);\n }\n\n const isAnonymous = explicitAnonymous ?? anonymous ?? true;\n\n await client.submitFeedback(text, {\n anonymous: isAnonymous,\n version: __VERSION__,\n });\n\n return mcpResult({ ok: true });\n } catch (error) {\n return mcpError(error);\n }\n}\n\nexport function registerFeedbackTool(server: McpServer, client: ToolClient) {\n const spec = createFeedbackToolSpec(client);\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\n\nimport type { ToolClient } from '../tool-client.js';\nimport type { ToolSpec } from '../tool-spec.js';\n\nconst TITLE = 'Authentication';\nconst DESCRIPTION =\n 'Manage walkerOS authentication. Check login status, log in via device code flow, or log out. ' +\n 'No terminal or browser required, the MCP client handles the authorization URL.';\n\nconst inputSchema = {\n action: z\n .enum(['status', 'login', 'logout'])\n .describe('Authentication action to perform'),\n deviceCode: z\n .string()\n .optional()\n .describe(\n 'Device code from a previous pending login attempt. Provide to resume polling without requesting a new code.',\n ),\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createAuthToolSpec(client: ToolClient): ToolSpec {\n return {\n name: 'auth',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => authHandlerBody(client, input),\n };\n}\n\nasync function authHandlerBody(client: ToolClient, input: unknown) {\n const { action, deviceCode } = (input ?? {}) as {\n action?: 'status' | 'login' | 'logout';\n deviceCode?: string;\n };\n try {\n switch (action) {\n case 'status': {\n const resolved = client.resolveToken();\n if (!resolved) {\n return mcpResult(\n { authenticated: false },\n { next: ['Use auth with action \"login\" to authenticate'] },\n );\n }\n const user = await client.whoami();\n return mcpResult({\n authenticated: true,\n ...(user as Record<string, unknown>),\n });\n }\n\n case 'login': {\n if (deviceCode) {\n const pollResult = await client.pollForToken(deviceCode, {\n timeoutMs: 60000,\n });\n\n if (pollResult.success) {\n return mcpResult(\n { authenticated: true, email: pollResult.email },\n {\n next: [\n 'Use project_manage with action \"list\" to see your projects',\n ],\n },\n );\n }\n\n if (pollResult.status === 'pending') {\n return mcpResult({\n authenticated: false,\n status: 'pending',\n message: 'Still waiting for authorization. Try again shortly.',\n deviceCode,\n });\n }\n\n return mcpError(\n new Error(pollResult.error || 'Authorization failed'),\n );\n }\n\n const code = await client.requestDeviceCode();\n const loginUrl = code.verificationUriComplete || code.verificationUri;\n\n return mcpResult({\n authenticated: false,\n status: 'awaiting_authorization',\n loginUrl,\n message: `Open this link to authorize: ${loginUrl}`,\n deviceCode: code.deviceCode,\n });\n }\n\n case 'logout': {\n const deleted = client.deleteConfig();\n const hadEnvToken =\n typeof process.env.WALKEROS_TOKEN === 'string' &&\n process.env.WALKEROS_TOKEN.length > 0;\n delete process.env.WALKEROS_TOKEN;\n let message: string;\n if (deleted && hadEnvToken) {\n message =\n 'Logged out. Config removed and WALKEROS_TOKEN cleared from process environment.';\n } else if (deleted) {\n message = 'Logged out and config removed.';\n } else if (hadEnvToken) {\n message =\n 'No config found. WALKEROS_TOKEN cleared from process environment.';\n } else {\n message = 'No config found, already logged out.';\n }\n return mcpResult({\n loggedOut: true,\n message,\n });\n }\n\n default:\n throw new Error(\n `Unknown action: ${action}. Use one of: status, login, logout`,\n );\n }\n } catch (error) {\n return mcpError(error);\n }\n}\n\nexport function registerAuthTool(server: McpServer, client: ToolClient) {\n const spec = createAuthToolSpec(client);\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { isAuthError, AUTH_HINT } from '../types.js';\nimport { wrapUserData } from '../user-data.js';\n\nimport type { ToolClient } from '../tool-client.js';\nimport type { ToolSpec } from '../tool-spec.js';\n\nfunction wrapProjectName<T extends { name?: string }>(p: T): T {\n return p.name !== undefined ? { ...p, name: wrapUserData(p.name) } : p;\n}\n\nconst TITLE = 'Project Management';\nconst DESCRIPTION =\n 'Manage walkerOS projects. List, create, update, delete projects, or set a default project for CLI operations.';\n\nconst inputSchema = {\n action: z\n .enum(['list', 'get', 'create', 'update', 'delete', 'set_default'])\n .describe('Project management action to perform'),\n projectId: z\n .string()\n .optional()\n .describe(\n 'Project ID. Required for get, update, delete, and set_default actions.',\n ),\n name: z\n .string()\n .optional()\n .describe(\n 'Project name. Required for create. Optional for update (to rename).',\n ),\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createProjectManageToolSpec(client: ToolClient): ToolSpec {\n return {\n name: 'project_manage',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => projectManageHandlerBody(client, input),\n };\n}\n\nasync function projectManageHandlerBody(client: ToolClient, input: unknown) {\n const { action, projectId, name } = (input ?? {}) as {\n action?: 'list' | 'get' | 'create' | 'update' | 'delete' | 'set_default';\n projectId?: string;\n name?: string;\n };\n try {\n switch (action) {\n case 'list': {\n const projects = (await client.listProjects()) as\n | unknown[]\n | { projects?: unknown[] };\n const items = Array.isArray(projects)\n ? projects\n : projects?.projects || [];\n if (items.length === 0) {\n return mcpResult(\n { projects: [] },\n {\n next: [\n 'Use project_manage with action \"create\" to create your first project',\n 'Use project_manage with action \"set_default\" after creating to set it as default',\n ],\n },\n );\n }\n const typedItems = items as Array<{ name?: string }>;\n const safe = Array.isArray(projects)\n ? typedItems.map(wrapProjectName)\n : { ...projects, projects: typedItems.map(wrapProjectName) };\n return mcpResult(safe);\n }\n\n case 'get': {\n if (!projectId) {\n return mcpError(\n new Error(\n 'projectId is required for get action. Use action \"list\" to see available projects.',\n ),\n );\n }\n const project = await client.getProject({ projectId });\n return mcpResult(wrapProjectName(project as { name?: string }));\n }\n\n case 'create': {\n if (!name) {\n return mcpError(new Error('name is required for create action.'));\n }\n const created = await client.createProject({ name });\n return mcpResult(wrapProjectName(created as { name?: string }), {\n next: [\n 'Use project_manage with action \"set_default\" to make this your active project',\n ],\n });\n }\n\n case 'update': {\n if (!projectId) {\n return mcpError(\n new Error(\n 'projectId is required for update action. Use action \"list\" to see available projects.',\n ),\n );\n }\n if (!name) {\n return mcpError(new Error('name is required for update action.'));\n }\n const updated = await client.updateProject({ projectId, name });\n return mcpResult(wrapProjectName(updated as { name?: string }));\n }\n\n case 'delete': {\n if (!projectId) {\n return mcpError(\n new Error(\n 'projectId is required for delete action. Use action \"list\" to see available projects.',\n ),\n );\n }\n const deleted = await client.deleteProject({ projectId });\n return mcpResult(deleted);\n }\n\n case 'set_default': {\n if (!projectId) {\n return mcpError(\n new Error(\n 'projectId is required for set_default action. Use action \"list\" to see available projects.',\n ),\n );\n }\n client.setDefaultProject(projectId);\n return mcpResult(\n { defaultProjectId: projectId },\n {\n next: [\n 'Use flow_manage with action \"list\" to see flows in this project',\n ],\n },\n );\n }\n\n default:\n throw new Error(\n `Unknown action: ${action}. Use one of: list, get, create, update, delete, set_default`,\n );\n }\n } catch (error) {\n return mcpError(error, isAuthError(error) ? AUTH_HINT : undefined);\n }\n}\n\nexport function registerProjectManageTool(\n server: McpServer,\n client: ToolClient,\n) {\n const spec = createProjectManageToolSpec(client);\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","// Shared types for MCP management tools.\n// Keep this file dependency-light: only type-level imports from SDK/core.\n\n/**\n * Discriminated input shape for action-based MCP tools.\n * Example: ActionToolInput<'list', { projectId?: string }>\n */\nexport type ActionToolInput<A extends string, T = Record<string, never>> = {\n action: A;\n} & T;\n\n/**\n * Uniform handler return shape used by all mgmt tools.\n * Matches mcpResult / mcpError from @walkeros/core.\n */\nexport type ToolHandlerResult = {\n content: Array<{ type: 'text'; text: string }>;\n structuredContent: Record<string, unknown>;\n isError?: true;\n};\n\n/**\n * True when the error looks like an authentication/authorization failure\n * from the walkerOS cloud API. Used to decide whether to append the\n * \"Are you logged in?\" hint on caught errors.\n */\nexport function isAuthError(error: unknown): boolean {\n if (!(error instanceof Error)) return false;\n const msg = error.message.toLowerCase();\n if (\n msg.includes('unauthorized') ||\n msg.includes('forbidden') ||\n msg.includes('invalid token') ||\n msg.includes('token expired') ||\n msg.includes('not authenticated')\n ) {\n return true;\n }\n const code = (error as Error & { code?: string }).code;\n if (!code) return false;\n const upperCode = code.toUpperCase();\n return (\n upperCode === 'UNAUTHORIZED' ||\n upperCode === 'FORBIDDEN' ||\n upperCode === '401' ||\n upperCode === '403' ||\n upperCode.startsWith('AUTH_')\n );\n}\n\nexport const AUTH_HINT =\n 'Are you logged in? Use auth(action: \"status\") to check.';\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { isAuthError, AUTH_HINT } from '../types.js';\nimport { wrapUserData, redactNestedStrings } from '../user-data.js';\nimport { flowCanvasResult } from '../ui-parts.js';\n\n/** Peek at a Flow.Json root (v4) and decide whether the bubble should render\n * as web-flavoured or server-flavoured. The platform is recorded on\n * `flows[name].config.platform`. We pick the first flow's platform; if no\n * platform is set we fall back to `'server'` so the chat bubble can still\n * render even if the user is mid-edit. */\nfunction pickPlatform(content: unknown): 'web' | 'server' {\n if (content && typeof content === 'object') {\n const flows = (content as { flows?: unknown }).flows;\n if (flows && typeof flows === 'object') {\n for (const flow of Object.values(flows as Record<string, unknown>)) {\n if (flow && typeof flow === 'object') {\n const config = (flow as { config?: unknown }).config;\n if (config && typeof config === 'object') {\n const platform = (config as { platform?: unknown }).platform;\n if (platform === 'web' || platform === 'server') return platform;\n }\n }\n }\n }\n }\n return 'server';\n}\n\nimport type { ToolClient } from '../tool-client.js';\nimport type { ToolSpec } from '../tool-spec.js';\n\n// Keys whose string values must remain literal so the LLM can reference them\n// (ids, dates, immutable identifiers). Everything else that's a string goes\n// through wrapUserData.\nconst KEEP_LITERAL = new Set([\n 'id',\n 'flowId',\n 'projectId',\n 'previewId',\n 'version',\n 'slug',\n 'createdAt',\n 'updatedAt',\n 'deletedAt',\n]);\nconst keepLiteral = (key: string) => KEEP_LITERAL.has(key);\n\nfunction safeSummary<T extends { name?: string }>(flow: T): T {\n return flow.name !== undefined\n ? { ...flow, name: wrapUserData(flow.name) }\n : flow;\n}\n\nfunction safeDetail<T extends { name?: string; config?: unknown }>(flow: T): T {\n const withName =\n flow.name !== undefined\n ? { ...flow, name: wrapUserData(flow.name) }\n : { ...flow };\n if (flow.config !== undefined) {\n (withName as { config?: unknown }).config = redactNestedStrings(\n flow.config,\n { skip: keepLiteral },\n );\n }\n return withName as T;\n}\n\nconst TITLE = 'Flow Management';\nconst DESCRIPTION =\n 'Manage walkerOS flows and their previews. List/get/create/update/delete/duplicate flows, or create/inspect/delete preview bundles for testing flow changes on live sites.';\n\nconst inputSchema = {\n action: z\n .enum([\n 'list',\n 'get',\n 'create',\n 'update',\n 'delete',\n 'duplicate',\n 'preview_list',\n 'preview_get',\n 'preview_create',\n 'preview_delete',\n ])\n .describe('Flow management action to perform'),\n flowId: z\n .string()\n .optional()\n .describe(\n 'Flow ID (flow_...) or config ID (cfg_...). Required for get, update, delete, duplicate.',\n ),\n projectId: z\n .string()\n .optional()\n .describe(\n 'Project ID. Optional filter for list (omit to list all projects). Required for create if no default project set.',\n ),\n name: z\n .string()\n .optional()\n .describe(\n 'Flow name. Required for create. Optional for update (to rename) and duplicate.',\n ),\n content: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Flow.Json content. Used for create and update.'),\n patch: z\n .boolean()\n .optional()\n .describe(\n 'Merge-patch for update (default true). When true, only provided fields are updated.',\n ),\n fields: z\n .array(z.string())\n .optional()\n .describe('Dot-path selectors for get to return only specific fields.'),\n sort: z\n .enum(['name', 'updated_at', 'created_at'])\n .optional()\n .describe('Sort field for list.'),\n order: z.enum(['asc', 'desc']).optional().describe('Sort order for list.'),\n includeDeleted: z\n .boolean()\n .optional()\n .describe('Include soft-deleted flows in list results.'),\n previewId: z\n .string()\n .optional()\n .describe(\n 'Preview ID (prv_...). Required for preview_get and preview_delete.',\n ),\n flowName: z\n .string()\n .optional()\n .describe(\n 'Flow settings name. Used by preview_create as an alternative to flowSettingsId.',\n ),\n flowSettingsId: z\n .string()\n .optional()\n .describe(\n 'Flow settings ID. Used by preview_create as an alternative to flowName.',\n ),\n siteUrl: z\n .string()\n .optional()\n .describe(\n 'Optional site URL for preview_create. When provided, the response includes full activationUrl and deactivationUrl the user can click.',\n ),\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createFlowManageToolSpec(client: ToolClient): ToolSpec {\n return {\n name: 'flow_manage',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowManageHandlerBody(client, input),\n };\n}\n\nasync function flowManageHandlerBody(client: ToolClient, input: unknown) {\n const {\n action,\n flowId,\n projectId,\n name,\n content,\n patch,\n fields,\n sort,\n order,\n includeDeleted,\n previewId,\n flowName,\n flowSettingsId,\n siteUrl,\n } = (input ?? {}) as {\n action?:\n | 'list'\n | 'get'\n | 'create'\n | 'update'\n | 'delete'\n | 'duplicate'\n | 'preview_list'\n | 'preview_get'\n | 'preview_create'\n | 'preview_delete';\n flowId?: string;\n projectId?: string;\n name?: string;\n content?: Record<string, unknown>;\n patch?: boolean;\n fields?: string[];\n sort?: 'name' | 'updated_at' | 'created_at';\n order?: 'asc' | 'desc';\n includeDeleted?: boolean;\n previewId?: string;\n flowName?: string;\n flowSettingsId?: string;\n siteUrl?: string;\n };\n try {\n switch (action) {\n case 'list': {\n if (projectId) {\n const data = await client.listFlows({\n projectId,\n sort,\n order,\n includeDeleted,\n });\n const dataObj = data as { flows?: Array<{ name?: string }> };\n const flows = dataObj.flows;\n const safe = Array.isArray(flows)\n ? { ...dataObj, flows: flows.map(safeSummary) }\n : data;\n return mcpResult(safe);\n }\n const data = await client.listAllFlows({\n sort,\n order,\n includeDeleted,\n });\n const safe = Array.isArray(data)\n ? (data as Array<{ name?: string }>).map(safeSummary)\n : data;\n return mcpResult(\n { projects: safe },\n {\n next: [\n 'Use flow_manage with action \"get\" and a flowId to inspect a specific flow',\n 'Use flow_load to open a flow for editing',\n ],\n },\n );\n }\n\n case 'get': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for get action. Use action \"list\" to see available flows.',\n ),\n );\n }\n const flow = await client.getFlow({ flowId, projectId, fields });\n const safe = safeDetail(\n flow as {\n id?: string;\n name?: string;\n config?: Record<string, unknown>;\n },\n );\n return flowCanvasResult({\n flowId: safe.id,\n configName: safe.name ?? 'default',\n platform: pickPlatform(safe.config),\n flowConfig: (safe.config ?? {}) as Record<string, unknown>,\n suggestions: [\n {\n label: 'Validate this flow',\n prompt: `Validate flow ${safe.id}`,\n autoSend: true,\n },\n {\n label: 'Add a destination',\n prompt: `Help me add a destination to flow ${safe.id}`,\n },\n ],\n });\n }\n\n case 'create': {\n if (!name) {\n return mcpError(new Error('name is required for create action.'));\n }\n const created = await client.createFlow({\n name,\n content: content ?? {},\n projectId,\n });\n const safeCreated = safeDetail(\n created as {\n id?: string;\n name?: string;\n config?: Record<string, unknown>;\n },\n );\n return flowCanvasResult({\n flowId: safeCreated.id,\n configName: safeCreated.name ?? 'default',\n platform: pickPlatform(safeCreated.config),\n flowConfig: (safeCreated.config ?? {}) as Record<string, unknown>,\n suggestions: [\n {\n label: 'Validate this flow',\n prompt: `Validate flow ${safeCreated.id}`,\n autoSend: true,\n },\n {\n label: 'Deploy it',\n prompt: `Deploy flow ${safeCreated.id}`,\n },\n ],\n });\n }\n\n case 'update': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for update action. Use action \"list\" to see available flows.',\n ),\n );\n }\n const updated = await client.updateFlow({\n flowId,\n projectId,\n name,\n content,\n mergePatch: patch ?? true,\n });\n const safeUpdated = safeDetail(\n updated as {\n id?: string;\n name?: string;\n config?: Record<string, unknown>;\n },\n );\n return flowCanvasResult({\n flowId: safeUpdated.id,\n configName: safeUpdated.name ?? 'default',\n platform: pickPlatform(safeUpdated.config),\n flowConfig: (safeUpdated.config ?? {}) as Record<string, unknown>,\n suggestions: [\n {\n label: 'Validate this flow',\n prompt: `Validate flow ${safeUpdated.id}`,\n autoSend: true,\n },\n {\n label: 'Deploy it',\n prompt: `Deploy flow ${safeUpdated.id}`,\n },\n ],\n });\n }\n\n case 'delete': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for delete action. Use action \"list\" to see available flows.',\n ),\n );\n }\n const deleted = await client.deleteFlow({ flowId, projectId });\n return mcpResult(deleted);\n }\n\n case 'duplicate': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for duplicate action. Use action \"list\" to see available flows.',\n ),\n );\n }\n const duplicated = await client.duplicateFlow({\n flowId,\n name,\n projectId,\n });\n return mcpResult(\n safeDetail(duplicated as { name?: string; config?: unknown }),\n );\n }\n\n case 'preview_list': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for preview_list. Use action \"list\" to see available flows.',\n ),\n );\n }\n const data = await client.listPreviews({ projectId, flowId });\n return mcpResult(data);\n }\n\n case 'preview_get': {\n if (!flowId || !previewId) {\n return mcpError(\n new Error('flowId and previewId are required for preview_get.'),\n );\n }\n const data = await client.getPreview({\n projectId,\n flowId,\n previewId,\n });\n return mcpResult(data);\n }\n\n case 'preview_create': {\n if (!flowId) {\n return mcpError(new Error('flowId is required for preview_create.'));\n }\n if (!flowName && !flowSettingsId) {\n return mcpError(\n new Error(\n 'flowName or flowSettingsId is required for preview_create.',\n ),\n );\n }\n const preview = await client.createPreview({\n projectId,\n flowId,\n flowName,\n flowSettingsId,\n });\n const typedPreview = preview as {\n id: string;\n token: string;\n activationUrl: string;\n bundleUrl: string;\n createdBy: string;\n createdAt: string;\n [key: string]: unknown;\n };\n const enriched: Record<string, unknown> = {\n ...typedPreview,\n activationParam: typedPreview.activationUrl,\n };\n if (siteUrl) {\n const on = new URL(siteUrl);\n on.searchParams.set('elbPreview', typedPreview.token);\n enriched.activationUrl = on.toString();\n\n const off = new URL(siteUrl);\n off.searchParams.set('elbPreview', 'off');\n enriched.deactivationUrl = off.toString();\n } else {\n delete enriched.activationUrl;\n }\n return mcpResult(enriched, {\n next: siteUrl\n ? [\n 'Open activationUrl to activate preview mode; open deactivationUrl to exit.',\n ]\n : [\n 'Append activationParam to any URL on your site to activate preview mode.',\n ],\n });\n }\n\n case 'preview_delete': {\n if (!flowId || !previewId) {\n return mcpError(\n new Error('flowId and previewId are required for preview_delete.'),\n );\n }\n const data = await client.deletePreview({\n projectId,\n flowId,\n previewId,\n });\n return mcpResult(data);\n }\n\n default:\n throw new Error(\n `Unknown action: ${action}. Use one of: list, get, create, update, delete, duplicate, preview_list, preview_get, preview_create, preview_delete`,\n );\n }\n } catch (error) {\n return mcpError(error, isAuthError(error) ? AUTH_HINT : undefined);\n }\n}\n\nexport function registerFlowManageTool(server: McpServer, client: ToolClient) {\n const spec = createFlowManageToolSpec(client);\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","export type SuggestionTile = {\n label: string;\n description?: string;\n prompt: string;\n autoSend?: boolean;\n};\n\nexport interface FlowCanvasPayload {\n flowId?: string;\n configName: string;\n platform: 'web' | 'server';\n flowConfig: Record<string, unknown>;\n highlight?: { stepAddress: string; reason: string };\n suggestions?: SuggestionTile[];\n}\n\nexport interface FlowCanvasToolResult extends FlowCanvasPayload {\n kind: 'flow-canvas';\n}\n\n/**\n * Tool-result helper that marks a response as renderable as a FlowCanvas.\n * The chat UI inspects `structuredContent.kind === 'flow-canvas'` and mounts\n * a `FlowCanvasBubble` instead of the generic JSON fallback. The `content[0]`\n * text is the same JSON stringified — the LLM sees a self-describing object.\n */\nexport function flowCanvasResult(payload: FlowCanvasPayload) {\n const structured: FlowCanvasToolResult = { kind: 'flow-canvas', ...payload };\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(structured, null, 2),\n },\n ],\n structuredContent: structured as unknown as Record<string, unknown> & {\n kind: 'flow-canvas';\n },\n };\n}\n\nexport function isFlowCanvasResult(v: unknown): v is FlowCanvasToolResult {\n return (\n typeof v === 'object' &&\n v !== null &&\n (v as { kind?: unknown }).kind === 'flow-canvas'\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { isAuthError, AUTH_HINT } from '../types.js';\n\nimport type { ToolClient } from '../tool-client.js';\nimport type { ToolSpec } from '../tool-spec.js';\nimport {\n resolveDeploymentSlug,\n type DeploymentSummaryForResolver,\n type ListDeploymentsForResolver,\n} from './_resolvers.js';\n\nconst TITLE = 'Deploy Management';\nconst DESCRIPTION =\n 'Deploy walkerOS flows and manage deployments. ' +\n 'For get/delete actions pass flowId (required) plus optional slug to disambiguate when a flow has multiple active deployments. ' +\n \"If a flow has >=2 active deployments and no slug is supplied, the tool returns a MULTIPLE_DEPLOYMENTS error with a details[] list showing each deployment's slug, type, status, and updatedAt.\";\n\nconst inputSchema = {\n action: z\n .enum(['deploy', 'list', 'get', 'delete'])\n .describe('Deployment action to perform'),\n projectId: z\n .string()\n .optional()\n .describe('Project ID. Optional; falls back to the default project.'),\n flowId: z\n .string()\n .optional()\n .describe(\n 'Flow ID. Required for: deploy, get, delete. Optional filter for list.',\n ),\n slug: z\n .string()\n .optional()\n .describe(\n 'Deployment slug. Optional disambiguator for get/delete when the flow has multiple active deployments.',\n ),\n type: z\n .enum(['web', 'server'])\n .optional()\n .describe('Deployment type filter for list.'),\n status: z.string().optional().describe('Status filter for list.'),\n wait: z\n .boolean()\n .optional()\n .describe(\n 'Wait for deploy to complete (default true). Only used with deploy action.',\n ),\n flowName: z\n .string()\n .optional()\n .describe(\n 'Flow name for multi-settings flows. Only used with deploy action.',\n ),\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nfunction listForResolver(\n client: ToolClient,\n projectId: string | undefined,\n): ListDeploymentsForResolver {\n return async (q) => {\n const resp = (await client.listDeployments({\n projectId: projectId || q.projectId || undefined,\n flowId: q.flowId,\n })) as { deployments?: DeploymentSummaryForResolver[] };\n return resp.deployments ?? [];\n };\n}\n\nexport function createDeployManageToolSpec(client: ToolClient): ToolSpec {\n return {\n name: 'deploy_manage',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => deployManageHandlerBody(client, input),\n };\n}\n\nasync function deployManageHandlerBody(client: ToolClient, input: unknown) {\n const { action, projectId, flowId, slug, type, status, wait, flowName } =\n (input ?? {}) as {\n action?: 'deploy' | 'list' | 'get' | 'delete';\n projectId?: string;\n flowId?: string;\n slug?: string;\n type?: 'web' | 'server';\n status?: string;\n wait?: boolean;\n flowName?: string;\n };\n try {\n switch (action) {\n case 'deploy': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for deploy action. Use flow_manage with action \"list\" to see available flows.',\n ),\n );\n }\n const result = await client.deploy({\n flowId,\n wait: wait ?? true,\n flowName,\n });\n return mcpResult(result, {\n next: [\n 'Use deploy_manage with action \"get\" to check deployment status',\n ],\n });\n }\n\n case 'list': {\n const data = await client.listDeployments({\n projectId,\n flowId,\n type,\n status,\n });\n return mcpResult(data);\n }\n\n case 'get': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for get action. Use flow_manage with action \"list\" to see available flows.',\n ),\n );\n }\n const resolvedSlug = await resolveDeploymentSlug({\n projectId: projectId ?? '',\n flowId,\n slug,\n list: listForResolver(client, projectId),\n });\n const data = await client.getDeploymentBySlug({\n slug: resolvedSlug,\n projectId,\n });\n return mcpResult(data);\n }\n\n case 'delete': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for delete action. Use flow_manage with action \"list\" to see available flows.',\n ),\n );\n }\n const resolvedSlug = await resolveDeploymentSlug({\n projectId: projectId ?? '',\n flowId,\n slug,\n list: listForResolver(client, projectId),\n });\n const data = await client.deleteDeployment({\n slug: resolvedSlug,\n projectId,\n });\n return mcpResult({\n deleted: true,\n ...(data as Record<string, unknown>),\n });\n }\n\n default:\n throw new Error(\n `Unknown action: ${action}. Use one of: deploy, list, get, delete`,\n );\n }\n } catch (error) {\n return mcpError(error, isAuthError(error) ? AUTH_HINT : undefined);\n }\n}\n\nexport function registerDeployTool(server: McpServer, client: ToolClient) {\n const spec = createDeployManageToolSpec(client);\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","/**\n * Internal helpers shared by deploy_manage actions. Not re-exported from the\n * tools barrel; leading underscore marks this as tool-module internal.\n *\n * All collaborators are passed in as arguments so unit tests can inject fakes\n * without relying on jest.mock. This keeps resolver tests local to the\n * resolver signature and avoids shared-mock drift.\n */\n\n/**\n * The subset of a deployment summary the resolver needs to decide 0 / 1 / many\n * and to surface a useful MULTIPLE_DEPLOYMENTS error. Kept structurally\n * compatible with the CLI's DeploymentSummaryForFlow.\n */\nexport interface DeploymentSummaryForResolver {\n slug: string;\n type: string;\n status: string;\n updatedAt: string;\n}\n\n/**\n * Dependency injected list function. Must return only non-deleted deployments\n * for the given project + flow. The production wiring calls\n * `listDeployments({ projectId, flowId })` from `@walkeros/cli`, which hits\n * the app API; the API excludes soft-deleted rows.\n */\nexport type ListDeploymentsForResolver = (q: {\n projectId: string;\n flowId: string;\n}) => Promise<DeploymentSummaryForResolver[]>;\n\n/**\n * Error thrown when a flow has 0 matching deployments, or when a caller passed\n * a slug that does not match any active deployment of the flow. The MCP layer\n * translates this into an mcpError with `code: 'NOT_FOUND'`.\n */\nexport class DeploymentNotFoundError extends Error {\n readonly code = 'NOT_FOUND';\n constructor(message: string) {\n super(message);\n this.name = 'DeploymentNotFoundError';\n }\n}\n\n/**\n * Error thrown when a flow has >= 2 active deployments and the caller did not\n * pass a slug. Carries a `details[]` list so the MCP layer can surface the\n * options to the user.\n */\nexport class MultipleDeploymentsError extends Error {\n readonly code = 'MULTIPLE_DEPLOYMENTS';\n readonly details: DeploymentSummaryForResolver[];\n constructor(message: string, details: DeploymentSummaryForResolver[]) {\n super(message);\n this.name = 'MultipleDeploymentsError';\n this.details = details;\n }\n}\n\n/**\n * Resolve a concrete deployment slug for a (projectId, flowId, slug?) tuple.\n *\n * Behavior:\n * - 0 matches: throws DeploymentNotFoundError.\n * - 1 match, no slug: returns the single slug.\n * - slug provided and matches: returns the slug.\n * - slug provided and does not match: throws DeploymentNotFoundError.\n * - >= 2 matches, no slug: throws MultipleDeploymentsError with details[].\n */\nexport async function resolveDeploymentSlug(args: {\n projectId: string;\n flowId: string;\n slug?: string;\n list: ListDeploymentsForResolver;\n}): Promise<string> {\n const matches = await args.list({\n projectId: args.projectId,\n flowId: args.flowId,\n });\n\n if (matches.length === 0) {\n throw new DeploymentNotFoundError(\n `No deployments found for flow ${args.flowId}`,\n );\n }\n\n if (args.slug !== undefined) {\n const hit = matches.find((m) => m.slug === args.slug);\n if (!hit) {\n throw new DeploymentNotFoundError(\n `No deployment with slug ${args.slug} in flow ${args.flowId}`,\n );\n }\n return hit.slug;\n }\n\n if (matches.length === 1) {\n return matches[0].slug;\n }\n\n throw new MultipleDeploymentsError(\n `Flow ${args.flowId} has ${matches.length} active deployments; pass slug to disambiguate`,\n matches.map((m) => ({\n slug: m.slug,\n type: m.type,\n status: m.status,\n updatedAt: m.updatedAt,\n })),\n );\n}\n","import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { fetchPackageSchema } from '@walkeros/core';\nimport { fetchCatalog } from '../catalog.js';\n\nexport function registerPackageSchemaResources(server: McpServer) {\n const template = new ResourceTemplate('walkeros://schema/{packageName}', {\n list: async () => {\n const catalog = await fetchCatalog();\n return {\n resources: catalog.map((pkg) => ({\n uri: `walkeros://schema/${encodeURIComponent(pkg.name)}`,\n name: pkg.name,\n description: `Schema and examples for ${pkg.name}`,\n mimeType: 'application/json' as const,\n })),\n };\n },\n });\n\n server.registerResource(\n 'package-schema',\n template,\n {\n title: 'walkerOS Package Schema',\n description:\n 'JSON Schema and configuration examples for walkerOS packages',\n mimeType: 'application/json',\n },\n async (uri, { packageName }) => {\n const info = await fetchPackageSchema(\n decodeURIComponent(packageName as string),\n );\n return {\n contents: [\n {\n uri: uri.toString(),\n mimeType: 'application/json' as const,\n text: JSON.stringify(info, null, 2),\n },\n ],\n };\n },\n );\n}\n","/**\n * Reference resources — pure schema and structural data only.\n *\n * Design principle: resources are loaded into context and should contain\n * only schemas, type definitions, and structural references. Behavioral\n * guidance, tutorials, and step-by-step instructions belong in prompts.\n * Vendor-specific examples belong in packages (fetched via package_get).\n */\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { schemas } from '@walkeros/core/dev';\nimport { fetchCatalog } from '../catalog.js';\n\nexport function registerReferenceResources(server: McpServer) {\n // Flow Schema reference (generated from Zod)\n server.resource(\n 'flow-schema',\n 'walkeros://reference/flow-schema',\n {\n description:\n 'JSON Schema for Flow.Json — the complete flow configuration structure',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/flow-schema',\n text: JSON.stringify(schemas.configJsonSchema, null, 2),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Event Model reference (generated from Zod)\n server.resource(\n 'event-model',\n 'walkeros://reference/event-model',\n {\n description:\n 'JSON Schema for walkerOS events: entity-action naming, data, context, globals, user, consent',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/event-model',\n text: JSON.stringify(schemas.eventJsonSchema, null, 2),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Mapping reference (generated from Zod — composite of related schemas)\n server.resource(\n 'mapping',\n 'walkeros://reference/mapping',\n {\n description:\n 'JSON Schemas for walkerOS mapping: rules, valueConfig, rule, policy',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/mapping',\n text: JSON.stringify(\n {\n rules: schemas.rulesJsonSchema,\n valueConfig: schemas.valueConfigJsonSchema,\n rule: schemas.ruleJsonSchema,\n policy: schemas.policyJsonSchema,\n },\n null,\n 2,\n ),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Consent reference (generated from Zod)\n server.resource(\n 'consent',\n 'walkeros://reference/consent',\n {\n description:\n 'JSON Schema for walkerOS consent: destination-level, rule-level, and field-level consent gating',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/consent',\n text: JSON.stringify(schemas.consentJsonSchema, null, 2),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Variables reference (hand-maintained — runtime interpolation patterns not captured in Zod schemas)\n server.resource(\n 'variables',\n 'walkeros://reference/variables',\n {\n description:\n 'walkerOS variable patterns: $var, $env, $contract, $code, $store, $secret substitution',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/variables',\n text: JSON.stringify(\n {\n separatorRule:\n '`.` for names and paths; `:` for literal values or raw-code payloads.',\n patterns: {\n '$var.name':\n 'Variable reference. Whole-string preserves native type (object, array, scalar). Inline interpolation requires a scalar. Reusable fragments (mapping templates, matcher lists, consent objects) live in the variables block and are referenced by name.',\n '$var.name.deep.path':\n 'Deep-path access into a structured variable. Walks nested keys/indices. Whole-string preserves type at the leaf; inline still requires a scalar leaf.',\n '$env.NAME':\n 'Environment variable. $env.GA_ID reads process.env.GA_ID.',\n '$env.NAME:default':\n 'Environment variable with fallback. $env.GA_ID:G-DEFAULT (the `:` is the literal default separator).',\n '$contract.name':\n 'Contract reference. Links to a named contract for validation.',\n '$contract.name.path':\n 'Nested contract access. $contract.ecommerce.product.',\n '$code:(expr)':\n 'Inline JavaScript. $code:(event) => event.data.price * 100 (the `:` carries the raw-code payload).',\n '$store.storeId':\n 'Store injection in env values. Wires runtime store access.',\n '$secret.NAME':\n 'Secret injection. Resolved server-side at deploy/runtime.',\n },\n cascade: {\n priority: [\n '1. Step-level variables (highest)',\n '2. Flow-level variables',\n '3. Config-level variables (lowest)',\n ],\n example: {\n variables: {\n apiUrl: 'https://x.io',\n mapping: { id: 'data.id' },\n },\n flows: {\n production: {\n destinations: {\n api: {\n config: {\n url: '$var.apiUrl',\n idPath: '$var.mapping.id',\n },\n },\n },\n },\n },\n },\n },\n },\n null,\n 2,\n ),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Contract reference (generated from Zod)\n server.resource(\n 'contract',\n 'walkeros://reference/contract',\n {\n description:\n 'JSON Schema for walkerOS contracts: event schema validation with entity-action keying',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/contract',\n text: JSON.stringify(schemas.contractJsonSchema, null, 2),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Examples reference (loaded from @walkeros/cli at runtime)\n server.resource(\n 'examples',\n 'walkeros://reference/examples',\n {\n description:\n 'Complete flow config example: web + server flows, mapping, contracts, step examples',\n mimeType: 'application/json',\n },\n async () => {\n let example: string;\n try {\n const { readFileSync } = await import('fs');\n const { createRequire } = await import('module');\n const require = createRequire(import.meta.url);\n const examplePath =\n require.resolve('@walkeros/cli/examples/flow-complete.json');\n example = readFileSync(examplePath, 'utf-8');\n } catch {\n example = JSON.stringify({ error: 'Example not found' });\n }\n return {\n contents: [\n {\n uri: 'walkeros://reference/examples',\n text: example,\n mimeType: 'application/json',\n },\n ],\n };\n },\n );\n\n // OpenAPI 3.1 specification for the walkerOS cloud HTTP API\n server.resource(\n 'openapi',\n 'walkeros://reference/openapi',\n {\n description: 'walkerOS cloud API — OpenAPI 3.1 specification',\n mimeType: 'application/json',\n },\n async () => {\n let openApiSpec: string;\n try {\n const { readFileSync } = await import('fs');\n const { createRequire } = await import('module');\n const require = createRequire(import.meta.url);\n const specPath = require.resolve('@walkeros/cli/openapi/spec.json');\n openApiSpec = readFileSync(specPath, 'utf-8');\n } catch {\n openApiSpec = JSON.stringify({ error: 'OpenAPI spec not found' });\n }\n return {\n contents: [\n {\n uri: 'walkeros://reference/openapi',\n text: openApiSpec,\n mimeType: 'application/json',\n },\n ],\n };\n },\n );\n\n // Packages catalog resource\n server.resource(\n 'packages',\n 'walkeros://reference/packages',\n {\n description:\n 'Complete walkerOS package catalog — all sources, destinations, transformers, and stores',\n mimeType: 'application/json',\n },\n async () => {\n const catalog = await fetchCatalog();\n return {\n contents: [\n {\n uri: 'walkeros://reference/packages',\n text: JSON.stringify(catalog, null, 2),\n mimeType: 'application/json',\n },\n ],\n };\n },\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerAddStepPrompt(server: McpServer) {\n server.registerPrompt(\n 'add-step',\n {\n description:\n 'Add a source, destination, transformer, or store step to a flow configuration. ' +\n 'Guides through package selection, config scaffolding, and wiring.',\n argsSchema: {\n stepType: z\n .string()\n .optional()\n .describe(\n 'Type of step to add: source, destination, transformer, or store',\n ),\n flowPath: z\n .string()\n .optional()\n .describe('Path to the flow.json file to modify'),\n },\n },\n async ({ stepType, flowPath }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Help me add a ${stepType || 'new'} step to my flow${flowPath ? ` at ${flowPath}` : ''}.`,\n '',\n 'Follow these steps:',\n `1. ${stepType ? '' : 'Ask what type of step (source, destination, transformer, store). Then '}Use package_search to browse available packages for the selected type and platform.`,\n '2. Use package_get to read the package\\'s config schema (schemas.config contains the full config shape: base fields like consent/require/logger + package-specific settings). Use section=\"hints\" for additional guidance.',\n '3. Use package_get with section=\"examples\" to see working configuration examples.',\n '4. Scaffold the step config using the package schemas — include required settings with placeholder values.',\n '5. Wire the step into the flow: add to packages section (with version if needed), connect via next/before chains if needed.',\n '6. For destinations: configure mapping using nested entity → action keys. Event \"product add\" maps to `{ \"product\": { \"add\": { name: \"AddToCart\" } } }`. Use the setup-mapping prompt for guidance.',\n '7. For destinations: if consent-gated loading is needed, add require: [\"consent\"] to config. ' +\n 'Note: require delays initialization until a \"walker consent\" event fires. ' +\n 'When simulating with flow_simulate, destinations with require will error \"not found\" — ' +\n 'remove require temporarily or test without it. ' +\n 'For per-event consent filtering, add consent: { marketing: true } to config.',\n '8. Use flow_validate to verify the result.',\n '9. For server sources: check if the package supports `ingest` configuration via package_get. Ingest extracts request metadata (IP, user-agent, headers) using mapping syntax. Transformers like fingerprint depend on ingest data.',\n '10. When adding a transformer that uses ingest fields, verify the source has `ingest` configured — otherwise ingest fields resolve to empty values.',\n '',\n 'Important:',\n '- Read the walkeros://reference/flow-schema resource to understand connection rules.',\n '- Sources connect to pre-collector transformers via `next`.',\n '- Destinations connect to post-collector transformers via `before`.',\n '- Stores are passive — referenced via `$store.storeName` in env values.',\n '- Use variables ($var) for values that change between environments.',\n '- For required settings without defaults in the package schema, ask the user which value to use. Do not guess credentials, IDs, or environment-specific values.',\n '- If $meta.exports lists named exports, set the `code` field on the step to the chosen export name. If only one export exists, use it automatically.',\n ].join('\\n'),\n },\n },\n ],\n }),\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerSetupMappingPrompt(server: McpServer) {\n server.registerPrompt(\n 'setup-mapping',\n {\n description:\n 'Set up event mapping for any step in a flow. Teaches mapping syntax and uses package examples as templates.',\n argsSchema: {\n stepName: z\n .string()\n .optional()\n .describe('Step name in the flow (e.g., \"gtag\", \"meta\", \"express\")'),\n },\n },\n async ({ stepName }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Help me set up mapping${stepName ? ` for the \"${stepName}\" step` : ''}.`,\n '',\n 'Follow these steps:',\n '1. Read the walkeros://reference/mapping resource for syntax reference.',\n `2. ${stepName ? `Identify the package for \"${stepName}\" in the flow, then u` : 'U'}se package_get with section=\"examples\" to see the source output shape — mapping keys must match the actual events the source emits.`,\n '3. Ask whether this is source mapping (raw input → walkerOS events) or destination mapping (walkerOS events → vendor format).',\n '4. Ask which events to map (one at a time, not all at once).',\n '5. Generate one mapping rule using the package examples as templates. Validate it with flow_validate before moving to the next.',\n '6. Repeat for each event.',\n '',\n 'Mapping uses nested entity → action keys. Event \"product add\" maps to `{ \"product\": { \"add\": Rule } }`. Wildcards: `{ \"*\": { \"view\": Rule } }`.',\n '',\n 'Extract shared mapping shapes into variables, reference via $var.name (deep paths supported).',\n '',\n 'Policy and consent in mapping:',\n '- config.policy runs BEFORE mapping rules — use it to inject or redact fields on the event.',\n '- rule.policy runs after config.policy but before data transformation — use for event-specific pre-processing.',\n '- config.consent gates ALL events to this destination. rule.consent gates specific event types.',\n '- Individual value configs support consent: { marketing: true } for field-level gating.',\n ].join('\\n'),\n },\n },\n ],\n }),\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerManageContractPrompt(server: McpServer) {\n server.registerPrompt(\n 'manage-contract',\n {\n description:\n 'Create or update event contracts for a flow. Can generate contracts from existing mappings or scaffold mappings from contracts.',\n argsSchema: {\n direction: z\n .string()\n .optional()\n .describe(\n 'Direction: \"from-mappings\" (extract contract from existing mappings), ' +\n '\"from-scratch\" (create new contract), or \"to-mappings\" (scaffold mappings from contract)',\n ),\n },\n },\n async ({ direction }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Help me ${direction === 'to-mappings' ? 'scaffold mappings from a contract' : direction === 'from-mappings' ? 'generate a contract from existing mappings' : 'manage event contracts'}.`,\n '',\n 'Follow these steps:',\n '1. Read the walkeros://reference/contract resource to understand contract structure.',\n direction === 'from-mappings'\n ? '2. Read all destination mappings in the flow, extract referenced event fields, and generate a contract with those as required properties.'\n : direction === 'to-mappings'\n ? '2. Read the contract from the flow, then scaffold mapping stubs for each destination based on the contract fields.'\n : '2. Ask for entity-action names and required properties, or ask whether to generate from existing mappings.',\n '3. Use entity-action keying with wildcards (*.*, *.action, entity.*) for broad rules.',\n '4. Define JSON Schema for events, globals, context, custom, user, and consent.',\n '5. Use flow_validate to verify the contract.',\n '',\n 'Contracts and mappings are bidirectional:',\n '- **Contract → Mappings**: contract defines what events look like, mappings are scaffolded to match.',\n '- **Mappings → Contract**: existing mappings reveal which fields are used, contract formalizes them.',\n '',\n 'For server flows: if the contract references fields populated by ingest (e.g., user fingerprint hash), verify the source config.ingest extracts the needed request metadata.',\n '',\n 'Use $contract.name references to link contracts in the flow.',\n 'Contracts support extends for inheritance between event types.',\n ].join('\\n'),\n },\n },\n ],\n }),\n );\n}\n","export const SERVER_INSTRUCTIONS = `walkerOS is an open-source, privacy-first event data collection platform. Define event pipelines as code using JSON flow configurations.\n\n## Rules\n\n- **Never guess package names.** Always use \\`package_search\\` first to find exact names, then \\`package_get\\` for details.\n- **Never construct flow configs from memory.** Read \\`walkeros://reference/flow-schema\\` and use \\`package_get\\` for package-specific schemas.\n- **Always validate.** Run \\`flow_validate\\` after every config change. If validation fails, fix and re-validate.\n- **Simulate before deploying.** Use \\`flow_simulate\\` to test with mocked API calls before \\`flow_bundle\\` or \\`flow_push\\`.\n\n## Workflow\n\n1. \\`auth({ action: \"status\" })\\` — check if logged in, or \\`auth({ action: \"login\" })\\` to connect\n2. \\`project_manage({ action: \"list\" })\\` — see your projects\n3. \\`flow_manage({ action: \"list\" })\\` — see all flows across projects\n4. \\`flow_load({ platform: \"web\" })\\` or \\`flow_load({ source: \"./flow.json\" })\\` — create or load\n5. \\`package_search({ type: \"destination\", platform: \"web\" })\\` — discover packages\n6. \\`package_get({ package: \"...\" })\\` — read schemas, hints, examples\n7. Use the \\`add-step\\` prompt — guided step addition\n8. Use the \\`setup-mapping\\` prompt — event transformation config\n9. \\`flow_validate({ type: \"flow\", input: \"flow.json\" })\\` — verify\n10. \\`flow_simulate({ configPath: \"flow.json\", event: \"...\" })\\` — test\n11. \\`flow_manage({ action: \"update\", flowId: \"...\", content: {...} })\\` — save to cloud\n12. \\`deploy_manage({ action: \"deploy\", flowId: \"...\" })\\` — deploy\n\n## Architecture: Source → Collector → Destination(s)\n\nEvery component in a flow is a **step**: sources capture events, transformers process them, destinations deliver them, stores provide shared state. Steps connect via \\`next\\` (pre-collector) and \\`before\\` (post-collector) chains.\n\n## Flow Config Structure\n\n\\`\\`\\`json\n{\n \"version\": 4,\n \"flows\": {\n \"default\": {\n \"config\": { \"platform\": \"web\" },\n \"sources\": { \"<name>\": { \"package\": \"<npm-package>\", \"config\": {} } },\n \"destinations\": { \"<name>\": { \"package\": \"<npm-package>\", \"config\": { \"settings\": {} } } }\n }\n }\n}\n\\`\\`\\`\n\n- \\`version: 4\\` is required\n- Each flow declares its target via \\`config.platform\\` (\\`\"web\"\\` or \\`\"server\"\\`)\n- Destination settings go inside \\`config.settings\\`, not directly on the destination\n- Event format: \\`{ name: \"entity action\", data: {...}, entity: \"...\", action: \"...\" }\\`\n\n## Key Concepts\n\n- **Mapping** transforms events using data/map/loop/set/condition rules. Same syntax on sources and destinations. Mapping rules use NESTED entity → action keying: event name \"product add\" maps to \\`{ \"product\": { \"add\": Rule } }\\`. Wildcards: \\`{ \"*\": { \"view\": Rule } }\\`.\n- **Contracts** define event schemas using entity-action keying. Can generate FROM mappings or scaffold mappings FROM contracts.\n- **Variables** (\\$var, \\$env, \\$code, \\$store) enable DRY, environment-aware config. Whole-string \\`$var.name\\` references preserve native type (object/array/scalar); inline interpolation requires a scalar. Deep paths via \\`$var.name.deep.path\\`.\n- **Consent** gates destinations, mapping rules, and individual fields. Privacy-first by design.\n\n## Simulation Tips\n\n- Destinations with \\`require: [\"consent\"]\\` stay **pending** until a \\`\"walker consent\"\\` event fires. Simulation will error \"not found\" for pending destinations, remove \\`require\\` from config when testing with \\`flow_simulate\\`.\n- Destinations with \\`consent: { marketing: true }\\` silently skip events that lack matching consent. Include \\`consent\\` in the event: \\`{ name: \"page view\", data: {...}, consent: { marketing: true } }\\`.\n- **Mapping** transforms event names and data at the destination level. Events without a matching mapping rule pass through unmodified.\n- **Policy** modifies the event before mapping runs, use it to inject computed fields or redact sensitive data.\n\n## Reference Resources\n\nRead these before constructing configs manually: \\`walkeros://reference/flow-schema\\`, \\`walkeros://reference/mapping\\`, \\`walkeros://reference/event-model\\`, \\`walkeros://reference/consent\\`, \\`walkeros://reference/variables\\`, \\`walkeros://reference/contract\\`, \\`walkeros://reference/examples\\`.`;\n","import { randomUUID } from 'crypto';\nimport { telemetry } from '@walkeros/cli';\n\n/**\n * Options for the MCP telemetry emitter wrapper.\n *\n * `clientInfo` mirrors the MCP SDK shape negotiated during initialize.\n * When the client doesn't send one, we record the client name as \"unknown\"\n * inside the per-event data so downstream analytics can still bucket the\n * event. The walkerOS source identifier is the package itself (`mcp`), not\n * the client.\n */\nexport interface McpEmitterOptions {\n clientInfo?: { name: string; version: string };\n packageVersion: string;\n}\n\n/**\n * MCP-specific event emitter.\n *\n * Wraps `@walkeros/cli`'s `telemetry.createEmitter` with:\n * - `source.type` fixed to `\"mcp\"`\n * - `source.platform` fixed to `\"server\"`\n * - per-emission `source.tool` for `cmd invoke` events\n * - a fresh session UUID per MCP server instance\n *\n * Surfaces the narrow set of events the MCP server needs to emit.\n */\nexport interface McpEmitter {\n emitStart(): Promise<void>;\n emitInvoke(\n tool: string,\n outcome: 'success' | 'error',\n timingMs: number,\n ): Promise<void>;\n emitError(kind: 'uncaught' | 'unhandledRejection' | 'startup'): Promise<void>;\n}\n\n/**\n * Build an MCP telemetry emitter.\n *\n * All consent, debug, and endpoint resolution is delegated to the CLI's\n * underlying `telemetry.createEmitter`. This wrapper only provides\n * MCP-specific field mapping and event shorthands.\n */\nexport async function createMcpEmitter(\n opts: McpEmitterOptions,\n): Promise<McpEmitter> {\n const clientName = opts.clientInfo?.name || 'unknown';\n const session = randomUUID();\n\n const emitter = await telemetry.createEmitter({\n source: {\n type: 'mcp',\n platform: 'server',\n },\n packageVersion: opts.packageVersion,\n session,\n });\n\n return {\n async emitStart() {\n const ci = telemetry.getCiInfo();\n await emitter.send('mcp start', {\n ...ci,\n client: clientName,\n });\n },\n async emitInvoke(tool, outcome, timingMs) {\n await emitter.send(\n 'cmd invoke',\n { outcome, client: clientName },\n timingMs,\n { tool },\n );\n },\n async emitError(kind) {\n await emitter.send('error throw', { kind });\n },\n };\n}\n","import {\n listProjects,\n getProject,\n createProject,\n updateProject,\n deleteProject,\n setDefaultProject,\n getDefaultProject,\n listAllFlows,\n listFlows,\n getFlow,\n createFlow,\n updateFlow,\n deleteFlow,\n duplicateFlow,\n listPreviews,\n getPreview,\n createPreview,\n deletePreview,\n deploy,\n listDeployments,\n getDeploymentBySlug,\n deleteDeployment,\n requestDeviceCode,\n pollForToken,\n whoami,\n resolveToken,\n deleteConfig,\n feedback,\n getFeedbackPreference,\n setFeedbackPreference,\n} from '@walkeros/cli';\nimport type {\n DeviceCodeResult,\n PollResult,\n ListFlowsOptions,\n DeployOptions,\n ListDeploymentsOptions,\n ListPreviewsOptions,\n GetPreviewOptions,\n CreatePreviewOptions,\n DeletePreviewOptions,\n FeedbackOptions,\n} from '@walkeros/cli';\n\nimport type { ToolClient } from './tool-client.js';\n\n/**\n * Default ToolClient implementation backed by @walkeros/cli. Every method\n * delegates to the CLI's programmatic API, which in turn talks to the\n * walkerOS app over HTTPS via openapi-fetch. Token resolution and the\n * base URL come from the CLI's config file and environment\n * (WALKEROS_TOKEN, WALKEROS_APP_URL), so no constructor args are required.\n */\nexport class HttpToolClient implements ToolClient {\n async listProjects(): Promise<unknown> {\n return listProjects();\n }\n async getProject(options: { projectId?: string }): Promise<unknown> {\n return getProject(options);\n }\n async createProject(options: { name: string }): Promise<unknown> {\n return createProject(options);\n }\n async updateProject(options: {\n projectId?: string;\n name: string;\n }): Promise<unknown> {\n return updateProject(options);\n }\n async deleteProject(options: { projectId?: string }): Promise<unknown> {\n return deleteProject(options);\n }\n setDefaultProject(projectId: string): void {\n setDefaultProject(projectId);\n }\n getDefaultProject(): string | null {\n return getDefaultProject();\n }\n\n async listAllFlows(options?: {\n sort?: string;\n order?: 'asc' | 'desc';\n includeDeleted?: boolean;\n }): Promise<unknown> {\n return listAllFlows(options as Parameters<typeof listAllFlows>[0]);\n }\n async listFlows(options: ListFlowsOptions): Promise<unknown> {\n return listFlows(options);\n }\n async getFlow(options: {\n flowId: string;\n projectId?: string;\n fields?: string[];\n }): Promise<unknown> {\n return getFlow(options);\n }\n async createFlow(options: {\n name: string;\n content: Record<string, unknown>;\n projectId?: string;\n }): Promise<unknown> {\n return createFlow(options);\n }\n async updateFlow(options: {\n flowId: string;\n projectId?: string;\n name?: string;\n content?: Record<string, unknown>;\n mergePatch?: boolean;\n }): Promise<unknown> {\n return updateFlow(options);\n }\n async deleteFlow(options: {\n flowId: string;\n projectId?: string;\n }): Promise<unknown> {\n return deleteFlow(options);\n }\n async duplicateFlow(options: {\n flowId: string;\n name?: string;\n projectId?: string;\n }): Promise<unknown> {\n return duplicateFlow(options);\n }\n\n async listPreviews(options: ListPreviewsOptions): Promise<unknown> {\n return listPreviews(options);\n }\n async getPreview(options: GetPreviewOptions): Promise<unknown> {\n return getPreview(options);\n }\n async createPreview(options: CreatePreviewOptions): Promise<unknown> {\n return createPreview(options);\n }\n async deletePreview(options: DeletePreviewOptions): Promise<unknown> {\n return deletePreview(options);\n }\n\n async deploy(options: DeployOptions): Promise<unknown> {\n return deploy(options);\n }\n async listDeployments(options: ListDeploymentsOptions): Promise<unknown> {\n return listDeployments(options);\n }\n async getDeploymentBySlug(options: {\n slug: string;\n projectId?: string;\n }): Promise<unknown> {\n return getDeploymentBySlug(options);\n }\n async deleteDeployment(options: {\n slug: string;\n projectId?: string;\n }): Promise<unknown> {\n return deleteDeployment(options);\n }\n\n async requestDeviceCode(): Promise<DeviceCodeResult> {\n return requestDeviceCode();\n }\n async pollForToken(\n deviceCode: string,\n options?: { timeoutMs?: number },\n ): Promise<PollResult> {\n return pollForToken(deviceCode, options);\n }\n async whoami(): Promise<unknown> {\n return whoami();\n }\n resolveToken(): { token: string; source: 'env' | 'config' } | null {\n return resolveToken();\n }\n deleteConfig(): boolean {\n return deleteConfig();\n }\n\n async submitFeedback(text: string, options?: FeedbackOptions): Promise<void> {\n await feedback(text, options);\n }\n getFeedbackPreference(): boolean | undefined {\n return getFeedbackPreference();\n }\n setFeedbackPreference(anonymous: boolean): void {\n setFeedbackPreference(anonymous);\n }\n}\n"],"mappings":";;;A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G,qBAAqB,CAAC,QAAQ;AACvC,QAAM,UAAU,uBAAuB;AACvC,MAAI,SAAS;AACX,YAAQ,UAAU,UAAU,EAAE,MAAM,MAAM;AAAA,IAAC,CAAC;AAAA,EAC9C;AACA,UAAQ,MAAM,0CAA0C,GAAG;AAC7D,CAAC;AAED,QAAQ,GAAG,sBAAsB,CAAC,WAAW;AAC3C,QAAM,UAAU,uBAAuB;AACvC,MAAI,SAAS;AACX,YAAQ,UAAU,oBAAoB,EAAE,MAAM,MAAM;AAAA,IAAC,CAAC;AAAA,EACxD;AACA,UAAQ,MAAM,2CAA2C,MAAM;AACjE,CAAC;AAED,eAAe,OAAO;AACpB,QAAM,SAAS,wBAAwB;AAAA,IACrC,QAAQ,IAAI,eAAe;AAAA,IAC3B,SAAS;AAAA,EACX,CAAC;AACD,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAC9B,UAAQ,MAAM,2CAA2C;AAC3D;AAEA,KAAK,EAAE,MAAM,OAAO,UAAU;AAI5B,MAAI;AACF,UAAM,UAAU,MAAM,iBAAiB;AAAA,MACrC,YAAY;AAAA,MACZ,gBAAgB;AAAA,IAClB,CAAC;AACD,UAAM,QAAQ,UAAU,SAAS;AAAA,EACnC,QAAQ;AAAA,EAER;AACA,UAAQ,MAAM,oCAAoC,KAAK;AACvD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["schemas","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","schemas","annotations","mcpResult","mcpError","z","schemas","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","schemas","z","annotations","summary","mcpResult","mcpError","z","schemas","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","schemas","z","annotations","mcpError","mcpResult","z","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","z","annotations","mcpResult","mcpError","z","mcpResult","mcpError","z","mcpResult","mcpError","z","loadJsonConfig","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","z","annotations","loadJsonConfig","mcpResult","mcpError","z","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","annotations","z","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","annotations","z","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","z","annotations","mcpResult","mcpError","z","mcpResult","mcpError","KEEP_LITERAL","keepLiteral","TITLE","DESCRIPTION","inputSchema","z","annotations","data","safe","mcpResult","mcpError","z","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","z","annotations","mcpError","mcpResult","schemas","schemas","require","z","z","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/stdio.ts","../src/server.ts","../src/tools/validate.ts","../src/schemas/output.ts","../src/user-data.ts","../src/tools/bundle.ts","../src/tools/simulate.ts","../src/tools/push.ts","../src/tools/examples.ts","../src/tools/package.ts","../src/catalog.ts","../src/tools/flow-load.ts","../src/tools/feedback.ts","../src/tools/auth.ts","../src/tools/project-manage.ts","../src/types.ts","../src/tools/flow-manage.ts","../src/ui-parts.ts","../src/tools/deploy-manage.ts","../src/tools/_resolvers.ts","../src/resources/package-schemas.ts","../src/resources/references.ts","../src/prompts/add-step.ts","../src/prompts/setup-mapping.ts","../src/prompts/manage-contract.ts","../src/instructions.ts","../src/telemetry.ts","../src/http-tool-client.ts"],"sourcesContent":["import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { setClientContext } from '@walkeros/cli';\n\nimport { createWalkerOSMcpServer, getMcpEmitterSingleton } from './server.js';\nimport { HttpToolClient } from './http-tool-client.js';\nimport { createMcpEmitter } from './telemetry.js';\n\ndeclare const __VERSION__: string;\n\nsetClientContext({ type: 'mcp', version: __VERSION__ });\n\n// Hook process-level error channels so we can emit `error throw` before the\n// process tears down. Both handlers look up the emitter lazily: if the MCP\n// handshake never completed, no emitter exists and we silently skip.\n// We don't call process.exit — stdio transport already propagates failures\n// up to the parent client via the JSON-RPC channel.\nprocess.on('uncaughtException', (err) => {\n const emitter = getMcpEmitterSingleton();\n if (emitter) {\n emitter.emitError('uncaught').catch(() => {});\n }\n console.error('Uncaught exception in Flow MCP server:', err);\n});\n\nprocess.on('unhandledRejection', (reason) => {\n const emitter = getMcpEmitterSingleton();\n if (emitter) {\n emitter.emitError('unhandledRejection').catch(() => {});\n }\n console.error('Unhandled rejection in Flow MCP server:', reason);\n});\n\nasync function main() {\n const server = createWalkerOSMcpServer({\n client: new HttpToolClient(),\n version: __VERSION__,\n });\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error('walkerOS Flow MCP server running on stdio');\n}\n\nmain().catch(async (error) => {\n // Startup failure — no client handshake happened, so there's no emitter in\n // the module singleton. Build a one-shot emitter with an unknown client so\n // the error is still visible to telemetry.\n try {\n const emitter = await createMcpEmitter({\n clientInfo: undefined,\n packageVersion: __VERSION__,\n });\n await emitter.emitError('startup');\n } catch {\n // swallow — telemetry must never mask the original startup error\n }\n console.error('Failed to start Flow MCP server:', error);\n process.exit(1);\n});\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport type { ToolClient } from './tool-client.js';\nimport { registerFlowValidateTool } from './tools/validate.js';\nimport { registerFlowBundleTool } from './tools/bundle.js';\nimport { registerFlowSimulateTool } from './tools/simulate.js';\nimport { registerFlowPushTool } from './tools/push.js';\nimport { registerFlowExamplesTool } from './tools/examples.js';\nimport {\n registerPackageSearchTool,\n registerGetPackageSchemaTool,\n} from './tools/package.js';\nimport { registerFlowLoadTool } from './tools/flow-load.js';\nimport { registerFeedbackTool } from './tools/feedback.js';\nimport { registerAuthTool } from './tools/auth.js';\nimport { registerProjectManageTool } from './tools/project-manage.js';\nimport { registerFlowManageTool } from './tools/flow-manage.js';\nimport { registerDeployTool } from './tools/deploy-manage.js';\nimport { registerPackageSchemaResources } from './resources/package-schemas.js';\nimport { registerReferenceResources } from './resources/references.js';\nimport { registerAddStepPrompt } from './prompts/add-step.js';\nimport { registerSetupMappingPrompt } from './prompts/setup-mapping.js';\nimport { registerManageContractPrompt } from './prompts/manage-contract.js';\nimport { SERVER_INSTRUCTIONS } from './instructions.js';\nimport { createMcpEmitter, type McpEmitter } from './telemetry.js';\n\nexport interface Logger {\n debug?(message: string, meta?: Record<string, unknown>): void;\n info?(message: string, meta?: Record<string, unknown>): void;\n warn?(message: string, meta?: Record<string, unknown>): void;\n error?(message: string, meta?: Record<string, unknown>): void;\n}\n\nexport interface CreateServerOptions {\n client: ToolClient;\n logger?: Logger;\n version?: string;\n catalogBaseUrl?: string;\n}\n\n/**\n * Module-scoped singleton emitter, populated once the MCP `initialize`\n * handshake completes and clientInfo is known. The stdio entrypoint reads\n * this to emit process-level `error throw` events from uncaughtException /\n * unhandledRejection hooks, where the Server instance isn't in scope.\n */\nlet currentEmitter: McpEmitter | undefined;\n\nexport function getMcpEmitterSingleton(): McpEmitter | undefined {\n return currentEmitter;\n}\n\n/**\n * Internal: reset for tests that want a clean slate between cases.\n * Not exported from the package.\n */\nexport function __resetMcpEmitterSingletonForTesting(): void {\n currentEmitter = undefined;\n}\n\n/**\n * Minimal shape of a `_registeredTools` entry we rely on for handler\n * wrapping. Typed locally to avoid leaking SDK internals while keeping\n * strict typing on the handler signature.\n */\ntype WrappableRegisteredTool = {\n handler: (...args: unknown[]) => unknown;\n};\n\ntype RegisteredToolsRecord = Record<string, WrappableRegisteredTool>;\n\n/**\n * Wrap every already-registered tool handler with telemetry. The wrapper\n * emits `cmd invoke` with outcome + timing, swallowing any telemetry error\n * so it never surfaces to the tool caller. We look up the emitter lazily at\n * call time so wrapping can happen before the emitter is created.\n */\nfunction wrapRegisteredToolsWithTelemetry(server: McpServer): void {\n const internal = server as unknown as {\n _registeredTools: RegisteredToolsRecord;\n };\n const tools = internal._registeredTools;\n if (!tools) return;\n for (const [toolName, tool] of Object.entries(tools)) {\n const original = tool.handler;\n tool.handler = async (...args: unknown[]): Promise<unknown> => {\n const start = Date.now();\n try {\n const result = await original(...args);\n const emitter = currentEmitter;\n if (emitter) {\n emitter\n .emitInvoke(toolName, 'success', Date.now() - start)\n .catch(() => {});\n }\n return result;\n } catch (err) {\n const emitter = currentEmitter;\n if (emitter) {\n emitter\n .emitInvoke(toolName, 'error', Date.now() - start)\n .catch(() => {});\n }\n throw err;\n }\n };\n }\n}\n\nexport function createWalkerOSMcpServer(opts: CreateServerOptions): McpServer {\n const packageVersion = opts.version ?? '0.0.0';\n const server = new McpServer(\n {\n name: 'walkeros-flow',\n version: packageVersion,\n },\n { instructions: SERVER_INSTRUCTIONS },\n );\n\n registerAuthTool(server, opts.client);\n registerProjectManageTool(server, opts.client);\n registerFlowManageTool(server, opts.client);\n registerDeployTool(server, opts.client);\n registerFeedbackTool(server, opts.client);\n\n registerFlowValidateTool(server);\n registerFlowBundleTool(server);\n registerFlowSimulateTool(server);\n registerFlowPushTool(server);\n registerFlowExamplesTool(server);\n registerFlowLoadTool(server);\n\n registerPackageSearchTool(server);\n registerGetPackageSchemaTool(server);\n\n registerPackageSchemaResources(server);\n registerReferenceResources(server);\n registerAddStepPrompt(server);\n registerSetupMappingPrompt(server);\n registerManageContractPrompt(server);\n\n wrapRegisteredToolsWithTelemetry(server);\n\n // MCP SDK fires `oninitialized` after the `initialized` notification, which\n // follows a successful `initialize` request. At that point `getClientVersion`\n // returns the negotiated client identity. We create the emitter here and\n // emit `mcp start`, so consent, debug, and endpoint resolution happen lazily\n // at the moment a real client connects.\n const priorOnInitialized = server.server.oninitialized;\n server.server.oninitialized = () => {\n try {\n priorOnInitialized?.();\n } catch {\n // existing handler must not prevent telemetry setup\n }\n const clientInfo = server.server.getClientVersion();\n void createMcpEmitter({\n clientInfo,\n packageVersion,\n })\n .then(async (emitter) => {\n currentEmitter = emitter;\n await emitter.emitStart();\n })\n .catch(() => {\n // telemetry must never break the server; swallow setup/emit errors.\n });\n };\n\n return server;\n}\n","import { validate } from '@walkeros/cli';\nimport type { ValidateResult } from '@walkeros/cli';\nimport { schemas } from '@walkeros/cli/dev';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { ValidateOutputShape } from '../schemas/output.js';\nimport { wrapUserData } from '../user-data.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\nfunction wrapIssueMessages(result: ValidateResult): ValidateResult {\n return {\n ...result,\n errors: result.errors.map((e) => ({\n ...e,\n message: wrapUserData(e.message),\n })),\n warnings: result.warnings.map((w) => ({\n ...w,\n message: wrapUserData(w.message),\n })),\n };\n}\n\nconst TITLE = 'Validate Flow';\nconst DESCRIPTION =\n 'Validate walkerOS events, flow configurations, mapping rules, or data contracts. ' +\n 'Accepts JSON strings, file paths, or URLs as input. ' +\n 'Returns validation results with errors, warnings, and details.';\n\nconst inputSchema = schemas.ValidateInputShape;\n\nconst annotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nexport function createFlowValidateToolSpec(): ToolSpec {\n return {\n name: 'flow_validate',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowValidateHandlerBody(input),\n };\n}\n\nasync function flowValidateHandlerBody(input: unknown) {\n const {\n type,\n input: validateInput,\n flow,\n path,\n } = (input ?? {}) as {\n type: 'contract' | 'event' | 'flow' | 'mapping';\n input: string;\n flow?: string;\n path?: string;\n };\n try {\n const result: ValidateResult = await validate(type, validateInput, {\n flow,\n path,\n });\n const hints = result.valid\n ? {\n next: [\n 'Use flow_simulate to test event flow',\n 'Use flow_bundle to build',\n ],\n }\n : {\n next: [\n 'Fix errors above, then run flow_validate again',\n 'Read walkeros://reference/flow-schema for correct structure',\n ],\n };\n return mcpResult(wrapIssueMessages(result), hints);\n } catch (error) {\n return mcpError(\n error,\n 'Check the input parameter — expected a JSON string, file path, or URL',\n );\n }\n}\n\nexport function registerFlowValidateTool(server: McpServer) {\n const spec = createFlowValidateToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema: ValidateOutputShape,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\n\n// CLI tool output shapes\nexport const ValidateOutputShape = {\n valid: z.boolean().describe('Whether validation passed'),\n type: z\n .union([\n z.enum(['contract', 'entry', 'event', 'flow', 'mapping']),\n z.string().regex(/^(destinations|sources|transformers)\\.\\w+$/),\n ])\n .describe('What was validated'),\n errors: z\n .array(\n z.object({\n path: z.string(),\n message: z.string(),\n value: z.unknown().optional(),\n code: z.string().optional(),\n }),\n )\n .describe('Validation errors'),\n warnings: z\n .array(\n z.object({\n path: z.string(),\n message: z.string(),\n suggestion: z.string().optional(),\n }),\n )\n .describe('Validation warnings'),\n details: z\n .record(z.string(), z.unknown())\n .describe('Additional validation details'),\n};\n\nexport const BundleOutputShape = {\n success: z.boolean().describe('Whether bundling succeeded'),\n totalSize: z.number().optional().describe('Total bundle size in bytes'),\n buildTime: z.number().optional().describe('Build time in milliseconds'),\n packages: z\n .array(\n z.object({\n name: z.string(),\n size: z.number(),\n }),\n )\n .optional()\n .describe('Per-package size breakdown'),\n treeshakingEffective: z\n .boolean()\n .optional()\n .describe('Whether tree-shaking was effective'),\n message: z.string().optional().describe('Status message'),\n};\n\nexport const SimulateOutputShape = {\n success: z.boolean().describe('Whether simulation succeeded'),\n error: z.string().optional().describe('Error message if failed'),\n summary: z.string().describe('One-line result summary'),\n destinations: z\n .record(\n z.string(),\n z.object({\n received: z\n .boolean()\n .describe('Whether destination received the event'),\n calls: z.number().describe('Number of API calls made'),\n payload: z\n .unknown()\n .optional()\n .describe('All intercepted API calls (only when verbose: true)'),\n }),\n )\n .optional()\n .describe('Per-destination results'),\n capturedEvents: z\n .array(z.record(z.string(), z.unknown()))\n .optional()\n .describe('Events captured by source simulation'),\n duration: z.number().optional().describe('Simulation duration in ms'),\n};\n\nexport const PushOutputShape = {\n success: z.boolean().describe('Whether push succeeded'),\n elbResult: z.unknown().optional().describe('Push result from the collector'),\n duration: z.number().describe('Push duration in milliseconds'),\n error: z.string().optional().describe('Error message if push failed'),\n};\n\n// Examples List output shape\nexport const ExamplesListOutputShape = {\n flow: z.string().describe('Flow name'),\n count: z.number().describe('Number of examples found'),\n examples: z\n .array(\n z.object({\n step: z.string().describe('Step location (e.g., \"destination.gtag\")'),\n stepType: z\n .enum(['source', 'transformer', 'destination'])\n .describe('Step type'),\n stepName: z.string().describe('Step name'),\n exampleName: z.string().describe('Example name'),\n title: z.string().optional().describe('Human-readable title if set'),\n description: z\n .string()\n .optional()\n .describe('Short human-readable description'),\n public: z\n .boolean()\n .optional()\n .describe(\n 'Whether the example is public (defaults to true if omitted)',\n ),\n hasIn: z.boolean().describe('Whether the example has an input value'),\n hasOut: z.boolean().describe('Whether the example has an output value'),\n hasMapping: z\n .boolean()\n .describe('Whether the example has a mapping configuration'),\n hasTrigger: z\n .boolean()\n .describe('Whether the example has trigger metadata'),\n in: z.unknown().optional().describe('Input event data'),\n out: z.unknown().optional().describe('Expected output data'),\n mapping: z\n .unknown()\n .optional()\n .describe('Mapping configuration for destinations'),\n trigger: z\n .object({\n type: z.string().optional(),\n options: z.unknown().optional(),\n })\n .optional()\n .describe('Trigger metadata for source simulation'),\n }),\n )\n .describe('Step examples'),\n};\n","/**\n * Wraps a user-writable string in `<user_data>…</user_data>` so the chat\n * assistant treats it as data, never as instructions. Inner `</user_data>`\n * sequences are mangled (`</user_data_>`) so a malicious string can't close\n * the envelope early.\n *\n * Idempotent: a string that is already a well-formed envelope with no inner\n * `</user_data>` is returned unchanged.\n */\nexport function wrapUserData(s: string): string {\n const alreadyWrapped =\n s.startsWith('<user_data>') &&\n s.endsWith('</user_data>') &&\n s.slice(11, -12).indexOf('</user_data>') === -1;\n if (alreadyWrapped) return s;\n const neutralised = s.replace(/<\\/user_data>/g, '</user_data_>');\n return `<user_data>${neutralised}</user_data>`;\n}\n\nexport interface RedactOptions {\n /** Return `true` to skip wrapping for a given object key. Only invoked for\n * string values on object entries — not for array elements or scalar\n * roots. Use to keep ids / slugs / dates literal. */\n skip?: (key: string) => boolean;\n}\n\n/**\n * Recursively walks `value` and returns a deep-copied structure where every\n * string leaf has been passed through `wrapUserData`. Pass `skip` to exclude\n * specific keys (e.g. `id`) from wrapping.\n */\nexport function redactNestedStrings<T>(value: T, opts?: RedactOptions): T {\n return walk(value, opts) as T;\n}\n\nfunction walk(value: unknown, opts?: RedactOptions): unknown {\n if (typeof value === 'string') return wrapUserData(value);\n if (Array.isArray(value)) return value.map((v) => walk(v, opts));\n if (value && typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n if (opts?.skip?.(k) && typeof v === 'string') {\n out[k] = v;\n } else {\n out[k] = walk(v, opts);\n }\n }\n return out;\n }\n return value;\n}\n","import { bundle } from '@walkeros/cli';\nimport { schemas } from '@walkeros/cli/dev';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { BundleOutputShape } from '../schemas/output.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\nconst TITLE = 'Bundle Flow';\nconst DESCRIPTION =\n 'Bundle a walkerOS flow configuration into deployable JavaScript. ' +\n 'Resolves all destinations, sources, and transformers, then outputs ' +\n 'a tree-shaken production bundle. Returns bundle statistics.';\n\nconst inputSchema = {\n ...schemas.BundleInputShape,\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createFlowBundleToolSpec(): ToolSpec {\n return {\n name: 'flow_bundle',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowBundleHandlerBody(input),\n };\n}\n\nasync function flowBundleHandlerBody(input: unknown) {\n const { configPath, flow, stats, output } = (input ?? {}) as {\n configPath: string;\n flow?: string;\n stats?: boolean;\n output?: string;\n };\n try {\n const result = await bundle(configPath, {\n flowName: flow,\n stats: stats ?? true,\n buildOverrides: output ? { output } : undefined,\n });\n\n if (!result) {\n return mcpResult(\n { success: false, message: 'Bundle produced no output' },\n {\n warnings: [\n 'The build returned no result. The flow may be empty or misconfigured.',\n ],\n next: ['Run flow_validate to check your configuration'],\n },\n );\n }\n\n const output_ = result as unknown as Record<string, unknown>;\n\n return mcpResult(\n { success: true, ...output_ },\n {\n next: [\n 'Use flow_simulate to test',\n 'Use deploy_manage with action \"deploy\" to publish',\n ],\n },\n );\n } catch (error) {\n return mcpError(error, 'Run flow_validate for detailed error messages');\n }\n}\n\nexport function registerFlowBundleTool(server: McpServer) {\n const spec = createFlowBundleToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema: BundleOutputShape,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport {\n simulateSource,\n simulateTransformer,\n simulateDestination,\n} from '@walkeros/cli';\nimport type { PushResult } from '@walkeros/cli';\nimport { schemas } from '@walkeros/cli/dev';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { SimulateOutputShape } from '../schemas/output.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\ninterface DestinationSummary {\n received: boolean;\n calls: number;\n payload?: unknown;\n}\n\nconst TITLE = 'Simulate Flow';\nconst DESCRIPTION =\n 'Simulate events through a walkerOS flow without making real API calls. ' +\n 'For destinations: event is a walkerOS event { name: \"entity action\", data: {...} }. ' +\n 'For sources: event is { content: ..., trigger?: { type?, options? }, env?: {...} }. ' +\n 'Use step to target a specific step. ' +\n 'Use flow_examples to discover available test data. ' +\n 'IMPORTANT: Destinations with require (e.g. require: [\"consent\"]) stay pending until ' +\n 'that collector event fires — simulation will error \"not found\" if require is not satisfied. ' +\n 'Remove require from config or provide consent/user events before simulating. ' +\n 'Separately, destinations with consent (e.g. consent: { marketing: true }) only receive ' +\n 'events where the event includes matching consent. ' +\n 'Mapping transforms event names and data at the destination level. ' +\n 'Policy redacts or injects fields before mapping runs.';\n\nconst inputSchema = {\n configPath: schemas.SimulateInputShape.configPath,\n event: z\n .union([z.record(z.string(), z.unknown()), z.string()])\n .optional()\n .describe(\n 'For destinations: { name, data, consent? }. Include consent (e.g. { marketing: true }) ' +\n 'to satisfy destination consent requirements. ' +\n 'For sources: { content, trigger?, env? }. ' +\n 'Can also be a JSON string or file path.',\n ),\n flow: schemas.SimulateInputShape.flow,\n platform: schemas.SimulateInputShape.platform,\n step: schemas.SimulateInputShape.step,\n verbose: z\n .boolean()\n .optional()\n .describe('Include full payload per destination (default: false)'),\n};\n\nconst annotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nexport function createFlowSimulateToolSpec(): ToolSpec {\n return {\n name: 'flow_simulate',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowSimulateHandlerBody(input),\n };\n}\n\nasync function flowSimulateHandlerBody(input: unknown) {\n const { configPath, event, flow, platform, step, verbose } = (input ??\n {}) as {\n configPath: string;\n event?: Record<string, unknown> | string;\n flow?: string;\n platform?: 'web' | 'server';\n step?: string;\n verbose?: boolean;\n };\n try {\n if (!event) {\n throw new Error(\n 'event is required. For sources provide { content, trigger? }, for destinations provide { name, data }.',\n );\n }\n\n if (!step) {\n throw new Error(\n 'step is required. Specify a target like \"source.browser\", \"destination.gtag\", or \"transformer.demo\".',\n );\n }\n\n // Resolve string event input (JSON string)\n let resolvedEvent: unknown = event;\n if (typeof event === 'string') {\n try {\n resolvedEvent = JSON.parse(event);\n } catch {\n throw new Error(\n 'Event string must be valid JSON. Got: ' + event.substring(0, 50),\n );\n }\n }\n\n // Parse step into type and id\n const dotIndex = step.indexOf('.');\n if (dotIndex === -1) {\n throw new Error(\n `Invalid step format \"${step}\". Use \"type.name\" (e.g. \"source.browser\", \"destination.gtag\").`,\n );\n }\n const stepType = step.substring(0, dotIndex);\n const stepId = step.substring(dotIndex + 1);\n\n let result: PushResult;\n\n switch (stepType) {\n case 'source':\n result = await simulateSource(configPath, resolvedEvent, {\n sourceId: stepId,\n flow,\n silent: true,\n });\n break;\n\n case 'transformer':\n result = await simulateTransformer(\n configPath,\n resolvedEvent as import('@walkeros/core').WalkerOS.DeepPartialEvent,\n {\n transformerId: stepId,\n flow,\n silent: true,\n },\n );\n break;\n\n case 'destination':\n result = await simulateDestination(\n configPath,\n resolvedEvent as import('@walkeros/core').WalkerOS.DeepPartialEvent,\n {\n destinationId: stepId,\n flow,\n silent: true,\n },\n );\n break;\n\n default:\n throw new Error(\n `Unknown step type \"${stepType}\". Use \"source\", \"transformer\", or \"destination\".`,\n );\n }\n\n // Source simulation returns captured events\n if (result.captured && result.captured.length > 0) {\n const eventCount = result.captured.length;\n const summary = `Source captured ${eventCount} event${eventCount !== 1 ? 's' : ''}`;\n\n return mcpResult(\n {\n success: result.success,\n error: result.error,\n summary,\n capturedEvents: result.captured,\n duration: result.duration,\n },\n {\n next:\n eventCount > 0\n ? [\n 'Use flow_simulate with a destination step to test downstream processing',\n ]\n : [\n 'Check source package examples with package_get, verify trigger type matches',\n ],\n },\n );\n }\n\n // Destination/transformer simulation\n const destinations: Record<string, DestinationSummary> = {};\n\n // Build destinations summary from elbResult.done\n if (\n result.elbResult &&\n typeof result.elbResult === 'object' &&\n 'done' in result.elbResult &&\n result.elbResult.done\n ) {\n const done = result.elbResult.done as Record<string, unknown>;\n for (const name of Object.keys(done)) {\n destinations[name] = { received: true, calls: 0 };\n }\n }\n\n // Also check usage (call tracking from mock envs)\n if (result.usage) {\n for (const [name, calls] of Object.entries(result.usage)) {\n const summary: DestinationSummary = {\n received: calls.length > 0,\n calls: calls.length,\n };\n if (verbose && calls.length > 0) {\n summary.payload = calls;\n }\n destinations[name] = summary;\n }\n }\n\n const destCount = Object.keys(destinations).length;\n const receivedCount = Object.values(destinations).filter(\n (d) => d.received,\n ).length;\n\n const warnings: string[] = [];\n if (stepType === 'destination' && destCount === 0) {\n warnings.push(\n 'Destination did not receive the event. Common causes: ' +\n '(1) destination config has consent: { marketing: true } but event lacks matching consent, ' +\n '(2) mapping rules do not match the event name, ' +\n '(3) policy redacted required fields. ' +\n 'Add consent to the event: { name: \"...\", data: {...}, consent: { marketing: true } }.',\n );\n }\n\n const summary =\n stepType === 'transformer'\n ? `Transformer processed event`\n : `${receivedCount}/${destCount} destinations received the event`;\n\n const resultObj = {\n success: result.success,\n error: result.error,\n summary,\n destinations: destCount > 0 ? destinations : undefined,\n duration: result.duration,\n };\n\n return mcpResult(resultObj, {\n next: ['Use flow_bundle to build for production'],\n ...(warnings.length > 0 ? { warnings } : {}),\n });\n } catch (error) {\n const msg = error instanceof Error ? error.message : '';\n let hint = 'Run flow_validate for detailed error messages';\n if (msg.includes('not found in collector')) {\n hint =\n 'If this destination has require: [\"consent\"] or require: [\"user\"], it stays ' +\n 'pending until that event fires. For simulation, either remove require from ' +\n 'the config or simulate with a flow that omits require on the target destination.';\n }\n return mcpError(error, hint);\n }\n}\n\nexport function registerFlowSimulateTool(server: McpServer) {\n const spec = createFlowSimulateToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema: SimulateOutputShape,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport { push } from '@walkeros/cli';\nimport type { PushResult } from '@walkeros/cli';\nimport { schemas } from '@walkeros/cli/dev';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { PushOutputShape } from '../schemas/output.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\nconst TITLE = 'Push Events';\nconst DESCRIPTION =\n 'Push a real event through a walkerOS flow to actual destinations. ' +\n 'Makes real API calls to real endpoints. ' +\n 'Best suited for server-side flows — web flows should use flow_simulate for testing.';\n\nconst inputSchema = {\n configPath: schemas.PushInputShape.configPath,\n event: z\n .record(z.string(), z.unknown())\n .describe(\n 'Event object, e.g. { name: \"page view\", data: { title: \"Home\" } }',\n ),\n flow: schemas.PushInputShape.flow,\n platform: schemas.PushInputShape.platform,\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createFlowPushToolSpec(): ToolSpec {\n return {\n name: 'flow_push',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowPushHandlerBody(input),\n };\n}\n\nasync function flowPushHandlerBody(input: unknown) {\n const { configPath, event, flow, platform } = (input ?? {}) as {\n configPath: string;\n event: Record<string, unknown>;\n flow?: string;\n platform?: 'web' | 'server';\n };\n try {\n const result: PushResult = await push(configPath, event, {\n json: true,\n flow,\n platform,\n });\n\n if (!result.success) {\n return mcpError(\n new Error(result.error || 'Push failed'),\n 'Check destination configuration and connectivity.',\n );\n }\n\n return mcpResult(result);\n } catch (error) {\n return mcpError(\n error,\n 'Check configPath and event format. For web flows, use flow_simulate.',\n );\n }\n}\n\nexport function registerFlowPushTool(server: McpServer) {\n const spec = createFlowPushToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema: PushOutputShape,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport { loadJsonConfig } from '@walkeros/cli';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport type { Flow } from '@walkeros/core';\nimport { ExamplesListOutputShape } from '../schemas/output.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\nconst TITLE = 'Flow Examples';\nconst DESCRIPTION =\n 'List all step examples in a walkerOS flow configuration. ' +\n 'Shows example names, step locations, and in/out shapes. ' +\n 'Use this to discover available test fixtures and simulation data.';\n\nconst inputSchema = {\n configPath: z\n .string()\n .min(1)\n .describe('Path to flow configuration file, URL, or inline JSON string'),\n flow: z.string().optional().describe('Flow name for multi-flow configs'),\n step: z\n .string()\n .optional()\n .describe('Filter to a specific step (e.g., \"destination.gtag\")'),\n full: z\n .boolean()\n .optional()\n .describe(\n 'Return full in/out/mapping data for each example (default: false, returns metadata only)',\n ),\n includeHidden: z\n .boolean()\n .optional()\n .describe(\n 'Include examples marked public: false (default: false). Set true for test/debug discovery.',\n ),\n};\n\nconst annotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nexport function createFlowExamplesToolSpec(): ToolSpec {\n return {\n name: 'flow_examples',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowExamplesHandlerBody(input),\n };\n}\n\nasync function flowExamplesHandlerBody(input: unknown) {\n const { configPath, flow, step, full, includeHidden } = (input ?? {}) as {\n configPath: string;\n flow?: string;\n step?: string;\n full?: boolean;\n includeHidden?: boolean;\n };\n try {\n const rawConfig = await loadJsonConfig<Flow.Json>(configPath);\n\n // Resolve flow name\n const flowNames = Object.keys(rawConfig.flows || {});\n const flowName =\n flow || (flowNames.length === 1 ? flowNames[0] : undefined);\n\n if (!flowName) {\n throw new Error(\n `Multiple flows found. Specify flow parameter. Available: ${flowNames.join(', ')}`,\n );\n }\n\n const flowSettings = rawConfig.flows[flowName];\n if (!flowSettings) {\n throw new Error(`Flow \"${flowName}\" not found`);\n }\n\n // Collect all examples\n const examples: Array<{\n step: string;\n stepType: string;\n stepName: string;\n exampleName: string;\n title?: string;\n description?: string;\n public?: boolean;\n hasIn: boolean;\n hasOut: boolean;\n hasMapping: boolean;\n hasTrigger: boolean;\n in?: unknown;\n out?: unknown;\n mapping?: unknown;\n trigger?: unknown;\n }> = [];\n\n const stepTypes = [\n { key: 'sources' as const, type: 'source' },\n { key: 'transformers' as const, type: 'transformer' },\n { key: 'destinations' as const, type: 'destination' },\n ];\n\n for (const { key, type } of stepTypes) {\n const refs = flowSettings[key] || {};\n for (const [name, ref] of Object.entries(refs)) {\n if (!ref.examples) continue;\n\n // Apply step filter\n if (step && `${type}.${name}` !== step) continue;\n\n for (const [exName, ex] of Object.entries(\n ref.examples as Flow.StepExamples,\n )) {\n if (!includeHidden && ex.public === false) continue;\n examples.push({\n step: `${type}.${name}`,\n stepType: type,\n stepName: name,\n exampleName: exName,\n title: ex.title,\n description: ex.description,\n public: ex.public,\n hasIn: ex.in !== undefined,\n hasOut: ex.out !== undefined,\n hasMapping: ex.mapping !== undefined,\n hasTrigger: ex.trigger !== undefined,\n ...(full\n ? {\n in: ex.in,\n out: ex.out,\n mapping: ex.mapping,\n trigger: ex.trigger,\n }\n : {}),\n });\n }\n }\n }\n\n const result = {\n flow: flowName,\n count: examples.length,\n examples,\n };\n\n const hints: { next: string[]; warnings?: string[] } = {\n next: ['Use flow_simulate with step and event to simulate'],\n };\n if (examples.length === 0) {\n hints.warnings = [\n 'No examples found. Add examples to step entries in your flow config for testing.',\n ];\n }\n return mcpResult(result, hints);\n } catch (error) {\n return mcpError(error, 'Check configPath — expected a flow.json file');\n }\n}\n\nexport function registerFlowExamplesTool(server: McpServer) {\n const spec = createFlowExamplesToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema: ExamplesListOutputShape,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { fetchPackage, mcpResult, mcpError } from '@walkeros/core';\nimport { mergeConfigSchema } from '@walkeros/core/dev';\nimport { fetchCatalog, normalizePlatform, CLIENT_HEADER } from '../catalog.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\n/**\n * Resolve the walkerOS app base URL for MCP outbound calls.\n *\n * Env-only by design: the MCP runs in an editor with explicit `.mcp.json`\n * env. No config-file precedence (which is what `@walkeros/cli`'s\n * `resolveAppUrl()` does for the `walkeros` CLI binary). Hard-cut:\n * `APP_URL` is no longer recognized.\n */\nexport function getPackageBaseUrl(): string | undefined {\n return process.env.WALKEROS_APP_URL || undefined;\n}\n\n// ---------- package_search ----------\n\nconst SEARCH_TITLE = 'Search Package';\nconst SEARCH_DESCRIPTION =\n 'Start here for package discovery. Never guess package names: use this tool first to find exact names. ' +\n 'Without package name: returns catalog filtered by type/platform. ' +\n 'With package name: returns metadata, hint keys, and example summaries.';\n\nconst searchInputSchema = {\n package: z\n .string()\n .min(1)\n .optional()\n .describe(\n 'Exact npm package name for detailed lookup (e.g., @walkeros/web-destination-snowplow)',\n ),\n type: z\n .enum(['source', 'destination', 'transformer', 'store'])\n .optional()\n .describe('Filter by package type (browse mode)'),\n platform: z\n .enum(['web', 'server'])\n .optional()\n .describe('Filter by platform (browse mode, includes universal packages)'),\n version: z\n .string()\n .optional()\n .describe('Package version for detailed lookup (default: latest)'),\n};\n\nconst searchAnnotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nexport function createPackageSearchToolSpec(): ToolSpec {\n return {\n name: 'package_search',\n title: SEARCH_TITLE,\n description: SEARCH_DESCRIPTION,\n inputSchema: searchInputSchema,\n annotations: searchAnnotations,\n handler: (input) => packageSearchHandlerBody(input),\n };\n}\n\nasync function packageSearchHandlerBody(input: unknown) {\n const {\n package: packageName,\n type,\n platform,\n version,\n } = (input ?? {}) as {\n package?: string;\n type?: 'source' | 'destination' | 'transformer' | 'store';\n platform?: 'web' | 'server';\n version?: string;\n };\n const baseUrl = getPackageBaseUrl();\n\n // Browse mode: no package specified → return catalog\n if (!packageName) {\n const catalog = await fetchCatalog({ type, platform, baseUrl });\n const result = { catalog, count: catalog.length };\n return mcpResult(result, {\n next: ['Use package_get for schemas and examples'],\n });\n }\n\n // Lookup mode: fetch specific package details\n try {\n const info = await fetchPackage(packageName, {\n version,\n baseUrl,\n client: CLIENT_HEADER,\n });\n\n const result = {\n package: info.packageName,\n version: info.version,\n description: info.description,\n type: info.type,\n platform: normalizePlatform(info.platform),\n hintKeys: info.hintKeys,\n exampleSummaries: info.exampleSummaries,\n };\n\n return mcpResult(result, {\n next: ['Use package_get for schemas and examples'],\n });\n } catch (error) {\n return mcpError(\n error,\n 'Package not found. Use package_search without parameters to browse available packages.',\n );\n }\n}\n\nexport function registerPackageSearchTool(server: McpServer) {\n const spec = createPackageSearchToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // No outputSchema: browse mode returns {catalog, count}, lookup returns metadata — incompatible shapes\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n\n// ---------- package_get ----------\n\nconst GET_TITLE = 'Get Package';\nconst GET_DESCRIPTION =\n 'Requires exact package name: do not guess names, use package_search first to find them. ' +\n 'Returns schemas + hint texts + example summaries by default (lightweight). ' +\n 'Use section parameter for full content: \"hints\" (with code blocks), \"examples\" (full in/out data), or \"all\".';\n\nconst getInputSchema = {\n package: z\n .string()\n .min(1)\n .describe(\n 'Exact npm package name (e.g., @walkeros/web-destination-snowplow)',\n ),\n version: z.string().optional().describe('Package version (default: latest)'),\n section: z\n .enum(['hints', 'examples', 'all'])\n .optional()\n .describe(\n 'Section to expand with full content. Default: summary view with schemas + hint texts + example descriptions',\n ),\n};\n\nconst getAnnotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: true,\n} as const;\n\nexport function createPackageGetToolSpec(): ToolSpec {\n return {\n name: 'package_get',\n title: GET_TITLE,\n description: GET_DESCRIPTION,\n inputSchema: getInputSchema,\n annotations: getAnnotations,\n handler: (input) => packageGetHandlerBody(input),\n };\n}\n\nasync function packageGetHandlerBody(input: unknown) {\n const {\n package: packageName,\n version,\n section,\n } = (input ?? {}) as {\n package: string;\n version?: string;\n section?: 'hints' | 'examples' | 'all';\n };\n const baseUrl = getPackageBaseUrl();\n\n try {\n const info = await fetchPackage(packageName, {\n version,\n baseUrl,\n client: CLIENT_HEADER,\n });\n\n // Build merged schemas: base config + package settings → schemas.config\n const mergedSchemas: Record<string, unknown> = {};\n\n if (info.type) {\n mergedSchemas.config = mergeConfigSchema(\n info.type as 'source' | 'destination' | 'transformer' | 'store',\n info.schemas as Record<string, Record<string, unknown>>,\n );\n }\n\n // Keep non-settings schemas as siblings (mapping, ga4, tagger, etc.)\n for (const [key, value] of Object.entries(info.schemas)) {\n if (key !== 'settings') {\n mergedSchemas[key] = value;\n }\n }\n\n const result: Record<string, unknown> = {\n package: info.packageName,\n version: info.version,\n type: info.type,\n platform: normalizePlatform(info.platform),\n schemas: mergedSchemas,\n };\n\n // Hints\n if (info.hints) {\n if (section === 'hints' || section === 'all') {\n result.hints = info.hints;\n } else {\n const hintSummary: Record<string, { text: string }> = {};\n for (const [key, hint] of Object.entries(info.hints)) {\n const h = hint as { text: string };\n hintSummary[key] = { text: h.text };\n }\n result.hints = hintSummary;\n }\n }\n\n // Examples\n if (section === 'examples' || section === 'all') {\n result.examples = info.examples;\n } else {\n result.exampleSummaries = info.exampleSummaries;\n }\n\n return mcpResult(result);\n } catch (error) {\n return mcpError(\n error,\n 'Use package_search to browse available package names.',\n );\n }\n}\n\nexport function registerGetPackageSchemaTool(server: McpServer) {\n const spec = createPackageGetToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // No outputSchema: removed to avoid SDK -32602 crashes on unexpected field values\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","// __VERSION__ is replaced at build time by tsup's `define` (see tsup.config.ts).\n// In tests, it's set on globalThis (see src/__tests__/support/version.ts).\ndeclare const __VERSION__: string;\n\nconst NPM_SEARCH_URL = 'https://registry.npmjs.org/-/v1/search';\nconst JSDELIVR_BASE = 'https://cdn.jsdelivr.net/npm';\nconst WALKEROS_JSON_PATH = 'dist/walkerOS.json';\nconst CACHE_TTL = 5 * 60 * 1000;\n\nexport const CLIENT_HEADER = 'walkeros-mcp/' + __VERSION__;\n\nexport interface CatalogEntry {\n name: string;\n version: string;\n description?: string;\n type: string;\n platform: string[];\n}\n\nlet cache: { entries: CatalogEntry[]; timestamp: number } | undefined;\n\nexport function clearCatalogCache() {\n cache = undefined;\n}\n\nexport function normalizePlatform(platform?: unknown): string[] {\n if (platform == null) return [];\n if (typeof platform === 'string') {\n return platform === 'universal' ? ['web', 'server'] : [platform];\n }\n if (Array.isArray(platform)) {\n return platform.filter((v): v is string => typeof v === 'string');\n }\n return [];\n}\n\nexport async function fetchCatalog(filters?: {\n type?: string;\n platform?: string;\n baseUrl?: string;\n}): Promise<CatalogEntry[]> {\n if (cache && Date.now() - cache.timestamp < CACHE_TTL) {\n return applyFilters(cache.entries, filters);\n }\n\n let entries: CatalogEntry[];\n try {\n entries = filters?.baseUrl\n ? await fetchCatalogFrom(filters.baseUrl, filters)\n : await fetchFromNpm();\n } catch {\n try {\n entries = await fetchFromNpm();\n } catch {\n return [];\n }\n }\n\n cache = { entries, timestamp: Date.now() };\n\n return applyFilters(entries, filters);\n}\n\nasync function fetchCatalogFrom(\n baseUrl: string,\n filters?: { type?: string; platform?: string },\n): Promise<CatalogEntry[]> {\n const params = new URLSearchParams();\n if (filters?.type) params.set('type', filters.type);\n if (filters?.platform) params.set('platform', filters.platform);\n\n const url = `${baseUrl}/api/packages${params.toString() ? `?${params}` : ''}`;\n const res = await fetch(url, {\n signal: AbortSignal.timeout(15000),\n headers: { 'X-Walkeros-Client': CLIENT_HEADER },\n });\n if (!res.ok) throw new Error(`Catalog fetch failed: ${res.status}`);\n\n const data = (await res.json()) as { catalog: CatalogEntry[] };\n return data.catalog;\n}\n\nasync function fetchFromNpm(): Promise<CatalogEntry[]> {\n const res = await fetch(`${NPM_SEARCH_URL}?text=@walkeros/&size=250`, {\n signal: AbortSignal.timeout(10000),\n headers: { 'X-Walkeros-Client': CLIENT_HEADER },\n });\n if (!res.ok) throw new Error(`npm search failed: ${res.status}`);\n\n const data = (await res.json()) as {\n objects: Array<{\n package: { name: string; version: string; description?: string };\n }>;\n };\n\n const metaResults = await Promise.allSettled(\n data.objects.map((obj) => enrichWithMeta(obj.package)),\n );\n\n return metaResults\n .filter(\n (r): r is PromiseFulfilledResult<CatalogEntry | undefined> =>\n r.status === 'fulfilled',\n )\n .map((r) => r.value)\n .filter((entry): entry is CatalogEntry => entry !== undefined);\n}\n\nasync function enrichWithMeta(pkg: {\n name: string;\n version: string;\n description?: string;\n}): Promise<CatalogEntry | undefined> {\n try {\n const res = await fetch(\n `${JSDELIVR_BASE}/${pkg.name}@${pkg.version}/${WALKEROS_JSON_PATH}`,\n {\n signal: AbortSignal.timeout(5000),\n headers: { 'X-Walkeros-Client': CLIENT_HEADER },\n },\n );\n if (!res.ok) return undefined;\n\n const json = (await res.json()) as { $meta?: Record<string, unknown> };\n const meta = json.$meta;\n if (!meta || typeof meta.type !== 'string') return undefined;\n\n return {\n name: pkg.name,\n version: pkg.version,\n description: pkg.description,\n type: meta.type,\n platform: normalizePlatform(meta.platform),\n };\n } catch {\n return undefined;\n }\n}\n\nfunction applyFilters(\n entries: CatalogEntry[],\n filters?: { type?: string; platform?: string },\n): CatalogEntry[] {\n let results = entries;\n if (filters?.type) {\n results = results.filter((e) => e.type === filters.type);\n }\n if (filters?.platform) {\n // Empty platform means platform-agnostic → matches any filter\n results = results.filter(\n (e) => e.platform.length === 0 || e.platform.includes(filters.platform!),\n );\n }\n return results;\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { loadJsonConfig } from '@walkeros/cli';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { redactNestedStrings } from '../user-data.js';\n\nimport type { ToolSpec } from '../tool-spec.js';\n\nconst KEEP_LITERAL = new Set([\n 'id',\n 'flowId',\n 'projectId',\n 'version',\n 'slug',\n 'createdAt',\n 'updatedAt',\n 'deletedAt',\n]);\nconst keepLiteral = (key: string) => KEEP_LITERAL.has(key);\n\nconst WEB_SKELETON = {\n version: 4,\n flows: {\n default: {\n config: { platform: 'web', bundle: { packages: {} } },\n sources: {},\n destinations: {},\n },\n },\n};\n\nconst SERVER_SKELETON = {\n version: 4,\n flows: {\n default: {\n config: { platform: 'server', bundle: { packages: {} } },\n sources: {},\n destinations: {},\n },\n },\n};\n\nconst TITLE = 'Load or Create Flow';\nconst DESCRIPTION =\n 'Load an existing flow configuration from a local file path, URL, or walkerOS API (by flow ID). ' +\n 'Or create a new empty flow by specifying a platform (web or server). ' +\n 'Use the add-step prompt to add sources, destinations, transformers, or stores to the flow.';\n\nconst inputSchema = {\n source: z\n .string()\n .optional()\n .describe(\n 'Flow source: local file path (./flow.json), URL (https://...), ' +\n 'inline JSON string, or API flow ID (cfg_...). Omit to create a new flow.',\n ),\n platform: z\n .enum(['web', 'server'])\n .optional()\n .describe(\n 'Platform for new flows. Required when source is omitted. ' +\n 'web = browser tracking, server = Node.js HTTP.',\n ),\n};\n\nconst outputSchema = {\n version: z.number().describe('Flow config version'),\n flows: z.record(z.string(), z.unknown()).describe('Flow entries'),\n};\n\nconst annotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: true,\n} as const;\n\nexport function createFlowLoadToolSpec(): ToolSpec {\n return {\n name: 'flow_load',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowLoadHandlerBody(input),\n };\n}\n\nasync function flowLoadHandlerBody(input: unknown) {\n const { source, platform } = (input ?? {}) as {\n source?: string;\n platform?: 'web' | 'server';\n };\n try {\n if (source) {\n const config = await loadJsonConfig(source);\n return mcpResult(redactNestedStrings(config, { skip: keepLiteral }), {\n next: ['Use flow_validate to check', 'Use add-step prompt to modify'],\n });\n }\n\n if (!platform) {\n return mcpError(\n new Error(\n 'Provide source (file path, URL, or flow ID) to load existing flow, ' +\n 'or platform (web/server) to create a new one.',\n ),\n );\n }\n\n const skeleton = platform === 'web' ? WEB_SKELETON : SERVER_SKELETON;\n return mcpResult(skeleton, {\n next: [\n 'Read walkeros://reference/flow-schema for config structure',\n 'Use add-step prompt to add sources and destinations',\n ],\n });\n } catch (error) {\n const msg = error instanceof Error ? error.message : '';\n if (msg.includes('not found') || msg.includes('ENOENT'))\n return mcpError(error, 'Check configPath — expected a flow.json file');\n return mcpError(error);\n }\n}\n\nexport function registerFlowLoadTool(server: McpServer) {\n const spec = createFlowLoadToolSpec();\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n // outputSchema is wire-only; not part of ToolSpec\n outputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\n\nimport type { ToolClient } from '../tool-client.js';\nimport type { ToolSpec } from '../tool-spec.js';\n\ndeclare const __VERSION__: string;\n\nconst TITLE = 'Send Feedback';\nconst DESCRIPTION = 'Send feedback about walkerOS';\n\nconst inputSchema = {\n text: z.string().describe('Your feedback text'),\n anonymous: z\n .boolean()\n .optional()\n .describe(\n 'Include user/project info? false = include, true = anonymous. Only needed on first call if not yet configured.',\n ),\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createFeedbackToolSpec(client: ToolClient): ToolSpec {\n return {\n name: 'feedback',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => feedbackHandlerBody(client, input),\n };\n}\n\nasync function feedbackHandlerBody(client: ToolClient, input: unknown) {\n const { text, anonymous: explicitAnonymous } = (input ?? {}) as {\n text: string;\n anonymous?: boolean;\n };\n try {\n let anonymous = client.getFeedbackPreference();\n\n if (anonymous === undefined && explicitAnonymous === undefined) {\n return mcpResult(\n { needsConsent: true },\n {\n next: [\n 'Ask the user if they want to include their info',\n 'Call feedback again with anonymous: true or false',\n ],\n },\n );\n }\n\n if (anonymous === undefined && explicitAnonymous !== undefined) {\n anonymous = explicitAnonymous;\n client.setFeedbackPreference(anonymous);\n }\n\n const isAnonymous = explicitAnonymous ?? anonymous ?? true;\n\n await client.submitFeedback(text, {\n anonymous: isAnonymous,\n version: __VERSION__,\n });\n\n return mcpResult({ ok: true });\n } catch (error) {\n return mcpError(error);\n }\n}\n\nexport function registerFeedbackTool(server: McpServer, client: ToolClient) {\n const spec = createFeedbackToolSpec(client);\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\n\nimport type { ToolClient } from '../tool-client.js';\nimport type { ToolSpec } from '../tool-spec.js';\n\nconst TITLE = 'Authentication';\nconst DESCRIPTION =\n 'Manage walkerOS authentication. Check login status, log in via device code flow, or log out. ' +\n 'No terminal or browser required, the MCP client handles the authorization URL.';\n\nconst inputSchema = {\n action: z\n .enum(['status', 'login', 'logout'])\n .describe('Authentication action to perform'),\n deviceCode: z\n .string()\n .optional()\n .describe(\n 'Device code from a previous pending login attempt. Provide to resume polling without requesting a new code.',\n ),\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createAuthToolSpec(client: ToolClient): ToolSpec {\n return {\n name: 'auth',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => authHandlerBody(client, input),\n };\n}\n\nasync function authHandlerBody(client: ToolClient, input: unknown) {\n const { action, deviceCode } = (input ?? {}) as {\n action?: 'status' | 'login' | 'logout';\n deviceCode?: string;\n };\n try {\n switch (action) {\n case 'status': {\n const resolved = client.resolveToken();\n if (!resolved) {\n return mcpResult(\n { authenticated: false },\n { next: ['Use auth with action \"login\" to authenticate'] },\n );\n }\n const user = await client.whoami();\n return mcpResult({\n authenticated: true,\n ...(user as Record<string, unknown>),\n });\n }\n\n case 'login': {\n if (deviceCode) {\n const pollResult = await client.pollForToken(deviceCode, {\n timeoutMs: 60000,\n });\n\n if (pollResult.success) {\n return mcpResult(\n { authenticated: true, email: pollResult.email },\n {\n next: [\n 'Use project_manage with action \"list\" to see your projects',\n ],\n },\n );\n }\n\n if (pollResult.status === 'pending') {\n return mcpResult({\n authenticated: false,\n status: 'pending',\n message: 'Still waiting for authorization. Try again shortly.',\n deviceCode,\n });\n }\n\n return mcpError(\n new Error(pollResult.error || 'Authorization failed'),\n );\n }\n\n const code = await client.requestDeviceCode();\n const loginUrl = code.verificationUriComplete || code.verificationUri;\n\n return mcpResult({\n authenticated: false,\n status: 'awaiting_authorization',\n loginUrl,\n message: `Open this link to authorize: ${loginUrl}`,\n deviceCode: code.deviceCode,\n });\n }\n\n case 'logout': {\n const deleted = client.deleteConfig();\n const hadEnvToken =\n typeof process.env.WALKEROS_TOKEN === 'string' &&\n process.env.WALKEROS_TOKEN.length > 0;\n delete process.env.WALKEROS_TOKEN;\n let message: string;\n if (deleted && hadEnvToken) {\n message =\n 'Logged out. Config removed and WALKEROS_TOKEN cleared from process environment.';\n } else if (deleted) {\n message = 'Logged out and config removed.';\n } else if (hadEnvToken) {\n message =\n 'No config found. WALKEROS_TOKEN cleared from process environment.';\n } else {\n message = 'No config found, already logged out.';\n }\n return mcpResult({\n loggedOut: true,\n message,\n });\n }\n\n default:\n throw new Error(\n `Unknown action: ${action}. Use one of: status, login, logout`,\n );\n }\n } catch (error) {\n return mcpError(error);\n }\n}\n\nexport function registerAuthTool(server: McpServer, client: ToolClient) {\n const spec = createAuthToolSpec(client);\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { isAuthError, AUTH_HINT } from '../types.js';\nimport { wrapUserData } from '../user-data.js';\n\nimport type { ToolClient } from '../tool-client.js';\nimport type { ToolSpec } from '../tool-spec.js';\n\nfunction wrapProjectName<T extends { name?: string }>(p: T): T {\n return p.name !== undefined ? { ...p, name: wrapUserData(p.name) } : p;\n}\n\nconst TITLE = 'Project Management';\nconst DESCRIPTION =\n 'Manage walkerOS projects. List, create, update, delete projects, or set a default project for CLI operations.';\n\nconst inputSchema = {\n action: z\n .enum(['list', 'get', 'create', 'update', 'delete', 'set_default'])\n .describe('Project management action to perform'),\n projectId: z\n .string()\n .optional()\n .describe(\n 'Project ID. Required for get, update, delete, and set_default actions.',\n ),\n name: z\n .string()\n .optional()\n .describe(\n 'Project name. Required for create. Optional for update (to rename).',\n ),\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createProjectManageToolSpec(client: ToolClient): ToolSpec {\n return {\n name: 'project_manage',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => projectManageHandlerBody(client, input),\n };\n}\n\nasync function projectManageHandlerBody(client: ToolClient, input: unknown) {\n const { action, projectId, name } = (input ?? {}) as {\n action?: 'list' | 'get' | 'create' | 'update' | 'delete' | 'set_default';\n projectId?: string;\n name?: string;\n };\n try {\n switch (action) {\n case 'list': {\n const projects = (await client.listProjects()) as\n | unknown[]\n | { projects?: unknown[] };\n const items = Array.isArray(projects)\n ? projects\n : projects?.projects || [];\n if (items.length === 0) {\n return mcpResult(\n { projects: [] },\n {\n next: [\n 'Use project_manage with action \"create\" to create your first project',\n 'Use project_manage with action \"set_default\" after creating to set it as default',\n ],\n },\n );\n }\n const typedItems = items as Array<{ name?: string }>;\n const safe = Array.isArray(projects)\n ? typedItems.map(wrapProjectName)\n : { ...projects, projects: typedItems.map(wrapProjectName) };\n return mcpResult(safe);\n }\n\n case 'get': {\n if (!projectId) {\n return mcpError(\n new Error(\n 'projectId is required for get action. Use action \"list\" to see available projects.',\n ),\n );\n }\n const project = await client.getProject({ projectId });\n return mcpResult(wrapProjectName(project as { name?: string }));\n }\n\n case 'create': {\n if (!name) {\n return mcpError(new Error('name is required for create action.'));\n }\n const created = await client.createProject({ name });\n return mcpResult(wrapProjectName(created as { name?: string }), {\n next: [\n 'Use project_manage with action \"set_default\" to make this your active project',\n ],\n });\n }\n\n case 'update': {\n if (!projectId) {\n return mcpError(\n new Error(\n 'projectId is required for update action. Use action \"list\" to see available projects.',\n ),\n );\n }\n if (!name) {\n return mcpError(new Error('name is required for update action.'));\n }\n const updated = await client.updateProject({ projectId, name });\n return mcpResult(wrapProjectName(updated as { name?: string }));\n }\n\n case 'delete': {\n if (!projectId) {\n return mcpError(\n new Error(\n 'projectId is required for delete action. Use action \"list\" to see available projects.',\n ),\n );\n }\n const deleted = await client.deleteProject({ projectId });\n return mcpResult(deleted);\n }\n\n case 'set_default': {\n if (!projectId) {\n return mcpError(\n new Error(\n 'projectId is required for set_default action. Use action \"list\" to see available projects.',\n ),\n );\n }\n client.setDefaultProject(projectId);\n return mcpResult(\n { defaultProjectId: projectId },\n {\n next: [\n 'Use flow_manage with action \"list\" to see flows in this project',\n ],\n },\n );\n }\n\n default:\n throw new Error(\n `Unknown action: ${action}. Use one of: list, get, create, update, delete, set_default`,\n );\n }\n } catch (error) {\n return mcpError(error, isAuthError(error) ? AUTH_HINT : undefined);\n }\n}\n\nexport function registerProjectManageTool(\n server: McpServer,\n client: ToolClient,\n) {\n const spec = createProjectManageToolSpec(client);\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","// Shared types for MCP management tools.\n// Keep this file dependency-light: only type-level imports from SDK/core.\n\n/**\n * Discriminated input shape for action-based MCP tools.\n * Example: ActionToolInput<'list', { projectId?: string }>\n */\nexport type ActionToolInput<A extends string, T = Record<string, never>> = {\n action: A;\n} & T;\n\n/**\n * Uniform handler return shape used by all mgmt tools.\n * Matches mcpResult / mcpError from @walkeros/core.\n */\nexport type ToolHandlerResult = {\n content: Array<{ type: 'text'; text: string }>;\n structuredContent: Record<string, unknown>;\n isError?: true;\n};\n\n/**\n * True when the error looks like an authentication/authorization failure\n * from the walkerOS cloud API. Used to decide whether to append the\n * \"Are you logged in?\" hint on caught errors.\n */\nexport function isAuthError(error: unknown): boolean {\n if (!(error instanceof Error)) return false;\n const msg = error.message.toLowerCase();\n if (\n msg.includes('unauthorized') ||\n msg.includes('forbidden') ||\n msg.includes('invalid token') ||\n msg.includes('token expired') ||\n msg.includes('not authenticated')\n ) {\n return true;\n }\n const code = (error as Error & { code?: string }).code;\n if (!code) return false;\n const upperCode = code.toUpperCase();\n return (\n upperCode === 'UNAUTHORIZED' ||\n upperCode === 'FORBIDDEN' ||\n upperCode === '401' ||\n upperCode === '403' ||\n upperCode.startsWith('AUTH_')\n );\n}\n\nexport const AUTH_HINT =\n 'Are you logged in? Use auth(action: \"status\") to check.';\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { isAuthError, AUTH_HINT } from '../types.js';\nimport { wrapUserData, redactNestedStrings } from '../user-data.js';\nimport { flowCanvasResult } from '../ui-parts.js';\n\n/** Peek at a Flow.Json root (v4) and decide whether the bubble should render\n * as web-flavoured or server-flavoured. The platform is recorded on\n * `flows[name].config.platform`. We pick the first flow's platform; if no\n * platform is set we fall back to `'server'` so the chat bubble can still\n * render even if the user is mid-edit. */\nfunction pickPlatform(content: unknown): 'web' | 'server' {\n if (content && typeof content === 'object') {\n const flows = (content as { flows?: unknown }).flows;\n if (flows && typeof flows === 'object') {\n for (const flow of Object.values(flows as Record<string, unknown>)) {\n if (flow && typeof flow === 'object') {\n const config = (flow as { config?: unknown }).config;\n if (config && typeof config === 'object') {\n const platform = (config as { platform?: unknown }).platform;\n if (platform === 'web' || platform === 'server') return platform;\n }\n }\n }\n }\n }\n return 'server';\n}\n\nimport type { ToolClient } from '../tool-client.js';\nimport type { ToolSpec } from '../tool-spec.js';\n\n// Keys whose string values must remain literal so the LLM can reference them\n// (ids, dates, immutable identifiers). Everything else that's a string goes\n// through wrapUserData.\nconst KEEP_LITERAL = new Set([\n 'id',\n 'flowId',\n 'projectId',\n 'previewId',\n 'version',\n 'slug',\n 'createdAt',\n 'updatedAt',\n 'deletedAt',\n]);\nconst keepLiteral = (key: string) => KEEP_LITERAL.has(key);\n\nfunction safeSummary<T extends { name?: string }>(flow: T): T {\n return flow.name !== undefined\n ? { ...flow, name: wrapUserData(flow.name) }\n : flow;\n}\n\nfunction safeDetail<T extends { name?: string; config?: unknown }>(flow: T): T {\n const withName =\n flow.name !== undefined\n ? { ...flow, name: wrapUserData(flow.name) }\n : { ...flow };\n if (flow.config !== undefined) {\n (withName as { config?: unknown }).config = redactNestedStrings(\n flow.config,\n { skip: keepLiteral },\n );\n }\n return withName as T;\n}\n\nconst TITLE = 'Flow Management';\nconst DESCRIPTION =\n 'Manage walkerOS flows and their previews. List/get/create/update/delete/duplicate flows, or create/inspect/delete preview bundles for testing flow changes on live sites.';\n\nconst inputSchema = {\n action: z\n .enum([\n 'list',\n 'get',\n 'create',\n 'update',\n 'delete',\n 'duplicate',\n 'preview_list',\n 'preview_get',\n 'preview_create',\n 'preview_delete',\n ])\n .describe('Flow management action to perform'),\n flowId: z\n .string()\n .optional()\n .describe(\n 'Flow ID (flow_...) or config ID (cfg_...). Required for get, update, delete, duplicate.',\n ),\n projectId: z\n .string()\n .optional()\n .describe(\n 'Project ID. Optional filter for list (omit to list all projects). Required for create if no default project set.',\n ),\n name: z\n .string()\n .optional()\n .describe(\n 'Flow name. Required for create. Optional for update (to rename) and duplicate.',\n ),\n content: z\n .record(z.string(), z.unknown())\n .optional()\n .describe('Flow.Json content. Used for create and update.'),\n patch: z\n .boolean()\n .optional()\n .describe(\n 'Merge-patch for update (default true). When true, only provided fields are updated.',\n ),\n fields: z\n .array(z.string())\n .optional()\n .describe('Dot-path selectors for get to return only specific fields.'),\n sort: z\n .enum(['name', 'updated_at', 'created_at'])\n .optional()\n .describe('Sort field for list.'),\n order: z.enum(['asc', 'desc']).optional().describe('Sort order for list.'),\n includeDeleted: z\n .boolean()\n .optional()\n .describe('Include soft-deleted flows in list results.'),\n previewId: z\n .string()\n .optional()\n .describe(\n 'Preview ID (prv_...). Required for preview_get and preview_delete.',\n ),\n flowName: z\n .string()\n .optional()\n .describe(\n 'Flow settings name. Used by preview_create as an alternative to flowSettingsId.',\n ),\n flowSettingsId: z\n .string()\n .optional()\n .describe(\n 'Flow settings ID. Used by preview_create as an alternative to flowName.',\n ),\n siteUrl: z\n .string()\n .optional()\n .describe(\n 'Optional site URL for preview_create. When provided, the response includes full activationUrl and deactivationUrl the user can click.',\n ),\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nexport function createFlowManageToolSpec(client: ToolClient): ToolSpec {\n return {\n name: 'flow_manage',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => flowManageHandlerBody(client, input),\n };\n}\n\nasync function flowManageHandlerBody(client: ToolClient, input: unknown) {\n const {\n action,\n flowId,\n projectId,\n name,\n content,\n patch,\n fields,\n sort,\n order,\n includeDeleted,\n previewId,\n flowName,\n flowSettingsId,\n siteUrl,\n } = (input ?? {}) as {\n action?:\n | 'list'\n | 'get'\n | 'create'\n | 'update'\n | 'delete'\n | 'duplicate'\n | 'preview_list'\n | 'preview_get'\n | 'preview_create'\n | 'preview_delete';\n flowId?: string;\n projectId?: string;\n name?: string;\n content?: Record<string, unknown>;\n patch?: boolean;\n fields?: string[];\n sort?: 'name' | 'updated_at' | 'created_at';\n order?: 'asc' | 'desc';\n includeDeleted?: boolean;\n previewId?: string;\n flowName?: string;\n flowSettingsId?: string;\n siteUrl?: string;\n };\n try {\n switch (action) {\n case 'list': {\n if (projectId) {\n const data = await client.listFlows({\n projectId,\n sort,\n order,\n includeDeleted,\n });\n const dataObj = data as { flows?: Array<{ name?: string }> };\n const flows = dataObj.flows;\n const safe = Array.isArray(flows)\n ? { ...dataObj, flows: flows.map(safeSummary) }\n : data;\n return mcpResult(safe);\n }\n const data = await client.listAllFlows({\n sort,\n order,\n includeDeleted,\n });\n const safe = Array.isArray(data)\n ? (data as Array<{ name?: string }>).map(safeSummary)\n : data;\n return mcpResult(\n { projects: safe },\n {\n next: [\n 'Use flow_manage with action \"get\" and a flowId to inspect a specific flow',\n 'Use flow_load to open a flow for editing',\n ],\n },\n );\n }\n\n case 'get': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for get action. Use action \"list\" to see available flows.',\n ),\n );\n }\n const flow = await client.getFlow({ flowId, projectId, fields });\n const safe = safeDetail(\n flow as {\n id?: string;\n name?: string;\n config?: Record<string, unknown>;\n },\n );\n return flowCanvasResult({\n flowId: safe.id,\n configName: safe.name ?? 'default',\n platform: pickPlatform(safe.config),\n flowConfig: (safe.config ?? {}) as Record<string, unknown>,\n suggestions: [\n {\n label: 'Validate this flow',\n prompt: `Validate flow ${safe.id}`,\n autoSend: true,\n },\n {\n label: 'Add a destination',\n prompt: `Help me add a destination to flow ${safe.id}`,\n },\n ],\n });\n }\n\n case 'create': {\n if (!name) {\n return mcpError(new Error('name is required for create action.'));\n }\n const created = await client.createFlow({\n name,\n content: content ?? {},\n projectId,\n });\n const safeCreated = safeDetail(\n created as {\n id?: string;\n name?: string;\n config?: Record<string, unknown>;\n },\n );\n return flowCanvasResult({\n flowId: safeCreated.id,\n configName: safeCreated.name ?? 'default',\n platform: pickPlatform(safeCreated.config),\n flowConfig: (safeCreated.config ?? {}) as Record<string, unknown>,\n suggestions: [\n {\n label: 'Validate this flow',\n prompt: `Validate flow ${safeCreated.id}`,\n autoSend: true,\n },\n {\n label: 'Deploy it',\n prompt: `Deploy flow ${safeCreated.id}`,\n },\n ],\n });\n }\n\n case 'update': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for update action. Use action \"list\" to see available flows.',\n ),\n );\n }\n const updated = await client.updateFlow({\n flowId,\n projectId,\n name,\n content,\n mergePatch: patch ?? true,\n });\n const safeUpdated = safeDetail(\n updated as {\n id?: string;\n name?: string;\n config?: Record<string, unknown>;\n },\n );\n return flowCanvasResult({\n flowId: safeUpdated.id,\n configName: safeUpdated.name ?? 'default',\n platform: pickPlatform(safeUpdated.config),\n flowConfig: (safeUpdated.config ?? {}) as Record<string, unknown>,\n suggestions: [\n {\n label: 'Validate this flow',\n prompt: `Validate flow ${safeUpdated.id}`,\n autoSend: true,\n },\n {\n label: 'Deploy it',\n prompt: `Deploy flow ${safeUpdated.id}`,\n },\n ],\n });\n }\n\n case 'delete': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for delete action. Use action \"list\" to see available flows.',\n ),\n );\n }\n const deleted = await client.deleteFlow({ flowId, projectId });\n return mcpResult(deleted);\n }\n\n case 'duplicate': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for duplicate action. Use action \"list\" to see available flows.',\n ),\n );\n }\n const duplicated = await client.duplicateFlow({\n flowId,\n name,\n projectId,\n });\n return mcpResult(\n safeDetail(duplicated as { name?: string; config?: unknown }),\n );\n }\n\n case 'preview_list': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for preview_list. Use action \"list\" to see available flows.',\n ),\n );\n }\n const data = await client.listPreviews({ projectId, flowId });\n return mcpResult(data);\n }\n\n case 'preview_get': {\n if (!flowId || !previewId) {\n return mcpError(\n new Error('flowId and previewId are required for preview_get.'),\n );\n }\n const data = await client.getPreview({\n projectId,\n flowId,\n previewId,\n });\n return mcpResult(data);\n }\n\n case 'preview_create': {\n if (!flowId) {\n return mcpError(new Error('flowId is required for preview_create.'));\n }\n if (!flowName && !flowSettingsId) {\n return mcpError(\n new Error(\n 'flowName or flowSettingsId is required for preview_create.',\n ),\n );\n }\n const preview = await client.createPreview({\n projectId,\n flowId,\n flowName,\n flowSettingsId,\n });\n const typedPreview = preview as {\n id: string;\n token: string;\n activationUrl: string;\n bundleUrl: string;\n createdBy: string;\n createdAt: string;\n [key: string]: unknown;\n };\n const enriched: Record<string, unknown> = {\n ...typedPreview,\n activationParam: typedPreview.activationUrl,\n };\n if (siteUrl) {\n const on = new URL(siteUrl);\n on.searchParams.set('elbPreview', typedPreview.token);\n enriched.activationUrl = on.toString();\n\n const off = new URL(siteUrl);\n off.searchParams.set('elbPreview', 'off');\n enriched.deactivationUrl = off.toString();\n } else {\n delete enriched.activationUrl;\n }\n return mcpResult(enriched, {\n next: siteUrl\n ? [\n 'Open activationUrl to activate preview mode; open deactivationUrl to exit.',\n ]\n : [\n 'Append activationParam to any URL on your site to activate preview mode.',\n ],\n });\n }\n\n case 'preview_delete': {\n if (!flowId || !previewId) {\n return mcpError(\n new Error('flowId and previewId are required for preview_delete.'),\n );\n }\n const data = await client.deletePreview({\n projectId,\n flowId,\n previewId,\n });\n return mcpResult(data);\n }\n\n default:\n throw new Error(\n `Unknown action: ${action}. Use one of: list, get, create, update, delete, duplicate, preview_list, preview_get, preview_create, preview_delete`,\n );\n }\n } catch (error) {\n return mcpError(error, isAuthError(error) ? AUTH_HINT : undefined);\n }\n}\n\nexport function registerFlowManageTool(server: McpServer, client: ToolClient) {\n const spec = createFlowManageToolSpec(client);\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","export type SuggestionTile = {\n label: string;\n description?: string;\n prompt: string;\n autoSend?: boolean;\n};\n\nexport interface FlowCanvasPayload {\n flowId?: string;\n configName: string;\n platform: 'web' | 'server';\n flowConfig: Record<string, unknown>;\n highlight?: { stepAddress: string; reason: string };\n suggestions?: SuggestionTile[];\n}\n\nexport interface FlowCanvasToolResult extends FlowCanvasPayload {\n kind: 'flow-canvas';\n}\n\n/**\n * Tool-result helper that marks a response as renderable as a FlowCanvas.\n * The chat UI inspects `structuredContent.kind === 'flow-canvas'` and mounts\n * a `FlowCanvasBubble` instead of the generic JSON fallback. The `content[0]`\n * text is the same JSON stringified — the LLM sees a self-describing object.\n */\nexport function flowCanvasResult(payload: FlowCanvasPayload) {\n const structured: FlowCanvasToolResult = { kind: 'flow-canvas', ...payload };\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(structured, null, 2),\n },\n ],\n structuredContent: structured as unknown as Record<string, unknown> & {\n kind: 'flow-canvas';\n },\n };\n}\n\nexport function isFlowCanvasResult(v: unknown): v is FlowCanvasToolResult {\n return (\n typeof v === 'object' &&\n v !== null &&\n (v as { kind?: unknown }).kind === 'flow-canvas'\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { mcpResult, mcpError } from '@walkeros/core';\nimport { isAuthError, AUTH_HINT } from '../types.js';\n\nimport type { ToolClient } from '../tool-client.js';\nimport type { ToolSpec } from '../tool-spec.js';\nimport {\n resolveDeploymentSlug,\n type DeploymentSummaryForResolver,\n type ListDeploymentsForResolver,\n} from './_resolvers.js';\n\nconst TITLE = 'Deploy Management';\nconst DESCRIPTION =\n 'Deploy walkerOS flows and manage deployments. ' +\n 'For get/delete actions pass flowId (required) plus optional slug to disambiguate when a flow has multiple active deployments. ' +\n \"If a flow has >=2 active deployments and no slug is supplied, the tool returns a MULTIPLE_DEPLOYMENTS error with a details[] list showing each deployment's slug, type, status, and updatedAt.\";\n\nconst inputSchema = {\n action: z\n .enum(['deploy', 'list', 'get', 'delete'])\n .describe('Deployment action to perform'),\n projectId: z\n .string()\n .optional()\n .describe('Project ID. Optional; falls back to the default project.'),\n flowId: z\n .string()\n .optional()\n .describe(\n 'Flow ID. Required for: deploy, get, delete. Optional filter for list.',\n ),\n slug: z\n .string()\n .optional()\n .describe(\n 'Deployment slug. Optional disambiguator for get/delete when the flow has multiple active deployments.',\n ),\n type: z\n .enum(['web', 'server'])\n .optional()\n .describe('Deployment type filter for list.'),\n status: z.string().optional().describe('Status filter for list.'),\n wait: z\n .boolean()\n .optional()\n .describe(\n 'Wait for deploy to complete (default true). Only used with deploy action.',\n ),\n flowName: z\n .string()\n .optional()\n .describe(\n 'Flow name for multi-settings flows. Only used with deploy action.',\n ),\n};\n\nconst annotations = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n} as const;\n\nfunction listForResolver(\n client: ToolClient,\n projectId: string | undefined,\n): ListDeploymentsForResolver {\n return async (q) => {\n const resp = (await client.listDeployments({\n projectId: projectId || q.projectId || undefined,\n flowId: q.flowId,\n })) as { deployments?: DeploymentSummaryForResolver[] };\n return resp.deployments ?? [];\n };\n}\n\nexport function createDeployManageToolSpec(client: ToolClient): ToolSpec {\n return {\n name: 'deploy_manage',\n title: TITLE,\n description: DESCRIPTION,\n inputSchema,\n annotations,\n handler: (input) => deployManageHandlerBody(client, input),\n };\n}\n\nasync function deployManageHandlerBody(client: ToolClient, input: unknown) {\n const { action, projectId, flowId, slug, type, status, wait, flowName } =\n (input ?? {}) as {\n action?: 'deploy' | 'list' | 'get' | 'delete';\n projectId?: string;\n flowId?: string;\n slug?: string;\n type?: 'web' | 'server';\n status?: string;\n wait?: boolean;\n flowName?: string;\n };\n try {\n switch (action) {\n case 'deploy': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for deploy action. Use flow_manage with action \"list\" to see available flows.',\n ),\n );\n }\n const result = await client.deploy({\n flowId,\n wait: wait ?? true,\n flowName,\n });\n return mcpResult(result, {\n next: [\n 'Use deploy_manage with action \"get\" to check deployment status',\n ],\n });\n }\n\n case 'list': {\n const data = await client.listDeployments({\n projectId,\n flowId,\n type,\n status,\n });\n return mcpResult(data);\n }\n\n case 'get': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for get action. Use flow_manage with action \"list\" to see available flows.',\n ),\n );\n }\n const resolvedSlug = await resolveDeploymentSlug({\n projectId: projectId ?? '',\n flowId,\n slug,\n list: listForResolver(client, projectId),\n });\n const data = await client.getDeploymentBySlug({\n slug: resolvedSlug,\n projectId,\n });\n return mcpResult(data);\n }\n\n case 'delete': {\n if (!flowId) {\n return mcpError(\n new Error(\n 'flowId is required for delete action. Use flow_manage with action \"list\" to see available flows.',\n ),\n );\n }\n const resolvedSlug = await resolveDeploymentSlug({\n projectId: projectId ?? '',\n flowId,\n slug,\n list: listForResolver(client, projectId),\n });\n const data = await client.deleteDeployment({\n slug: resolvedSlug,\n projectId,\n });\n return mcpResult({\n deleted: true,\n ...(data as Record<string, unknown>),\n });\n }\n\n default:\n throw new Error(\n `Unknown action: ${action}. Use one of: deploy, list, get, delete`,\n );\n }\n } catch (error) {\n return mcpError(error, isAuthError(error) ? AUTH_HINT : undefined);\n }\n}\n\nexport function registerDeployTool(server: McpServer, client: ToolClient) {\n const spec = createDeployManageToolSpec(client);\n server.registerTool(\n spec.name,\n {\n title: spec.title,\n description: spec.description,\n inputSchema: spec.inputSchema,\n annotations: spec.annotations,\n },\n // SDK infers handler type from inputSchema shape; ToolSpec.handler is the\n // type-erased (input: unknown) => Promise<unknown> form by design.\n spec.handler as Parameters<typeof server.registerTool>[2],\n );\n}\n","/**\n * Internal helpers shared by deploy_manage actions. Not re-exported from the\n * tools barrel; leading underscore marks this as tool-module internal.\n *\n * All collaborators are passed in as arguments so unit tests can inject fakes\n * without relying on jest.mock. This keeps resolver tests local to the\n * resolver signature and avoids shared-mock drift.\n */\n\n/**\n * The subset of a deployment summary the resolver needs to decide 0 / 1 / many\n * and to surface a useful MULTIPLE_DEPLOYMENTS error. Kept structurally\n * compatible with the CLI's DeploymentSummaryForFlow.\n */\nexport interface DeploymentSummaryForResolver {\n slug: string;\n type: string;\n status: string;\n updatedAt: string;\n}\n\n/**\n * Dependency injected list function. Must return only non-deleted deployments\n * for the given project + flow. The production wiring calls\n * `listDeployments({ projectId, flowId })` from `@walkeros/cli`, which hits\n * the app API; the API excludes soft-deleted rows.\n */\nexport type ListDeploymentsForResolver = (q: {\n projectId: string;\n flowId: string;\n}) => Promise<DeploymentSummaryForResolver[]>;\n\n/**\n * Error thrown when a flow has 0 matching deployments, or when a caller passed\n * a slug that does not match any active deployment of the flow. The MCP layer\n * translates this into an mcpError with `code: 'NOT_FOUND'`.\n */\nexport class DeploymentNotFoundError extends Error {\n readonly code = 'NOT_FOUND';\n constructor(message: string) {\n super(message);\n this.name = 'DeploymentNotFoundError';\n }\n}\n\n/**\n * Error thrown when a flow has >= 2 active deployments and the caller did not\n * pass a slug. Carries a `details[]` list so the MCP layer can surface the\n * options to the user.\n */\nexport class MultipleDeploymentsError extends Error {\n readonly code = 'MULTIPLE_DEPLOYMENTS';\n readonly details: DeploymentSummaryForResolver[];\n constructor(message: string, details: DeploymentSummaryForResolver[]) {\n super(message);\n this.name = 'MultipleDeploymentsError';\n this.details = details;\n }\n}\n\n/**\n * Resolve a concrete deployment slug for a (projectId, flowId, slug?) tuple.\n *\n * Behavior:\n * - 0 matches: throws DeploymentNotFoundError.\n * - 1 match, no slug: returns the single slug.\n * - slug provided and matches: returns the slug.\n * - slug provided and does not match: throws DeploymentNotFoundError.\n * - >= 2 matches, no slug: throws MultipleDeploymentsError with details[].\n */\nexport async function resolveDeploymentSlug(args: {\n projectId: string;\n flowId: string;\n slug?: string;\n list: ListDeploymentsForResolver;\n}): Promise<string> {\n const matches = await args.list({\n projectId: args.projectId,\n flowId: args.flowId,\n });\n\n if (matches.length === 0) {\n throw new DeploymentNotFoundError(\n `No deployments found for flow ${args.flowId}`,\n );\n }\n\n if (args.slug !== undefined) {\n const hit = matches.find((m) => m.slug === args.slug);\n if (!hit) {\n throw new DeploymentNotFoundError(\n `No deployment with slug ${args.slug} in flow ${args.flowId}`,\n );\n }\n return hit.slug;\n }\n\n if (matches.length === 1) {\n return matches[0].slug;\n }\n\n throw new MultipleDeploymentsError(\n `Flow ${args.flowId} has ${matches.length} active deployments; pass slug to disambiguate`,\n matches.map((m) => ({\n slug: m.slug,\n type: m.type,\n status: m.status,\n updatedAt: m.updatedAt,\n })),\n );\n}\n","import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { fetchPackageSchema } from '@walkeros/core';\nimport { fetchCatalog } from '../catalog.js';\n\nexport function registerPackageSchemaResources(server: McpServer) {\n const template = new ResourceTemplate('walkeros://schema/{packageName}', {\n list: async () => {\n const catalog = await fetchCatalog();\n return {\n resources: catalog.map((pkg) => ({\n uri: `walkeros://schema/${encodeURIComponent(pkg.name)}`,\n name: pkg.name,\n description: `Schema and examples for ${pkg.name}`,\n mimeType: 'application/json' as const,\n })),\n };\n },\n });\n\n server.registerResource(\n 'package-schema',\n template,\n {\n title: 'walkerOS Package Schema',\n description:\n 'JSON Schema and configuration examples for walkerOS packages',\n mimeType: 'application/json',\n },\n async (uri, { packageName }) => {\n const info = await fetchPackageSchema(\n decodeURIComponent(packageName as string),\n );\n return {\n contents: [\n {\n uri: uri.toString(),\n mimeType: 'application/json' as const,\n text: JSON.stringify(info, null, 2),\n },\n ],\n };\n },\n );\n}\n","/**\n * Reference resources — pure schema and structural data only.\n *\n * Design principle: resources are loaded into context and should contain\n * only schemas, type definitions, and structural references. Behavioral\n * guidance, tutorials, and step-by-step instructions belong in prompts.\n * Vendor-specific examples belong in packages (fetched via package_get).\n */\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { schemas } from '@walkeros/core/dev';\nimport { fetchCatalog } from '../catalog.js';\n\nexport function registerReferenceResources(server: McpServer) {\n // Flow Schema reference (generated from Zod)\n server.resource(\n 'flow-schema',\n 'walkeros://reference/flow-schema',\n {\n description:\n 'JSON Schema for Flow.Json — the complete flow configuration structure',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/flow-schema',\n text: JSON.stringify(schemas.configJsonSchema, null, 2),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Event Model reference (generated from Zod)\n server.resource(\n 'event-model',\n 'walkeros://reference/event-model',\n {\n description:\n 'JSON Schema for walkerOS events: entity-action naming, data, context, globals, user, consent',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/event-model',\n text: JSON.stringify(schemas.eventJsonSchema, null, 2),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Mapping reference (generated from Zod — composite of related schemas)\n server.resource(\n 'mapping',\n 'walkeros://reference/mapping',\n {\n description:\n 'JSON Schemas for walkerOS mapping: rules, valueConfig, rule, policy',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/mapping',\n text: JSON.stringify(\n {\n rules: schemas.rulesJsonSchema,\n valueConfig: schemas.valueConfigJsonSchema,\n rule: schemas.ruleJsonSchema,\n policy: schemas.policyJsonSchema,\n },\n null,\n 2,\n ),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Consent reference (generated from Zod)\n server.resource(\n 'consent',\n 'walkeros://reference/consent',\n {\n description:\n 'JSON Schema for walkerOS consent: destination-level, rule-level, and field-level consent gating',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/consent',\n text: JSON.stringify(schemas.consentJsonSchema, null, 2),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Variables reference (hand-maintained — runtime interpolation patterns not captured in Zod schemas)\n server.resource(\n 'variables',\n 'walkeros://reference/variables',\n {\n description:\n 'walkerOS variable patterns: $var, $env, $contract, $code, $store, $secret substitution',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/variables',\n text: JSON.stringify(\n {\n separatorRule:\n '`.` for names and paths; `:` for literal values or raw-code payloads.',\n patterns: {\n '$var.name':\n 'Variable reference. Whole-string preserves native type (object, array, scalar). Inline interpolation requires a scalar. Reusable fragments (mapping templates, matcher lists, consent objects) live in the variables block and are referenced by name.',\n '$var.name.deep.path':\n 'Deep-path access into a structured variable. Walks nested keys/indices. Whole-string preserves type at the leaf; inline still requires a scalar leaf.',\n '$env.NAME':\n 'Environment variable. $env.GA_ID reads process.env.GA_ID.',\n '$env.NAME:default':\n 'Environment variable with fallback. $env.GA_ID:G-DEFAULT (the `:` is the literal default separator).',\n '$contract.name':\n 'Contract reference. Links to a named contract for validation.',\n '$contract.name.path':\n 'Nested contract access. $contract.ecommerce.product.',\n '$code:(expr)':\n 'Inline JavaScript. $code:(event) => event.data.price * 100 (the `:` carries the raw-code payload).',\n '$store.storeId':\n 'Store injection in env values. Wires runtime store access.',\n '$secret.NAME':\n 'Secret injection. Resolved server-side at deploy/runtime.',\n },\n cascade: {\n priority: [\n '1. Step-level variables (highest)',\n '2. Flow-level variables',\n '3. Config-level variables (lowest)',\n ],\n example: {\n variables: {\n apiUrl: 'https://x.io',\n mapping: { id: 'data.id' },\n },\n flows: {\n production: {\n destinations: {\n api: {\n config: {\n url: '$var.apiUrl',\n idPath: '$var.mapping.id',\n },\n },\n },\n },\n },\n },\n },\n },\n null,\n 2,\n ),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Contract reference (generated from Zod)\n server.resource(\n 'contract',\n 'walkeros://reference/contract',\n {\n description:\n 'JSON Schema for walkerOS contracts: event schema validation with entity-action keying',\n mimeType: 'application/json',\n },\n async () => ({\n contents: [\n {\n uri: 'walkeros://reference/contract',\n text: JSON.stringify(schemas.contractJsonSchema, null, 2),\n mimeType: 'application/json',\n },\n ],\n }),\n );\n\n // Examples reference (loaded from @walkeros/cli at runtime)\n server.resource(\n 'examples',\n 'walkeros://reference/examples',\n {\n description:\n 'Complete flow config example: web + server flows, mapping, contracts, step examples',\n mimeType: 'application/json',\n },\n async () => {\n let example: string;\n try {\n const { readFileSync } = await import('fs');\n const { createRequire } = await import('module');\n const require = createRequire(import.meta.url);\n const examplePath =\n require.resolve('@walkeros/cli/examples/flow-complete.json');\n example = readFileSync(examplePath, 'utf-8');\n } catch {\n example = JSON.stringify({ error: 'Example not found' });\n }\n return {\n contents: [\n {\n uri: 'walkeros://reference/examples',\n text: example,\n mimeType: 'application/json',\n },\n ],\n };\n },\n );\n\n // OpenAPI 3.1 specification for the walkerOS cloud HTTP API\n server.resource(\n 'openapi',\n 'walkeros://reference/openapi',\n {\n description: 'walkerOS cloud API — OpenAPI 3.1 specification',\n mimeType: 'application/json',\n },\n async () => {\n let openApiSpec: string;\n try {\n const { readFileSync } = await import('fs');\n const { createRequire } = await import('module');\n const require = createRequire(import.meta.url);\n const specPath = require.resolve('@walkeros/cli/openapi/spec.json');\n openApiSpec = readFileSync(specPath, 'utf-8');\n } catch {\n openApiSpec = JSON.stringify({ error: 'OpenAPI spec not found' });\n }\n return {\n contents: [\n {\n uri: 'walkeros://reference/openapi',\n text: openApiSpec,\n mimeType: 'application/json',\n },\n ],\n };\n },\n );\n\n // Packages catalog resource\n server.resource(\n 'packages',\n 'walkeros://reference/packages',\n {\n description:\n 'Complete walkerOS package catalog — all sources, destinations, transformers, and stores',\n mimeType: 'application/json',\n },\n async () => {\n const catalog = await fetchCatalog();\n return {\n contents: [\n {\n uri: 'walkeros://reference/packages',\n text: JSON.stringify(catalog, null, 2),\n mimeType: 'application/json',\n },\n ],\n };\n },\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerAddStepPrompt(server: McpServer) {\n server.registerPrompt(\n 'add-step',\n {\n description:\n 'Add a source, destination, transformer, or store step to a flow configuration. ' +\n 'Guides through package selection, config scaffolding, and wiring.',\n argsSchema: {\n stepType: z\n .string()\n .optional()\n .describe(\n 'Type of step to add: source, destination, transformer, or store',\n ),\n flowPath: z\n .string()\n .optional()\n .describe('Path to the flow.json file to modify'),\n },\n },\n async ({ stepType, flowPath }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Help me add a ${stepType || 'new'} step to my flow${flowPath ? ` at ${flowPath}` : ''}.`,\n '',\n 'Follow these steps:',\n `1. ${stepType ? '' : 'Ask what type of step (source, destination, transformer, store). Then '}Use package_search to browse available packages for the selected type and platform.`,\n '2. Use package_get to read the package\\'s config schema (schemas.config contains the full config shape: base fields like consent/require/logger + package-specific settings). Use section=\"hints\" for additional guidance.',\n '3. Use package_get with section=\"examples\" to see working configuration examples.',\n '4. Scaffold the step config using the package schemas — include required settings with placeholder values.',\n '5. Wire the step into the flow: add to packages section (with version if needed), connect via next/before chains if needed.',\n '6. For destinations: configure mapping using nested entity → action keys. Event \"product add\" maps to `{ \"product\": { \"add\": { name: \"AddToCart\" } } }`. Use the setup-mapping prompt for guidance.',\n '7. For destinations: if consent-gated loading is needed, add require: [\"consent\"] to config. ' +\n 'Note: require delays initialization until a \"walker consent\" event fires. ' +\n 'When simulating with flow_simulate, destinations with require will error \"not found\" — ' +\n 'remove require temporarily or test without it. ' +\n 'For per-event consent filtering, add consent: { marketing: true } to config.',\n '8. Use flow_validate to verify the result.',\n '9. For server sources: check if the package supports `ingest` configuration via package_get. Ingest extracts request metadata (IP, user-agent, headers) using mapping syntax. Transformers like fingerprint depend on ingest data.',\n '10. When adding a transformer that uses ingest fields, verify the source has `ingest` configured — otherwise ingest fields resolve to empty values.',\n '',\n 'Important:',\n '- Read the walkeros://reference/flow-schema resource to understand connection rules.',\n '- Sources connect to pre-collector transformers via `next`.',\n '- Destinations connect to post-collector transformers via `before`.',\n '- Stores are passive — referenced via `$store.storeName` in env values.',\n '- Use variables ($var) for values that change between environments.',\n '- For required settings without defaults in the package schema, ask the user which value to use. Do not guess credentials, IDs, or environment-specific values.',\n '- If $meta.exports lists named exports, set the `code` field on the step to the chosen export name. If only one export exists, use it automatically.',\n ].join('\\n'),\n },\n },\n ],\n }),\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerSetupMappingPrompt(server: McpServer) {\n server.registerPrompt(\n 'setup-mapping',\n {\n description:\n 'Set up event mapping for any step in a flow. Teaches mapping syntax and uses package examples as templates.',\n argsSchema: {\n stepName: z\n .string()\n .optional()\n .describe('Step name in the flow (e.g., \"gtag\", \"meta\", \"express\")'),\n },\n },\n async ({ stepName }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Help me set up mapping${stepName ? ` for the \"${stepName}\" step` : ''}.`,\n '',\n 'Follow these steps:',\n '1. Read the walkeros://reference/mapping resource for syntax reference.',\n `2. ${stepName ? `Identify the package for \"${stepName}\" in the flow, then u` : 'U'}se package_get with section=\"examples\" to see the source output shape — mapping keys must match the actual events the source emits.`,\n '3. Ask whether this is source mapping (raw input → walkerOS events) or destination mapping (walkerOS events → vendor format).',\n '4. Ask which events to map (one at a time, not all at once).',\n '5. Generate one mapping rule using the package examples as templates. Validate it with flow_validate before moving to the next.',\n '6. Repeat for each event.',\n '',\n 'Mapping uses nested entity → action keys. Event \"product add\" maps to `{ \"product\": { \"add\": Rule } }`. Wildcards: `{ \"*\": { \"view\": Rule } }`.',\n '',\n 'Extract shared mapping shapes into variables, reference via $var.name (deep paths supported).',\n '',\n 'Policy and consent in mapping:',\n '- config.policy runs BEFORE mapping rules — use it to inject or redact fields on the event.',\n '- rule.policy runs after config.policy but before data transformation — use for event-specific pre-processing.',\n '- config.consent gates ALL events to this destination. rule.consent gates specific event types.',\n '- Individual value configs support consent: { marketing: true } for field-level gating.',\n ].join('\\n'),\n },\n },\n ],\n }),\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerManageContractPrompt(server: McpServer) {\n server.registerPrompt(\n 'manage-contract',\n {\n description:\n 'Create or update event contracts for a flow. Can generate contracts from existing mappings or scaffold mappings from contracts.',\n argsSchema: {\n direction: z\n .string()\n .optional()\n .describe(\n 'Direction: \"from-mappings\" (extract contract from existing mappings), ' +\n '\"from-scratch\" (create new contract), or \"to-mappings\" (scaffold mappings from contract)',\n ),\n },\n },\n async ({ direction }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Help me ${direction === 'to-mappings' ? 'scaffold mappings from a contract' : direction === 'from-mappings' ? 'generate a contract from existing mappings' : 'manage event contracts'}.`,\n '',\n 'Follow these steps:',\n '1. Read the walkeros://reference/contract resource to understand contract structure.',\n direction === 'from-mappings'\n ? '2. Read all destination mappings in the flow, extract referenced event fields, and generate a contract with those as required properties.'\n : direction === 'to-mappings'\n ? '2. Read the contract from the flow, then scaffold mapping stubs for each destination based on the contract fields.'\n : '2. Ask for entity-action names and required properties, or ask whether to generate from existing mappings.',\n '3. Use entity-action keying with wildcards (*.*, *.action, entity.*) for broad rules.',\n '4. Define JSON Schema for events, globals, context, custom, user, and consent.',\n '5. Use flow_validate to verify the contract.',\n '',\n 'Contracts and mappings are bidirectional:',\n '- **Contract → Mappings**: contract defines what events look like, mappings are scaffolded to match.',\n '- **Mappings → Contract**: existing mappings reveal which fields are used, contract formalizes them.',\n '',\n 'For server flows: if the contract references fields populated by ingest (e.g., user fingerprint hash), verify the source config.ingest extracts the needed request metadata.',\n '',\n 'Use $contract.name references to link contracts in the flow.',\n 'Contracts support extends for inheritance between event types.',\n ].join('\\n'),\n },\n },\n ],\n }),\n );\n}\n","export const SERVER_INSTRUCTIONS = `walkerOS is an open-source, privacy-first event data collection platform. Define event pipelines as code using JSON flow configurations.\n\n## Rules\n\n- **Never guess package names.** Always use \\`package_search\\` first to find exact names, then \\`package_get\\` for details.\n- **Never construct flow configs from memory.** Read \\`walkeros://reference/flow-schema\\` and use \\`package_get\\` for package-specific schemas.\n- **Always validate.** Run \\`flow_validate\\` after every config change. If validation fails, fix and re-validate.\n- **Simulate before deploying.** Use \\`flow_simulate\\` to test with mocked API calls before \\`flow_bundle\\` or \\`flow_push\\`.\n\n## Workflow\n\n1. \\`auth({ action: \"status\" })\\` — check if logged in, or \\`auth({ action: \"login\" })\\` to connect\n2. \\`project_manage({ action: \"list\" })\\` — see your projects\n3. \\`flow_manage({ action: \"list\" })\\` — see all flows across projects\n4. \\`flow_load({ platform: \"web\" })\\` or \\`flow_load({ source: \"./flow.json\" })\\` — create or load\n5. \\`package_search({ type: \"destination\", platform: \"web\" })\\` — discover packages\n6. \\`package_get({ package: \"...\" })\\` — read schemas, hints, examples\n7. Use the \\`add-step\\` prompt — guided step addition\n8. Use the \\`setup-mapping\\` prompt — event transformation config\n9. \\`flow_validate({ type: \"flow\", input: \"flow.json\" })\\` — verify\n10. \\`flow_simulate({ configPath: \"flow.json\", event: \"...\" })\\` — test\n11. \\`flow_manage({ action: \"update\", flowId: \"...\", content: {...} })\\` — save to cloud\n12. \\`deploy_manage({ action: \"deploy\", flowId: \"...\" })\\` — deploy\n\n## Architecture: Source → Collector → Destination(s)\n\nEvery component in a flow is a **step**: sources capture events, transformers process them, destinations deliver them, stores provide shared state. Steps connect via \\`next\\` (pre-collector) and \\`before\\` (post-collector) chains.\n\n## Flow Config Structure\n\n\\`\\`\\`json\n{\n \"version\": 4,\n \"flows\": {\n \"default\": {\n \"config\": { \"platform\": \"web\" },\n \"sources\": { \"<name>\": { \"package\": \"<npm-package>\", \"config\": {} } },\n \"destinations\": { \"<name>\": { \"package\": \"<npm-package>\", \"config\": { \"settings\": {} } } }\n }\n }\n}\n\\`\\`\\`\n\n- \\`version: 4\\` is required\n- Each flow declares its target via \\`config.platform\\` (\\`\"web\"\\` or \\`\"server\"\\`)\n- Destination settings go inside \\`config.settings\\`, not directly on the destination\n- Event format: \\`{ name: \"entity action\", data: {...}, entity: \"...\", action: \"...\" }\\`\n\n## Key Concepts\n\n- **Mapping** transforms events using data/map/loop/set/condition rules. Same syntax on sources and destinations. Mapping rules use NESTED entity → action keying: event name \"product add\" maps to \\`{ \"product\": { \"add\": Rule } }\\`. Wildcards: \\`{ \"*\": { \"view\": Rule } }\\`.\n- **Contracts** define event schemas using entity-action keying. Can generate FROM mappings or scaffold mappings FROM contracts.\n- **Variables** (\\$var, \\$env, \\$code, \\$store) enable DRY, environment-aware config. Whole-string \\`$var.name\\` references preserve native type (object/array/scalar); inline interpolation requires a scalar. Deep paths via \\`$var.name.deep.path\\`.\n- **Consent** gates destinations, mapping rules, and individual fields. Privacy-first by design.\n\n## Simulation Tips\n\n- Destinations with \\`require: [\"consent\"]\\` stay **pending** until a \\`\"walker consent\"\\` event fires. Simulation will error \"not found\" for pending destinations, remove \\`require\\` from config when testing with \\`flow_simulate\\`.\n- Destinations with \\`consent: { marketing: true }\\` silently skip events that lack matching consent. Include \\`consent\\` in the event: \\`{ name: \"page view\", data: {...}, consent: { marketing: true } }\\`.\n- **Mapping** transforms event names and data at the destination level. Events without a matching mapping rule pass through unmodified.\n- **Policy** modifies the event before mapping runs, use it to inject computed fields or redact sensitive data.\n\n## Reference Resources\n\nRead these before constructing configs manually: \\`walkeros://reference/flow-schema\\`, \\`walkeros://reference/mapping\\`, \\`walkeros://reference/event-model\\`, \\`walkeros://reference/consent\\`, \\`walkeros://reference/variables\\`, \\`walkeros://reference/contract\\`, \\`walkeros://reference/examples\\`.`;\n","import { randomUUID } from 'crypto';\nimport { telemetry } from '@walkeros/cli';\n\n/**\n * Options for the MCP telemetry emitter wrapper.\n *\n * `clientInfo` mirrors the MCP SDK shape negotiated during initialize.\n * When the client doesn't send one, we record the client name as \"unknown\"\n * inside the per-event data so downstream analytics can still bucket the\n * event. The walkerOS source identifier is the package itself (`mcp`), not\n * the client.\n */\nexport interface McpEmitterOptions {\n clientInfo?: { name: string; version: string };\n packageVersion: string;\n}\n\n/**\n * MCP-specific event emitter.\n *\n * Wraps `@walkeros/cli`'s `telemetry.createEmitter` with:\n * - `source.type` fixed to `\"mcp\"`\n * - `source.platform` fixed to `\"server\"`\n * - per-emission `source.tool` for `cmd invoke` events\n * - a fresh session UUID per MCP server instance\n *\n * Surfaces the narrow set of events the MCP server needs to emit.\n */\nexport interface McpEmitter {\n emitStart(): Promise<void>;\n emitInvoke(\n tool: string,\n outcome: 'success' | 'error',\n timingMs: number,\n ): Promise<void>;\n emitError(kind: 'uncaught' | 'unhandledRejection' | 'startup'): Promise<void>;\n}\n\n/**\n * Build an MCP telemetry emitter.\n *\n * All consent, debug, and endpoint resolution is delegated to the CLI's\n * underlying `telemetry.createEmitter`. This wrapper only provides\n * MCP-specific field mapping and event shorthands.\n */\nexport async function createMcpEmitter(\n opts: McpEmitterOptions,\n): Promise<McpEmitter> {\n const clientName = opts.clientInfo?.name || 'unknown';\n const session = randomUUID();\n\n const emitter = await telemetry.createEmitter({\n source: {\n type: 'mcp',\n platform: 'server',\n },\n packageVersion: opts.packageVersion,\n session,\n });\n\n return {\n async emitStart() {\n const ci = telemetry.getCiInfo();\n await emitter.send('mcp start', {\n ...ci,\n client: clientName,\n });\n },\n async emitInvoke(tool, outcome, timingMs) {\n await emitter.send(\n 'cmd invoke',\n { outcome, client: clientName },\n timingMs,\n { tool },\n );\n },\n async emitError(kind) {\n await emitter.send('error throw', { kind });\n },\n };\n}\n","import {\n listProjects,\n getProject,\n createProject,\n updateProject,\n deleteProject,\n setDefaultProject,\n getDefaultProject,\n listAllFlows,\n listFlows,\n getFlow,\n createFlow,\n updateFlow,\n deleteFlow,\n duplicateFlow,\n listPreviews,\n getPreview,\n createPreview,\n deletePreview,\n deploy,\n listDeployments,\n getDeploymentBySlug,\n deleteDeployment,\n requestDeviceCode,\n pollForToken,\n whoami,\n resolveToken,\n deleteConfig,\n feedback,\n getFeedbackPreference,\n setFeedbackPreference,\n} from '@walkeros/cli';\nimport type {\n DeviceCodeResult,\n PollResult,\n ListFlowsOptions,\n DeployOptions,\n ListDeploymentsOptions,\n ListPreviewsOptions,\n GetPreviewOptions,\n CreatePreviewOptions,\n DeletePreviewOptions,\n FeedbackOptions,\n} from '@walkeros/cli';\n\nimport type { ToolClient } from './tool-client.js';\n\n/**\n * Default ToolClient implementation backed by @walkeros/cli. Every method\n * delegates to the CLI's programmatic API, which in turn talks to the\n * walkerOS app over HTTPS via openapi-fetch. Token resolution and the\n * base URL come from the CLI's config file and environment\n * (WALKEROS_TOKEN, WALKEROS_APP_URL), so no constructor args are required.\n */\nexport class HttpToolClient implements ToolClient {\n async listProjects(): Promise<unknown> {\n return listProjects();\n }\n async getProject(options: { projectId?: string }): Promise<unknown> {\n return getProject(options);\n }\n async createProject(options: { name: string }): Promise<unknown> {\n return createProject(options);\n }\n async updateProject(options: {\n projectId?: string;\n name: string;\n }): Promise<unknown> {\n return updateProject(options);\n }\n async deleteProject(options: { projectId?: string }): Promise<unknown> {\n return deleteProject(options);\n }\n setDefaultProject(projectId: string): void {\n setDefaultProject(projectId);\n }\n getDefaultProject(): string | null {\n return getDefaultProject();\n }\n\n async listAllFlows(options?: {\n sort?: string;\n order?: 'asc' | 'desc';\n includeDeleted?: boolean;\n }): Promise<unknown> {\n return listAllFlows(options as Parameters<typeof listAllFlows>[0]);\n }\n async listFlows(options: ListFlowsOptions): Promise<unknown> {\n return listFlows(options);\n }\n async getFlow(options: {\n flowId: string;\n projectId?: string;\n fields?: string[];\n }): Promise<unknown> {\n return getFlow(options);\n }\n async createFlow(options: {\n name: string;\n content: Record<string, unknown>;\n projectId?: string;\n }): Promise<unknown> {\n return createFlow(options);\n }\n async updateFlow(options: {\n flowId: string;\n projectId?: string;\n name?: string;\n content?: Record<string, unknown>;\n mergePatch?: boolean;\n }): Promise<unknown> {\n return updateFlow(options);\n }\n async deleteFlow(options: {\n flowId: string;\n projectId?: string;\n }): Promise<unknown> {\n return deleteFlow(options);\n }\n async duplicateFlow(options: {\n flowId: string;\n name?: string;\n projectId?: string;\n }): Promise<unknown> {\n return duplicateFlow(options);\n }\n\n async listPreviews(options: ListPreviewsOptions): Promise<unknown> {\n return listPreviews(options);\n }\n async getPreview(options: GetPreviewOptions): Promise<unknown> {\n return getPreview(options);\n }\n async createPreview(options: CreatePreviewOptions): Promise<unknown> {\n return createPreview(options);\n }\n async deletePreview(options: DeletePreviewOptions): Promise<unknown> {\n return deletePreview(options);\n }\n\n async deploy(options: DeployOptions): Promise<unknown> {\n return deploy(options);\n }\n async listDeployments(options: ListDeploymentsOptions): Promise<unknown> {\n return listDeployments(options);\n }\n async getDeploymentBySlug(options: {\n slug: string;\n projectId?: string;\n }): Promise<unknown> {\n return getDeploymentBySlug(options);\n }\n async deleteDeployment(options: {\n slug: string;\n projectId?: string;\n }): Promise<unknown> {\n return deleteDeployment(options);\n }\n\n async requestDeviceCode(): Promise<DeviceCodeResult> {\n return requestDeviceCode();\n }\n async pollForToken(\n deviceCode: string,\n options?: { timeoutMs?: number },\n ): Promise<PollResult> {\n return pollForToken(deviceCode, options);\n }\n async whoami(): Promise<unknown> {\n return whoami();\n }\n resolveToken(): { token: string; source: 'env' | 'config' } | null {\n return resolveToken();\n }\n deleteConfig(): boolean {\n return deleteConfig();\n }\n\n async submitFeedback(text: string, options?: FeedbackOptions): Promise<void> {\n await feedback(text, options);\n }\n getFeedbackPreference(): boolean | undefined {\n return getFeedbackPreference();\n }\n setFeedbackPreference(anonymous: boolean): void {\n setFeedbackPreference(anonymous);\n }\n}\n"],"mappings":";;;AAAA,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;;;ACDjC,SAAS,iBAAiB;;;ACA1B,SAAS,gBAAgB;AAEzB,SAAS,eAAe;AAExB,SAAS,WAAW,gBAAgB;;;ACJpC,SAAS,SAAS;AAGX,IAAM,sBAAsB;AAAA,EACjC,OAAO,EAAE,QAAQ,EAAE,SAAS,2BAA2B;AAAA,EACvD,MAAM,EACH,MAAM;AAAA,IACL,EAAE,KAAK,CAAC,YAAY,SAAS,SAAS,QAAQ,SAAS,CAAC;AAAA,IACxD,EAAE,OAAO,EAAE,MAAM,4CAA4C;AAAA,EAC/D,CAAC,EACA,SAAS,oBAAoB;AAAA,EAChC,QAAQ,EACL;AAAA,IACC,EAAE,OAAO;AAAA,MACP,MAAM,EAAE,OAAO;AAAA,MACf,SAAS,EAAE,OAAO;AAAA,MAClB,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,MAC5B,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,IAC5B,CAAC;AAAA,EACH,EACC,SAAS,mBAAmB;AAAA,EAC/B,UAAU,EACP;AAAA,IACC,EAAE,OAAO;AAAA,MACP,MAAM,EAAE,OAAO;AAAA,MACf,SAAS,EAAE,OAAO;AAAA,MAClB,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,IAClC,CAAC;AA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M,oCAAoC,KAAK;AACvD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["schemas","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","schemas","annotations","mcpResult","mcpError","z","schemas","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","schemas","z","annotations","summary","mcpResult","mcpError","z","schemas","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","schemas","z","annotations","mcpError","mcpResult","z","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","z","annotations","mcpResult","mcpError","z","mcpResult","mcpError","z","mcpResult","mcpError","z","loadJsonConfig","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","z","annotations","loadJsonConfig","mcpResult","mcpError","z","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","annotations","z","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","annotations","z","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","z","annotations","mcpResult","mcpError","z","mcpResult","mcpError","KEEP_LITERAL","keepLiteral","TITLE","DESCRIPTION","inputSchema","z","annotations","data","safe","mcpResult","mcpError","z","mcpResult","mcpError","TITLE","DESCRIPTION","inputSchema","z","annotations","mcpError","mcpResult","schemas","schemas","require","z","z","z"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/mcp",
|
|
3
|
-
"version": "4.0.1
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "MCP server for walkerOS flow development - discover packages, scaffold configs, validate, bundle, simulate, and test event pipelines",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
38
|
-
"@walkeros/cli": "4.0.1
|
|
39
|
-
"@walkeros/core": "4.0.1
|
|
38
|
+
"@walkeros/cli": "4.0.1",
|
|
39
|
+
"@walkeros/core": "4.0.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"zod": "^4.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^20.0.0",
|
|
46
|
-
"@walkeros/config": "4.0.1
|
|
46
|
+
"@walkeros/config": "4.0.1"
|
|
47
47
|
},
|
|
48
48
|
"repository": {
|
|
49
49
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|