@ai-ecoverse/slicc-spectrum 1.83.0 → 1.84.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
@@ -12325,30 +12325,43 @@ var guestExpiries = [
12325
12325
  ];
12326
12326
  var guestNameLimit = 40;
12327
12327
  var approve = "A person with Control approves each one.";
12328
- function gateOptions(field, cone) {
12329
- const scoops = cone.scoops.map((name) => ({
12330
- value: `scoop:${name}`,
12331
- label: `${name} decides`,
12332
- description: `The scoop ${name} decides.`
12333
- }));
12334
- const user2 = { value: "user", label: "You approve each one", description: approve };
12335
- const agent = {
12336
- value: "agent",
12337
- label: "The automatic check decides",
12338
- description: "It decides by your intent, and asks a person when unsure."
12339
- };
12340
- if (field === "tools") return [user2, agent, ...scoops];
12341
- return [
12342
- user2,
12343
- agent,
12344
- {
12328
+ var defaultGates = {
12329
+ messages: ["user", "agent", "cone", "scoop:*", "off"],
12330
+ tools: ["user", "agent", "scoop:*"]
12331
+ };
12332
+ function gateChoice(field, cone, gate) {
12333
+ if (gate === "scoop:*")
12334
+ return cone.scoops.flatMap((name) => gateChoice(field, cone, `scoop:${name}`));
12335
+ if (gate.startsWith("scoop:")) {
12336
+ const name = gate.slice(6);
12337
+ return cone.scoops.includes(name) ? [{ value: gate, label: `${name} decides`, description: `The scoop ${name} decides.` }] : [];
12338
+ }
12339
+ const choices = {
12340
+ user: { value: "user", label: "You approve each one", description: approve },
12341
+ agent: {
12342
+ value: "agent",
12343
+ label: "The automatic check decides",
12344
+ description: "It decides by your intent, and asks a person when unsure."
12345
+ },
12346
+ cone: {
12345
12347
  value: "cone",
12346
12348
  label: `${cone.name} decides`,
12347
12349
  description: "The shared cone itself decides."
12348
12350
  },
12349
- ...scoops,
12350
- { value: "off", label: "No review", description: "Messages go straight in as follow-ups." }
12351
- ];
12351
+ off: {
12352
+ value: "off",
12353
+ label: "No review",
12354
+ description: field === "messages" ? "Messages go straight in as follow-ups." : "Tool calls run without review."
12355
+ }
12356
+ };
12357
+ return choices[gate] ? [choices[gate]] : [];
12358
+ }
12359
+ function gateOptions(field, cone, allowed = defaultGates[field]) {
12360
+ const options = allowed.flatMap((gate) => gateChoice(field, cone, gate)).filter((option2, index, all2) => all2.findIndex(({ value }) => value === option2.value) === index);
12361
+ return options.length ? options : gateChoice(field, cone, "user");
12362
+ }
12363
+ function defaultGate(options) {
12364
+ return options.some(({ value }) => value === "user") ? "user" : options[0].value;
12352
12365
  }
12353
12366
  function guestCones(agents) {
12354
12367
  return agents.filter((agent) => agent.kind === "cone" && !agent.frozen).map((cone) => ({
@@ -12490,16 +12503,25 @@ var SliccGuestInvite = class extends i2 {
12490
12503
  get #current() {
12491
12504
  return this.cones.find((cone) => cone.id === this.cone) ?? this.cones[0];
12492
12505
  }
12506
+ #options(field, cone) {
12507
+ return gateOptions(field, cone, this.port?.gates?.()[field]);
12508
+ }
12493
12509
  #keep(gate, field, cone) {
12494
- return gateOptions(field, cone).some((option2) => option2.value === gate) ? gate : "user";
12510
+ const options = this.#options(field, cone);
12511
+ return options.some((option2) => option2.value === gate) ? gate : defaultGate(options);
12512
+ }
12513
+ #settle() {
12514
+ this.messages = this.#keep(this.messages, "messages", this.#current);
12515
+ this.tools = this.#keep(this.tools, "tools", this.#current);
12495
12516
  }
12496
12517
  #pick(event2) {
12497
12518
  return event2.target.value;
12498
12519
  }
12499
12520
  #setCone(event2) {
12500
12521
  this.cone = this.#pick(event2);
12501
- this.messages = this.#keep(this.messages, "messages", this.#current);
12502
- this.tools = this.#keep(this.tools, "tools", this.#current);
12522
+ }
12523
+ willUpdate() {
12524
+ this.#settle();
12503
12525
  }
12504
12526
  #input(event2) {
12505
12527
  this.label = event2.currentTarget.value;
@@ -12520,6 +12542,7 @@ var SliccGuestInvite = class extends i2 {
12520
12542
  this.#focus("#guest-name");
12521
12543
  return;
12522
12544
  }
12545
+ this.#settle();
12523
12546
  const ms = guestExpiries.find(([key2]) => key2 === this.expiry)[2];
12524
12547
  this.pending = true;
12525
12548
  try {
@@ -12557,7 +12580,7 @@ var SliccGuestInvite = class extends i2 {
12557
12580
  if (this.trigger?.isConnected) this.trigger.focus();
12558
12581
  }
12559
12582
  #gate(field, title, value) {
12560
- const options = gateOptions(field, this.#current);
12583
+ const options = this.#options(field, this.#current);
12561
12584
  const chosen = options.find((option2) => option2.value === value);
12562
12585
  const id = `guest-${field}`;
12563
12586
  return b`<div class="field">
@@ -34474,11 +34497,15 @@ var inCwd = (approval) => approval.kind === "sudo" && approval.alwaysScope === "
34474
34497
  function alwaysHint(approval) {
34475
34498
  return inCwd(approval) ? `Always allow lets ${approval.requester.name} run exactly this command with sudo, in ${approval.cwd}, without asking again.` : `Always allow lets ${approval.requester.name} run exactly this command with sudo without asking again.`;
34476
34499
  }
34500
+ function guestAlwaysHint(approval) {
34501
+ const agent = approval.agentName ?? "this cone";
34502
+ return approval.kind === "guest-message" ? `Always allow lets ${approval.requester.name} send messages to ${agent} without asking again.` : `Always allow lets ${agent} run exactly this ${approval.tool} call for ${approval.requester.name} without asking again.`;
34503
+ }
34477
34504
  function guestAsking(approval) {
34478
34505
  return approval.kind === "guest-message" ? `${approval.requester.name} wants to send this to ${approval.agentName ?? "this cone"}:` : `${approval.agentName ?? "This cone"} wants to run ${approval.tool} for ${approval.requester.name}:`;
34479
34506
  }
34480
34507
  function guestWaiting(approval) {
34481
- return approval.kind === "guest-message" ? `${approval.requester.name}'s message to ${approval.agentName ?? "this cone"} waits for approval on the device in control.` : `${approval.agentName ?? "This cone"} wants to run ${approval.tool} for ${approval.requester.name}, which waits for approval on the device in control.`;
34508
+ 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.`;
34482
34509
  }
34483
34510
  var clear = { certain: null, maybe: null };
34484
34511
  function rulesOf(approval) {
@@ -34664,8 +34691,8 @@ var SliccApprovals = class extends ModelElement {
34664
34691
  const port = this.model?.approvals;
34665
34692
  if (!port?.decide || this.busy || decision2 !== "deny" && !this.#armed) return;
34666
34693
  const verdict = rulesOf(approval);
34667
- if (decision2 === "always" && (approval.kind !== "sudo" || verdict.certain || verdict.maybe))
34668
- return;
34694
+ const always = approval.kind === "sudo" || approval.always;
34695
+ if (decision2 === "always" && (!always || verdict.certain || verdict.maybe)) return;
34669
34696
  this.busy = decision2;
34670
34697
  this.failure = null;
34671
34698
  this.#pending.add(approval.id);
@@ -34797,8 +34824,8 @@ var SliccApprovals = class extends ModelElement {
34797
34824
  const failure2 = this.failure?.id === approval.id ? this.failure.message : "";
34798
34825
  const verdict = rulesOf(approval);
34799
34826
  const rules = verdict.certain ?? verdict.maybe;
34800
- const always = approval.kind === "sudo" && approval.always && !rules;
34801
- const hint2 = approval.kind === "sudo" && always ? alwaysHint(approval) : "";
34827
+ const always = approval.always && !rules;
34828
+ const hint2 = always ? approval.kind === "sudo" ? alwaysHint(approval) : guestAlwaysHint(approval) : "";
34802
34829
  return this.#dialog(
34803
34830
  approval,
34804
34831
  approval.id,
@@ -39638,6 +39665,12 @@ ${this.value}` : text2;
39638
39665
  );
39639
39666
  }
39640
39667
  }
