eve-hub 0.16.14 → 0.16.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve-hub",
3
- "version": "0.16.14",
3
+ "version": "0.16.15",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Bot-side code shared by every hub agent: registry tools, the roster hook, the eve channel, the host sandbox and browser, and model helpers.",
6
6
  "type": "module",
@@ -23,6 +23,8 @@ export const PLAN_TIMEOUT_MS = 240_000;
23
23
  const MS_DAY = 86_400_000;
24
24
  const PRS_PER_CARD = 6;
25
25
  export const LINE_MAX = 90;
26
+ // The wire's PLAN_BASIS_MAX (SetDashPlan.basis); test/dash-plan.test.mjs keeps the two equal.
27
+ export const PLAN_BASIS_MAX = 100_000;
26
28
 
27
29
  const humanOf = (snap) => snap?.humans?.[0]?.name ?? "me";
28
30
  const isHuman = (m, human) => m.author === human || m.authorKind === "human";
@@ -308,6 +310,12 @@ export async function runPlan(hub, { generate, decisions = "", sizes = {}, now =
308
310
  const reason = replanReason(s, now);
309
311
  if (!reason) return { planned: null, reason: "plan is current" };
310
312
  if (!waitingThreads(s).length) return { planned: null, reason: "nothing waits on the human" };
313
+ const basis = planBasis(s, now);
314
+ if (basis.length > PLAN_BASIS_MAX) {
315
+ const why = `${JSON.parse(basis).asks.length} asks exceed the plan basis limit`;
316
+ log?.warn?.(`dash plan: skipped, ${why}`);
317
+ return { planned: null, reason: why };
318
+ }
311
319
  let plan;
312
320
  try {
313
321
  const cards = planCards(s, { now, sizes });
@@ -318,7 +326,7 @@ export async function runPlan(hub, { generate, decisions = "", sizes = {}, now =
318
326
  return { planned: null, reason: String(err?.message ?? err) };
319
327
  }
320
328
  if (!plan.chunks.length && !plan.later) return { planned: null, reason: "no asks" };
321
- const { id } = await hub.dashPlan(planBasis(s, now), plan);
329
+ const { id } = await hub.dashPlan(basis, plan);
322
330
  log?.log?.(`dash plan: ${id} (${reason}): ${plan.chunks.length} chunks, ${planned(plan).length} rows`);
323
331
  return { planned: id, reason };
324
332
  }
@@ -21,7 +21,7 @@ export type Hub = {
21
21
  dashPlan(basis: string, plan: object): Promise<Ok & { id: string }>;
22
22
  dashEntries(entries: object[], remove?: string[], notice?: Notice | null): Promise<Ok & { entries: DashEntries }>;
23
23
  };
24
- export function createHub(options?: { base?: string; agent?: string; fetchImpl?: typeof fetch }): Hub;
24
+ export function createHub(options?: { base?: string; agent?: string; fetchImpl?: typeof fetch; log?: Pick<Console, "log"> }): Hub;
25
25
  export const POST_MAX_BYTES: number;
26
26
  export const POSTS_PER_COMMIT: number;
27
27
  export function toPosts(notices: string[]): string[];
package/schedules/hub.mjs CHANGED
@@ -8,7 +8,7 @@
8
8
  import { createHash } from "node:crypto";
9
9
  import { registryBase, registryFetch } from "../registry-fetch.mjs";
10
10
 
11
- export function createHub({ base = registryBase(), agent = "main", fetchImpl = fetch } = {}) {
11
+ export function createHub({ base = registryBase(), agent = "main", fetchImpl = fetch, log = console } = {}) {
12
12
  const call = async (path, init = {}) => {
13
13
  const res = await registryFetch(path, { ...init, headers: { "content-type": "application/json", ...(init.headers ?? {}) } }, { base, fetchImpl, deadlineMs: 10_000 });
14
14
  const text = await res.text();
@@ -45,7 +45,10 @@ export function createHub({ base = registryBase(), agent = "main", fetchImpl = f
45
45
  track: async (id, fn) => {
46
46
  const started = await call(`${statePath(id).slice(0, -"/state".length)}/runs`, { method: "POST", body: "{}" }).catch(() => null);
47
47
  if (!started?.ok) return fn();
48
- if (started.body.paused) return;
48
+ if (started.body.paused) {
49
+ log.log(`schedule ${agent}/${id} skipped: paused`);
50
+ return;
51
+ }
49
52
  run = { id, run: started.body.run };
50
53
  const end = (error) => call(`${statePath(id).slice(0, -"/state".length)}/runs/${encodeURIComponent(run.run)}/end`, { method: "POST", body: JSON.stringify(error ? { error: error.slice(0, 2000) } : {}) }).catch(() => null);
51
54
  try {