@jpcasabiancai/cayenne 0.5.18 → 0.5.20

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/cli.js +72 -28
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -8196,7 +8196,9 @@ function readFrontmatter(text5) {
8196
8196
  if (block === void 0) return { ok: false };
8197
8197
  const raw = {};
8198
8198
  let list3 = null;
8199
- for (const line of block.split(/\r?\n/)) {
8199
+ const lines = block.split(/\r?\n/);
8200
+ for (let i = 0; i < lines.length; i++) {
8201
+ const line = lines[i] ?? "";
8200
8202
  if (line.trim() === "" || line.trimStart().startsWith("#")) continue;
8201
8203
  const item = ITEM2.exec(line);
8202
8204
  if (item?.[1] !== void 0) {
@@ -8217,6 +8219,18 @@ function readFrontmatter(text5) {
8217
8219
  continue;
8218
8220
  }
8219
8221
  list3 = null;
8222
+ const style = /^([>|])[-+]?$/.exec(rest)?.[1];
8223
+ if (style !== void 0) {
8224
+ const body = [];
8225
+ while (i + 1 < lines.length && /^([ \t]|$)/.test(lines[i + 1] ?? "")) {
8226
+ i++;
8227
+ body.push((lines[i] ?? "").trim());
8228
+ }
8229
+ const value2 = (style === "|" ? body.join("\n") : body.map((l) => l === "" ? "\n" : l).join(" ").replace(/ ?\n ?/g, "\n")).trim();
8230
+ if (value2 === "") return { ok: false };
8231
+ raw[key] = value2;
8232
+ continue;
8233
+ }
8220
8234
  if (rest.startsWith("[")) {
8221
8235
  if (!rest.endsWith("]")) return { ok: false };
8222
8236
  const inner = rest.slice(1, -1).trim();
@@ -20153,7 +20167,7 @@ function inSecretDir(path) {
20153
20167
  return SECRET_DIRS.has(p) || p === ".config" && CONFIG_SECRET_DIRS.has(next) || p === ".docker" && next === "config.json";
20154
20168
  });
20155
20169
  }
20156
- function taskSecretDenyRules(protectedPaths2 = []) {
20170
+ function taskSecretDenyRules(protectedPaths2 = [], exemptPaths = []) {
20157
20171
  const names = [
20158
20172
  ".env*",
20159
20173
  ".envrc",
@@ -20170,7 +20184,9 @@ function taskSecretDenyRules(protectedPaths2 = []) {
20170
20184
  const dirs = [...SECRET_DIRS, ...[...CONFIG_SECRET_DIRS].map((d) => `.config/${d}`)].map(
20171
20185
  (dir) => `Read(**/${dir}/**)`
20172
20186
  );
20187
+ const holdsExempt = (p) => withReal(p).some((root) => exemptPaths.some((e) => within3(e, root)));
20173
20188
  const absolute = protectedPaths2.flatMap((p) => {
20189
+ if (holdsExempt(p)) return [];
20174
20190
  const abs = `/${p.replace(/^\/+/, "")}`;
20175
20191
  return [`Read(/${abs})`, `Read(/${abs}/**)`];
20176
20192
  });
@@ -20219,19 +20235,14 @@ function globTargetsSecrets(glob) {
20219
20235
  return PROBES.some((p) => re.test(p)) && !CONTROLS.some((c) => re.test(c));
20220
20236
  });
20221
20237
  }
20222
- function createSecretGuard(cwd, protectedPaths2 = [], mode = "task") {
20238
+ function createSecretGuard(cwd, protectedPaths2 = [], mode = "task", exemptPaths = []) {
20223
20239
  const refusal = mode === "autopilot" ? AUTOPILOT_SECRET_REFUSAL : SECRET_READ_REFUSAL;
20224
20240
  const home = homedir12();
20225
- const protectedReal = protectedPaths2.flatMap((p) => {
20226
- try {
20227
- const real = realpathSync21.native(p);
20228
- return real === p ? [p] : [p, real];
20229
- } catch {
20230
- return [p];
20231
- }
20232
- });
20241
+ const protectedReal = protectedPaths2.flatMap(withReal);
20242
+ const exemptReal = exemptPaths.flatMap(withReal);
20243
+ const inProtected = (path) => protectedReal.some((root) => within3(path, root)) && !exemptReal.some((root) => within3(path, root));
20233
20244
  const expand = (arg) => arg === "~" ? home : arg.startsWith("~/") ? resolve6(home, arg.slice(2)) : arg;
20234
- const pathShaped = (path) => isSecretFileName(basename6(path)) || inSecretDir(path) || protectedReal.some((root) => within3(path, root));
20245
+ const pathShaped = (path) => isSecretFileName(basename6(path)) || inSecretDir(path) || inProtected(path);
20235
20246
  const argTargets = (raw) => {
20236
20247
  if (GLOB_CHARS.test(raw))
20237
20248
  return globTargetsSecrets(raw) || pathShaped(resolve6(cwd, expand(raw.replace(/[*?[{].*$/, ""))));
@@ -20260,7 +20271,7 @@ function createSecretGuard(cwd, protectedPaths2 = [], mode = "task") {
20260
20271
  }
20261
20272
  }
20262
20273
  };
20263
- const writesProtected = (raw) => writesWhere(raw, (path) => protectedReal.some((root) => within3(path, root)));
20274
+ const writesProtected = (raw) => writesWhere(raw, inProtected);
20264
20275
  const cwds = [cwd];
20265
20276
  try {
20266
20277
  const real = realpathSync21.native(cwd);
@@ -20310,7 +20321,7 @@ function createSecretGuard(cwd, protectedPaths2 = [], mode = "task") {
20310
20321
  }
20311
20322
  };
20312
20323
  }
20313
- var SECRET_NAMES, SECRET_EXTENSIONS, SSH_KEY, SECRET_DIRS, CONFIG_SECRET_DIRS, SECRET_LIST, SECRET_READ_REFUSAL, CONFIG_WRITE_REFUSAL, AUTOPILOT_SECRET_REFUSAL, PROBES, CONTROLS, GLOB_CHARS, within3, PATH_KEYS2, WRITE_KEYS, GLOB_KEYS, globWords, shellWords;
20324
+ var SECRET_NAMES, SECRET_EXTENSIONS, SSH_KEY, SECRET_DIRS, CONFIG_SECRET_DIRS, SECRET_LIST, SECRET_READ_REFUSAL, CONFIG_WRITE_REFUSAL, AUTOPILOT_SECRET_REFUSAL, PROBES, CONTROLS, GLOB_CHARS, withReal, within3, PATH_KEYS2, WRITE_KEYS, GLOB_KEYS, globWords, shellWords;
20314
20325
  var init_secret_files = __esm({
20315
20326
  "src/sessions/secret-files.ts"() {
20316
20327
  "use strict";
@@ -20348,6 +20359,14 @@ var init_secret_files = __esm({
20348
20359
  ];
20349
20360
  CONTROLS = ["x.txt", "x.ts", "x.md", "readme", ".gitignore"];
20350
20361
  GLOB_CHARS = /[*?[{]/;
20362
+ withReal = (p) => {
20363
+ try {
20364
+ const real = realpathSync21.native(p);
20365
+ return real === p ? [p] : [p, real];
20366
+ } catch {
20367
+ return [p];
20368
+ }
20369
+ };
20351
20370
  within3 = (path, root) => {
20352
20371
  const rel = relative17(root, path);
20353
20372
  return rel === "" || rel !== ".." && !rel.startsWith(`..${sep18}`) && !isAbsolute24(rel);
@@ -20864,6 +20883,7 @@ var init_manager = __esm({
20864
20883
  }
20865
20884
  const { cwd, root, roots, record, repo } = place;
20866
20885
  const guard = place.guard === "repository" && this.isTaskSession(sessionId) ? "repository+task" : place.guard;
20886
+ if (guard === "repository+task") this.assertTaskSessionMode(sessionId, p.permissionMode);
20867
20887
  try {
20868
20888
  this.assertNotRemoving(cwd);
20869
20889
  } catch (err) {
@@ -22299,29 +22319,44 @@ var init_manager = __esm({
22299
22319
  readInsideDirs: toolResults
22300
22320
  })
22301
22321
  };
22302
- return guard === "repository" ? repository : this.withTaskGuard(repository, cwd);
22322
+ return guard === "repository" ? repository : this.withTaskGuard(repository, cwd, permissionMode, sessionId);
22303
22323
  }
22304
22324
  const gitGuard = this.reachesManagedRoot(roots) ? createManagedGitGuard(this.deps.managedRoot, cwd) : null;
22305
22325
  const policy = this.settingsPolicy(createdBy, cwd, permissionMode, this.deps.trustedRoots);
22306
22326
  this.warnBypassWithoutUserGuards(createdBy, permissionMode, policy, sessionId);
22307
22327
  const guarded = gitGuard ? { ...policy, toolGuard: gitGuard } : policy;
22308
- return guard === "task" ? this.withTaskGuard(guarded, cwd) : guarded;
22328
+ return guard === "task" ? this.withTaskGuard(guarded, cwd, permissionMode, sessionId) : guarded;
22329
+ }
22330
+ /**
22331
+ * A repository chat's own checkout, which lies inside the runner's home and is not a protected
22332
+ * path. Its own worktree only: sibling worktrees and other clones stay protected.
22333
+ */
22334
+ managedExempt(cwd) {
22335
+ return isAtOrBelow3(cwd, this.deps.managedRoot) ? [cwd] : [];
22309
22336
  }
22310
22337
  /** Protocol §2.8's task guard added to `policy`: asked before the guard it already has. */
22311
- withTaskGuard(policy, cwd) {
22338
+ withTaskGuard(policy, cwd, permissionMode, sessionId) {
22312
22339
  const permissions = policy.settings?.permissions;
22313
- const secretGuard = createSecretGuard(cwd, this.deps.protectedPaths);
22340
+ const exempt = this.managedExempt(cwd);
22341
+ const secretGuard = createSecretGuard(cwd, this.deps.protectedPaths, "task", exempt);
22314
22342
  return {
22315
22343
  ...policy,
22316
22344
  settings: {
22317
22345
  ...policy.settings,
22318
22346
  permissions: {
22319
22347
  ...permissions,
22320
- deny: [...permissions?.deny ?? [], ...taskSecretDenyRules(this.deps.protectedPaths)]
22348
+ deny: [
22349
+ ...permissions?.deny ?? [],
22350
+ ...taskSecretDenyRules(this.deps.protectedPaths, exempt)
22351
+ ]
22321
22352
  }
22322
22353
  },
22323
22354
  toolGuard: policy.toolGuard ? firstRefusal(secretGuard, policy.toolGuard) : secretGuard,
22324
- askTools: TASK_ASK_TOOLS
22355
+ // A flow session this runner accepted in `auto` runs with nobody at the card, and the CLI
22356
+ // does raise a hook's `ask` in `auto` (probed live 2026-11-12): the step would wait out its
22357
+ // timeout. D79's amendment accepted the risk; the guard above still refuses. Asked again
22358
+ // here, so a start that missed its mode check still gets the card.
22359
+ ...permissionMode === "auto" && sessionId !== void 0 && this.acceptedFlowAuto(sessionId) ? {} : { askTools: TASK_ASK_TOOLS }
22325
22360
  };
22326
22361
  }
22327
22362
  /**
@@ -22381,15 +22416,19 @@ var init_manager = __esm({
22381
22416
  * a record that cannot be read refuses.
22382
22417
  */
22383
22418
  assertTaskSessionMode(sessionId, mode) {
22384
- if (mode === "auto" && this.deps.allowFlowAuto === true) {
22385
- try {
22386
- if (this.flowAutoSessions().has(sessionId)) return;
22387
- } catch (err) {
22388
- this.deps.log.warn({ err, sessionId }, "flow auto record unreadable; refusing auto");
22389
- }
22390
- }
22419
+ if (mode === "auto" && this.acceptedFlowAuto(sessionId)) return;
22391
22420
  assertTaskMode(mode);
22392
22421
  }
22422
+ /** A flow session recorded as started in `auto`, while `allowFlowAuto` stands; unreadable is no. */
22423
+ acceptedFlowAuto(sessionId) {
22424
+ if (this.deps.allowFlowAuto !== true) return false;
22425
+ try {
22426
+ return this.flowAutoSessions().has(sessionId);
22427
+ } catch (err) {
22428
+ this.deps.log.warn({ err, sessionId }, "flow auto record unreadable; refusing auto");
22429
+ return false;
22430
+ }
22431
+ }
22393
22432
  markTaskSession(sessionId) {
22394
22433
  try {
22395
22434
  this.taskSessions().mark(sessionId);
@@ -22652,7 +22691,12 @@ var init_manager = __esm({
22652
22691
  * so a database blip does not bind a chat that never ran Auto Pilot.
22653
22692
  */
22654
22693
  autopilotSecretGuard(sessionId, cwd, prior) {
22655
- const secret = createSecretGuard(cwd, this.deps.protectedPaths, "autopilot");
22694
+ const secret = createSecretGuard(
22695
+ cwd,
22696
+ this.deps.protectedPaths,
22697
+ "autopilot",
22698
+ this.managedExempt(cwd)
22699
+ );
22656
22700
  this.autopilotAskedAt.delete(sessionId);
22657
22701
  const armed = async () => {
22658
22702
  if (this.autopilotSessions().has(sessionId)) return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpcasabiancai/cayenne",
3
- "version": "0.5.18",
3
+ "version": "0.5.20",
4
4
  "files": [
5
5
  "dist/cli.js"
6
6
  ],