@mcpcloud/runtime 0.7.1 → 0.12.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/adapters/codeModeHost.d.ts +25 -0
- package/dist/compat-stdio.js +48 -23
- package/dist/compat-worker.js +58 -89
- package/dist/container-host.js +12 -2
- package/dist/engine/emscripten-module.cloudflare.cjs +21 -0
- package/dist/engine/emscripten-module.cloudflare.d.cts +3 -0
- package/dist/engine/emscripten-module.d.mts +3 -0
- package/dist/engine/emscripten-module.d.ts +11 -0
- package/dist/engine/emscripten-module.mjs +26 -0
- package/dist/engine/emscripten-module.wasm +0 -0
- package/dist/engine/ffi.d.mts +4 -0
- package/dist/engine/ffi.d.ts +85 -0
- package/dist/engine/ffi.mjs +1 -0
- package/dist/engine/manifest.json +51 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +71 -85
- package/dist/node.js +12 -2
- package/dist/projection.d.ts +9 -0
- package/dist/sandbox/bindings.d.ts +116 -0
- package/dist/sandbox/codeModeTool.d.ts +114 -0
- package/dist/sandbox/console.d.ts +51 -0
- package/dist/sandbox/createSandbox.d.ts +16 -1
- package/dist/sandbox/nodeEngine.d.ts +30 -0
- package/dist/sandbox/shape.d.ts +68 -0
- package/dist/sandbox/types.d.ts +80 -2
- package/dist/server.d.ts +13 -0
- package/dist/stdio.js +59 -24
- package/dist/validation.d.ts +16 -0
- package/package.json +1 -1
package/dist/sandbox/types.d.ts
CHANGED
|
@@ -32,9 +32,19 @@ export interface SandboxLimits {
|
|
|
32
32
|
* that is slow because it is waiting, once tool calls exist in P2.
|
|
33
33
|
*/
|
|
34
34
|
wallClockMs: number;
|
|
35
|
+
/**
|
|
36
|
+
* Upstream calls one execution may make.
|
|
37
|
+
*
|
|
38
|
+
* Not a cost control — §9.4's "10,000 calls costs $0.15" bounds the COST of a
|
|
39
|
+
* runaway, not the HARM. This bounds how much an injected or mistaken agent
|
|
40
|
+
* can do in one request, which is the thing that actually matters (§7.4).
|
|
41
|
+
*/
|
|
42
|
+
maxToolCalls: number;
|
|
35
43
|
}
|
|
36
44
|
/** Which ceiling an execution hit. Named so a caller can retry narrower. */
|
|
37
|
-
export type SandboxBudget = 'opcodes' | 'memory' | 'stack' | 'wall_clock'
|
|
45
|
+
export type SandboxBudget = 'opcodes' | 'memory' | 'stack' | 'wall_clock'
|
|
46
|
+
/** One execution can issue thousands of upstream calls from a loop (§6). */
|
|
47
|
+
| 'tool_calls';
|
|
38
48
|
/**
|
|
39
49
|
* Why an execution failed.
|
|
40
50
|
*
|
|
@@ -44,13 +54,73 @@ export type SandboxBudget = 'opcodes' | 'memory' | 'stack' | 'wall_clock';
|
|
|
44
54
|
* naming the budget lets an agent retry with a narrower query instead of
|
|
45
55
|
* rewriting working code.
|
|
46
56
|
*/
|
|
47
|
-
export type SandboxFailureKind = 'syntax_error' | 'runtime_error' | 'budget_exhausted' | 'timeout'
|
|
57
|
+
export type SandboxFailureKind = 'syntax_error' | 'runtime_error' | 'budget_exhausted' | 'timeout'
|
|
58
|
+
/**
|
|
59
|
+
* A tool call was refused by policy — not a code defect.
|
|
60
|
+
*
|
|
61
|
+
* Separate from `runtime_error` because §7.2's classes exist to drive opposite
|
|
62
|
+
* responses: a refusal means stop and escalate, while a runtime error means
|
|
63
|
+
* rewrite. Reporting a refusal as a code bug invites the agent to rewrite
|
|
64
|
+
* code that was fine, which is the expensive failure the taxonomy exists to
|
|
65
|
+
* prevent.
|
|
66
|
+
*/
|
|
67
|
+
| 'policy_denied';
|
|
68
|
+
/** One tool call the guest made, as the failure digest will render it (§7.3). */
|
|
69
|
+
export interface SandboxSpan {
|
|
70
|
+
/** Tool name as the guest called it. */
|
|
71
|
+
name: string;
|
|
72
|
+
/**
|
|
73
|
+
* Arguments, recorded as VALUES rather than shapes. They are small and
|
|
74
|
+
* agent-authored — the guest wrote them, so echoing them back leaks nothing
|
|
75
|
+
* it did not already know, and they are what a corrected call needs.
|
|
76
|
+
*/
|
|
77
|
+
args: unknown;
|
|
78
|
+
durationMs: number;
|
|
79
|
+
/** Structure of what came back. Never the content — see shape.ts. */
|
|
80
|
+
resultShape?: string;
|
|
81
|
+
/** Distributional facts about the result, when it is an array of records. */
|
|
82
|
+
facts?: string[];
|
|
83
|
+
error?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Payload size either side of the tool's JMESPath projection, when it has
|
|
86
|
+
* one. Present only if a projection ran, so an unprojected tool adds no noise.
|
|
87
|
+
* Feeds the same savings telemetry the direct-call path already reports.
|
|
88
|
+
*/
|
|
89
|
+
preProjectionBytes?: number;
|
|
90
|
+
postProjectionBytes?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Whether this call may have changed anything upstream. Unknown resolves to
|
|
93
|
+
* true: misclassifying a mutation as a read is the one error with
|
|
94
|
+
* irreversible consequences (§7.4).
|
|
95
|
+
*/
|
|
96
|
+
mutates: boolean;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* One `console.*` call the guest made (§7.5).
|
|
100
|
+
*
|
|
101
|
+
* Kept in the trace always, surfaced inline only when the execution failed — a
|
|
102
|
+
* successful run returned what was asked for, and its logs in context would
|
|
103
|
+
* reintroduce the cost Code Mode removes.
|
|
104
|
+
*/
|
|
105
|
+
export interface SandboxLogEntry {
|
|
106
|
+
level: string;
|
|
107
|
+
/**
|
|
108
|
+
* Already rendered: strings literal and capped, everything else summarized to
|
|
109
|
+
* a SHAPE. A logged object is usually a tool result the agent is inspecting,
|
|
110
|
+
* which is the content the token wall exists to keep out.
|
|
111
|
+
*/
|
|
112
|
+
message: string;
|
|
113
|
+
}
|
|
48
114
|
export interface SandboxSuccess {
|
|
49
115
|
ok: true;
|
|
50
116
|
/** Whatever the guest returned, marshalled through JSON. */
|
|
51
117
|
value: unknown;
|
|
52
118
|
/** Interrupt ticks consumed. The metering read (§3). */
|
|
53
119
|
opcodesUsed: number;
|
|
120
|
+
/** One per tool call, in call order. */
|
|
121
|
+
spans: SandboxSpan[];
|
|
122
|
+
/** `console.*` output, in call order. Never surfaced on success. */
|
|
123
|
+
logs: SandboxLogEntry[];
|
|
54
124
|
}
|
|
55
125
|
export interface SandboxFailure {
|
|
56
126
|
ok: false;
|
|
@@ -61,5 +131,13 @@ export interface SandboxFailure {
|
|
|
61
131
|
/** Guest stack, when the engine produced one. Harness frames are stripped. */
|
|
62
132
|
stack?: string;
|
|
63
133
|
opcodesUsed: number;
|
|
134
|
+
/**
|
|
135
|
+
* Calls made before the failure. These are the partial results: the agent can
|
|
136
|
+
* see what already ran and write a follow-up that skips it, which is cheaper
|
|
137
|
+
* and more flexible than resuming a heap (§7.7).
|
|
138
|
+
*/
|
|
139
|
+
spans: SandboxSpan[];
|
|
140
|
+
/** `console.*` output, in call order — the mid-execution view (§7.5). */
|
|
141
|
+
logs: SandboxLogEntry[];
|
|
64
142
|
}
|
|
65
143
|
export type SandboxResult = SandboxSuccess | SandboxFailure;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
import type { CallerContext, RuntimeConfig, RuntimeEnv, ServerIdentity } from './config';
|
|
4
|
+
import type { CodeModeOptions } from './sandbox/codeModeTool';
|
|
4
5
|
import type { PromptDefinition, ResourceDefinition, ToolDefinition } from './types';
|
|
5
6
|
export type ToolHandler = (input: unknown, config: RuntimeConfig, caller: CallerContext) => Promise<CallToolResult>;
|
|
6
7
|
export interface RegisteredTool {
|
|
@@ -16,6 +17,18 @@ export interface DefineServerOptions {
|
|
|
16
17
|
prompts?: PromptDefinition[];
|
|
17
18
|
/** Resources served via `resources/list` / `resources/read` (#78). */
|
|
18
19
|
resources?: ResourceDefinition[];
|
|
20
|
+
/**
|
|
21
|
+
* Code Mode. Registers `codemode_execute` ALONGSIDE whatever discoveryMode
|
|
22
|
+
* already exposes — the search/execute pair the design is modelled on, not a
|
|
23
|
+
* replacement for either.
|
|
24
|
+
*
|
|
25
|
+
* Needs both a non-`off` mode and an engine. Codegen emits the mode from the
|
|
26
|
+
* server's setting; the host supplies the engine. A server whose operator
|
|
27
|
+
* turned Code Mode on still registers nothing on a host that cannot run it,
|
|
28
|
+
* which is the honest outcome — but it is also why the setting alone is not
|
|
29
|
+
* yet enough to make the tool appear on the Workers edge.
|
|
30
|
+
*/
|
|
31
|
+
codeMode?: CodeModeOptions;
|
|
19
32
|
}
|
|
20
33
|
export interface GeneratedServer {
|
|
21
34
|
/** Build a fresh McpServer (per request — handler closures are isolation-safe). */
|