@ai-ecoverse/slicc-spectrum 2.0.2 → 2.1.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.
@@ -1916,6 +1916,11 @@ var DummyAgent = class extends Emitter {
1916
1916
  #ice = /* @__PURE__ */ new Map();
1917
1917
  #suggestions = /* @__PURE__ */ new Map();
1918
1918
  #runs = /* @__PURE__ */ new Map();
1919
+ #earlier = /* @__PURE__ */ new Map();
1920
+ #page = 0;
1921
+ #failing = 0;
1922
+ olderTicks = 10;
1923
+ olderCalls = [];
1919
1924
  #active;
1920
1925
  #clock;
1921
1926
  #effects;
@@ -2278,6 +2283,7 @@ var DummyAgent = class extends Emitter {
2278
2283
  const messages = this.#messages.get(agentId);
2279
2284
  if (agent.kind === "cone" && messages.length) this.#shelve(agent, messages);
2280
2285
  this.#messages.set(agentId, []);
2286
+ this.#earlier.delete(agentId);
2281
2287
  this.#queues.set(agentId, []);
2282
2288
  this.#suggestions.delete(agentId);
2283
2289
  this.emit("messages", agentId);
@@ -2309,8 +2315,36 @@ var DummyAgent = class extends Emitter {
2309
2315
  agent.thinking = thinking;
2310
2316
  this.#changed();
2311
2317
  }
2312
- async older() {
2313
- return [];
2318
+ paginate(keep, size, ids = [...this.#messages.keys()]) {
2319
+ this.#page = size;
2320
+ for (const agentId of ids) {
2321
+ const all = [...this.#earlier.get(agentId) ?? [], ...this.#messages.get(agentId) ?? []];
2322
+ const cut = Math.max(0, all.length - keep);
2323
+ this.#earlier.set(agentId, all.slice(0, cut));
2324
+ this.#messages.set(agentId, all.slice(cut));
2325
+ this.emit("messages", agentId);
2326
+ }
2327
+ }
2328
+ failOlder(times = 1) {
2329
+ this.#failing = times;
2330
+ }
2331
+ hasOlder(agentId) {
2332
+ return !!this.#earlier.get(agentId)?.length;
2333
+ }
2334
+ async older(agentId) {
2335
+ this.olderCalls.push(agentId);
2336
+ await this.#clock.sleep(this.olderTicks);
2337
+ if (this.#failing > 0) {
2338
+ this.#failing--;
2339
+ throw new Error("The earlier messages couldn\u2019t be read.");
2340
+ }
2341
+ const earlier = this.#earlier.get(agentId) ?? [];
2342
+ const page2 = earlier.splice(Math.max(0, earlier.length - this.#page));
2343
+ if (page2.length) {
2344
+ this.#messages.get(agentId)?.unshift(...page2);
2345
+ this.emit("messages", agentId);
2346
+ }
2347
+ return page2;
2314
2348
  }
2315
2349
  commands(agentId) {
2316
2350
  if (this.#agent(agentId)?.kind !== "cone") return [];
@@ -2354,6 +2388,7 @@ var DummyAgent = class extends Emitter {
2354
2388
  this.stop(agentId);
2355
2389
  this.#agents = this.#agents.filter((candidate) => candidate !== agent);
2356
2390
  this.#messages.delete(agentId);
2391
+ this.#earlier.delete(agentId);
2357
2392
  this.#queues.delete(agentId);
2358
2393
  this.#suggestions.delete(agentId);
2359
2394
  if (this.#active === agentId) this.select(agent.parentId ?? this.#agents[0].id);
@@ -7111,7 +7146,8 @@ function createDummyModel({
7111
7146
  monitor = "dummy",
7112
7147
  import: imports = "off",
7113
7148
  login,
7114
- budget = "plain"
7149
+ budget = "plain",
7150
+ older = "off"
7115
7151
  } = {}) {
7116
7152
  const time = clock(delay);
7117
7153
  const mount = mounts === "off" ? null : { scenario: mounts, point: mountPoint, files: mounted };
@@ -7136,6 +7172,7 @@ function createDummyModel({
7136
7172
  browser.release(agentId);
7137
7173
  };
7138
7174
  importPort(imports, agent, time);
7175
+ if (older === "paged") agent.paginate(6, 4);
7139
7176
  if (hold !== "off") agent.setHold({ reason: hold, held: 2 });
7140
7177
  const noticePort = noticesPort(agent, time, notices, readonly, arrival);
7141
7178
  if (scenario === "driving") void browser.run(drive);