@thedeck/mcp 0.1.1 → 0.1.2
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 +78 -78
- package/dist/cli.js +110 -20
- package/dist/index.js +154 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
# @thedeck/mcp
|
|
2
|
-
|
|
3
|
-
The Deck's MCP server. It lets your AI agent draft tasks, send blanked example copies, propose tests, check
|
|
4
|
-
your tasks and their passing entries, run the pre-check on your entry, and try passing entries on your real
|
|
5
|
-
data. It acts as you, with the same rights you have on the site.
|
|
6
|
-
|
|
7
|
-
An agent can never save a card, post a task live, accept an entry, pitch in or pay anyone. You do those on
|
|
8
|
-
The Deck yourself.
|
|
9
|
-
|
|
10
|
-
## Connect
|
|
11
|
-
|
|
12
|
-
Claude Code:
|
|
13
|
-
|
|
14
|
-
```sh
|
|
15
|
-
claude mcp add thedeck -- npx @thedeck/mcp
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Codex:
|
|
19
|
-
|
|
20
|
-
```sh
|
|
21
|
-
codex mcp add thedeck -- npx @thedeck/mcp
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
GitHub Copilot in VS Code:
|
|
25
|
-
|
|
26
|
-
```sh
|
|
27
|
-
code --add-mcp '{"name":"thedeck","command":"npx","args":["@thedeck/mcp"]}'
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
The first time your agent uses a tool, your browser opens The Deck's consent page. Sign in, check what the
|
|
31
|
-
agent may do, and press Allow. The sign-in is saved in `~/.thedeck/credentials.json`; disconnect the agent
|
|
32
|
-
any time in Settings › Agent.
|
|
33
|
-
|
|
34
|
-
ChatGPT and other clients that only connect to remote servers use `https://thedeck.dev/mcp` instead. That
|
|
35
|
-
address has the poster tools and `deck.report_issue` only: nothing there runs on your computer. In Grok, open
|
|
36
|
-
Connectors, choose New Connector, then Custom, enter that address and sign in to The Deck when asked.
|
|
37
|
-
|
|
38
|
-
## Tools
|
|
39
|
-
|
|
40
|
-
| Tool | For | Runs |
|
|
41
|
-
|---|---|---|
|
|
42
|
-
| `deck.post_draft` | posters | The Deck |
|
|
43
|
-
| `deck.add_example_copy` | posters | checks the copy here, then The Deck |
|
|
44
|
-
| `deck.propose_tests` | posters | The Deck |
|
|
45
|
-
| `deck.list_quests` | posters and builders | The Deck |
|
|
46
|
-
| `deck.get_task_status` | posters | The Deck |
|
|
47
|
-
| `deck.get_passing_entries` | posters | The Deck |
|
|
48
|
-
| `deck.try_on_real_data` | posters | a sandbox on this computer |
|
|
49
|
-
| `deck.run_precheck` | builders | a sandbox on this computer |
|
|
50
|
-
| `deck.report_issue` | posters and builders, during the beta, with your yes | The Deck |
|
|
51
|
-
|
|
52
|
-
Real files and real data never leave your computer: only blanked copies and scores do.
|
|
53
|
-
|
|
54
|
-
## The local sandbox
|
|
55
|
-
|
|
56
|
-
`deck.run_precheck` and `deck.try_on_real_data` run entries the way The Deck's runner does, in a Docker
|
|
57
|
-
container with no network. Install Docker and build the sandbox image once from this repository:
|
|
58
|
-
|
|
59
|
-
```sh
|
|
60
|
-
docker build -f runner/Dockerfile --target sandbox -t thedeck-sandbox .
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
An entry folder needs a `deck.json` naming the command that runs it, for example
|
|
64
|
-
`{"run": ["python", "read_invoices.py", "{input}", "{output}"]}`. Without `{output}`, what the program
|
|
65
|
-
prints is its answer.
|
|
66
|
-
|
|
67
|
-
For `deck.try_on_real_data`, put each real input beside its right answer with the same name, such as
|
|
68
|
-
`invoice-01.pdf` and `invoice-01.csv`.
|
|
69
|
-
|
|
70
|
-
## Pre-check from a terminal
|
|
71
|
-
|
|
72
|
-
```sh
|
|
73
|
-
npx -p @thedeck/mcp thedeck precheck <quest id> [entry folder]
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Settings
|
|
77
|
-
|
|
78
|
-
`THEDECK_URL` points the server at another copy of The Deck, for example `http://127.0.0.1:3000` locally.
|
|
1
|
+
# @thedeck/mcp
|
|
2
|
+
|
|
3
|
+
The Deck's MCP server. It lets your AI agent draft tasks, send blanked example copies, propose tests, check
|
|
4
|
+
your tasks and their passing entries, run the pre-check on your entry, and try passing entries on your real
|
|
5
|
+
data. It acts as you, with the same rights you have on the site.
|
|
6
|
+
|
|
7
|
+
An agent can never save a card, post a task live, accept an entry, pitch in or pay anyone. You do those on
|
|
8
|
+
The Deck yourself.
|
|
9
|
+
|
|
10
|
+
## Connect
|
|
11
|
+
|
|
12
|
+
Claude Code:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
claude mcp add thedeck -- npx @thedeck/mcp
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Codex:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
codex mcp add thedeck -- npx @thedeck/mcp
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
GitHub Copilot in VS Code:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
code --add-mcp '{"name":"thedeck","command":"npx","args":["@thedeck/mcp"]}'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The first time your agent uses a tool, your browser opens The Deck's consent page. Sign in, check what the
|
|
31
|
+
agent may do, and press Allow. The sign-in is saved in `~/.thedeck/credentials.json`; disconnect the agent
|
|
32
|
+
any time in Settings › Agent.
|
|
33
|
+
|
|
34
|
+
ChatGPT and other clients that only connect to remote servers use `https://thedeck.dev/mcp` instead. That
|
|
35
|
+
address has the poster tools and `deck.report_issue` only: nothing there runs on your computer. In Grok, open
|
|
36
|
+
Connectors, choose New Connector, then Custom, enter that address and sign in to The Deck when asked.
|
|
37
|
+
|
|
38
|
+
## Tools
|
|
39
|
+
|
|
40
|
+
| Tool | For | Runs |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| `deck.post_draft` | posters | The Deck |
|
|
43
|
+
| `deck.add_example_copy` | posters | checks the copy here, then The Deck; over `/mcp`, after you approve the exact copy in the chat |
|
|
44
|
+
| `deck.propose_tests` | posters | The Deck, after you approve the test plan in the chat |
|
|
45
|
+
| `deck.list_quests` | posters and builders | The Deck |
|
|
46
|
+
| `deck.get_task_status` | posters | The Deck |
|
|
47
|
+
| `deck.get_passing_entries` | posters | The Deck |
|
|
48
|
+
| `deck.try_on_real_data` | posters | a sandbox on this computer |
|
|
49
|
+
| `deck.run_precheck` | builders | a sandbox on this computer |
|
|
50
|
+
| `deck.report_issue` | posters and builders, during the beta, with your yes | The Deck |
|
|
51
|
+
|
|
52
|
+
Real files and real data never leave your computer: only blanked copies and scores do.
|
|
53
|
+
|
|
54
|
+
## The local sandbox
|
|
55
|
+
|
|
56
|
+
`deck.run_precheck` and `deck.try_on_real_data` run entries the way The Deck's runner does, in a Docker
|
|
57
|
+
container with no network. Install Docker and build the sandbox image once from this repository:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
docker build -f runner/Dockerfile --target sandbox -t thedeck-sandbox .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
An entry folder needs a `deck.json` naming the command that runs it, for example
|
|
64
|
+
`{"run": ["python", "read_invoices.py", "{input}", "{output}"]}`. Without `{output}`, what the program
|
|
65
|
+
prints is its answer.
|
|
66
|
+
|
|
67
|
+
For `deck.try_on_real_data`, put each real input beside its right answer with the same name, such as
|
|
68
|
+
`invoice-01.pdf` and `invoice-01.csv`.
|
|
69
|
+
|
|
70
|
+
## Pre-check from a terminal
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
npx -p @thedeck/mcp thedeck precheck <quest id> [entry folder]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Settings
|
|
77
|
+
|
|
78
|
+
`THEDECK_URL` points the server at another copy of The Deck, for example `http://127.0.0.1:3000` locally.
|
package/dist/cli.js
CHANGED
|
@@ -52,6 +52,8 @@ var tagLabel = z.object({
|
|
|
52
52
|
label: z.string().min(1)
|
|
53
53
|
}).strict();
|
|
54
54
|
z.discriminatedUnion("kind", [usernameLabel, tagLabel]);
|
|
55
|
+
// ../shared/src/money.ts
|
|
56
|
+
var MAX_REWARD_CENTS = 2e9;
|
|
55
57
|
// ../shared/src/time.ts
|
|
56
58
|
var zones = null;
|
|
57
59
|
function isTimeZone(value) {
|
|
@@ -133,6 +135,20 @@ z.object({
|
|
|
133
135
|
of: z.number().int().positive(),
|
|
134
136
|
due_at: z.string()
|
|
135
137
|
});
|
|
138
|
+
// ../shared/src/schemas/testCheck.ts
|
|
139
|
+
var TEST_COMPARES = [
|
|
140
|
+
"exact",
|
|
141
|
+
"unordered_lines",
|
|
142
|
+
"numbers",
|
|
143
|
+
"json"
|
|
144
|
+
];
|
|
145
|
+
var TEST_OUTCOMES = ["output", "fails_cleanly"];
|
|
146
|
+
var TEST_DEFAULTS = {
|
|
147
|
+
compare: "exact",
|
|
148
|
+
tolerance: 1e-6,
|
|
149
|
+
timeLimitMs: 1e4,
|
|
150
|
+
outcome: "output"
|
|
151
|
+
};
|
|
136
152
|
// ../shared/src/schemas/mcp.ts
|
|
137
153
|
var questId = z.uuid();
|
|
138
154
|
var section = z.string().trim().min(1).max(BRIEF_LIMITS.section);
|
|
@@ -181,7 +197,9 @@ var postDraftInput = z.object({
|
|
|
181
197
|
deliverables: z.array(deliverableSchema).min(1),
|
|
182
198
|
ends_on: z.iso.date({ error: ASK_END_DATE }).describe("The last day builders can enter (YYYY-MM-DD), as the person stated it, 5 to 60 days from their today. Entries close at 23:59 that day in time_zone."),
|
|
183
199
|
time_zone: z.string({ error: ASK_TIME_ZONE }).refine(isTimeZone, { error: ASK_TIME_ZONE }).describe("The person’s IANA time zone, such as America/New_York, as they confirmed it. The deadline is 23:59 on ends_on in this zone."),
|
|
184
|
-
scenarios: scenarios.describe("The scenarios the person confirmed: each situation that comes in and what should happen then, as you described them back and they agreed.")
|
|
200
|
+
scenarios: scenarios.describe("The scenarios the person confirmed: each situation that comes in and what should happen then, as you described them back and they agreed."),
|
|
201
|
+
reward_cents: z.number().int().positive().max(MAX_REWARD_CENTS).optional().describe("The reward the person agreed to pay for the accepted submission, in US cents. Leave it out until they have said it; never suggest it as settled."),
|
|
202
|
+
visibility: z.enum(["public", "private"]).optional().describe("Who can see the task, as the person chose: public for anyone on The Deck, private for only the builders they invite. Leave it out until they have chosen.")
|
|
185
203
|
});
|
|
186
204
|
var postPart = z.enum([
|
|
187
205
|
"title",
|
|
@@ -198,6 +216,7 @@ var postPart = z.enum([
|
|
|
198
216
|
var postDraftOutput = z.object({
|
|
199
217
|
quest_id: questId,
|
|
200
218
|
review_url: z.url(),
|
|
219
|
+
pay_url: z.url(),
|
|
201
220
|
missing: z.array(z.object({
|
|
202
221
|
part: postPart,
|
|
203
222
|
label: z.string()
|
|
@@ -211,28 +230,50 @@ var addExampleCopyInput = z.object({
|
|
|
211
230
|
filename: z.string().trim().min(1).max(255),
|
|
212
231
|
content: z.string(),
|
|
213
232
|
blanked_summary: z.string().trim().min(1),
|
|
214
|
-
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.")
|
|
233
|
+
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."),
|
|
234
|
+
person_approved: z.literal(true).optional().describe("true only when you showed the person this exact blanked copy and they said yes to sending it. The copy then needs no second approval on The Deck.")
|
|
215
235
|
});
|
|
216
236
|
var addExampleCopyOutput = z.object({
|
|
217
237
|
example_id: z.uuid(),
|
|
218
|
-
status: z.
|
|
238
|
+
status: z.enum(["pending", "approved"])
|
|
239
|
+
});
|
|
240
|
+
var isJson = (text) => {
|
|
241
|
+
try {
|
|
242
|
+
JSON.parse(text);
|
|
243
|
+
return true;
|
|
244
|
+
} catch {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
var proposedTest = z.object({
|
|
249
|
+
name: z.string().trim().min(1),
|
|
250
|
+
kind: z.enum(["sample", "hidden"]),
|
|
251
|
+
input: z.string(),
|
|
252
|
+
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."),
|
|
253
|
+
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."),
|
|
254
|
+
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."),
|
|
255
|
+
tolerance: z.number().nonnegative().optional().describe(`Only with compare numbers: how far each number may be from the expected one. Default ${TEST_DEFAULTS.tolerance}.`),
|
|
256
|
+
time_limit_seconds: z.number().int().min(1).max(120).optional().describe(`How long the program may run on this test before it fails. Default ${TEST_DEFAULTS.timeLimitMs / 1e3}; raise it for a large input.`),
|
|
257
|
+
outcome: z.enum(TEST_OUTCOMES).optional().describe("output (the default): the program must exit normally with the expected output. fails_cleanly: the program must refuse the input with an error exit, neither crashing nor hanging; use it for malformed input.")
|
|
258
|
+
}).refine((t) => t.tolerance === void 0 || t.compare === "numbers", {
|
|
259
|
+
path: ["tolerance"],
|
|
260
|
+
error: "tolerance applies only with compare numbers"
|
|
261
|
+
}).refine((t) => t.compare !== "json" || t.outcome === "fails_cleanly" || isJson(t.expected), {
|
|
262
|
+
path: ["expected"],
|
|
263
|
+
error: "with compare json, expected must be valid JSON"
|
|
219
264
|
});
|
|
220
265
|
var proposeTestsInput = z.object({
|
|
221
266
|
quest_id: questId,
|
|
222
|
-
tests: z.array(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
input: z.string(),
|
|
226
|
-
expected: z.string(),
|
|
227
|
-
category: z.string().trim().min(1).optional()
|
|
228
|
-
})).min(1),
|
|
229
|
-
suggested_pass_mark: z.number().int().positive()
|
|
267
|
+
tests: z.array(proposedTest).min(1).describe("A test plan, not only 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). Give each test the category it covers."),
|
|
268
|
+
suggested_pass_mark: z.number().int().positive(),
|
|
269
|
+
person_approved: z.literal(true, { error: "show the person the test plan in plain words (what each test checks, which ones builders see, the pass mark) and send it only after they say yes, with person_approved true" }).describe("true only when you showed the person this test plan in plain words (what each test checks, which ones builders see, the pass mark) and they said yes. The tests then need no second approval on The Deck.")
|
|
230
270
|
});
|
|
231
271
|
var proposeTestsOutput = z.object({
|
|
232
272
|
quest_id: questId,
|
|
233
273
|
samples: z.number().int().nonnegative(),
|
|
234
274
|
hidden: z.number().int().nonnegative(),
|
|
235
|
-
pass_mark: z.number().int().nonnegative()
|
|
275
|
+
pass_mark: z.number().int().nonnegative(),
|
|
276
|
+
status: z.enum(["pending", "approved"])
|
|
236
277
|
});
|
|
237
278
|
var listQuestsInput = z.object({
|
|
238
279
|
query: z.string().trim().optional(),
|
|
@@ -309,7 +350,11 @@ var precheckKitOutput = z.object({
|
|
|
309
350
|
input_file: z.string().min(1),
|
|
310
351
|
input: z.base64(),
|
|
311
352
|
expected_file: z.string().min(1),
|
|
312
|
-
expected: z.base64()
|
|
353
|
+
expected: z.base64(),
|
|
354
|
+
compare: z.enum(TEST_COMPARES).optional(),
|
|
355
|
+
tolerance: z.number().nonnegative().nullable().optional(),
|
|
356
|
+
time_limit_ms: z.number().int().positive().optional(),
|
|
357
|
+
outcome: z.enum(TEST_OUTCOMES).optional()
|
|
313
358
|
}))
|
|
314
359
|
});
|
|
315
360
|
var precheckReportInput = z.object({
|
|
@@ -368,7 +413,7 @@ var MCP_TOOLS = {
|
|
|
368
413
|
"deck.add_example_copy": {
|
|
369
414
|
input: addExampleCopyInput,
|
|
370
415
|
output: addExampleCopyOutput,
|
|
371
|
-
remote:
|
|
416
|
+
remote: true
|
|
372
417
|
},
|
|
373
418
|
"deck.propose_tests": {
|
|
374
419
|
input: proposeTestsInput,
|
|
@@ -751,6 +796,42 @@ function sameOutput(actual, expected) {
|
|
|
751
796
|
const norm = (b) => b.toString("latin1").replaceAll("\r\n", "\n").trimEnd();
|
|
752
797
|
return norm(actual) === norm(expected);
|
|
753
798
|
}
|
|
799
|
+
var text = (b) => b.toString("utf8").replaceAll("\r\n", "\n").trimEnd();
|
|
800
|
+
var byCodeUnit = (a, b) => Number(a > b) - Number(a < b);
|
|
801
|
+
function sameLinesAnyOrder(actual, expected) {
|
|
802
|
+
const a = actual.split("\n").sort(byCodeUnit);
|
|
803
|
+
const e = expected.split("\n").sort(byCodeUnit);
|
|
804
|
+
return a.length === e.length && a.every((line, i) => line === e[i]);
|
|
805
|
+
}
|
|
806
|
+
var NUMBER = /-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g;
|
|
807
|
+
function sameNumbers(actual, expected, tolerance) {
|
|
808
|
+
const a = actual.match(NUMBER) ?? [];
|
|
809
|
+
const e = expected.match(NUMBER) ?? [];
|
|
810
|
+
const around = (s) => JSON.stringify(s.split(NUMBER));
|
|
811
|
+
return around(actual) === around(expected) && a.length === e.length && a.every((n, i) => Math.abs(Number(n) - Number(e[i])) <= tolerance);
|
|
812
|
+
}
|
|
813
|
+
function canonical(value) {
|
|
814
|
+
if (Array.isArray(value)) return value.map(canonical);
|
|
815
|
+
if (value === null || typeof value !== "object") return value;
|
|
816
|
+
const object = value;
|
|
817
|
+
return Object.fromEntries(Object.keys(object).sort(byCodeUnit).map((key) => [key, canonical(object[key])]));
|
|
818
|
+
}
|
|
819
|
+
function sameJson(actual, expected) {
|
|
820
|
+
try {
|
|
821
|
+
return JSON.stringify(canonical(JSON.parse(actual))) === JSON.stringify(canonical(JSON.parse(expected)));
|
|
822
|
+
} catch {
|
|
823
|
+
return false;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
function outputMatches(actual, expected, compare, tolerance) {
|
|
827
|
+
switch (compare) {
|
|
828
|
+
case "exact": return sameOutput(actual, expected);
|
|
829
|
+
case "unordered_lines": return sameLinesAnyOrder(text(actual), text(expected));
|
|
830
|
+
case "numbers": return sameNumbers(text(actual), text(expected), tolerance ?? TEST_DEFAULTS.tolerance);
|
|
831
|
+
case "json": return sameJson(text(actual), text(expected));
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
var refusedCleanly = (exitCode) => exitCode > 0 && exitCode < 128;
|
|
754
835
|
function slotPaths(index, test) {
|
|
755
836
|
const dir = `${TESTS_DIR}/${index}`;
|
|
756
837
|
return {
|
|
@@ -774,16 +855,20 @@ function groupFailures(failed) {
|
|
|
774
855
|
count
|
|
775
856
|
})).sort((a, b) => b.count - a.count);
|
|
776
857
|
}
|
|
777
|
-
async function runOne(sandbox, command, index, test,
|
|
858
|
+
async function runOne(sandbox, command, index, test, left) {
|
|
778
859
|
const slot = slotPaths(index, test);
|
|
779
860
|
const argv = command.argv.map((a) => a.replaceAll("{input}", slot.input).replaceAll("{output}", slot.output));
|
|
780
861
|
const result = await sandbox.exec(argv, {
|
|
781
862
|
cwd: ENTRY_DIR,
|
|
782
|
-
timeoutMs
|
|
863
|
+
timeoutMs: Math.min(test.timeLimitMs, left)
|
|
783
864
|
});
|
|
784
865
|
if (result.timedOut) return {
|
|
785
866
|
passed: false,
|
|
786
|
-
timedOut:
|
|
867
|
+
timedOut: left <= test.timeLimitMs
|
|
868
|
+
};
|
|
869
|
+
if (test.outcome === "fails_cleanly") return {
|
|
870
|
+
passed: refusedCleanly(result.exitCode),
|
|
871
|
+
timedOut: false
|
|
787
872
|
};
|
|
788
873
|
if (result.exitCode !== 0) return {
|
|
789
874
|
passed: false,
|
|
@@ -791,7 +876,7 @@ async function runOne(sandbox, command, index, test, timeoutMs) {
|
|
|
791
876
|
};
|
|
792
877
|
const actual = command.outputToFile ? await sandbox.readFile(slot.output, OUTPUT_MAX_BYTES) : Buffer.from(result.stdout, "utf8");
|
|
793
878
|
return {
|
|
794
|
-
passed: actual !== null &&
|
|
879
|
+
passed: actual !== null && outputMatches(actual, await readFile(test.expectedFile), test.compare, test.tolerance),
|
|
795
880
|
timedOut: false
|
|
796
881
|
};
|
|
797
882
|
}
|
|
@@ -22512,6 +22597,7 @@ var E2B_TEMPLATE = process.env.E2B_TEMPLATE ?? "thedeck-sandbox";
|
|
|
22512
22597
|
var OUTPUT_CAP = 1048576;
|
|
22513
22598
|
var DOCKER = process.env.DOCKER_BIN ?? "docker";
|
|
22514
22599
|
var run = promisify(execFile);
|
|
22600
|
+
var DOCKER_CLOCK_SLACK = .8;
|
|
22515
22601
|
function exitCodeOf(err) {
|
|
22516
22602
|
if (!err) return 0;
|
|
22517
22603
|
return typeof err.code === "number" ? err.code : -1;
|
|
@@ -22658,7 +22744,7 @@ var DockerSandbox = class DockerSandbox {
|
|
|
22658
22744
|
reject(new Error("docker exec failed", { cause: err }));
|
|
22659
22745
|
return;
|
|
22660
22746
|
}
|
|
22661
|
-
const timedOut = Boolean(err?.killed) || code === 137 && Date.now() - started >= seconds * 1e3;
|
|
22747
|
+
const timedOut = Boolean(err?.killed) || code === 137 && Date.now() - started >= seconds * 1e3 * DOCKER_CLOCK_SLACK;
|
|
22662
22748
|
resolve({
|
|
22663
22749
|
exitCode: code,
|
|
22664
22750
|
stdout: capped(stdout),
|
|
@@ -22940,7 +23026,11 @@ async function stageKit(kit, dir) {
|
|
|
22940
23026
|
kind: "sample",
|
|
22941
23027
|
category: null,
|
|
22942
23028
|
inputFile,
|
|
22943
|
-
expectedFile
|
|
23029
|
+
expectedFile,
|
|
23030
|
+
compare: test.compare ?? TEST_DEFAULTS.compare,
|
|
23031
|
+
tolerance: test.tolerance ?? null,
|
|
23032
|
+
timeLimitMs: test.time_limit_ms ?? TEST_DEFAULTS.timeLimitMs,
|
|
23033
|
+
outcome: test.outcome ?? TEST_DEFAULTS.outcome
|
|
22944
23034
|
});
|
|
22945
23035
|
}
|
|
22946
23036
|
return tests;
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,7 @@ var tagLabel = z.object({
|
|
|
55
55
|
}).strict();
|
|
56
56
|
z.discriminatedUnion("kind", [usernameLabel, tagLabel]);
|
|
57
57
|
// ../shared/src/money.ts
|
|
58
|
+
var MAX_REWARD_CENTS = 2e9;
|
|
58
59
|
function formatMoney(cents, currency = "USD") {
|
|
59
60
|
if (!Number.isSafeInteger(cents)) throw new RangeError(`expected whole cents, got ${cents}`);
|
|
60
61
|
const whole = cents % 100 === 0;
|
|
@@ -152,6 +153,20 @@ z.object({
|
|
|
152
153
|
of: z.number().int().positive(),
|
|
153
154
|
due_at: z.string()
|
|
154
155
|
});
|
|
156
|
+
// ../shared/src/schemas/testCheck.ts
|
|
157
|
+
var TEST_COMPARES = [
|
|
158
|
+
"exact",
|
|
159
|
+
"unordered_lines",
|
|
160
|
+
"numbers",
|
|
161
|
+
"json"
|
|
162
|
+
];
|
|
163
|
+
var TEST_OUTCOMES = ["output", "fails_cleanly"];
|
|
164
|
+
var TEST_DEFAULTS = {
|
|
165
|
+
compare: "exact",
|
|
166
|
+
tolerance: 1e-6,
|
|
167
|
+
timeLimitMs: 1e4,
|
|
168
|
+
outcome: "output"
|
|
169
|
+
};
|
|
155
170
|
// ../shared/src/schemas/mcp.ts
|
|
156
171
|
var questId = z.uuid();
|
|
157
172
|
var section = z.string().trim().min(1).max(BRIEF_LIMITS.section);
|
|
@@ -200,7 +215,9 @@ var postDraftInput = z.object({
|
|
|
200
215
|
deliverables: z.array(deliverableSchema).min(1),
|
|
201
216
|
ends_on: z.iso.date({ error: ASK_END_DATE }).describe("The last day builders can enter (YYYY-MM-DD), as the person stated it, 5 to 60 days from their today. Entries close at 23:59 that day in time_zone."),
|
|
202
217
|
time_zone: z.string({ error: ASK_TIME_ZONE }).refine(isTimeZone, { error: ASK_TIME_ZONE }).describe("The person’s IANA time zone, such as America/New_York, as they confirmed it. The deadline is 23:59 on ends_on in this zone."),
|
|
203
|
-
scenarios: scenarios.describe("The scenarios the person confirmed: each situation that comes in and what should happen then, as you described them back and they agreed.")
|
|
218
|
+
scenarios: scenarios.describe("The scenarios the person confirmed: each situation that comes in and what should happen then, as you described them back and they agreed."),
|
|
219
|
+
reward_cents: z.number().int().positive().max(MAX_REWARD_CENTS).optional().describe("The reward the person agreed to pay for the accepted submission, in US cents. Leave it out until they have said it; never suggest it as settled."),
|
|
220
|
+
visibility: z.enum(["public", "private"]).optional().describe("Who can see the task, as the person chose: public for anyone on The Deck, private for only the builders they invite. Leave it out until they have chosen.")
|
|
204
221
|
});
|
|
205
222
|
var postPart = z.enum([
|
|
206
223
|
"title",
|
|
@@ -217,6 +234,7 @@ var postPart = z.enum([
|
|
|
217
234
|
var postDraftOutput = z.object({
|
|
218
235
|
quest_id: questId,
|
|
219
236
|
review_url: z.url(),
|
|
237
|
+
pay_url: z.url(),
|
|
220
238
|
missing: z.array(z.object({
|
|
221
239
|
part: postPart,
|
|
222
240
|
label: z.string()
|
|
@@ -230,28 +248,50 @@ var addExampleCopyInput = z.object({
|
|
|
230
248
|
filename: z.string().trim().min(1).max(255),
|
|
231
249
|
content: z.string(),
|
|
232
250
|
blanked_summary: z.string().trim().min(1),
|
|
233
|
-
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.")
|
|
251
|
+
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."),
|
|
252
|
+
person_approved: z.literal(true).optional().describe("true only when you showed the person this exact blanked copy and they said yes to sending it. The copy then needs no second approval on The Deck.")
|
|
234
253
|
});
|
|
235
254
|
var addExampleCopyOutput = z.object({
|
|
236
255
|
example_id: z.uuid(),
|
|
237
|
-
status: z.
|
|
256
|
+
status: z.enum(["pending", "approved"])
|
|
257
|
+
});
|
|
258
|
+
var isJson = (text) => {
|
|
259
|
+
try {
|
|
260
|
+
JSON.parse(text);
|
|
261
|
+
return true;
|
|
262
|
+
} catch {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
var proposedTest = z.object({
|
|
267
|
+
name: z.string().trim().min(1),
|
|
268
|
+
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."),
|
|
271
|
+
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
|
+
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
|
+
tolerance: z.number().nonnegative().optional().describe(`Only with compare numbers: how far each number may be from the expected one. Default ${TEST_DEFAULTS.tolerance}.`),
|
|
274
|
+
time_limit_seconds: z.number().int().min(1).max(120).optional().describe(`How long the program may run on this test before it fails. Default ${TEST_DEFAULTS.timeLimitMs / 1e3}; raise it for a large input.`),
|
|
275
|
+
outcome: z.enum(TEST_OUTCOMES).optional().describe("output (the default): the program must exit normally with the expected output. fails_cleanly: the program must refuse the input with an error exit, neither crashing nor hanging; use it for malformed input.")
|
|
276
|
+
}).refine((t) => t.tolerance === void 0 || t.compare === "numbers", {
|
|
277
|
+
path: ["tolerance"],
|
|
278
|
+
error: "tolerance applies only with compare numbers"
|
|
279
|
+
}).refine((t) => t.compare !== "json" || t.outcome === "fails_cleanly" || isJson(t.expected), {
|
|
280
|
+
path: ["expected"],
|
|
281
|
+
error: "with compare json, expected must be valid JSON"
|
|
238
282
|
});
|
|
239
283
|
var proposeTestsInput = z.object({
|
|
240
284
|
quest_id: questId,
|
|
241
|
-
tests: z.array(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
input: z.string(),
|
|
245
|
-
expected: z.string(),
|
|
246
|
-
category: z.string().trim().min(1).optional()
|
|
247
|
-
})).min(1),
|
|
248
|
-
suggested_pass_mark: z.number().int().positive()
|
|
285
|
+
tests: z.array(proposedTest).min(1).describe("A test plan, not only 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). Give each test the category it covers."),
|
|
286
|
+
suggested_pass_mark: z.number().int().positive(),
|
|
287
|
+
person_approved: z.literal(true, { error: "show the person the test plan in plain words (what each test checks, which ones builders see, the pass mark) and send it only after they say yes, with person_approved true" }).describe("true only when you showed the person this test plan in plain words (what each test checks, which ones builders see, the pass mark) and they said yes. The tests then need no second approval on The Deck.")
|
|
249
288
|
});
|
|
250
289
|
var proposeTestsOutput = z.object({
|
|
251
290
|
quest_id: questId,
|
|
252
291
|
samples: z.number().int().nonnegative(),
|
|
253
292
|
hidden: z.number().int().nonnegative(),
|
|
254
|
-
pass_mark: z.number().int().nonnegative()
|
|
293
|
+
pass_mark: z.number().int().nonnegative(),
|
|
294
|
+
status: z.enum(["pending", "approved"])
|
|
255
295
|
});
|
|
256
296
|
var listQuestsInput = z.object({
|
|
257
297
|
query: z.string().trim().optional(),
|
|
@@ -328,7 +368,11 @@ var precheckKitOutput = z.object({
|
|
|
328
368
|
input_file: z.string().min(1),
|
|
329
369
|
input: z.base64(),
|
|
330
370
|
expected_file: z.string().min(1),
|
|
331
|
-
expected: z.base64()
|
|
371
|
+
expected: z.base64(),
|
|
372
|
+
compare: z.enum(TEST_COMPARES).optional(),
|
|
373
|
+
tolerance: z.number().nonnegative().nullable().optional(),
|
|
374
|
+
time_limit_ms: z.number().int().positive().optional(),
|
|
375
|
+
outcome: z.enum(TEST_OUTCOMES).optional()
|
|
332
376
|
}))
|
|
333
377
|
});
|
|
334
378
|
var precheckReportInput = z.object({
|
|
@@ -387,7 +431,7 @@ var MCP_TOOLS = {
|
|
|
387
431
|
"deck.add_example_copy": {
|
|
388
432
|
input: addExampleCopyInput,
|
|
389
433
|
output: addExampleCopyOutput,
|
|
390
|
-
remote:
|
|
434
|
+
remote: true
|
|
391
435
|
},
|
|
392
436
|
"deck.propose_tests": {
|
|
393
437
|
input: proposeTestsInput,
|
|
@@ -871,7 +915,7 @@ var SCRIPT = String.raw`
|
|
|
871
915
|
if (scenarios.length) b.append(el('p', 'lbl', 'Scenarios'), scenarioList(scenarios));
|
|
872
916
|
const missing = o.missing || [];
|
|
873
917
|
b.append(missing.length ? p('', [mute('Still needed: '), missing.map((m) => m.label).join('; ')]) : p('', [em('Nothing missing'), ' · ready to post from The Deck']));
|
|
874
|
-
if (safeUrl(o.review_url)) b.append(el('div', 'acts', [openLink('Review on The Deck', o.review_url), mute('
|
|
918
|
+
if (safeUrl(o.review_url)) b.append(el('div', 'acts', [openLink('Review on The Deck', o.review_url), mute('Paying and posting stay yours.')]));
|
|
875
919
|
},
|
|
876
920
|
entries(b, o) {
|
|
877
921
|
const entries = o.entries || [];
|
|
@@ -1011,25 +1055,29 @@ function registerCard(server, tool) {
|
|
|
1011
1055
|
};
|
|
1012
1056
|
}
|
|
1013
1057
|
// src/guidance.ts
|
|
1058
|
+
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. 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.";
|
|
1014
1059
|
var POSTING_STEPS = [
|
|
1015
1060
|
"To help a person post a task, go through these steps in order, one at a time:",
|
|
1016
|
-
"1. Ask
|
|
1061
|
+
"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.",
|
|
1017
1062
|
"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.",
|
|
1018
|
-
"3.
|
|
1019
|
-
"4. Ask for
|
|
1020
|
-
"5.
|
|
1021
|
-
"6.
|
|
1063
|
+
"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
|
+
"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.",
|
|
1066
|
+
"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."
|
|
1022
1068
|
].join("\n");
|
|
1023
|
-
var NEVER = "You can never save a card, post a task live, accept an entry, pitch in or pay anyone: the person
|
|
1069
|
+
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.";
|
|
1024
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.";
|
|
1025
1071
|
var INSTRUCTIONS = [
|
|
1026
1072
|
"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
|
+
CONVERSATION,
|
|
1027
1074
|
POSTING_STEPS,
|
|
1028
1075
|
NEVER,
|
|
1029
1076
|
REPORTS
|
|
1030
1077
|
].join("\n\n");
|
|
1031
1078
|
var POST_A_TASK = [
|
|
1032
1079
|
"Help me post a task on The Deck. Take it one step at a time and wait for my answer at each step.",
|
|
1080
|
+
CONVERSATION,
|
|
1033
1081
|
POSTING_STEPS,
|
|
1034
1082
|
NEVER,
|
|
1035
1083
|
REPORTS
|
|
@@ -1037,7 +1085,7 @@ var POST_A_TASK = [
|
|
|
1037
1085
|
function registerPostATask(server) {
|
|
1038
1086
|
server.registerPrompt("post_a_task", {
|
|
1039
1087
|
title: "Post a task on The Deck",
|
|
1040
|
-
description: "Work out a task with the person, from what they need to
|
|
1088
|
+
description: "Work out a task with the person, one question at a time, from what they need to the one link they open to pay and post it."
|
|
1041
1089
|
}, () => ({ messages: [{
|
|
1042
1090
|
role: "user",
|
|
1043
1091
|
content: {
|
|
@@ -1083,6 +1131,7 @@ async function checkBlankedCopy(input, dir) {
|
|
|
1083
1131
|
};
|
|
1084
1132
|
}
|
|
1085
1133
|
// src/tools/addExampleCopy.ts
|
|
1134
|
+
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.` : `Blanked copy sent as example ${out.example_id}, status ${out.status}. It waits on the poster’s Examples list for approval.`;
|
|
1086
1135
|
var addExampleCopy = {
|
|
1087
1136
|
name: "deck.add_example_copy",
|
|
1088
1137
|
title: "Send a blanked example copy",
|
|
@@ -1094,7 +1143,23 @@ var addExampleCopy = {
|
|
|
1094
1143
|
filename: copy.filename
|
|
1095
1144
|
});
|
|
1096
1145
|
},
|
|
1097
|
-
summary
|
|
1146
|
+
summary
|
|
1147
|
+
};
|
|
1148
|
+
var addExampleCopyRemote = {
|
|
1149
|
+
name: "deck.add_example_copy",
|
|
1150
|
+
title: "Send a blanked example copy",
|
|
1151
|
+
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. Never send the original.",
|
|
1152
|
+
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");
|
|
1154
|
+
const size = decodeCopy(args.content).length;
|
|
1155
|
+
if (size === 0) throw new DeckError("BAD_INPUT", "the copy is empty");
|
|
1156
|
+
if (size > 52428800) throw new DeckError("FILE_TOO_LARGE", `the copy is ${size} bytes; the limit is ${COPY_MAX_BYTES}`);
|
|
1157
|
+
return backend.addExampleCopy({
|
|
1158
|
+
...args,
|
|
1159
|
+
filename: blankedName(args.filename)
|
|
1160
|
+
});
|
|
1161
|
+
},
|
|
1162
|
+
summary
|
|
1098
1163
|
};
|
|
1099
1164
|
// src/tools/getPassingEntries.ts
|
|
1100
1165
|
var line$1 = (e, i) => `${i + 1}. ${e.identity.label} · entry ${e.entry_id} · version ${e.version} · samples ${e.sample.passed} of ${e.sample.total} · hidden ${e.hidden.passed} of ${e.hidden.total} · download ${e.download_url} (expires ${utc(e.expires_at)})`;
|
|
@@ -1150,11 +1215,11 @@ var listQuests = {
|
|
|
1150
1215
|
var postDraft = {
|
|
1151
1216
|
name: "deck.post_draft",
|
|
1152
1217
|
title: "Draft a task",
|
|
1153
|
-
description: "For posters. Saves a task brief on The Deck as a draft, or updates the draft named by quest_id. The deadline
|
|
1218
|
+
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 on Stripe themselves, which posts the task. An agent never posts a task live and never spends money.",
|
|
1154
1219
|
run: (backend, args) => backend.postDraft(args),
|
|
1155
1220
|
summary: (out) => {
|
|
1156
|
-
|
|
1157
|
-
|
|
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 saved = `Draft saved as quest ${out.quest_id}. The poster checks it at ${out.review_url}; paying and posting stay theirs.`;
|
|
1158
1223
|
const needsTests = out.missing.some((m) => m.part === "tests" || m.part === "examples");
|
|
1159
1224
|
return [
|
|
1160
1225
|
saved,
|
|
@@ -1167,9 +1232,9 @@ var postDraft = {
|
|
|
1167
1232
|
var proposeTests = {
|
|
1168
1233
|
name: "deck.propose_tests",
|
|
1169
1234
|
title: "Propose tests",
|
|
1170
|
-
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.
|
|
1235
|
+
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. 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.",
|
|
1171
1236
|
run: (backend, args) => backend.proposeTests(args),
|
|
1172
|
-
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}. The poster approves them
|
|
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.")
|
|
1173
1238
|
};
|
|
1174
1239
|
// src/tools/reportIssue.ts
|
|
1175
1240
|
var reportIssue = {
|
|
@@ -1193,7 +1258,6 @@ var SERVER_INFO = {
|
|
|
1193
1258
|
};
|
|
1194
1259
|
var SHARED_TOOLS = [
|
|
1195
1260
|
postDraft,
|
|
1196
|
-
addExampleCopy,
|
|
1197
1261
|
proposeTests,
|
|
1198
1262
|
listQuests,
|
|
1199
1263
|
getTaskStatus,
|
|
@@ -1250,7 +1314,11 @@ function register(server, tool, backend) {
|
|
|
1250
1314
|
function createDeckServer(backend, options = { remote: false }) {
|
|
1251
1315
|
const server = new McpServer(SERVER_INFO, { instructions: INSTRUCTIONS });
|
|
1252
1316
|
registerPostATask(server);
|
|
1253
|
-
const tools = options.remote ?
|
|
1317
|
+
const tools = options.remote ? [...SHARED_TOOLS, addExampleCopyRemote] : [
|
|
1318
|
+
...SHARED_TOOLS,
|
|
1319
|
+
addExampleCopy,
|
|
1320
|
+
...options.localTools ?? []
|
|
1321
|
+
];
|
|
1254
1322
|
for (const tool of tools) {
|
|
1255
1323
|
if (options.remote && !MCP_TOOLS[tool.name].remote) continue;
|
|
1256
1324
|
register(server, tool, backend);
|
|
@@ -1299,6 +1367,42 @@ function sameOutput(actual, expected) {
|
|
|
1299
1367
|
const norm = (b) => b.toString("latin1").replaceAll("\r\n", "\n").trimEnd();
|
|
1300
1368
|
return norm(actual) === norm(expected);
|
|
1301
1369
|
}
|
|
1370
|
+
var text = (b) => b.toString("utf8").replaceAll("\r\n", "\n").trimEnd();
|
|
1371
|
+
var byCodeUnit = (a, b) => Number(a > b) - Number(a < b);
|
|
1372
|
+
function sameLinesAnyOrder(actual, expected) {
|
|
1373
|
+
const a = actual.split("\n").sort(byCodeUnit);
|
|
1374
|
+
const e = expected.split("\n").sort(byCodeUnit);
|
|
1375
|
+
return a.length === e.length && a.every((line, i) => line === e[i]);
|
|
1376
|
+
}
|
|
1377
|
+
var NUMBER = /-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g;
|
|
1378
|
+
function sameNumbers(actual, expected, tolerance) {
|
|
1379
|
+
const a = actual.match(NUMBER) ?? [];
|
|
1380
|
+
const e = expected.match(NUMBER) ?? [];
|
|
1381
|
+
const around = (s) => JSON.stringify(s.split(NUMBER));
|
|
1382
|
+
return around(actual) === around(expected) && a.length === e.length && a.every((n, i) => Math.abs(Number(n) - Number(e[i])) <= tolerance);
|
|
1383
|
+
}
|
|
1384
|
+
function canonical(value) {
|
|
1385
|
+
if (Array.isArray(value)) return value.map(canonical);
|
|
1386
|
+
if (value === null || typeof value !== "object") return value;
|
|
1387
|
+
const object = value;
|
|
1388
|
+
return Object.fromEntries(Object.keys(object).sort(byCodeUnit).map((key) => [key, canonical(object[key])]));
|
|
1389
|
+
}
|
|
1390
|
+
function sameJson(actual, expected) {
|
|
1391
|
+
try {
|
|
1392
|
+
return JSON.stringify(canonical(JSON.parse(actual))) === JSON.stringify(canonical(JSON.parse(expected)));
|
|
1393
|
+
} catch {
|
|
1394
|
+
return false;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
function outputMatches(actual, expected, compare, tolerance) {
|
|
1398
|
+
switch (compare) {
|
|
1399
|
+
case "exact": return sameOutput(actual, expected);
|
|
1400
|
+
case "unordered_lines": return sameLinesAnyOrder(text(actual), text(expected));
|
|
1401
|
+
case "numbers": return sameNumbers(text(actual), text(expected), tolerance ?? TEST_DEFAULTS.tolerance);
|
|
1402
|
+
case "json": return sameJson(text(actual), text(expected));
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
var refusedCleanly = (exitCode) => exitCode > 0 && exitCode < 128;
|
|
1302
1406
|
function slotPaths(index, test) {
|
|
1303
1407
|
const dir = `${TESTS_DIR}/${index}`;
|
|
1304
1408
|
return {
|
|
@@ -1322,16 +1426,20 @@ function groupFailures(failed) {
|
|
|
1322
1426
|
count
|
|
1323
1427
|
})).sort((a, b) => b.count - a.count);
|
|
1324
1428
|
}
|
|
1325
|
-
async function runOne(sandbox, command, index, test,
|
|
1429
|
+
async function runOne(sandbox, command, index, test, left) {
|
|
1326
1430
|
const slot = slotPaths(index, test);
|
|
1327
1431
|
const argv = command.argv.map((a) => a.replaceAll("{input}", slot.input).replaceAll("{output}", slot.output));
|
|
1328
1432
|
const result = await sandbox.exec(argv, {
|
|
1329
1433
|
cwd: ENTRY_DIR,
|
|
1330
|
-
timeoutMs
|
|
1434
|
+
timeoutMs: Math.min(test.timeLimitMs, left)
|
|
1331
1435
|
});
|
|
1332
1436
|
if (result.timedOut) return {
|
|
1333
1437
|
passed: false,
|
|
1334
|
-
timedOut:
|
|
1438
|
+
timedOut: left <= test.timeLimitMs
|
|
1439
|
+
};
|
|
1440
|
+
if (test.outcome === "fails_cleanly") return {
|
|
1441
|
+
passed: refusedCleanly(result.exitCode),
|
|
1442
|
+
timedOut: false
|
|
1335
1443
|
};
|
|
1336
1444
|
if (result.exitCode !== 0) return {
|
|
1337
1445
|
passed: false,
|
|
@@ -1339,7 +1447,7 @@ async function runOne(sandbox, command, index, test, timeoutMs) {
|
|
|
1339
1447
|
};
|
|
1340
1448
|
const actual = command.outputToFile ? await sandbox.readFile(slot.output, OUTPUT_MAX_BYTES) : Buffer.from(result.stdout, "utf8");
|
|
1341
1449
|
return {
|
|
1342
|
-
passed: actual !== null &&
|
|
1450
|
+
passed: actual !== null && outputMatches(actual, await readFile(test.expectedFile), test.compare, test.tolerance),
|
|
1343
1451
|
timedOut: false
|
|
1344
1452
|
};
|
|
1345
1453
|
}
|
|
@@ -23060,6 +23168,7 @@ var E2B_TEMPLATE = process.env.E2B_TEMPLATE ?? "thedeck-sandbox";
|
|
|
23060
23168
|
var OUTPUT_CAP = 1048576;
|
|
23061
23169
|
var DOCKER = process.env.DOCKER_BIN ?? "docker";
|
|
23062
23170
|
var run = promisify(execFile);
|
|
23171
|
+
var DOCKER_CLOCK_SLACK = .8;
|
|
23063
23172
|
function exitCodeOf(err) {
|
|
23064
23173
|
if (!err) return 0;
|
|
23065
23174
|
return typeof err.code === "number" ? err.code : -1;
|
|
@@ -23206,7 +23315,7 @@ var DockerSandbox = class DockerSandbox {
|
|
|
23206
23315
|
reject(new Error("docker exec failed", { cause: err }));
|
|
23207
23316
|
return;
|
|
23208
23317
|
}
|
|
23209
|
-
const timedOut = Boolean(err?.killed) || code === 137 && Date.now() - started >= seconds * 1e3;
|
|
23318
|
+
const timedOut = Boolean(err?.killed) || code === 137 && Date.now() - started >= seconds * 1e3 * DOCKER_CLOCK_SLACK;
|
|
23210
23319
|
resolve({
|
|
23211
23320
|
exitCode: code,
|
|
23212
23321
|
stdout: capped(stdout),
|
|
@@ -23488,7 +23597,11 @@ async function stageKit(kit, dir) {
|
|
|
23488
23597
|
kind: "sample",
|
|
23489
23598
|
category: null,
|
|
23490
23599
|
inputFile,
|
|
23491
|
-
expectedFile
|
|
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
|
|
23492
23605
|
});
|
|
23493
23606
|
}
|
|
23494
23607
|
return tests;
|
|
@@ -24872,7 +24985,11 @@ async function pairRealData(dataDir) {
|
|
|
24872
24985
|
kind: "sample",
|
|
24873
24986
|
category: null,
|
|
24874
24987
|
inputFile: path.join(dataDir, input),
|
|
24875
|
-
expectedFile: path.join(dataDir, answer)
|
|
24988
|
+
expectedFile: path.join(dataDir, answer),
|
|
24989
|
+
compare: "exact",
|
|
24990
|
+
tolerance: null,
|
|
24991
|
+
timeLimitMs: RUN_LIMIT_MS,
|
|
24992
|
+
outcome: "output"
|
|
24876
24993
|
});
|
|
24877
24994
|
}
|
|
24878
24995
|
if (tests.length === 0) throw new DeckError("BAD_INPUT", `${dataDir} has no pairs: put each real input beside its right answer with the same name, like invoice-01.pdf and invoice-01.csv`);
|