@thedeck/mcp 0.1.2 → 0.1.4
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 +1316 -14
- package/dist/index.js +178 -140
- package/package.json +38 -38
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { execFile, spawn } from "node:child_process";
|
|
5
5
|
import crypto$1, { randomBytes } from "node:crypto";
|
|
6
|
-
import {
|
|
6
|
+
import { cp, mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
7
7
|
import { createServer } from "node:http";
|
|
8
8
|
import os, { homedir, tmpdir } from "node:os";
|
|
9
9
|
import path from "node:path";
|
|
@@ -235,6 +235,8 @@ var postDraftOutput = z.object({
|
|
|
235
235
|
quest_id: questId,
|
|
236
236
|
review_url: z.url(),
|
|
237
237
|
pay_url: z.url(),
|
|
238
|
+
reward_cents: z.number().int().nonnegative(),
|
|
239
|
+
deposit_cents: z.number().int().nonnegative().describe("What the pay link charges now: the held deposit, 30% of the reward. The rest is charged when the person accepts a submission."),
|
|
238
240
|
missing: z.array(z.object({
|
|
239
241
|
part: postPart,
|
|
240
242
|
label: z.string()
|
|
@@ -244,8 +246,8 @@ var postDraftOutput = z.object({
|
|
|
244
246
|
var addExampleCopyInput = z.object({
|
|
245
247
|
quest_id: questId,
|
|
246
248
|
pair: z.number().int().positive(),
|
|
247
|
-
role: z.enum(["input", "expected"]),
|
|
248
|
-
filename: z.string().trim().min(1).max(255),
|
|
249
|
+
role: z.enum(["input", "expected"]).describe("input: a file the program reads. An example’s input can be several files: send each with the same pair and role input. expected: the one answer file of that pair."),
|
|
250
|
+
filename: z.string().trim().min(1).max(255).describe("A file sent again under the same name, pair and role replaces the one sent before."),
|
|
249
251
|
content: z.string(),
|
|
250
252
|
blanked_summary: z.string().trim().min(1),
|
|
251
253
|
shown_to_builders: z.boolean().optional().describe("True when the person chose to show this example to builders. Leave it out to keep it hidden for judging, like a hidden test."),
|
|
@@ -263,11 +265,15 @@ var isJson = (text) => {
|
|
|
263
265
|
return false;
|
|
264
266
|
}
|
|
265
267
|
};
|
|
268
|
+
var exampleCopyRef = z.object({
|
|
269
|
+
pair: z.number().int().positive(),
|
|
270
|
+
role: z.enum(["input", "expected"])
|
|
271
|
+
}).describe("An example copy already sent with deck.add_example_copy, named by its pair and role, in place of inline text.");
|
|
266
272
|
var proposedTest = z.object({
|
|
267
273
|
name: z.string().trim().min(1),
|
|
268
274
|
kind: z.enum(["sample", "hidden"]),
|
|
269
|
-
input: z.string(),
|
|
270
|
-
expected: z.string().describe("The expected output. For outcome fails_cleanly, a short note of why the input is bad; it is shown to the person, not compared."),
|
|
275
|
+
input: z.union([z.string(), exampleCopyRef]).describe("The input as text, or an example copy by its pair and role. For a large input, send the file once with deck.add_example_copy (hidden unless the person shows it) and name it here instead of writing it out. When that example’s input is several files, the program gets a folder holding them."),
|
|
276
|
+
expected: z.union([z.string(), exampleCopyRef]).describe("The expected output as text, or an example copy by its pair and role. For outcome fails_cleanly, a short note of why the input is bad; it is shown to the person, not compared."),
|
|
271
277
|
category: z.string().trim().min(1).optional().describe("The part of the test plan this test covers: the confirmed scenario it checks, or an edge case such as empty input, malformed input, large input or boundary values. Builders see how many hidden tests failed in each category."),
|
|
272
278
|
compare: z.enum(TEST_COMPARES).optional().describe("How the output is checked against expected. exact (the default): the same text, ignoring line endings and trailing space. unordered_lines: the same lines in any order, for rows whose order does not matter. numbers: every number within tolerance and the text around them the same. json: the same JSON value, whatever the key order and spacing."),
|
|
273
279
|
tolerance: z.number().nonnegative().optional().describe(`Only with compare numbers: how far each number may be from the expected one. Default ${TEST_DEFAULTS.tolerance}.`),
|
|
@@ -276,7 +282,7 @@ var proposedTest = z.object({
|
|
|
276
282
|
}).refine((t) => t.tolerance === void 0 || t.compare === "numbers", {
|
|
277
283
|
path: ["tolerance"],
|
|
278
284
|
error: "tolerance applies only with compare numbers"
|
|
279
|
-
}).refine((t) => t.compare !== "json" || t.outcome === "fails_cleanly" || isJson(t.expected), {
|
|
285
|
+
}).refine((t) => t.compare !== "json" || t.outcome === "fails_cleanly" || typeof t.expected !== "string" || isJson(t.expected), {
|
|
280
286
|
path: ["expected"],
|
|
281
287
|
error: "with compare json, expected must be valid JSON"
|
|
282
288
|
});
|
|
@@ -367,6 +373,7 @@ var precheckKitOutput = z.object({
|
|
|
367
373
|
name: z.string(),
|
|
368
374
|
input_file: z.string().min(1),
|
|
369
375
|
input: z.base64(),
|
|
376
|
+
input_folder: z.boolean().optional().describe("true when input is a zip of several files, unpacked into a folder that is passed as {input}."),
|
|
370
377
|
expected_file: z.string().min(1),
|
|
371
378
|
expected: z.base64(),
|
|
372
379
|
compare: z.enum(TEST_COMPARES).optional(),
|
|
@@ -388,7 +395,8 @@ var realDataReportInput = z.object({
|
|
|
388
395
|
total: z.number().int().positive()
|
|
389
396
|
});
|
|
390
397
|
var reportedOutput = z.object({ reported: z.literal(true) });
|
|
391
|
-
var
|
|
398
|
+
var reportFields = z.object({
|
|
399
|
+
kind: z.enum(["problem", "workflow_change"]).optional().describe("problem (the default): the person struggled or was held up. workflow_change: the person went through the steps their own way, which shows how people prefer to work with an agent."),
|
|
392
400
|
side: z.enum(["poster", "builder"]),
|
|
393
401
|
step: z.enum([
|
|
394
402
|
"understanding_the_deck",
|
|
@@ -413,15 +421,21 @@ var reportIssueInput = z.object({
|
|
|
413
421
|
"blocker",
|
|
414
422
|
"annoying",
|
|
415
423
|
"minor"
|
|
416
|
-
]),
|
|
424
|
+
]).optional().describe("How much the problem held the person up. Needed for a problem; leave it out for a workflow change."),
|
|
417
425
|
quest_id: questId.optional(),
|
|
418
426
|
person_agreed: z.literal(true).describe("true only when you showed the person this exact text and they said yes to sending it.")
|
|
419
427
|
});
|
|
428
|
+
var hasSeverity = (r) => r.kind === "workflow_change" || r.severity !== void 0;
|
|
429
|
+
var NEEDS_SEVERITY = {
|
|
430
|
+
path: ["severity"],
|
|
431
|
+
error: "a problem needs its severity: blocker, annoying or minor"
|
|
432
|
+
};
|
|
433
|
+
var reportIssueInput = reportFields.refine(hasSeverity, NEEDS_SEVERITY);
|
|
420
434
|
var reportIssueOutput = z.object({
|
|
421
435
|
report_id: z.uuid(),
|
|
422
436
|
received_at: z.string()
|
|
423
437
|
});
|
|
424
|
-
var betaReportInput =
|
|
438
|
+
var betaReportInput = reportFields.extend({ agent_client: z.string().trim().min(1).max(200).nullable().optional() }).refine(hasSeverity, NEEDS_SEVERITY);
|
|
425
439
|
var MCP_TOOLS = {
|
|
426
440
|
"deck.post_draft": {
|
|
427
441
|
input: postDraftInput,
|
|
@@ -488,10 +502,12 @@ var DECK_ERROR_CODES = [
|
|
|
488
502
|
var isDeckErrorCode = (code) => DECK_ERROR_CODES.includes(code);
|
|
489
503
|
var DeckError = class extends Error {
|
|
490
504
|
code;
|
|
505
|
+
waitsOnPerson;
|
|
491
506
|
constructor(code, message, options) {
|
|
492
507
|
super(message ?? code, options);
|
|
493
508
|
this.name = "DeckError";
|
|
494
509
|
this.code = code;
|
|
510
|
+
this.waitsOnPerson = options?.waitsOnPerson === true;
|
|
495
511
|
}
|
|
496
512
|
};
|
|
497
513
|
var toolCall = (name) => ({
|
|
@@ -1055,19 +1071,20 @@ function registerCard(server, tool) {
|
|
|
1055
1071
|
};
|
|
1056
1072
|
}
|
|
1057
1073
|
// src/guidance.ts
|
|
1058
|
-
var
|
|
1074
|
+
var ONE_QUESTION = "Ask the person one short question per message, never a list, and wait for their answer. If they leave a question unanswered, ask it again briefly; never decide it for them.";
|
|
1075
|
+
var CONVERSATION = "Keep it a conversation, not a form. Ask one short question per message, in plain, friendly words, and wait for their answer. Never send a list of questions. If the person leaves a question unanswered, ask it again briefly; never decide it for them. After each answer, say back in a sentence what you heard, ask a brief follow-up if anything is unclear, then go on to the next question.";
|
|
1059
1076
|
var POSTING_STEPS = [
|
|
1060
1077
|
"To help a person post a task, go through these steps in order, one at a time:",
|
|
1061
1078
|
"1. Ask them to describe the problem in their own words. If they don’t know what to build, suggest ideas from what you already know of them, from this conversation and earlier ones. This brainstorming stays between you and them: nothing goes to The Deck except the post they approve.",
|
|
1062
1079
|
"2. Describe concrete scenarios back to them (\"when X comes in, it should do Y\") and ask whether that is what they want. Revise until they confirm.",
|
|
1063
1080
|
"3. Go through the details one question at a time: what comes in, what should come out, the file formats, what counts as right, and any constraints.",
|
|
1064
1081
|
"4. Ask for the end date: the last day builders can enter, 5 to 60 days from today. Confirm the person’s time zone with them; never assume it. Entries close at 23:59 on that date in their time zone. Then save the draft with deck.post_draft, with the confirmed scenarios.",
|
|
1065
|
-
"5. Ask for real example data. If they attach a file in this chat, make the blanked copy yourself: replace names, numbers and anything sensitive, show them the exact blanked copy, and send it with deck.add_example_copy only after they say yes. On their own computer, blank names, numbers and anything sensitive in a copy on their computer before anything is sent. The confirmed scenarios are the basis for the examples and tests. Suggest which one or two examples builders should see; the person decides, and the rest stay hidden for judging. Then propose tests with deck.propose_tests. Propose a test plan, not copies of the examples: at least one test for every confirmed scenario, plus edge cases you write yourself (empty input, malformed input with outcome fails_cleanly, large input, boundary values), each with its category. Pick how each test is compared and raise its time limit only for large inputs. Show them the plan in plain words: what each test checks, which ones builders see, and the pass mark. Send it with person_approved true only after they say yes.",
|
|
1082
|
+
"5. Ask for real example data. If they attach a file in this chat, make the blanked copy yourself: replace names, numbers and anything sensitive, show them the exact blanked copy, and send it with deck.add_example_copy only after they say yes. An example’s input can be several files, like a PDF and a CSV: send each with the same pair, never zipped together. On their own computer, blank names, numbers and anything sensitive in a copy on their computer before anything is sent. The confirmed scenarios are the basis for the examples and tests. Suggest which one or two examples builders should see; the person decides, and the rest stay hidden for judging. Then propose tests with deck.propose_tests. Propose a test plan, not copies of the examples: at least one test for every confirmed scenario, plus edge cases you write yourself (empty input, malformed input with outcome fails_cleanly, large input, boundary values), each with its category. Pick how each test is compared and raise its time limit only for large inputs. For a large input or a hidden test file, send it once with deck.add_example_copy (hidden from builders unless they choose to show it) and name it in the test by its pair and role instead of writing it out. Show them the plan in plain words: what each test checks, which ones builders see, and the pass mark. Send it with person_approved true only after they say yes.",
|
|
1066
1083
|
"6. Ask what reward they will pay for the accepted submission, then who can see the task: anyone on The Deck, or only builders they invite. Save both on the draft with deck.post_draft.",
|
|
1067
|
-
"7. When deck.post_draft says nothing is missing, give the person its pay link. They open it and pay the held deposit on Stripe themselves, which posts the task. While something is still missing, the same link opens the review page, which shows what."
|
|
1084
|
+
"7. When deck.post_draft says nothing is missing, give the person its pay link. They open it and pay the held deposit, 30% of the reward, on Stripe themselves, which posts the task; the rest is charged only when they accept a submission. Tell them the exact amounts deck.post_draft gives. While something is still missing, the same link opens the review page, which shows what."
|
|
1068
1085
|
].join("\n");
|
|
1069
1086
|
var NEVER = "You can never save a card, post a task live, accept an entry, pitch in or pay anyone: the person pays the deposit themselves on Stripe, through the pay link, and accepts entries on The Deck.";
|
|
1070
|
-
var REPORTS = "During the beta, when the person is noticeably struggling or inconvenienced at any step, posting or building, write a short report of what went wrong, show them the exact text and send it with deck.report_issue only if they say yes. Do the same whenever they say \"report this\". Ask at most once per problem. Never put example data, file contents, secrets or other people’s details in a report.";
|
|
1087
|
+
var REPORTS = "During the beta, when the person is noticeably struggling or inconvenienced at any step, posting or building, write a short report of what went wrong, show them the exact text and send it with deck.report_issue only if they say yes. Do the same whenever they say \"report this\". Offer a report with kind workflow_change, the same way, when the person changes how they go through the steps: answers in a different order, skips or merges steps, does a step on the website instead of in the chat, writes the post themselves, or turns down a suggested approach and does it their own way; it shows how people prefer to work with an agent. Ask whether to send it in one short question, at most once per problem or change. Never put example data, file contents, secrets or other people’s details in a report.";
|
|
1071
1088
|
var INSTRUCTIONS = [
|
|
1072
1089
|
"The Deck is a board where posters put up tasks with a reward and builders enter solutions that are tested automatically. These tools act as the person who connected you.",
|
|
1073
1090
|
CONVERSATION,
|
|
@@ -1124,18 +1141,19 @@ async function checkBlankedCopy(input, dir) {
|
|
|
1124
1141
|
const bytes = decodeCopy(input.content);
|
|
1125
1142
|
if (bytes.length === 0) throw new DeckError("BAD_INPUT", "the copy is empty");
|
|
1126
1143
|
if (bytes.length > 52428800) throw new DeckError("FILE_TOO_LARGE", `the copy is ${bytes.length} bytes; the limit is ${COPY_MAX_BYTES}`);
|
|
1127
|
-
for (const name of originalNames(input.filename)) if ((await readIfThere(path.join(dir, name)))?.equals(bytes)) throw new DeckError("NOT_BLANKED", `${name} is unchanged: blank the names and numbers in a copy before sending it
|
|
1144
|
+
for (const name of originalNames(input.filename)) if ((await readIfThere(path.join(dir, name)))?.equals(bytes)) throw new DeckError("NOT_BLANKED", `${name} is unchanged: blank the names and numbers in a copy before sending it`, { waitsOnPerson: true });
|
|
1128
1145
|
return {
|
|
1129
1146
|
filename: blankedName(input.filename),
|
|
1130
1147
|
size: bytes.length
|
|
1131
1148
|
};
|
|
1132
1149
|
}
|
|
1133
1150
|
// src/tools/addExampleCopy.ts
|
|
1134
|
-
var
|
|
1151
|
+
var SEVERAL_FILES = "An example’s input can be several files, like a PDF and a CSV: send each with the same pair and role input; never zip them together.";
|
|
1152
|
+
var summary = (out) => out.status === "approved" ? `Blanked copy sent as example ${out.example_id}, status approved: the person approved this exact copy in the chat. ${ONE_QUESTION}` : `Blanked copy sent as example ${out.example_id}, status ${out.status}. It waits on the poster’s Examples list for approval. ${ONE_QUESTION}`;
|
|
1135
1153
|
var addExampleCopy = {
|
|
1136
1154
|
name: "deck.add_example_copy",
|
|
1137
1155
|
title: "Send a blanked example copy",
|
|
1138
|
-
description:
|
|
1156
|
+
description: `For posters, on this computer. Sends one example file to a draft task after you have blanked its names and numbers in a copy: content is the copy as text, or as a data URL (data:<type>;base64,...) for binary files. ${SEVERAL_FILES} The original never leaves this computer; the copy waits for the poster to approve it. ${ONE_QUESTION}`,
|
|
1139
1157
|
async run(backend, args) {
|
|
1140
1158
|
const copy = await checkBlankedCopy(args, process.cwd());
|
|
1141
1159
|
return backend.addExampleCopy({
|
|
@@ -1148,9 +1166,9 @@ var addExampleCopy = {
|
|
|
1148
1166
|
var addExampleCopyRemote = {
|
|
1149
1167
|
name: "deck.add_example_copy",
|
|
1150
1168
|
title: "Send a blanked example copy",
|
|
1151
|
-
description:
|
|
1169
|
+
description: `For posters. Sends one example file the person attached in this chat to a draft task, as a copy you blanked: replace names, numbers and anything sensitive, show the person the exact blanked copy, and send it only after they say yes, with person_approved true. content is the copy as text, or as a data URL (data:<type>;base64,...) for binary files. ${SEVERAL_FILES} Never send the original. ${ONE_QUESTION}`,
|
|
1152
1170
|
async run(backend, args) {
|
|
1153
|
-
if (args.person_approved !== true) throw new DeckError("BAD_INPUT", "show the person the exact blanked copy and send it only after they say yes, with person_approved true");
|
|
1171
|
+
if (args.person_approved !== true) throw new DeckError("BAD_INPUT", "show the person the exact blanked copy and send it only after they say yes, with person_approved true", { waitsOnPerson: true });
|
|
1154
1172
|
const size = decodeCopy(args.content).length;
|
|
1155
1173
|
if (size === 0) throw new DeckError("BAD_INPUT", "the copy is empty");
|
|
1156
1174
|
if (size > 52428800) throw new DeckError("FILE_TOO_LARGE", `the copy is ${size} bytes; the limit is ${COPY_MAX_BYTES}`);
|
|
@@ -1212,19 +1230,35 @@ var listQuests = {
|
|
|
1212
1230
|
summary: (out) => out.quests.length === 0 ? "No quests found." : [`${plural(out.quests.length, "quest", "quests")} found:`, ...out.quests.map(line)].join("\n")
|
|
1213
1231
|
};
|
|
1214
1232
|
// src/tools/postDraft.ts
|
|
1233
|
+
var ASK_ABOUT_IT = "Ask the person about it, then save the draft again with deck.post_draft.";
|
|
1234
|
+
var NEXT = {
|
|
1235
|
+
title: ASK_ABOUT_IT,
|
|
1236
|
+
problem: ASK_ABOUT_IT,
|
|
1237
|
+
looking_for: ASK_ABOUT_IT,
|
|
1238
|
+
rules: ASK_ABOUT_IT,
|
|
1239
|
+
handover: ASK_ABOUT_IT,
|
|
1240
|
+
examples: "Ask the person for one real example file, then blank it and send it with deck.add_example_copy.",
|
|
1241
|
+
tests: "Propose a test plan with deck.propose_tests: show it to the person in plain words and ask whether it is right.",
|
|
1242
|
+
reward: "Ask the person what reward they will pay for the accepted submission.",
|
|
1243
|
+
deadline: "Ask the person for an end date 5 to 60 days from their today.",
|
|
1244
|
+
visibility: "Ask the person who can see the task: anyone on The Deck, or only builders they invite."
|
|
1245
|
+
};
|
|
1246
|
+
function payNote(out) {
|
|
1247
|
+
const rest = out.reward_cents - out.deposit_cents;
|
|
1248
|
+
return `The pay link charges ${formatMoney(out.deposit_cents)} now, the held deposit, 30% of the ${formatMoney(out.reward_cents)} reward; the other ${formatMoney(rest)} is charged only when they accept a submission, and the deposit comes back in full if no entry passes. Say these exact amounts.`;
|
|
1249
|
+
}
|
|
1215
1250
|
var postDraft = {
|
|
1216
1251
|
name: "deck.post_draft",
|
|
1217
1252
|
title: "Draft a task",
|
|
1218
|
-
description:
|
|
1253
|
+
description: `For posters. Saves a task brief on The Deck as a draft, or updates the draft named by quest_id. The deadline, the reward and who can see it are the person’s: send only the end date, time zone, reward and visibility they gave you, never ones you chose, and leave the reward and visibility out until they have said them. When nothing is missing, give the person pay_url: they pay the held deposit, 30% of the reward, on Stripe themselves, which posts the task; the rest is charged when they accept a submission. An agent never posts a task live and never spends money. ${ONE_QUESTION}`,
|
|
1219
1254
|
run: (backend, args) => backend.postDraft(args),
|
|
1220
1255
|
summary: (out) => {
|
|
1221
|
-
if (out.missing.length === 0) return `Draft saved as quest ${out.quest_id}. Nothing is missing. Give the person this link to pay the held deposit on Stripe themselves, which posts the task: ${out.pay_url}`;
|
|
1222
|
-
const
|
|
1223
|
-
const needsTests = out.missing.some((m) => m.part === "tests" || m.part === "examples");
|
|
1256
|
+
if (out.missing.length === 0) return `Draft saved as quest ${out.quest_id}. Nothing is missing. ${payNote(out)} Give the person this link to pay the held deposit on Stripe themselves, which posts the task: ${out.pay_url}`;
|
|
1257
|
+
const [next] = out.missing;
|
|
1224
1258
|
return [
|
|
1225
|
-
saved
|
|
1226
|
-
|
|
1227
|
-
|
|
1259
|
+
`Draft saved as quest ${out.quest_id}. The poster checks it at ${out.review_url}; paying and posting stay theirs.`,
|
|
1260
|
+
...next ? [`Next: ${next.label}. ${NEXT[next.part]}`] : [],
|
|
1261
|
+
ONE_QUESTION
|
|
1228
1262
|
].join(" ");
|
|
1229
1263
|
}
|
|
1230
1264
|
};
|
|
@@ -1232,17 +1266,17 @@ var postDraft = {
|
|
|
1232
1266
|
var proposeTests = {
|
|
1233
1267
|
name: "deck.propose_tests",
|
|
1234
1268
|
title: "Propose tests",
|
|
1235
|
-
description:
|
|
1269
|
+
description: `For posters. Adds tests to a draft task: sample tests builders can see and hidden tests they cannot, each an input and its expected answer, with a suggested pass mark out of the hidden tests. Propose a test plan, like a graded coding assignment, not only copies of the examples: at least one test for every confirmed scenario, plus edge cases you write yourself (empty input, malformed input the program should refuse, large input, boundary values), each with the category it covers. Choose per test how the output is compared (exact, any line order, numbers within a tolerance, or JSON), a time limit if the default 10 seconds does not fit, and outcome fails_cleanly where the program should reject the input. For a large input, or a hidden test file, send the file once with deck.add_example_copy and name it here by its pair and role instead of writing it out; when that example’s input is several files, the program gets a folder holding them. Show the person the test plan in plain words: what each test checks, which ones builders see, and the pass mark. Send it only after they say yes, with person_approved true; without it nothing is sent. Then it needs no second approval on The Deck. ${ONE_QUESTION}`,
|
|
1236
1270
|
run: (backend, args) => backend.proposeTests(args),
|
|
1237
|
-
summary: (out) => `${out.samples + out.hidden} tests on draft quest ${out.quest_id}: ${out.samples} visible to builders, ${out.hidden} hidden, pass mark ${out.pass_mark} of ${out.hidden}. ` + (out.status === "approved" ? "Approved in the chat: the person said yes to this test plan, so it needs no second approval on The Deck." : "The poster approves them.")
|
|
1271
|
+
summary: (out) => `${out.samples + out.hidden} tests on draft quest ${out.quest_id}: ${out.samples} visible to builders, ${out.hidden} hidden, pass mark ${out.pass_mark} of ${out.hidden}. ` + (out.status === "approved" ? "Approved in the chat: the person said yes to this test plan, so it needs no second approval on The Deck." : "The poster approves them.") + ` Next, save the draft again with deck.post_draft; its answer names the one thing still to ask. ${ONE_QUESTION}`
|
|
1238
1272
|
};
|
|
1239
1273
|
// src/tools/reportIssue.ts
|
|
1240
1274
|
var reportIssue = {
|
|
1241
1275
|
name: "deck.report_issue",
|
|
1242
|
-
title: "Report a problem
|
|
1243
|
-
description:
|
|
1276
|
+
title: "Report a problem or a workflow change",
|
|
1277
|
+
description: `For posters and builders, during the beta. Saves a short report for The Deck team: kind problem (the default) when the person struggled or was held up at a step, or asked you to report something; kind workflow_change, with no severity, when they went through the steps their own way: another order, a step skipped or merged, a step done on the website instead of in the chat, the post written themselves, or a suggested approach turned down for their own. Write the report, show the person the exact text, and send it only if they say yes; ask at most once per problem. Never put example data, file contents, secrets or other people’s details in a report. ${ONE_QUESTION}`,
|
|
1244
1278
|
run: (backend, args) => backend.reportIssue(args),
|
|
1245
|
-
summary: (out) => `Thank you: report ${out.report_id}
|
|
1279
|
+
summary: (out) => `Thank you: report ${out.report_id} was saved for The Deck team at ${utc(out.received_at)}.`
|
|
1246
1280
|
};
|
|
1247
1281
|
// src/server.ts
|
|
1248
1282
|
function plural(n, one, many) {
|
|
@@ -1264,12 +1298,14 @@ var SHARED_TOOLS = [
|
|
|
1264
1298
|
getPassingEntries,
|
|
1265
1299
|
reportIssue
|
|
1266
1300
|
];
|
|
1267
|
-
|
|
1301
|
+
var REPORT_OFFER = "If this held the person up, write a short report, show them the exact text and send it with deck.report_issue only if they say yes; ask at most once per problem.";
|
|
1302
|
+
function toolError(err, tool) {
|
|
1303
|
+
const offer = tool === "deck.report_issue" ? "" : ` ${REPORT_OFFER}`;
|
|
1268
1304
|
if (err instanceof DeckError) return {
|
|
1269
1305
|
isError: true,
|
|
1270
1306
|
content: [{
|
|
1271
1307
|
type: "text",
|
|
1272
|
-
text: `${err.code}: ${err.message}`
|
|
1308
|
+
text: `${err.code}: ${err.message}${err.waitsOnPerson ? "" : offer}`
|
|
1273
1309
|
}]
|
|
1274
1310
|
};
|
|
1275
1311
|
console.error("[thedeck-mcp] a tool failed", err);
|
|
@@ -1277,7 +1313,7 @@ function toolError(err) {
|
|
|
1277
1313
|
isError: true,
|
|
1278
1314
|
content: [{
|
|
1279
1315
|
type: "text",
|
|
1280
|
-
text:
|
|
1316
|
+
text: `UNAVAILABLE: The Deck could not finish this. Try again in a moment.${offer}`
|
|
1281
1317
|
}]
|
|
1282
1318
|
};
|
|
1283
1319
|
}
|
|
@@ -1292,7 +1328,7 @@ async function callTool(tool, backend, args) {
|
|
|
1292
1328
|
structuredContent: out
|
|
1293
1329
|
};
|
|
1294
1330
|
} catch (err) {
|
|
1295
|
-
return toolError(err);
|
|
1331
|
+
return toolError(err, tool.name);
|
|
1296
1332
|
}
|
|
1297
1333
|
}
|
|
1298
1334
|
function register(server, tool, backend) {
|
|
@@ -1414,7 +1450,7 @@ async function stageInputs(tests) {
|
|
|
1414
1450
|
const dir = await mkdtemp(path.join(tmpdir(), "deck-inputs-"));
|
|
1415
1451
|
await Promise.all(tests.map(async (test, i) => {
|
|
1416
1452
|
await mkdir(path.join(dir, String(i)));
|
|
1417
|
-
await
|
|
1453
|
+
await cp(test.inputFile, path.join(dir, String(i), `input${path.extname(test.inputFile)}`), { recursive: true });
|
|
1418
1454
|
}));
|
|
1419
1455
|
return dir;
|
|
1420
1456
|
}
|
|
@@ -23573,111 +23609,6 @@ async function scan(options) {
|
|
|
23573
23609
|
summary
|
|
23574
23610
|
};
|
|
23575
23611
|
}
|
|
23576
|
-
// src/local/precheck.ts
|
|
23577
|
-
var RUN_LIMIT_MS = 6e5;
|
|
23578
|
-
var noStep = () => void 0;
|
|
23579
|
-
var safeName = (name) => path.basename(name).replaceAll(/[^\w.-]/g, "_") || "file";
|
|
23580
|
-
async function open(openBox) {
|
|
23581
|
-
try {
|
|
23582
|
-
return await openBox();
|
|
23583
|
-
} catch (err) {
|
|
23584
|
-
throw new DeckError("SANDBOX_FAILED", "the local sandbox could not start; the pre-check and real-data runs need Docker and the thedeck-sandbox image", { cause: err });
|
|
23585
|
-
}
|
|
23586
|
-
}
|
|
23587
|
-
async function stageKit(kit, dir) {
|
|
23588
|
-
const tests = [];
|
|
23589
|
-
for (const [i, test] of kit.tests.entries()) {
|
|
23590
|
-
const slot = path.join(dir, String(i));
|
|
23591
|
-
await mkdir(slot, { recursive: true });
|
|
23592
|
-
const inputFile = path.join(slot, `input-${safeName(test.input_file)}`);
|
|
23593
|
-
const expectedFile = path.join(slot, `expected-${safeName(test.expected_file)}`);
|
|
23594
|
-
await writeFile(inputFile, Buffer.from(test.input, "base64"));
|
|
23595
|
-
await writeFile(expectedFile, Buffer.from(test.expected, "base64"));
|
|
23596
|
-
tests.push({
|
|
23597
|
-
kind: "sample",
|
|
23598
|
-
category: null,
|
|
23599
|
-
inputFile,
|
|
23600
|
-
expectedFile,
|
|
23601
|
-
compare: test.compare ?? TEST_DEFAULTS.compare,
|
|
23602
|
-
tolerance: test.tolerance ?? null,
|
|
23603
|
-
timeLimitMs: test.time_limit_ms ?? TEST_DEFAULTS.timeLimitMs,
|
|
23604
|
-
outcome: test.outcome ?? TEST_DEFAULTS.outcome
|
|
23605
|
-
});
|
|
23606
|
-
}
|
|
23607
|
-
return tests;
|
|
23608
|
-
}
|
|
23609
|
-
async function runInSandbox(options, openBox = openSandbox) {
|
|
23610
|
-
let root;
|
|
23611
|
-
try {
|
|
23612
|
-
root = await findEntryRoot(options.entryDir);
|
|
23613
|
-
} catch (err) {
|
|
23614
|
-
if (err instanceof EntryError) throw new DeckError("BAD_INPUT", err.message, { cause: err });
|
|
23615
|
-
throw new DeckError("BAD_INPUT", `${options.entryDir} could not be read`, { cause: err });
|
|
23616
|
-
}
|
|
23617
|
-
const sandbox = await open(openBox);
|
|
23618
|
-
try {
|
|
23619
|
-
const report = await runTests({
|
|
23620
|
-
sandbox,
|
|
23621
|
-
entryDir: root,
|
|
23622
|
-
tests: options.tests,
|
|
23623
|
-
deadline: Date.now() + RUN_LIMIT_MS,
|
|
23624
|
-
onStep: noStep
|
|
23625
|
-
});
|
|
23626
|
-
const scanned = options.withScan ? await scan({
|
|
23627
|
-
sandbox,
|
|
23628
|
-
entryRoot: root,
|
|
23629
|
-
onStep: noStep
|
|
23630
|
-
}) : null;
|
|
23631
|
-
return {
|
|
23632
|
-
report,
|
|
23633
|
-
scanClear: scanned ? scanned.status === "clear" : null
|
|
23634
|
-
};
|
|
23635
|
-
} catch (err) {
|
|
23636
|
-
if (err instanceof EntryError) throw new DeckError("BAD_INPUT", err.message, { cause: err });
|
|
23637
|
-
throw new DeckError("SANDBOX_FAILED", "the run stopped in the local sandbox", { cause: err });
|
|
23638
|
-
} finally {
|
|
23639
|
-
await sandbox.close();
|
|
23640
|
-
}
|
|
23641
|
-
}
|
|
23642
|
-
async function precheckLocally(kit, entryDir, openBox = openSandbox) {
|
|
23643
|
-
if (kit.tests.length === 0) throw new DeckError("NOT_FOUND", "this quest has no sample tests yet");
|
|
23644
|
-
const staged = await mkdtemp(path.join(tmpdir(), "deck-precheck-"));
|
|
23645
|
-
try {
|
|
23646
|
-
const { report, scanClear } = await runInSandbox({
|
|
23647
|
-
entryDir,
|
|
23648
|
-
tests: await stageKit(kit, staged),
|
|
23649
|
-
withScan: true
|
|
23650
|
-
}, openBox);
|
|
23651
|
-
return {
|
|
23652
|
-
passed: report.samplePassed,
|
|
23653
|
-
total: report.sampleTotal,
|
|
23654
|
-
scan_clear: scanClear === true
|
|
23655
|
-
};
|
|
23656
|
-
} finally {
|
|
23657
|
-
await rm(staged, {
|
|
23658
|
-
recursive: true,
|
|
23659
|
-
force: true
|
|
23660
|
-
});
|
|
23661
|
-
}
|
|
23662
|
-
}
|
|
23663
|
-
// src/tools/runPrecheck.ts
|
|
23664
|
-
var runPrecheck = {
|
|
23665
|
-
name: "deck.run_precheck",
|
|
23666
|
-
title: "Run the pre-check",
|
|
23667
|
-
description: "For builders, on this computer. Runs a quest’s sample tests and the security scan on your entry folder in a local sandbox (Docker), then tells The Deck the result. The hidden tests are never sent; it costs nothing. The folder needs a deck.json naming the command, like {\"run\": [\"python\", \"main.py\", \"{input}\"]}.",
|
|
23668
|
-
async run(backend, args) {
|
|
23669
|
-
const result = await precheckLocally(await backend.getPrecheckKit({ quest_id: args.quest_id }), args.entry_dir);
|
|
23670
|
-
await backend.reportPrecheck({
|
|
23671
|
-
quest_id: args.quest_id,
|
|
23672
|
-
...result
|
|
23673
|
-
});
|
|
23674
|
-
return result;
|
|
23675
|
-
},
|
|
23676
|
-
summary: (out) => {
|
|
23677
|
-
const failed = out.passed < out.total ? `, ${out.total - out.passed} failed` : "";
|
|
23678
|
-
return `${out.passed} of ${out.total} sample tests passed${failed}, scan ${out.scan_clear ? "clear" : "flagged"}. It ran on your computer and cost nothing.`;
|
|
23679
|
-
}
|
|
23680
|
-
};
|
|
23681
23612
|
// ../node_modules/.pnpm/pend@1.2.0/node_modules/pend/index.js
|
|
23682
23613
|
var require_pend = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
23683
23614
|
module.exports = Pend;
|
|
@@ -24962,6 +24893,113 @@ async function unpack(zipPath, destDir, limits = UNPACK_LIMITS) {
|
|
|
24962
24893
|
zip.close();
|
|
24963
24894
|
}
|
|
24964
24895
|
}
|
|
24896
|
+
// src/local/precheck.ts
|
|
24897
|
+
var RUN_LIMIT_MS = 6e5;
|
|
24898
|
+
var noStep = () => void 0;
|
|
24899
|
+
var safeName = (name) => path.basename(name).replaceAll(/[^\w.-]/g, "_") || "file";
|
|
24900
|
+
async function open(openBox) {
|
|
24901
|
+
try {
|
|
24902
|
+
return await openBox();
|
|
24903
|
+
} catch (err) {
|
|
24904
|
+
throw new DeckError("SANDBOX_FAILED", "the local sandbox could not start; the pre-check and real-data runs need Docker and the thedeck-sandbox image", { cause: err });
|
|
24905
|
+
}
|
|
24906
|
+
}
|
|
24907
|
+
async function stageKit(kit, dir) {
|
|
24908
|
+
const tests = [];
|
|
24909
|
+
for (const [i, test] of kit.tests.entries()) {
|
|
24910
|
+
const slot = path.join(dir, String(i));
|
|
24911
|
+
await mkdir(slot, { recursive: true });
|
|
24912
|
+
const given = path.join(slot, `input-${safeName(test.input_file)}`);
|
|
24913
|
+
const expectedFile = path.join(slot, `expected-${safeName(test.expected_file)}`);
|
|
24914
|
+
await writeFile(given, Buffer.from(test.input, "base64"));
|
|
24915
|
+
const inputFile = test.input_folder ? path.join(slot, "input") : given;
|
|
24916
|
+
if (test.input_folder) await unpack(given, inputFile);
|
|
24917
|
+
await writeFile(expectedFile, Buffer.from(test.expected, "base64"));
|
|
24918
|
+
tests.push({
|
|
24919
|
+
kind: "sample",
|
|
24920
|
+
category: null,
|
|
24921
|
+
inputFile,
|
|
24922
|
+
expectedFile,
|
|
24923
|
+
compare: test.compare ?? TEST_DEFAULTS.compare,
|
|
24924
|
+
tolerance: test.tolerance ?? null,
|
|
24925
|
+
timeLimitMs: test.time_limit_ms ?? TEST_DEFAULTS.timeLimitMs,
|
|
24926
|
+
outcome: test.outcome ?? TEST_DEFAULTS.outcome
|
|
24927
|
+
});
|
|
24928
|
+
}
|
|
24929
|
+
return tests;
|
|
24930
|
+
}
|
|
24931
|
+
async function runInSandbox(options, openBox = openSandbox) {
|
|
24932
|
+
let root;
|
|
24933
|
+
try {
|
|
24934
|
+
root = await findEntryRoot(options.entryDir);
|
|
24935
|
+
} catch (err) {
|
|
24936
|
+
if (err instanceof EntryError) throw new DeckError("BAD_INPUT", err.message, { cause: err });
|
|
24937
|
+
throw new DeckError("BAD_INPUT", `${options.entryDir} could not be read`, { cause: err });
|
|
24938
|
+
}
|
|
24939
|
+
const sandbox = await open(openBox);
|
|
24940
|
+
try {
|
|
24941
|
+
const report = await runTests({
|
|
24942
|
+
sandbox,
|
|
24943
|
+
entryDir: root,
|
|
24944
|
+
tests: options.tests,
|
|
24945
|
+
deadline: Date.now() + RUN_LIMIT_MS,
|
|
24946
|
+
onStep: noStep
|
|
24947
|
+
});
|
|
24948
|
+
const scanned = options.withScan ? await scan({
|
|
24949
|
+
sandbox,
|
|
24950
|
+
entryRoot: root,
|
|
24951
|
+
onStep: noStep
|
|
24952
|
+
}) : null;
|
|
24953
|
+
return {
|
|
24954
|
+
report,
|
|
24955
|
+
scanClear: scanned ? scanned.status === "clear" : null
|
|
24956
|
+
};
|
|
24957
|
+
} catch (err) {
|
|
24958
|
+
if (err instanceof EntryError) throw new DeckError("BAD_INPUT", err.message, { cause: err });
|
|
24959
|
+
throw new DeckError("SANDBOX_FAILED", "the run stopped in the local sandbox", { cause: err });
|
|
24960
|
+
} finally {
|
|
24961
|
+
await sandbox.close();
|
|
24962
|
+
}
|
|
24963
|
+
}
|
|
24964
|
+
async function precheckLocally(kit, entryDir, openBox = openSandbox) {
|
|
24965
|
+
if (kit.tests.length === 0) throw new DeckError("NOT_FOUND", "this quest has no sample tests yet");
|
|
24966
|
+
const staged = await mkdtemp(path.join(tmpdir(), "deck-precheck-"));
|
|
24967
|
+
try {
|
|
24968
|
+
const { report, scanClear } = await runInSandbox({
|
|
24969
|
+
entryDir,
|
|
24970
|
+
tests: await stageKit(kit, staged),
|
|
24971
|
+
withScan: true
|
|
24972
|
+
}, openBox);
|
|
24973
|
+
return {
|
|
24974
|
+
passed: report.samplePassed,
|
|
24975
|
+
total: report.sampleTotal,
|
|
24976
|
+
scan_clear: scanClear === true
|
|
24977
|
+
};
|
|
24978
|
+
} finally {
|
|
24979
|
+
await rm(staged, {
|
|
24980
|
+
recursive: true,
|
|
24981
|
+
force: true
|
|
24982
|
+
});
|
|
24983
|
+
}
|
|
24984
|
+
}
|
|
24985
|
+
// src/tools/runPrecheck.ts
|
|
24986
|
+
var runPrecheck = {
|
|
24987
|
+
name: "deck.run_precheck",
|
|
24988
|
+
title: "Run the pre-check",
|
|
24989
|
+
description: "For builders, on this computer. Runs a quest’s sample tests and the security scan on your entry folder in a local sandbox (Docker), then tells The Deck the result. The hidden tests are never sent; it costs nothing. The folder needs a deck.json naming the command, like {\"run\": [\"python\", \"main.py\", \"{input}\"]}. When a test’s input is several files, {input} is a folder holding them.",
|
|
24990
|
+
async run(backend, args) {
|
|
24991
|
+
const result = await precheckLocally(await backend.getPrecheckKit({ quest_id: args.quest_id }), args.entry_dir);
|
|
24992
|
+
await backend.reportPrecheck({
|
|
24993
|
+
quest_id: args.quest_id,
|
|
24994
|
+
...result
|
|
24995
|
+
});
|
|
24996
|
+
return result;
|
|
24997
|
+
},
|
|
24998
|
+
summary: (out) => {
|
|
24999
|
+
const failed = out.passed < out.total ? `, ${out.total - out.passed} failed` : "";
|
|
25000
|
+
return `${out.passed} of ${out.total} sample tests passed${failed}, scan ${out.scan_clear ? "clear" : "flagged"}. It ran on your computer and cost nothing.`;
|
|
25001
|
+
}
|
|
25002
|
+
};
|
|
24965
25003
|
// src/local/realData.ts
|
|
24966
25004
|
var RESULT_EXT = /\.(csv|json|xlsx?|txt|md|xml)$/i;
|
|
24967
25005
|
var ENTRY_MAX_BYTES = 104857600;
|
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.4",
|
|
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
|
+
}
|