@walkeros/mcp 4.6.0-next-1788933594957 → 4.6.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/README.md CHANGED
@@ -162,13 +162,16 @@ can mount the protocol over HTTP instead of running the stdio binary:
162
162
  ```typescript
163
163
  import {
164
164
  createWalkerOSMcpServer,
165
+ createHostedRuntime,
165
166
  HttpToolClient,
166
167
  createStreamableHttpHandler,
167
168
  } from '@walkeros/mcp';
168
169
 
170
+ const client = new HttpToolClient();
169
171
  const server = createWalkerOSMcpServer({
170
- client: new HttpToolClient(),
172
+ client,
171
173
  version: '1.0.0',
174
+ runtime: createHostedRuntime(client),
172
175
  });
173
176
 
174
177
  export const POST = createStreamableHttpHandler(server, {
@@ -176,10 +179,19 @@ export const POST = createStreamableHttpHandler(server, {
176
179
  });
177
180
  ```
178
181
 
182
+ The server reads, bundles and runs flows only through a runtime, which decides
183
+ what the process it lives in may do. `createHostedRuntime(client)` is the
184
+ default when `runtime` is omitted and the right choice for anything reached over
185
+ the network: it loads inline JSON and saved flow ids, refuses local file paths
186
+ and URLs, and never bundles, simulates or pushes in the host process.
187
+ `createLocalRuntime()` keeps every capability, including local files, URLs and
188
+ in-process execution, and belongs only on the user's own machine; the stdio
189
+ binary uses it.
190
+
179
191
  To use the tool registry without the MCP protocol, for example with the Vercel
180
- AI SDK, import `TOOL_DEFINITIONS` and supply your own `ToolClient`. The stdio
181
- binary stays available as `@walkeros/mcp/stdio` and the `walkeros-mcp` bin
182
- entry.
192
+ AI SDK, call `createToolHandlers(client, version, runtime)` or import
193
+ `TOOL_DEFINITIONS` and supply your own `ToolClient`. The stdio binary stays
194
+ available as `@walkeros/mcp/stdio` and the `walkeros-mcp` bin entry.
183
195
 
184
196
  ## Documentation
185
197
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ListFlowsOptions, ListPreviewsOptions, GetPreviewOptions, CreatePreviewOptions, DeletePreviewOptions, ListSecretsOptions, CreateSecretOptions, UpdateSecretOptions, DeleteSecretOptions, DeployOptions, ListDeploymentsOptions, DeviceAuthorization, DeviceLoginResult, FeedbackOptions } from '@walkeros/cli';
2
- import { Journey, JourneyGap, JourneyUnattributed } from '@walkeros/core';
1
+ import { ListFlowsOptions, ListPreviewsOptions, GetPreviewOptions, CreatePreviewOptions, DeletePreviewOptions, ListSecretsOptions, CreateSecretOptions, UpdateSecretOptions, DeleteSecretOptions, DeployOptions, ListDeploymentsOptions, DeviceAuthorization, DeviceLoginResult, FeedbackOptions, BundleStats, PushResult } from '@walkeros/cli';
2
+ import { Journey, JourneyGap, JourneyUnattributed, Ingest, WalkerOS, Simulation } from '@walkeros/core';
3
3
  import { ZodRawShape, z } from 'zod';
