@ai-ecoverse/slicc-spectrum 2.3.1 → 2.5.0

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.
@@ -29,7 +29,7 @@ import {
29
29
  skillEdit,
30
30
  tabs,
31
31
  terminals
32
- } from "./chunk-47KEBIYA.js";
32
+ } from "./chunk-AIE26XNA.js";
33
33
  import {
34
34
  Emitter
35
35
  } from "./chunk-T5NHW4KC.js";
@@ -303,7 +303,48 @@ function levelFixture(scenario, now2) {
303
303
  verdictError: "The check didn\u2019t answer in time."
304
304
  };
305
305
  }
306
+ function captureFixtures(scenario, now2) {
307
+ const base = { createdAt: now2, expiresAt: now2 + 5 * minutes };
308
+ if (scenario === "capture")
309
+ return [
310
+ {
311
+ ...base,
312
+ id: "capture-screen",
313
+ kind: "capture",
314
+ requester: mara,
315
+ agentId: "cone-sliccy",
316
+ agentName: "sliccy",
317
+ detail: { what: "screen", mode: "video", seconds: 10, microphone: true, program: "media" },
318
+ always: false,
319
+ verdict: {
320
+ level: 2,
321
+ aligned: true,
322
+ reason: "It records the screen and the microphone, which the guest asked for."
323
+ }
324
+ }
325
+ ];
326
+ return [
327
+ {
328
+ ...base,
329
+ id: "click-share",
330
+ kind: "click",
331
+ subject: "capture",
332
+ what: "screen",
333
+ program: "media",
334
+ requester: { kind: "agent", name: "sliccy", agentId: "cone-sliccy" },
335
+ title: "Share your screen?",
336
+ body: "media wants to record your screen for sliccy. Choose a screen, window or tab in Chrome\u2019s picker.",
337
+ action: "Choose what to share",
338
+ here: scenario === "click",
339
+ ...scenario === "click" ? {} : { device: { id: "device-studio", name: "Studio Mac" } }
340
+ }
341
+ ];
342
+ }
306
343
  function approvalFixtures(scenario, now2 = Date.now()) {
344
+ if (scenario.startsWith("click") || scenario === "capture") return captureFixtures(scenario, now2);
345
+ return sudoFixtures(scenario, now2);
346
+ }
347
+ function sudoFixtures(scenario, now2) {
307
348
  const agent = {
308
349
  id: "sudo-jq",
309
350
  kind: "sudo",
@@ -4132,6 +4173,69 @@ var DummyFiles = class extends Emitter {
4132
4173
  }
4133
4174
  };
4134
4175
 
4176
+ // src/dummy/live.ts
4177
+ function liveFixtures(scenario, now2 = Date.now()) {
4178
+ const screen = {
4179
+ id: "live-screen",
4180
+ kind: "screen",
4181
+ label: "Recording screen",
4182
+ what: "Entire screen",
4183
+ asker: "sliccy",
4184
+ since: now2 - 42e3,
4185
+ action: { label: "Stop" }
4186
+ };
4187
+ if (scenario === "screen") return [screen];
4188
+ return [
4189
+ screen,
4190
+ {
4191
+ id: "live-microphone",
4192
+ kind: "microphone",
4193
+ label: "Recording microphone",
4194
+ what: "Desk microphone",
4195
+ asker: "Seat 2 (Mara) via docs-pass",
4196
+ since: now2 - 7e3,
4197
+ action: { label: "Stop" }
4198
+ }
4199
+ ];
4200
+ }
4201
+ var DummyLive = class extends Emitter {
4202
+ #items;
4203
+ acted = [];
4204
+ constructor(scenario) {
4205
+ super();
4206
+ this.#items = liveFixtures(scenario);
4207
+ }
4208
+ items() {
4209
+ return [...this.#items];
4210
+ }
4211
+ add(item) {
4212
+ this.#items = [...this.#items.filter(({ id }) => id !== item.id), item];
4213
+ this.emit("items", this.items());
4214
+ }
4215
+ act(id) {
4216
+ this.acted.push(id);
4217
+ this.#items = this.#items.filter((item) => item.id !== id);
4218
+ this.emit("items", this.items());
4219
+ }
4220
+ };
4221
+ var switchFixtures = [
4222
+ { key: "camera", label: "Camera", on: true },
4223
+ { key: "microphone", label: "Microphone", on: true },
4224
+ { key: "screen", label: "Screen", on: true }
4225
+ ];
4226
+ var DummySwitches = class extends Emitter {
4227
+ #list = switchFixtures.map((item) => ({ ...item }));
4228
+ sets = [];
4229
+ list() {
4230
+ return this.#list.map((item) => ({ ...item }));
4231
+ }
4232
+ set(key, on) {
4233
+ this.sets.push([key, on]);
4234
+ this.#list = this.#list.map((item) => item.key === key ? { ...item, on } : item);
4235
+ this.emit("switches", this.list());
4236
+ }
4237
+ };
4238
+
4135
4239
  // src/dummy/memory.ts
4136
4240
  var DummyMemory = class extends Emitter {
4137
4241
  #memories;
@@ -6995,9 +7099,20 @@ var DummyValueFrame = class {
6995
7099
  problem.textContent = "";
6996
7100
  this.#finished = true;
6997
7101
  try {
6998
- if (reveal) await this.#vault.allow(this.request);
6999
- else await this.#vault.seal(this.request, value);
7000
- this.#emit({ event: "done", request: this.request, state: reveal ? "allowed" : "sealed" });
7102
+ if (reveal) {
7103
+ await this.#vault.allow(this.request);
7104
+ this.#emit({ event: "done", request: this.request, state: "allowed" });
7105
+ } else {
7106
+ const { name: name2, placeholder, state } = await this.#vault.seal(this.request, value);
7107
+ this.#emit({
7108
+ event: "done",
7109
+ request: this.request,
7110
+ state: "sealed",
7111
+ name: name2,
7112
+ placeholder,
7113
+ record: state
7114
+ });
7115
+ }
7001
7116
  } catch (error) {
7002
7117
  this.#finished = false;
7003
7118
  const { code, message } = error;
@@ -7016,6 +7131,8 @@ var DummyVault = class extends Emitter {
7016
7131
  #serial = 0;
7017
7132
  buttons = [];
7018
7133
  frames = [];
7134
+ entered = [];
7135
+ #entries = /* @__PURE__ */ new Map();
7019
7136
  answered = /* @__PURE__ */ new Set();
7020
7137
  revealed = [];
7021
7138
  puts = [];
@@ -7070,6 +7187,10 @@ var DummyVault = class extends Emitter {
7070
7187
  if (this.#available === "waiting") return "waiting";
7071
7188
  return this.#status.locked ? "locked" : "ready";
7072
7189
  }
7190
+ wait() {
7191
+ this.#available = "waiting";
7192
+ this.emit("availability", this.availability());
7193
+ }
7073
7194
  arrive() {
7074
7195
  this.#available = "ready";
7075
7196
  this.emit("availability", this.availability());
@@ -7205,7 +7326,7 @@ var DummyVault = class extends Emitter {
7205
7326
  async cancel(request) {
7206
7327
  await this.#time.sleep(5);
7207
7328
  this.#failed();
7208
- this.#take(request);
7329
+ if (!this.#ended(request)) this.#take(request);
7209
7330
  this.cancelled.push(request);
7210
7331
  return "cancelled";
7211
7332
  }
@@ -7305,7 +7426,44 @@ var DummyVault = class extends Emitter {
7305
7426
  this.emit("status", this.#status);
7306
7427
  }
7307
7428
  ask(request) {
7308
- return this.#status.waiting.find(({ id, kind }) => id === request && kind === "ask");
7429
+ return this.#entries.get(request)?.pending ?? this.#status.waiting.find(({ id, kind }) => id === request && kind === "ask");
7430
+ }
7431
+ enter = (options) => this.#open(options);
7432
+ async #open(options) {
7433
+ await this.#time.sleep(5);
7434
+ this.#failed();
7435
+ const { name: name2, kind = "secret", replace } = options;
7436
+ const bad = nameProblem(name2);
7437
+ if (bad) throw vaultFailure("EINVAL", bad);
7438
+ const live = this.#list.secrets.some(
7439
+ (secret) => secret.name === name2 && secret.kind === kind && secret.state !== "removed"
7440
+ );
7441
+ if (live && !replace)
7442
+ throw vaultFailure("EEXIST", `${name2} already holds a value; replace it instead`);
7443
+ if (options.settings) refused(options.settings);
7444
+ this.#serial += 1;
7445
+ const request = `enter-${this.#serial}`;
7446
+ const now2 = Date.now();
7447
+ this.entered.push({ ...options });
7448
+ this.#entries.set(request, {
7449
+ options,
7450
+ pending: {
7451
+ id: request,
7452
+ kind: "ask",
7453
+ name: name2,
7454
+ mode: "enter",
7455
+ uid: 0,
7456
+ tag: null,
7457
+ createdAt: now2,
7458
+ expiresAt: now2 + 5 * minute3
7459
+ }
7460
+ });
7461
+ return { request };
7462
+ }
7463
+ #ended(request) {
7464
+ if (!this.#entries.delete(request)) return false;
7465
+ this.emit("status", this.#status);
7466
+ return true;
7309
7467
  }
7310
7468
  #asked(request) {
7311
7469
  this.#unlocked();
@@ -7319,8 +7477,18 @@ var DummyVault = class extends Emitter {
7319
7477
  const problem = valueProblem(value);
7320
7478
  if (problem) throw vaultFailure("EINVAL", problem);
7321
7479
  this.answered.add(request);
7322
- this.#take(request);
7323
- return this.#seal(found.name, "settings");
7480
+ const entry = this.#entries.get(request);
7481
+ if (!entry) {
7482
+ this.#take(request);
7483
+ return this.#seal(found.name, "settings");
7484
+ }
7485
+ this.#ended(request);
7486
+ const { kind = "secret", provider, server, settings } = entry.options;
7487
+ return this.#seal(found.name, "settings", kind, {
7488
+ ...provider === void 0 ? {} : { provider },
7489
+ ...server === void 0 ? {} : { server },
7490
+ ...settings === void 0 ? {} : { settings: { ...settings } }
7491
+ });
7324
7492
  }
7325
7493
  async allow(request) {
7326
7494
  await this.#time.sleep(5);
@@ -7402,6 +7570,12 @@ function vaultRecords(accounts2, mcp) {
7402
7570
  if (accounts2 === "settings") return [];
7403
7571
  return accountRecords(Date.now(), mcp === "moved" ? docsUrl : void 0);
7404
7572
  }
7573
+ function dummyVault(vault, entry, time, records) {
7574
+ if (vault === "off") return void 0;
7575
+ const port = new DummyVault(vault, time, records);
7576
+ if (entry === "input") port.enter = void 0;
7577
+ return port;
7578
+ }
7405
7579
  function guestsPort(guests, time) {
7406
7580
  return guests === "off" ? {} : { guests: new DummyGuests(guests, time) };
7407
7581
  }
@@ -7438,8 +7612,11 @@ function createDummyModel({
7438
7612
  tabs: tabs2 = "off",
7439
7613
  approvals = "off",
7440
7614
  asks = "off",
7615
+ live = "off",
7616
+ switches = "off",
7441
7617
  follow = "off",
7442
7618
  vault = "off",
7619
+ entry = "input",
7443
7620
  guests = "off",
7444
7621
  accounts: accounts2 = "settings",
7445
7622
  providers = "connected",
@@ -7483,7 +7660,7 @@ function createDummyModel({
7483
7660
  if (older === "paged") agent.paginate(6, 4);
7484
7661
  if (hold !== "off") agent.setHold({ reason: hold, held: 2 });
7485
7662
  const noticePort = noticesPort(agent, time, notices, readonly, arrival);
7486
- const vaultPort = vault === "off" ? void 0 : new DummyVault(vault, time, vaultRecords(accounts2, mcp));
7663
+ const vaultPort = dummyVault(vault, entry, time, vaultRecords(accounts2, mcp));
7487
7664
  if (scenario === "driving") void browser.run(drive);
7488
7665
  const base = {
7489
7666
  agent,
@@ -7527,6 +7704,8 @@ function createDummyModel({
7527
7704
  ...noticePort ? { notices: noticePort } : {},
7528
7705
  ...tabs2 === "off" ? {} : { tabs: new DummyTabs(tabs2, time) },
7529
7706
  ...approvals === "off" ? {} : { approvals: new DummyApprovals(approvals, time, vaultPort) },
7707
+ ...live === "off" ? {} : { live: new DummyLive(live) },
7708
+ ...switches === "off" ? {} : { switches: new DummySwitches() },
7530
7709
  ...follow === "off" ? {} : { follow: new DummyFollow(follow, time) },
7531
7710
  ...vaultPort ? { vault: vaultPort } : {},
7532
7711
  ...guestsPort(guests, time)
@@ -7547,8 +7726,10 @@ export {
7547
7726
  DummyGuestAgent,
7548
7727
  DummyGuests,
7549
7728
  DummyImport,
7729
+ DummyLive,
7550
7730
  DummyNetwork,
7551
7731
  DummyNotices,
7732
+ DummySwitches,
7552
7733
  DummyTabs,
7553
7734
  DummyUpdates,
7554
7735
  DummyValueFrame,
@@ -7584,6 +7765,7 @@ export {
7584
7765
  joinUrl,
7585
7766
  leadersFixtures,
7586
7767
  linksFixtures,
7768
+ liveFixtures,
7587
7769
  movedDocs,
7588
7770
  networkFixtures,
7589
7771
  noticeFixtures,
@@ -7598,6 +7780,7 @@ export {
7598
7780
  providerAccount,
7599
7781
  providerAccounts,
7600
7782
  providerFixtures,
7783
+ switchFixtures,
7601
7784
  tabsFixtures,
7602
7785
  tailnetFixtures,
7603
7786
  updateFixtures,