@50arms/platform-mcp 0.1.463 → 0.1.465
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/access-request.js +19 -6
- package/dist/agent-gate.js +19 -5
- package/dist/board-id.js +8 -2
- package/dist/checkout-docs-root.js +10 -2
- package/dist/clear-control.js +18 -4
- package/dist/compaction-control.js +30 -7
- package/dist/credential.js +10 -2
- package/dist/danxbot-api-examples.js +20 -3
- package/dist/design-screenshot.js +22 -5
- package/dist/digest-hold.js +14 -3
- package/dist/docs-tools.js +46 -12
- package/dist/durable-write.js +10 -2
- package/dist/forbidden-hint.js +13 -2
- package/dist/guarded-calls.js +7 -2
- package/dist/handlers.js +70 -15
- package/dist/heartbeat-reporter.js +8 -3
- package/dist/http-client.js +5 -3
- package/dist/index.js +252 -82
- package/dist/job-key.js +47 -0
- package/dist/json-body.js +3 -1
- package/dist/key-revoked-halt.js +2 -1
- package/dist/leftover-wire.js +17 -4
- package/dist/lifecycle.js +11 -3
- package/dist/listen.js +242 -64
- package/dist/listener-reminder.js +8 -2
- package/dist/machine-daemon/autostart.js +16 -4
- package/dist/machine-daemon/beat.js +18 -4
- package/dist/machine-daemon/cli.js +15 -4
- package/dist/machine-daemon/install.js +33 -9
- package/dist/machine-daemon/leftovers.js +134 -30
- package/dist/machine-daemon/state.js +9 -3
- package/dist/machine-daemon.js +531 -128
- package/dist/machine-registration.js +27 -6
- package/dist/machine-secret.js +8 -3
- package/dist/machine-toolkit.js +377 -81
- package/dist/mini-app-build.js +19 -5
- package/dist/mini-app-checkout.js +38 -10
- package/dist/mini-app-output.js +22 -5
- package/dist/mini-app-publish.js +34 -11
- package/dist/mini-app-restore.js +30 -9
- package/dist/one-line.js +3 -1
- package/dist/permission-request.js +14 -3
- package/dist/permission-watch.js +10 -3
- package/dist/plan-events-relay.js +96 -19
- package/dist/plan-events-tool.js +9 -2
- package/dist/plugin-publish.js +23 -6
- package/dist/plugin-screenshot.js +18 -6
- package/dist/restart-notice.js +47 -15
- package/dist/result-limit.js +6 -1
- package/dist/role-instruction-file.js +16 -4
- package/dist/route-board-scope.generated.js +5 -0
- package/dist/route-board-scope.js +6 -2
- package/dist/session-access.js +114 -33
- package/dist/session-connection.js +23 -7
- package/dist/session-control-file.js +1 -1
- package/dist/session-key.js +12 -4
- package/dist/session-options.js +6 -2
- package/dist/session-stats.js +2 -1
- package/dist/session-stream.js +81 -20
- package/dist/shutdown.js +3 -1
- package/dist/subagents-live.js +8 -2
- package/dist/terms-halt.js +4 -2
- package/dist/tool-access.js +17 -4
- package/dist/tool-surface.js +9 -2
- package/dist/transcript-lineage.js +5 -2
- package/dist/urgent-records.js +1 -0
- package/package.json +1 -1
package/dist/mini-app-build.js
CHANGED
|
@@ -41,7 +41,10 @@ async function killProcessTree(pid, child) {
|
|
|
41
41
|
return;
|
|
42
42
|
if (process.platform === "win32") {
|
|
43
43
|
const status = await new Promise((resolve) => {
|
|
44
|
-
const killer = spawn("taskkill", ["/T", "/F", "/PID", String(pid)], {
|
|
44
|
+
const killer = spawn("taskkill", ["/T", "/F", "/PID", String(pid)], {
|
|
45
|
+
windowsHide: true,
|
|
46
|
+
stdio: "ignore",
|
|
47
|
+
});
|
|
45
48
|
killer.once("error", () => resolve(null));
|
|
46
49
|
killer.once("close", (code) => resolve(code));
|
|
47
50
|
});
|
|
@@ -120,14 +123,20 @@ export async function runBuildCommand(input, timeoutMs = BUILD_TIMEOUT_MS, pipeG
|
|
|
120
123
|
resolve({ code, signal, text, truncated, timedOut: false });
|
|
121
124
|
});
|
|
122
125
|
});
|
|
123
|
-
const note = done.truncated
|
|
126
|
+
const note = done.truncated
|
|
127
|
+
? `[output truncated: only the last ${MAX_BUILD_OUTPUT_CHARS} characters are shown]\n`
|
|
128
|
+
: "";
|
|
124
129
|
const output = done.text.trim();
|
|
125
130
|
if (done.timedOut) {
|
|
126
131
|
throw new Error(`mini_app_publish: the build did not finish within ${timeoutMs / 1000}s and was killed${output === "" ? "" : `; its output so far:\n${note}${output}`}`);
|
|
127
132
|
}
|
|
128
133
|
if (done.code !== 0) {
|
|
129
|
-
const ended = done.signal !== null
|
|
130
|
-
|
|
134
|
+
const ended = done.signal !== null
|
|
135
|
+
? `was killed by ${done.signal}`
|
|
136
|
+
: `exited with code ${String(done.code)}`;
|
|
137
|
+
throw new Error(output
|
|
138
|
+
? `${note}${output}`
|
|
139
|
+
: `mini_app_publish: the build process ${ended} and wrote nothing`);
|
|
131
140
|
}
|
|
132
141
|
if (done.text !== "")
|
|
133
142
|
process.stderr.write(done.text);
|
|
@@ -144,7 +153,12 @@ export async function buildMiniApp(input, timeoutMs = BUILD_TIMEOUT_MS, pipeGrac
|
|
|
144
153
|
}
|
|
145
154
|
finally {
|
|
146
155
|
// A temp folder danxbot made: a failed delete (a killed build's file handle still open on Windows) leaks only that folder and must not discard the build.
|
|
147
|
-
await rm(outputDir, {
|
|
156
|
+
await rm(outputDir, {
|
|
157
|
+
recursive: true,
|
|
158
|
+
force: true,
|
|
159
|
+
maxRetries: OUTPUT_DELETE_RETRIES,
|
|
160
|
+
retryDelay: OUTPUT_DELETE_RETRY_MS,
|
|
161
|
+
}).catch((err) => {
|
|
148
162
|
process.stderr.write(`mini_app_publish: could not delete the temporary output folder ${outputDir}: ${err.message}\n`);
|
|
149
163
|
});
|
|
150
164
|
}
|
|
@@ -18,7 +18,8 @@ export const MINI_APP_TARGET_KEYS = ["name", "command"];
|
|
|
18
18
|
* fault in what the dashboard answered: it fails loud naming the index and field, and the row is never repaired.
|
|
19
19
|
*/
|
|
20
20
|
export function parseMiniAppTargets(body, repo) {
|
|
21
|
-
const targets = body
|
|
21
|
+
const targets = body
|
|
22
|
+
?.mini_app_targets;
|
|
22
23
|
if (!Array.isArray(targets)) {
|
|
23
24
|
throw new Error(`mini_app_publish: GET /api/repos/${repo} answered without a mini_app_targets array (a dashboard older than this tool, or a repo it does not serve?)`);
|
|
24
25
|
}
|
|
@@ -34,10 +35,15 @@ export function parseMiniAppTargets(body, repo) {
|
|
|
34
35
|
throw new Error(`mini_app_publish: ${where} has no "name" (a non-empty string is required)`);
|
|
35
36
|
}
|
|
36
37
|
const command = fields.command;
|
|
37
|
-
if (!Array.isArray(command) ||
|
|
38
|
+
if (!Array.isArray(command) ||
|
|
39
|
+
command.length < 2 ||
|
|
40
|
+
command.some((part) => typeof part !== "string" || part === "")) {
|
|
38
41
|
throw new Error(`mini_app_publish: ${where} has no "command" (an array of at least two non-empty strings is required: the program, then the committed script)`);
|
|
39
42
|
}
|
|
40
|
-
return {
|
|
43
|
+
return {
|
|
44
|
+
name: fields.name,
|
|
45
|
+
command: command,
|
|
46
|
+
};
|
|
41
47
|
});
|
|
42
48
|
}
|
|
43
49
|
/** The declared target named `name`, or the refusal an agent can act on: no targets at all, or the declared names. */
|
|
@@ -54,7 +60,10 @@ export function pickMiniAppTarget(targets, name, repo) {
|
|
|
54
60
|
/** True when `child` is strictly inside `parent` (both absolute, already real paths). */
|
|
55
61
|
export function isStrictlyInside(parent, child) {
|
|
56
62
|
const rel = path.relative(parent, child);
|
|
57
|
-
return rel !== "" &&
|
|
63
|
+
return (rel !== "" &&
|
|
64
|
+
rel !== ".." &&
|
|
65
|
+
!rel.startsWith(`..${path.sep}`) &&
|
|
66
|
+
!path.isAbsolute(rel));
|
|
58
67
|
}
|
|
59
68
|
/** `p` relative to `base`, always with forward slashes (the form the dashboard stores repo-relative paths in). */
|
|
60
69
|
export function relativePosix(base, p) {
|
|
@@ -69,7 +78,11 @@ async function git(repoDir, args) {
|
|
|
69
78
|
catch (err) {
|
|
70
79
|
const failure = err;
|
|
71
80
|
if (typeof failure.code === "number")
|
|
72
|
-
return {
|
|
81
|
+
return {
|
|
82
|
+
code: failure.code,
|
|
83
|
+
stdout: failure.stdout ?? "",
|
|
84
|
+
stderr: failure.stderr ?? "",
|
|
85
|
+
};
|
|
73
86
|
throw err;
|
|
74
87
|
}
|
|
75
88
|
}
|
|
@@ -160,8 +173,9 @@ export async function checkTarget(target, repo, repoRoot, dirAbs, platform) {
|
|
|
160
173
|
if (isInvalidProgram(program))
|
|
161
174
|
throw refuse("command[0]", program, "must be a bare program name, with no path separator or whitespace");
|
|
162
175
|
const lower = program.toLowerCase();
|
|
163
|
-
if (platform === "win32" &&
|
|
164
|
-
|
|
176
|
+
if (platform === "win32" &&
|
|
177
|
+
(WINDOWS_SHIM_PROGRAMS.has(lower) || /\.(cmd|bat)$/.test(lower))) {
|
|
178
|
+
throw refuse("command[0]", program, 'is a .cmd shim, which cannot be started without a shell: name `node` and a committed script instead, e.g. ["node", "scripts/build-mini-app.mjs"]');
|
|
165
179
|
}
|
|
166
180
|
if (isUnsafeTargetPath(script))
|
|
167
181
|
throw refuse("command[1]", script, "must be a repo-relative path with no `..` segment, backslash, absolute path or drive letter");
|
|
@@ -170,12 +184,23 @@ export async function checkTarget(target, repo, repoRoot, dirAbs, platform) {
|
|
|
170
184
|
throw new Error(`mini_app_publish: dir "${dirAbs}" is not inside the repo root ${repoRoot}`);
|
|
171
185
|
await requireUntrackedAndIgnored(repoRoot, designDirRel);
|
|
172
186
|
// DX-5294 known limit: this proves the NAMED script is committed and unchanged, not what that script imports.
|
|
173
|
-
const known = await git(repoRoot, [
|
|
187
|
+
const known = await git(repoRoot, [
|
|
188
|
+
"ls-files",
|
|
189
|
+
"--error-unmatch",
|
|
190
|
+
"--",
|
|
191
|
+
script,
|
|
192
|
+
]);
|
|
174
193
|
if (known.code === 1)
|
|
175
194
|
throw refuse("command[1]", script, "is not tracked by git: commit the build script before publishing");
|
|
176
195
|
if (known.code !== 0)
|
|
177
196
|
throw new Error(`mini_app_publish: git ls-files failed (exit ${known.code}) for ${script}: ${known.stderr.trim()}`);
|
|
178
|
-
const changed = await git(repoRoot, [
|
|
197
|
+
const changed = await git(repoRoot, [
|
|
198
|
+
"diff",
|
|
199
|
+
"--quiet",
|
|
200
|
+
"HEAD",
|
|
201
|
+
"--",
|
|
202
|
+
script,
|
|
203
|
+
]);
|
|
179
204
|
if (changed.code === 1)
|
|
180
205
|
throw refuse("command[1]", script, "has changes against HEAD: commit the build script before publishing");
|
|
181
206
|
if (changed.code !== 0)
|
|
@@ -199,7 +224,10 @@ export async function readSourceFiles(dirAbs, repoRoot) {
|
|
|
199
224
|
else if (entry.isFile()) {
|
|
200
225
|
const bytes = await readFile(full);
|
|
201
226
|
try {
|
|
202
|
-
files.push({
|
|
227
|
+
files.push({
|
|
228
|
+
path: relativePosix(repoRoot, full),
|
|
229
|
+
content: decoder.decode(bytes),
|
|
230
|
+
});
|
|
203
231
|
}
|
|
204
232
|
catch {
|
|
205
233
|
throw new Error(`mini_app_publish: ${relativePosix(repoRoot, full)} is not valid UTF-8 text; a design folder holds text files only`);
|
package/dist/mini-app-output.js
CHANGED
|
@@ -16,7 +16,9 @@ export const INDEX_HTML = "index.html";
|
|
|
16
16
|
*/
|
|
17
17
|
const ESCAPED_COMMENT_OPEN = "\\x3C!--";
|
|
18
18
|
function escapeScript(js) {
|
|
19
|
-
return js
|
|
19
|
+
return js
|
|
20
|
+
.replace(/<\/(script)/gi, "<\\/$1")
|
|
21
|
+
.replace(/<!--/g, ESCAPED_COMMENT_OPEN);
|
|
20
22
|
}
|
|
21
23
|
function refEndsWith(ref, name) {
|
|
22
24
|
const clean = ref.split(/[?#]/)[0];
|
|
@@ -79,7 +81,11 @@ async function listFiles(dir) {
|
|
|
79
81
|
*/
|
|
80
82
|
export async function readBuildOutput(outDir) {
|
|
81
83
|
const files = await listFiles(outDir);
|
|
82
|
-
const slots = {
|
|
84
|
+
const slots = {
|
|
85
|
+
html: [],
|
|
86
|
+
js: [],
|
|
87
|
+
css: [],
|
|
88
|
+
};
|
|
83
89
|
const extras = [];
|
|
84
90
|
for (const file of files) {
|
|
85
91
|
const ext = path.extname(file).toLowerCase();
|
|
@@ -97,12 +103,23 @@ export async function readBuildOutput(outDir) {
|
|
|
97
103
|
const named = extras.map((f) => relativePosix(outDir, f)).sort();
|
|
98
104
|
throw new Error(`mini_app_publish: the build wrote an unexpected file ${named.join(", ")}: the output must be only ${INDEX_HTML}, one .js and one .css`);
|
|
99
105
|
}
|
|
100
|
-
for (const [kind, label] of [
|
|
106
|
+
for (const [kind, label] of [
|
|
107
|
+
["html", INDEX_HTML],
|
|
108
|
+
["js", ".js file"],
|
|
109
|
+
["css", ".css file"],
|
|
110
|
+
]) {
|
|
101
111
|
if (slots[kind].length === 0)
|
|
102
112
|
throw new Error(`mini_app_publish: the build wrote no ${label}`);
|
|
103
113
|
}
|
|
104
|
-
const asset = async (file) => ({
|
|
105
|
-
|
|
114
|
+
const asset = async (file) => ({
|
|
115
|
+
name: path.basename(file),
|
|
116
|
+
text: await readFile(file, "utf8"),
|
|
117
|
+
});
|
|
118
|
+
return {
|
|
119
|
+
html: await asset(slots.html[0]),
|
|
120
|
+
js: await asset(slots.js[0]),
|
|
121
|
+
css: await asset(slots.css[0]),
|
|
122
|
+
};
|
|
106
123
|
}
|
|
107
124
|
/** The build output folder as the one page the dashboard receives: read it (exactly `index.html`, one `.js`, one `.css`) and fold the script and stylesheet in. */
|
|
108
125
|
export async function foldBuildOutput(outDir) {
|
package/dist/mini-app-publish.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { buildMiniApp, writeLocalHtml } from "./mini-app-build.js";
|
|
23
23
|
import { checkTarget, parseMiniAppTargets, pickMiniAppTarget, readHeadCommit, readSourceFiles, resolveDesignDir, resolveRepoRoot, } from "./mini-app-checkout.js";
|
|
24
|
-
import { captureScreenshot } from "./design-screenshot.js";
|
|
24
|
+
import { captureScreenshot, } from "./design-screenshot.js";
|
|
25
25
|
import { danxbotApi } from "./handlers.js";
|
|
26
26
|
function fail(message) {
|
|
27
27
|
throw new Error(`mini_app_publish: ${message}`);
|
|
@@ -48,7 +48,10 @@ async function readCardBoard(client, cardId) {
|
|
|
48
48
|
});
|
|
49
49
|
if (!card.ok)
|
|
50
50
|
return card;
|
|
51
|
-
return {
|
|
51
|
+
return {
|
|
52
|
+
ok: true,
|
|
53
|
+
board: refField(card.body, "board_id", `GET /api/issues/${cardId}`),
|
|
54
|
+
};
|
|
52
55
|
}
|
|
53
56
|
export async function miniAppPublish(client, args, deps) {
|
|
54
57
|
// DX-4729: refused before any call, so a blank note never leaves a built page or a screenshot behind.
|
|
@@ -65,7 +68,7 @@ export async function miniAppPublish(client, args, deps) {
|
|
|
65
68
|
fail("`destination.design_title` must not be blank");
|
|
66
69
|
// DX-5856: a new design names the element it decides (its design problem is that element's); a revision stays on its design's problem.
|
|
67
70
|
if (hasTitle && args.destination.design_element === undefined)
|
|
68
|
-
fail(
|
|
71
|
+
fail('`destination.design_element` is required with `destination.design_title`: name the one thing this design decides (e.g. "Indicator pill")');
|
|
69
72
|
if (hasNo && args.destination.design_element !== undefined)
|
|
70
73
|
fail("`destination.design_element` goes only with `destination.design_title`: a revision stays on its design's problem");
|
|
71
74
|
if (args.destination.design_element?.trim() === "")
|
|
@@ -78,7 +81,10 @@ export async function miniAppPublish(client, args, deps) {
|
|
|
78
81
|
// read from the board, never parsed out of its id and never from an env var.
|
|
79
82
|
let repo = args.target.repo;
|
|
80
83
|
if (repo === undefined) {
|
|
81
|
-
const boardRow = await danxbotApi(client, {
|
|
84
|
+
const boardRow = await danxbotApi(client, {
|
|
85
|
+
method: "GET",
|
|
86
|
+
path: `/api/boards/${board}`,
|
|
87
|
+
});
|
|
82
88
|
if (!boardRow.ok)
|
|
83
89
|
return boardRow;
|
|
84
90
|
repo = field(boardRow.body, "repo_name", `GET /api/boards/${board}`);
|
|
@@ -109,20 +115,35 @@ export async function miniAppPublish(client, args, deps) {
|
|
|
109
115
|
method: "POST",
|
|
110
116
|
path: designRoute,
|
|
111
117
|
body: {
|
|
112
|
-
...(hasTitle
|
|
118
|
+
...(hasTitle
|
|
119
|
+
? {
|
|
120
|
+
title: args.destination.design_title,
|
|
121
|
+
element: args.destination.design_element,
|
|
122
|
+
}
|
|
123
|
+
: {}),
|
|
113
124
|
note: args.note,
|
|
114
125
|
target: target.name,
|
|
115
126
|
design_dir: checked.designDirRel,
|
|
116
127
|
source_files: sourceFiles,
|
|
117
128
|
bundle_html: html,
|
|
118
129
|
built_from_commit: builtFromCommit,
|
|
119
|
-
...(shot.png_base64 === null
|
|
120
|
-
|
|
130
|
+
...(shot.png_base64 === null
|
|
131
|
+
? {}
|
|
132
|
+
: { screenshot_png_base64: shot.png_base64 }),
|
|
133
|
+
...(args.option_groups === undefined
|
|
134
|
+
? {}
|
|
135
|
+
: { option_groups: args.option_groups }),
|
|
121
136
|
checklist: args.checklist,
|
|
122
137
|
browser_check: args.browser_check,
|
|
123
|
-
...(args.problem_statement === undefined
|
|
124
|
-
|
|
125
|
-
|
|
138
|
+
...(args.problem_statement === undefined
|
|
139
|
+
? {}
|
|
140
|
+
: { problem_statement: args.problem_statement }),
|
|
141
|
+
...(args.problem_summary === undefined
|
|
142
|
+
? {}
|
|
143
|
+
: { problem_summary: args.problem_summary }),
|
|
144
|
+
...(args.problem_context === undefined
|
|
145
|
+
? {}
|
|
146
|
+
: { problem_context: args.problem_context }),
|
|
126
147
|
},
|
|
127
148
|
board,
|
|
128
149
|
});
|
|
@@ -147,7 +168,9 @@ export async function miniAppPublish(client, args, deps) {
|
|
|
147
168
|
screenshot: shot.screenshot,
|
|
148
169
|
browser_check: args.browser_check,
|
|
149
170
|
...(args.browser_check.status === "not_checked"
|
|
150
|
-
? {
|
|
171
|
+
? {
|
|
172
|
+
warning: `Published WITHOUT a browser check (${args.browser_check.note}). The revision carries a big red warning on its design problem and in the full-screen design dialog, and the operator is told. Check it in a browser and publish a new revision that says "checked".`,
|
|
173
|
+
}
|
|
151
174
|
: {}),
|
|
152
175
|
};
|
|
153
176
|
return { ok: true, status: published.status, body };
|
package/dist/mini-app-restore.js
CHANGED
|
@@ -11,22 +11,30 @@
|
|
|
11
11
|
* (that is unpublished work, never overwritten), naming each such file. A file with equal content is `unchanged`; a file in the folder the
|
|
12
12
|
* revision lacks is left alone and named in `extra_local`.
|
|
13
13
|
*/
|
|
14
|
-
import { lstat, mkdir, readFile, readdir, realpath, writeFile } from "node:fs/promises";
|
|
14
|
+
import { lstat, mkdir, readFile, readdir, realpath, writeFile, } from "node:fs/promises";
|
|
15
15
|
import path from "node:path";
|
|
16
|
-
import { isStrictlyInside, relativePosix, resolveRepoRoot } from "./mini-app-checkout.js";
|
|
16
|
+
import { isStrictlyInside, relativePosix, resolveRepoRoot, } from "./mini-app-checkout.js";
|
|
17
17
|
import { danxbotApi } from "./handlers.js";
|
|
18
18
|
function fail(message) {
|
|
19
19
|
throw new Error(`mini_app_restore: ${message}`);
|
|
20
20
|
}
|
|
21
21
|
/** A repo-relative POSIX path that is safe to join under a root: non-empty, not absolute (either flavour), no backslash, no drive letter, no `.`/`..`/empty segment. */
|
|
22
22
|
function isSafeRelative(p) {
|
|
23
|
-
if (p === "" ||
|
|
23
|
+
if (p === "" ||
|
|
24
|
+
p.includes("\\") ||
|
|
25
|
+
p.includes("\0") ||
|
|
26
|
+
p.startsWith("/") ||
|
|
27
|
+
/^[A-Za-z]:/.test(p))
|
|
24
28
|
return false;
|
|
25
|
-
return p
|
|
29
|
+
return p
|
|
30
|
+
.split("/")
|
|
31
|
+
.every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
26
32
|
}
|
|
27
33
|
function parseSource(body, where) {
|
|
28
34
|
const b = body;
|
|
29
|
-
if (typeof b?.design_dir !== "string" ||
|
|
35
|
+
if (typeof b?.design_dir !== "string" ||
|
|
36
|
+
typeof b.built_from_commit !== "string" ||
|
|
37
|
+
!Array.isArray(b.source_files)) {
|
|
30
38
|
fail(`${where} answered without design_dir, built_from_commit and source_files`);
|
|
31
39
|
}
|
|
32
40
|
const files = b.source_files.map((f, i) => {
|
|
@@ -35,11 +43,19 @@ function parseSource(body, where) {
|
|
|
35
43
|
fail(`${where} answered source_files[${i}] without a string path and content`);
|
|
36
44
|
return { path: file.path, content: file.content };
|
|
37
45
|
});
|
|
38
|
-
return {
|
|
46
|
+
return {
|
|
47
|
+
design_dir: b.design_dir,
|
|
48
|
+
built_from_commit: b.built_from_commit,
|
|
49
|
+
source_files: files,
|
|
50
|
+
};
|
|
39
51
|
}
|
|
40
52
|
/** The design's latest revision number, from the card's `designs` relation. */
|
|
41
53
|
async function latestRevisionNo(client, cardId, designNo) {
|
|
42
|
-
const card = await danxbotApi(client, {
|
|
54
|
+
const card = await danxbotApi(client, {
|
|
55
|
+
method: "GET",
|
|
56
|
+
path: `/api/issues/${encodeURIComponent(cardId)}`,
|
|
57
|
+
query: { fields: { designs: true } },
|
|
58
|
+
});
|
|
43
59
|
if (!card.ok)
|
|
44
60
|
return card;
|
|
45
61
|
const designs = card.body?.designs;
|
|
@@ -129,7 +145,10 @@ export async function miniAppRestore(client, args, deps) {
|
|
|
129
145
|
fail(`${outside.length} path(s) sit outside the design folder "${source.design_dir}" (absolute, "..", a backslash or another folder); nothing was written: ${outside.map((f) => JSON.stringify(f.path)).join(", ")}`);
|
|
130
146
|
}
|
|
131
147
|
const repoRoot = await resolveRepoRoot(deps.cwd);
|
|
132
|
-
const targets = source.source_files.map((f) => ({
|
|
148
|
+
const targets = source.source_files.map((f) => ({
|
|
149
|
+
...f,
|
|
150
|
+
abs: path.join(repoRoot, ...f.path.split("/")),
|
|
151
|
+
}));
|
|
133
152
|
const leaving = [];
|
|
134
153
|
const differing = [];
|
|
135
154
|
const unchanged = [];
|
|
@@ -159,7 +178,9 @@ export async function miniAppRestore(client, args, deps) {
|
|
|
159
178
|
await writeFile(t.abs, t.content, "utf8");
|
|
160
179
|
}
|
|
161
180
|
const restored = new Set(source.source_files.map((f) => f.path));
|
|
162
|
-
const extraLocal = (await listFolder(path.join(repoRoot, ...source.design_dir.split("/")), repoRoot))
|
|
181
|
+
const extraLocal = (await listFolder(path.join(repoRoot, ...source.design_dir.split("/")), repoRoot))
|
|
182
|
+
.filter((p) => !restored.has(p))
|
|
183
|
+
.sort();
|
|
163
184
|
return {
|
|
164
185
|
ok: true,
|
|
165
186
|
status: answer.status,
|
package/dist/one-line.js
CHANGED
|
@@ -15,7 +15,9 @@ export function oneLine(text, maxCodePoints) {
|
|
|
15
15
|
if (maxCodePoints === undefined)
|
|
16
16
|
return collapsed;
|
|
17
17
|
const points = Array.from(collapsed);
|
|
18
|
-
return points.length > maxCodePoints
|
|
18
|
+
return points.length > maxCodePoints
|
|
19
|
+
? `${points.slice(0, maxCodePoints).join("")}…`
|
|
20
|
+
: collapsed;
|
|
19
21
|
}
|
|
20
22
|
/** The prefix of every line the stream listener emits for the session to read. */
|
|
21
23
|
export const LINE_PREFIX = "[platform stream]";
|
|
@@ -48,7 +48,12 @@ export class PermissionRequests {
|
|
|
48
48
|
if (existing !== undefined && this.deps.access.isSignedIn()) {
|
|
49
49
|
return { answer: this.answer("approval_pending", existing) };
|
|
50
50
|
}
|
|
51
|
-
const guarded = await this.deps.access.guard(() => this.deps.request({
|
|
51
|
+
const guarded = await this.deps.access.guard(() => this.deps.request({
|
|
52
|
+
method: "POST",
|
|
53
|
+
basePath: PERMISSION_REQUESTS_BASE_PATH,
|
|
54
|
+
path: "",
|
|
55
|
+
body: { permissions, reason: args.reason },
|
|
56
|
+
}));
|
|
52
57
|
if ("halt" in guarded)
|
|
53
58
|
return { halt: guarded.halt };
|
|
54
59
|
const result = guarded.result;
|
|
@@ -68,7 +73,9 @@ export class PermissionRequests {
|
|
|
68
73
|
state,
|
|
69
74
|
approvalUrl: request.approvalUrl,
|
|
70
75
|
confirmCode: request.confirmCode,
|
|
71
|
-
instruction: state === "approval_required"
|
|
76
|
+
instruction: state === "approval_required"
|
|
77
|
+
? APPROVAL_REQUIRED_INSTRUCTION
|
|
78
|
+
: APPROVAL_PENDING_INSTRUCTION,
|
|
72
79
|
};
|
|
73
80
|
}
|
|
74
81
|
/**
|
|
@@ -96,7 +103,11 @@ export class PermissionRequests {
|
|
|
96
103
|
let guarded;
|
|
97
104
|
try {
|
|
98
105
|
// `guard` runs before EVERY claim (DX-4418): a revoked or signed-out session answers its halt without a request.
|
|
99
|
-
guarded = await this.deps.access.guard(() => this.deps.requestOwn({
|
|
106
|
+
guarded = await this.deps.access.guard(() => this.deps.requestOwn({
|
|
107
|
+
method: "POST",
|
|
108
|
+
basePath: PERMISSION_REQUESTS_BASE_PATH,
|
|
109
|
+
path: `/${request.publicId}/claim`,
|
|
110
|
+
}));
|
|
100
111
|
}
|
|
101
112
|
catch (err) {
|
|
102
113
|
// An outdated MCP will never get a different answer; any other failure is retried until the request ends.
|
package/dist/permission-watch.js
CHANGED
|
@@ -85,10 +85,16 @@ export class PermissionWatch {
|
|
|
85
85
|
try {
|
|
86
86
|
const response = await this.fetchImpl(`${this.deps.dashboardUrl.replace(/\/+$/, "")}${STREAM_PATH}`, {
|
|
87
87
|
// DX-5354: the watch is this process's own work, never the agent acting, so neither its connect nor any reconnect extends the session's key.
|
|
88
|
-
headers: {
|
|
88
|
+
headers: {
|
|
89
|
+
Authorization: `Bearer ${token}`,
|
|
90
|
+
Accept: "text/event-stream",
|
|
91
|
+
[PLUGIN_BACKGROUND_HEADER]: "1",
|
|
92
|
+
},
|
|
89
93
|
signal: controller.signal,
|
|
90
94
|
});
|
|
91
|
-
if (response.status >= 400 &&
|
|
95
|
+
if (response.status >= 400 &&
|
|
96
|
+
response.status < 500 &&
|
|
97
|
+
!RETRYABLE_REFUSALS.has(response.status)) {
|
|
92
98
|
this.deps.log?.(`[platform-mcp] the dashboard refused the permission stream (HTTP ${response.status}): a permission granted ` +
|
|
93
99
|
`mid-session shows its tools at the next session_connect instead`);
|
|
94
100
|
await response.body?.cancel();
|
|
@@ -104,7 +110,8 @@ export class PermissionWatch {
|
|
|
104
110
|
const decoder = new TextDecoder();
|
|
105
111
|
for await (const chunk of response.body) {
|
|
106
112
|
for (const message of parser.push(decoder.decode(chunk, { stream: true }))) {
|
|
107
|
-
if (message.event === "end" &&
|
|
113
|
+
if (message.event === "end" &&
|
|
114
|
+
endReason(message.data) === PERMISSIONS_CHANGED)
|
|
108
115
|
return { kind: "changed" };
|
|
109
116
|
}
|
|
110
117
|
}
|