4
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
5
  export { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
@@ -590,6 +590,71 @@ interface ToolSpec {
590
590
  handler: (input: unknown) => Promise<unknown>;
591
591
  }
592
592
 
593
+ /**
594
+ * The capability seam between the flow tools and the machine they run on.
595
+ *
596
+ * Every file read, URL fetch, bundle, simulation and push a tool performs goes
597
+ * through a `FlowRuntime` and nothing else, so the runtime alone decides what
598
+ * the process it lives in may do:
599
+ *
600
+ * - `createLocalRuntime()` keeps every capability. It is for the user's own
601
+ * machine (stdio, the developer CLI), where the user is responsible for what
602
+ * runs there.
603
+ * - `createHostedRuntime(client)` is least privilege for a shared, network
604
+ * reached process: it loads inline JSON and saved flow ids only, refuses
605
+ * local paths and URLs, and has no `bundle`, `simulate` or `push` at all.
606
+ *
607
+ * A tool whose operation the runtime does not provide refuses with a hint that
608
+ * names only out-of-process routes.
609
+ */
610
+ interface FlowRuntime {
611
+ /**
612
+ * Resolve a config input to parsed JSON. Local: a file path, an http(s) URL
613
+ * or inline JSON. Hosted: inline JSON or a saved `flow_`/`cfg_` id; a local
614
+ * path or URL is refused with a `RuntimeRefusal`.
615
+ */
616
+ load(input: string): Promise<unknown>;
617
+ /** Compile a flow. Absent on a runtime that must not build in its process. */
618
+ bundle?(input: string, opts: BundleOptions): Promise<BundleStats | void>;
619
+ /** Build and run one step of a flow. Absent where that must not happen. */
620
+ simulate?(input: string, opts: SimulateOptions): Promise<Simulation.Result>;
621
+ /** Build and run a flow against real destinations. Absent where forbidden. */
622
+ push?(input: string, event: Record<string, unknown>, opts: PushOptions): Promise<PushResult>;
623
+ }
624
+ interface BundleOptions {
625
+ flowName?: string;
626
+ stats?: boolean;
627
+ output?: string;
628
+ }
629
+ type SimulateStepType = 'source' | 'transformer' | 'collector' | 'destination';
630
+ interface SimulateOptions {
631
+ stepType: SimulateStepType;
632
+ stepId: string;
633
+ event: unknown;
634
+ flow?: string;
635
+ /** Transformer steps only: pipeline context the step reads via `ctx.ingest`. */
636
+ ingest?: Omit<Ingest, '_meta'>;
637
+ /** Collector steps only: state snapshot seeded before enrichment runs. */
638
+ state?: {
639
+ consent?: WalkerOS.Consent;
640
+ user?: WalkerOS.User;
641
+ globals?: WalkerOS.Properties;
642
+ timing?: number;
643
+ };
644
+ }
645
+ interface PushOptions {
646
+ flow?: string;
647
+ platform?: 'web' | 'server';
648
+ }
649
+ /**
650
+ * Thrown by a runtime when it refuses an input on principle rather than on a
651
+ * fault. Carries the hint a tool should surface next to the message.
652
+ */
653
+ declare class RuntimeRefusal extends Error {
654
+ readonly hint: string;
655
+ constructor(message: string, hint: string);
656
+ }
657
+
593
658
  interface Logger {
594
659
  debug?(message: string, meta?: Record<string, unknown>): void;
595
660
  info?(message: string, meta?: Record<string, unknown>): void;
@@ -601,6 +666,15 @@ interface CreateServerOptions {
601
666
  logger?: Logger;
602
667
  version?: string;
603
668
  catalogBaseUrl?: string;
669
+ /**
670
+ * The capability runtime the flow tools read, build and run flows through.
671
+ * Omitted, the HOSTED runtime is used, the safe default for any shared or
672
+ * network-reached process: inline JSON and saved flow ids only, no local
673
+ * files, no URLs, no in-process bundle, simulate or push. Pass
674
+ * `createLocalRuntime()` only on the user's own machine (stdio, the CLI) to
675
+ * keep local file, URL and execution behaviour. See `FlowRuntime`.
676
+ */
677
+ runtime?: FlowRuntime;
604
678
  }
605
679
  declare function createWalkerOSMcpServer(opts: CreateServerOptions): McpServer;
606
680
 
@@ -819,6 +893,31 @@ interface CreateStreamableHttpHandlerOptions extends WebStandardStreamableHTTPSe
819
893
  */
820
894
  declare function createStreamableHttpHandler(server: McpServer, opts?: CreateStreamableHttpHandlerOptions): (request: Request) => Promise<Response>;
821
895
 
896
+ /**
897
+ * The full-capability runtime for the user's own machine (stdio, the developer
898
+ * CLI). It wraps the `@walkeros/cli` loaders and runners exactly as the tools
899
+ * called them before the runtime seam existed, so local behaviour is unchanged:
900
+ * a config may be a file path, an http(s) URL or inline JSON, and bundling,
901
+ * simulation and push run in this process.
902
+ *
903
+ * This is the only module in the package that may bind those cli functions;
904
+ * the tools reach them through the `FlowRuntime` interface and nothing else.
905
+ */
906
+ declare function createLocalRuntime(): FlowRuntime;
907
+
908
+ /**
909
+ * The least-privilege runtime for a shared, network-reached process: the app's
910
+ * OAuth door, in-app chat, and any third-party HTTP host.
911
+ *
912
+ * It never touches the filesystem or the network on the caller's behalf. A
913
+ * saved `flow_`/`cfg_` id is resolved through the access-scoped tool client, a
914
+ * document is parsed inline, and everything else is refused. `bundle`,
915
+ * `simulate` and `push` are deliberately absent: compiling or importing a
916
+ * caller's flow pulls that caller's code (inline or by package name) into this
917
+ * process, and no input shape makes that safe here.
918
+ */
919
+ declare function createHostedRuntime(client: Pick<ToolClient, 'getFlow'>): FlowRuntime;
920
+
822
921
  /**
823
922
  * Exported so the hosted plane can assert parity against this exact string
824
923
  * instead of retyping it.
@@ -1195,8 +1294,10 @@ declare module '@walkeros/core' {
1195
1294
  * Handlers are closed over `client`, so the caller can bind a single
1196
1295
  * `ToolClient` (such as the zero-hop `ServiceToolClient`) once per session.
1197
1296
  * `packageVersion` is reported by the `diagnostics` tool and defaults to
1198
- * `'0.0.0'` when omitted.
1297
+ * `'0.0.0'` when omitted. `runtime` defaults to the hosted runtime, the safe
1298
+ * choice for any shared process; pass `createLocalRuntime()` only on the
1299
+ * user's own machine.
1199
1300
  */
1200
- declare function createToolHandlers(client: ToolClient, packageVersion?: string): Record<string, ToolSpec>;
1301
+ declare function createToolHandlers(client: ToolClient, packageVersion?: string, runtime?: FlowRuntime): Record<string, ToolSpec>;
1201
1302
 
1202
- export { type CreateServerOptions, type CreateStreamableHttpHandlerOptions, type DeploymentLinkTarget, FEATURE_NOT_AVAILABLE, FRAME_HINT_EXTENDS_BASE, FRAME_HINT_MARK_SPACE, FRAME_HINT_NAMES_ARE_DOCUMENTATION, FRAME_HINT_NONE_ON_PAGE, FRAME_HINT_NONE_YET, FRAME_HINT_OPEN_PAGE_OR_GET, FRAME_HINT_READ_KNOWLEDGE, FRAME_MANAGE_DESCRIPTION, FRAME_MANAGE_INPUT_SCHEMA, FRAME_NOT_FOUND_HINT, type FlowCanvasPayload, type FlowCanvasToolResult, type FlowLinkTarget, type FrameLeanListWire, type FrameLeanWire, type FrameListWire, type FrameWire, type GatedFeature, HINT_EMPTY_FEED, HINT_ENDED, HINT_NO_WINDOW, HINT_PREVIEW_STREAMS, HINT_READ, HINT_SIMULATE_FIRST, HINT_STOP, HUB_HINT_CONFIRM_INDEX, HUB_HINT_ENTRY_NAMES_FLOW, HUB_HINT_KEEP_ONE_THREAD, HUB_HINT_KNOWLEDGE_INDEX, HUB_HINT_KNOWLEDGE_PAGE_CAPPED, HUB_HINT_KNOWLEDGE_READ_ONLY, HUB_HINT_MASKED_ONLY, HUB_HINT_MESSAGES_TRUNCATED, HUB_HINT_MESSAGE_VISIBLE, HUB_HINT_NOTHING_DISCUSSED, HUB_HINT_NOTHING_WRITTEN, HUB_HINT_NO_MATCH, HUB_HINT_NO_THREAD_ON_ANCHOR, HUB_HINT_OPEN_RELEASE, HUB_HINT_RATIONALE_VISIBLE, HUB_HINT_READ_BACK, HUB_HINT_READ_FRAME, HUB_HINT_RELEASE_GET, HUB_HINT_REPLY_OR_OPEN, HUB_HINT_RESOLVE_IN_APP, HUB_HINT_ROWS_ARE_DEPLOYMENTS, HUB_HINT_SCAN_CAPPED, HUB_HINT_STAYS_RESOLVED, HUB_HINT_STEP_HISTORY, HUB_HINT_THREADS_INDEX, HUB_HINT_THREADS_PAGE_CAPPED, HUB_HINT_THREAD_OPEN, HUB_HINT_TRACE_STEP, HUB_HINT_WRITE_RATIONALE, HUB_MANAGE_DESCRIPTION, HUB_MANAGE_INPUT_SCHEMA, HUB_NOT_FOUND_HINT, HttpToolClient, type HubThreadWire, type JourneysResult, type KnowledgeEntryWire, type ListKnowledgeWire, type ListThreadsWire, type Logger, DESCRIPTION as OBSERVE_SESSION_DESCRIPTION, type RedactOptions, type ReleaseDetailWire, type ReleaseIndexWire, type ReleaseRef, type StepHistoryWire, type StepLinkTarget, type SuggestionTile, TOOL_DEFINITIONS, type ThreadLinkTarget, type ToolAnnotations, type ToolClient, type ToolDefinition, type ToolSpec, type VersionAnnotationWire, createStreamableHttpHandler, createToolHandlers, createWalkerOSMcpServer, featureDenialHint, flowCanvasResult, isFeatureDenial, isFlowCanvasResult, links, redactNestedStrings, wrapUserData };
1303
+ export { type BundleOptions, type CreateServerOptions, type CreateStreamableHttpHandlerOptions, type DeploymentLinkTarget, FEATURE_NOT_AVAILABLE, FRAME_HINT_EXTENDS_BASE, FRAME_HINT_MARK_SPACE, FRAME_HINT_NAMES_ARE_DOCUMENTATION, FRAME_HINT_NONE_ON_PAGE, FRAME_HINT_NONE_YET, FRAME_HINT_OPEN_PAGE_OR_GET, FRAME_HINT_READ_KNOWLEDGE, FRAME_MANAGE_DESCRIPTION, FRAME_MANAGE_INPUT_SCHEMA, FRAME_NOT_FOUND_HINT, type FlowCanvasPayload, type FlowCanvasToolResult, type FlowLinkTarget, type FlowRuntime, type FrameLeanListWire, type FrameLeanWire, type FrameListWire, type FrameWire, type GatedFeature, HINT_EMPTY_FEED, HINT_ENDED, HINT_NO_WINDOW, HINT_PREVIEW_STREAMS, HINT_READ, HINT_SIMULATE_FIRST, HINT_STOP, HUB_HINT_CONFIRM_INDEX, HUB_HINT_ENTRY_NAMES_FLOW, HUB_HINT_KEEP_ONE_THREAD, HUB_HINT_KNOWLEDGE_INDEX, HUB_HINT_KNOWLEDGE_PAGE_CAPPED, HUB_HINT_KNOWLEDGE_READ_ONLY, HUB_HINT_MASKED_ONLY, HUB_HINT_MESSAGES_TRUNCATED, HUB_HINT_MESSAGE_VISIBLE, HUB_HINT_NOTHING_DISCUSSED, HUB_HINT_NOTHING_WRITTEN, HUB_HINT_NO_MATCH, HUB_HINT_NO_THREAD_ON_ANCHOR, HUB_HINT_OPEN_RELEASE, HUB_HINT_RATIONALE_VISIBLE, HUB_HINT_READ_BACK, HUB_HINT_READ_FRAME, HUB_HINT_RELEASE_GET, HUB_HINT_REPLY_OR_OPEN, HUB_HINT_RESOLVE_IN_APP, HUB_HINT_ROWS_ARE_DEPLOYMENTS, HUB_HINT_SCAN_CAPPED, HUB_HINT_STAYS_RESOLVED, HUB_HINT_STEP_HISTORY, HUB_HINT_THREADS_INDEX, HUB_HINT_THREADS_PAGE_CAPPED, HUB_HINT_THREAD_OPEN, HUB_HINT_TRACE_STEP, HUB_HINT_WRITE_RATIONALE, HUB_MANAGE_DESCRIPTION, HUB_MANAGE_INPUT_SCHEMA, HUB_NOT_FOUND_HINT, HttpToolClient, type HubThreadWire, type JourneysResult, type KnowledgeEntryWire, type ListKnowledgeWire, type ListThreadsWire, type Logger, DESCRIPTION as OBSERVE_SESSION_DESCRIPTION, type PushOptions, type RedactOptions, type ReleaseDetailWire, type ReleaseIndexWire, type ReleaseRef, RuntimeRefusal, type SimulateOptions, type SimulateStepType, type StepHistoryWire, type StepLinkTarget, type SuggestionTile, TOOL_DEFINITIONS, type ThreadLinkTarget, type ToolAnnotations, type ToolClient, type ToolDefinition, type ToolSpec, type VersionAnnotationWire, createHostedRuntime, createLocalRuntime, createStreamableHttpHandler, createToolHandlers, createWalkerOSMcpServer, featureDenialHint, flowCanvasResult, isFeatureDenial, isFlowCanvasResult, links, redactNestedStrings, wrapUserData };