@thedeck/mcp 0.1.6 → 0.1.7
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/cli.js +10 -10
- package/dist/index.js +37 -13
- package/package.json +38 -38
package/dist/cli.js
CHANGED
|
@@ -331,18 +331,13 @@ var scenarioSchema = z.object({
|
|
|
331
331
|
expected: z.string().trim().min(1).max(2e3)
|
|
332
332
|
});
|
|
333
333
|
// ../shared/src/schemas/entry.ts
|
|
334
|
-
var ENTRY_UPLOAD_MAX_BYTES = 104857600;
|
|
335
334
|
var DEMO_MAX_BYTES = 209715200;
|
|
336
335
|
var SETUP_NOTES_MAX = 1e4;
|
|
337
336
|
var identityKindSchema = z.enum(["username", "tag"]);
|
|
338
|
-
var entrySourceSchema = z.
|
|
339
|
-
kind: z.literal("
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}), z.object({
|
|
343
|
-
kind: z.literal("repo"),
|
|
344
|
-
url: z.url({ protocol: /^https$/ })
|
|
345
|
-
})]);
|
|
337
|
+
var entrySourceSchema = z.object({
|
|
338
|
+
kind: z.literal("github"),
|
|
339
|
+
commitSha: z.string().regex(/^[0-9a-f]{40}([0-9a-f]{24})?$/)
|
|
340
|
+
});
|
|
346
341
|
var entryDemoSchema = z.object({
|
|
347
342
|
fileName: z.string().trim().min(1).max(255),
|
|
348
343
|
size: z.number().int().positive().max(DEMO_MAX_BYTES),
|
|
@@ -855,11 +850,13 @@ var isDeckErrorCode = (code) => DECK_ERROR_CODES.includes(code);
|
|
|
855
850
|
var DeckError = class extends Error {
|
|
856
851
|
code;
|
|
857
852
|
waitsOnPerson;
|
|
853
|
+
page;
|
|
858
854
|
constructor(code, message, options) {
|
|
859
855
|
super(message ?? code, options);
|
|
860
856
|
this.name = "DeckError";
|
|
861
857
|
this.code = code;
|
|
862
858
|
this.waitsOnPerson = options?.waitsOnPerson === true;
|
|
859
|
+
this.page = options?.page;
|
|
863
860
|
}
|
|
864
861
|
};
|
|
865
862
|
var toolCall = (name) => ({
|
|
@@ -1115,6 +1112,9 @@ async function readBody(res) {
|
|
|
1115
1112
|
throw new DeckError("UNAVAILABLE", `The Deck answered ${res.status} without JSON`, { cause: err });
|
|
1116
1113
|
}
|
|
1117
1114
|
}
|
|
1115
|
+
function deckPage(page, deckUrl) {
|
|
1116
|
+
return typeof page === "string" && URL.canParse(page) && new URL(page).origin === new URL(deckUrl).origin ? page : void 0;
|
|
1117
|
+
}
|
|
1118
1118
|
function createRemoteBackend(options) {
|
|
1119
1119
|
const fetchFn = options.fetchFn ?? fetch;
|
|
1120
1120
|
async function post(call, body, fresh) {
|
|
@@ -1139,7 +1139,7 @@ function createRemoteBackend(options) {
|
|
|
1139
1139
|
let res = await post(name, body, false);
|
|
1140
1140
|
if (res.status === 401) res = await post(name, body, true);
|
|
1141
1141
|
const json = await readBody(res);
|
|
1142
|
-
if (json.ok !== true) throw new DeckError(isDeckErrorCode(json.code) ? json.code : "UNAVAILABLE", typeof json.message === "string" ? json.message : `The Deck refused ${path} (${res.status})
|
|
1142
|
+
if (json.ok !== true) throw new DeckError(isDeckErrorCode(json.code) ? json.code : "UNAVAILABLE", typeof json.message === "string" ? json.message : `The Deck refused ${path} (${res.status})`, { page: deckPage(json.page, options.deckUrl) });
|
|
1143
1143
|
const parsed = output.safeParse(json.data);
|
|
1144
1144
|
if (!parsed.success) throw new DeckError("UNAVAILABLE", `The Deck's answer to ${path} did not match the tool contract`, { cause: parsed.error });
|
|
1145
1145
|
return parsed.data;
|
package/dist/index.js
CHANGED
|
@@ -349,18 +349,13 @@ var scenarioSchema = z.object({
|
|
|
349
349
|
expected: z.string().trim().min(1).max(2e3)
|
|
350
350
|
});
|
|
351
351
|
// ../shared/src/schemas/entry.ts
|
|
352
|
-
var ENTRY_UPLOAD_MAX_BYTES = 104857600;
|
|
353
352
|
var DEMO_MAX_BYTES = 209715200;
|
|
354
353
|
var SETUP_NOTES_MAX = 1e4;
|
|
355
354
|
var identityKindSchema = z.enum(["username", "tag"]);
|
|
356
|
-
var entrySourceSchema = z.
|
|
357
|
-
kind: z.literal("
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}), z.object({
|
|
361
|
-
kind: z.literal("repo"),
|
|
362
|
-
url: z.url({ protocol: /^https$/ })
|
|
363
|
-
})]);
|
|
355
|
+
var entrySourceSchema = z.object({
|
|
356
|
+
kind: z.literal("github"),
|
|
357
|
+
commitSha: z.string().regex(/^[0-9a-f]{40}([0-9a-f]{24})?$/)
|
|
358
|
+
});
|
|
364
359
|
var entryDemoSchema = z.object({
|
|
365
360
|
fileName: z.string().trim().min(1).max(255),
|
|
366
361
|
size: z.number().int().positive().max(DEMO_MAX_BYTES),
|
|
@@ -876,11 +871,13 @@ var isDeckErrorCode = (code) => DECK_ERROR_CODES.includes(code);
|
|
|
876
871
|
var DeckError = class extends Error {
|
|
877
872
|
code;
|
|
878
873
|
waitsOnPerson;
|
|
874
|
+
page;
|
|
879
875
|
constructor(code, message, options) {
|
|
880
876
|
super(message ?? code, options);
|
|
881
877
|
this.name = "DeckError";
|
|
882
878
|
this.code = code;
|
|
883
879
|
this.waitsOnPerson = options?.waitsOnPerson === true;
|
|
880
|
+
this.page = options?.page;
|
|
884
881
|
}
|
|
885
882
|
};
|
|
886
883
|
var toolCall = (name) => ({
|
|
@@ -1150,6 +1147,9 @@ async function readBody(res) {
|
|
|
1150
1147
|
throw new DeckError("UNAVAILABLE", `The Deck answered ${res.status} without JSON`, { cause: err });
|
|
1151
1148
|
}
|
|
1152
1149
|
}
|
|
1150
|
+
function deckPage(page, deckUrl) {
|
|
1151
|
+
return typeof page === "string" && URL.canParse(page) && new URL(page).origin === new URL(deckUrl).origin ? page : void 0;
|
|
1152
|
+
}
|
|
1153
1153
|
function createRemoteBackend(options) {
|
|
1154
1154
|
const fetchFn = options.fetchFn ?? fetch;
|
|
1155
1155
|
async function post(call, body, fresh) {
|
|
@@ -1174,7 +1174,7 @@ function createRemoteBackend(options) {
|
|
|
1174
1174
|
let res = await post(name, body, false);
|
|
1175
1175
|
if (res.status === 401) res = await post(name, body, true);
|
|
1176
1176
|
const json = await readBody(res);
|
|
1177
|
-
if (json.ok !== true) throw new DeckError(isDeckErrorCode(json.code) ? json.code : "UNAVAILABLE", typeof json.message === "string" ? json.message : `The Deck refused ${path} (${res.status})
|
|
1177
|
+
if (json.ok !== true) throw new DeckError(isDeckErrorCode(json.code) ? json.code : "UNAVAILABLE", typeof json.message === "string" ? json.message : `The Deck refused ${path} (${res.status})`, { page: deckPage(json.page, options.deckUrl) });
|
|
1178
1178
|
const parsed = output.safeParse(json.data);
|
|
1179
1179
|
if (!parsed.success) throw new DeckError("UNAVAILABLE", `The Deck's answer to ${path} did not match the tool contract`, { cause: parsed.error });
|
|
1180
1180
|
return parsed.data;
|
|
@@ -1193,9 +1193,33 @@ function withAgentClient(backend, client) {
|
|
|
1193
1193
|
}
|
|
1194
1194
|
};
|
|
1195
1195
|
}
|
|
1196
|
+
var PAGE_AGAIN_MS = 6e5;
|
|
1197
|
+
function withPages(backend, open, now = Date.now) {
|
|
1198
|
+
const opened = /* @__PURE__ */ new Map();
|
|
1199
|
+
async function openPage(err) {
|
|
1200
|
+
if (!(err instanceof DeckError) || !err.page) throw err;
|
|
1201
|
+
const page = err.page;
|
|
1202
|
+
const last = opened.get(page);
|
|
1203
|
+
if (last !== void 0 && now() - last < PAGE_AGAIN_MS) throw err;
|
|
1204
|
+
opened.set(page, now());
|
|
1205
|
+
try {
|
|
1206
|
+
await open(page);
|
|
1207
|
+
} catch (openErr) {
|
|
1208
|
+
console.error("[thedeck-mcp] could not open a browser for the page", openErr);
|
|
1209
|
+
opened.delete(page);
|
|
1210
|
+
throw err;
|
|
1211
|
+
}
|
|
1212
|
+
throw new DeckError(err.code, `${err.message} The page is now open in the person’s browser.`, {
|
|
1213
|
+
cause: err,
|
|
1214
|
+
page,
|
|
1215
|
+
waitsOnPerson: err.waitsOnPerson
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
return Object.fromEntries(BACKEND_CALLS.map((name) => [name, (input) => backend[name](input).catch(openPage)]));
|
|
1219
|
+
}
|
|
1196
1220
|
var package_default = {
|
|
1197
1221
|
name: "@thedeck/mcp",
|
|
1198
|
-
version: "0.1.
|
|
1222
|
+
version: "0.1.7",
|
|
1199
1223
|
type: "module",
|
|
1200
1224
|
bin: {
|
|
1201
1225
|
"mcp": "dist/index.js",
|
|
@@ -6090,14 +6114,14 @@ process.on("unhandledRejection", fail("unhandled rejection"));
|
|
|
6090
6114
|
process.on("uncaughtException", fail("uncaught exception"));
|
|
6091
6115
|
var server = null;
|
|
6092
6116
|
var clientName = () => readableClientName(server?.server.getClientVersion());
|
|
6093
|
-
server = createDeckServer(withAgentClient(createRemoteBackend({
|
|
6117
|
+
server = createDeckServer(withPages(withAgentClient(createRemoteBackend({
|
|
6094
6118
|
deckUrl: DECK_URL,
|
|
6095
6119
|
token: createLogin({
|
|
6096
6120
|
deckUrl: DECK_URL,
|
|
6097
6121
|
clientName,
|
|
6098
6122
|
handBackAfterMs: 45e3
|
|
6099
6123
|
})
|
|
6100
|
-
}), () => server?.server.getClientVersion()), {
|
|
6124
|
+
}), () => server?.server.getClientVersion()), openInBrowser), {
|
|
6101
6125
|
remote: false,
|
|
6102
6126
|
localTools: [runPrecheck, tryOnRealData]
|
|
6103
6127
|
});
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@thedeck/mcp",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"bin": {
|
|
6
|
-
"mcp": "dist/index.js",
|
|
7
|
-
"thedeck-mcp": "dist/index.js",
|
|
8
|
-
"thedeck": "dist/cli.js"
|
|
9
|
-
},
|
|
10
|
-
"exports": {
|
|
11
|
-
".": "./src/server.ts",
|
|
12
|
-
"./backend": "./src/backend.ts"
|
|
13
|
-
},
|
|
14
|
-
"files": [
|
|
15
|
-
"dist"
|
|
16
|
-
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "vite build --ssr src/index.ts --outDir dist && vite build --ssr src/cli.ts --outDir dist --emptyOutDir false",
|
|
19
|
-
"typecheck": "tsc --noEmit",
|
|
20
|
-
"lint": "eslint .",
|
|
21
|
-
"test": "vitest run"
|
|
22
|
-
},
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@modelcontextprotocol/sdk": "1.32.1",
|
|
25
|
-
"zod": "4.6.7"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@modelcontextprotocol/ext-apps": "1.7.5",
|
|
29
|
-
"@thedeck/runner": "workspace:*",
|
|
30
|
-
"@thedeck/shared": "workspace:*",
|
|
31
|
-
"@types/node": "26.6.5",
|
|
32
|
-
"@vitest/coverage-v8": "5.0.5",
|
|
33
|
-
"happy-dom": "21.0.4",
|
|
34
|
-
"typescript": "6.0.3",
|
|
35
|
-
"vite": "8.3.5",
|
|
36
|
-
"vitest": "5.0.5"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@thedeck/mcp",
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"mcp": "dist/index.js",
|
|
7
|
+
"thedeck-mcp": "dist/index.js",
|
|
8
|
+
"thedeck": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./src/server.ts",
|
|
12
|
+
"./backend": "./src/backend.ts"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "vite build --ssr src/index.ts --outDir dist && vite build --ssr src/cli.ts --outDir dist --emptyOutDir false",
|
|
19
|
+
"typecheck": "tsc --noEmit",
|
|
20
|
+
"lint": "eslint .",
|
|
21
|
+
"test": "vitest run"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@modelcontextprotocol/sdk": "1.32.1",
|
|
25
|
+
"zod": "4.6.7"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@modelcontextprotocol/ext-apps": "1.7.5",
|
|
29
|
+
"@thedeck/runner": "workspace:*",
|
|
30
|
+
"@thedeck/shared": "workspace:*",
|
|
31
|
+
"@types/node": "26.6.5",
|
|
32
|
+
"@vitest/coverage-v8": "5.0.5",
|
|
33
|
+
"happy-dom": "21.0.4",
|
|
34
|
+
"typescript": "6.0.3",
|
|
35
|
+
"vite": "8.3.5",
|
|
36
|
+
"vitest": "5.0.5"
|
|
37
|
+
}
|
|
38
|
+
}
|