replicas-cli 0.3.686 → 0.3.688

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.
Files changed (2) hide show
  1. package/dist/index.cjs +350 -279
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -277,7 +277,7 @@ var init_urls = __esm({
277
277
  WEB_APP_PATHS.automations,
278
278
  `${WEB_APP_PATHS.automations}/${UUID_PATTERN}`
279
279
  ];
280
- APP_LINK_PATTERNS = APP_LINK_PATHS.map((path14) => new RegExp(`^${path14.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\?/g, ".").replace(/\*/g, ".*")}$`));
280
+ APP_LINK_PATTERNS = APP_LINK_PATHS.map((path16) => new RegExp(`^${path16.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\?/g, ".").replace(/\*/g, ".*")}$`));
281
281
  LEGACY_WEB_APP_PATHS = {
282
282
  app: "/app",
283
283
  home: "/home",
@@ -671,10 +671,10 @@ function mergeDefs(...defs) {
671
671
  function cloneDef(schema) {
672
672
  return mergeDefs(schema._zod.def);
673
673
  }
674
- function getElementAtPath(obj, path14) {
675
- if (!path14)
674
+ function getElementAtPath(obj, path16) {
675
+ if (!path16)
676
676
  return obj;
677
- return path14.reduce((acc, key2) => acc?.[key2], obj);
677
+ return path16.reduce((acc, key2) => acc?.[key2], obj);
678
678
  }
679
679
  function promiseAllObject(promisesObj) {
680
680
  const keys = Object.keys(promisesObj);
@@ -933,11 +933,11 @@ function explicitlyAborted(x, startIndex = 0) {
933
933
  }
934
934
  return false;
935
935
  }
936
- function prefixIssues(path14, issues) {
936
+ function prefixIssues(path16, issues) {
937
937
  return issues.map((iss) => {
938
938
  var _a3;
939
939
  (_a3 = iss).path ?? (_a3.path = []);
940
- iss.path.unshift(path14);
940
+ iss.path.unshift(path16);
941
941
  return iss;
942
942
  });
943
943
  }
@@ -1472,16 +1472,16 @@ function flattenError(error62, mapper = (issue3) => issue3.message) {
1472
1472
  }
1473
1473
  function formatError(error62, mapper = (issue3) => issue3.message) {
1474
1474
  const fieldErrors = { _errors: [] };
1475
- const processError = (error63, path14 = []) => {
1475
+ const processError = (error63, path16 = []) => {
1476
1476
  for (const issue3 of error63.issues) {
1477
1477
  if (issue3.code === "invalid_union" && issue3.errors.length) {
1478
- issue3.errors.map((issues) => processError({ issues }, [...path14, ...issue3.path]));
1478
+ issue3.errors.map((issues) => processError({ issues }, [...path16, ...issue3.path]));
1479
1479
  } else if (issue3.code === "invalid_key") {
1480
- processError({ issues: issue3.issues }, [...path14, ...issue3.path]);
1480
+ processError({ issues: issue3.issues }, [...path16, ...issue3.path]);
1481
1481
  } else if (issue3.code === "invalid_element") {
1482
- processError({ issues: issue3.issues }, [...path14, ...issue3.path]);
1482
+ processError({ issues: issue3.issues }, [...path16, ...issue3.path]);
1483
1483
  } else {
1484
- const fullpath = [...path14, ...issue3.path];
1484
+ const fullpath = [...path16, ...issue3.path];
1485
1485
  if (fullpath.length === 0) {
1486
1486
  fieldErrors._errors.push(mapper(issue3));
1487
1487
  } else {
@@ -1520,17 +1520,17 @@ function formatError(error62, mapper = (issue3) => issue3.message) {
1520
1520
  }
1521
1521
  function treeifyError(error62, mapper = (issue3) => issue3.message) {
1522
1522
  const result = { errors: [] };
1523
- const processError = (error63, path14 = []) => {
1523
+ const processError = (error63, path16 = []) => {
1524
1524
  var _a3;
1525
1525
  for (const issue3 of error63.issues) {
1526
1526
  if (issue3.code === "invalid_union" && issue3.errors.length) {
1527
- issue3.errors.map((issues) => processError({ issues }, [...path14, ...issue3.path]));
1527
+ issue3.errors.map((issues) => processError({ issues }, [...path16, ...issue3.path]));
1528
1528
  } else if (issue3.code === "invalid_key") {
1529
- processError({ issues: issue3.issues }, [...path14, ...issue3.path]);
1529
+ processError({ issues: issue3.issues }, [...path16, ...issue3.path]);
1530
1530
  } else if (issue3.code === "invalid_element") {
1531
- processError({ issues: issue3.issues }, [...path14, ...issue3.path]);
1531
+ processError({ issues: issue3.issues }, [...path16, ...issue3.path]);
1532
1532
  } else {
1533
- const fullpath = [...path14, ...issue3.path];
1533
+ const fullpath = [...path16, ...issue3.path];
1534
1534
  if (fullpath.length === 0) {
1535
1535
  result.errors.push(mapper(issue3));
1536
1536
  continue;
@@ -1569,8 +1569,8 @@ function treeifyError(error62, mapper = (issue3) => issue3.message) {
1569
1569
  }
1570
1570
  function toDotPath(_path) {
1571
1571
  const segs = [];
1572
- const path14 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1573
- for (const seg of path14) {
1572
+ const path16 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1573
+ for (const seg of path16) {
1574
1574
  if (typeof seg === "number")
1575
1575
  segs.push(`[${seg}]`);
1576
1576
  else if (typeof seg === "symbol")
@@ -19688,13 +19688,13 @@ function resolveRef(ref, ctx) {
19688
19688
  if (!ref.startsWith("#")) {
19689
19689
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
19690
19690
  }
19691
- const path14 = ref.slice(1).split("/").filter(Boolean);
19692
- if (path14.length === 0) {
19691
+ const path16 = ref.slice(1).split("/").filter(Boolean);
19692
+ if (path16.length === 0) {
19693
19693
  return ctx.rootSchema;
19694
19694
  }
19695
19695
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
19696
- if (path14[0] === defsKey) {
19697
- const key2 = path14[1] === void 0 ? void 0 : decodeJSONPointerSegment(path14[1]);
19696
+ if (path16[0] === defsKey) {
19697
+ const key2 = path16[1] === void 0 ? void 0 : decodeJSONPointerSegment(path16[1]);
19698
19698
  if (!key2 || !ctx.defs[key2]) {
19699
19699
  throw new Error(`Reference not found: ${ref}`);
19700
19700
  }
@@ -21728,7 +21728,7 @@ var init_repository_path = __esm({
21728
21728
  "use strict";
21729
21729
  init_zod();
21730
21730
  repositoryPathSchema = external_exports.string().trim().min(1).max(1e3).refine(
21731
- (path14) => !path14.startsWith("/") && path14.split("/").every((part) => part !== "" && part !== "." && part !== ".."),
21731
+ (path16) => !path16.startsWith("/") && path16.split("/").every((part) => part !== "" && part !== "." && part !== ".."),
21732
21732
  "path is relative to the repository root, with no empty, . or .. parts"
21733
21733
  );
21734
21734
  }
@@ -22067,7 +22067,7 @@ function jsonStrings(raw) {
22067
22067
  } catch {
22068
22068
  return null;
22069
22069
  }
22070
- const strings = [], path14 = [], inObject = [];
22070
+ const strings = [], path16 = [], inObject = [];
22071
22071
  let expectKey = false;
22072
22072
  for (let index = 0; index < raw.length; index++) {
22073
22073
  const char = raw[index];
@@ -22075,22 +22075,22 @@ function jsonStrings(raw) {
22075
22075
  let end = index + 1;
22076
22076
  while (raw[end] !== '"') end += raw[end] === "\\" ? 2 : 1;
22077
22077
  const key2 = inObject.at(-1) === true && expectKey;
22078
- if (key2) path14[path14.length - 1] = parseJsonString(raw.slice(index, end + 1));
22079
- strings.push({ start: index, end: end + 1, path: key2 ? path14.slice(0, -1) : [...path14], key: key2 });
22078
+ if (key2) path16[path16.length - 1] = parseJsonString(raw.slice(index, end + 1));
22079
+ strings.push({ start: index, end: end + 1, path: key2 ? path16.slice(0, -1) : [...path16], key: key2 });
22080
22080
  expectKey = false;
22081
22081
  index = end;
22082
22082
  } else if (char === "{" || char === "[") {
22083
22083
  inObject.push(char === "{");
22084
- path14.push(char === "{" ? "" : 0);
22084
+ path16.push(char === "{" ? "" : 0);
22085
22085
  expectKey = char === "{";
22086
22086
  } else if (char === "}" || char === "]") {
22087
22087
  inObject.pop();
22088
- path14.pop();
22088
+ path16.pop();
22089
22089
  } else if (char === ",") {
22090
22090
  if (inObject.at(-1)) expectKey = true;
22091
22091
  else {
22092
- const last = path14[path14.length - 1];
22093
- if (typeof last === "number") path14[path14.length - 1] = last + 1;
22092
+ const last = path16[path16.length - 1];
22093
+ if (typeof last === "number") path16[path16.length - 1] = last + 1;
22094
22094
  }
22095
22095
  }
22096
22096
  }
@@ -22234,8 +22234,8 @@ function proofValues(content, known, allowCommitted) {
22234
22234
  else high = middle - 1;
22235
22235
  }
22236
22236
  if (strings && (!string4 || start >= string4.end)) return { label: "the JSON outside any string", kept: false };
22237
- const path14 = string4 ? fieldPath(string4.path, known) : "";
22238
- if (string4?.key) return { label: `a JSON key${path14 ? ` in ${path14}` : ""}`, kept: false };
22237
+ const path16 = string4 ? fieldPath(string4.path, known) : "";
22238
+ if (string4?.key) return { label: `a JSON key${path16 ? ` in ${path16}` : ""}`, kept: false };
22239
22239
  let body2, from = start, to = end;
22240
22240
  if (string4) {
22241
22241
  let own2 = read.get(string4.start);
@@ -22243,7 +22243,7 @@ function proofValues(content, known, allowCommitted) {
22243
22243
  body2 = own2;
22244
22244
  [from, to] = [own2.at[start - string4.start], own2.at[Math.min(end, string4.end - 1) - string4.start]];
22245
22245
  } else body2 = whole ?? (whole = readText(content, null));
22246
- const field2 = path14 || "content", line = lineAt(body2.lineStarts, from);
22246
+ const field2 = path16 || "content", line = lineAt(body2.lineStarts, from);
22247
22247
  if (!body2.diff) return { label: body2.text.includes("\n") ? `${field2}, line ${line + 1}` : field2, kept: false };
22248
22248
  const kind = body2.diff.kinds[line], file2 = body2.diff.files[line];
22249
22249
  const where = file2 === null ? "" : containsProofSecret(file2, known) ? ", in a file whose path holds the value" : `, in ${file2}`;
@@ -22500,7 +22500,7 @@ var init_secrets = __esm({
22500
22500
  [STANDALONE_TOKEN, "a token"]
22501
22501
  ]);
22502
22502
  POSITIONAL = /* @__PURE__ */ new Set([...BY_NAME, ...SECRET_PATTERNS.slice(1, 5)]);
22503
- fieldPath = (path14, known) => path14.map((part) => typeof part === "number" ? `[${part}]` : containsProofSecret(part, known) ? ".<key>" : `.${part}`).join("").replace(/^\./, "");
22503
+ fieldPath = (path16, known) => path16.map((part) => typeof part === "number" ? `[${part}]` : containsProofSecret(part, known) ? ".<key>" : `.${part}`).join("").replace(/^\./, "");
22504
22504
  DIFF = /^(?:diff --git |--- \S|\+\+\+ \S|@@ -\d)/m;
22505
22505
  HUNK = /^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/;
22506
22506
  SIDES = [/* @__PURE__ */ new Set(["removed", "context"]), /* @__PURE__ */ new Set(["added", "context"])];
@@ -23639,7 +23639,7 @@ var init_security = __esm({
23639
23639
  FIRST_VALUE_PLACEHOLDER = "{first.value}";
23640
23640
  declaredReplayRequestSchema = (placeholders) => external_exports.strictObject({
23641
23641
  method: external_exports.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]),
23642
- path: external_exports.string().startsWith("/", 'path must start with "/"').max(2e3).refine((path14) => !/[{}]/.test(placeholders.reduce((rest, placeholder) => rest.replaceAll(placeholder, ""), path14)), `the only placeholders in path are ${placeholders.join(" and ")}`),
23642
+ path: external_exports.string().startsWith("/", 'path must start with "/"').max(2e3).refine((path16) => !/[{}]/.test(placeholders.reduce((rest, placeholder) => rest.replaceAll(placeholder, ""), path16)), `the only placeholders in path are ${placeholders.join(" and ")}`),
23643
23643
  body: external_exports.json().optional()
23644
23644
  });
23645
23645
  usesFirstValue = (request2) => `${request2.path}${JSON.stringify(request2.body ?? null)}`.includes(FIRST_VALUE_PLACEHOLDER);
@@ -25749,27 +25749,26 @@ Artifacts are the home for everything this workspace generates: docs, diagrams,
25749
25749
  **Reference:** \`references/ARTIFACTS.md\`
25750
25750
 
25751
25751
  Use this when:
25752
- - You generate anything someone might want to see after the workspace is deleted
25752
+ - You save a file you generated so the person can open it, now or after the workspace is gone
25753
25753
  - You need to list, rename, share or delete an artifact`;
25754
25754
  REFERENCE = `# Artifacts
25755
25755
 
25756
- An artifact is anything this workspace generates that someone might want to see after the workspace is deleted. Work on plans and notes in the Canvas, and save one with \`replicas artifact upload\` when the person will want it after the workspace is gone. An artifact belongs to the person this workspace belongs to and is private to them until it is shared. A workspace with no owner saves artifacts that belong to the whole organization.
25756
+ An artifact is a file this workspace saved for people to open. It belongs to the person this workspace belongs to and is private to them until it is shared. A workspace with no owner saves artifacts that belong to the whole organization.
25757
25757
 
25758
- ## Mutable or immutable
25758
+ ## Temporary or permanent
25759
25759
 
25760
- Every artifact is one or the other. Choose by what the thing is, not by whether someone might want it later:
25760
+ Every upload passes \`--permanent false\` or \`--permanent true\`; the command refuses one without it.
25761
25761
 
25762
- - **Immutable** (\`--immutable\`): a record of this workspace's work, which a later version would sit beside rather than replace. Screenshots, recordings, GIFs, before/after images, test output, one-off renders. It is deleted when the workspace is deleted.
25763
- - **Mutable**: a document people come back to, share or review, which a later version would replace. A plan, report, design doc, dashboard or dataset. It is kept after the workspace is gone and shows on the person's Artifacts page.
25762
+ - **Temporary** (\`--permanent false\`): deleted with this workspace. Screenshots, recordings, GIFs, test output, one-off renders, and working files such as plans and notes.
25763
+ - **Permanent** (\`--permanent true\`): kept after the workspace is gone and listed on the person's Artifacts page. Only when the person asked to keep it, or it is the finished deliverable of the task: a report, dashboard or dataset.
25764
25764
 
25765
- If you're unsure, save it as immutable. A screenshot or recording is immutable.
25766
-
25767
- Save everything with \`replicas artifact upload\`, adding \`--immutable\` for anything immutable. Paste the line the command prints into your reply.
25765
+ If you're unsure, use \`--permanent false\`. If the person says you chose wrong, upload the same file again with the other value: if it is unchanged, that changes the saved artifact; if you edited it, it is saved as a new artifact. Paste the line the upload prints into your reply.
25768
25766
 
25769
25767
  ## Commands
25770
25768
 
25771
25769
  \`\`\`bash
25772
- replicas artifact upload report.pdf diagram.mmd --name "Q3 report" --name "Signup flow"
25770
+ replicas artifact upload /tmp/login.png --name "Login page after fix" --permanent false
25771
+ replicas artifact upload report.pdf --name "Q3 report" --permanent true
25773
25772
  replicas artifact list
25774
25773
  replicas artifact url <id>
25775
25774
  replicas artifact rename <id> "Q3 report (final)"
@@ -25781,7 +25780,7 @@ replicas artifact delete <id>
25781
25780
  \`\`\`
25782
25781
 
25783
25782
  - Pass one \`--name\` per file: the name people will see. Up to 50 MB per file.
25784
- - \`list\` shows yours and those shared with you, mutable only; \`--all\`, \`--kind\`, \`--owner\` and \`--workspace\` widen or narrow it. \`url\` prints a short-lived download link. Sharing gives view unless you pass \`--permission edit\`.
25783
+ - \`list\` shows your permanent artifacts and those shared with you; \`--permanent false\`, \`--all\`, \`--kind\`, \`--owner\` and \`--workspace\` widen or narrow it. \`url\` prints a short-lived download link. Sharing gives view unless you pass \`--permission edit\`.
25785
25784
  - You act with the workspace owner's access: an \`edit\` share lets you rename and reshare. Only the owner can delete, except that anyone in the organization can delete an artifact the organization owns.
25786
25785
  - Share only when the person asks.
25787
25786
  `;
@@ -26896,8 +26895,8 @@ function parseIssueContractRecord(schema, value, at, report) {
26896
26895
  return result.data;
26897
26896
  }
26898
26897
  for (const issue3 of result.error.issues) {
26899
- const path14 = [at, ...issue3.path.map((key2) => typeof key2 === "number" || UUID_RE.test(String(key2)) ? "*" : String(key2))].filter(Boolean).join(".");
26900
- report.problems.add(`${path14} ${issue3.code}${issue3.code === "invalid_value" ? ` ${String(issue3.input).slice(0, 40)}` : ""}`);
26898
+ const path16 = [at, ...issue3.path.map((key2) => typeof key2 === "number" || UUID_RE.test(String(key2)) ? "*" : String(key2))].filter(Boolean).join(".");
26899
+ report.problems.add(`${path16} ${issue3.code}${issue3.code === "invalid_value" ? ` ${String(issue3.input).slice(0, 40)}` : ""}`);
26901
26900
  }
26902
26901
  report.dropped++;
26903
26902
  return void 0;
@@ -27217,7 +27216,8 @@ var init_issues = __esm({
27217
27216
  status: external_exports.enum(WORKSPACE_STATUSES),
27218
27217
  avatar: managerAvatarSchema.nullable(),
27219
27218
  manager_id: external_exports.string().nullable(),
27220
- user_id: external_exports.string().nullable().default(null)
27219
+ user_id: external_exports.string().nullable().default(null),
27220
+ shared_with_org: external_exports.boolean().default(false)
27221
27221
  });
27222
27222
  issuesBootstrapResponseSchema = external_exports.object({
27223
27223
  sync_id: external_exports.number().int(),
@@ -27991,20 +27991,20 @@ replicas media upload chart-a.svg chart-b.svg --name "Latency chart" --name "Err
27991
27991
  ARTIFACT_UPLOADING = `## Uploading to Replicas
27992
27992
 
27993
27993
  \`\`\`bash
27994
- replicas artifact upload <path-to-file> --name "<display name>" [<path-to-file> --name "<display name>" ...]
27994
+ replicas artifact upload <path-to-file> --name "<display name>" [<path-to-file> --name "<display name>" ...] --permanent false
27995
27995
  \`\`\`
27996
27996
 
27997
- Pass one or more file paths, each with a required \`--name\` (see below). Uploading several files in a single invocation is preferred over running the command repeatedly: it's faster and keeps the output grouped.
27997
+ Pass one or more file paths, each with a required \`--name\` (see below), and \`--permanent false\` or \`--permanent true\`. Uploading several files in a single invocation is preferred over running the command repeatedly: it's faster and keeps the output grouped.
27998
27998
 
27999
27999
  ### Name each upload
28000
28000
 
28001
28001
  \`--name\` is **required** and sets the short, human-readable name people see in Replicas. Make it descriptive of the content, e.g. \`Login page after fix\` or \`DB latency chart\`. Never use a generic value like \`screenshot\` or \`image\`, and give every upload a distinct name.
28002
28002
 
28003
28003
  \`\`\`bash
28004
- replicas artifact upload /tmp/before.png /tmp/after.png --name "Before fix" --name "After fix" --immutable
28004
+ replicas artifact upload /tmp/before.png /tmp/after.png --name "Before fix" --name "After fix" --permanent false
28005
28005
  \`\`\`
28006
28006
 
28007
- A screenshot or recording is immutable, so these examples pass \`--immutable\`, which also lists it in the workspace's Media folder (see \`ARTIFACTS.md\`).
28007
+ A screenshot or recording is temporary: it is deleted with this workspace (see \`ARTIFACTS.md\`).
28008
28008
 
28009
28009
  For each image, video or audio file, the CLI prints an embed line and a dashboard link:
28010
28010
 
@@ -28023,7 +28023,7 @@ The kind comes from the filename extension. Images (\`png\`, \`jpg\`, \`jpeg\`,
28023
28023
  ## Options
28024
28024
 
28025
28025
  - \`--name <name>\`: required name people see, one per file in order
28026
- - \`--immutable\`: a record of this workspace's work, such as a screenshot or recording, deleted with the workspace (see \`ARTIFACTS.md\`)
28026
+ - \`--permanent false|true\`, required: false (temporary) for screenshots, recordings, test output and working files, deleted with the workspace; permanent only for something the person asked to keep or a finished deliverable (see \`ARTIFACTS.md\`)
28027
28027
  `;
28028
28028
  githubAttachUsage = (textName, replaced) => `\`\`\`bash
28029
28029
  gh pr create --title "Describe the change" --body-file /tmp/pr-body.md --attach './after.png#Settings page after the fix'
@@ -28078,7 +28078,7 @@ ${GITHUB_DONT}
28078
28078
  githubDelivery: `On GitHub, \`gh \u2026 --attach\` uploads screenshots and recording previews and links them.`,
28079
28079
  github: `### GitHub: link images and recordings
28080
28080
 
28081
- GitHub can't show Replicas files inline, and artifacts are never public, so on GitHub you link them: the link opens the file for people signed in to Replicas who can see it. Attach images with \`gh --attach\`, in public and private repositories alike: \`gh\` uploads each image with \`replicas artifact upload --immutable\` and puts its signed-in link in the body. It prints each image's chat embed, so paste those in your chat reply too:
28081
+ GitHub can't show Replicas files inline, and artifacts are never public, so on GitHub you link them: the link opens the file for people signed in to Replicas who can see it. Attach images with \`gh --attach\`, in public and private repositories alike: \`gh\` uploads each image with \`replicas artifact upload --permanent false\` and puts its signed-in link in the body. It prints each image's chat embed, so paste those in your chat reply too:
28082
28082
 
28083
28083
  ${githubAttachUsage("Link text", "becomes a link to the image; other images are appended as links")}
28084
28084
 
@@ -29442,8 +29442,8 @@ var init_preferences = __esm({
29442
29442
  });
29443
29443
 
29444
29444
  // ../shared/src/environment-files.ts
29445
- function validateEnvironmentFilePath(path14) {
29446
- const trimmedPath = path14.trim();
29445
+ function validateEnvironmentFilePath(path16) {
29446
+ const trimmedPath = path16.trim();
29447
29447
  if (!trimmedPath) {
29448
29448
  return "Path is required.";
29449
29449
  }
@@ -29876,7 +29876,7 @@ var init_environment_config = __esm({
29876
29876
  }).nullable().optional(),
29877
29877
  repositories: external_exports.array(external_exports.string().trim().min(1)).optional(),
29878
29878
  workspaceSize: external_exports.enum(WORKSPACE_SIZE_OPTIONS).optional(),
29879
- files: external_exports.record(external_exports.string().trim().refine((path14) => !validateEnvironmentFilePath(path14), "must be a file path starting with ~/"), external_exports.strictObject({
29879
+ files: external_exports.record(external_exports.string().trim().refine((path16) => !validateEnvironmentFilePath(path16), "must be a file path starting with ~/"), external_exports.strictObject({
29880
29880
  name: external_exports.string().trim().min(1).optional(),
29881
29881
  content: external_exports.string().max(65536)
29882
29882
  })).optional(),
@@ -30739,11 +30739,11 @@ function parseShellScript(script, cwd) {
30739
30739
  parseUntil(scope, 0, false);
30740
30740
  return scope.commands;
30741
30741
  }
30742
- function resolveShellPath(dir, path14) {
30743
- if (path14.includes(SHELL_OPAQUE)) return null;
30744
- if (!path14.startsWith("/") && dir === null) return null;
30742
+ function resolveShellPath(dir, path16) {
30743
+ if (path16.includes(SHELL_OPAQUE)) return null;
30744
+ if (!path16.startsWith("/") && dir === null) return null;
30745
30745
  const parts = [];
30746
- for (const part of (path14.startsWith("/") ? path14 : `${dir}/${path14}`).split("/")) {
30746
+ for (const part of (path16.startsWith("/") ? path16 : `${dir}/${path16}`).split("/")) {
30747
30747
  if (part === "..") parts.pop();
30748
30748
  else if (part && part !== ".") parts.push(part);
30749
30749
  }
@@ -31204,8 +31204,8 @@ function parseSkillName(tool, input2) {
31204
31204
  const skillName = parsedInput.skill ?? parsedInput.name;
31205
31205
  return typeof skillName === "string" && skillName ? skillName : null;
31206
31206
  }
31207
- function skillNameFromFilePath(path14) {
31208
- const parts = path14.split(/[\\/]+/).filter(Boolean);
31207
+ function skillNameFromFilePath(path16) {
31208
+ const parts = path16.split(/[\\/]+/).filter(Boolean);
31209
31209
  if (parts.length < 2 || parts[parts.length - 1].toLowerCase() !== "skill.md") return null;
31210
31210
  const skillName = parts[parts.length - 2];
31211
31211
  return /[*?[\]{}…$]/.test(skillName) || ["skills", ".system"].includes(skillName.toLowerCase()) ? null : skillName;
@@ -31214,19 +31214,19 @@ function skillFilePath(tool, input2) {
31214
31214
  if (!READ_TOOL_NAMES.has(tool.toLowerCase())) return null;
31215
31215
  const parsedInput = typeof input2 === "string" ? safeJsonParse(input2, null) : input2;
31216
31216
  if (!isRecord(parsedInput)) return null;
31217
- const path14 = [parsedInput.path, parsedInput.filePath, parsedInput.file_path].find((value) => typeof value === "string" && value.length > 0);
31218
- return path14 && skillNameFromFilePath(path14) ? path14 : null;
31217
+ const path16 = [parsedInput.path, parsedInput.filePath, parsedInput.file_path].find((value) => typeof value === "string" && value.length > 0);
31218
+ return path16 && skillNameFromFilePath(path16) ? path16 : null;
31219
31219
  }
31220
31220
  function createCallDisplayMessage(message2) {
31221
31221
  if (message2.inputRequest) return { ...message2, type: "tool_call" };
31222
- const path14 = skillFilePath(message2.tool, message2.input);
31223
- const skillName = message2.server.toLowerCase() === "skills" ? message2.tool : path14 ? skillNameFromFilePath(path14) : parseSkillName(message2.tool, message2.input);
31222
+ const path16 = skillFilePath(message2.tool, message2.input);
31223
+ const skillName = message2.server.toLowerCase() === "skills" ? message2.tool : path16 ? skillNameFromFilePath(path16) : parseSkillName(message2.tool, message2.input);
31224
31224
  if (skillName === null) return { ...message2, type: "tool_call" };
31225
31225
  return {
31226
31226
  id: message2.id,
31227
31227
  type: "skill",
31228
31228
  skillName,
31229
- ...path14 ? { path: path14 } : {},
31229
+ ...path16 ? { path: path16 } : {},
31230
31230
  status: message2.status,
31231
31231
  timestamp: message2.timestamp
31232
31232
  };
@@ -31258,11 +31258,11 @@ function userMessageText(message2) {
31258
31258
 
31259
31259
  ${message2.content}` : message2.content;
31260
31260
  }
31261
- function fileContentDiff(path14, content, action) {
31261
+ function fileContentDiff(path16, content, action) {
31262
31262
  const lines = content.replace(/\n$/, "").split("\n");
31263
31263
  return [
31264
- `--- ${action === "add" ? "/dev/null" : `a/${path14}`}`,
31265
- `+++ ${action === "add" ? `b/${path14}` : "/dev/null"}`,
31264
+ `--- ${action === "add" ? "/dev/null" : `a/${path16}`}`,
31265
+ `+++ ${action === "add" ? `b/${path16}` : "/dev/null"}`,
31266
31266
  action === "add" ? `@@ -0,0 +1,${lines.length} @@` : `@@ -1,${lines.length} +0,0 @@`,
31267
31267
  ...lines.map((line) => `${action === "add" ? "+" : "-"}${line}`)
31268
31268
  ].join("\n");
@@ -31277,8 +31277,8 @@ function skillNamesFromCommand(command) {
31277
31277
  if (!SKILL_READ_COMMANDS.has(name) || writesFiles(name, argv) || fileWrites(shellCommand).length > 0) return [];
31278
31278
  const paths = readCommandPaths(name, argv);
31279
31279
  const stdinTarget = shellCommand.stdinTarget?.replaceAll(SHELL_OPAQUE, "\u2026");
31280
- return (paths.length === 0 && stdinTarget ? [stdinTarget] : paths).flatMap((path14) => {
31281
- const resolved = path14.startsWith("~") ? path14 : resolveShellPath(shellCommand.dir, path14)?.replace(SCRIPT_ROOT, "");
31280
+ return (paths.length === 0 && stdinTarget ? [stdinTarget] : paths).flatMap((path16) => {
31281
+ const resolved = path16.startsWith("~") ? path16 : resolveShellPath(shellCommand.dir, path16)?.replace(SCRIPT_ROOT, "");
31282
31282
  const skillName = resolved && skillNameFromFilePath(resolved);
31283
31283
  return skillName ? [skillName] : [];
31284
31284
  });
@@ -31362,7 +31362,7 @@ var init_format2 = __esm({
31362
31362
  PATTERN_FLAGS = /* @__PURE__ */ new Set(["-e", "-f", "--file", "--regexp"]);
31363
31363
  SCRIPT_ROOT = "/";
31364
31364
  commandName = (argv) => argv[0].split("/").pop() ?? argv[0];
31365
- fileWrites = ({ writes }) => writes.filter(({ path: path14 }) => path14 !== "/dev/null");
31365
+ fileWrites = ({ writes }) => writes.filter(({ path: path16 }) => path16 !== "/dev/null");
31366
31366
  SKILL_READ_COMMANDS = /* @__PURE__ */ new Set(["awk", "bat", "cat", "head", "less", "more", "nl", "sed", "tail"]);
31367
31367
  }
31368
31368
  });
@@ -31477,17 +31477,17 @@ var require_visit = __commonJS({
31477
31477
  visit2.BREAK = BREAK;
31478
31478
  visit2.SKIP = SKIP;
31479
31479
  visit2.REMOVE = REMOVE;
31480
- function visit_(key2, node2, visitor, path14) {
31481
- const ctrl = callVisitor(key2, node2, visitor, path14);
31480
+ function visit_(key2, node2, visitor, path16) {
31481
+ const ctrl = callVisitor(key2, node2, visitor, path16);
31482
31482
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
31483
- replaceNode(key2, path14, ctrl);
31484
- return visit_(key2, ctrl, visitor, path14);
31483
+ replaceNode(key2, path16, ctrl);
31484
+ return visit_(key2, ctrl, visitor, path16);
31485
31485
  }
31486
31486
  if (typeof ctrl !== "symbol") {
31487
31487
  if (identity.isCollection(node2)) {
31488
- path14 = Object.freeze(path14.concat(node2));
31488
+ path16 = Object.freeze(path16.concat(node2));
31489
31489
  for (let i = 0; i < node2.items.length; ++i) {
31490
- const ci = visit_(i, node2.items[i], visitor, path14);
31490
+ const ci = visit_(i, node2.items[i], visitor, path16);
31491
31491
  if (typeof ci === "number")
31492
31492
  i = ci - 1;
31493
31493
  else if (ci === BREAK)
@@ -31498,13 +31498,13 @@ var require_visit = __commonJS({
31498
31498
  }
31499
31499
  }
31500
31500
  } else if (identity.isPair(node2)) {
31501
- path14 = Object.freeze(path14.concat(node2));
31502
- const ck = visit_("key", node2.key, visitor, path14);
31501
+ path16 = Object.freeze(path16.concat(node2));
31502
+ const ck = visit_("key", node2.key, visitor, path16);
31503
31503
  if (ck === BREAK)
31504
31504
  return BREAK;
31505
31505
  else if (ck === REMOVE)
31506
31506
  node2.key = null;
31507
- const cv = visit_("value", node2.value, visitor, path14);
31507
+ const cv = visit_("value", node2.value, visitor, path16);
31508
31508
  if (cv === BREAK)
31509
31509
  return BREAK;
31510
31510
  else if (cv === REMOVE)
@@ -31525,17 +31525,17 @@ var require_visit = __commonJS({
31525
31525
  visitAsync.BREAK = BREAK;
31526
31526
  visitAsync.SKIP = SKIP;
31527
31527
  visitAsync.REMOVE = REMOVE;
31528
- async function visitAsync_(key2, node2, visitor, path14) {
31529
- const ctrl = await callVisitor(key2, node2, visitor, path14);
31528
+ async function visitAsync_(key2, node2, visitor, path16) {
31529
+ const ctrl = await callVisitor(key2, node2, visitor, path16);
31530
31530
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
31531
- replaceNode(key2, path14, ctrl);
31532
- return visitAsync_(key2, ctrl, visitor, path14);
31531
+ replaceNode(key2, path16, ctrl);
31532
+ return visitAsync_(key2, ctrl, visitor, path16);
31533
31533
  }
31534
31534
  if (typeof ctrl !== "symbol") {
31535
31535
  if (identity.isCollection(node2)) {
31536
- path14 = Object.freeze(path14.concat(node2));
31536
+ path16 = Object.freeze(path16.concat(node2));
31537
31537
  for (let i = 0; i < node2.items.length; ++i) {
31538
- const ci = await visitAsync_(i, node2.items[i], visitor, path14);
31538
+ const ci = await visitAsync_(i, node2.items[i], visitor, path16);
31539
31539
  if (typeof ci === "number")
31540
31540
  i = ci - 1;
31541
31541
  else if (ci === BREAK)
@@ -31546,13 +31546,13 @@ var require_visit = __commonJS({
31546
31546
  }
31547
31547
  }
31548
31548
  } else if (identity.isPair(node2)) {
31549
- path14 = Object.freeze(path14.concat(node2));
31550
- const ck = await visitAsync_("key", node2.key, visitor, path14);
31549
+ path16 = Object.freeze(path16.concat(node2));
31550
+ const ck = await visitAsync_("key", node2.key, visitor, path16);
31551
31551
  if (ck === BREAK)
31552
31552
  return BREAK;
31553
31553
  else if (ck === REMOVE)
31554
31554
  node2.key = null;
31555
- const cv = await visitAsync_("value", node2.value, visitor, path14);
31555
+ const cv = await visitAsync_("value", node2.value, visitor, path16);
31556
31556
  if (cv === BREAK)
31557
31557
  return BREAK;
31558
31558
  else if (cv === REMOVE)
@@ -31579,23 +31579,23 @@ var require_visit = __commonJS({
31579
31579
  }
31580
31580
  return visitor;
31581
31581
  }
31582
- function callVisitor(key2, node2, visitor, path14) {
31582
+ function callVisitor(key2, node2, visitor, path16) {
31583
31583
  if (typeof visitor === "function")
31584
- return visitor(key2, node2, path14);
31584
+ return visitor(key2, node2, path16);
31585
31585
  if (identity.isMap(node2))
31586
- return visitor.Map?.(key2, node2, path14);
31586
+ return visitor.Map?.(key2, node2, path16);
31587
31587
  if (identity.isSeq(node2))
31588
- return visitor.Seq?.(key2, node2, path14);
31588
+ return visitor.Seq?.(key2, node2, path16);
31589
31589
  if (identity.isPair(node2))
31590
- return visitor.Pair?.(key2, node2, path14);
31590
+ return visitor.Pair?.(key2, node2, path16);
31591
31591
  if (identity.isScalar(node2))
31592
- return visitor.Scalar?.(key2, node2, path14);
31592
+ return visitor.Scalar?.(key2, node2, path16);
31593
31593
  if (identity.isAlias(node2))
31594
- return visitor.Alias?.(key2, node2, path14);
31594
+ return visitor.Alias?.(key2, node2, path16);
31595
31595
  return void 0;
31596
31596
  }
31597
- function replaceNode(key2, path14, node2) {
31598
- const parent = path14[path14.length - 1];
31597
+ function replaceNode(key2, path16, node2) {
31598
+ const parent = path16[path16.length - 1];
31599
31599
  if (identity.isCollection(parent)) {
31600
31600
  parent.items[key2] = node2;
31601
31601
  } else if (identity.isPair(parent)) {
@@ -32205,10 +32205,10 @@ var require_Collection = __commonJS({
32205
32205
  var createNode = require_createNode();
32206
32206
  var identity = require_identity();
32207
32207
  var Node = require_Node();
32208
- function collectionFromPath(schema, path14, value) {
32208
+ function collectionFromPath(schema, path16, value) {
32209
32209
  let v2 = value;
32210
- for (let i = path14.length - 1; i >= 0; --i) {
32211
- const k = path14[i];
32210
+ for (let i = path16.length - 1; i >= 0; --i) {
32211
+ const k = path16[i];
32212
32212
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
32213
32213
  const a = [];
32214
32214
  a[k] = v2;
@@ -32227,7 +32227,7 @@ var require_Collection = __commonJS({
32227
32227
  sourceObjects: /* @__PURE__ */ new Map()
32228
32228
  });
32229
32229
  }
32230
- var isEmptyPath = (path14) => path14 == null || typeof path14 === "object" && !!path14[Symbol.iterator]().next().done;
32230
+ var isEmptyPath = (path16) => path16 == null || typeof path16 === "object" && !!path16[Symbol.iterator]().next().done;
32231
32231
  var Collection = class extends Node.NodeBase {
32232
32232
  constructor(type, schema) {
32233
32233
  super(type);
@@ -32257,11 +32257,11 @@ var require_Collection = __commonJS({
32257
32257
  * be a Pair instance or a `{ key, value }` object, which may not have a key
32258
32258
  * that already exists in the map.
32259
32259
  */
32260
- addIn(path14, value) {
32261
- if (isEmptyPath(path14))
32260
+ addIn(path16, value) {
32261
+ if (isEmptyPath(path16))
32262
32262
  this.add(value);
32263
32263
  else {
32264
- const [key2, ...rest] = path14;
32264
+ const [key2, ...rest] = path16;
32265
32265
  const node2 = this.get(key2, true);
32266
32266
  if (identity.isCollection(node2))
32267
32267
  node2.addIn(rest, value);
@@ -32275,8 +32275,8 @@ var require_Collection = __commonJS({
32275
32275
  * Removes a value from the collection.
32276
32276
  * @returns `true` if the item was found and removed.
32277
32277
  */
32278
- deleteIn(path14) {
32279
- const [key2, ...rest] = path14;
32278
+ deleteIn(path16) {
32279
+ const [key2, ...rest] = path16;
32280
32280
  if (rest.length === 0)
32281
32281
  return this.delete(key2);
32282
32282
  const node2 = this.get(key2, true);
@@ -32290,8 +32290,8 @@ var require_Collection = __commonJS({
32290
32290
  * scalar values from their surrounding node; to disable set `keepScalar` to
32291
32291
  * `true` (collections are always returned intact).
32292
32292
  */
32293
- getIn(path14, keepScalar) {
32294
- const [key2, ...rest] = path14;
32293
+ getIn(path16, keepScalar) {
32294
+ const [key2, ...rest] = path16;
32295
32295
  const node2 = this.get(key2, true);
32296
32296
  if (rest.length === 0)
32297
32297
  return !keepScalar && identity.isScalar(node2) ? node2.value : node2;
@@ -32309,8 +32309,8 @@ var require_Collection = __commonJS({
32309
32309
  /**
32310
32310
  * Checks if the collection includes a value with the key `key`.
32311
32311
  */
32312
- hasIn(path14) {
32313
- const [key2, ...rest] = path14;
32312
+ hasIn(path16) {
32313
+ const [key2, ...rest] = path16;
32314
32314
  if (rest.length === 0)
32315
32315
  return this.has(key2);
32316
32316
  const node2 = this.get(key2, true);
@@ -32320,8 +32320,8 @@ var require_Collection = __commonJS({
32320
32320
  * Sets a value in this collection. For `!!set`, `value` needs to be a
32321
32321
  * boolean to add/remove the item from the set.
32322
32322
  */
32323
- setIn(path14, value) {
32324
- const [key2, ...rest] = path14;
32323
+ setIn(path16, value) {
32324
+ const [key2, ...rest] = path16;
32325
32325
  if (rest.length === 0) {
32326
32326
  this.set(key2, value);
32327
32327
  } else {
@@ -34836,9 +34836,9 @@ var require_Document = __commonJS({
34836
34836
  this.contents.add(value);
34837
34837
  }
34838
34838
  /** Adds a value to the document. */
34839
- addIn(path14, value) {
34839
+ addIn(path16, value) {
34840
34840
  if (assertCollection(this.contents))
34841
- this.contents.addIn(path14, value);
34841
+ this.contents.addIn(path16, value);
34842
34842
  }
34843
34843
  /**
34844
34844
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -34913,14 +34913,14 @@ var require_Document = __commonJS({
34913
34913
  * Removes a value from the document.
34914
34914
  * @returns `true` if the item was found and removed.
34915
34915
  */
34916
- deleteIn(path14) {
34917
- if (Collection.isEmptyPath(path14)) {
34916
+ deleteIn(path16) {
34917
+ if (Collection.isEmptyPath(path16)) {
34918
34918
  if (this.contents == null)
34919
34919
  return false;
34920
34920
  this.contents = null;
34921
34921
  return true;
34922
34922
  }
34923
- return assertCollection(this.contents) ? this.contents.deleteIn(path14) : false;
34923
+ return assertCollection(this.contents) ? this.contents.deleteIn(path16) : false;
34924
34924
  }
34925
34925
  /**
34926
34926
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -34935,10 +34935,10 @@ var require_Document = __commonJS({
34935
34935
  * scalar values from their surrounding node; to disable set `keepScalar` to
34936
34936
  * `true` (collections are always returned intact).
34937
34937
  */
34938
- getIn(path14, keepScalar) {
34939
- if (Collection.isEmptyPath(path14))
34938
+ getIn(path16, keepScalar) {
34939
+ if (Collection.isEmptyPath(path16))
34940
34940
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
34941
- return identity.isCollection(this.contents) ? this.contents.getIn(path14, keepScalar) : void 0;
34941
+ return identity.isCollection(this.contents) ? this.contents.getIn(path16, keepScalar) : void 0;
34942
34942
  }
34943
34943
  /**
34944
34944
  * Checks if the document includes a value with the key `key`.
@@ -34949,10 +34949,10 @@ var require_Document = __commonJS({
34949
34949
  /**
34950
34950
  * Checks if the document includes a value at `path`.
34951
34951
  */
34952
- hasIn(path14) {
34953
- if (Collection.isEmptyPath(path14))
34952
+ hasIn(path16) {
34953
+ if (Collection.isEmptyPath(path16))
34954
34954
  return this.contents !== void 0;
34955
- return identity.isCollection(this.contents) ? this.contents.hasIn(path14) : false;
34955
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path16) : false;
34956
34956
  }
34957
34957
  /**
34958
34958
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -34969,13 +34969,13 @@ var require_Document = __commonJS({
34969
34969
  * Sets a value in this document. For `!!set`, `value` needs to be a
34970
34970
  * boolean to add/remove the item from the set.
34971
34971
  */
34972
- setIn(path14, value) {
34973
- if (Collection.isEmptyPath(path14)) {
34972
+ setIn(path16, value) {
34973
+ if (Collection.isEmptyPath(path16)) {
34974
34974
  this.contents = value;
34975
34975
  } else if (this.contents == null) {
34976
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path14), value);
34976
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path16), value);
34977
34977
  } else if (assertCollection(this.contents)) {
34978
- this.contents.setIn(path14, value);
34978
+ this.contents.setIn(path16, value);
34979
34979
  }
34980
34980
  }
34981
34981
  /**
@@ -36935,9 +36935,9 @@ var require_cst_visit = __commonJS({
36935
36935
  visit2.BREAK = BREAK;
36936
36936
  visit2.SKIP = SKIP;
36937
36937
  visit2.REMOVE = REMOVE;
36938
- visit2.itemAtPath = (cst, path14) => {
36938
+ visit2.itemAtPath = (cst, path16) => {
36939
36939
  let item = cst;
36940
- for (const [field2, index] of path14) {
36940
+ for (const [field2, index] of path16) {
36941
36941
  const tok = item?.[field2];
36942
36942
  if (tok && "items" in tok) {
36943
36943
  item = tok.items[index];
@@ -36946,23 +36946,23 @@ var require_cst_visit = __commonJS({
36946
36946
  }
36947
36947
  return item;
36948
36948
  };
36949
- visit2.parentCollection = (cst, path14) => {
36950
- const parent = visit2.itemAtPath(cst, path14.slice(0, -1));
36951
- const field2 = path14[path14.length - 1][0];
36949
+ visit2.parentCollection = (cst, path16) => {
36950
+ const parent = visit2.itemAtPath(cst, path16.slice(0, -1));
36951
+ const field2 = path16[path16.length - 1][0];
36952
36952
  const coll = parent?.[field2];
36953
36953
  if (coll && "items" in coll)
36954
36954
  return coll;
36955
36955
  throw new Error("Parent collection not found");
36956
36956
  };
36957
- function _visit(path14, item, visitor) {
36958
- let ctrl = visitor(item, path14);
36957
+ function _visit(path16, item, visitor) {
36958
+ let ctrl = visitor(item, path16);
36959
36959
  if (typeof ctrl === "symbol")
36960
36960
  return ctrl;
36961
36961
  for (const field2 of ["key", "value"]) {
36962
36962
  const token = item[field2];
36963
36963
  if (token && "items" in token) {
36964
36964
  for (let i = 0; i < token.items.length; ++i) {
36965
- const ci = _visit(Object.freeze(path14.concat([[field2, i]])), token.items[i], visitor);
36965
+ const ci = _visit(Object.freeze(path16.concat([[field2, i]])), token.items[i], visitor);
36966
36966
  if (typeof ci === "number")
36967
36967
  i = ci - 1;
36968
36968
  else if (ci === BREAK)
@@ -36973,10 +36973,10 @@ var require_cst_visit = __commonJS({
36973
36973
  }
36974
36974
  }
36975
36975
  if (typeof ctrl === "function" && field2 === "key")
36976
- ctrl = ctrl(item, path14);
36976
+ ctrl = ctrl(item, path16);
36977
36977
  }
36978
36978
  }
36979
- return typeof ctrl === "function" ? ctrl(item, path14) : ctrl;
36979
+ return typeof ctrl === "function" ? ctrl(item, path16) : ctrl;
36980
36980
  }
36981
36981
  exports2.visit = visit2;
36982
36982
  }
@@ -38278,14 +38278,14 @@ var require_parser = __commonJS({
38278
38278
  case "scalar":
38279
38279
  case "single-quoted-scalar":
38280
38280
  case "double-quoted-scalar": {
38281
- const fs15 = this.flowScalar(this.type);
38281
+ const fs16 = this.flowScalar(this.type);
38282
38282
  if (atNextItem || it.value) {
38283
- map2.items.push({ start, key: fs15, sep: [] });
38283
+ map2.items.push({ start, key: fs16, sep: [] });
38284
38284
  this.onKeyLine = true;
38285
38285
  } else if (it.sep) {
38286
- this.stack.push(fs15);
38286
+ this.stack.push(fs16);
38287
38287
  } else {
38288
- Object.assign(it, { key: fs15, sep: [] });
38288
+ Object.assign(it, { key: fs16, sep: [] });
38289
38289
  this.onKeyLine = true;
38290
38290
  }
38291
38291
  return;
@@ -38413,13 +38413,13 @@ var require_parser = __commonJS({
38413
38413
  case "scalar":
38414
38414
  case "single-quoted-scalar":
38415
38415
  case "double-quoted-scalar": {
38416
- const fs15 = this.flowScalar(this.type);
38416
+ const fs16 = this.flowScalar(this.type);
38417
38417
  if (!it || it.value)
38418
- fc.items.push({ start: [], key: fs15, sep: [] });
38418
+ fc.items.push({ start: [], key: fs16, sep: [] });
38419
38419
  else if (it.sep)
38420
- this.stack.push(fs15);
38420
+ this.stack.push(fs16);
38421
38421
  else
38422
- Object.assign(it, { key: fs15, sep: [] });
38422
+ Object.assign(it, { key: fs16, sep: [] });
38423
38423
  return;
38424
38424
  }
38425
38425
  case "flow-map-end":
@@ -38967,7 +38967,7 @@ function stripAttachmentNote(text5) {
38967
38967
  if (annotationsNote) content = content.slice(0, annotationsNote.index).trim();
38968
38968
  return {
38969
38969
  content,
38970
- files: match ? [...match[1].matchAll(/^- (.+)$/gm)].map(([, path14]) => path14) : [],
38970
+ files: match ? [...match[1].matchAll(/^- (.+)$/gm)].map(([, path16]) => path16) : [],
38971
38971
  walkthroughs,
38972
38972
  appshots,
38973
38973
  annotations: annotationsNote ? parseAnnotationsNote(annotationsNote.body) : []
@@ -39006,7 +39006,7 @@ var init_user_message_attachments = __esm({
39006
39006
  WALKTHROUGH_NOTE_REGEX = /(?:^|\n\n)<replicas_walkthrough path="([^"\n]+)" duration_seconds="(\d+)" audio="(true|false)">\n[^<]*\n<\/replicas_walkthrough>$/;
39007
39007
  TRUNCATED_WALKTHROUGH_NOTE_REGEX = /(?:^|\n\n)<replicas_walkthrough path="([^"\n]*)(?:" duration_seconds="(\d*))?(?:" audio="(true)?)?[^<]*(?:<\/?[a-z_]*)?$/;
39008
39008
  VIDEO_SIZES_REGEX = /<replicas_instructions>\nThe attached videos' frame sizes, in pixels:((?:\n- .+: \d+x\d+)+)(?:\nFor display only; ignore\.)?\n<\/replicas_instructions>/;
39009
- parseVideoSizes = (raw) => Object.fromEntries([...(raw.match(VIDEO_SIZES_REGEX)?.[1] ?? "").matchAll(/^- (.+): (\d+)x(\d+)$/gm)].map(([, path14, width, height]) => [path14, { width: Number(width), height: Number(height) }]));
39009
+ parseVideoSizes = (raw) => Object.fromEntries([...(raw.match(VIDEO_SIZES_REGEX)?.[1] ?? "").matchAll(/^- (.+): (\d+)x(\d+)$/gm)].map(([, path16, width, height]) => [path16, { width: Number(width), height: Number(height) }]));
39010
39010
  }
39011
39011
  });
39012
39012
 
@@ -40387,7 +40387,7 @@ function parseOpencodeEvents(events) {
40387
40387
  upsertDisplayMessage(messages, {
40388
40388
  id,
40389
40389
  type: "file_change",
40390
- changes: files.map((path14) => ({ path: path14, kind: "update" })),
40390
+ changes: files.map((path16) => ({ path: path16, kind: "update" })),
40391
40391
  status: "completed",
40392
40392
  timestamp: timestamp2
40393
40393
  });
@@ -43585,7 +43585,7 @@ var CLI_VERSION;
43585
43585
  var init_cli_version = __esm({
43586
43586
  "../shared/src/cli-version.ts"() {
43587
43587
  "use strict";
43588
- CLI_VERSION = "0.3.685";
43588
+ CLI_VERSION = "0.3.688";
43589
43589
  }
43590
43590
  });
43591
43591
 
@@ -44136,7 +44136,7 @@ var init_web_auth = __esm({
44136
44136
  });
44137
44137
 
44138
44138
  // ../shared/src/routes/artifacts.ts
44139
- var ARTIFACT_KINDS, ARTIFACT_MUTABILITIES, ARTIFACT_PERMISSIONS, ARTIFACT_LIST_OWNERS, ARTIFACT_DISPLAY_NAME_MAX_LENGTH, artifactMetadataSchema, listArtifactsQuerySchema, listArtifactWorkspacesQuerySchema, updateArtifactRequestSchema, setArtifactShareRequestSchema;
44139
+ var ARTIFACT_KINDS, ARTIFACT_PERMISSIONS, ARTIFACT_LIST_OWNERS, ARTIFACT_DISPLAY_NAME_MAX_LENGTH, artifactMetadataSchema, listArtifactsQuerySchema, listArtifactWorkspacesQuerySchema, updateArtifactRequestSchema, setArtifactShareRequestSchema;
44140
44140
  var init_artifacts2 = __esm({
44141
44141
  "../shared/src/routes/artifacts.ts"() {
44142
44142
  "use strict";
@@ -44144,7 +44144,6 @@ var init_artifacts2 = __esm({
44144
44144
  init_types4();
44145
44145
  init_visuals();
44146
44146
  ARTIFACT_KINDS = CANVAS_ITEM_KINDS.filter((kind) => kind !== "other");
44147
- ARTIFACT_MUTABILITIES = ["mutable", "immutable"];
44148
44147
  ARTIFACT_PERMISSIONS = ["view", "edit"];
44149
44148
  ARTIFACT_LIST_OWNERS = ["me", "others", "organization"];
44150
44149
  ARTIFACT_DISPLAY_NAME_MAX_LENGTH = 200;
@@ -44152,7 +44151,7 @@ var init_artifacts2 = __esm({
44152
44151
  visual_heights: visualHeightsSchema.optional()
44153
44152
  });
44154
44153
  listArtifactsQuerySchema = external_exports.object({
44155
- mutability: external_exports.enum([...ARTIFACT_MUTABILITIES, "all"]).optional(),
44154
+ permanent: external_exports.enum(["true", "false", "all"]).transform((value) => value === "all" ? null : value === "true").optional(),
44156
44155
  owner: external_exports.array(external_exports.enum(ARTIFACT_LIST_OWNERS)),
44157
44156
  kind: external_exports.array(external_exports.enum(ARTIFACT_KINDS)),
44158
44157
  workspace_id: external_exports.string().uuid().optional(),
@@ -44166,8 +44165,9 @@ var init_artifacts2 = __esm({
44166
44165
  owner: external_exports.array(external_exports.union([external_exports.literal("organization"), external_exports.string().uuid()]))
44167
44166
  });
44168
44167
  updateArtifactRequestSchema = external_exports.object({
44169
- display_name: external_exports.string().trim().min(1).max(ARTIFACT_DISPLAY_NAME_MAX_LENGTH)
44170
- });
44168
+ display_name: external_exports.string().trim().min(1).max(ARTIFACT_DISPLAY_NAME_MAX_LENGTH).optional(),
44169
+ permanent: external_exports.boolean().optional()
44170
+ }).refine((body2) => body2.display_name !== void 0 || body2.permanent !== void 0);
44171
44171
  setArtifactShareRequestSchema = external_exports.object({ permission: external_exports.enum(ARTIFACT_PERMISSIONS) });
44172
44172
  }
44173
44173
  });
@@ -57133,8 +57133,8 @@ var init_claude_auth2 = __esm({
57133
57133
  });
57134
57134
 
57135
57135
  // src/lib/muse-oauth.ts
57136
- async function post(path14, body2) {
57137
- return fetch(`${AUTH_URL}${path14}`, {
57136
+ async function post(path16, body2) {
57137
+ return fetch(`${AUTH_URL}${path16}`, {
57138
57138
  method: "POST",
57139
57139
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
57140
57140
  body: body2
@@ -57408,7 +57408,7 @@ async function credentialsGetCommand(service, options) {
57408
57408
  });
57409
57409
  }
57410
57410
  async function credentialsSetCommand(service, options) {
57411
- const path14 = credentialsPath(service, options, true);
57411
+ const path16 = credentialsPath(service, options, true);
57412
57412
  const { org: org2, models, ...fields } = options;
57413
57413
  const secretField = service === "bedrock" ? "aws_secret_access_key" : "api_key";
57414
57414
  const body2 = {
@@ -57416,7 +57416,7 @@ async function credentialsSetCommand(service, options) {
57416
57416
  ...models ? { models: models.split(",").map((model2) => model2.trim()).filter(Boolean) } : {},
57417
57417
  [secretField]: await readSecret(service, secretField === "api_key" ? "API key" : "AWS secret access key")
57418
57418
  };
57419
- const response = await orgAuthenticatedFetch(path14, { method: "POST", body: body2 });
57419
+ const response = await orgAuthenticatedFetch(path16, { method: "POST", body: body2 });
57420
57420
  output2(response, () => console.log(import_chalk19.default.green(`Saved ${scopeLabel(options)} ${service} credentials.`)));
57421
57421
  }
57422
57422
  async function credentialsRemoveCommand(service, options) {
@@ -59128,8 +59128,8 @@ async function chatQueueListCommand(id, chatId) {
59128
59128
  printQueue(queue);
59129
59129
  });
59130
59130
  }
59131
- async function mutateQueue(path14, method, body2) {
59132
- output2(await orgAuthenticatedFetch(path14, { method, body: body2 }), ({ queue }) => {
59131
+ async function mutateQueue(path16, method, body2) {
59132
+ output2(await orgAuthenticatedFetch(path16, { method, body: body2 }), ({ queue }) => {
59133
59133
  if (queue) printQueue(queue);
59134
59134
  else console.log("Done.");
59135
59135
  });
@@ -59143,7 +59143,7 @@ var init_chat = __esm({
59143
59143
  init_api2();
59144
59144
  init_output();
59145
59145
  init_replica2();
59146
- chatPath2 = (id, chatId, path14 = "") => `/v1/replica/${id}/chats/${chatId}${path14}`;
59146
+ chatPath2 = (id, chatId, path16 = "") => `/v1/replica/${id}/chats/${chatId}${path16}`;
59147
59147
  chatQueueClearCommand = (id, chatId) => mutateQueue(chatPath2(id, chatId, "/queue"), "DELETE");
59148
59148
  chatQueueRemoveCommand = (id, chatId, messageId) => mutateQueue(chatPath2(id, chatId, `/queue/${messageId}`), "DELETE");
59149
59149
  chatQueueEditCommand = (id, chatId, messageId, message2) => mutateQueue(chatPath2(id, chatId, `/queue/${messageId}`), "PATCH", { message: message2 });
@@ -59194,7 +59194,7 @@ var init_plugins3 = __esm({
59194
59194
  init_command_utils();
59195
59195
  init_output();
59196
59196
  init_environment3();
59197
- pluginsPath = async ({ env }, path14) => env ? `/v1/environments/${await resolveEnvironmentId(env)}/plugins${path14}` : `/v1/plugins${path14}`;
59197
+ pluginsPath = async ({ env }, path16) => env ? `/v1/environments/${await resolveEnvironmentId(env)}/plugins${path16}` : `/v1/plugins${path16}`;
59198
59198
  }
59199
59199
  });
59200
59200
 
@@ -60216,10 +60216,10 @@ var init_automation = __esm({
60216
60216
  });
60217
60217
 
60218
60218
  // src/lib/agent-api.ts
60219
- async function agentFetch(path14, options) {
60220
- return (await agentRequest(path14, options)).json();
60219
+ async function agentFetch(path16, options) {
60220
+ return (await agentRequest(path16, options)).json();
60221
60221
  }
60222
- async function agentRequest(path14, options) {
60222
+ async function agentRequest(path16, options) {
60223
60223
  const config3 = readAgentConfig();
60224
60224
  if (!config3) {
60225
60225
  throw new Error("Agent mode config not found");
@@ -60235,7 +60235,7 @@ async function agentRequest(path14, options) {
60235
60235
  ...options?.headers || {}
60236
60236
  };
60237
60237
  const body2 = rawBody === void 0 ? void 0 : rawBody instanceof FormData || rawBody instanceof ReadableStream ? rawBody : JSON.stringify(rawBody);
60238
- const response = await fetch(`${MONOLITH_URL}${path14}`, {
60238
+ const response = await fetch(`${MONOLITH_URL}${path16}`, {
60239
60239
  ...options,
60240
60240
  headers,
60241
60241
  body: body2,
@@ -60247,7 +60247,7 @@ async function agentRequest(path14, options) {
60247
60247
  }
60248
60248
  return response;
60249
60249
  }
60250
- async function engineFetch(path14, options) {
60250
+ async function engineFetch(path16, options) {
60251
60251
  const config3 = readAgentConfig();
60252
60252
  if (!config3) {
60253
60253
  throw new Error("Agent mode config not found");
@@ -60257,7 +60257,7 @@ async function engineFetch(path14, options) {
60257
60257
  "Content-Type": "application/json",
60258
60258
  ...options?.headers || {}
60259
60259
  };
60260
- const response = await fetch(`http://localhost:${ENGINE_PORT2}${path14}`, {
60260
+ const response = await fetch(`http://localhost:${ENGINE_PORT2}${path16}`, {
60261
60261
  ...options,
60262
60262
  headers,
60263
60263
  body: options?.body !== void 0 ? JSON.stringify(options.body) : void 0
@@ -60681,27 +60681,88 @@ var init_media_gif = __esm({
60681
60681
  }
60682
60682
  });
60683
60683
 
60684
+ // src/lib/artifact-files.ts
60685
+ function readArtifactFiles() {
60686
+ try {
60687
+ return artifactFilesSchema.parse(JSON.parse(import_node_fs2.default.readFileSync(ARTIFACT_FILES_PATH, "utf8")));
60688
+ } catch {
60689
+ return { files: {} };
60690
+ }
60691
+ }
60692
+ function writeArtifactFiles(record2) {
60693
+ try {
60694
+ const temporary = `${ARTIFACT_FILES_PATH}.${process.pid}.tmp`;
60695
+ import_node_fs2.default.mkdirSync(import_node_path2.default.dirname(ARTIFACT_FILES_PATH), { recursive: true });
60696
+ import_node_fs2.default.writeFileSync(temporary, JSON.stringify(record2, null, 2));
60697
+ import_node_fs2.default.renameSync(temporary, ARTIFACT_FILES_PATH);
60698
+ } catch {
60699
+ }
60700
+ }
60701
+ function sha2562(body2) {
60702
+ return (0, import_node_crypto2.createHash)("sha256").update(body2).digest("hex");
60703
+ }
60704
+ var import_node_crypto2, import_node_fs2, import_node_path2, artifactFilesSchema, ARTIFACT_FILES_PATH;
60705
+ var init_artifact_files = __esm({
60706
+ "src/lib/artifact-files.ts"() {
60707
+ "use strict";
60708
+ import_node_crypto2 = require("crypto");
60709
+ import_node_fs2 = __toESM(require("fs"));
60710
+ import_node_path2 = __toESM(require("path"));
60711
+ init_zod();
60712
+ init_config();
60713
+ artifactFilesSchema = external_exports.looseObject({
60714
+ files: external_exports.record(external_exports.string(), external_exports.looseObject({ artifactId: external_exports.string(), sha256: external_exports.string() }))
60715
+ });
60716
+ ARTIFACT_FILES_PATH = import_node_path2.default.join(CONFIG_DIR, "artifacts.json");
60717
+ }
60718
+ });
60719
+
60684
60720
  // src/commands/artifact.ts
60685
- async function uploadArtifact(filePath, displayName, options) {
60721
+ async function uploadArtifact(filePath, displayName, permanent, record2) {
60686
60722
  const { fileName, body: body2 } = readUploadFile(filePath);
60723
+ const absolutePath = import_node_path3.default.resolve(filePath);
60724
+ const hash2 = sha2562(body2);
60725
+ const saved = record2.files[absolutePath];
60726
+ if (saved?.sha256 === hash2) {
60727
+ const existing = await agentFetch(`/v1/artifacts/${saved.artifactId}`).catch((error62) => {
60728
+ if (error62 instanceof AgentRequestError && error62.status === 404) return null;
60729
+ throw error62;
60730
+ });
60731
+ if (existing?.artifact.permanent === permanent) return { artifact: existing.artifact, outcome: "unchanged" };
60732
+ if (existing) {
60733
+ const { artifact: artifact3 } = await agentFetch(`/v1/artifacts/${saved.artifactId}`, { method: "PATCH", body: { permanent } });
60734
+ return { artifact: artifact3, outcome: permanent ? "kept" : "unkept" };
60735
+ }
60736
+ }
60687
60737
  const form = new FormData();
60688
60738
  form.append("file", new Blob([body2]), fileName);
60689
60739
  form.append("display_name", displayName);
60690
- form.append("mutability", options.immutable ? "immutable" : "mutable");
60740
+ form.append("permanent", String(permanent));
60691
60741
  const { artifact: artifact2 } = await agentFetch("/v1/artifacts", { method: "POST", body: form });
60692
- return artifact2;
60742
+ record2.files[absolutePath] = { artifactId: artifact2.id, sha256: hash2 };
60743
+ return { artifact: artifact2, outcome: "saved" };
60693
60744
  }
60694
60745
  async function artifactUploadCommand(filePaths, options) {
60695
60746
  if (!isAgentMode()) throw new Error("Run this inside a Replicas workspace. Only workspaces can upload artifacts.");
60747
+ if (options.permanent !== "true" && options.permanent !== "false") {
60748
+ throw new Error([
60749
+ "Pass --permanent false or --permanent true.",
60750
+ "--permanent false: deleted with this workspace. Screenshots, recordings, GIFs, test output, one-off renders, and working files such as plans and notes. If unsure, false.",
60751
+ "--permanent true: kept after the workspace is gone. Only when the person asked to keep it, or it is the finished deliverable of the task (a report, dashboard or dataset)."
60752
+ ].join("\n"));
60753
+ }
60754
+ const permanent = options.permanent === "true";
60696
60755
  const names = requireNamePerFile(filePaths, options.name ?? []);
60756
+ const record2 = readArtifactFiles();
60697
60757
  const results = await Promise.allSettled(
60698
- filePaths.map((filePath, i) => uploadArtifact(filePath, names[i], options))
60758
+ filePaths.map((filePath, i) => uploadArtifact(filePath, names[i], permanent, record2))
60699
60759
  );
60760
+ writeArtifactFiles(record2);
60700
60761
  const uploads = [];
60701
60762
  const failures = [];
60702
60763
  results.forEach((result, i) => {
60703
60764
  if (result.status === "fulfilled") {
60704
- uploads.push({ file: filePaths[i], artifact: result.value });
60765
+ uploads.push({ file: filePaths[i], ...result.value });
60705
60766
  } else {
60706
60767
  const reason = result.reason instanceof Error ? result.reason.message : String(result.reason);
60707
60768
  failures.push(`${filePaths[i]}: ${reason}`);
@@ -60709,10 +60770,11 @@ async function artifactUploadCommand(filePaths, options) {
60709
60770
  });
60710
60771
  const workspaceId = readAgentConfig()?.workspace_id;
60711
60772
  output2({ uploads }, () => {
60712
- for (const { artifact: artifact2 } of uploads) {
60773
+ for (const { artifact: artifact2, outcome } of uploads) {
60713
60774
  const size = formatBytes(artifact2.size_bytes);
60714
60775
  const visibility = artifact2.owner ? `Private to ${artifact2.owner.display_name} until shared.` : "This workspace has no owner, so it belongs to the organization: everyone in it can see, rename and delete it.";
60715
- console.log(`Saved artifact "${artifact2.display_name}" (${artifact2.kind}, ${size}). ${visibility}`);
60776
+ const lifetime = artifact2.permanent ? "Permanent: kept after this workspace is gone." : "Temporary: deleted with this workspace.";
60777
+ console.log(`${OUTCOME_LABELS[outcome]} "${artifact2.display_name}" (${artifact2.kind}, ${size}). ${lifetime} ${visibility}`);
60716
60778
  const mediaKind = MEDIA_KINDS.find((kind) => kind === artifact2.kind);
60717
60779
  if (!mediaKind) {
60718
60780
  console.log(`[${markdownLabel(artifact2.display_name)}](${getArtifactUrl(artifact2.id)})`);
@@ -60727,8 +60789,8 @@ async function artifactUploadCommand(filePaths, options) {
60727
60789
  }
60728
60790
  async function artifactListCommand(options) {
60729
60791
  const query = new URLSearchParams();
60730
- if (options.all) query.set("mutability", "all");
60731
- else if (options.immutable) query.set("mutability", "immutable");
60792
+ if (options.all) query.set("permanent", "all");
60793
+ else if (options.permanent) query.set("permanent", options.permanent);
60732
60794
  for (const owner of options.owner ?? []) query.append("owner", owner);
60733
60795
  for (const kind of options.kind ?? []) query.append("kind", kind);
60734
60796
  if (options.workspace) {
@@ -60744,15 +60806,15 @@ async function artifactListCommand(options) {
60744
60806
  for (const artifact2 of artifacts) {
60745
60807
  const owner = artifact2.owner?.email ?? "organization";
60746
60808
  const size = formatBytes(artifact2.size_bytes);
60747
- const columns = [artifact2.id, artifact2.kind, artifact2.mutability, artifact2.display_name, owner, size, artifact2.updated_at];
60809
+ const columns = [artifact2.id, artifact2.kind, artifact2.permanent ? "permanent" : "temporary", artifact2.display_name, owner, size, artifact2.updated_at];
60748
60810
  console.log(columns.join(" "));
60749
60811
  }
60750
60812
  if (total > artifacts.length) console.log(`Showing ${artifacts.length} of ${total}. Use --page for more.`);
60751
60813
  });
60752
60814
  }
60753
60815
  async function artifactUrlCommand(artifactId) {
60754
- const path14 = `/v1/artifacts/${artifactId}/url?disposition=attachment`;
60755
- const response = await orgAuthenticatedFetch(path14);
60816
+ const path16 = `/v1/artifacts/${artifactId}/url?disposition=attachment`;
60817
+ const response = await orgAuthenticatedFetch(path16);
60756
60818
  output2(response, ({ url: url2 }) => console.log(url2));
60757
60819
  }
60758
60820
  async function artifactRenameCommand(artifactId, name) {
@@ -60782,13 +60844,13 @@ async function artifactShareCommand(artifactId, options) {
60782
60844
  if (!permission) {
60783
60845
  throw new Error(`Invalid permission '${options.permission}'. Must be one of: ${ARTIFACT_PERMISSIONS.join(", ")}`);
60784
60846
  }
60785
- const { path: path14, granteeName } = await resolveGrantPath(artifactId, options);
60786
- const { share: share2 } = await orgAuthenticatedFetch(path14, { method: "PUT", body: { permission } });
60847
+ const { path: path16, granteeName } = await resolveGrantPath(artifactId, options);
60848
+ const { share: share2 } = await orgAuthenticatedFetch(path16, { method: "PUT", body: { permission } });
60787
60849
  output2({ share: share2 }, () => console.log(`Shared artifact ${artifactId} with ${granteeName} (${share2.permission}).`));
60788
60850
  }
60789
60851
  async function artifactUnshareCommand(artifactId, options) {
60790
- const { path: path14, granteeName } = await resolveGrantPath(artifactId, options);
60791
- await orgAuthenticatedFetch(path14, { method: "DELETE" });
60852
+ const { path: path16, granteeName } = await resolveGrantPath(artifactId, options);
60853
+ await orgAuthenticatedFetch(path16, { method: "DELETE" });
60792
60854
  outputSuccess(`Artifact ${artifactId} is no longer shared with ${granteeName}.`);
60793
60855
  }
60794
60856
  async function artifactSharesCommand(artifactId) {
@@ -60799,16 +60861,25 @@ async function artifactSharesCommand(artifactId) {
60799
60861
  for (const share2 of users) console.log(`${share2.user?.email} ${share2.permission}`);
60800
60862
  });
60801
60863
  }
60864
+ var import_node_path3, OUTCOME_LABELS;
60802
60865
  var init_artifact = __esm({
60803
60866
  "src/commands/artifact.ts"() {
60804
60867
  "use strict";
60868
+ import_node_path3 = __toESM(require("path"));
60805
60869
  init_src();
60806
60870
  init_agent_api();
60871
+ init_artifact_files();
60807
60872
  init_api2();
60808
60873
  init_command_utils();
60809
60874
  init_config();
60810
60875
  init_members();
60811
60876
  init_output();
60877
+ OUTCOME_LABELS = {
60878
+ saved: "Saved artifact",
60879
+ unchanged: "Already saved, nothing uploaded:",
60880
+ kept: "Now permanent:",
60881
+ unkept: "Now temporary:"
60882
+ };
60812
60883
  }
60813
60884
  });
60814
60885
 
@@ -60833,12 +60904,12 @@ async function callIssueTool(name, args, schema, printHuman) {
60833
60904
  async function uploadAttachments(files) {
60834
60905
  if (!files?.length) return void 0;
60835
60906
  if (!isAgentMode()) throw new Error("--attach works inside a workspace. Elsewhere, embed an image URL in the markdown.");
60836
- const uploaded = await Promise.all(files.map((file2) => uploadOne(file2, import_node_path2.default.basename(file2), resolveKind(import_node_path2.default.extname(file2).slice(1).toLowerCase()), {})));
60907
+ const uploaded = await Promise.all(files.map((file2) => uploadOne(file2, import_node_path4.default.basename(file2), resolveKind(import_node_path4.default.extname(file2).slice(1).toLowerCase()), {})));
60837
60908
  return uploaded.map(({ media: media2 }) => media2.id);
60838
60909
  }
60839
60910
  function readText2(inline, file2, what) {
60840
60911
  if (inline !== void 0 && file2 !== void 0) throw new Error(`Pass either --${what} or --${what}-file, not both`);
60841
- return file2 === void 0 ? inline : import_node_fs2.default.readFileSync(file2 === "-" ? 0 : file2, "utf8");
60912
+ return file2 === void 0 ? inline : import_node_fs3.default.readFileSync(file2 === "-" ? 0 : file2, "utf8");
60842
60913
  }
60843
60914
  async function issueCreateCommand(title3, options) {
60844
60915
  await callIssueTool(ISSUE_COMMANDS.create, {
@@ -60940,12 +61011,12 @@ async function issueUnlinkPrCommand(issue3, url2) {
60940
61011
  async function issueRelateCommand(issue3, type, related) {
60941
61012
  await callIssueTool(ISSUE_COMMANDS.relate, { issue: issue3, type, related_issue: related }, noData, () => console.log(`${import_chalk30.default.green("\u2713")} ${issue3} ${type.replace("_", " ")} ${related}`));
60942
61013
  }
60943
- var import_node_fs2, import_node_path2, import_chalk30, mutationSchema, noData, csv, issueLine, printMutation;
61014
+ var import_node_fs3, import_node_path4, import_chalk30, mutationSchema, noData, csv, issueLine, printMutation;
60944
61015
  var init_issue = __esm({
60945
61016
  "src/commands/issue.ts"() {
60946
61017
  "use strict";
60947
- import_node_fs2 = __toESM(require("fs"));
60948
- import_node_path2 = __toESM(require("path"));
61018
+ import_node_fs3 = __toESM(require("fs"));
61019
+ import_node_path4 = __toESM(require("path"));
60949
61020
  import_chalk30 = __toESM(require("chalk"));
60950
61021
  init_zod();
60951
61022
  init_src();
@@ -61408,16 +61479,16 @@ function computeExecCommand(kind) {
61408
61479
  return async (command, options) => {
61409
61480
  if (command.length === 0) throw new Error(`Pass a command after --, e.g. replicas ${kind} exec -- ${kind === "gpu" ? "nvidia-smi" : "xcodebuild -version"}`);
61410
61481
  const sandboxId = await resolveSandboxId(kind, options);
61411
- const path14 = `${BASE}/${sandboxId}/exec`;
61482
+ const path16 = `${BASE}/${sandboxId}/exec`;
61412
61483
  if (options.detach) {
61413
- const { jobId } = await agentFetch(path14, execRequest(command.join(" "), options));
61484
+ const { jobId } = await agentFetch(path16, execRequest(command.join(" "), options));
61414
61485
  output2({ jobId, sandboxId }, () => {
61415
61486
  console.log(`Started job ${import_chalk31.default.bold(jobId)} in ${sandboxId}`);
61416
61487
  console.log(import_chalk31.default.gray(`Follow it with: replicas ${kind} logs ${jobId} -f`));
61417
61488
  });
61418
61489
  return;
61419
61490
  }
61420
- const exitCode = await streamOutput(await agentRequest(path14, execRequest(command.join(" "), options)));
61491
+ const exitCode = await streamOutput(await agentRequest(path16, execRequest(command.join(" "), options)));
61421
61492
  process.exitCode = exitCode ?? 1;
61422
61493
  if (isJsonMode()) output2({ sandboxId, exitCode }, () => {
61423
61494
  });
@@ -61450,21 +61521,21 @@ function assertTransferSize(bytes, localPath) {
61450
61521
  }
61451
61522
  }
61452
61523
  function archive(localPath) {
61453
- const path14 = (0, import_node_path3.resolve)(localPath);
61454
- if (!(0, import_node_fs3.existsSync)(path14)) throw new Error(`${path14} does not exist`);
61455
- if (!(0, import_node_fs3.statSync)(path14).isDirectory()) {
61456
- assertTransferSize((0, import_node_fs3.statSync)(path14).size, localPath);
61457
- return (0, import_node_child_process2.spawn)("tar", ["-czf", "-", "-C", (0, import_node_path3.dirname)(path14), (0, import_node_path3.basename)(path14)], { stdio: ["ignore", "pipe", "pipe"] });
61524
+ const path16 = (0, import_node_path5.resolve)(localPath);
61525
+ if (!(0, import_node_fs4.existsSync)(path16)) throw new Error(`${path16} does not exist`);
61526
+ if (!(0, import_node_fs4.statSync)(path16).isDirectory()) {
61527
+ assertTransferSize((0, import_node_fs4.statSync)(path16).size, localPath);
61528
+ return (0, import_node_child_process2.spawn)("tar", ["-czf", "-", "-C", (0, import_node_path5.dirname)(path16), (0, import_node_path5.basename)(path16)], { stdio: ["ignore", "pipe", "pipe"] });
61458
61529
  }
61459
- const listed = (0, import_node_child_process2.spawnSync)("git", ["-C", path14, "ls-files", "-co", "--exclude-standard", "-z"], { maxBuffer: 256 * 1024 * 1024 });
61530
+ const listed = (0, import_node_child_process2.spawnSync)("git", ["-C", path16, "ls-files", "-co", "--exclude-standard", "-z"], { maxBuffer: 256 * 1024 * 1024 });
61460
61531
  if (listed.status !== 0) {
61461
- const du = (0, import_node_child_process2.spawnSync)("du", ["-sk", "--exclude=.git", "--exclude=node_modules", path14]);
61532
+ const du = (0, import_node_child_process2.spawnSync)("du", ["-sk", "--exclude=.git", "--exclude=node_modules", path16]);
61462
61533
  assertTransferSize(Number(du.stdout.toString().split(" ")[0]) * 1024, localPath);
61463
- return (0, import_node_child_process2.spawn)("tar", ["-czf", "-", "-C", path14, "--exclude=.git", "--exclude=node_modules", "."], { stdio: ["ignore", "pipe", "pipe"] });
61534
+ return (0, import_node_child_process2.spawn)("tar", ["-czf", "-", "-C", path16, "--exclude=.git", "--exclude=node_modules", "."], { stdio: ["ignore", "pipe", "pipe"] });
61464
61535
  }
61465
- const files = listed.stdout.toString().split("\0").filter((file2) => file2 && (0, import_node_fs3.existsSync)((0, import_node_path3.join)(path14, file2)));
61466
- assertTransferSize(files.reduce((total, file2) => total + (0, import_node_fs3.statSync)((0, import_node_path3.join)(path14, file2)).size, 0), localPath);
61467
- const child = (0, import_node_child_process2.spawn)("tar", ["-czf", "-", "-C", path14, "--null", "-T", "-"], { stdio: ["pipe", "pipe", "pipe"] });
61536
+ const files = listed.stdout.toString().split("\0").filter((file2) => file2 && (0, import_node_fs4.existsSync)((0, import_node_path5.join)(path16, file2)));
61537
+ assertTransferSize(files.reduce((total, file2) => total + (0, import_node_fs4.statSync)((0, import_node_path5.join)(path16, file2)).size, 0), localPath);
61538
+ const child = (0, import_node_child_process2.spawn)("tar", ["-czf", "-", "-C", path16, "--null", "-T", "-"], { stdio: ["pipe", "pipe", "pipe"] });
61468
61539
  child.stdin.end(files.map((file2) => `${file2}\0`).join(""));
61469
61540
  return child;
61470
61541
  }
@@ -61479,17 +61550,17 @@ async function push(sandboxId, localPath, remotePath) {
61479
61550
  });
61480
61551
  const exited = new Promise((done) => tar.on("close", done));
61481
61552
  const pathQuery = `?path=${encodeURIComponent(remotePath)}`;
61482
- const archivePath = (0, import_node_path3.join)((0, import_node_os2.tmpdir)(), `replicas-push-${(0, import_node_crypto2.randomUUID)()}.tgz`);
61553
+ const archivePath = (0, import_node_path5.join)((0, import_node_os2.tmpdir)(), `replicas-push-${(0, import_node_crypto3.randomUUID)()}.tgz`);
61483
61554
  try {
61484
- await (0, import_promises.pipeline)(tar.stdout, (0, import_node_fs3.createWriteStream)(archivePath, { mode: 384 }));
61555
+ await (0, import_promises.pipeline)(tar.stdout, (0, import_node_fs4.createWriteStream)(archivePath, { mode: 384 }));
61485
61556
  if (await exited !== 0) throw new Error(`Archiving ${localPath} failed: ${stderr.trim()}`);
61486
61557
  try {
61487
- const size = (0, import_node_fs3.statSync)(archivePath).size;
61558
+ const size = (0, import_node_fs4.statSync)(archivePath).size;
61488
61559
  const { uploadId, uploadUrl } = await agentFetch(`${BASE}/${sandboxId}/uploads`, {
61489
61560
  method: "POST",
61490
61561
  body: { size }
61491
61562
  });
61492
- const chunks = (0, import_node_fs3.createReadStream)(archivePath)[Symbol.asyncIterator]();
61563
+ const chunks = (0, import_node_fs4.createReadStream)(archivePath)[Symbol.asyncIterator]();
61493
61564
  const upload = {
61494
61565
  method: "PUT",
61495
61566
  headers: { "content-type": "application/gzip", "content-length": String(size) },
@@ -61507,10 +61578,10 @@ async function push(sandboxId, localPath, remotePath) {
61507
61578
  await agentRequest(`${BASE}/${sandboxId}/uploads/${uploadId}/extract`, { method: "POST", body: { path: remotePath } });
61508
61579
  } catch (error62) {
61509
61580
  if (!mustStream(error62)) throw error62;
61510
- await agentRequest(`${BASE}/${sandboxId}/files${pathQuery}`, { method: "PUT", body: import_node_stream.Readable.toWeb((0, import_node_fs3.createReadStream)(archivePath)) });
61581
+ await agentRequest(`${BASE}/${sandboxId}/files${pathQuery}`, { method: "PUT", body: import_node_stream.Readable.toWeb((0, import_node_fs4.createReadStream)(archivePath)) });
61511
61582
  }
61512
61583
  } finally {
61513
- (0, import_node_fs3.rmSync)(archivePath, { force: true });
61584
+ (0, import_node_fs4.rmSync)(archivePath, { force: true });
61514
61585
  }
61515
61586
  }
61516
61587
  function computePushCommand(kind) {
@@ -61530,7 +61601,7 @@ async function pull(sandboxId, remotePath, localPath) {
61530
61601
  response = await agentRequest(`${BASE}/${sandboxId}/files?path=${encodeURIComponent(remotePath)}`);
61531
61602
  }
61532
61603
  if (!response.ok || !response.body) throw new Error(`Downloading ${remotePath} failed (${response.status})`);
61533
- (0, import_node_fs3.mkdirSync)(localPath, { recursive: true });
61604
+ (0, import_node_fs4.mkdirSync)(localPath, { recursive: true });
61534
61605
  const tar = (0, import_node_child_process2.spawn)("tar", ["-xzf", "-", "-C", localPath], { stdio: ["pipe", "ignore", "pipe"] });
61535
61606
  let stderr = "";
61536
61607
  tar.stderr.on("data", (chunk) => {
@@ -61571,16 +61642,16 @@ function computeRunCommand(kind) {
61571
61642
  }
61572
61643
  };
61573
61644
  }
61574
- var import_chalk31, import_node_child_process2, import_node_crypto2, import_node_fs3, import_node_os2, import_node_path3, import_node_stream, import_promises, BASE, CREATE_POLL_INTERVAL_MS, CREATE_WAIT_TIMEOUT_MS;
61645
+ var import_chalk31, import_node_child_process2, import_node_crypto3, import_node_fs4, import_node_os2, import_node_path5, import_node_stream, import_promises, BASE, CREATE_POLL_INTERVAL_MS, CREATE_WAIT_TIMEOUT_MS;
61575
61646
  var init_compute2 = __esm({
61576
61647
  "src/commands/compute.ts"() {
61577
61648
  "use strict";
61578
61649
  import_chalk31 = __toESM(require("chalk"));
61579
61650
  import_node_child_process2 = require("child_process");
61580
- import_node_crypto2 = require("crypto");
61581
- import_node_fs3 = require("fs");
61651
+ import_node_crypto3 = require("crypto");
61652
+ import_node_fs4 = require("fs");
61582
61653
  import_node_os2 = require("os");
61583
- import_node_path3 = require("path");
61654
+ import_node_path5 = require("path");
61584
61655
  import_node_stream = require("stream");
61585
61656
  import_promises = require("stream/promises");
61586
61657
  init_src();
@@ -61643,9 +61714,9 @@ async function readConfigFile(filename) {
61643
61714
  async function sourceInput2(options) {
61644
61715
  if (options.file && options.repository) throw new Error("Choose either --file or --repository");
61645
61716
  if (options.file) {
61646
- const filename = (0, import_node_path4.resolve)(options.file);
61717
+ const filename = (0, import_node_path6.resolve)(options.file);
61647
61718
  const entrypoint = await readConfigFile(filename);
61648
- const result = await resolveReplicasEnvironmentConfig(entrypoint, async (pointer) => createSuccessResult(await readConfigFile((0, import_node_path4.resolve)((0, import_node_path4.dirname)(filename), pointer))));
61719
+ const result = await resolveReplicasEnvironmentConfig(entrypoint, async (pointer) => createSuccessResult(await readConfigFile((0, import_node_path6.resolve)((0, import_node_path6.dirname)(filename), pointer))));
61649
61720
  if (!result.ok) throw new Error(result.error.message);
61650
61721
  return { file: { filename: result.data.filename, environment: result.data.config.environment } };
61651
61722
  }
@@ -61715,13 +61786,13 @@ async function environmentConfigAutoApplyCommand(environment2, mode) {
61715
61786
  body: { auto_apply: mode === "on" }
61716
61787
  }), printSource);
61717
61788
  }
61718
- var import_chalk32, import_promises2, import_node_path4;
61789
+ var import_chalk32, import_promises2, import_node_path6;
61719
61790
  var init_environment_config2 = __esm({
61720
61791
  "src/commands/environment-config.ts"() {
61721
61792
  "use strict";
61722
61793
  import_chalk32 = __toESM(require("chalk"));
61723
61794
  import_promises2 = require("fs/promises");
61724
- import_node_path4 = require("path");
61795
+ import_node_path6 = require("path");
61725
61796
  init_src();
61726
61797
  init_api2();
61727
61798
  init_command_utils();
@@ -61738,18 +61809,18 @@ async function historyTranscriptCommand(name) {
61738
61809
  throw new Error(`Invalid session name '${name}'. Use the name from INDEX.md, e.g. 2026-01-31-<id>`);
61739
61810
  }
61740
61811
  const response = await agentRequest(`/v1/engine/history/transcripts/${session}`);
61741
- const dir = (0, import_node_path5.join)(HISTORY_ROOT, "transcripts");
61742
- (0, import_node_fs4.mkdirSync)(dir, { recursive: true });
61743
- const file2 = (0, import_node_path5.join)(dir, `${session}.jsonl`);
61744
- (0, import_node_fs4.writeFileSync)(file2, Buffer.from(await response.arrayBuffer()));
61812
+ const dir = (0, import_node_path7.join)(HISTORY_ROOT, "transcripts");
61813
+ (0, import_node_fs5.mkdirSync)(dir, { recursive: true });
61814
+ const file2 = (0, import_node_path7.join)(dir, `${session}.jsonl`);
61815
+ (0, import_node_fs5.writeFileSync)(file2, Buffer.from(await response.arrayBuffer()));
61745
61816
  output2({ path: file2 }, () => console.log(file2));
61746
61817
  }
61747
- var import_node_fs4, import_node_path5;
61818
+ var import_node_fs5, import_node_path7;
61748
61819
  var init_history = __esm({
61749
61820
  "src/commands/history.ts"() {
61750
61821
  "use strict";
61751
- import_node_fs4 = require("fs");
61752
- import_node_path5 = require("path");
61822
+ import_node_fs5 = require("fs");
61823
+ import_node_path7 = require("path");
61753
61824
  init_src();
61754
61825
  init_agent_api();
61755
61826
  init_output();
@@ -61763,7 +61834,7 @@ async function skillsSuggestCommand(file2, options) {
61763
61834
  throw new Error(`Invalid --scope '${options.scope}'. Use one of: ${LEARNED_SKILL_SCOPES.join(", ")}`);
61764
61835
  }
61765
61836
  const target = scope ? { scope } : {};
61766
- const body2 = options.delete ? { remove: options.delete, ...target } : file2 && options.title ? { content: (0, import_node_fs5.readFileSync)(file2, "utf-8"), title: options.title, ...target } : null;
61837
+ const body2 = options.delete ? { remove: options.delete, ...target } : file2 && options.title ? { content: (0, import_node_fs6.readFileSync)(file2, "utf-8"), title: options.title, ...target } : null;
61767
61838
  if (!body2) throw new Error("Pass a SKILL.md file with --title, or --delete <name-or-id>");
61768
61839
  const { id, name, update, scope: resolvedScope, managerWorkspaceId } = await agentFetch("/v1/learned-skills/suggestions", {
61769
61840
  method: "POST",
@@ -61784,7 +61855,7 @@ async function skillsListCommand() {
61784
61855
  });
61785
61856
  }
61786
61857
  async function skillsCreateCommand(file2, options) {
61787
- const body2 = { content: (0, import_node_fs5.readFileSync)(file2, "utf-8"), title: options.title };
61858
+ const body2 = { content: (0, import_node_fs6.readFileSync)(file2, "utf-8"), title: options.title };
61788
61859
  output2(await orgAuthenticatedFetch("/v1/learned-skills", { method: "POST", body: body2 }), ({ id, name }) => console.log(import_chalk33.default.green(`Saved learning '${name}' (${id})`)));
61789
61860
  }
61790
61861
  async function skillsUpdateCommand(id, options) {
@@ -61793,7 +61864,7 @@ async function skillsUpdateCommand(id, options) {
61793
61864
  if (!existing) throw new Error(`Learning not found: ${id}`);
61794
61865
  const body2 = {
61795
61866
  title: options.title ?? existing.title,
61796
- content: options.file ? (0, import_node_fs5.readFileSync)(options.file, "utf-8") : existing.content
61867
+ content: options.file ? (0, import_node_fs6.readFileSync)(options.file, "utf-8") : existing.content
61797
61868
  };
61798
61869
  output2(await orgAuthenticatedFetch(`/v1/learned-skills/${existing.id}`, { method: "PUT", body: body2 }), ({ name }) => console.log(import_chalk33.default.green(`Updated learning '${name}'`)));
61799
61870
  }
@@ -61801,11 +61872,11 @@ async function skillsDeleteCommand(id) {
61801
61872
  await orgAuthenticatedFetch(`/v1/learned-skills/${id}`, { method: "DELETE" });
61802
61873
  outputSuccess(`Deleted learning ${id}`);
61803
61874
  }
61804
- var import_node_fs5, import_chalk33;
61875
+ var import_node_fs6, import_chalk33;
61805
61876
  var init_skills = __esm({
61806
61877
  "src/commands/skills.ts"() {
61807
61878
  "use strict";
61808
- import_node_fs5 = require("fs");
61879
+ import_node_fs6 = require("fs");
61809
61880
  import_chalk33 = __toESM(require("chalk"));
61810
61881
  init_src();
61811
61882
  init_agent_api();
@@ -61910,7 +61981,7 @@ function tailLines(content, lines) {
61910
61981
  return all.slice(-lines).join("\n").trim();
61911
61982
  }
61912
61983
  function statePath(name) {
61913
- return (0, import_node_path6.join)(SERVICES_DIR, `${name}.json`);
61984
+ return (0, import_node_path8.join)(SERVICES_DIR, `${name}.json`);
61914
61985
  }
61915
61986
  function isServiceState(value) {
61916
61987
  if (typeof value !== "object" || value === null) return false;
@@ -61920,7 +61991,7 @@ function isServiceState(value) {
61920
61991
  function readState(name) {
61921
61992
  let parsed;
61922
61993
  try {
61923
- parsed = JSON.parse((0, import_node_fs6.readFileSync)(statePath(name), "utf-8"));
61994
+ parsed = JSON.parse((0, import_node_fs7.readFileSync)(statePath(name), "utf-8"));
61924
61995
  } catch {
61925
61996
  return null;
61926
61997
  }
@@ -61940,15 +62011,15 @@ function sleep(ms) {
61940
62011
  function tailLog(logFile, lines) {
61941
62012
  let fd;
61942
62013
  try {
61943
- fd = (0, import_node_fs6.openSync)(logFile, "r");
61944
- const { size } = (0, import_node_fs6.fstatSync)(fd);
62014
+ fd = (0, import_node_fs7.openSync)(logFile, "r");
62015
+ const { size } = (0, import_node_fs7.fstatSync)(fd);
61945
62016
  const buffer = Buffer.alloc(Math.min(size, LOG_KEEP_BYTES));
61946
- const read = (0, import_node_fs6.readSync)(fd, buffer, 0, buffer.length, size - buffer.length);
62017
+ const read = (0, import_node_fs7.readSync)(fd, buffer, 0, buffer.length, size - buffer.length);
61947
62018
  return tailLines(buffer.toString("utf-8", 0, read), lines);
61948
62019
  } catch {
61949
62020
  return "";
61950
62021
  } finally {
61951
- if (fd !== void 0) (0, import_node_fs6.closeSync)(fd);
62022
+ if (fd !== void 0) (0, import_node_fs7.closeSync)(fd);
61952
62023
  }
61953
62024
  }
61954
62025
  async function serviceStartCommand(name, commandParts, options) {
@@ -61964,11 +62035,11 @@ async function serviceStartCommand(name, commandParts, options) {
61964
62035
  console.log(`Stopping existing "${name}" (pid ${existing.pid}) before restart`);
61965
62036
  await stopProcessGroups([existing.pid], 5e3);
61966
62037
  }
61967
- (0, import_node_fs6.mkdirSync)(SERVICES_DIR, { recursive: true });
61968
- const cwd = (0, import_node_path6.resolve)(options.cwd ?? process.cwd());
61969
- const logFile = (0, import_node_path6.join)(SERVICES_DIR, `${name}.log`);
61970
- const logFd = (0, import_node_fs6.openSync)(logFile, "a");
61971
- (0, import_node_fs6.writeFileSync)(logFd, `
62038
+ (0, import_node_fs7.mkdirSync)(SERVICES_DIR, { recursive: true });
62039
+ const cwd = (0, import_node_path8.resolve)(options.cwd ?? process.cwd());
62040
+ const logFile = (0, import_node_path8.join)(SERVICES_DIR, `${name}.log`);
62041
+ const logFd = (0, import_node_fs7.openSync)(logFile, "a");
62042
+ (0, import_node_fs7.writeFileSync)(logFd, `
61972
62043
  === [replicas service] "${name}" started ${(/* @__PURE__ */ new Date()).toISOString()} in ${cwd}: ${command} ===
61973
62044
  `);
61974
62045
  const child = (0, import_node_child_process3.spawn)("bash", ["-lc", command], {
@@ -61977,7 +62048,7 @@ async function serviceStartCommand(name, commandParts, options) {
61977
62048
  stdio: ["ignore", logFd, logFd],
61978
62049
  env: process.env
61979
62050
  });
61980
- (0, import_node_fs6.closeSync)(logFd);
62051
+ (0, import_node_fs7.closeSync)(logFd);
61981
62052
  if (child.pid === void 0) {
61982
62053
  throw new Error("Failed to spawn service process");
61983
62054
  }
@@ -61991,11 +62062,11 @@ async function serviceStartCommand(name, commandParts, options) {
61991
62062
  logFile,
61992
62063
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
61993
62064
  };
61994
- (0, import_node_fs6.writeFileSync)(statePath(name), JSON.stringify(state, null, 2));
62065
+ (0, import_node_fs7.writeFileSync)(statePath(name), JSON.stringify(state, null, 2));
61995
62066
  await sleep(1e3);
61996
62067
  if (!isRunning(child.pid)) {
61997
62068
  const logs = tailLog(logFile, 20);
61998
- (0, import_node_fs6.rmSync)(statePath(name), { force: true });
62069
+ (0, import_node_fs7.rmSync)(statePath(name), { force: true });
61999
62070
  throw new Error(`Service "${name}" exited immediately.${logs ? `
62000
62071
 
62001
62072
  Last log output:
@@ -62013,7 +62084,7 @@ async function serviceStopCommand(name) {
62013
62084
  }
62014
62085
  const wasRunning = isRunning(state.pid);
62015
62086
  if (wasRunning) await stopProcessGroups([state.pid], 5e3);
62016
- (0, import_node_fs6.rmSync)(statePath(name), { force: true });
62087
+ (0, import_node_fs7.rmSync)(statePath(name), { force: true });
62017
62088
  output2({ name, pid: state.pid, was_running: wasRunning }, () => {
62018
62089
  console.log(wasRunning ? `Stopped "${name}" (pid ${state.pid})` : `Service "${name}" was not running`);
62019
62090
  });
@@ -62021,7 +62092,7 @@ async function serviceStopCommand(name) {
62021
62092
  async function serviceListCommand() {
62022
62093
  let entries;
62023
62094
  try {
62024
- entries = (0, import_node_fs6.readdirSync)(SERVICES_DIR).filter((f) => f.endsWith(".json"));
62095
+ entries = (0, import_node_fs7.readdirSync)(SERVICES_DIR).filter((f) => f.endsWith(".json"));
62025
62096
  } catch {
62026
62097
  entries = [];
62027
62098
  }
@@ -62052,19 +62123,19 @@ async function serviceLogsCommand(name, options) {
62052
62123
  console.log(logs || "(no log output yet)");
62053
62124
  });
62054
62125
  }
62055
- var import_chalk35, import_node_child_process3, import_node_fs6, import_node_os3, import_node_path6, SERVICES_DIR, NAME_PATTERN, LOG_KEEP_BYTES, LOG_TRIM_LOOP;
62126
+ var import_chalk35, import_node_child_process3, import_node_fs7, import_node_os3, import_node_path8, SERVICES_DIR, NAME_PATTERN, LOG_KEEP_BYTES, LOG_TRIM_LOOP;
62056
62127
  var init_service = __esm({
62057
62128
  "src/commands/service.ts"() {
62058
62129
  "use strict";
62059
62130
  import_chalk35 = __toESM(require("chalk"));
62060
62131
  import_node_child_process3 = require("child_process");
62061
- import_node_fs6 = require("fs");
62132
+ import_node_fs7 = require("fs");
62062
62133
  import_node_os3 = require("os");
62063
- import_node_path6 = require("path");
62134
+ import_node_path8 = require("path");
62064
62135
  init_src();
62065
62136
  init_process_group();
62066
62137
  init_output();
62067
- SERVICES_DIR = (0, import_node_path6.join)((0, import_node_os3.homedir)(), ".replicas", "services");
62138
+ SERVICES_DIR = (0, import_node_path8.join)((0, import_node_os3.homedir)(), ".replicas", "services");
62068
62139
  NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
62069
62140
  LOG_KEEP_BYTES = 5 * 1024 * 1024;
62070
62141
  LOG_TRIM_LOOP = `trim() { ${trimLogTailCommand('"$1"', 10 * 1024 * 1024, LOG_KEEP_BYTES)}; }
@@ -62215,13 +62286,13 @@ async function themePublishCommand(options) {
62215
62286
  };
62216
62287
  let body2 = payload;
62217
62288
  if (options.wallpaper) {
62218
- const resolvedPath = import_node_path7.default.resolve(options.wallpaper);
62219
- if (!import_node_fs7.default.existsSync(resolvedPath)) throw new Error(`Wallpaper file not found: ${resolvedPath}`);
62220
- const { mimeType } = classifyCanvasFilename(import_node_path7.default.basename(resolvedPath));
62289
+ const resolvedPath = import_node_path9.default.resolve(options.wallpaper);
62290
+ if (!import_node_fs8.default.existsSync(resolvedPath)) throw new Error(`Wallpaper file not found: ${resolvedPath}`);
62291
+ const { mimeType } = classifyCanvasFilename(import_node_path9.default.basename(resolvedPath));
62221
62292
  if (!IMAGE_MEDIA_TYPES.some((allowed) => allowed === mimeType)) throw new Error("Wallpaper must be a PNG, JPEG, WebP, or GIF image.");
62222
62293
  const form = new FormData();
62223
62294
  form.set("data", JSON.stringify(payload));
62224
- form.set("image", new File([import_node_fs7.default.readFileSync(resolvedPath)], import_node_path7.default.basename(resolvedPath), { type: mimeType }));
62295
+ form.set("image", new File([import_node_fs8.default.readFileSync(resolvedPath)], import_node_path9.default.basename(resolvedPath), { type: mimeType }));
62225
62296
  body2 = form;
62226
62297
  }
62227
62298
  const published = await agentFetch("/v1/engine/theme/publish", { method: "POST", body: body2 });
@@ -62234,12 +62305,12 @@ async function themePublishCommand(options) {
62234
62305
  if (item.content.wallpaper) console.log(`wallpaper: ${item.content.wallpaper.url} (${item.content.wallpaper.effect})`);
62235
62306
  });
62236
62307
  }
62237
- var import_node_fs7, import_node_path7, print;
62308
+ var import_node_fs8, import_node_path9, print;
62238
62309
  var init_theme = __esm({
62239
62310
  "src/commands/theme.ts"() {
62240
62311
  "use strict";
62241
- import_node_fs7 = __toESM(require("fs"));
62242
- import_node_path7 = __toESM(require("path"));
62312
+ import_node_fs8 = __toESM(require("fs"));
62313
+ import_node_path9 = __toESM(require("path"));
62243
62314
  init_src();
62244
62315
  init_design_tokens();
62245
62316
  init_agent_api();
@@ -62348,7 +62419,7 @@ var init_local_control = __esm({
62348
62419
 
62349
62420
  // ../shared/src/security-checkout.ts
62350
62421
  function checkoutWithCommit(root, commitSha) {
62351
- return (0, import_node_fs8.readdirSync)(root).map((name) => (0, import_node_path8.join)(root, name)).find((dir) => {
62422
+ return (0, import_node_fs9.readdirSync)(root).map((name) => (0, import_node_path10.join)(root, name)).find((dir) => {
62352
62423
  try {
62353
62424
  (0, import_node_child_process5.execFileSync)("git", ["-C", dir, "cat-file", "-e", `${commitSha}^{commit}`], { stdio: "ignore" });
62354
62425
  return true;
@@ -62357,13 +62428,13 @@ function checkoutWithCommit(root, commitSha) {
62357
62428
  }
62358
62429
  }) ?? null;
62359
62430
  }
62360
- var import_node_child_process5, import_node_fs8, import_node_path8;
62431
+ var import_node_child_process5, import_node_fs9, import_node_path10;
62361
62432
  var init_security_checkout = __esm({
62362
62433
  "../shared/src/security-checkout.ts"() {
62363
62434
  "use strict";
62364
62435
  import_node_child_process5 = require("child_process");
62365
- import_node_fs8 = require("fs");
62366
- import_node_path8 = require("path");
62436
+ import_node_fs9 = require("fs");
62437
+ import_node_path10 = require("path");
62367
62438
  }
62368
62439
  });
62369
62440
 
@@ -62387,13 +62458,13 @@ function oneOf(values, value, label) {
62387
62458
  if (!match) throw new Error(`Unknown ${label} "${value}". Use one of: ${values.join(", ")}`);
62388
62459
  return match;
62389
62460
  }
62390
- function maskBody(path14, body2) {
62461
+ function maskBody(path16, body2) {
62391
62462
  let masked = 0;
62392
62463
  const mask = (value) => {
62393
62464
  masked += stringsIn(value).reduce((count, text5) => count + countSecrets(text5), 0);
62394
62465
  return maskSecretsDeep(value);
62395
62466
  };
62396
- const setup = path14 === "/app-setup" ? securityAppSetupSubmissionSchema.safeParse(body2) : null;
62467
+ const setup = path16 === "/app-setup" ? securityAppSetupSubmissionSchema.safeParse(body2) : null;
62397
62468
  if (setup?.success) {
62398
62469
  const { recipe } = setup.data;
62399
62470
  const prepared = recipe && prepareSecurityAppRecipe(recipe);
@@ -62405,23 +62476,23 @@ function maskBody(path14, body2) {
62405
62476
  };
62406
62477
  }
62407
62478
  if (setup) return { body: body2, masked };
62408
- if (path14.endsWith("/proofs") && body2 && typeof body2 === "object" && "content" in body2) {
62479
+ if (path16.endsWith("/proofs") && body2 && typeof body2 === "object" && "content" in body2) {
62409
62480
  const { content, ...meta3 } = body2;
62410
62481
  return { body: { ...mask(meta3), content }, masked };
62411
62482
  }
62412
- if (path14 === "/fix" && body2 && typeof body2 === "object" && "files" in body2) {
62483
+ if (path16 === "/fix" && body2 && typeof body2 === "object" && "files" in body2) {
62413
62484
  const { files, ...meta3 } = body2;
62414
62485
  return { body: { ...mask(meta3), files }, masked };
62415
62486
  }
62416
62487
  return { body: mask(body2), masked };
62417
62488
  }
62418
- function request(path14, init) {
62489
+ function request(path16, init) {
62419
62490
  ensureOrgApiAuthenticated();
62420
- if (!init) return orgAuthenticatedFetch(`/v1/code-security/run${path14}`);
62421
- const { body: body2, masked } = maskBody(path14, init.body);
62491
+ if (!init) return orgAuthenticatedFetch(`/v1/code-security/run${path16}`);
62492
+ const { body: body2, masked } = maskBody(path16, init.body);
62422
62493
  if (masked > 0) process.stderr.write(`masked ${masked} secret-shaped value(s) before sending
62423
62494
  `);
62424
- return orgAuthenticatedFetch(`/v1/code-security/run${path14}`, { ...init, body: body2 });
62495
+ return orgAuthenticatedFetch(`/v1/code-security/run${path16}`, { ...init, body: body2 });
62425
62496
  }
62426
62497
  function printRun({ run: run2 }) {
62427
62498
  const units = Object.values(run2.coverage);
@@ -62792,11 +62863,11 @@ function registerEnvironmentHookCommands(parent, config3) {
62792
62863
  }
62793
62864
  hooks.command("repository-hooks <env>").description(`List per-repo ${config3.kind} hooks defined in replicas.json / replicas.yaml`).action(run(config3.repositoryHooks));
62794
62865
  }
62795
- var import_config22, import_commander, collect, program, organizationOptionalCommands, interactiveCommands, billing, org, config2, chat, chatQueue, share, pr, canvas, credentials, automation, repos, plugins, skills, artifact, media, issue2, environment, envConfig, envVars, envFiles, envSkills, envMcps, parsePortOption, envDevices, envWarmPool, preview, authenticatedPreviewHelp;
62866
+ var import_config23, import_commander, collect, program, organizationOptionalCommands, interactiveCommands, billing, org, config2, chat, chatQueue, share, pr, canvas, credentials, automation, repos, plugins, skills, artifact, media, issue2, environment, envConfig, envVars, envFiles, envSkills, envMcps, parsePortOption, envDevices, envWarmPool, preview, authenticatedPreviewHelp;
62796
62867
  var init_src2 = __esm({
62797
62868
  "src/index.ts"() {
62798
62869
  "use strict";
62799
- import_config22 = require("dotenv/config");
62870
+ import_config23 = require("dotenv/config");
62800
62871
  import_commander = require("commander");
62801
62872
  init_login3();
62802
62873
  init_logout();
@@ -63001,8 +63072,8 @@ var init_src2 = __esm({
63001
63072
  skills.command("update <name-or-id>").description("Update an organization skill").option("--title <text>", "New title").option("-f, --file <file>", "New SKILL.md content").action(run(skillsUpdateCommand));
63002
63073
  skills.command("delete <id>").description("Delete an organization skill").action(run(skillsDeleteCommand));
63003
63074
  artifact = program.command("artifact").description("Keep files a workspace made: deliverables people can find, open and share after the workspace is gone");
63004
- artifact.command("upload <files...>").description("Upload one or more files as artifacts, concurrently. They belong to the person this workspace belongs to").option("-n, --name <name>", "Required name people see. Pass one --name per file, in order.", collect, []).option("--immutable", "A record that never changes, such as a screenshot (default: mutable)").action(run(artifactUploadCommand));
63005
- artifact.command("list").description("List your artifacts and those shared with you (mutable only unless --immutable or --all)").option("--immutable", "Only immutable artifacts").option("--all", "Mutable and immutable artifacts").option("--owner <owner>", "me, others or organization (repeatable)", collect, []).option("-k, --kind <kind>", "Viewer kind such as markdown, html or image (repeatable)", collect, []).option("-w, --workspace [id]", "Everything a workspace made that you can open (this workspace if no id)").option("-l, --limit <n>", "Page size (default 50, max 200)").option("-p, --page <n>", "Page number (default 1)").action(run(artifactListCommand));
63075
+ artifact.command("upload <files...>").description("Upload one or more files as artifacts, concurrently. They belong to the person this workspace belongs to").option("-n, --name <name>", "Required name people see. Pass one --name per file, in order.", collect, []).option("--permanent [true|false]", "Required. false: deleted with this workspace, such as a screenshot, recording or working plan. true: kept after it, for something the person asked to keep or a finished deliverable").action(run(artifactUploadCommand));
63076
+ artifact.command("list").description("List your permanent artifacts and those shared with you (--permanent false or --all for others; --workspace lists both)").option("--permanent <true|false>", "Only permanent (true) or temporary (false) artifacts").option("--all", "Permanent and temporary artifacts").option("--owner <owner>", "me, others or organization (repeatable)", collect, []).option("-k, --kind <kind>", "Viewer kind such as markdown, html or image (repeatable)", collect, []).option("-w, --workspace [id]", "Everything a workspace made that you can open (this workspace if no id)").option("-l, --limit <n>", "Page size (default 50, max 200)").option("-p, --page <n>", "Page number (default 1)").action(run(artifactListCommand));
63006
63077
  artifact.command("url <artifactId>").description("Print a short-lived download URL for an artifact").action(run(artifactUrlCommand));
63007
63078
  artifact.command("rename <artifactId> <name>").description("Rename an artifact (needs edit access)").action(run(artifactRenameCommand));
63008
63079
  artifact.command("share <artifactId>").description("Share an artifact with a member or the whole organization (needs edit access)").option("-u, --user <email>", "Member to share with").option("--organization", "Share with everyone in the organization").option("--permission <permission>", "view or edit (default view)").action(run(artifactShareCommand));
@@ -63147,7 +63218,7 @@ var init_src2 = __esm({
63147
63218
  service.command("list").description("List registered services and whether they are running").action(run(serviceListCommand));
63148
63219
  service.command("logs <name>").description("Print the last lines of a service log").option("-n, --lines <n>", "Number of lines to print (default 50)").action(run(serviceLogsCommand));
63149
63220
  addGifCommand(media, "replicas media upload");
63150
- addGifCommand(artifact, "replicas artifact upload");
63221
+ addGifCommand(artifact, "replicas artifact upload --permanent false");
63151
63222
  media.command("upload <files...>").description("Upload one or more image, video, or audio files. Multiple files are uploaded concurrently. Publish HTML pages with `replicas visualize`.").option("-k, --kind <kind>", "Media kind: image, video, or audio (inferred from extension if omitted)").option("-s, --session-id <id>", "Session ID to associate the asset with").option(
63152
63223
  "-n, --name <name>",
63153
63224
  "Required human-facing display name shown in the dashboard. Pass one --name per file, in order.",