replicas-cli 0.3.685 → 0.3.687

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 +371 -286
  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;
@@ -27991,20 +27990,20 @@ replicas media upload chart-a.svg chart-b.svg --name "Latency chart" --name "Err
27991
27990
  ARTIFACT_UPLOADING = `## Uploading to Replicas
27992
27991
 
27993
27992
  \`\`\`bash
27994
- replicas artifact upload <path-to-file> --name "<display name>" [<path-to-file> --name "<display name>" ...]
27993
+ replicas artifact upload <path-to-file> --name "<display name>" [<path-to-file> --name "<display name>" ...] --permanent false
27995
27994
  \`\`\`
27996
27995
 
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.
27996
+ 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
27997
 
27999
27998
  ### Name each upload
28000
27999
 
28001
28000
  \`--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
28001
 
28003
28002
  \`\`\`bash
28004
- replicas artifact upload /tmp/before.png /tmp/after.png --name "Before fix" --name "After fix" --immutable
28003
+ replicas artifact upload /tmp/before.png /tmp/after.png --name "Before fix" --name "After fix" --permanent false
28005
28004
  \`\`\`
28006
28005
 
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\`).
28006
+ A screenshot or recording is temporary: it is deleted with this workspace (see \`ARTIFACTS.md\`).
28008
28007
 
28009
28008
  For each image, video or audio file, the CLI prints an embed line and a dashboard link:
28010
28009
 
@@ -28023,7 +28022,7 @@ The kind comes from the filename extension. Images (\`png\`, \`jpg\`, \`jpeg\`,
28023
28022
  ## Options
28024
28023
 
28025
28024
  - \`--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\`)
28025
+ - \`--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
28026
  `;
28028
28027
  githubAttachUsage = (textName, replaced) => `\`\`\`bash
28029
28028
  gh pr create --title "Describe the change" --body-file /tmp/pr-body.md --attach './after.png#Settings page after the fix'
@@ -28078,7 +28077,7 @@ ${GITHUB_DONT}
28078
28077
  githubDelivery: `On GitHub, \`gh \u2026 --attach\` uploads screenshots and recording previews and links them.`,
28079
28078
  github: `### GitHub: link images and recordings
28080
28079
 
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:
28080
+ 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
28081
 
28083
28082
  ${githubAttachUsage("Link text", "becomes a link to the image; other images are appended as links")}
28084
28083
 
@@ -28503,8 +28502,8 @@ In agent mode the CLI hides commands that don't make sense for in-workspace agen
28503
28502
  | \`replicas preview ...\` | Register / list preview URLs (covered in \`PREVIEWS.md\`) |
28504
28503
  | \`replicas service ...\` | Run long-lived services detached so they survive workspace sleep/wake (see below) |
28505
28504
  | \`replicas media ...\` | Upload, list, share, revoke, or delete workspace media; follow \`MEDIA.md\` for destination embedding |
28506
- | \`replicas skills suggest <SKILL.md> --title <text>\` | Suggest saving a lasting user instruction as a learning (an organization skill); the user accepts or dismisses it |
28507
- | \`replicas skills suggest --delete <name-or-id>\` | When the user asks you to delete a learning, suggest removing it; the user accepts or dismisses it |
28505
+ | \`replicas skills suggest <SKILL.md> --title <text> [--scope manager|org]\` | Suggest saving a lasting user instruction as a learning (defaults to this Manager inside a Manager or its ships, otherwise organization-wide); the user accepts or dismisses it |
28506
+ | \`replicas skills suggest --delete <name-or-id> [--scope manager|org]\` | When the user asks you to delete a learning, suggest removing it; the user accepts or dismisses it |
28508
28507
  | \`replicas slack thread ...\` | Attach or switch Slack thread routing (covered in \`SLACK.md\`) |
28509
28508
  | \`replicas theme get\` / \`replicas theme set ...\` | Show or change the web and desktop app theme of the person who wrote in this workspace (see *Themes*) |
28510
28509
 
@@ -29442,8 +29441,8 @@ var init_preferences = __esm({
29442
29441
  });
29443
29442
 
29444
29443
  // ../shared/src/environment-files.ts
29445
- function validateEnvironmentFilePath(path14) {
29446
- const trimmedPath = path14.trim();
29444
+ function validateEnvironmentFilePath(path16) {
29445
+ const trimmedPath = path16.trim();
29447
29446
  if (!trimmedPath) {
29448
29447
  return "Path is required.";
29449
29448
  }
@@ -29876,7 +29875,7 @@ var init_environment_config = __esm({
29876
29875
  }).nullable().optional(),
29877
29876
  repositories: external_exports.array(external_exports.string().trim().min(1)).optional(),
29878
29877
  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({
29878
+ files: external_exports.record(external_exports.string().trim().refine((path16) => !validateEnvironmentFilePath(path16), "must be a file path starting with ~/"), external_exports.strictObject({
29880
29879
  name: external_exports.string().trim().min(1).optional(),
29881
29880
  content: external_exports.string().max(65536)
29882
29881
  })).optional(),
@@ -30739,11 +30738,11 @@ function parseShellScript(script, cwd) {
30739
30738
  parseUntil(scope, 0, false);
30740
30739
  return scope.commands;
30741
30740
  }
30742
- function resolveShellPath(dir, path14) {
30743
- if (path14.includes(SHELL_OPAQUE)) return null;
30744
- if (!path14.startsWith("/") && dir === null) return null;
30741
+ function resolveShellPath(dir, path16) {
30742
+ if (path16.includes(SHELL_OPAQUE)) return null;
30743
+ if (!path16.startsWith("/") && dir === null) return null;
30745
30744
  const parts = [];
30746
- for (const part of (path14.startsWith("/") ? path14 : `${dir}/${path14}`).split("/")) {
30745
+ for (const part of (path16.startsWith("/") ? path16 : `${dir}/${path16}`).split("/")) {
30747
30746
  if (part === "..") parts.pop();
30748
30747
  else if (part && part !== ".") parts.push(part);
30749
30748
  }
@@ -31204,8 +31203,8 @@ function parseSkillName(tool, input2) {
31204
31203
  const skillName = parsedInput.skill ?? parsedInput.name;
31205
31204
  return typeof skillName === "string" && skillName ? skillName : null;
31206
31205
  }
31207
- function skillNameFromFilePath(path14) {
31208
- const parts = path14.split(/[\\/]+/).filter(Boolean);
31206
+ function skillNameFromFilePath(path16) {
31207
+ const parts = path16.split(/[\\/]+/).filter(Boolean);
31209
31208
  if (parts.length < 2 || parts[parts.length - 1].toLowerCase() !== "skill.md") return null;
31210
31209
  const skillName = parts[parts.length - 2];
31211
31210
  return /[*?[\]{}…$]/.test(skillName) || ["skills", ".system"].includes(skillName.toLowerCase()) ? null : skillName;
@@ -31214,19 +31213,19 @@ function skillFilePath(tool, input2) {
31214
31213
  if (!READ_TOOL_NAMES.has(tool.toLowerCase())) return null;
31215
31214
  const parsedInput = typeof input2 === "string" ? safeJsonParse(input2, null) : input2;
31216
31215
  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;
31216
+ const path16 = [parsedInput.path, parsedInput.filePath, parsedInput.file_path].find((value) => typeof value === "string" && value.length > 0);
31217
+ return path16 && skillNameFromFilePath(path16) ? path16 : null;
31219
31218
  }
31220
31219
  function createCallDisplayMessage(message2) {
31221
31220
  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);
31221
+ const path16 = skillFilePath(message2.tool, message2.input);
31222
+ const skillName = message2.server.toLowerCase() === "skills" ? message2.tool : path16 ? skillNameFromFilePath(path16) : parseSkillName(message2.tool, message2.input);
31224
31223
  if (skillName === null) return { ...message2, type: "tool_call" };
31225
31224
  return {
31226
31225
  id: message2.id,
31227
31226
  type: "skill",
31228
31227
  skillName,
31229
- ...path14 ? { path: path14 } : {},
31228
+ ...path16 ? { path: path16 } : {},
31230
31229
  status: message2.status,
31231
31230
  timestamp: message2.timestamp
31232
31231
  };
@@ -31258,11 +31257,11 @@ function userMessageText(message2) {
31258
31257
 
31259
31258
  ${message2.content}` : message2.content;
31260
31259
  }
