38 lines
2.0 KiB
Diff
38 lines
2.0 KiB
Diff
diff --git a/packages/bus/src/broker.mjs b/packages/bus/src/broker.mjs
|
|
index 732c7310e..e15d76679 100644
|
|
--- a/packages/bus/src/broker.mjs
|
|
+++ b/packages/bus/src/broker.mjs
|
|
@@ -654,7 +654,7 @@ export class Broker {
|
|
if (!object(args)) fail('invalid-request');
|
|
this.#secretCheck(args);
|
|
return this.#store.transaction(() => {
|
|
- if (s.reader && !['inbox', 'agents', 'tasks', 'trail', 'decisions', 'credentials', 'replies', 'messages'].includes(request.verb))
|
|
+ if (s.reader && !['inbox', 'agents', 'tasks', 'trail', 'decisions', 'credentials', 'replies', 'messages', 'state'].includes(request.verb))
|
|
fail('read-only');
|
|
const result = this.#dispatch(s, request.verb, args);
|
|
this.#secretCheck(result);
|
|
@@ -1086,6 +1086,23 @@ export class Broker {
|
|
this.#agent(s);
|
|
return this.#requirements;
|
|
}
|
|
+ // Row 109 (#1603): what a run needs to know before it plans. The business's launch state with
|
|
+ // the time and id of the event that set it (`allowed`, no time and no id when none has), and
|
|
+ // the open tasks as the tracker snapshot shows them: refs and titles, at most `cap` of them,
|
|
+ // `total` counting every open task. A read for role, reader and human sessions; nothing is stored.
|
|
+ case 'state': {
|
|
+ keys(a, []);
|
|
+ if (!s.human && !s.reader) this.#agent(s);
|
|
+ const set = this.#store.get(
|
|
+ "SELECT id,kind,at FROM events WHERE business=? AND kind IN ('launch.revoked','launch.restored') ORDER BY seq DESC LIMIT 1",
|
|
+ s.business,
|
|
+ );
|
|
+ const open = this.#tasks(s.business, { done: false });
|
|
+ return {
|
|
+ launch: { state: set?.kind === 'launch.revoked' ? 'revoked' : 'allowed', at: set?.at ?? null, event: set?.id ?? null },
|
|
+ tasks: { open: open.tasks.map(({ task_ref, title }) => ({ task_ref, title })), total: open.total },
|
|
+ };
|
|
+ }
|
|
case 'inbox':
|
|
case 'agents':
|
|
case 'tasks':
|