@scalequality/cli 0.4.27 → 0.4.29

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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "sdkVersion": "0.3.281",
3
- "sha256": "17180f5819c1bc15eb3673f2b233c0ed2bfec058b6e5c61f664c1e31a814d8a5",
4
- "sourceCommit": "2d39889d75ad2d495e1d185212f15d0113581f52"
3
+ "sha256": "4b79a46af574de81267e70c31c7aa612ed39a08300461fc58c8e74272938573e",
4
+ "sourceCommit": "3b50cf2b25653763cbfcf55dd685d06f0645da45"
5
5
  }
package/dist/connect.cjs CHANGED
@@ -5124,6 +5124,7 @@ var ENGINE_MESSAGES = {
5124
5124
  MODEL_RATE_LIMIT: "The AI gateway limited this request. Try again in a moment.",
5125
5125
  MODEL_OVERLOADED: "The model provider is overloaded right now. Try again in a moment.",
5126
5126
  MODEL_AUTHENTICATION_FAILED: "The workspace could not authenticate with the AI gateway for this context.",
5127
+ MODEL_BLOCKED_BEFORE_GATEWAY: "A network filter refused this request before it reached the AI gateway.",
5127
5128
  MODEL_BILLING_ERROR: "The AI gateway refused this request for billing reasons.",
5128
5129
  MODEL_MODEL_NOT_FOUND: "The selected model is not available for this workspace.",
5129
5130
  MODEL_MAX_OUTPUT_TOKENS: "The answer reached the maximum output length.",
@@ -9859,7 +9860,7 @@ var SdkEventMapper = class {
9859
9860
  if (typeof err === "string" && err) {
9860
9861
  const raw = (msg?.content ?? []).map((b) => b.type === "text" && typeof b.text === "string" ? b.text : "").join("\n");
9861
9862
  const gw = gatewayError(raw);
9862
- const key = gw ? gw.code : `MODEL_${err.toUpperCase()}`;
9863
+ const key = gw ? gw.code : /API Error:\s*403 Forbidden\s*$/i.test(raw.trim()) ? "MODEL_BLOCKED_BEFORE_GATEWAY" : `MODEL_${err.toUpperCase()}`;
9863
9864
  if (this.reported.has(key)) return;
9864
9865
  this.reported.add(key);
9865
9866
  if (gw) this.cb.emit({ type: "error", data: { code: gw.code, message: engineMessage(gw.code, gw.params), params: gw.params } });
@@ -10409,6 +10410,15 @@ function briefLines(c) {
10409
10410
  "</scope_brief>"
10410
10411
  ];
10411
10412
  }
10413
+ function folderIsScopeCode(c) {
10414
+ if (c.layout?.kind === "folder") return c.layout.repos.some((r) => !!r.repoFullName) || c.layout.looseLinked.length > 0;
10415
+ return c.open.some((o) => !!o.repoFullName);
10416
+ }
10417
+ function localScopeLines(c) {
10418
+ if (!c.local || c.scope.kind === "ALL") return [];
10419
+ if (folderIsScopeCode(c)) return [`The user chose this association in ScaleQuality: it is what they are working on, and the folder ${c.root} is where its code is on this machine.`];
10420
+ return [`The user chose this association in ScaleQuality, and the folder ${c.root} is not its code: none of the association's repositories is in it, and it is not linked to its project. Do not treat the folder's files as the association's code, and do not take their structure, language or style as the project's. Before working, tell the user in one line that this folder is not the code of the association, and that they can choose the project's folder in "Runs on" or run in the cloud, where the association's repositories are cloned; then wait for their answer.`];
10421
+ }
10412
10422
  function openLine(c) {
10413
10423
  if (!c.open.length) return "No repository is open yet.";
10414
10424
  return `Open now: ${c.open.map((o) => `${o.repoFullName ?? "this folder (not a repository of the scope)"} at ${o.path} (branch ${o.branch})`).join("; ")}.`;
@@ -10416,8 +10426,8 @@ function openLine(c) {
10416
10426
  function buildSystemAppend(c) {
10417
10427
  return [
10418
10428
  "# ScaleQuality workspace",
10419
- c.local ? `You are ScaleQuality's coding workspace, working in the user's own folder ${c.root} on the user's machine.` : `You are ScaleQuality's coding workspace. The workspace root is ${c.root}, an isolated machine created for this conversation.`,
10420
- scopeLine(c),
10429
+ // On the user's machine the association comes first, the folder after it (Erik, 24/10/2026).
10430
+ ...c.local ? [scopeLine(c), ...localScopeLines(c), `You are ScaleQuality's coding workspace, working in the user's own folder ${c.root} on the user's machine.`] : [`You are ScaleQuality's coding workspace. The workspace root is ${c.root}, an isolated machine created for this conversation.`, scopeLine(c)],
10421
10431
  ...c.layout?.kind === "folder" ? [] : [openLine(c)],
10422
10432
  ...layoutLines(c.root, c.layout),
10423
10433
  ...c.onDemand ? [
@@ -12361,6 +12371,14 @@ ${String(item.content)}` : String(item.content);
12361
12371
  await this.sink.flush();
12362
12372
  }
12363
12373
  }
12374
+ /** A file the person attached, saved whole in the engine's own folder (the file tools read there, nothing writes there). */
12375
+ async saveAttachment(name, bytes) {
12376
+ const dir = (0, import_path16.join)(this.deps.configDir, "attachments", (0, import_crypto8.randomUUID)());
12377
+ await (0, import_promises15.mkdir)(dir, { recursive: true });
12378
+ const path = (0, import_path16.join)(dir, (0, import_path16.basename)(name ?? "").replace(/[\u0000-\u001f\\/:]/g, "_").replace(/^\.+/, "") || "attachment");
12379
+ await (0, import_promises15.writeFile)(path, bytes);
12380
+ return path;
12381
+ }
12364
12382
  /**
12365
12383
  * v4: what the person attached to the message, for the model: the images
12366
12384
  * (the API read them from the Runtime), the files they mentioned (text,
@@ -12437,9 +12455,24 @@ ${lines2.join("\n")}
12437
12455
  if (cut) text3 = Buffer.from(text3, "utf8").subarray(0, room).toString("utf8").replace(/\uFFFD$/, "");
12438
12456
  filesBytes += Buffer.byteLength(text3);
12439
12457
  const name = typeof d.name === "string" ? d.name.replace(/["<>]/g, "").slice(0, 200) : null;
12440
- blocks.push(`<attached_document${name ? ` name="${name}"` : ""} type="${String(d.mediaType ?? "text/plain").replace(/"/g, "")}"${cut ? ' truncated="true"' : ""}>
12458
+ const whole = cut ? await this.saveAttachment(name, Buffer.from(d.text, "utf8")).catch(() => null) : null;
12459
+ blocks.push(`<attached_document${name ? ` name="${name}"` : ""} type="${String(d.mediaType ?? "text/plain").replace(/"/g, "")}"${cut ? ' truncated="true"' : ""}${whole ? ` path="${whole.replace(/"/g, "")}"` : ""}>
12441
12460
  ${text3}
12442
12461
  </attached_document>`);
12462
+ }
12463
+ for (const raw of (Array.isArray(payload.files) ? payload.files : []).slice(0, TURN_CAPS.images)) {
12464
+ const f = raw;
12465
+ if (typeof f.data !== "string" || !f.data) continue;
12466
+ const bytes = Buffer.from(f.data, "base64");
12467
+ const name = typeof f.name === "string" ? f.name.replace(/["<>]/g, "").slice(0, 200) : null;
12468
+ const path = await this.saveAttachment(name, bytes).catch(() => null);
12469
+ if (!path) {
12470
+ this.error("ATTACHMENT_SKIPPED");
12471
+ continue;
12472
+ }
12473
+ blocks.push(`<attached_file${name ? ` name="${name}"` : ""} type="${String(f.mediaType ?? "application/octet-stream").replace(/"/g, "")}" bytes="${bytes.length}" path="${path.replace(/"/g, "")}">
12474
+ The user attached this file; it is saved at this path, outside the repository. Open it with your tools (Read reads PDFs and images; use Bash for archives, spreadsheets and other formats). Copy it into the repository only if the user asks.
12475
+ </attached_file>`);
12443
12476
  }
12444
12477
  for (const raw of (Array.isArray(payload.sessionContext) ? payload.sessionContext : []).slice(0, 8)) {
12445
12478
  const c = raw;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalequality/cli",
3
- "version": "0.4.27",
3
+ "version": "0.4.29",
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": {