31261
- function fileContentDiff(path14, content, action) {
31260
+ function fileContentDiff(path16, content, action) {
31262
31261
  const lines = content.replace(/\n$/, "").split("\n");
31263
31262
  return [
31264
- `--- ${action === "add" ? "/dev/null" : `a/${path14}`}`,
31265
- `+++ ${action === "add" ? `b/${path14}` : "/dev/null"}`,
31263
+ `--- ${action === "add" ? "/dev/null" : `a/${path16}`}`,
31264
+ `+++ ${action === "add" ? `b/${path16}` : "/dev/null"}`,
31266
31265
  action === "add" ? `@@ -0,0 +1,${lines.length} @@` : `@@ -1,${lines.length} +0,0 @@`,
31267
31266
  ...lines.map((line) => `${action === "add" ? "+" : "-"}${line}`)
31268
31267
  ].join("\n");
@@ -31277,8 +31276,8 @@ function skillNamesFromCommand(command) {
31277
31276
  if (!SKILL_READ_COMMANDS.has(name) || writesFiles(name, argv) || fileWrites(shellCommand).length > 0) return [];
31278
31277
  const paths = readCommandPaths(name, argv);
31279
31278
  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, "");
31279
+ return (paths.length === 0 && stdinTarget ? [stdinTarget] : paths).flatMap((path16) => {
31280
+ const resolved = path16.startsWith("~") ? path16 : resolveShellPath(shellCommand.dir, path16)?.replace(SCRIPT_ROOT, "");
31282
31281
  const skillName = resolved && skillNameFromFilePath(resolved);
31283
31282
  return skillName ? [skillName] : [];
31284
31283
  });
@@ -31362,7 +31361,7 @@ var init_format2 = __esm({
31362
31361
  PATTERN_FLAGS = /* @__PURE__ */ new Set(["-e", "-f", "--file", "--regexp"]);
31363
31362
  SCRIPT_ROOT = "/";
31364
31363
  commandName = (argv) => argv[0].split("/").pop() ?? argv[0];
31365
- fileWrites = ({ writes }) => writes.filter(({ path: path14 }) => path14 !== "/dev/null");
31364
+ fileWrites = ({ writes }) => writes.filter(({ path: path16 }) => path16 !== "/dev/null");
31366
31365
  SKILL_READ_COMMANDS = /* @__PURE__ */ new Set(["awk", "bat", "cat", "head", "less", "more", "nl", "sed", "tail"]);
31367
31366
  }
31368
31367
  });
@@ -31477,17 +31476,17 @@ var require_visit = __commonJS({
31477
31476
  visit2.BREAK = BREAK;
31478
31477
  visit2.SKIP = SKIP;
31479
31478
  visit2.REMOVE = REMOVE;
31480
- function visit_(key2, node2, visitor, path14) {
31481
- const ctrl = callVisitor(key2, node2, visitor, path14);
31479
+ function visit_(key2, node2, visitor, path16) {
31480
+ const ctrl = callVisitor(key2, node2, visitor, path16);
31482
31481
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
31483
- replaceNode(key2, path14, ctrl);
31484
- return visit_(key2, ctrl, visitor, path14);
31482
+ replaceNode(key2, path16, ctrl);
31483
+ return visit_(key2, ctrl, visitor, path16);
31485
31484
  }
31486
31485
  if (typeof ctrl !== "symbol") {
31487
31486
  if (identity.isCollection(node2)) {
31488
- path14 = Object.freeze(path14.concat(node2));
31487
+ path16 = Object.freeze(path16.concat(node2));
31489
31488
  for (let i = 0; i < node2.items.length; ++i) {
31490
- const ci = visit_(i, node2.items[i], visitor, path14);
31489
+ const ci = visit_(i, node2.items[i], visitor, path16);
31491
31490
  if (typeof ci === "number")
31492
31491
  i = ci - 1;
31493
31492
  else if (ci === BREAK)
@@ -31498,13 +31497,13 @@ var require_visit = __commonJS({
31498
31497
  }
31499
31498
  }
31500
31499
  } else if (identity.isPair(node2)) {
31501
- path14 = Object.freeze(path14.concat(node2));
31502
- const ck = visit_("key", node2.key, visitor, path14);
31500
+ path16 = Object.freeze(path16.concat(node2));
31501
+ const ck = visit_("key", node2.key, visitor, path16);
31503
31502
  if (ck === BREAK)
31504
31503
  return BREAK;
31505
31504
  else if (ck === REMOVE)
31506
31505
  node2.key = null;
31507
- const cv = visit_("value", node2.value, visitor, path14);
31506
+ const cv = visit_("value", node2.value, visitor, path16);
31508
31507
  if (cv === BREAK)
31509
31508
  return BREAK;
31510
31509
  else if (cv === REMOVE)
@@ -31525,17 +31524,17 @@ var require_visit = __commonJS({
31525
31524
  visitAsync.BREAK = BREAK;
31526
31525
  visitAsync.SKIP = SKIP;
31527
31526
  visitAsync.REMOVE = REMOVE;
31528
- async function visitAsync_(key2, node2, visitor, path14) {
31529
- const ctrl = await callVisitor(key2, node2, visitor, path14);
31527
+ async function visitAsync_(key2, node2, visitor, path16) {
31528
+ const ctrl = await callVisitor(key2, node2, visitor, path16);
31530
31529
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
31531
- replaceNode(key2, path14, ctrl);
31532
- return visitAsync_(key2, ctrl, visitor, path14);
31530
+ replaceNode(key2, path16, ctrl);
31531
+ return visitAsync_(key2, ctrl, visitor, path16);
31533
31532
  }
31534
31533
  if (typeof ctrl !== "symbol") {
31535
31534
  if (identity.isCollection(node2)) {
31536
- path14 = Object.freeze(path14.concat(node2));
31535
+ path16 = Object.freeze(path16.concat(node2));
31537
31536
  for (let i = 0; i < node2.items.length; ++i) {
31538
- const ci = await visitAsync_(i, node2.items[i], visitor, path14);
31537
+ const ci = await visitAsync_(i, node2.items[i], visitor, path16);
31539
31538
  if (typeof ci === "number")
31540
31539
  i = ci - 1;
31541
31540
  else if (ci === BREAK)
@@ -31546,13 +31545,13 @@ var require_visit = __commonJS({
31546
31545
  }
31547
31546
  }
31548
31547
  } else if (identity.isPair(node2)) {
31549
- path14 = Object.freeze(path14.concat(node2));
31550
- const ck = await visitAsync_("key", node2.key, visitor, path14);
31548
+ path16 = Object.freeze(path16.concat(node2));
31549
+ const ck = await visitAsync_("key", node2.key, visitor, path16);
31551
31550
  if (ck === BREAK)
31552
31551
  return BREAK;
31553
31552
  else if (ck === REMOVE)
31554
31553
  node2.key = null;
31555
- const cv = await visitAsync_("value", node2.value, visitor, path14);
31554
+ const cv = await visitAsync_("value", node2.value, visitor, path16);
31556
31555
  if (cv === BREAK)
31557
31556
  return BREAK;
31558
31557
  else if (cv === REMOVE)
@@ -31579,23 +31578,23 @@ var require_visit = __commonJS({
31579
31578
  }
31580
31579
  return visitor;
31581
31580
  }
31582
- function callVisitor(key2, node2, visitor, path14) {
31581
+ function callVisitor(key2, node2, visitor, path16) {
31583
31582
  if (typeof visitor === "function")
31584
- return visitor(key2, node2, path14);
31583
+ return visitor(key2, node2, path16);
31585
31584
  if (identity.isMap(node2))
31586
- return visitor.Map?.(key2, node2, path14);
31585
+ return visitor.Map?.(key2, node2, path16);
31587
31586
  if (identity.isSeq(node2))
31588
- return visitor.Seq?.(key2, node2, path14);
31587
+ return visitor.Seq?.(key2, node2, path16);
31589
31588
  if (identity.isPair(node2))
31590
- return visitor.Pair?.(key2, node2, path14);
31589
+ return visitor.Pair?.(key2, node2, path16);
31591
31590
  if (identity.isScalar(node2))
31592
- return visitor.Scalar?.(key2, node2, path14);
31591
+ return visitor.Scalar?.(key2, node2, path16);
31593
31592
  if (identity.isAlias(node2))
31594
- return visitor.Alias?.(key2, node2, path14);
31593
+ return visitor.Alias?.(key2, node2, path16);
31595
31594
  return void 0;
31596
31595
  }
31597
- function replaceNode(key2, path14, node2) {
31598
- const parent = path14[path14.length - 1];
31596
+ function replaceNode(key2, path16, node2) {
31597
+ const parent = path16[path16.length - 1];
31599
31598
  if (identity.isCollection(parent)) {
31600
31599
  parent.items[key2] = node2;
31601
31600
  } else if (identity.isPair(parent)) {
@@ -32205,10 +32204,10 @@ var require_Collection = __commonJS({
32205
32204
  var createNode = require_createNode();
32206
32205
  var identity = require_identity();
32207
32206
  var Node = require_Node();
32208
- function collectionFromPath(schema, path14, value) {
32207
+ function collectionFromPath(schema, path16, value) {
32209
32208
  let v2 = value;
32210
- for (let i = path14.length - 1; i >= 0; --i) {
32211
- const k = path14[i];
32209
+ for (let i = path16.length - 1; i >= 0; --i) {
32210
+ const k = path16[i];
32212
32211
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
32213
32212
  const a = [];
32214
32213
  a[k] = v2;
@@ -32227,7 +32226,7 @@ var require_Collection = __commonJS({
32227
32226
  sourceObjects: /* @__PURE__ */ new Map()
32228
32227
  });
32229
32228
  }
32230
- var isEmptyPath = (path14) => path14 == null || typeof path14 === "object" && !!path14[Symbol.iterator]().next().done;
32229
+ var isEmptyPath = (path16) => path16 == null || typeof path16 === "object" && !!path16[Symbol.iterator]().next().done;
32231
32230
  var Collection = class extends Node.NodeBase {
32232
32231
  constructor(type, schema) {
32233
32232
  super(type);
@@ -32257,11 +32256,11 @@ var require_Collection = __commonJS({
32257
32256
  * be a Pair instance or a `{ key, value }` object, which may not have a key
32258
32257
  * that already exists in the map.
32259
32258
  */
32260
- addIn(path14, value) {
32261
- if (isEmptyPath(path14))
32259
+ addIn(path16, value) {
32260
+ if (isEmptyPath(path16))
32262
32261
  this.add(value);
32263
32262
  else {
32264
- const [key2, ...rest] = path14;
32263
+ const [key2, ...rest] = path16;
32265
32264
  const node2 = this.get(key2, true);
32266
32265
  if (identity.isCollection(node2))
32267
32266
  node2.addIn(rest, value);
@@ -32275,8 +32274,8 @@ var require_Collection = __commonJS({
32275
32274
  * Removes a value from the collection.
32276
32275
  * @returns `true` if the item was found and removed.
32277
32276
  */
32278
- deleteIn(path14) {
32279
- const [key2, ...rest] = path14;
32277
+ deleteIn(path16) {
32278
+ const [key2, ...rest] = path16;
32280
32279
  if (rest.length === 0)
32281
32280
  return this.delete(key2);
32282
32281
  const node2 = this.get(key2, true);
@@ -32290,8 +32289,8 @@ var require_Collection = __commonJS({
32290
32289
  * scalar values from their surrounding node; to disable set `keepScalar` to
32291
32290
  * `true` (collections are always returned intact).
32292
32291
  */
32293
- getIn(path14, keepScalar) {
32294
- const [key2, ...rest] = path14;
32292
+ getIn(path16, keepScalar) {
32293
+ const [key2, ...rest] = path16;
32295
32294
  const node2 = this.get(key2, true);
32296
32295
  if (rest.length === 0)
32297
32296
  return !keepScalar && identity.isScalar(node2) ? node2.value : node2;
@@ -32309,8 +32308,8 @@ var require_Collection = __commonJS({
32309
32308
  /**
32310
32309
  * Checks if the collection includes a value with the key `key`.
32311
32310
  */
32312
- hasIn(path14) {
32313
- const [key2, ...rest] = path14;
32311
+ hasIn(path16) {
32312
+ const [key2, ...rest] = path16;
32314
32313
  if (rest.length === 0)
32315
32314
  return this.has(key2);
32316
32315
  const node2 = this.get(key2, true);
@@ -32320,8 +32319,8 @@ var require_Collection = __commonJS({
32320
32319
  * Sets a value in this collection. For `!!set`, `value` needs to be a
32321
32320
  * boolean to add/remove the item from the set.
32322
32321
  */
32323
- setIn(path14, value) {
32324
- const [key2, ...rest] = path14;
32322
+ setIn(path16, value) {
32323
+ const [key2, ...rest] = path16;
32325
32324
  if (rest.length === 0) {
32326
32325
  this.set(key2, value);
32327
32326
  } else {
@@ -34836,9 +34835,9 @@ var require_Document = __commonJS({
34836
34835
  this.contents.add(value);
34837
34836
  }
34838
34837
  /** Adds a value to the document. */
34839
- addIn(path14, value) {
34838
+ addIn(path16, value) {
34840
34839
  if (assertCollection(this.contents))
34841
- this.contents.addIn(path14, value);
34840
+ this.contents.addIn(path16, value);
34842
34841
  }
34843
34842
  /**
34844
34843
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -34913,14 +34912,14 @@ var require_Document = __commonJS({
34913
34912
  * Removes a value from the document.
34914
34913
  * @returns `true` if the item was found and removed.
34915
34914
  */
34916
- deleteIn(path14) {
34917
- if (Collection.isEmptyPath(path14)) {
34915
+ deleteIn(path16) {
34916
+ if (Collection.isEmptyPath(path16)) {
34918
34917
  if (this.contents == null)
34919
34918
  return false;
34920
34919
  this.contents = null;
34921
34920
  return true;
34922
34921
  }
34923
- return assertCollection(this.contents) ? this.contents.deleteIn(path14) : false;
34922
+ return assertCollection(this.contents) ? this.contents.deleteIn(path16) : false;
34924
34923
  }
34925
34924
  /**
34926
34925
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -34935,10 +34934,10 @@ var require_Document = __commonJS({
34935
34934
  * scalar values from their surrounding node; to disable set `keepScalar` to
34936
34935
  * `true` (collections are always returned intact).
34937
34936
  */
34938
- getIn(path14, keepScalar) {
34939
- if (Collection.isEmptyPath(path14))
34937
+ getIn(path16, keepScalar) {
34938
+ if (Collection.isEmptyPath(path16))
34940
34939
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
34941
- return identity.isCollection(this.contents) ? this.contents.getIn(path14, keepScalar) : void 0;
34940
+ return identity.isCollection(this.contents) ? this.contents.getIn(path16, keepScalar) : void 0;
34942
34941
  }
34943
34942
  /**
34944
34943
  * Checks if the document includes a value with the key `key`.
@@ -34949,10 +34948,10 @@ var require_Document = __commonJS({
34949
34948
  /**
34950
34949
  * Checks if the document includes a value at `path`.
34951
34950
  */
34952
- hasIn(path14) {
34953
- if (Collection.isEmptyPath(path14))
34951
+ hasIn(path16) {
34952
+ if (Collection.isEmptyPath(path16))
34954
34953
  return this.contents !== void 0;
34955
- return identity.isCollection(this.contents) ? this.contents.hasIn(path14) : false;
34954
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path16) : false;
34956
34955
  }
34957
34956
  /**
34958
34957
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -34969,13 +34968,13 @@ var require_Document = __commonJS({
34969
34968
  * Sets a value in this document. For `!!set`, `value` needs to be a
34970
34969
  * boolean to add/remove the item from the set.
34971
34970
  */
34972
- setIn(path14, value) {
34973
- if (Collection.isEmptyPath(path14)) {
34971
+ setIn(path16, value) {
34972
+ if (Collection.isEmptyPath(path16)) {
34974
34973
  this.contents = value;
34975
34974
  } else if (this.contents == null) {
34976
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path14), value);
34975
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path16), value);
34977
34976
  } else if (assertCollection(this.contents)) {
34978
- this.contents.setIn(path14, value);
34977
+ this.contents.setIn(path16, value);
34979
34978
  }
34980
34979
  }
34981
34980
  /**
@@ -36935,9 +36934,9 @@ var require_cst_visit = __commonJS({
36935
36934
  visit2.BREAK = BREAK;
36936
36935
  visit2.SKIP = SKIP;
36937
36936
  visit2.REMOVE = REMOVE;
36938
- visit2.itemAtPath = (cst, path14) => {
36937
+ visit2.itemAtPath = (cst, path16) => {
36939
36938
  let item = cst;
36940
- for (const [field2, index] of path14) {
36939
+ for (const [field2, index] of path16) {
36941
36940
  const tok = item?.[field2];
36942
36941
  if (tok && "items" in tok) {
36943
36942
  item = tok.items[index];
@@ -36946,23 +36945,23 @@ var require_cst_visit = __commonJS({
36946
36945
  }
36947
36946
  return item;
36948
36947
  };
36949
- visit2.parentCollection = (cst, path14) => {
36950
- const parent = visit2.itemAtPath(cst, path14.slice(0, -1));
36951
- const field2 = path14[path14.length - 1][0];
36948
+ visit2.parentCollection = (cst, path16) => {
36949
+ const parent = visit2.itemAtPath(cst, path16.slice(0, -1));
36950
+ const field2 = path16[path16.length - 1][0];
36952
36951
  const coll = parent?.[field2];
36953
36952
  if (coll && "items" in coll)
36954
36953
  return coll;
36955
36954
  throw new Error("Parent collection not found");
36956
36955
  };
36957
- function _visit(path14, item, visitor) {
36958
- let ctrl = visitor(item, path14);
36956
+ function _visit(path16, item, visitor) {
36957
+ let ctrl = visitor(item, path16);
36959
36958
  if (typeof ctrl === "symbol")
36960
36959
  return ctrl;
36961
36960
  for (const field2 of ["key", "value"]) {
36962
36961
  const token = item[field2];
36963
36962
  if (token && "items" in token) {
36964
36963
  for (let i = 0; i < token.items.length; ++i) {
36965
- const ci = _visit(Object.freeze(path14.concat([[field2, i]])), token.items[i], visitor);
36964
+ const ci = _visit(Object.freeze(path16.concat([[field2, i]])), token.items[i], visitor);
36966
36965
  if (typeof ci === "number")
36967
36966
  i = ci - 1;
36968
36967
  else if (ci === BREAK)
@@ -36973,10 +36972,10 @@ var require_cst_visit = __commonJS({
36973
36972
  }
36974
36973
  }
36975
36974
  if (typeof ctrl === "function" && field2 === "key")
36976
- ctrl = ctrl(item, path14);
36975
+ ctrl = ctrl(item, path16);
36977
36976
  }
36978
36977
  }
36979
- return typeof ctrl === "function" ? ctrl(item, path14) : ctrl;
36978
+ return typeof ctrl === "function" ? ctrl(item, path16) : ctrl;
36980
36979
  }
36981
36980
  exports2.visit = visit2;
36982
36981
  }
@@ -38278,14 +38277,14 @@ var require_parser = __commonJS({
38278
38277
  case "scalar":
38279
38278
  case "single-quoted-scalar":
38280
38279
  case "double-quoted-scalar": {
38281
- const fs15 = this.flowScalar(this.type);
38280
+ const fs16 = this.flowScalar(this.type);
38282
38281
  if (atNextItem || it.value) {
38283
- map2.items.push({ start, key: fs15, sep: [] });
38282
+ map2.items.push({ start, key: fs16, sep: [] });
38284
38283
  this.onKeyLine = true;
38285
38284
  } else if (it.sep) {
38286
- this.stack.push(fs15);
38285
+ this.stack.push(fs16);
38287
38286
  } else {
38288
- Object.assign(it, { key: fs15, sep: [] });
38287
+ Object.assign(it, { key: fs16, sep: [] });
38289
38288
  this.onKeyLine = true;
38290
38289
  }
38291
38290
  return;
@@ -38413,13 +38412,13 @@ var require_parser = __commonJS({
38413
38412
  case "scalar":
38414
38413
  case "single-quoted-scalar":
38415
38414
  case "double-quoted-scalar": {
38416
- const fs15 = this.flowScalar(this.type);
38415
+ const fs16 = this.flowScalar(this.type);
38417
38416
  if (!it || it.value)
38418
- fc.items.push({ start: [], key: fs15, sep: [] });
38417
+ fc.items.push({ start: [], key: fs16, sep: [] });
38419
38418
  else if (it.sep)
38420
- this.stack.push(fs15);
38419
+ this.stack.push(fs16);
38421
38420
  else
38422
- Object.assign(it, { key: fs15, sep: [] });
38421
+ Object.assign(it, { key: fs16, sep: [] });
38423
38422
  return;
38424
38423
  }
38425
38424
  case "flow-map-end":
@@ -38737,7 +38736,7 @@ var init_frontmatter = __esm({
38737
38736
  });
38738
38737
 
38739
38738
  // ../shared/src/learned-skills.ts
38740
- var LEARNED_SKILLS_ROOT, LEARNED_SKILLS_MANIFEST_PATH, learnedSkillsManifestSchema, dreamVerdictChecksSchema, DREAM_VERDICT_CHECKS, dreamVerdictSchema;
38739
+ var LEARNED_SKILLS_ROOT, LEARNED_SKILLS_MANIFEST_PATH, LEARNED_SKILL_DIR_PREFIX, MANAGER_LEARNED_SKILL_DIR_PREFIX, LEARNED_SKILL_SCOPES, learnedSkillsManifestSchema, dreamVerdictChecksSchema, DREAM_VERDICT_CHECKS, dreamVerdictSchema;
38741
38740
  var init_learned_skills = __esm({
38742
38741
  "../shared/src/learned-skills.ts"() {
38743
38742
  "use strict";
@@ -38747,8 +38746,16 @@ var init_learned_skills = __esm({
38747
38746
  init_sandbox();
38748
38747
  LEARNED_SKILLS_ROOT = `${SANDBOX_PATHS.REPLICAS_DIR}/learned-skills`;
38749
38748
  LEARNED_SKILLS_MANIFEST_PATH = `${LEARNED_SKILLS_ROOT}/manifest.json`;
38749
+ LEARNED_SKILL_DIR_PREFIX = "replicas-learned__";
38750
+ MANAGER_LEARNED_SKILL_DIR_PREFIX = `${LEARNED_SKILL_DIR_PREFIX}manager__`;
38751
+ LEARNED_SKILL_SCOPES = ["org", "manager"];
38750
38752
  learnedSkillsManifestSchema = external_exports.object({
38751
- skills: external_exports.array(external_exports.object({ name: external_exports.string(), sha256: external_exports.string() }))
38753
+ managerWorkspaceId: external_exports.string().nullable().default(null),
38754
+ skills: external_exports.array(external_exports.object({
38755
+ name: external_exports.string(),
38756
+ sha256: external_exports.string(),
38757
+ scope: external_exports.enum(LEARNED_SKILL_SCOPES).optional()
38758
+ }))
38752
38759
  });
38753
38760
  dreamVerdictChecksSchema = external_exports.object({
38754
38761
  repeatable: external_exports.boolean(),
@@ -38959,7 +38966,7 @@ function stripAttachmentNote(text5) {
38959
38966
  if (annotationsNote) content = content.slice(0, annotationsNote.index).trim();
38960
38967
  return {
38961
38968
  content,
38962
- files: match ? [...match[1].matchAll(/^- (.+)$/gm)].map(([, path14]) => path14) : [],
38969
+ files: match ? [...match[1].matchAll(/^- (.+)$/gm)].map(([, path16]) => path16) : [],
38963
38970
  walkthroughs,
38964
38971
  appshots,
38965
38972
  annotations: annotationsNote ? parseAnnotationsNote(annotationsNote.body) : []
@@ -38998,7 +39005,7 @@ var init_user_message_attachments = __esm({
38998
39005
  WALKTHROUGH_NOTE_REGEX = /(?:^|\n\n)<replicas_walkthrough path="([^"\n]+)" duration_seconds="(\d+)" audio="(true|false)">\n[^<]*\n<\/replicas_walkthrough>$/;
38999
39006
  TRUNCATED_WALKTHROUGH_NOTE_REGEX = /(?:^|\n\n)<replicas_walkthrough path="([^"\n]*)(?:" duration_seconds="(\d*))?(?:" audio="(true)?)?[^<]*(?:<\/?[a-z_]*)?$/;
39000
39007
  VIDEO_SIZES_REGEX = /<replicas_instructions>\nThe attached videos' frame sizes, in pixels:((?:\n- .+: \d+x\d+)+)(?:\nFor display only; ignore\.)?\n<\/replicas_instructions>/;
39001
- 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) }]));
39008
+ 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) }]));
39002
39009
  }
39003
39010
  });
39004
39011
 
@@ -40379,7 +40386,7 @@ function parseOpencodeEvents(events) {
40379
40386
  upsertDisplayMessage(messages, {
40380
40387
  id,
40381
40388
  type: "file_change",
40382
- changes: files.map((path14) => ({ path: path14, kind: "update" })),
40389
+ changes: files.map((path16) => ({ path: path16, kind: "update" })),
40383
40390
  status: "completed",
40384
40391
  timestamp: timestamp2
40385
40392
  });
@@ -43577,7 +43584,7 @@ var CLI_VERSION;
43577
43584
  var init_cli_version = __esm({
43578
43585
  "../shared/src/cli-version.ts"() {
43579
43586
  "use strict";
43580
- CLI_VERSION = "0.3.685";
43587
+ CLI_VERSION = "0.3.687";
43581
43588
  }
43582
43589
  });
43583
43590
 
@@ -44128,7 +44135,7 @@ var init_web_auth = __esm({
44128
44135
  });
44129
44136
 
44130
44137
  // ../shared/src/routes/artifacts.ts
44131
- var ARTIFACT_KINDS, ARTIFACT_MUTABILITIES, ARTIFACT_PERMISSIONS, ARTIFACT_LIST_OWNERS, ARTIFACT_DISPLAY_NAME_MAX_LENGTH, artifactMetadataSchema, listArtifactsQuerySchema, listArtifactWorkspacesQuerySchema, updateArtifactRequestSchema, setArtifactShareRequestSchema;
44138
+ var ARTIFACT_KINDS, ARTIFACT_PERMISSIONS, ARTIFACT_LIST_OWNERS, ARTIFACT_DISPLAY_NAME_MAX_LENGTH, artifactMetadataSchema, listArtifactsQuerySchema, listArtifactWorkspacesQuerySchema, updateArtifactRequestSchema, setArtifactShareRequestSchema;
44132
44139
  var init_artifacts2 = __esm({
44133
44140
  "../shared/src/routes/artifacts.ts"() {
44134
44141
  "use strict";
@@ -44136,7 +44143,6 @@ var init_artifacts2 = __esm({
44136
44143
  init_types4();
44137
44144
  init_visuals();
44138
44145
  ARTIFACT_KINDS = CANVAS_ITEM_KINDS.filter((kind) => kind !== "other");
44139
- ARTIFACT_MUTABILITIES = ["mutable", "immutable"];
44140
44146
  ARTIFACT_PERMISSIONS = ["view", "edit"];
44141
44147
  ARTIFACT_LIST_OWNERS = ["me", "others", "organization"];
44142
44148
  ARTIFACT_DISPLAY_NAME_MAX_LENGTH = 200;
@@ -44144,7 +44150,7 @@ var init_artifacts2 = __esm({
44144
44150
  visual_heights: visualHeightsSchema.optional()
44145
44151
  });
44146
44152
  listArtifactsQuerySchema = external_exports.object({
44147
- mutability: external_exports.enum([...ARTIFACT_MUTABILITIES, "all"]).optional(),
44153
+ permanent: external_exports.enum(["true", "false", "all"]).transform((value) => value === "all" ? null : value === "true").optional(),
44148
44154
  owner: external_exports.array(external_exports.enum(ARTIFACT_LIST_OWNERS)),
44149
44155
  kind: external_exports.array(external_exports.enum(ARTIFACT_KINDS)),
44150
44156
  workspace_id: external_exports.string().uuid().optional(),
@@ -44158,8 +44164,9 @@ var init_artifacts2 = __esm({
44158
44164
  owner: external_exports.array(external_exports.union([external_exports.literal("organization"), external_exports.string().uuid()]))
44159
44165
  });
44160
44166
  updateArtifactRequestSchema = external_exports.object({
44161
- display_name: external_exports.string().trim().min(1).max(ARTIFACT_DISPLAY_NAME_MAX_LENGTH)
44162
- });
44167
+ display_name: external_exports.string().trim().min(1).max(ARTIFACT_DISPLAY_NAME_MAX_LENGTH).optional(),
44168
+ permanent: external_exports.boolean().optional()
44169
+ }).refine((body2) => body2.display_name !== void 0 || body2.permanent !== void 0);
44163
44170
  setArtifactShareRequestSchema = external_exports.object({ permission: external_exports.enum(ARTIFACT_PERMISSIONS) });
44164
44171
  }
44165
44172
  });
@@ -57125,8 +57132,8 @@ var init_claude_auth2 = __esm({
57125
57132
  });
57126
57133
 
57127
57134
  // src/lib/muse-oauth.ts
57128
- async function post(path14, body2) {
57129
- return fetch(`${AUTH_URL}${path14}`, {
57135
+ async function post(path16, body2) {
57136
+ return fetch(`${AUTH_URL}${path16}`, {
57130
57137
  method: "POST",
57131
57138
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
57132
57139
  body: body2
@@ -57400,7 +57407,7 @@ async function credentialsGetCommand(service, options) {
57400
57407
  });
57401
57408
  }
57402
57409
  async function credentialsSetCommand(service, options) {
57403
- const path14 = credentialsPath(service, options, true);
57410
+ const path16 = credentialsPath(service, options, true);
57404
57411
  const { org: org2, models, ...fields } = options;
57405
57412
  const secretField = service === "bedrock" ? "aws_secret_access_key" : "api_key";
57406
57413
  const body2 = {
@@ -57408,7 +57415,7 @@ async function credentialsSetCommand(service, options) {
57408
57415
  ...models ? { models: models.split(",").map((model2) => model2.trim()).filter(Boolean) } : {},
57409
57416
  [secretField]: await readSecret(service, secretField === "api_key" ? "API key" : "AWS secret access key")
57410
57417
  };
57411
- const response = await orgAuthenticatedFetch(path14, { method: "POST", body: body2 });
57418
+ const response = await orgAuthenticatedFetch(path16, { method: "POST", body: body2 });
57412
57419
  output2(response, () => console.log(import_chalk19.default.green(`Saved ${scopeLabel(options)} ${service} credentials.`)));
57413
57420
  }
57414
57421
  async function credentialsRemoveCommand(service, options) {
@@ -59120,8 +59127,8 @@ async function chatQueueListCommand(id, chatId) {
59120
59127
  printQueue(queue);
59121
59128
  });
59122
59129
  }
59123
- async function mutateQueue(path14, method, body2) {
59124
- output2(await orgAuthenticatedFetch(path14, { method, body: body2 }), ({ queue }) => {
59130
+ async function mutateQueue(path16, method, body2) {
59131
+ output2(await orgAuthenticatedFetch(path16, { method, body: body2 }), ({ queue }) => {
59125
59132
  if (queue) printQueue(queue);
59126
59133
  else console.log("Done.");
59127
59134
  });
@@ -59135,7 +59142,7 @@ var init_chat = __esm({
59135
59142
  init_api2();
59136
59143
  init_output();
59137
59144
  init_replica2();
59138
- chatPath2 = (id, chatId, path14 = "") => `/v1/replica/${id}/chats/${chatId}${path14}`;
59145
+ chatPath2 = (id, chatId, path16 = "") => `/v1/replica/${id}/chats/${chatId}${path16}`;
59139
59146
  chatQueueClearCommand = (id, chatId) => mutateQueue(chatPath2(id, chatId, "/queue"), "DELETE");
59140
59147
  chatQueueRemoveCommand = (id, chatId, messageId) => mutateQueue(chatPath2(id, chatId, `/queue/${messageId}`), "DELETE");
59141
59148
  chatQueueEditCommand = (id, chatId, messageId, message2) => mutateQueue(chatPath2(id, chatId, `/queue/${messageId}`), "PATCH", { message: message2 });
@@ -59186,7 +59193,7 @@ var init_plugins3 = __esm({
59186
59193
  init_command_utils();
59187
59194
  init_output();
59188
59195
  init_environment3();
59189
- pluginsPath = async ({ env }, path14) => env ? `/v1/environments/${await resolveEnvironmentId(env)}/plugins${path14}` : `/v1/plugins${path14}`;
59196
+ pluginsPath = async ({ env }, path16) => env ? `/v1/environments/${await resolveEnvironmentId(env)}/plugins${path16}` : `/v1/plugins${path16}`;
59190
59197
  }
59191
59198
  });
59192
59199
 
@@ -60208,10 +60215,10 @@ var init_automation = __esm({
60208
60215
  });
60209
60216
 
60210
60217
  // src/lib/agent-api.ts
60211
- async function agentFetch(path14, options) {
60212
- return (await agentRequest(path14, options)).json();
60218
+ async function agentFetch(path16, options) {
60219
+ return (await agentRequest(path16, options)).json();
60213
60220
  }
60214
- async function agentRequest(path14, options) {
60221
+ async function agentRequest(path16, options) {
60215
60222
  const config3 = readAgentConfig();
60216
60223
  if (!config3) {
60217
60224
  throw new Error("Agent mode config not found");
@@ -60227,7 +60234,7 @@ async function agentRequest(path14, options) {
60227
60234
  ...options?.headers || {}
60228
60235
  };
60229
60236
  const body2 = rawBody === void 0 ? void 0 : rawBody instanceof FormData || rawBody instanceof ReadableStream ? rawBody : JSON.stringify(rawBody);
60230
- const response = await fetch(`${MONOLITH_URL}${path14}`, {
60237
+ const response = await fetch(`${MONOLITH_URL}${path16}`, {
60231
60238
  ...options,
60232
60239
  headers,
60233
60240
  body: body2,
@@ -60239,7 +60246,7 @@ async function agentRequest(path14, options) {
60239
60246
  }
60240
60247
  return response;
60241
60248
  }
60242
- async function engineFetch(path14, options) {
60249
+ async function engineFetch(path16, options) {
60243
60250
  const config3 = readAgentConfig();
60244
60251
  if (!config3) {
60245
60252
  throw new Error("Agent mode config not found");
@@ -60249,7 +60256,7 @@ async function engineFetch(path14, options) {
60249
60256
  "Content-Type": "application/json",
60250
60257
  ...options?.headers || {}
60251
60258
  };
60252
- const response = await fetch(`http://localhost:${ENGINE_PORT2}${path14}`, {
60259
+ const response = await fetch(`http://localhost:${ENGINE_PORT2}${path16}`, {
60253
60260
  ...options,
60254
60261
  headers,
60255
60262
  body: options?.body !== void 0 ? JSON.stringify(options.body) : void 0
@@ -60673,27 +60680,88 @@ var init_media_gif = __esm({
60673
60680
  }
60674
60681
  });
60675
60682
 
60683
+ // src/lib/artifact-files.ts
60684
+ function readArtifactFiles() {
60685
+ try {
60686
+ return artifactFilesSchema.parse(JSON.parse(import_node_fs2.default.readFileSync(ARTIFACT_FILES_PATH, "utf8")));
60687
+ } catch {
60688
+ return { files: {} };
60689
+ }
60690
+ }
60691
+ function writeArtifactFiles(record2) {
60692
+ try {
60693
+ const temporary = `${ARTIFACT_FILES_PATH}.${process.pid}.tmp`;
60694
+ import_node_fs2.default.mkdirSync(import_node_path2.default.dirname(ARTIFACT_FILES_PATH), { recursive: true });
60695
+ import_node_fs2.default.writeFileSync(temporary, JSON.stringify(record2, null, 2));
60696
+ import_node_fs2.default.renameSync(temporary, ARTIFACT_FILES_PATH);
60697
+ } catch {
60698
+ }
60699
+ }
60700
+ function sha2562(body2) {
60701
+ return (0, import_node_crypto2.createHash)("sha256").update(body2).digest("hex");
60702
+ }
60703
+ var import_node_crypto2, import_node_fs2, import_node_path2, artifactFilesSchema, ARTIFACT_FILES_PATH;
60704
+ var init_artifact_files = __esm({
60705
+ "src/lib/artifact-files.ts"() {
60706
+ "use strict";
60707
+ import_node_crypto2 = require("crypto");
60708
+ import_node_fs2 = __toESM(require("fs"));
60709
+ import_node_path2 = __toESM(require("path"));
60710
+ init_zod();
60711
+ init_config();
60712
+ artifactFilesSchema = external_exports.looseObject({
60713
+ files: external_exports.record(external_exports.string(), external_exports.looseObject({ artifactId: external_exports.string(), sha256: external_exports.string() }))
60714
+ });
60715
+ ARTIFACT_FILES_PATH = import_node_path2.default.join(CONFIG_DIR, "artifacts.json");
60716
+ }
60717
+ });
60718
+
60676
60719
  // src/commands/artifact.ts
60677
- async function uploadArtifact(filePath, displayName, options) {
60720
+ async function uploadArtifact(filePath, displayName, permanent, record2) {
60678
60721
  const { fileName, body: body2 } = readUploadFile(filePath);
60722
+ const absolutePath = import_node_path3.default.resolve(filePath);
60723
+ const hash2 = sha2562(body2);
60724
+ const saved = record2.files[absolutePath];
60725
+ if (saved?.sha256 === hash2) {
60726
+ const existing = await agentFetch(`/v1/artifacts/${saved.artifactId}`).catch((error62) => {
60727
+ if (error62 instanceof AgentRequestError && error62.status === 404) return null;
60728
+ throw error62;
60729
+ });
60730
+ if (existing?.artifact.permanent === permanent) return { artifact: existing.artifact, outcome: "unchanged" };
60731
+ if (existing) {
60732
+ const { artifact: artifact3 } = await agentFetch(`/v1/artifacts/${saved.artifactId}`, { method: "PATCH", body: { permanent } });
60733
+ return { artifact: artifact3, outcome: permanent ? "kept" : "unkept" };
60734
+ }
60735
+ }
60679
60736
  const form = new FormData();
60680
60737
  form.append("file", new Blob([body2]), fileName);
60681
60738
  form.append("display_name", displayName);
60682
- form.append("mutability", options.immutable ? "immutable" : "mutable");
60739
+ form.append("permanent", String(permanent));
60683
60740
  const { artifact: artifact2 } = await agentFetch("/v1/artifacts", { method: "POST", body: form });
60684
- return artifact2;
60741
+ record2.files[absolutePath] = { artifactId: artifact2.id, sha256: hash2 };
60742
+ return { artifact: artifact2, outcome: "saved" };
60685
60743
  }
60686
60744
  async function artifactUploadCommand(filePaths, options) {
60687
60745
  if (!isAgentMode()) throw new Error("Run this inside a Replicas workspace. Only workspaces can upload artifacts.");
60746
+ if (options.permanent !== "true" && options.permanent !== "false") {
60747
+ throw new Error([
60748
+ "Pass --permanent false or --permanent true.",
60749
+ "--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.",
60750
+ "--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)."
60751
+ ].join("\n"));
60752
+ }
60753
+ const permanent = options.permanent === "true";
60688
60754
  const names = requireNamePerFile(filePaths, options.name ?? []);
60755
+ const record2 = readArtifactFiles();
60689
60756
  const results = await Promise.allSettled(
60690
- filePaths.map((filePath, i) => uploadArtifact(filePath, names[i], options))
60757
+ filePaths.map((filePath, i) => uploadArtifact(filePath, names[i], permanent, record2))
60691
60758
  );
60759
+ writeArtifactFiles(record2);
60692
60760
  const uploads = [];
60693
60761
  const failures = [];
60694
60762
  results.forEach((result, i) => {
60695
60763
  if (result.status === "fulfilled") {
60696
- uploads.push({ file: filePaths[i], artifact: result.value });
60764
+ uploads.push({ file: filePaths[i], ...result.value });
60697
60765
  } else {
60698
60766
  const reason = result.reason instanceof Error ? result.reason.message : String(result.reason);
60699
60767
  failures.push(`${filePaths[i]}: ${reason}`);
@@ -60701,10 +60769,11 @@ async function artifactUploadCommand(filePaths, options) {
60701
60769
  });
60702
60770
  const workspaceId = readAgentConfig()?.workspace_id;
60703
60771
  output2({ uploads }, () => {
60704
- for (const { artifact: artifact2 } of uploads) {
60772
+ for (const { artifact: artifact2, outcome } of uploads) {
60705
60773
  const size = formatBytes(artifact2.size_bytes);
60706
60774
  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.";
60707
- console.log(`Saved artifact "${artifact2.display_name}" (${artifact2.kind}, ${size}). ${visibility}`);
60775
+ const lifetime = artifact2.permanent ? "Permanent: kept after this workspace is gone." : "Temporary: deleted with this workspace.";
60776
+ console.log(`${OUTCOME_LABELS[outcome]} "${artifact2.display_name}" (${artifact2.kind}, ${size}). ${lifetime} ${visibility}`);
60708
60777
  const mediaKind = MEDIA_KINDS.find((kind) => kind === artifact2.kind);
60709
60778
  if (!mediaKind) {
60710
60779
  console.log(`[${markdownLabel(artifact2.display_name)}](${getArtifactUrl(artifact2.id)})`);
@@ -60719,8 +60788,8 @@ async function artifactUploadCommand(filePaths, options) {
60719
60788
  }
60720
60789
  async function artifactListCommand(options) {
60721
60790
  const query = new URLSearchParams();
60722
- if (options.all) query.set("mutability", "all");
60723
- else if (options.immutable) query.set("mutability", "immutable");
60791
+ if (options.all) query.set("permanent", "all");
60792
+ else if (options.permanent) query.set("permanent", options.permanent);
60724
60793
  for (const owner of options.owner ?? []) query.append("owner", owner);
60725
60794
  for (const kind of options.kind ?? []) query.append("kind", kind);
60726
60795
  if (options.workspace) {
@@ -60736,15 +60805,15 @@ async function artifactListCommand(options) {
60736
60805
  for (const artifact2 of artifacts) {
60737
60806
  const owner = artifact2.owner?.email ?? "organization";
60738
60807
  const size = formatBytes(artifact2.size_bytes);
60739
- const columns = [artifact2.id, artifact2.kind, artifact2.mutability, artifact2.display_name, owner, size, artifact2.updated_at];
60808
+ const columns = [artifact2.id, artifact2.kind, artifact2.permanent ? "permanent" : "temporary", artifact2.display_name, owner, size, artifact2.updated_at];
60740
60809
  console.log(columns.join(" "));
60741
60810
  }
60742
60811
  if (total > artifacts.length) console.log(`Showing ${artifacts.length} of ${total}. Use --page for more.`);
60743
60812
  });
60744
60813
  }
60745
60814
  async function artifactUrlCommand(artifactId) {
60746
- const path14 = `/v1/artifacts/${artifactId}/url?disposition=attachment`;
60747
- const response = await orgAuthenticatedFetch(path14);
60815
+ const path16 = `/v1/artifacts/${artifactId}/url?disposition=attachment`;
60816
+ const response = await orgAuthenticatedFetch(path16);
60748
60817
  output2(response, ({ url: url2 }) => console.log(url2));
60749
60818
  }
60750
60819
  async function artifactRenameCommand(artifactId, name) {
@@ -60774,13 +60843,13 @@ async function artifactShareCommand(artifactId, options) {
60774
60843
  if (!permission) {
60775
60844
  throw new Error(`Invalid permission '${options.permission}'. Must be one of: ${ARTIFACT_PERMISSIONS.join(", ")}`);
60776
60845
  }
60777
- const { path: path14, granteeName } = await resolveGrantPath(artifactId, options);
60778
- const { share: share2 } = await orgAuthenticatedFetch(path14, { method: "PUT", body: { permission } });
60846
+ const { path: path16, granteeName } = await resolveGrantPath(artifactId, options);
60847
+ const { share: share2 } = await orgAuthenticatedFetch(path16, { method: "PUT", body: { permission } });
60779
60848
  output2({ share: share2 }, () => console.log(`Shared artifact ${artifactId} with ${granteeName} (${share2.permission}).`));
60780
60849
  }
60781
60850
  async function artifactUnshareCommand(artifactId, options) {
60782
- const { path: path14, granteeName } = await resolveGrantPath(artifactId, options);
60783
- await orgAuthenticatedFetch(path14, { method: "DELETE" });
60851
+ const { path: path16, granteeName } = await resolveGrantPath(artifactId, options);
60852
+ await orgAuthenticatedFetch(path16, { method: "DELETE" });
60784
60853
  outputSuccess(`Artifact ${artifactId} is no longer shared with ${granteeName}.`);
60785
60854
  }
60786
60855
  async function artifactSharesCommand(artifactId) {
@@ -60791,16 +60860,25 @@ async function artifactSharesCommand(artifactId) {
60791
60860
  for (const share2 of users) console.log(`${share2.user?.email} ${share2.permission}`);
60792
60861
  });
60793
60862
  }
60863
+ var import_node_path3, OUTCOME_LABELS;
60794
60864
  var init_artifact = __esm({
60795
60865
  "src/commands/artifact.ts"() {
60796
60866
  "use strict";
60867
+ import_node_path3 = __toESM(require("path"));
60797
60868
  init_src();
60798
60869
  init_agent_api();
60870
+ init_artifact_files();
60799
60871
  init_api2();
60800
60872
  init_command_utils();
60801
60873
  init_config();
60802
60874
  init_members();
60803
60875
  init_output();
60876
+ OUTCOME_LABELS = {
60877
+ saved: "Saved artifact",
60878
+ unchanged: "Already saved, nothing uploaded:",
60879
+ kept: "Now permanent:",
60880
+ unkept: "Now temporary:"
60881
+ };
60804
60882
  }
60805
60883
  });
60806
60884
 
@@ -60825,12 +60903,12 @@ async function callIssueTool(name, args, schema, printHuman) {
60825
60903
  async function uploadAttachments(files) {
60826
60904
  if (!files?.length) return void 0;
60827
60905
  if (!isAgentMode()) throw new Error("--attach works inside a workspace. Elsewhere, embed an image URL in the markdown.");
60828
- 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()), {})));
60906
+ 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()), {})));
60829
60907
  return uploaded.map(({ media: media2 }) => media2.id);
60830
60908
  }
60831
60909
  function readText2(inline, file2, what) {
60832
60910
  if (inline !== void 0 && file2 !== void 0) throw new Error(`Pass either --${what} or --${what}-file, not both`);
60833
- return file2 === void 0 ? inline : import_node_fs2.default.readFileSync(file2 === "-" ? 0 : file2, "utf8");
60911
+ return file2 === void 0 ? inline : import_node_fs3.default.readFileSync(file2 === "-" ? 0 : file2, "utf8");
60834
60912
  }
60835
60913
  async function issueCreateCommand(title3, options) {
60836
60914
  await callIssueTool(ISSUE_COMMANDS.create, {
@@ -60932,12 +61010,12 @@ async function issueUnlinkPrCommand(issue3, url2) {
60932
61010
  async function issueRelateCommand(issue3, type, related) {
60933
61011
  await callIssueTool(ISSUE_COMMANDS.relate, { issue: issue3, type, related_issue: related }, noData, () => console.log(`${import_chalk30.default.green("\u2713")} ${issue3} ${type.replace("_", " ")} ${related}`));
60934
61012
  }
60935
- var import_node_fs2, import_node_path2, import_chalk30, mutationSchema, noData, csv, issueLine, printMutation;
61013
+ var import_node_fs3, import_node_path4, import_chalk30, mutationSchema, noData, csv, issueLine, printMutation;
60936
61014
  var init_issue = __esm({
60937
61015
  "src/commands/issue.ts"() {
60938
61016
  "use strict";
60939
- import_node_fs2 = __toESM(require("fs"));
60940
- import_node_path2 = __toESM(require("path"));
61017
+ import_node_fs3 = __toESM(require("fs"));
61018
+ import_node_path4 = __toESM(require("path"));
60941
61019
  import_chalk30 = __toESM(require("chalk"));
60942
61020
  init_zod();
60943
61021
  init_src();
@@ -61400,16 +61478,16 @@ function computeExecCommand(kind) {
61400
61478
  return async (command, options) => {
61401
61479
  if (command.length === 0) throw new Error(`Pass a command after --, e.g. replicas ${kind} exec -- ${kind === "gpu" ? "nvidia-smi" : "xcodebuild -version"}`);
61402
61480
  const sandboxId = await resolveSandboxId(kind, options);
61403
- const path14 = `${BASE}/${sandboxId}/exec`;
61481
+ const path16 = `${BASE}/${sandboxId}/exec`;
61404
61482
  if (options.detach) {
61405
- const { jobId } = await agentFetch(path14, execRequest(command.join(" "), options));
61483
+ const { jobId } = await agentFetch(path16, execRequest(command.join(" "), options));
61406
61484
  output2({ jobId, sandboxId }, () => {
61407
61485
  console.log(`Started job ${import_chalk31.default.bold(jobId)} in ${sandboxId}`);
61408
61486
  console.log(import_chalk31.default.gray(`Follow it with: replicas ${kind} logs ${jobId} -f`));
61409
61487
  });
61410
61488
  return;
61411
61489
  }
61412
- const exitCode = await streamOutput(await agentRequest(path14, execRequest(command.join(" "), options)));
61490
+ const exitCode = await streamOutput(await agentRequest(path16, execRequest(command.join(" "), options)));
61413
61491
  process.exitCode = exitCode ?? 1;
61414
61492
  if (isJsonMode()) output2({ sandboxId, exitCode }, () => {
61415
61493
  });
@@ -61442,21 +61520,21 @@ function assertTransferSize(bytes, localPath) {
61442
61520
  }
61443
61521
  }
61444
61522
  function archive(localPath) {
61445
- const path14 = (0, import_node_path3.resolve)(localPath);
61446
- if (!(0, import_node_fs3.existsSync)(path14)) throw new Error(`${path14} does not exist`);
61447
- if (!(0, import_node_fs3.statSync)(path14).isDirectory()) {
61448
- assertTransferSize((0, import_node_fs3.statSync)(path14).size, localPath);
61449
- 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"] });
61523
+ const path16 = (0, import_node_path5.resolve)(localPath);
61524
+ if (!(0, import_node_fs4.existsSync)(path16)) throw new Error(`${path16} does not exist`);
61525
+ if (!(0, import_node_fs4.statSync)(path16).isDirectory()) {
61526
+ assertTransferSize((0, import_node_fs4.statSync)(path16).size, localPath);
61527
+ 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"] });
61450
61528
  }
61451
- const listed = (0, import_node_child_process2.spawnSync)("git", ["-C", path14, "ls-files", "-co", "--exclude-standard", "-z"], { maxBuffer: 256 * 1024 * 1024 });
61529
+ const listed = (0, import_node_child_process2.spawnSync)("git", ["-C", path16, "ls-files", "-co", "--exclude-standard", "-z"], { maxBuffer: 256 * 1024 * 1024 });
61452
61530
  if (listed.status !== 0) {
61453
- const du = (0, import_node_child_process2.spawnSync)("du", ["-sk", "--exclude=.git", "--exclude=node_modules", path14]);
61531
+ const du = (0, import_node_child_process2.spawnSync)("du", ["-sk", "--exclude=.git", "--exclude=node_modules", path16]);
61454
61532
  assertTransferSize(Number(du.stdout.toString().split(" ")[0]) * 1024, localPath);
61455
- return (0, import_node_child_process2.spawn)("tar", ["-czf", "-", "-C", path14, "--exclude=.git", "--exclude=node_modules", "."], { stdio: ["ignore", "pipe", "pipe"] });
61533
+ return (0, import_node_child_process2.spawn)("tar", ["-czf", "-", "-C", path16, "--exclude=.git", "--exclude=node_modules", "."], { stdio: ["ignore", "pipe", "pipe"] });
61456
61534
  }
61457
- const files = listed.stdout.toString().split("\0").filter((file2) => file2 && (0, import_node_fs3.existsSync)((0, import_node_path3.join)(path14, file2)));
61458
- assertTransferSize(files.reduce((total, file2) => total + (0, import_node_fs3.statSync)((0, import_node_path3.join)(path14, file2)).size, 0), localPath);
61459
- const child = (0, import_node_child_process2.spawn)("tar", ["-czf", "-", "-C", path14, "--null", "-T", "-"], { stdio: ["pipe", "pipe", "pipe"] });
61535
+ const files = listed.stdout.toString().split("\0").filter((file2) => file2 && (0, import_node_fs4.existsSync)((0, import_node_path5.join)(path16, file2)));
61536
+ assertTransferSize(files.reduce((total, file2) => total + (0, import_node_fs4.statSync)((0, import_node_path5.join)(path16, file2)).size, 0), localPath);
61537
+ const child = (0, import_node_child_process2.spawn)("tar", ["-czf", "-", "-C", path16, "--null", "-T", "-"], { stdio: ["pipe", "pipe", "pipe"] });
61460
61538
  child.stdin.end(files.map((file2) => `${file2}\0`).join(""));
61461
61539
  return child;
61462
61540
  }
@@ -61471,17 +61549,17 @@ async function push(sandboxId, localPath, remotePath) {
61471
61549
  });
61472
61550
  const exited = new Promise((done) => tar.on("close", done));
61473
61551
  const pathQuery = `?path=${encodeURIComponent(remotePath)}`;
61474
- const archivePath = (0, import_node_path3.join)((0, import_node_os2.tmpdir)(), `replicas-push-${(0, import_node_crypto2.randomUUID)()}.tgz`);
61552
+ const archivePath = (0, import_node_path5.join)((0, import_node_os2.tmpdir)(), `replicas-push-${(0, import_node_crypto3.randomUUID)()}.tgz`);
61475
61553
  try {
61476
- await (0, import_promises.pipeline)(tar.stdout, (0, import_node_fs3.createWriteStream)(archivePath, { mode: 384 }));
61554
+ await (0, import_promises.pipeline)(tar.stdout, (0, import_node_fs4.createWriteStream)(archivePath, { mode: 384 }));
61477
61555
  if (await exited !== 0) throw new Error(`Archiving ${localPath} failed: ${stderr.trim()}`);
61478
61556
  try {
61479
- const size = (0, import_node_fs3.statSync)(archivePath).size;
61557
+ const size = (0, import_node_fs4.statSync)(archivePath).size;
61480
61558
  const { uploadId, uploadUrl } = await agentFetch(`${BASE}/${sandboxId}/uploads`, {
61481
61559
  method: "POST",
61482
61560
  body: { size }
61483
61561
  });
61484
- const chunks = (0, import_node_fs3.createReadStream)(archivePath)[Symbol.asyncIterator]();
61562
+ const chunks = (0, import_node_fs4.createReadStream)(archivePath)[Symbol.asyncIterator]();
61485
61563
  const upload = {
61486
61564
  method: "PUT",
61487
61565
  headers: { "content-type": "application/gzip", "content-length": String(size) },
@@ -61499,10 +61577,10 @@ async function push(sandboxId, localPath, remotePath) {
61499
61577
  await agentRequest(`${BASE}/${sandboxId}/uploads/${uploadId}/extract`, { method: "POST", body: { path: remotePath } });
61500
61578
  } catch (error62) {
61501
61579
  if (!mustStream(error62)) throw error62;
61502
- await agentRequest(`${BASE}/${sandboxId}/files${pathQuery}`, { method: "PUT", body: import_node_stream.Readable.toWeb((0, import_node_fs3.createReadStream)(archivePath)) });
61580
+ await agentRequest(`${BASE}/${sandboxId}/files${pathQuery}`, { method: "PUT", body: import_node_stream.Readable.toWeb((0, import_node_fs4.createReadStream)(archivePath)) });
61503
61581
  }
61504
61582
  } finally {
61505
- (0, import_node_fs3.rmSync)(archivePath, { force: true });
61583
+ (0, import_node_fs4.rmSync)(archivePath, { force: true });
61506
61584
  }
61507
61585
  }
61508
61586
  function computePushCommand(kind) {
@@ -61522,7 +61600,7 @@ async function pull(sandboxId, remotePath, localPath) {
61522
61600
  response = await agentRequest(`${BASE}/${sandboxId}/files?path=${encodeURIComponent(remotePath)}`);
61523
61601
  }
61524
61602
  if (!response.ok || !response.body) throw new Error(`Downloading ${remotePath} failed (${response.status})`);
61525
- (0, import_node_fs3.mkdirSync)(localPath, { recursive: true });
61603
+ (0, import_node_fs4.mkdirSync)(localPath, { recursive: true });
61526
61604
  const tar = (0, import_node_child_process2.spawn)("tar", ["-xzf", "-", "-C", localPath], { stdio: ["pipe", "ignore", "pipe"] });
61527
61605
  let stderr = "";
61528
61606
  tar.stderr.on("data", (chunk) => {
@@ -61563,16 +61641,16 @@ function computeRunCommand(kind) {
61563
61641
  }
61564
61642
  };
61565
61643
  }
61566
- 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;
61644
+ 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;
61567
61645
  var init_compute2 = __esm({
61568
61646
  "src/commands/compute.ts"() {
61569
61647
  "use strict";
61570
61648
  import_chalk31 = __toESM(require("chalk"));
61571
61649
  import_node_child_process2 = require("child_process");
61572
- import_node_crypto2 = require("crypto");
61573
- import_node_fs3 = require("fs");
61650
+ import_node_crypto3 = require("crypto");
61651
+ import_node_fs4 = require("fs");
61574
61652
  import_node_os2 = require("os");
61575
- import_node_path3 = require("path");
61653
+ import_node_path5 = require("path");
61576
61654
  import_node_stream = require("stream");
61577
61655
  import_promises = require("stream/promises");
61578
61656
  init_src();
@@ -61635,9 +61713,9 @@ async function readConfigFile(filename) {
61635
61713
  async function sourceInput2(options) {
61636
61714
  if (options.file && options.repository) throw new Error("Choose either --file or --repository");
61637
61715
  if (options.file) {
61638
- const filename = (0, import_node_path4.resolve)(options.file);
61716
+ const filename = (0, import_node_path6.resolve)(options.file);
61639
61717
  const entrypoint = await readConfigFile(filename);
61640
- const result = await resolveReplicasEnvironmentConfig(entrypoint, async (pointer) => createSuccessResult(await readConfigFile((0, import_node_path4.resolve)((0, import_node_path4.dirname)(filename), pointer))));
61718
+ const result = await resolveReplicasEnvironmentConfig(entrypoint, async (pointer) => createSuccessResult(await readConfigFile((0, import_node_path6.resolve)((0, import_node_path6.dirname)(filename), pointer))));
61641
61719
  if (!result.ok) throw new Error(result.error.message);
61642
61720
  return { file: { filename: result.data.filename, environment: result.data.config.environment } };
61643
61721
  }
@@ -61707,13 +61785,13 @@ async function environmentConfigAutoApplyCommand(environment2, mode) {
61707
61785
  body: { auto_apply: mode === "on" }
61708
61786
  }), printSource);
61709
61787
  }
61710
- var import_chalk32, import_promises2, import_node_path4;
61788
+ var import_chalk32, import_promises2, import_node_path6;
61711
61789
  var init_environment_config2 = __esm({
61712
61790
  "src/commands/environment-config.ts"() {
61713
61791
  "use strict";
61714
61792
  import_chalk32 = __toESM(require("chalk"));
61715
61793
  import_promises2 = require("fs/promises");
61716
- import_node_path4 = require("path");
61794
+ import_node_path6 = require("path");
61717
61795
  init_src();
61718
61796
  init_api2();
61719
61797
  init_command_utils();
@@ -61730,18 +61808,18 @@ async function historyTranscriptCommand(name) {
61730
61808
  throw new Error(`Invalid session name '${name}'. Use the name from INDEX.md, e.g. 2026-01-31-<id>`);
61731
61809
  }
61732
61810
  const response = await agentRequest(`/v1/engine/history/transcripts/${session}`);
61733
- const dir = (0, import_node_path5.join)(HISTORY_ROOT, "transcripts");
61734
- (0, import_node_fs4.mkdirSync)(dir, { recursive: true });
61735
- const file2 = (0, import_node_path5.join)(dir, `${session}.jsonl`);
61736
- (0, import_node_fs4.writeFileSync)(file2, Buffer.from(await response.arrayBuffer()));
61811
+ const dir = (0, import_node_path7.join)(HISTORY_ROOT, "transcripts");
61812
+ (0, import_node_fs5.mkdirSync)(dir, { recursive: true });
61813
+ const file2 = (0, import_node_path7.join)(dir, `${session}.jsonl`);
61814
+ (0, import_node_fs5.writeFileSync)(file2, Buffer.from(await response.arrayBuffer()));
61737
61815
  output2({ path: file2 }, () => console.log(file2));
61738
61816
  }
61739
- var import_node_fs4, import_node_path5;
61817
+ var import_node_fs5, import_node_path7;
61740
61818
  var init_history = __esm({
61741
61819
  "src/commands/history.ts"() {
61742
61820
  "use strict";
61743
- import_node_fs4 = require("fs");
61744
- import_node_path5 = require("path");
61821
+ import_node_fs5 = require("fs");
61822
+ import_node_path7 = require("path");
61745
61823
  init_src();
61746
61824
  init_agent_api();
61747
61825
  init_output();
@@ -61750,15 +61828,21 @@ var init_history = __esm({
61750
61828
 
61751
61829
  // src/commands/skills.ts
61752
61830
  async function skillsSuggestCommand(file2, options) {
61753
- const body2 = options.delete ? { remove: options.delete } : file2 && options.title ? { content: (0, import_node_fs5.readFileSync)(file2, "utf-8"), title: options.title } : null;
61831
+ const scope = LEARNED_SKILL_SCOPES.find((scope2) => scope2 === options.scope);
61832
+ if (options.scope !== void 0 && scope === void 0) {
61833
+ throw new Error(`Invalid --scope '${options.scope}'. Use one of: ${LEARNED_SKILL_SCOPES.join(", ")}`);
61834
+ }
61835
+ const target = scope ? { scope } : {};
61836
+ 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;
61754
61837
  if (!body2) throw new Error("Pass a SKILL.md file with --title, or --delete <name-or-id>");
61755
- const { id, name, update } = await agentFetch("/v1/learned-skills/suggestions", {
61838
+ const { id, name, update, scope: resolvedScope, managerWorkspaceId } = await agentFetch("/v1/learned-skills/suggestions", {
61756
61839
  method: "POST",
61757
61840
  body: body2
61758
61841
  });
61759
61842
  const link = `[${name}](${MONOLITH_URL}/v1/learned-skills/suggestions/${id})`;
61760
- output2({ id, name, update, link }, () => {
61761
- console.log(options.delete ? `Suggested removing the learning '${name}'. It is removed only if the user accepts it.` : `Suggested ${update ? "an update to the" : "a new"} learning '${name}'. It is saved only if the user accepts it.`);
61843
+ const scopeLabel2 = resolvedScope === "manager" ? "manager learning" : "organization learning";
61844
+ output2({ id, name, update, scope: resolvedScope, managerWorkspaceId, link }, () => {
61845
+ console.log(options.delete ? `Suggested removing the ${scopeLabel2} '${name}'. It is removed only if the user accepts it.` : `Suggested ${update ? "an update to the" : "a new"} ${scopeLabel2} '${name}'. It is saved only if the user accepts it.`);
61762
61846
  console.log("Put this link on its own line in your reply; it renders as a chip where the user can review it:");
61763
61847
  console.log(link);
61764
61848
  });
@@ -61770,7 +61854,7 @@ async function skillsListCommand() {
61770
61854
  });
61771
61855
  }
61772
61856
  async function skillsCreateCommand(file2, options) {
61773
- const body2 = { content: (0, import_node_fs5.readFileSync)(file2, "utf-8"), title: options.title };
61857
+ const body2 = { content: (0, import_node_fs6.readFileSync)(file2, "utf-8"), title: options.title };
61774
61858
  output2(await orgAuthenticatedFetch("/v1/learned-skills", { method: "POST", body: body2 }), ({ id, name }) => console.log(import_chalk33.default.green(`Saved learning '${name}' (${id})`)));
61775
61859
  }
61776
61860
  async function skillsUpdateCommand(id, options) {
@@ -61779,7 +61863,7 @@ async function skillsUpdateCommand(id, options) {
61779
61863
  if (!existing) throw new Error(`Learning not found: ${id}`);
61780
61864
  const body2 = {
61781
61865
  title: options.title ?? existing.title,
61782
- content: options.file ? (0, import_node_fs5.readFileSync)(options.file, "utf-8") : existing.content
61866
+ content: options.file ? (0, import_node_fs6.readFileSync)(options.file, "utf-8") : existing.content
61783
61867
  };
61784
61868
  output2(await orgAuthenticatedFetch(`/v1/learned-skills/${existing.id}`, { method: "PUT", body: body2 }), ({ name }) => console.log(import_chalk33.default.green(`Updated learning '${name}'`)));
61785
61869
  }
@@ -61787,12 +61871,13 @@ async function skillsDeleteCommand(id) {
61787
61871
  await orgAuthenticatedFetch(`/v1/learned-skills/${id}`, { method: "DELETE" });
61788
61872
  outputSuccess(`Deleted learning ${id}`);
61789
61873
  }
61790
- var import_node_fs5, import_chalk33;
61874
+ var import_node_fs6, import_chalk33;
61791
61875
  var init_skills = __esm({
61792
61876
  "src/commands/skills.ts"() {
61793
61877
  "use strict";
61794
- import_node_fs5 = require("fs");
61878
+ import_node_fs6 = require("fs");
61795
61879
  import_chalk33 = __toESM(require("chalk"));
61880
+ init_src();
61796
61881
  init_agent_api();
61797
61882
  init_api2();
61798
61883
  init_monolith_url();
@@ -61895,7 +61980,7 @@ function tailLines(content, lines) {
61895
61980
  return all.slice(-lines).join("\n").trim();
61896
61981
  }
61897
61982
  function statePath(name) {
61898
- return (0, import_node_path6.join)(SERVICES_DIR, `${name}.json`);
61983
+ return (0, import_node_path8.join)(SERVICES_DIR, `${name}.json`);
61899
61984
  }
61900
61985
  function isServiceState(value) {
61901
61986
  if (typeof value !== "object" || value === null) return false;
@@ -61905,7 +61990,7 @@ function isServiceState(value) {
61905
61990
  function readState(name) {
61906
61991
  let parsed;
61907
61992
  try {
61908
- parsed = JSON.parse((0, import_node_fs6.readFileSync)(statePath(name), "utf-8"));
61993
+ parsed = JSON.parse((0, import_node_fs7.readFileSync)(statePath(name), "utf-8"));
61909
61994
  } catch {
61910
61995
  return null;
61911
61996
  }
@@ -61925,15 +62010,15 @@ function sleep(ms) {
61925
62010
  function tailLog(logFile, lines) {
61926
62011
  let fd;
61927
62012
  try {
61928
- fd = (0, import_node_fs6.openSync)(logFile, "r");
61929
- const { size } = (0, import_node_fs6.fstatSync)(fd);
62013
+ fd = (0, import_node_fs7.openSync)(logFile, "r");
62014
+ const { size } = (0, import_node_fs7.fstatSync)(fd);
61930
62015
  const buffer = Buffer.alloc(Math.min(size, LOG_KEEP_BYTES));
61931
- const read = (0, import_node_fs6.readSync)(fd, buffer, 0, buffer.length, size - buffer.length);
62016
+ const read = (0, import_node_fs7.readSync)(fd, buffer, 0, buffer.length, size - buffer.length);
61932
62017
  return tailLines(buffer.toString("utf-8", 0, read), lines);
61933
62018
  } catch {
61934
62019
  return "";
61935
62020
  } finally {
61936
- if (fd !== void 0) (0, import_node_fs6.closeSync)(fd);
62021
+ if (fd !== void 0) (0, import_node_fs7.closeSync)(fd);
61937
62022
  }
61938
62023
  }
61939
62024
  async function serviceStartCommand(name, commandParts, options) {
@@ -61949,11 +62034,11 @@ async function serviceStartCommand(name, commandParts, options) {
61949
62034
  console.log(`Stopping existing "${name}" (pid ${existing.pid}) before restart`);
61950
62035
  await stopProcessGroups([existing.pid], 5e3);
61951
62036
  }
61952
- (0, import_node_fs6.mkdirSync)(SERVICES_DIR, { recursive: true });
61953
- const cwd = (0, import_node_path6.resolve)(options.cwd ?? process.cwd());
61954
- const logFile = (0, import_node_path6.join)(SERVICES_DIR, `${name}.log`);
61955
- const logFd = (0, import_node_fs6.openSync)(logFile, "a");
61956
- (0, import_node_fs6.writeFileSync)(logFd, `
62037
+ (0, import_node_fs7.mkdirSync)(SERVICES_DIR, { recursive: true });
62038
+ const cwd = (0, import_node_path8.resolve)(options.cwd ?? process.cwd());
62039
+ const logFile = (0, import_node_path8.join)(SERVICES_DIR, `${name}.log`);
62040
+ const logFd = (0, import_node_fs7.openSync)(logFile, "a");
62041
+ (0, import_node_fs7.writeFileSync)(logFd, `
61957
62042
  === [replicas service] "${name}" started ${(/* @__PURE__ */ new Date()).toISOString()} in ${cwd}: ${command} ===
61958
62043
  `);
61959
62044
  const child = (0, import_node_child_process3.spawn)("bash", ["-lc", command], {
@@ -61962,7 +62047,7 @@ async function serviceStartCommand(name, commandParts, options) {
61962
62047
  stdio: ["ignore", logFd, logFd],
61963
62048
  env: process.env
61964
62049
  });
61965
- (0, import_node_fs6.closeSync)(logFd);
62050
+ (0, import_node_fs7.closeSync)(logFd);
61966
62051
  if (child.pid === void 0) {
61967
62052
  throw new Error("Failed to spawn service process");
61968
62053
  }
@@ -61976,11 +62061,11 @@ async function serviceStartCommand(name, commandParts, options) {
61976
62061
  logFile,
61977
62062
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
61978
62063
  };
61979
- (0, import_node_fs6.writeFileSync)(statePath(name), JSON.stringify(state, null, 2));
62064
+ (0, import_node_fs7.writeFileSync)(statePath(name), JSON.stringify(state, null, 2));
61980
62065
  await sleep(1e3);
61981
62066
  if (!isRunning(child.pid)) {
61982
62067
  const logs = tailLog(logFile, 20);
61983
- (0, import_node_fs6.rmSync)(statePath(name), { force: true });
62068
+ (0, import_node_fs7.rmSync)(statePath(name), { force: true });
61984
62069
  throw new Error(`Service "${name}" exited immediately.${logs ? `
61985
62070
 
61986
62071
  Last log output:
@@ -61998,7 +62083,7 @@ async function serviceStopCommand(name) {
61998
62083
  }
61999
62084
  const wasRunning = isRunning(state.pid);
62000
62085
  if (wasRunning) await stopProcessGroups([state.pid], 5e3);
62001
- (0, import_node_fs6.rmSync)(statePath(name), { force: true });
62086
+ (0, import_node_fs7.rmSync)(statePath(name), { force: true });
62002
62087
  output2({ name, pid: state.pid, was_running: wasRunning }, () => {
62003
62088
  console.log(wasRunning ? `Stopped "${name}" (pid ${state.pid})` : `Service "${name}" was not running`);
62004
62089
  });
@@ -62006,7 +62091,7 @@ async function serviceStopCommand(name) {
62006
62091
  async function serviceListCommand() {
62007
62092
  let entries;
62008
62093
  try {
62009
- entries = (0, import_node_fs6.readdirSync)(SERVICES_DIR).filter((f) => f.endsWith(".json"));
62094
+ entries = (0, import_node_fs7.readdirSync)(SERVICES_DIR).filter((f) => f.endsWith(".json"));
62010
62095
  } catch {
62011
62096
  entries = [];
62012
62097
  }
@@ -62037,19 +62122,19 @@ async function serviceLogsCommand(name, options) {
62037
62122
  console.log(logs || "(no log output yet)");
62038
62123
  });
62039
62124
  }
62040
- 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;
62125
+ 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;
62041
62126
  var init_service = __esm({
62042
62127
  "src/commands/service.ts"() {
62043
62128
  "use strict";
62044
62129
  import_chalk35 = __toESM(require("chalk"));
62045
62130
  import_node_child_process3 = require("child_process");
62046
- import_node_fs6 = require("fs");
62131
+ import_node_fs7 = require("fs");
62047
62132
  import_node_os3 = require("os");
62048
- import_node_path6 = require("path");
62133
+ import_node_path8 = require("path");
62049
62134
  init_src();
62050
62135
  init_process_group();
62051
62136
  init_output();
62052
- SERVICES_DIR = (0, import_node_path6.join)((0, import_node_os3.homedir)(), ".replicas", "services");
62137
+ SERVICES_DIR = (0, import_node_path8.join)((0, import_node_os3.homedir)(), ".replicas", "services");
62053
62138
  NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
62054
62139
  LOG_KEEP_BYTES = 5 * 1024 * 1024;
62055
62140
  LOG_TRIM_LOOP = `trim() { ${trimLogTailCommand('"$1"', 10 * 1024 * 1024, LOG_KEEP_BYTES)}; }
@@ -62200,13 +62285,13 @@ async function themePublishCommand(options) {
62200
62285
  };
62201
62286
  let body2 = payload;
62202
62287
  if (options.wallpaper) {
62203
- const resolvedPath = import_node_path7.default.resolve(options.wallpaper);
62204
- if (!import_node_fs7.default.existsSync(resolvedPath)) throw new Error(`Wallpaper file not found: ${resolvedPath}`);
62205
- const { mimeType } = classifyCanvasFilename(import_node_path7.default.basename(resolvedPath));
62288
+ const resolvedPath = import_node_path9.default.resolve(options.wallpaper);
62289
+ if (!import_node_fs8.default.existsSync(resolvedPath)) throw new Error(`Wallpaper file not found: ${resolvedPath}`);
62290
+ const { mimeType } = classifyCanvasFilename(import_node_path9.default.basename(resolvedPath));
62206
62291
  if (!IMAGE_MEDIA_TYPES.some((allowed) => allowed === mimeType)) throw new Error("Wallpaper must be a PNG, JPEG, WebP, or GIF image.");
62207
62292
  const form = new FormData();
62208
62293
  form.set("data", JSON.stringify(payload));
62209
- form.set("image", new File([import_node_fs7.default.readFileSync(resolvedPath)], import_node_path7.default.basename(resolvedPath), { type: mimeType }));
62294
+ form.set("image", new File([import_node_fs8.default.readFileSync(resolvedPath)], import_node_path9.default.basename(resolvedPath), { type: mimeType }));
62210
62295
  body2 = form;
62211
62296
  }
62212
62297
  const published = await agentFetch("/v1/engine/theme/publish", { method: "POST", body: body2 });
@@ -62219,12 +62304,12 @@ async function themePublishCommand(options) {
62219
62304
  if (item.content.wallpaper) console.log(`wallpaper: ${item.content.wallpaper.url} (${item.content.wallpaper.effect})`);
62220
62305
  });
62221
62306
  }
62222
- var import_node_fs7, import_node_path7, print;
62307
+ var import_node_fs8, import_node_path9, print;
62223
62308
  var init_theme = __esm({
62224
62309
  "src/commands/theme.ts"() {
62225
62310
  "use strict";
62226
- import_node_fs7 = __toESM(require("fs"));
62227
- import_node_path7 = __toESM(require("path"));
62311
+ import_node_fs8 = __toESM(require("fs"));
62312
+ import_node_path9 = __toESM(require("path"));
62228
62313
  init_src();
62229
62314
  init_design_tokens();
62230
62315
  init_agent_api();
@@ -62333,7 +62418,7 @@ var init_local_control = __esm({
62333
62418
 
62334
62419
  // ../shared/src/security-checkout.ts
62335
62420
  function checkoutWithCommit(root, commitSha) {
62336
- return (0, import_node_fs8.readdirSync)(root).map((name) => (0, import_node_path8.join)(root, name)).find((dir) => {
62421
+ return (0, import_node_fs9.readdirSync)(root).map((name) => (0, import_node_path10.join)(root, name)).find((dir) => {
62337
62422
  try {
62338
62423
  (0, import_node_child_process5.execFileSync)("git", ["-C", dir, "cat-file", "-e", `${commitSha}^{commit}`], { stdio: "ignore" });
62339
62424
  return true;
@@ -62342,13 +62427,13 @@ function checkoutWithCommit(root, commitSha) {
62342
62427
  }
62343
62428
  }) ?? null;
62344
62429
  }
62345
- var import_node_child_process5, import_node_fs8, import_node_path8;
62430
+ var import_node_child_process5, import_node_fs9, import_node_path10;
62346
62431
  var init_security_checkout = __esm({
62347
62432
  "../shared/src/security-checkout.ts"() {
62348
62433
  "use strict";
62349
62434
  import_node_child_process5 = require("child_process");
62350
- import_node_fs8 = require("fs");
62351
- import_node_path8 = require("path");
62435
+ import_node_fs9 = require("fs");
62436
+ import_node_path10 = require("path");
62352
62437
  }
62353
62438
  });
62354
62439
 
@@ -62372,13 +62457,13 @@ function oneOf(values, value, label) {
62372
62457
  if (!match) throw new Error(`Unknown ${label} "${value}". Use one of: ${values.join(", ")}`);
62373
62458
  return match;
62374
62459
  }
62375
- function maskBody(path14, body2) {
62460
+ function maskBody(path16, body2) {
62376
62461
  let masked = 0;
62377
62462
  const mask = (value) => {
62378
62463
  masked += stringsIn(value).reduce((count, text5) => count + countSecrets(text5), 0);
62379
62464
  return maskSecretsDeep(value);
62380
62465
  };
62381
- const setup = path14 === "/app-setup" ? securityAppSetupSubmissionSchema.safeParse(body2) : null;
62466
+ const setup = path16 === "/app-setup" ? securityAppSetupSubmissionSchema.safeParse(body2) : null;
62382
62467
  if (setup?.success) {
62383
62468
  const { recipe } = setup.data;
62384
62469
  const prepared = recipe && prepareSecurityAppRecipe(recipe);
@@ -62390,23 +62475,23 @@ function maskBody(path14, body2) {
62390
62475
  };
62391
62476
  }
62392
62477
  if (setup) return { body: body2, masked };
62393
- if (path14.endsWith("/proofs") && body2 && typeof body2 === "object" && "content" in body2) {
62478
+ if (path16.endsWith("/proofs") && body2 && typeof body2 === "object" && "content" in body2) {
62394
62479
  const { content, ...meta3 } = body2;
62395
62480
  return { body: { ...mask(meta3), content }, masked };
62396
62481
  }
62397
- if (path14 === "/fix" && body2 && typeof body2 === "object" && "files" in body2) {
62482
+ if (path16 === "/fix" && body2 && typeof body2 === "object" && "files" in body2) {
62398
62483
  const { files, ...meta3 } = body2;
62399
62484
  return { body: { ...mask(meta3), files }, masked };
62400
62485
  }
62401
62486
  return { body: mask(body2), masked };
62402
62487
  }
62403
- function request(path14, init) {
62488
+ function request(path16, init) {
62404
62489
  ensureOrgApiAuthenticated();
62405
- if (!init) return orgAuthenticatedFetch(`/v1/code-security/run${path14}`);
62406
- const { body: body2, masked } = maskBody(path14, init.body);
62490
+ if (!init) return orgAuthenticatedFetch(`/v1/code-security/run${path16}`);
62491
+ const { body: body2, masked } = maskBody(path16, init.body);
62407
62492
  if (masked > 0) process.stderr.write(`masked ${masked} secret-shaped value(s) before sending
62408
62493
  `);
62409
- return orgAuthenticatedFetch(`/v1/code-security/run${path14}`, { ...init, body: body2 });
62494
+ return orgAuthenticatedFetch(`/v1/code-security/run${path16}`, { ...init, body: body2 });
62410
62495
  }
62411
62496
  function printRun({ run: run2 }) {
62412
62497
  const units = Object.values(run2.coverage);
@@ -62777,11 +62862,11 @@ function registerEnvironmentHookCommands(parent, config3) {
62777
62862
  }
62778
62863
  hooks.command("repository-hooks <env>").description(`List per-repo ${config3.kind} hooks defined in replicas.json / replicas.yaml`).action(run(config3.repositoryHooks));
62779
62864
  }
62780
- 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;
62865
+ 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;
62781
62866
  var init_src2 = __esm({
62782
62867
  "src/index.ts"() {
62783
62868
  "use strict";
62784
- import_config22 = require("dotenv/config");
62869
+ import_config23 = require("dotenv/config");
62785
62870
  import_commander = require("commander");
62786
62871
  init_login3();
62787
62872
  init_logout();
@@ -62986,8 +63071,8 @@ var init_src2 = __esm({
62986
63071
  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));
62987
63072
  skills.command("delete <id>").description("Delete an organization skill").action(run(skillsDeleteCommand));
62988
63073
  artifact = program.command("artifact").description("Keep files a workspace made: deliverables people can find, open and share after the workspace is gone");
62989
- 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));
62990
- 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));
63074
+ 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));
63075
+ 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));
62991
63076
  artifact.command("url <artifactId>").description("Print a short-lived download URL for an artifact").action(run(artifactUrlCommand));
62992
63077
  artifact.command("rename <artifactId> <name>").description("Rename an artifact (needs edit access)").action(run(artifactRenameCommand));
62993
63078
  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));
@@ -63132,7 +63217,7 @@ var init_src2 = __esm({
63132
63217
  service.command("list").description("List registered services and whether they are running").action(run(serviceListCommand));
63133
63218
  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));
63134
63219
  addGifCommand(media, "replicas media upload");
63135
- addGifCommand(artifact, "replicas artifact upload");
63220
+ addGifCommand(artifact, "replicas artifact upload --permanent false");
63136
63221
  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(
63137
63222
  "-n, --name <name>",
63138
63223
  "Required human-facing display name shown in the dashboard. Pass one --name per file, in order.",
@@ -63170,7 +63255,7 @@ ${VISUAL_PAGE_RULES}`).action(run(visualizeCommand));
63170
63255
  addComputeCommands("macos", (command) => command.option("-t, --timeout <duration>", `Maximum lifetime, e.g. 90m or 2h (default 1h, max ${MACOS_SANDBOX_MAX_TIMEOUT_MINUTES / 60}h)`).option("-e, --env <KEY=value>", 'Environment variable for the command run by "run" (repeatable)', collect, []));
63171
63256
  }
63172
63257
  program.command("history").description("Read past session history").command("transcript <name>").description("Download the full transcript of a session in INDEX.md and print its path").action(run(historyTranscriptCommand));
63173
- skills.command("suggest [file]").description("Suggest saving a SKILL.md as an organization skill, or removing one with --delete; the user reviews it first").option("--title <text>", 'Short title shown to the user, e.g. "Always use Conventional Commits" (required with a file)').option("--delete <name-or-id>", "Suggest removing this organization skill instead").action(run(skillsSuggestCommand));
63258
+ skills.command("suggest [file]").description("Suggest saving a SKILL.md as a learning, or removing one with --delete; the user reviews it first").option("--title <text>", 'Short title shown to the user, e.g. "Always use Conventional Commits" (required with a file)').option("--delete <name-or-id>", "Suggest removing this learning instead").option("--scope <scope>", "Learning scope: manager or org (defaults to manager inside a Manager or its ships, otherwise org)").action(run(skillsSuggestCommand));
63174
63259
  const theme = program.command("theme").description("The web and desktop app theme of the person who wrote in this workspace");
63175
63260
  theme.command("get").description("Show their theme, color theme and accent").action(run(themeGetCommand));
63176
63261
  theme.command("set").description("Change their theme; their open web and desktop apps repaint on their own").option("--theme <theme>", THEME_PREFERENCES.join(", ")).option("--color-theme <name>", `With --theme dark: ${PALETTE_PRESETS.dark.join(", ")}. With --theme light: ${PALETTE_PRESETS.light.join(", ")}`).option("--accent <color>", `${ACCENT_PRESETS.join(", ")}, or any hex color such as ff5500`).option("--code <code>", "Custom colors as a theme code of three hex colors, background,text,accent, such as 0d1117,e6ecf4,ff5500. The text has to read on the background").action(run(themeSetCommand));