mandala-computer-mcp 0.11.0 → 0.13.0
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 +159 -39
- package/dist/api.d.ts +9 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +15 -4
- package/dist/api.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/credits.d.ts +187 -0
- package/dist/credits.d.ts.map +1 -0
- package/dist/credits.js +119 -0
- package/dist/credits.js.map +1 -0
- package/dist/errors.d.ts +92 -26
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +206 -35
- package/dist/errors.js.map +1 -1
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +30 -8
- package/dist/format.js.map +1 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +82 -8
- package/dist/http.js.map +1 -1
- package/dist/limits.d.ts +2 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +2 -0
- package/dist/limits.js.map +1 -1
- package/dist/paths.d.ts +42 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +46 -0
- package/dist/paths.js.map +1 -1
- package/dist/poll.d.ts +1 -1
- package/dist/poll.js +1 -1
- package/dist/server.d.ts +41 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +129 -5
- package/dist/server.js.map +1 -1
- package/dist/session.d.ts +20 -4
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +5 -0
- package/dist/session.js.map +1 -1
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +11 -1
- package/dist/stdio.js.map +1 -1
- package/dist/tool-filters.d.ts +3 -2
- package/dist/tool-filters.d.ts.map +1 -1
- package/dist/tool-filters.js +3 -1
- package/dist/tool-filters.js.map +1 -1
- package/dist/tools/account.d.ts.map +1 -1
- package/dist/tools/account.js +10 -3
- package/dist/tools/account.js.map +1 -1
- package/dist/tools/activities.d.ts.map +1 -1
- package/dist/tools/activities.js +4 -0
- package/dist/tools/activities.js.map +1 -1
- package/dist/tools/agent.d.ts +12 -4
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +292 -132
- package/dist/tools/agent.js.map +1 -1
- package/dist/tools/chat.d.ts +11 -2
- package/dist/tools/chat.d.ts.map +1 -1
- package/dist/tools/chat.js +19 -9
- package/dist/tools/chat.js.map +1 -1
- package/dist/tools/computers.d.ts.map +1 -1
- package/dist/tools/computers.js +92 -11
- package/dist/tools/computers.js.map +1 -1
- package/dist/tools/credits.d.ts +9 -0
- package/dist/tools/credits.d.ts.map +1 -0
- package/dist/tools/credits.js +53 -0
- package/dist/tools/credits.js.map +1 -0
- package/dist/tools/guest.d.ts.map +1 -1
- package/dist/tools/guest.js +6 -7
- package/dist/tools/guest.js.map +1 -1
- package/dist/tools/input.d.ts.map +1 -1
- package/dist/tools/input.js +51 -18
- package/dist/tools/input.js.map +1 -1
- package/dist/tools/operations.js +2 -2
- package/dist/tools/operations.js.map +1 -1
- package/dist/tools/publicurls.d.ts +3 -0
- package/dist/tools/publicurls.d.ts.map +1 -0
- package/dist/tools/publicurls.js +287 -0
- package/dist/tools/publicurls.js.map +1 -0
- package/dist/tools/snapshots.d.ts.map +1 -1
- package/dist/tools/snapshots.js +1 -0
- package/dist/tools/snapshots.js.map +1 -1
- package/dist/tools/ssh.d.ts.map +1 -1
- package/dist/tools/ssh.js +4 -2
- package/dist/tools/ssh.js.map +1 -1
- package/dist/tools/webhooks.d.ts.map +1 -1
- package/dist/tools/webhooks.js +32 -23
- package/dist/tools/webhooks.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/poll.js
CHANGED
|
@@ -80,7 +80,7 @@ export const HEARTBEAT_MS = 10_000;
|
|
|
80
80
|
* written to give it. Observed, not theorised — a live capture took 107s and
|
|
81
81
|
* was cancelled at 60 (OPL-4579), and `run_agent` had the same defect before
|
|
82
82
|
* OPL-4419, where a twenty-step run was cancelled mid-way while still billing
|
|
83
|
-
* the caller's own
|
|
83
|
+
* the caller's own model-provider key.
|
|
84
84
|
*
|
|
85
85
|
* IT IS NOT SUFFICIENT ON ITS OWN and no description may claim it is.
|
|
86
86
|
* protocol.js reads `options?.resetTimeoutOnProgress ?? false`, so the reset
|
package/dist/server.d.ts
CHANGED
|
@@ -1,10 +1,51 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { type JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { z } from 'zod';
|
|
2
4
|
import { type SessionConfig } from './session.js';
|
|
3
5
|
import { type ToolFilters } from './tool-filters.js';
|
|
4
6
|
import type { ToolOptions } from './tools/types.js';
|
|
5
7
|
import { SERVER_VERSION } from './version.js';
|
|
6
8
|
export { SERVER_VERSION };
|
|
7
9
|
export declare const SERVER_NAME = "mandala-computer";
|
|
10
|
+
/**
|
|
11
|
+
* Whether a session built from this config would offer run_agent on the
|
|
12
|
+
* account's AI credits, if `GET /credits` said they could pay (OPL-5866) — and
|
|
13
|
+
* so whether that read is worth making at all. Not with a model key, which
|
|
14
|
+
* always wins, and not when the filters withhold run_agent anyway.
|
|
15
|
+
*/
|
|
16
|
+
export declare function offersFundedAgent(cfg: ToolFilters & {
|
|
17
|
+
modelKey?: string;
|
|
18
|
+
}): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* A tool's input schema, made to refuse any key it does not declare.
|
|
21
|
+
*
|
|
22
|
+
* The SDK accepts either a field map or a Zod schema. A field map becomes an
|
|
23
|
+
* object that strips unknown keys, and so does a `z.object` without
|
|
24
|
+
* `.strict()`: the listed JSON Schema still says `additionalProperties: false`,
|
|
25
|
+
* but the call goes ahead with the unknown key silently dropped. That turned a
|
|
26
|
+
* misspelt `workspace_id` into a secret stored account-wide, a misspelt
|
|
27
|
+
* `resume_only` into a full start, and a misspelt flag on a delete into a
|
|
28
|
+
* delete. Every schema leaves here strict.
|
|
29
|
+
*
|
|
30
|
+
* Anything that cannot be made strict here is refused at registration, so a
|
|
31
|
+
* tool added later cannot reintroduce the stripping by its shape: a schema that
|
|
32
|
+
* is not an object, one that passes unknown keys through or has a catch-all,
|
|
33
|
+
* and an object wrapped in a refinement whose inner object is not strict
|
|
34
|
+
* already (a refinement's inner object cannot be replaced without losing it).
|
|
35
|
+
*/
|
|
36
|
+
export declare function strictInput(name: string, schema: unknown): z.ZodTypeAny;
|
|
37
|
+
/**
|
|
38
|
+
* The refusal for a `tools/call` whose arguments carry an own `__proto__` key,
|
|
39
|
+
* or `undefined` for any other message.
|
|
40
|
+
*
|
|
41
|
+
* The one undeclared argument {@link strictInput} never sees: the SDK parses
|
|
42
|
+
* the request envelope before any tool schema runs, and that parse drops a
|
|
43
|
+
* top-level `__proto__` key without a word, so a call carrying one went ahead
|
|
44
|
+
* as though it had not (Codex, round 5 on #213). Refused here, before the SDK,
|
|
45
|
+
* in the words the SDK uses for every other unknown argument. Only for a tool
|
|
46
|
+
* this session registers: anything else gets the SDK's own answer.
|
|
47
|
+
*/
|
|
48
|
+
export declare function protoKeyRefusal(message: JSONRPCMessage, registered: ReadonlySet<string>): JSONRPCMessage | undefined;
|
|
8
49
|
export type ServerConfig = SessionConfig & ToolFilters & Partial<ToolOptions> & {
|
|
9
50
|
/** Internal HTTP hook: hold a session active for the real tool callback lifetime. */
|
|
10
51
|
activity?: () => () => void;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAGL,KAAK,cAAc,EAIpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAW,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,KAAK,WAAW,EAAc,MAAM,mBAAmB,CAAC;AAqBjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,eAAO,MAAM,WAAW,qBAAqB,CAAC;AA6C9C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAEnF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC,UAAU,CAsBvE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,GAC9B,cAAc,GAAG,SAAS,CAsB5B;AAED,MAAM,MAAM,YAAY,GAAG,aAAa,GACtC,WAAW,GACX,OAAO,CAAC,WAAW,CAAC,GAAG;IACrB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,MAAM,IAAI,CAAC;CAC7B,CAAC;AAEJ;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,YAAY,GAAG,SAAS,CAyHzD"}
|
package/dist/server.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { z } from 'zod';
|
|
3
4
|
import { Session } from './session.js';
|
|
4
5
|
import { toolFilter } from './tool-filters.js';
|
|
5
6
|
import { registerAccount } from './tools/account.js';
|
|
6
7
|
import { registerActivities } from './tools/activities.js';
|
|
7
|
-
import { registerAgent } from './tools/agent.js';
|
|
8
|
+
import { RUN_AGENT_ANNOTATIONS, registerAgent } from './tools/agent.js';
|
|
8
9
|
import { registerArtifacts } from './tools/artifacts.js';
|
|
9
10
|
import { registerChat } from './tools/chat.js';
|
|
10
11
|
import { registerComputers } from './tools/computers.js';
|
|
12
|
+
import { registerCredits } from './tools/credits.js';
|
|
11
13
|
import { registerDirectory } from './tools/directory.js';
|
|
12
14
|
import { registerEvents } from './tools/events.js';
|
|
13
15
|
import { registerExecutions } from './tools/executions.js';
|
|
14
16
|
import { registerGuest } from './tools/guest.js';
|
|
15
17
|
import { registerInput } from './tools/input.js';
|
|
16
18
|
import { registerOperations } from './tools/operations.js';
|
|
19
|
+
import { registerPublicUrls } from './tools/publicurls.js';
|
|
17
20
|
import { registerResults } from './tools/results.js';
|
|
18
21
|
import { registerSecrets } from './tools/secrets.js';
|
|
19
22
|
import { registerSignals } from './tools/signals.js';
|
|
@@ -41,10 +44,10 @@ const instructions = (lifecycle) => `Mandala Computer gives you a real Linux des
|
|
|
41
44
|
|
|
42
45
|
How to work with one:
|
|
43
46
|
|
|
44
|
-
1. ${lifecycle ? 'use_computer (or create_computer) binds' : 'use_computer binds'} a machine to this session.
|
|
47
|
+
1. ${lifecycle ? 'use_computer (or create_computer) binds' : 'use_computer binds'} a machine to this session. Most computer tools can then leave computer_id out; workspace moves require it explicitly.
|
|
45
48
|
2. wait_for_computer with until="guest" before the first screenshot or exec. A computer that reports "running" is a VM the hypervisor has started; the desktop inside it comes up seconds later.
|
|
46
49
|
3. screenshot, look, act, screenshot again. The desktop does not tell you whether a click landed — the only way to know is to look. Take a fresh screenshot after anything you expect to change the screen.
|
|
47
|
-
4. Coordinates are the pixels of the full-size
|
|
50
|
+
4. Coordinates are the pixels of the full-size capture. Use the capture size returned with screenshot; it can differ from the computer record's "resolution". To crop a frame you measured, pass its capture name with region. If it has expired, take a new screenshot and remeasure the region.
|
|
48
51
|
|
|
49
52
|
Things that are true here and are not obvious:
|
|
50
53
|
|
|
@@ -55,7 +58,7 @@ Things that are true here and are not obvious:
|
|
|
55
58
|
- list_windows tells you what is on the screen as data. It is how you distinguish an application that failed to start from one that has not painted yet, which a screenshot alone cannot do.
|
|
56
59
|
- A computer suspends itself when nobody uses it — 30 minutes by default. Input, exec and file transfers all count as use and resume it. Screenshots deliberately do not, so a loop that only watches can see its own machine go down.
|
|
57
60
|
- Who you are is checked again while a call is in flight, not only when it starts, so a long call can be refused after part of its work is already done. A 401 or a 403 means the credential or the role behind it stopped being accepted: re-authenticate, or say what was refused. Do not resend it, and never resend one that creates, starts, moves, writes or deletes without first checking what took effect. A 402 is the plan as it stands now rather than a fault on the computer, and waiting does not change it. Any of the three can arrive with completed work attached — read that before deciding what is left to do.
|
|
58
|
-
- A 409 is not one thing, and retrying blindly is how a turn gets burned.
|
|
61
|
+
- A 409 is not one thing, and retrying blindly is how a turn gets burned. Some describe a passing state and clear on their own — a guest still booting, a guest agent busy with another call — and the answer says so. The rest describe a DECISION about what you asked for — a size the host cannot run, a computer that has to be stopped first, a label already taken — and those answer the same way forever. A 409 that does not say it will clear is one of those: read the message, which usually says what to do instead, rather than sending it again. A 400 never clears.
|
|
59
62
|
- Growing a computer past what its host can run is the refusal worth knowing by name: update_computer says a move is possible, and move_computer is how you take that up. It moves the machine to different hardware and copies its disk, so say what it costs before you call it.`;
|
|
60
63
|
const filteredInstructions = `Mandala Computer gives you access to a Linux desktop in the cloud.
|
|
61
64
|
|
|
@@ -63,7 +66,95 @@ This session exposes a filtered set of tools. Use only the tools in its tool lis
|
|
|
63
66
|
|
|
64
67
|
Read each available tool's description before calling it. Read-only access follows the tool's readOnlyHint annotation: a read that can resume or bill a computer is not read-only. A running computer still costs money, and passive observation does not prevent idle suspension.
|
|
65
68
|
|
|
66
|
-
Who you are is checked again while a call is in flight. A 401 or 403 means the credential or role stopped being accepted; a 402 means the current plan refuses the work. Do not resend these calls. Inspect any completed work attached before deciding what remains. A 409 may describe either a temporary condition or a decision that will not change on retry; read its message. A 400 never clears.`;
|
|
69
|
+
Who you are is checked again while a call is in flight. A 401 or 403 means the credential or role stopped being accepted; a 402 means the current plan refuses the work. Do not resend these calls. Inspect any completed work attached before deciding what remains. A 409 may describe either a temporary condition or a decision that will not change on retry; read its message, and treat one that does not say it will clear as one that will not. A 400 never clears.`;
|
|
70
|
+
/**
|
|
71
|
+
* Whether a session built from this config would offer run_agent on the
|
|
72
|
+
* account's AI credits, if `GET /credits` said they could pay (OPL-5866) — and
|
|
73
|
+
* so whether that read is worth making at all. Not with a model key, which
|
|
74
|
+
* always wins, and not when the filters withhold run_agent anyway.
|
|
75
|
+
*/
|
|
76
|
+
export function offersFundedAgent(cfg) {
|
|
77
|
+
return !cfg.modelKey && toolFilter(cfg).allows('run_agent', RUN_AGENT_ANNOTATIONS);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A tool's input schema, made to refuse any key it does not declare.
|
|
81
|
+
*
|
|
82
|
+
* The SDK accepts either a field map or a Zod schema. A field map becomes an
|
|
83
|
+
* object that strips unknown keys, and so does a `z.object` without
|
|
84
|
+
* `.strict()`: the listed JSON Schema still says `additionalProperties: false`,
|
|
85
|
+
* but the call goes ahead with the unknown key silently dropped. That turned a
|
|
86
|
+
* misspelt `workspace_id` into a secret stored account-wide, a misspelt
|
|
87
|
+
* `resume_only` into a full start, and a misspelt flag on a delete into a
|
|
88
|
+
* delete. Every schema leaves here strict.
|
|
89
|
+
*
|
|
90
|
+
* Anything that cannot be made strict here is refused at registration, so a
|
|
91
|
+
* tool added later cannot reintroduce the stripping by its shape: a schema that
|
|
92
|
+
* is not an object, one that passes unknown keys through or has a catch-all,
|
|
93
|
+
* and an object wrapped in a refinement whose inner object is not strict
|
|
94
|
+
* already (a refinement's inner object cannot be replaced without losing it).
|
|
95
|
+
*/
|
|
96
|
+
export function strictInput(name, schema) {
|
|
97
|
+
if (schema === undefined) {
|
|
98
|
+
throw new Error(`Tool ${name} declares no input schema; give it one, even if empty.`);
|
|
99
|
+
}
|
|
100
|
+
if (!(schema instanceof z.ZodType)) {
|
|
101
|
+
return z.object(schema).strict();
|
|
102
|
+
}
|
|
103
|
+
if (schema instanceof z.ZodObject) {
|
|
104
|
+
if (!(schema._def.catchall instanceof z.ZodNever)) {
|
|
105
|
+
throw new Error(`Tool ${name}'s input schema has a catch-all; it must refuse unknown keys.`);
|
|
106
|
+
}
|
|
107
|
+
if (schema._def.unknownKeys === 'strict')
|
|
108
|
+
return schema;
|
|
109
|
+
if (schema._def.unknownKeys === 'passthrough') {
|
|
110
|
+
throw new Error(`Tool ${name}'s input schema passes unknown keys through.`);
|
|
111
|
+
}
|
|
112
|
+
return schema.strict();
|
|
113
|
+
}
|
|
114
|
+
if (schema instanceof z.ZodEffects) {
|
|
115
|
+
const inner = schema.innerType();
|
|
116
|
+
if (inner instanceof z.ZodObject && inner._def.unknownKeys === 'strict')
|
|
117
|
+
return schema;
|
|
118
|
+
}
|
|
119
|
+
throw new Error(`Tool ${name}'s input schema must be a strict object.`);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The refusal for a `tools/call` whose arguments carry an own `__proto__` key,
|
|
123
|
+
* or `undefined` for any other message.
|
|
124
|
+
*
|
|
125
|
+
* The one undeclared argument {@link strictInput} never sees: the SDK parses
|
|
126
|
+
* the request envelope before any tool schema runs, and that parse drops a
|
|
127
|
+
* top-level `__proto__` key without a word, so a call carrying one went ahead
|
|
128
|
+
* as though it had not (Codex, round 5 on #213). Refused here, before the SDK,
|
|
129
|
+
* in the words the SDK uses for every other unknown argument. Only for a tool
|
|
130
|
+
* this session registers: anything else gets the SDK's own answer.
|
|
131
|
+
*/
|
|
132
|
+
export function protoKeyRefusal(message, registered) {
|
|
133
|
+
const m = message;
|
|
134
|
+
if (m.method !== 'tools/call' || (typeof m.id !== 'string' && typeof m.id !== 'number'))
|
|
135
|
+
return undefined;
|
|
136
|
+
const params = m.params;
|
|
137
|
+
if (!params || typeof params !== 'object')
|
|
138
|
+
return undefined;
|
|
139
|
+
const { name, arguments: args } = params;
|
|
140
|
+
if (typeof name !== 'string' || !registered.has(name))
|
|
141
|
+
return undefined;
|
|
142
|
+
if (!args || typeof args !== 'object' || !Object.hasOwn(args, '__proto__'))
|
|
143
|
+
return undefined;
|
|
144
|
+
return {
|
|
145
|
+
jsonrpc: '2.0',
|
|
146
|
+
id: m.id,
|
|
147
|
+
result: {
|
|
148
|
+
content: [
|
|
149
|
+
{
|
|
150
|
+
type: 'text',
|
|
151
|
+
text: `MCP error ${ErrorCode.InvalidParams}: Input validation error: Invalid arguments for tool ${name}: Unrecognized key(s) in object: '__proto__'`,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
isError: true,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
67
158
|
/**
|
|
68
159
|
* One MCP server over one account's API key.
|
|
69
160
|
*
|
|
@@ -85,10 +176,17 @@ export function createServer(cfg) {
|
|
|
85
176
|
// Withheld tools never reach the SDK registry or acquire an activity lease.
|
|
86
177
|
const register = server.registerTool.bind(server);
|
|
87
178
|
let registered = false;
|
|
179
|
+
const names = new Set();
|
|
88
180
|
server.registerTool = ((...args) => {
|
|
89
181
|
const [name, config] = args;
|
|
90
182
|
if (!filter.allows(name, config.annotations))
|
|
91
183
|
return;
|
|
184
|
+
// Every tool refuses an argument it does not know (OPL-5975). Done here,
|
|
185
|
+
// once, rather than trusted to each registration, because the SDK turns a
|
|
186
|
+
// plain field map into an object that STRIPS unknown keys while the listed
|
|
187
|
+
// schema says `additionalProperties: false` — so a misspelt flag was
|
|
188
|
+
// dropped and the call went ahead without it.
|
|
189
|
+
args[1] = { ...config, inputSchema: strictInput(name, config.inputSchema) };
|
|
92
190
|
if (cfg.activity) {
|
|
93
191
|
const handlerIndex = args.length - 1;
|
|
94
192
|
const handler = args[handlerIndex];
|
|
@@ -108,6 +206,7 @@ export function createServer(cfg) {
|
|
|
108
206
|
}
|
|
109
207
|
const tool = register(...args);
|
|
110
208
|
registered = true;
|
|
209
|
+
names.add(name);
|
|
111
210
|
return tool;
|
|
112
211
|
});
|
|
113
212
|
registerAccount(server, session, opts);
|
|
@@ -123,7 +222,9 @@ export function createServer(cfg) {
|
|
|
123
222
|
registerEvents(server, session, opts);
|
|
124
223
|
registerWebhooks(server, session, opts);
|
|
125
224
|
registerSSH(server, session, opts);
|
|
225
|
+
registerPublicUrls(server, session, opts);
|
|
126
226
|
registerSecrets(server, session, opts);
|
|
227
|
+
registerCredits(server, session, opts);
|
|
127
228
|
registerAgent(server, session, opts);
|
|
128
229
|
registerDirectory(server, session, opts);
|
|
129
230
|
registerActivities(server, session, opts);
|
|
@@ -137,6 +238,29 @@ export function createServer(cfg) {
|
|
|
137
238
|
throw new McpError(ErrorCode.InvalidParams, 'No tools are available in this session');
|
|
138
239
|
});
|
|
139
240
|
}
|
|
241
|
+
// A top-level `__proto__` argument is dropped by the SDK's own parse of the
|
|
242
|
+
// request, before any tool schema can refuse it, so it is refused on the way
|
|
243
|
+
// in (see protoKeyRefusal). Wrapped as the transport starts, which is after
|
|
244
|
+
// the server has installed its message handler and before any message.
|
|
245
|
+
const connect = server.connect.bind(server);
|
|
246
|
+
server.connect = (transport) => {
|
|
247
|
+
const start = transport.start.bind(transport);
|
|
248
|
+
transport.start = async () => {
|
|
249
|
+
const deliver = transport.onmessage;
|
|
250
|
+
if (deliver) {
|
|
251
|
+
transport.onmessage = (message, extra) => {
|
|
252
|
+
const refusal = protoKeyRefusal(message, names);
|
|
253
|
+
if (refusal) {
|
|
254
|
+
transport.send(refusal).catch(() => undefined);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
deliver(message, extra);
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return start();
|
|
261
|
+
};
|
|
262
|
+
return connect(transport);
|
|
263
|
+
};
|
|
140
264
|
// The event sockets outlive every tool call by design (OPL-3926), so nothing
|
|
141
265
|
// in a tool can be the thing that closes them. This is the end of the
|
|
142
266
|
// session, which is the lifetime they actually have — without it an HTTP
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EACL,qBAAqB,EACrB,SAAS,EAET,sBAAsB,EACtB,QAAQ,GAET,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAsB,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAoB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,kBA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,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;oBACvC,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;oBAChD,IAAI,OAAO,EAAE,CAAC;wBACZ,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;wBAC/C,OAAO;oBACT,CAAC;oBACD,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAC1B,CAAC,CAAC;YACJ,CAAC;YACD,OAAO,KAAK,EAAE,CAAC;QACjB,CAAC,CAAC;QACF,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC,CAAC;IAEF,6EAA6E;IAC7E,sEAAsE;IACtE,yEAAyE;IACzE,yEAAyE;IACzE,kDAAkD;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;IACrC,MAAM,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;QAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC1B,MAAM,EAAE,EAAE,CAAC;IACb,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/session.d.ts
CHANGED
|
@@ -6,13 +6,27 @@ export type SessionConfig = {
|
|
|
6
6
|
/** A computer bound at startup, so a single-machine setup never calls use_computer. */
|
|
7
7
|
computerId?: string;
|
|
8
8
|
/**
|
|
9
|
-
* The caller's
|
|
9
|
+
* The caller's model-provider key, for the hosted agent routes.
|
|
10
10
|
*
|
|
11
|
-
* Absent is the ordinary case and is not an error:
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Absent is the ordinary case and is not an error: `run_agent_chat` is not
|
|
12
|
+
* registered, and `run_agent` is registered only when {@link funded} says the
|
|
13
|
+
* account's credits can pay — rather than offered and failing on use. A tool
|
|
14
|
+
* a model can see is a tool it will try.
|
|
14
15
|
*/
|
|
15
16
|
modelKey?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether this account's AI credits can pay for a run (OPL-5866): `GET
|
|
19
|
+
* /credits` answered, on this session's own key, an account that is not
|
|
20
|
+
* frozen with enough available for a run's first model call.
|
|
21
|
+
*
|
|
22
|
+
* Consulted only when there is no `modelKey`, and then `run_agent` is
|
|
23
|
+
* registered to run on credits; `run_agent_chat` never is. Decided before the
|
|
24
|
+
* session is built — once at startup over stdio, per session at initialize
|
|
25
|
+
* over HTTP — and never from anything but that read: an embedder calling
|
|
26
|
+
* createServer directly makes the same check (see `fundedAccount`) or leaves
|
|
27
|
+
* this unset.
|
|
28
|
+
*/
|
|
29
|
+
funded?: boolean;
|
|
16
30
|
/**
|
|
17
31
|
* How the event stream opens a websocket. Defaults to undici's.
|
|
18
32
|
*
|
|
@@ -64,6 +78,8 @@ export declare class Session {
|
|
|
64
78
|
*/
|
|
65
79
|
readonly events: EventHub;
|
|
66
80
|
readonly modelKey?: string;
|
|
81
|
+
/** See {@link SessionConfig.funded}. False whenever a model key is present. */
|
|
82
|
+
readonly funded: boolean;
|
|
67
83
|
/** See {@link SessionConfig.defaultWorkspace}. */
|
|
68
84
|
readonly defaultWorkspace?: {
|
|
69
85
|
id: string;
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,UAAU,EAAoB,MAAM,UAAU,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["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AI,MAAM,GAAG,SAAS,CAEhC;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAKnD,qFAAqF;IACrF,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAI5C;;;;;;OAMG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAQ1C,oDAAoD;IACpD,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQtC,kFAAkF;IAClF,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAO3F,oFAAoF;IACpF,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IA8BhC,oEAAoE;IACpE,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAI7D;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;CAUnC"}
|
package/dist/session.js
CHANGED
|
@@ -20,6 +20,8 @@ export class Session {
|
|
|
20
20
|
*/
|
|
21
21
|
events;
|
|
22
22
|
modelKey;
|
|
23
|
+
/** See {@link SessionConfig.funded}. False whenever a model key is present. */
|
|
24
|
+
funded;
|
|
23
25
|
/** See {@link SessionConfig.defaultWorkspace}. */
|
|
24
26
|
defaultWorkspace;
|
|
25
27
|
/** See {@link SessionConfig.defaultWorkspaceUnreadable}. */
|
|
@@ -37,6 +39,9 @@ export class Session {
|
|
|
37
39
|
this.api = new Api(cfg.apiKey, cfg.baseUrl ?? DEFAULT_BASE_URL, undefined, cfg.platform);
|
|
38
40
|
this.events = new EventHub(this.api, cfg.webSocket);
|
|
39
41
|
this.modelKey = cfg.modelKey;
|
|
42
|
+
// A model key always wins, as it does on the platform: a run that carries
|
|
43
|
+
// one is the caller's own, and credits are never spent on it.
|
|
44
|
+
this.funded = !cfg.modelKey && cfg.funded === true;
|
|
40
45
|
this.defaultWorkspace = cfg.defaultWorkspace;
|
|
41
46
|
this.defaultWorkspaceUnreadable = cfg.defaultWorkspaceUnreadable;
|
|
42
47
|
this.#current = id(cfg.computerId);
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAmB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAA2B,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAmB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAA2B,MAAM,aAAa,CAAC;AA0DhE;;;;;;;GAOG;AACH,MAAM,OAAO,OAAO;IACT,GAAG,CAAM;IAClB;;;;;;OAMG;IACM,MAAM,CAAW;IACjB,QAAQ,CAAU;IAC3B,+EAA+E;IACtE,MAAM,CAAU;IACzB,kDAAkD;IACzC,gBAAgB,CAAuC;IAChE,4DAA4D;IACnD,0BAA0B,CAAU;IAC7C,QAAQ,CAAU;IAClB,+EAA+E;IAC/E,OAAO,CAAU;IACjB,iFAAiF;IACxE,kBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxD,6EAA6E;IACpE,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IACpD,gFAAgF;IAChF,MAAM,CAAU,uBAAuB,GAAG,GAAG,CAAC;IAE9C,YAAY,GAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,GA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C7C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,YAAY,CACpB,4EAA4E;gBAC1E,mEAAmE,CACtE,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;;AAGH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,EAAE,CAAC,KAAyB;IACnC,MAAM,CAAC,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IACxB,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3B,CAAC"}
|
package/dist/stdio.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmC,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEjF,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/F;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,GAAG,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwDnE"}
|
package/dist/stdio.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
2
2
|
import { resolveCredentials, resolveWorkspaceDefault } from './credentials.js';
|
|
3
|
-
import {
|
|
3
|
+
import { fundedAccount } from './credits.js';
|
|
4
|
+
import { createServer, offersFundedAgent } from './server.js';
|
|
4
5
|
/**
|
|
5
6
|
* The local install: one process, one key, spawned by the MCP client.
|
|
6
7
|
*
|
|
@@ -22,6 +23,15 @@ export async function runStdio(cfg = {}) {
|
|
|
22
23
|
};
|
|
23
24
|
if (defaults?.note)
|
|
24
25
|
console.error(`mandala-computer-mcp: ${defaults.note}`);
|
|
26
|
+
// Whether run_agent runs on the account's AI credits, asked once, here: one
|
|
27
|
+
// process is one key and one session, so startup IS the session's start. A
|
|
28
|
+
// read that fails, or a key the ledger refuses, leaves run_agent out until
|
|
29
|
+
// the next start — the same as an account with nothing to spend. Computed,
|
|
30
|
+
// never taken from the config, so nothing but that read can turn it on.
|
|
31
|
+
resolved.funded =
|
|
32
|
+
offersFundedAgent(resolved) && (await fundedAccount(credentials.apiKey, credentials.baseUrl));
|
|
33
|
+
if (resolved.funded)
|
|
34
|
+
console.error("mandala-computer-mcp: no MANDALA_MODEL_KEY, so run_agent runs on this account's AI credits");
|
|
25
35
|
const server = createServer(resolved);
|
|
26
36
|
const transport = new StdioServerTransport();
|
|
27
37
|
await server.connect(transport);
|
package/dist/stdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAqB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAqB,MAAM,aAAa,CAAC;AAIjF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,MAAmB,EAAE;IACl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,yEAAyE;IACzE,+EAA+E;IAC/E,4EAA4E;IAC5E,2EAA2E;IAC3E,2EAA2E;IAC3E,+DAA+D;IAC/D,EAAE;IACF,8EAA8E;IAC9E,4EAA4E;IAC5E,yEAAyE;IACzE,0EAA0E;IAC1E,qBAAqB;IACrB,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC3D,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtC,OAAO,CAAC,KAAK,CAAC,mCAAmC,IAAI,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACxF,IAAI,QAAQ,EAAE,SAAS;QACrB,OAAO,CAAC,KAAK,CACX,2DAA2D,QAAQ,CAAC,SAAS,CAAC,IAAI,KAAK,QAAQ,CAAC,SAAS,CAAC,EAAE,gCAAgC,CAC7I,CAAC;AACN,CAAC"}
|
package/dist/tool-filters.d.ts
CHANGED
|
@@ -12,13 +12,14 @@ export declare const TOOL_TAGS: {
|
|
|
12
12
|
readonly files: readonly ["list_directory", "read_file", "write_file", "wait_for_file_change"];
|
|
13
13
|
readonly guest: readonly ["exec", "exec_poll", "exec_kill", "open_url", "list_windows", "window_action", "read_clipboard", "write_clipboard"];
|
|
14
14
|
readonly input: readonly ["screenshot", "click", "type_text", "paste_text", "press_key", "scroll", "drag", "move_mouse", "mouse_button", "cursor_position", "wait"];
|
|
15
|
-
readonly lifecycle: readonly ["create_computer", "start_computer", "stop_computer", "suspend_computer", "restart_computer", "update_computer", "clone_computer", "delete_computer", "move_computer", "list_moves", "get_operation", "list_operations", "wait_for_operation"];
|
|
15
|
+
readonly lifecycle: readonly ["create_computer", "start_computer", "stop_computer", "suspend_computer", "restart_computer", "update_computer", "clone_computer", "delete_computer", "move_computer_to_workspace", "move_computer", "list_moves", "get_operation", "list_operations", "wait_for_operation"];
|
|
16
16
|
readonly results: readonly ["get_activity_results", "retain_execution_output", "get_result", "read_result_output", "delete_result"];
|
|
17
17
|
readonly snapshots: readonly ["list_snapshots", "snapshot_holdings", "create_snapshot", "restore_snapshot", "clone_snapshot", "snapshot_schedule", "get_retention", "delete_snapshot"];
|
|
18
18
|
readonly templates: readonly ["list_templates", "get_template_schema", "check_template", "publish_template", "get_template", "retire_template", "build_template", "list_builds", "get_build", "watch_build"];
|
|
19
19
|
readonly secrets: readonly ["get_computer_secrets", "set_computer_secrets", "list_secrets", "get_secret", "create_secret", "set_secret", "replace_secret", "delete_secret"];
|
|
20
20
|
readonly ssh: readonly ["list_ssh_keys", "add_ssh_key", "remove_ssh_key", "get_computer_ssh", "set_computer_ssh"];
|
|
21
|
-
readonly
|
|
21
|
+
readonly public_urls: readonly ["list_public_urls", "create_public_url", "update_public_url", "delete_public_url"];
|
|
22
|
+
readonly usage: readonly ["get_usage", "get_credits"];
|
|
22
23
|
readonly webhooks: readonly ["list_webhooks", "create_webhook", "get_webhook", "update_webhook", "rotate_webhook_secret", "test_webhook", "list_webhook_deliveries", "delete_webhook"];
|
|
23
24
|
};
|
|
24
25
|
export type ToolTag = keyof typeof TOOL_TAGS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-filters.d.ts","sourceRoot":"","sources":["../src/tool-filters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,sEAAsE;AACtE,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"tool-filters.d.ts","sourceRoot":"","sources":["../src/tool-filters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,sEAAsE;AACtE,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;CAsHZ,CAAC;AAEX,MAAM,MAAM,OAAO,GAAG,MAAM,OAAO,SAAS,CAAC;AAC7C,MAAM,MAAM,WAAW,GAAG;IACxB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gFAAgF;IAChF,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAoC,OAAO,EAAE,CAAC;AAcrE,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,EAAE,CAEhE;AAED,2FAA2F;AAC3F,wBAAgB,UAAU,CAAC,GAAG,EAAE,WAAW,GAAG;IAC5C,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;CAClE,CAmBA"}
|
package/dist/tool-filters.js
CHANGED
|
@@ -58,6 +58,7 @@ export const TOOL_TAGS = {
|
|
|
58
58
|
'update_computer',
|
|
59
59
|
'clone_computer',
|
|
60
60
|
'delete_computer',
|
|
61
|
+
'move_computer_to_workspace',
|
|
61
62
|
'move_computer',
|
|
62
63
|
'list_moves',
|
|
63
64
|
'get_operation',
|
|
@@ -104,7 +105,8 @@ export const TOOL_TAGS = {
|
|
|
104
105
|
'delete_secret',
|
|
105
106
|
],
|
|
106
107
|
ssh: ['list_ssh_keys', 'add_ssh_key', 'remove_ssh_key', 'get_computer_ssh', 'set_computer_ssh'],
|
|
107
|
-
|
|
108
|
+
public_urls: ['list_public_urls', 'create_public_url', 'update_public_url', 'delete_public_url'],
|
|
109
|
+
usage: ['get_usage', 'get_credits'],
|
|
108
110
|
webhooks: [
|
|
109
111
|
'list_webhooks',
|
|
110
112
|
'create_webhook',
|
package/dist/tool-filters.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-filters.js","sourceRoot":"","sources":["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tB,yBAAyB;QACzB,YAAY;QACZ,oBAAoB;QACpB,eAAe;KAChB;IACD,SAAS,EAAE;QACT,gBAAgB;QAChB,mBAAmB;QACnB,iBAAiB;QACjB,kBAAkB;QAClB,gBAAgB;QAChB,mBAAmB;QACnB,eAAe;QACf,iBAAiB;KAClB;IACD,SAAS,EAAE;QACT,gBAAgB;QAChB,qBAAqB;QACrB,gBAAgB;QAChB,kBAAkB;QAClB,cAAc;QACd,iBAAiB;QACjB,gBAAgB;QAChB,aAAa;QACb,WAAW;QACX,aAAa;KACd;IACD,OAAO,EAAE;QACP,sBAAsB;QACtB,sBAAsB;QACtB,cAAc;QACd,YAAY;QACZ,eAAe;QACf,YAAY;QACZ,gBAAgB;QAChB,eAAe;KAChB;IACD,GAAG,EAAE,CAAC,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,CAAC;IAC/F,KAAK,EAAE,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-filters.js","sourceRoot":"","sources":["../src/tool-filters.ts"],"names":[],"mappings":"AAEA,sEAAsE;AACtE,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE;QACP,aAAa;QACb,QAAQ;QACR,eAAe;QACf,iBAAiB;QACjB,eAAe;QACf,wBAAwB;QACxB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;KACnB;IACD,KAAK,EAAE,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACtC,UAAU,EAAE,CAAC,iBAAiB,EAAE,cAAc,EAAE,sBAAsB,CAAC;IACvE,OAAO,EAAE,CAAC,cAAc,CAAC;IACzB,SAAS,EAAE,CAAC,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,CAAC;IACnF,SAAS,EAAE;QACT,gBAAgB;QAChB,cAAc;QACd,cAAc;QACd,mBAAmB;QACnB,iBAAiB;QACjB,YAAY;KACb;IACD,MAAM,EAAE,CAAC,gBAAgB,EAAE,aAAa,E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YAAY,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAS,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,MAAM,KAAK,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/D,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC;IACvC,OAAO;QACL,QAAQ,EAAE,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QACrC,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE;YAC5B,yEAAyE;YACzE,0DAA0D;YAC1D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,2BAA2B,CAAC,CAAC;YAChF,OAAO,CACL,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,IAAI,WAAW,EAAE,YAAY,KAAK,IAAI,CAAC,CAC1F,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/tools/account.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/tools/account.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAkJ5C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,EAAE,SA4Q7B,CAAC"}
|
package/dist/tools/account.js
CHANGED
|
@@ -122,6 +122,12 @@ const workspaceMember = z.object({
|
|
|
122
122
|
role: label,
|
|
123
123
|
accepted_at: z.string(),
|
|
124
124
|
suspended: z.boolean(),
|
|
125
|
+
// Waiting for a seat on this account, and unable to act on it until one is
|
|
126
|
+
// restored (platform OPL-5919). Independent of `suspended`, which is a
|
|
127
|
+
// sign-in suspension. Optional, as the SDKs read it, so a platform that
|
|
128
|
+
// predates it still lists members; one sent as anything but a boolean fails
|
|
129
|
+
// the listing rather than reading as false.
|
|
130
|
+
seat_suspended: z.boolean().optional(),
|
|
125
131
|
});
|
|
126
132
|
// What a workspace delete answers: the ack, and how many keys went with it.
|
|
127
133
|
const workspaceDeleted = z.object({ ok: z.literal(true), revoked_keys: count });
|
|
@@ -200,15 +206,16 @@ export const registerAccount = (server, session) => {
|
|
|
200
206
|
}));
|
|
201
207
|
server.registerTool('list_workspace_members', {
|
|
202
208
|
title: "List a workspace's members",
|
|
203
|
-
description: "The people who reach a workspace, oldest member first: user_id, email, name (null when unset), role, accepted_at and
|
|
209
|
+
description: "The people who reach a workspace, oldest member first: user_id, email, name (null when unset), role, accepted_at, suspended (a sign-in suspension: they cannot sign in anywhere) and seat_suspended (true while they wait for a seat on this account and cannot act on it; it returns to false when their seat is restored). Either flag, or both, can be true. Workspaces do not divide people — everybody on the account reaches every workspace at their account role — so this is the account's accepted members; invitations not yet accepted are left out. A key confined to a workspace is refused with 403, because the list is the whole account's: relay that rather than retrying, and use an account-wide key.",
|
|
204
210
|
inputSchema: z.object({ workspace_id: workspaceIdArg }).strict(),
|
|
205
211
|
annotations: readAnnotations,
|
|
206
212
|
}, ({ workspace_id }, extra) => metadataCall(async () => {
|
|
207
213
|
const data = metadata(z.array(workspaceMember), await session.api.json('GET', P.workspaceMembers(workspace_id), {
|
|
208
214
|
signal: extra.signal,
|
|
209
215
|
}));
|
|
216
|
+
const waiting = data.filter((m) => m.seat_suspended === true).length;
|
|
210
217
|
return said(data.length
|
|
211
|
-
? `${data.length} member${data.length === 1 ? '' : 's'} reach this workspace, oldest first.`
|
|
218
|
+
? `${data.length} member${data.length === 1 ? '' : 's'} reach this workspace, oldest first.${waiting ? ` ${waiting} of them ${waiting === 1 ? 'is' : 'are'} waiting for a seat (seat_suspended) and cannot act on the account until one is restored.` : ''}`
|
|
212
219
|
: 'No members reach this workspace.', data);
|
|
213
220
|
}));
|
|
214
221
|
// metadataCall was built for reads, and rebuilds every APIError as a plain
|
|
@@ -256,7 +263,7 @@ export const registerAccount = (server, session) => {
|
|
|
256
263
|
}));
|
|
257
264
|
server.registerTool('delete_workspace', {
|
|
258
265
|
title: 'Delete a workspace',
|
|
259
|
-
description: `Permanently delete a workspace. It REVOKES every API key confined to it, whoever holds it, in the same step: anything using one of those keys — a person's CI, another agent — is refused from its next request, and this cannot be undone. The answer says how many were revoked. Only an empty workspace can be deleted: one that still holds computers is refused
|
|
266
|
+
description: `Permanently delete a workspace. It REVOKES every API key confined to it, whoever holds it, in the same step: anything using one of those keys — a person's CI, another agent — is refused from its next request, and this cannot be undone. The answer says how many were revoked. Only an empty workspace can be deleted: one that still holds computers (counting one an unfinished workspace change is moving into it) or active secrets is refused with 409, saying how many, and nothing is deleted or revoked. To empty it, move its computers to another workspace with move_computer_to_workspace (or in the dashboard) or delete them, and delete its secrets with delete_secret, giving their workspace_id and current revision_id; then send this again. Say what is in it before moving or deleting anything to empty it. A 503 means the platform could not confirm it is empty: nothing was deleted, and it can be sent again shortly. Snapshots taken in it remain, and an account-wide key can still clone them. Needs confirm: true. ${OWNER_ACCOUNT_WIDE}`,
|
|
260
267
|
inputSchema: z
|
|
261
268
|
.object({
|
|
262
269
|
workspace_id: workspaceIdArg,
|