@walkeros/mcp 4.8.0 → 4.8.1-next-1792019907609

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.
@@ -0,0 +1,277 @@
1
+ import { Flow, Ingest, WalkerOS, Simulation } from '@walkeros/core';
2
+ import { BundleStats, PushResult } from '@walkeros/cli';
3
+ import { ZodOptional, ZodString, ZodRawShape } from 'zod';
4
+ import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
5
+
6
+ /**
7
+ * The knowledge resources and prompts as plain data, so a host registers them
8
+ * on its own MCP server. No MCP SDK import: the shapes are what the SDK's
9
+ * `registerResource` and `registerPrompt` accept.
10
+ */
11
+
12
+ interface ResourceContent {
13
+ text: string;
14
+ mimeType: string;
15
+ }
16
+ /** A resource at one fixed URI. */
17
+ interface StaticResourceSpec {
18
+ kind: 'static';
19
+ /** Registration name, for example 'flow-schema'. */
20
+ name: string;
21
+ uri: string;
22
+ description: string;
23
+ mimeType: string;
24
+ read: () => Promise<ResourceContent>;
25
+ }
26
+ interface ResourceListEntry {
27
+ uri: string;
28
+ name: string;
29
+ description?: string;
30
+ mimeType: string;
31
+ }
32
+ /** A URI template resource that lists its own members. */
33
+ interface TemplateResourceSpec {
34
+ kind: 'template';
35
+ name: string;
36
+ uriTemplate: string;
37
+ title?: string;
38
+ description: string;
39
+ mimeType: string;
40
+ list: () => Promise<ResourceListEntry[]>;
41
+ /** The template variables of the requested URI, as the host parsed them. */
42
+ read: (variables: Readonly<Record<string, string | string[]>>) => Promise<ResourceContent>;
43
+ }
44
+ type ResourceSpec = StaticResourceSpec | TemplateResourceSpec;
45
+ interface PromptMessage {
46
+ role: 'user' | 'assistant';
47
+ content: {
48
+ type: 'text';
49
+ text: string;
50
+ };
51
+ }
52
+ /** A prompt; every argument is an optional string, as MCP prompt arguments are. */
53
+ interface PromptSpec {
54
+ name: string;
55
+ description: string;
56
+ argsSchema: Record<string, ZodOptional<ZodString>>;
57
+ handler: (args: Readonly<Record<string, string | undefined>>) => Promise<{
58
+ messages: PromptMessage[];
59
+ }>;
60
+ }
61
+
62
+ /**
63
+ * The capability seam between the flow tools and the machine they run on.
64
+ *
65
+ * Every file read, URL fetch, bundle, simulation and push a tool performs goes
66
+ * through a `FlowRuntime` and nothing else. A runtime decides what the process
67
+ * it lives in may read and run. `createLocalRuntime()` keeps every capability
68
+ * for the user's own machine; a host that must not read files or URLs or run
69
+ * flows passes a runtime with `load` only, and the tools that need more
70
+ * refuse.
71
+ *
72
+ * A tool whose operation the runtime does not provide refuses with a hint that
73
+ * names only out-of-process routes.
74
+ */
75
+ interface FlowRuntime {
76
+ /**
77
+ * Resolve a config input to parsed JSON. Local: a file path, an http(s) URL
78
+ * or inline JSON. An input the runtime refuses throws a `RuntimeRefusal`.
79
+ */
80
+ load(input: string): Promise<unknown>;
81
+ /**
82
+ * The directory local `path` packages of a loaded input resolve against:
83
+ * the input file's directory. Absent on a runtime without a filesystem,
84
+ * where such packages stay a reported skip.
85
+ */
86
+ baseDir?(input: string): string | undefined;
87
+ /** Compile a flow. Absent on a runtime that must not build in its process. */
88
+ bundle?(input: string, opts: BundleOptions): Promise<BundleStats | void>;
89
+ /** Build and run one step of a flow. Absent where that must not happen. */
90
+ simulate?(input: string, opts: SimulateOptions): Promise<Simulation.Result>;
91
+ /**
92
+ * The values of the secrets a flow config references (`$secret.NAME`),
93
+ * masked wherever a simulation or push result egresses. Read by the tools
94
+ * only on a runtime without `loadRun`; a read that fails stops the run.
95
+ */
96
+ knownSecrets?(input: string): Promise<string[]>;
97
+ /**
98
+ * Read a push or simulate input once: the config and the values of the
99
+ * secrets it references. A prebuilt bundle yields no config. A read that
100
+ * fails rejects. Absent with `simulate` and `push`.
101
+ */
102
+ loadRun?(input: string): Promise<LoadedRun>;
103
+ /** Build and run a flow against real destinations. Absent where forbidden. */
104
+ push?(input: string, event: Record<string, unknown>, opts: PushOptions): Promise<PushResult>;
105
+ }
106
+ interface BundleOptions {
107
+ flowName?: string;
108
+ stats?: boolean;
109
+ output?: string;
110
+ }
111
+ type SimulateStepType = 'source' | 'transformer' | 'collector' | 'destination';
112
+ interface SimulateOptions {
113
+ stepType: SimulateStepType;
114
+ stepId: string;
115
+ event: unknown;
116
+ flow?: string;
117
+ /** The config from `loadRun`: the runtime does not read the input again. */
118
+ config?: Flow.Json;
119
+ /**
120
+ * Transformer, collector and destination steps: pipeline context the step
121
+ * reads via `ctx.ingest`. Source steps ignore it.
122
+ */
123
+ ingest?: Omit<Ingest, '_meta'>;
124
+ /**
125
+ * Collector state the step starts from. `consent` applies to every step
126
+ * (the collector's starting consent); `user`, `globals` and `timing` to
127
+ * collector steps only.
128
+ */
129
+ state?: {
130
+ consent?: WalkerOS.Consent;
131
+ user?: WalkerOS.User;
132
+ globals?: WalkerOS.Properties;
133
+ timing?: number;
134
+ };
135
+ /**
136
+ * Destination steps only: run this collector command with `event` as its
137
+ * data instead of pushing it (a step example with `command`).
138
+ */
139
+ command?: Flow.StepCommand;
140
+ }
141
+ /** A push or simulate input as read once by `loadRun`. */
142
+ interface LoadedRun {
143
+ config?: Flow.Json;
144
+ knownSecrets: string[];
145
+ }
146
+ interface PushOptions {
147
+ flow?: string;
148
+ platform?: 'web' | 'server';
149
+ /** The config from `loadRun`: the runtime does not read the input again. */
150
+ config?: Flow.Json;
151
+ }
152
+ /**
153
+ * Thrown by a runtime when it refuses an input on principle rather than on a
154
+ * fault. Carries the hint a tool should surface next to the message.
155
+ */
156
+ declare class RuntimeRefusal extends Error {
157
+ readonly hint: string;
158
+ constructor(message: string, hint: string);
159
+ }
160
+
161
+ interface ToolAnnotations {
162
+ readOnlyHint: boolean;
163
+ destructiveHint: boolean;
164
+ idempotentHint: boolean;
165
+ openWorldHint: boolean;
166
+ }
167
+ /**
168
+ * A full tool specification: metadata plus executable handler.
169
+ *
170
+ * Produced by each `create<Name>ToolSpec(...)` factory. The local server
171
+ * registers every spec through one path; a host without an `McpServer`
172
+ * drives the handlers directly.
173
+ */
174
+ interface ToolSpec {
175
+ name: string;
176
+ title: string;
177
+ description: string;
178
+ inputSchema: ZodRawShape;
179
+ /** Wire-only output shape; absent where a tool answers in several shapes. */
180
+ outputSchema?: ZodRawShape;
181
+ annotations: ToolAnnotations;
182
+ handler: (input: unknown) => Promise<CallToolResult>;
183
+ }
184
+
185
+ /**
186
+ * Wraps a user-writable string in `<user_data>…</user_data>` so the chat
187
+ * assistant treats it as data, never as instructions. Inner `</user_data>`
188
+ * sequences are mangled (`</user_data_>`) so a malicious string can't close
189
+ * the envelope early.
190
+ *
191
+ * Idempotent: a string that is already a well-formed envelope with no inner
192
+ * `</user_data>` is returned unchanged.
193
+ */
194
+ declare function wrapUserData(s: string): string;
195
+ /**
196
+ * A listed record (a project, a flow summary, the project of a flow group)
197
+ * with its top-level display text wrapped as user data. Every other field
198
+ * stays literal, nested ones included, so a flow's `settings[].name` (an
199
+ * identifier the assistant passes back as `settingsName`) is never wrapped.
200
+ * Anything that is not an object passes through unchanged.
201
+ */
202
+ declare function wrapListedRecord(value: unknown): unknown;
203
+ /**
204
+ * The single redaction rule for every tool that echoes flow/deployment data
205
+ * back to the chat assistant:
206
+ *
207
+ * wrap only the human-facing display `name`/`flowName` field and deep config
208
+ * VALUES; leave all structural ids/keys literal everywhere.
209
+ *
210
+ * Redaction exists to neutralise user-CONTROLLED string VALUES so an injected
211
+ * `</user_data>` can't escape the envelope. It must NOT touch:
212
+ * - structural keys (ids, slugs, dates, immutable identifiers): the LLM needs
213
+ * to reference them verbatim, and wrapping them breaks get→edit→update
214
+ * round-trips (e.g. wrapping `package`/`platform` corrupts a config the
215
+ * user pushes straight back).
216
+ * - tool-generated text (validation messages, error strings): that text is
217
+ * authored by us, not echoed user input, so it stays literal like `path`.
218
+ *
219
+ * `STRUCTURAL_KEYS` is the union of every key whose value is an id/slug/date/
220
+ * immutable identifier rather than user free-text. Confirmed: none of these key
221
+ * names ever hold a genuine user-authored free-text value — `package`/`platform`
222
+ * are enum/package-name fields, `kind` is a discriminator, the rest are
223
+ * server-generated ids/timestamps.
224
+ */
225
+ declare const STRUCTURAL_KEYS: Set<string>;
226
+ /** Return `true` for keys that must stay literal (ids, slugs, dates, package,
227
+ * platform). Use as the `skip` predicate for {@link redactNestedStrings}. */
228
+ declare const keepStructural: (key: string) => boolean;
229
+ interface RedactOptions {
230
+ /** Return `true` to skip wrapping for a given object key. Only invoked for
231
+ * string values on object entries — not for array elements or scalar
232
+ * roots. Use to keep ids / slugs / dates literal. */
233
+ skip?: (key: string) => boolean;
234
+ }
235
+ /**
236
+ * Recursively walks `value` and returns a deep-copied structure where every
237
+ * string leaf has been passed through `wrapUserData`. Pass `skip` to exclude
238
+ * specific keys (e.g. `id`) from wrapping.
239
+ */
240
+ declare function redactNestedStrings<T>(value: T, opts?: RedactOptions): T;
241
+ /**
242
+ * Recursively wraps ONLY the human-facing display text fields (`name`,
243
+ * `flowName`, `summary`), leaving every other value (ids, slugs, status, type,
244
+ * dates) literal. Use on tool responses that echo deployment/flow summaries
245
+ * where the only user-authored free-text is display text.
246
+ */
247
+ declare function redactDisplayNames<T>(value: T): T;
248
+
249
+ /**
250
+ * The specs both walkerOS MCP servers share, as plain data: five tools over a
251
+ * FlowRuntime, the knowledge resources and the prompts. This entry imports no
252
+ * CLI main entry, no bundler, no package manager and no MCP SDK, so a server
253
+ * process registers them on its own server; a host imports everything it
254
+ * needs (the specs, `RuntimeRefusal`, `FlowRuntime`, the envelope helpers)
255
+ * from `@walkeros/mcp/specs`, never from the main entry, which loads the CLI.
256
+ * Bundle, simulate and push are not here: they run caller code and belong to
257
+ * the local server only.
258
+ */
259
+
260
+ /** The five tools both walkerOS MCP servers offer, keyed by name. */
261
+ type LocalToolSpecs = {
262
+ flow_validate: ToolSpec;
263
+ flow_examples: ToolSpec;
264
+ flow_load: ToolSpec;
265
+ package_search: ToolSpec;
266
+ package_get: ToolSpec;
267
+ };
268
+ declare function createLocalToolSpecs(runtime: FlowRuntime): LocalToolSpecs;
269
+ /**
270
+ * The reference resources plus the package schema template, in registration
271
+ * order. No openapi entry: the app owns that resource.
272
+ */
273
+ declare const KNOWLEDGE_RESOURCES: readonly ResourceSpec[];
274
+ /** add-step, setup-mapping, manage-contract. */
275
+ declare const PROMPTS: readonly PromptSpec[];
276
+
277
+ export { type BundleOptions, type FlowRuntime, KNOWLEDGE_RESOURCES, type LoadedRun, type LocalToolSpecs, PROMPTS, type PromptMessage, type PromptSpec, type PushOptions, type RedactOptions, type ResourceContent, type ResourceListEntry, type ResourceSpec, RuntimeRefusal, STRUCTURAL_KEYS, type SimulateOptions, type SimulateStepType, type StaticResourceSpec, type TemplateResourceSpec, type ToolAnnotations, type ToolSpec, createLocalToolSpecs, keepStructural, redactDisplayNames, redactNestedStrings, wrapListedRecord, wrapUserData };
package/dist/specs.js ADDED
@@ -0,0 +1,25 @@
1
+ import {
2
+ KNOWLEDGE_RESOURCES,
3
+ PROMPTS,
4
+ RuntimeRefusal,
5
+ STRUCTURAL_KEYS,
6
+ createLocalToolSpecs,
7
+ keepStructural,
8
+ redactDisplayNames,
9
+ redactNestedStrings,
10
+ wrapListedRecord,
11
+ wrapUserData
12
+ } from "./chunk-P6JS2RWY.js";
13
+ export {
14
+ KNOWLEDGE_RESOURCES,
15
+ PROMPTS,
16
+ RuntimeRefusal,
17
+ STRUCTURAL_KEYS,
18
+ createLocalToolSpecs,
19
+ keepStructural,
20
+ redactDisplayNames,
21
+ redactNestedStrings,
22
+ wrapListedRecord,
23
+ wrapUserData
24
+ };
25
+ //# sourceMappingURL=specs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}