39668
+ #menuKey(event2) {
39669
+ if (event2.key !== "Escape") return;
39670
+ event2.preventDefault();
39671
+ event2.stopPropagation();
39672
+ event2.currentTarget.open = false;
39673
+ }
39641
39674
  #toggleTalk = (event2) => {
39642
39675
  event2.stopPropagation();
39643
39676
  const settings = this.model?.settings;
@@ -39870,7 +39903,7 @@ ${this.value}` : text2;
39870
39903
  >
39871
39904
  ${this.attachments.map((attachment2) => this.#attachment(attachment2))}
39872
39905
  </swc-prompt-field>
39873
- <swc-popover placement="top-start" accessible-label="Add to the message" @swc-after-open=${() => this.renderRoot.querySelector("sp-menu")?.focus()}>
39906
+ <swc-popover placement="top-start" accessible-label="Add to the message" @keydown=${this.#menuKey} @swc-after-open=${() => this.renderRoot.querySelector("sp-menu")?.focus()}>
39874
39907
  <sp-menu label="Add to the message" @change=${this.#add}>
39875
39908
  <sp-menu-item value="upload">Upload from this computer</sp-menu-item>
39876
39909
  <sp-menu-item value="screenshot">Take a screenshot of the browser tab</sp-menu-item>
@@ -40472,7 +40505,7 @@ var SliccNotices = class extends ModelElement {
40472
40505
  <div class="text">
40473
40506
  <span class="title">Waiting for sudo approval</span>
40474
40507
  <p>${asking(approval)}: <code>${sudo(approval)}</code></p>
40475
- <p>Answer it in the tab running SLICC. Denied automatically at ${deadline(approval.expiresAt)}.</p>
40508
+ <p>It waits for the owner's approval. Denied automatically at ${deadline(approval.expiresAt)}.</p>
40476
40509
  </div>
40477
40510
  </div>`;
40478
40511
  }