@scalequality/cli 0.4.31 → 0.4.32
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/connect.build.json +2 -2
- package/dist/connect.cjs +111 -66
- package/package.json +1 -1
package/dist/connect.build.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sdkVersion": "0.3.281",
|
|
3
|
-
"sha256": "
|
|
4
|
-
"sourceCommit": "
|
|
3
|
+
"sha256": "6cc91235fd87e2125e963bb23b062d003f129ef8593d841d654846d4d6ff0552",
|
|
4
|
+
"sourceCommit": "5570a43b32111d0ca46a5417dcd54d78283277eb"
|
|
5
5
|
}
|
package/dist/connect.cjs
CHANGED
|
@@ -5803,7 +5803,7 @@ var HttpSessionTransport = class {
|
|
|
5803
5803
|
const raw = await this.post("/command-approvals", body, this.opts.requestTimeoutMs ?? 3e4);
|
|
5804
5804
|
const approvalId = typeof raw?.approvalId === "string" ? raw.approvalId : "";
|
|
5805
5805
|
if (!approvalId) throw new TransportError("invalid command approval response", 502, false);
|
|
5806
|
-
return { approvalId };
|
|
5806
|
+
return { approvalId, ...raw?.approved === true ? { approved: true } : {} };
|
|
5807
5807
|
}
|
|
5808
5808
|
async cancelCommandApproval(approvalId, reason) {
|
|
5809
5809
|
await this.post(`/command-approvals/${encodeURIComponent(approvalId)}/cancel`, { reason }, this.opts.requestTimeoutMs ?? 3e4);
|
|
@@ -7951,32 +7951,12 @@ var TerminalHost = class {
|
|
|
7951
7951
|
if (socket.readyState === socket.OPEN) socket.send(JSON.stringify(m));
|
|
7952
7952
|
};
|
|
7953
7953
|
socket.on("message", (raw) => {
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
socket.close(4401, "token");
|
|
7961
|
-
return;
|
|
7962
|
-
}
|
|
7963
|
-
if (!TAB_ID.test(m.tab)) {
|
|
7964
|
-
socket.close(4400, "tab");
|
|
7965
|
-
return;
|
|
7966
|
-
}
|
|
7967
|
-
tab = this.attach(m.tab, socket, size(m.cols, 80, 500), size(m.rows, 24, 200), send);
|
|
7968
|
-
return;
|
|
7969
|
-
}
|
|
7970
|
-
if (m.t === "in") {
|
|
7971
|
-
this.lastInputAt = (this.o.now ?? Date.now)();
|
|
7972
|
-
tab.pty.write(m.d.slice(0, MAX_INPUT));
|
|
7973
|
-
} else if (m.t === "resize") {
|
|
7974
|
-
try {
|
|
7975
|
-
tab.pty.resize(size(m.cols, 80, 500), size(m.rows, 24, 200));
|
|
7976
|
-
} catch {
|
|
7977
|
-
}
|
|
7978
|
-
} else if (m.t === "close") {
|
|
7979
|
-
this.end(tab.id);
|
|
7954
|
+
try {
|
|
7955
|
+
this.received(raw, socket, () => tab, (t) => {
|
|
7956
|
+
tab = t;
|
|
7957
|
+
}, hello, send);
|
|
7958
|
+
} catch (e) {
|
|
7959
|
+
this.o.log.warn("terminal message not handled", { error: e.message });
|
|
7980
7960
|
}
|
|
7981
7961
|
});
|
|
7982
7962
|
socket.on("close", () => {
|
|
@@ -7985,6 +7965,37 @@ var TerminalHost = class {
|
|
|
7985
7965
|
});
|
|
7986
7966
|
socket.on("error", () => void 0);
|
|
7987
7967
|
}
|
|
7968
|
+
/** One message of a page: the hello first (its token, its tab), then what it types, its size, or the tab's end. */
|
|
7969
|
+
received(raw, socket, current, set, hello, send) {
|
|
7970
|
+
const m = parse(raw);
|
|
7971
|
+
if (!m) return;
|
|
7972
|
+
const tab = current();
|
|
7973
|
+
if (!tab) {
|
|
7974
|
+
if (m.t !== "hello") return;
|
|
7975
|
+
clearTimeout(hello);
|
|
7976
|
+
if (!this.known(m.token)) {
|
|
7977
|
+
socket.close(4401, "token");
|
|
7978
|
+
return;
|
|
7979
|
+
}
|
|
7980
|
+
if (!TAB_ID.test(m.tab)) {
|
|
7981
|
+
socket.close(4400, "tab");
|
|
7982
|
+
return;
|
|
7983
|
+
}
|
|
7984
|
+
set(this.attach(m.tab, socket, size(m.cols, 80, 500), size(m.rows, 24, 200), send));
|
|
7985
|
+
return;
|
|
7986
|
+
}
|
|
7987
|
+
if (m.t === "in") {
|
|
7988
|
+
this.lastInputAt = (this.o.now ?? Date.now)();
|
|
7989
|
+
tab.pty.write(m.d.slice(0, MAX_INPUT));
|
|
7990
|
+
} else if (m.t === "resize") {
|
|
7991
|
+
try {
|
|
7992
|
+
tab.pty.resize(size(m.cols, 80, 500), size(m.rows, 24, 200));
|
|
7993
|
+
} catch {
|
|
7994
|
+
}
|
|
7995
|
+
} else if (m.t === "close") {
|
|
7996
|
+
this.end(tab.id);
|
|
7997
|
+
}
|
|
7998
|
+
}
|
|
7988
7999
|
/** The tab this page opens: its shell again (the screen it had, then what comes), or a new shell. */
|
|
7989
8000
|
attach(id, socket, cols, rows, send) {
|
|
7990
8001
|
const existing = this.tabs.get(id);
|
|
@@ -8023,16 +8034,26 @@ var TerminalHost = class {
|
|
|
8023
8034
|
const tab = { id, shell, pty, buffer: "", socket, detachTimer: null };
|
|
8024
8035
|
this.tabs.set(id, tab);
|
|
8025
8036
|
pty.onData((d) => {
|
|
8026
|
-
|
|
8027
|
-
|
|
8037
|
+
try {
|
|
8038
|
+
tab.buffer = (tab.buffer + d).slice(-MAX_BUFFER);
|
|
8039
|
+
const s = tab.socket;
|
|
8040
|
+
if (s && s.readyState === s.OPEN) s.send(JSON.stringify({ t: "out", d }));
|
|
8041
|
+
} catch (e) {
|
|
8042
|
+
this.o.log.warn("terminal output not sent", { error: e.message });
|
|
8043
|
+
}
|
|
8028
8044
|
});
|
|
8029
8045
|
pty.onExit(({ exitCode }) => {
|
|
8030
|
-
|
|
8031
|
-
tab.socket
|
|
8032
|
-
|
|
8046
|
+
try {
|
|
8047
|
+
const s = tab.socket;
|
|
8048
|
+
if (s && s.readyState === s.OPEN) {
|
|
8049
|
+
s.send(JSON.stringify({ t: "exit", code: exitCode }));
|
|
8050
|
+
s.close(1e3, "exited");
|
|
8051
|
+
}
|
|
8052
|
+
if (this.tabs.get(id) === tab) this.tabs.delete(id);
|
|
8053
|
+
if (tab.detachTimer) clearTimeout(tab.detachTimer);
|
|
8054
|
+
} catch (e) {
|
|
8055
|
+
this.o.log.warn("terminal exit not sent", { error: e.message });
|
|
8033
8056
|
}
|
|
8034
|
-
if (this.tabs.get(id) === tab) this.tabs.delete(id);
|
|
8035
|
-
if (tab.detachTimer) clearTimeout(tab.detachTimer);
|
|
8036
8057
|
});
|
|
8037
8058
|
send({ t: "ready", tab: id, shell, replay: "" });
|
|
8038
8059
|
return tab;
|
|
@@ -8937,8 +8958,11 @@ function sandboxTestEnv() {
|
|
|
8937
8958
|
var ApprovalBroker = class {
|
|
8938
8959
|
waiting = /* @__PURE__ */ new Map();
|
|
8939
8960
|
early = /* @__PURE__ */ new Map();
|
|
8961
|
+
/** Decisions already known from the request's answer: their copy on the poll is dropped, never kept. */
|
|
8962
|
+
settled = /* @__PURE__ */ new Set();
|
|
8940
8963
|
/** True when a call was waiting for this decision (it returns now); false when it is kept for a later wait. */
|
|
8941
8964
|
resolve(approvalId, decision) {
|
|
8965
|
+
if (this.settled.delete(approvalId)) return false;
|
|
8942
8966
|
const w = this.waiting.get(approvalId);
|
|
8943
8967
|
if (w) {
|
|
8944
8968
|
this.waiting.delete(approvalId);
|
|
@@ -8967,6 +8991,12 @@ var ApprovalBroker = class {
|
|
|
8967
8991
|
});
|
|
8968
8992
|
});
|
|
8969
8993
|
}
|
|
8994
|
+
/** The API answered this approval with the request itself: its decision arriving on the poll later is dropped. */
|
|
8995
|
+
settle(approvalId) {
|
|
8996
|
+
if (this.early.delete(approvalId)) return;
|
|
8997
|
+
this.settled.add(approvalId);
|
|
8998
|
+
while (this.settled.size > 500) this.settled.delete(this.settled.values().next().value);
|
|
8999
|
+
}
|
|
8970
9000
|
get pending() {
|
|
8971
9001
|
return this.waiting.size;
|
|
8972
9002
|
}
|
|
@@ -13167,48 +13197,58 @@ function readReport(dom) {
|
|
|
13167
13197
|
var run2 = (chrome, args, timeoutMs) => new Promise((resolve8, reject) => {
|
|
13168
13198
|
(0, import_child_process4.execFile)(chrome, args, { timeout: timeoutMs, windowsHide: true, maxBuffer: 32 * 1024 * 1024 }, (error, stdout) => error ? reject(error) : resolve8(String(stdout)));
|
|
13169
13199
|
});
|
|
13200
|
+
var SCREENS_AT_ONCE = 3;
|
|
13170
13201
|
async function checkDesign(chrome, folder, manifest, opts = {}) {
|
|
13171
13202
|
const runner = opts.runner ?? run2;
|
|
13172
13203
|
const work = await (0, import_promises10.mkdtemp)((0, import_path10.join)((0, import_os5.tmpdir)(), "sq-design-"));
|
|
13173
|
-
const
|
|
13174
|
-
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
|
|
13184
|
-
|
|
13185
|
-
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
const check = { file: b.file, title: b.title, errors: [], contrast: [], overflow: false, unread: true };
|
|
13204
|
+
const one = async (b, i) => {
|
|
13205
|
+
const page = (0, import_path10.join)(work, `screen-${i}.html`);
|
|
13206
|
+
await (0, import_promises10.writeFile)(page, checkedPage(await (0, import_promises10.readFile)((0, import_path10.join)(folder, b.file), "utf8"), folder));
|
|
13207
|
+
const url = (0, import_url.pathToFileURL)(page).href;
|
|
13208
|
+
const base = (profile) => [
|
|
13209
|
+
"--headless=new",
|
|
13210
|
+
"--disable-gpu",
|
|
13211
|
+
"--no-sandbox",
|
|
13212
|
+
"--disable-dev-shm-usage",
|
|
13213
|
+
"--hide-scrollbars",
|
|
13214
|
+
"--no-first-run",
|
|
13215
|
+
"--no-default-browser-check",
|
|
13216
|
+
`--user-data-dir=${(0, import_path10.join)(work, profile)}`,
|
|
13217
|
+
`--window-size=${b.width},${b.height}`,
|
|
13218
|
+
"--virtual-time-budget=6000"
|
|
13219
|
+
];
|
|
13220
|
+
const check = { file: b.file, title: b.title, errors: [], contrast: [], overflow: false, unread: true };
|
|
13221
|
+
const measured = (async () => {
|
|
13192
13222
|
try {
|
|
13193
|
-
const report = readReport(await runner(chrome, [...base, "--dump-dom", url], 45e3));
|
|
13223
|
+
const report = readReport(await runner(chrome, [...base(`profile-${i}-dom`), "--dump-dom", url], 45e3));
|
|
13194
13224
|
if (report) Object.assign(check, report, { unread: false });
|
|
13195
13225
|
} catch {
|
|
13196
13226
|
}
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
|
|
13227
|
+
})();
|
|
13228
|
+
const pictured = (async () => {
|
|
13229
|
+
if (i >= MAX_PICTURES) return;
|
|
13230
|
+
const shot = (0, import_path10.join)(work, `screen-${i}.png`);
|
|
13231
|
+
try {
|
|
13232
|
+
await runner(chrome, [...base(`profile-${i}-shot`), `--screenshot=${shot}`, url], 45e3);
|
|
13233
|
+
const png = await (0, import_promises10.readFile)(shot);
|
|
13234
|
+
if (png.length) check.picture = png.toString("base64");
|
|
13235
|
+
} catch {
|
|
13205
13236
|
}
|
|
13206
|
-
|
|
13207
|
-
|
|
13237
|
+
})();
|
|
13238
|
+
await Promise.all([measured, pictured]);
|
|
13239
|
+
return check;
|
|
13240
|
+
};
|
|
13241
|
+
try {
|
|
13242
|
+
const out2 = new Array(manifest.boards.length);
|
|
13243
|
+
let next = 0;
|
|
13244
|
+
const lane = async () => {
|
|
13245
|
+
for (let i = next++; i < manifest.boards.length; i = next++) out2[i] = await one(manifest.boards[i], i);
|
|
13246
|
+
};
|
|
13247
|
+
await Promise.all(Array.from({ length: Math.min(SCREENS_AT_ONCE, manifest.boards.length) }, lane));
|
|
13248
|
+
return out2;
|
|
13208
13249
|
} finally {
|
|
13209
13250
|
await (0, import_promises10.rm)(work, { recursive: true, force: true }).catch(() => void 0);
|
|
13210
13251
|
}
|
|
13211
|
-
return out2;
|
|
13212
13252
|
}
|
|
13213
13253
|
function designSummary(checks) {
|
|
13214
13254
|
return {
|
|
@@ -14429,8 +14469,9 @@ function cloudProtectionApprover(o) {
|
|
|
14429
14469
|
const edit = check.edit;
|
|
14430
14470
|
if (check.signal?.aborted) return { allow: false, message: edit ? PROTECTION_MESSAGES.editStopped : PROTECTION_MESSAGES.stopped };
|
|
14431
14471
|
let approvalId;
|
|
14472
|
+
let approved = false;
|
|
14432
14473
|
try {
|
|
14433
|
-
({ approvalId } = await o.calls.requestCommandApproval({
|
|
14474
|
+
({ approvalId, approved = false } = await o.calls.requestCommandApproval({
|
|
14434
14475
|
command,
|
|
14435
14476
|
cwd: o.cwd,
|
|
14436
14477
|
...check.description ? { description: check.description.slice(0, 1e3) } : {},
|
|
@@ -14443,6 +14484,10 @@ function cloudProtectionApprover(o) {
|
|
|
14443
14484
|
o.log?.(`protection approval could not be requested: ${e.message}`);
|
|
14444
14485
|
return { allow: false, message: edit ? PROTECTION_MESSAGES.editUnavailable(edit.path) : PROTECTION_MESSAGES.unavailable };
|
|
14445
14486
|
}
|
|
14487
|
+
if (approved) {
|
|
14488
|
+
o.broker.settle(approvalId);
|
|
14489
|
+
return { allow: true };
|
|
14490
|
+
}
|
|
14446
14491
|
const timeoutMs = o.timeoutMs ?? COMMAND_APPROVAL_TIMEOUT_MS;
|
|
14447
14492
|
const timer = new AbortController();
|
|
14448
14493
|
const t = setTimeout(() => timer.abort(), timeoutMs);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalequality/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.32",
|
|
4
4
|
"description": "ScaleQuality CLI. Connect your computer to the ScaleQuality AI Workspace (`scalequality login`), run its coding engine in any folder of your computer, and import your Claude Code and Codex conversations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|