@ai-ecoverse/slicc-spectrum 1.108.6 → 1.109.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/slicc-ui.js CHANGED
@@ -10331,8 +10331,8 @@ var ranges = [
10331
10331
  [100, "bg", 8]
10332
10332
  ];
10333
10333
  function simple(code3) {
10334
- const flag = flags[code3];
10335
- if (flag) return flag;
10334
+ const flag2 = flags[code3];
10335
+ if (flag2) return flag2;
10336
10336
  const range2 = ranges.find(([start2]) => code3 >= start2 && code3 < start2 + 8);
10337
10337
  return range2 ? { [range2[1]]: code3 - range2[0] + range2[2] } : null;
10338
10338
  }
@@ -40184,12 +40184,12 @@ var SliccMonitor = class extends ModelElement {
40184
40184
  </li>`;
40185
40185
  }
40186
40186
  #section(section) {
40187
- const flag = attention2(section);
40187
+ const flag2 = attention2(section);
40188
40188
  const surface2 = surfaces[section.id];
40189
40189
  const rows2 = section.rows.length > 0;
40190
- const open = rows2 && (this.expanded[section.id] ?? flag !== null);
40190
+ const open = rows2 && (this.expanded[section.id] ?? flag2 !== null);
40191
40191
  const list6 = `rows-${section.id}`;
40192
- const badge = flag ? b`<swc-badge size="s" variant=${flag.variant} subtle>${flag.text}</swc-badge>` : A;
40192
+ const badge = flag2 ? b`<swc-badge size="s" variant=${flag2.variant} subtle>${flag2.text}</swc-badge>` : A;
40193
40193
  return b`<li class="section" data-id=${section.id} data-open=${open ? "" : A}>
40194
40194
  <div class="line">
40195
40195
  <span class="caption">${rows2 ? b`<button class="toggle" aria-expanded=${open ? "true" : "false"} aria-controls=${open ? list6 : A} @click=${() => {
@@ -44002,14 +44002,14 @@ var directions2 = /* @__PURE__ */ new Set(["left", "right", "above", "below", "w
44002
44002
  function scan(parsed, rest, positional) {
44003
44003
  for (let index2 = 0; index2 < rest.length; index2++) {
44004
44004
  const arg = rest[index2];
44005
- const flag = arg.startsWith("--") ? arg.slice(2) : null;
44006
- if (flag === "json") parsed.json = true;
44007
- else if (flag === "section" || flag !== null && directions2.has(flag)) {
44005
+ const flag2 = arg.startsWith("--") ? arg.slice(2) : null;
44006
+ if (flag2 === "json") parsed.json = true;
44007
+ else if (flag2 === "section" || flag2 !== null && directions2.has(flag2)) {
44008
44008
  const value = rest[++index2];
44009
- if (value === void 0) return `--${flag} needs a value`;
44010
- if (flag === "section") parsed.section = value;
44009
+ if (value === void 0) return `--${flag2} needs a value`;
44010
+ if (flag2 === "section") parsed.section = value;
44011
44011
  else if (parsed.place) return "give one place";
44012
- else parsed.place = { direction: flag, ref: value };
44012
+ else parsed.place = { direction: flag2, ref: value };
44013
44013
  } else if (arg.startsWith("-")) return `unknown option ${arg}`;
44014
44014
  else positional.push(arg);
44015
44015
  }
@@ -49679,27 +49679,67 @@ function pattern(path2) {
49679
49679
  var opaque = /^\/(?:proc\/[^/]+\/(?:task\/[^/]+\/)?(?:cwd|fd|map_files)|dev\/fd)(?:\/|$)/;
49680
49680
  var certain = (rules) => rules.startsWith("/") && !opaque.test(rules) && !rules.endsWith("\u2026");
49681
49681
  var readOnly = [
49682
+ "b2sum",
49683
+ "base64",
49682
49684
  "cat",
49683
49685
  "cd",
49686
+ "cksum",
49687
+ "cut",
49684
49688
  "df",
49685
49689
  "diff",
49686
49690
  "du",
49687
49691
  "echo",
49688
49692
  "file",
49693
+ "find",
49689
49694
  "grep",
49690
49695
  "head",
49696
+ "jq",
49691
49697
  "ls",
49698
+ "md5sum",
49699
+ "nl",
49700
+ "od",
49692
49701
  "pwd",
49693
49702
  "readlink",
49694
49703
  "realpath",
49704
+ "sha1sum",
49705
+ "sha224sum",
49706
+ "sha256sum",
49707
+ "sha384sum",
49708
+ "sha512sum",
49709
+ "sort",
49695
49710
  "stat",
49711
+ "tac",
49696
49712
  "tail",
49697
49713
  "tree",
49698
- "wc"
49714
+ "uniq",
49715
+ "wc",
49716
+ "xxd",
49717
+ "yq"
49699
49718
  ];
49719
+ var flag = (short2, long) => (args2) => args2.some((arg) => {
49720
+ if (!arg.startsWith("--")) return /^-[^-]/.test(arg) && [...short2].some((c29) => arg.includes(c29));
49721
+ const [name] = arg.slice(2).split("=");
49722
+ return !!name && long.some((option) => option.startsWith(name));
49723
+ });
49724
+ var operands = (args2) => {
49725
+ const end = args2.includes("--") ? args2.indexOf("--") : args2.length;
49726
+ const named2 = args2.slice(0, end).filter((arg) => arg === "-" || !arg.startsWith("-"));
49727
+ return named2.length + args2.slice(end + 1).length > 1;
49728
+ };
49729
+ var writes = {
49730
+ base64: flag("o", ["output"]),
49731
+ file: flag("C", ["compile"]),
49732
+ find: (args2) => args2.some((arg) => /^-(?:delete|exec|execdir|ok|okdir|fls|fprint0?|fprintf)$/.test(arg)),
49733
+ sort: flag("oT", ["output", "temporary-directory", "compress-program"]),
49734
+ tree: flag("oR", []),
49735
+ uniq: operands,
49736
+ xxd: operands,
49737
+ yq: flag("is", ["inplace", "in-place", "split-exp", "split-exp-file"])
49738
+ };
49700
49739
  function candidates(word2) {
49701
49740
  if (word2 === "--") return [];
49702
- if (word2.startsWith("--")) return [word2];
49741
+ if (word2.startsWith("--"))
49742
+ return word2.includes("=") ? [word2, word2.split("=").slice(1).join("=")] : [word2];
49703
49743
  if (!word2.startsWith("-")) return [word2];
49704
49744
  const slash = word2.indexOf("/");
49705
49745
  const cluster = Array.from(word2.slice(2), (_7, index2) => word2.slice(index2 + 2));
@@ -49719,7 +49759,10 @@ function protects(path2, whole) {
49719
49759
  return rulePaths.some((rule) => glob.test(rule)) || top !== path2 && pattern(top).test("/etc/fnox") || whole && ruleParents.some((parent) => glob.test(parent));
49720
49760
  }
49721
49761
  var command2 = (word2) => word2.split("/").pop() ?? "";
49722
- var trusted2 = (word2) => readOnly.includes(word2.replace(/^\/(?:usr\/)?bin\/(?=[^/]+$)/, ""));
49762
+ var trusted2 = ([word2, ...args2]) => {
49763
+ const name = word2.replace(/^\/(?:usr\/)?bin\/(?=[^/]+$)/, "");
49764
+ return readOnly.includes(name) && !writes[name]?.(args2);
49765
+ };
49723
49766
  var expansion = /\$\([^)]*\)?|\$\{[^}]*\}?|\$[\w@*#?$!-]*|`[^`]*`?/;
49724
49767
  function moved(cwds, word2) {
49725
49768
  for (const cwd of [...cwds]) {
@@ -49795,6 +49838,8 @@ function shield(text4) {
49795
49838
  }
49796
49839
  return out;
49797
49840
  }
49841
+ var literal = (char, quote) => /[*?[{]/.test(char) || quote === "'" && char === "$" ? String.fromCharCode(57600 + char.charCodeAt(0)) : char;
49842
+ var unmark = (path2) => path2.replace(/[\ue100-\ue17f]/g, (char) => String.fromCharCode(char.charCodeAt(0) - 57600));
49798
49843
  function quoted(segment2) {
49799
49844
  const words2 = [];
49800
49845
  let word2 = "";
@@ -49805,7 +49850,7 @@ function quoted(segment2) {
49805
49850
  word2 += segment2[++index2];
49806
49851
  else if (quote) {
49807
49852
  if (char === quote) quote = "";
49808
- else word2 += char;
49853
+ else word2 += literal(char, quote);
49809
49854
  } else if (char === "'" || char === '"') quote = char;
49810
49855
  else if (char === "\\") word2 += segment2[++index2] ?? "";
49811
49856
  else if (/[\s<>=]/.test(char)) {
@@ -49842,8 +49887,10 @@ function reach2(command3, cwd) {
49842
49887
  const text4 = unglob(ansi2(command3.replace(/\\\n/g, "")));
49843
49888
  const plain4 = text4.split(separators).map((segment2) => commas(segment2.split(/[\s<>=]+/).map((word2) => word2.replace(/['"\\]/g, ""))));
49844
49889
  const aware = shield(text4).split(separators).map((segment2) => commas(quoted(unshield(segment2))));
49845
- const segments = JSON.stringify(aware) === JSON.stringify(plain4) ? plain4 : [...plain4, ...aware];
49846
- const whole = segments.some((words2) => words2.length > 0 && !trusted2(words2[0]));
49890
+ const live = text4.includes("`") || aware.flat().some((word2) => word2.includes("$"));
49891
+ const inert2 = !live && aware.every((words2) => !words2.length || trusted2(words2));
49892
+ const segments = inert2 || JSON.stringify(aware) === JSON.stringify(plain4) ? aware : [...plain4, ...aware];
49893
+ const whole = !inert2 && segments.some((words2) => words2.length > 0 && !trusted2(words2));
49847
49894
  for (const words2 of segments) {
49848
49895
  const hit = scan2(words2, cwds, whole);
49849
49896
  if (hit) return hit;
@@ -49855,7 +49902,8 @@ function reach2(command3, cwd) {
49855
49902
  return segments.flat().some((word2) => word2.includes("$")) || text4.includes("`") ? text4.match(expansion)[0] : null;
49856
49903
  }
49857
49904
  function secretRules(command3, cwd) {
49858
- const hit = reach2(command3, cwd);
49905
+ const found = reach2(command3, cwd);
49906
+ const hit = found && unmark(found);
49859
49907
  return hit && certain(hit) ? { certain: hit, maybe: null } : { certain: null, maybe: hit };
49860
49908
  }
49861
49909
  function origin() {
@@ -49899,6 +49947,7 @@ function truncated(approval) {
49899
49947
  function hintOf(approval) {
49900
49948
  return approval.kind === "sudo" ? commandText(alwaysHint(approval), false) : guestAlwaysHint(approval);
49901
49949
  }
49950
+ var deniedSudo = (approval) => approval.kind === "sudo" && approval.verdict?.decision === "deny";
49902
49951
  var tooLong = "This request is too long to show in full, so it can\u2019t be allowed.";
49903
49952
  function guestWaiting(approval) {
49904
49953
  return approval.kind === "guest-message" ? `${approval.requester.name}'s message to ${approval.agentName ?? "this cone"} waits for the owner's approval.` : `${approval.agentName ?? "This cone"} wants to run ${approval.tool} for ${approval.requester.name}, which waits for the owner's approval.`;
@@ -50141,7 +50190,8 @@ var SliccApprovals = class extends ModelElement {
50141
50190
  return;
50142
50191
  const verdict = rulesOf(approval);
50143
50192
  const always = approval.kind === "sudo" || approval.kind !== "tray" && approval.always;
50144
- if (decision2 === "always" && (!always || verdict.certain || verdict.maybe)) return;
50193
+ if (decision2 === "always" && (!always || deniedSudo(approval) || verdict.certain || verdict.maybe))
50194
+ return;
50145
50195
  this.busy = decision2;
50146
50196
  this.failure = null;
50147
50197
  this.#pending.add(approval.id);
@@ -50269,7 +50319,7 @@ var SliccApprovals = class extends ModelElement {
50269
50319
  ${files.length ? b`<ul class="files" data-attachments>${files.map((file) => b`<li>${file.name} · ${file.mimeType} · ${size3(file.size)}</li>`)}</ul>` : A}`;
50270
50320
  }
50271
50321
  #verdict(approval) {
50272
- const verdict = approval.kind === "sudo" || approval.kind === "tray" ? void 0 : approval.verdict;
50322
+ const verdict = approval.kind === "tray" ? void 0 : approval.verdict;
50273
50323
  return verdict ? b`<p class="verdict" data-verdict=${verdict.decision}>${verdict.decision === "unsure" ? "The automatic check wasn\u2019t sure" : `The automatic check would ${verdict.decision} this`}: ${verdict.reason}</p>` : A;
50274
50324
  }
50275
50325
  #actions(approval, rejected, always) {
@@ -50278,7 +50328,7 @@ var SliccApprovals = class extends ModelElement {
50278
50328
  const whole = this.#whole(approval);
50279
50329
  return b`${this.#button(approval, "deny", "Deny", "secondary")}
50280
50330
  ${whole && always ? this.#button(approval, "always", inCwd(approval) ? "Always allow in this directory" : "Always allow", "secondary") : A}
50281
- ${whole ? this.#button(approval, "once", "Allow once", "accent") : A}`;
50331
+ ${whole ? this.#button(approval, "once", deniedSudo(approval) ? "Allow anyway (once)" : "Allow once", "accent") : A}`;
50282
50332
  }
50283
50333
  render() {
50284
50334
  if (this.gone) {
@@ -50301,7 +50351,7 @@ var SliccApprovals = class extends ModelElement {
50301
50351
  const failure2 = this.failure?.id === approval.id ? this.failure.message : "";
50302
50352
  const verdict = rulesOf(approval);
50303
50353
  const rules = verdict.certain ?? verdict.maybe;
50304
- const always = approval.kind !== "tray" && approval.always && !rules;
50354
+ const always = approval.kind !== "tray" && approval.always && !deniedSudo(approval) && !rules;
50305
50355
  const gate = this.#gate(approval);
50306
50356
  const hint2 = always && this.#whole(approval) ? hintOf(approval) : "";
50307
50357
  return this.#dialog(
@@ -50310,8 +50360,8 @@ var SliccApprovals = class extends ModelElement {
50310
50360
  b`<sp-alert-dialog variant="warning" data-approval-kind=${approval.kind}>
50311
50361
  <h2 id="title" slot="heading">${title(approval)}</h2>
50312
50362
  ${this.#request(approval, true)}
50313
- ${this.#verdict(approval)}
50314
50363
  ${approval.kind === "sudo" && approval.cwd ? b`<p class="cwd">In ${commandText(approval.cwd, false)}</p>` : A}
50364
+ ${this.#verdict(approval)}
50315
50365
  ${rules ? b`<div class="rules" data-secret-rules=${rules}><swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle><p>${verdict.certain ? b`<strong>This changes secret rules.</strong> It names <code>${commandText(rules, false)}</code>, where SLICC keeps which secrets programs may use and where they may be sent.` : b`<strong>This may change secret rules.</strong> SLICC can't tell where <code>${commandText(rules, false)}</code> leads, and it could reach the files where SLICC keeps which secrets programs may use and where they may be sent.`} Allow it only if you asked for this change.</p></div>` : A}
50316
50366
  ${hint2 ? b`<p class="hint">${hint2}</p>` : A}
50317
50367
  ${!failure2 && gate ? b`<p class="hint" data-allow-hint>${gate}</p>` : A}
@@ -56110,7 +56160,7 @@ var bridge = `(() => {
56110
56160
  });
56111
56161
  post({ type: 'slicc-ready' });
56112
56162
  })();`;
56113
- function literal(value) {
56163
+ function literal2(value) {
56114
56164
  try {
56115
56165
  return JSON.stringify(value ?? null).replace(/</g, "\\u003c");
56116
56166
  } catch {
@@ -56119,7 +56169,7 @@ function literal(value) {
56119
56169
  }
56120
56170
  function store(state2) {
56121
56171
  return `(() => {
56122
- let state = ${literal(state2)};
56172
+ let state = ${literal2(state2)};
56123
56173
  const tag = Math.random().toString(36).slice(2);
56124
56174
  const pending = new Map();
56125
56175
  let next = 0;
@@ -75262,11 +75312,11 @@ function isDirectoryNode(node2) {
75262
75312
  function getNodeFlags(node2) {
75263
75313
  return node2.depthAndFlags & PATH_STORE_NODE_FLAGS_MASK;
75264
75314
  }
75265
- function hasNodeFlag(node2, flag) {
75266
- return (getNodeFlags(node2) & flag) !== 0;
75315
+ function hasNodeFlag(node2, flag2) {
75316
+ return (getNodeFlags(node2) & flag2) !== 0;
75267
75317
  }
75268
- function addNodeFlag(node2, flag) {
75269
- node2.depthAndFlags |= flag;
75318
+ function addNodeFlag(node2, flag2) {
75319
+ node2.depthAndFlags |= flag2;
75270
75320
  }
75271
75321
  function setNodeDepth(node2, depth) {
75272
75322
  node2.depthAndFlags = createNodeDepthAndFlags(depth, getNodeFlags(node2), getNodeKind(node2));