@ours.network/fleet 2.5.1 → 2.5.3

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/briefing.js CHANGED
@@ -17,6 +17,30 @@ function selfReminderGuidance(role) {
17
17
  'work, and is not a hard real-time alarm). Full contract: the "Self-reminders" section of `ours-fleet docs`.',
18
18
  ];
19
19
  }
20
+ /**
21
+ * Every managed agent: anything that needs the Owner's attention or decision is a native status by default, so it
22
+ * reaches the Owner's feed and devices and an answer comes back typed. Internal coordination stays internal.
23
+ */
24
+ function ownerAttentionGuidance(role) {
25
+ if (!managedSession(role))
26
+ return [];
27
+ return [
28
+ '', '## Owner attention and decisions: statuses first',
29
+ 'When something needs the Owner, publish a native status with `fleet_status_publish` instead of asking or',
30
+ 'reporting in plain text. This is the default for every Owner-directed request in this role, a mission, a',
31
+ 'persistent session or a standalone one:',
32
+ '- `question` for any choice or input you need: `single` or `multi` with 2–12 options (mark one `recommended`',
33
+ ' when you have a view; `allowOther` for free text), or `text`. This includes choosing a room template, team,',
34
+ ' preset or option. Make it self-contained; the Owner may read only the card. The answer arrives in your',
35
+ ' session as a message; until then, do not repeat the question in chat.',
36
+ '- `alert` when you are blocked or something failed and the Owner must look.',
37
+ '- `update` for a result the Owner would want to know without asking.',
38
+ 'Keep the existing channels for everything else: answer the Owner in the same session or chat they wrote in,',
39
+ 'and keep routine coordination (room messages, peer DMs and mission records) internal. Do not mirror a',
40
+ 'status into chat, and do not post routine steps as statuses. If the status tools are unavailable, say so and',
41
+ 'ask in your normal channel.',
42
+ ];
43
+ }
20
44
  /** Public, deployed app help; its source is ours-app `web/public/llms.txt`. */
21
45
  export const APP_GUIDE_URL = 'https://app.ours.network/llms.txt';
22
46
  /** Every role answers app questions from the public guide; standalone roles also learn the demo recipe. */
@@ -80,8 +104,9 @@ function taskReviewGuidance(taskId) {
80
104
  'Preparing it grants no lifecycle authority: move the task to Review only when your instructions grant',
81
105
  'that; otherwise hand the complete package to your authorized coordinator.',
82
106
  'To review holds one current request for human review or decision: that final package, or one specific',
83
- 'Owner decision that blocks the work. It is not agent review or an evidence archive. After the Owner',
84
- 'answers in the room, its writer clears it: read `revision` with `fleet_task_review_show`, then call',
107
+ 'Owner decision that blocks the work (ask the decision itself as a `question` status, below; To review',
108
+ 'holds its supporting material). It is not agent review or an evidence archive. After the Owner',
109
+ 'answers, its writer clears it: read `revision` with `fleet_task_review_show`, then call',
85
110
  '`fleet_task_review_clear` with `expected_revision` (or',
86
111
  `\`ours-fleet task review-package ${taskId} --clear --expected-revision <n>\`); a conflict means newer content.`,
87
112
  'The task **Progress** log (`fleet_task_progress_list`) holds significant verified facts for the Owner, at',
@@ -197,6 +222,7 @@ function generateRoomMemberBriefing(role, v, opts, prefix) {
197
222
  L.push('assistant response for the Fleet supervisor, then stop BLOCKED.');
198
223
  }
199
224
  L.push(...taskReviewGuidance(startup.task_id));
225
+ L.push(...ownerAttentionGuidance(role));
200
226
  L.push(...selfReminderGuidance(role));
201
227
  L.push(...appHelpGuidance(false));
202
228
  L.push('', '## Durable log');
@@ -267,7 +293,8 @@ export function generateBriefing(role, v, opts) {
267
293
  L.push(' Answer through your normal final assistant response; fleet extracts and');
268
294
  L.push(' deterministically routes that final response back to the owner.');
269
295
  if (role.owner_channel.agent) {
270
- L.push(`- For any non-final owner message—progress, blocker, suggestion, or proactive note—`);
296
+ L.push('- A question, decision, blocker or result for the Owner is a status (see "Owner attention" below).');
297
+ L.push(` For any other non-final owner message—progress or a proactive note—`);
271
298
  L.push(` call **${v.sendTool}** to contact **${role.owner_channel.identity}** from your normal`);
272
299
  L.push(` bound **${id}** identity. Do not include a task/request ID, phase, reply reference,`);
273
300
  L.push(' or routing command. Fleet accepts only your configured authenticated CID and forwards');
@@ -350,6 +377,7 @@ export function generateBriefing(role, v, opts) {
350
377
  L.push('assigned → nudge; actively working → do nothing, and do not mistake a long turn for a');
351
378
  L.push('stall. Escalate over ours messaging only when you cannot resolve it yourself.');
352
379
  }
380
+ L.push(...ownerAttentionGuidance(role));
353
381
  L.push(...selfReminderGuidance(role));
354
382
  L.push(...appHelpGuidance(true));
355
383
  L.push('', '## Durable log');
@@ -1,9 +1,9 @@
1
1
  {
2
- "version": "2.5.1",
3
- "buildId": "829a402b8c23",
4
- "commit": "ef9d71da74c27e115901bd6484ff9e6444e05991",
2
+ "version": "2.5.3",
3
+ "buildId": "7563dc5cb40c",
4
+ "commit": "f734f722dc569749e894a9614dae21a8b0a7dffc",
5
5
  "dirty": false,
6
- "builtAt": "2026-12-03T22:02:43.169Z",
6
+ "builtAt": "2026-12-04T09:44:30.479Z",
7
7
  "capabilities": [
8
8
  "service.refresh-v1",
9
9
  "managed-cli.codex-reasoning-effort-v1",
@@ -5,6 +5,30 @@ import { basename, join, relative, resolve, sep } from 'node:path';
5
5
  import { createHash } from 'node:crypto';
6
6
  import { NotificationOutbox } from './outbox.js';
7
7
  import { readSessionOwnership, validOwnerTask } from '../session/session-ownership.js';
8
+ import { sessionIdentityCid } from '../statuses/status-ledger.js';
9
+ import { listAuthorStatuses } from '../statuses/status-store.js';
10
+ /** The Owner's answer to a status, delivered as a prompt (`answerCommandId`): the status, not the turn, notifies. */
11
+ const STATUS_ANSWER_COMMAND = /^status-answer-[0-9a-f]{40}$/;
12
+ /**
13
+ * The turn published a question: that status is the turn's notification (it stays unread until the Owner answers and
14
+ * is resolved then), so no separate "agent completed" row is created for it that answering could never clear. (A turn
15
+ * with a permission request can only complete after the Owner's decision, so its completion is new news and stays.) A
16
+ * role's session runs one turn at a time and only that session publishes as the role's bound identity, so a question
17
+ * by that identity created while the turn ran (from its start to its completion) is the turn's own.
18
+ */
19
+ function turnAskedQuestion(roleDir, from, to) {
20
+ if (!from)
21
+ return false;
22
+ const cid = sessionIdentityCid(roleDir);
23
+ if (!cid)
24
+ return false;
25
+ try {
26
+ return listAuthorStatuses(cid).some(status => status.kind === 'question' && status.created_at >= from && status.created_at <= to);
27
+ }
28
+ catch {
29
+ return false;
30
+ }
31
+ }
8
32
  const MAX_BINDINGS = 16;
9
33
  const BATCH_BYTES = 256 * 1024;
10
34
  const TURN_ROLES = 4, TURN_MS = 8;
@@ -240,7 +264,8 @@ export class FleetNotificationProducer {
240
264
  outbox.saveCheckpoint({ segment: segments[0], offset: 0, prompts: [] });
241
265
  }
242
266
  const saved = outbox.checkpoint;
243
- const current = { ...saved, prompts: [...saved.prompts], messages: { ...saved.messages }, bindings: { ...saved.bindings } };
267
+ const current = { ...saved, prompts: [...saved.prompts], messages: { ...saved.messages }, bindings: { ...saved.bindings },
268
+ admitted: { ...saved.admitted } };
244
269
  let index = segments.indexOf(current.segment);
245
270
  if (index < 0) {
246
271
  this.warn('Notification ledger segment unavailable; checkpoint retained');
@@ -295,10 +320,15 @@ export class FleetNotificationProducer {
295
320
  const prompt = `${event.sessionGeneration}:${event.promptId}`;
296
321
  if (event.kind === 'session.ownership')
297
322
  bind(current.bindings, event);
298
- if (event.kind === 'prompt.admitted' && event.promptId && ['browser', 'owner_admin_console', 'owner_channel'].includes(event.source ?? '')) {
299
- if (!current.prompts.includes(prompt))
323
+ if (event.kind === 'prompt.admitted' && event.promptId && ['browser', 'owner_admin_console', 'owner_channel'].includes(event.source ?? '')
324
+ && !STATUS_ANSWER_COMMAND.test(event.commandId ?? '')) {
325
+ if (!current.prompts.includes(prompt)) {
300
326
  current.prompts.push(prompt);
327
+ current.admitted[prompt] = event.at;
328
+ }
301
329
  }
330
+ if (event.kind === 'prompt.started' && current.prompts.includes(prompt))
331
+ current.admitted[prompt] = event.at;
302
332
  if (['message.chunk', 'message.replace'].includes(event.kind) && event.promptId && event.messageId && current.prompts.includes(prompt))
303
333
  current.messages[prompt] = event.messageId;
304
334
  if (event.kind === 'turn.completed' && event.promptId && current.prompts.includes(prompt)) {
@@ -316,13 +346,16 @@ export class FleetNotificationProducer {
316
346
  current.bindings[event.sessionGeneration] = sidecar[event.sessionGeneration];
317
347
  }
318
348
  const binding = Object.hasOwn(current.bindings, event.sessionGeneration) ? { taskId: current.bindings[event.sessionGeneration] } : {};
319
- if (!outbox.enqueue(`${roleId}:${event.sessionGeneration}:${event.seq}`, { ...binding, anchor: { kind: 'fleet-message', messageId: current.messages[prompt] ?? event.promptId } })) {
320
- blocked = true;
321
- break;
349
+ if (!turnAskedQuestion(roleDir, current.admitted[prompt], event.at)) {
350
+ if (!outbox.enqueue(`${roleId}:${event.sessionGeneration}:${event.seq}`, { ...binding, anchor: { kind: 'fleet-message', messageId: current.messages[prompt] ?? event.promptId } })) {
351
+ blocked = true;
352
+ break;
353
+ }
354
+ admitted = true;
322
355
  }
323
- admitted = true;
324
356
  current.prompts = current.prompts.filter(p => p !== prompt);
325
357
  delete current.messages[prompt];
358
+ delete current.admitted[prompt];
326
359
  }
327
360
  current.offset += end - position + 1;
328
361
  position = end + 1;
@@ -1,6 +1,6 @@
1
1
  import { observeFleetResources } from '../application/resource-observer.js';
2
2
  import { statusKind } from '../statuses/status-kinds.js';
3
- import { acknowledgeStatusNotification, pendingStatusNotifications, statusesDir, } from '../statuses/status-store.js';
3
+ import { acknowledgeStatusNotification, pendingStatusNotifications, resolveSeenNotifications, statusesDir, } from '../statuses/status-store.js';
4
4
  /** The notification service's own bounds, in UTF-16 code units (it checks `string.length`). Previews only: the card keeps the full text. */
5
5
  export const PUSH_TITLE_MAX = 160, PUSH_BODY_MAX = 200;
6
6
  /** Clip to `max` UTF-16 units, never splitting a code point; the ellipsis counts toward the limit. */
@@ -63,6 +63,13 @@ export class StatusNotificationProducer {
63
63
  void this.drain();
64
64
  }
65
65
  }, this.shutdown.signal);
66
+ // Rows of statuses seen before seeing read their notification: resolved once, by their own event IDs.
67
+ try {
68
+ resolveSeenNotifications();
69
+ }
70
+ catch {
71
+ this.warn('Seen status notifications not linked yet; they are linked at the next start');
72
+ }
66
73
  void this.drain();
67
74
  }
68
75
  drain() {
@@ -119,6 +119,11 @@ const UNATTENDED_RETIREMENT_FINGERPRINTS = Object.freeze({
119
119
  'agent_templates/Engineer.yaml': ['9b784c8be4cc1dec96501351c645124da862ebf603ea251851c23cae1725e463'],
120
120
  'agents/FleetCoordinator.yaml': ['fd72781a253afb356be34a287a09965e1bb6855954fe4d1b398b54269a1d5cd6'],
121
121
  });
122
+ // The packaged revision-14 Coordinator before it asked the Owner for the room template as a native
123
+ // question status. Untouched copies adopt the current text; edited ones stay.
124
+ const STATUS_FIRST_FINGERPRINTS = Object.freeze({
125
+ 'roles/Coordinator.yaml': ['8343197182c7396479f45ed5e0d49bda86c2da4c6959a1d8dc68cf143d0769cf'],
126
+ });
122
127
  const CURRENT_ROLE_DEFAULTS = new Set([
123
128
  'roles/Coordinator.yaml', 'roles/LocalCoordinator.yaml', 'roles/Developer.yaml', 'roles/Critic.yaml',
124
129
  'roles/Engineer.yaml',
@@ -254,6 +259,7 @@ export function migratePackagedRoleDefaults(configuration, options = {}, hooks =
254
259
  ...Object.keys(REVIEW_PACKAGE_FINGERPRINTS),
255
260
  ...Object.keys(CURRENT_REQUEST_FINGERPRINTS),
256
261
  ...Object.keys(UNATTENDED_RETIREMENT_FINGERPRINTS),
262
+ ...Object.keys(STATUS_FIRST_FINGERPRINTS),
257
263
  ]);
258
264
  for (const relative of known) {
259
265
  const path = join(root, relative);
@@ -273,6 +279,7 @@ export function migratePackagedRoleDefaults(configuration, options = {}, hooks =
273
279
  ...(REVIEW_PACKAGE_FINGERPRINTS[relative] ?? []),
274
280
  ...(CURRENT_REQUEST_FINGERPRINTS[relative] ?? []),
275
281
  ...(UNATTENDED_RETIREMENT_FINGERPRINTS[relative] ?? []),
282
+ ...(STATUS_FIRST_FINGERPRINTS[relative] ?? []),
276
283
  ].some(expected => expected !== undefined && actual === expected);
277
284
  if (recognized)
278
285
  (CURRENT_ROLE_DEFAULTS.has(relative) ? replacements : removals).push(path);
@@ -63,10 +63,18 @@ export declare function markFeedItemSeen(statusId: string, revision: number): {
63
63
  seen: boolean;
64
64
  };
65
65
  export declare function feedItem(status: StatusRecord): FeedItem;
66
- /** One chronological page; `after` continues after a returned status ID. Totals cover the whole scope. */
66
+ /**
67
+ * One chronological page; `after` continues after a returned status ID. Totals cover the whole scope.
68
+ *
69
+ * `eligible` lists only what still needs the Owner: unseen informational statuses and open questions or pending
70
+ * requests (both stay unseen until resolved). Totals, `opens_at` and pages then cover that set, so a feed opens at its
71
+ * first item and counts it, never the history already read. `after` stays a position in the whole scope: a status that
72
+ * became seen (and left the eligible set) still continues the listing after it.
73
+ */
67
74
  export declare function listFeed(scope: FeedScope, options?: {
68
75
  after?: string;
69
76
  limit?: number;
77
+ eligible?: boolean;
70
78
  }): {
71
79
  items: FeedItem[];
72
80
  next_after: string | null;
@@ -82,4 +90,6 @@ export declare function listFeed(scope: FeedScope, options?: {
82
90
  * signals a change to an item further back (for example its answer delivery), and a client reloads what it shows.
83
91
  */
84
92
  scope_version: string;
93
+ /** Present when the listing holds only the eligible set. */
94
+ eligible?: true;
85
95
  };
@@ -10,7 +10,7 @@
10
10
  * status, else the newest (caught up).
11
11
  */
12
12
  import { createHash } from 'node:crypto';
13
- import { acknowledgeTaskProgress, acknowledgeTaskReview, TaskStateError } from '../rooms-tasks/task-state.js';
13
+ import { acknowledgeTaskProgress, acknowledgeTaskReview, getTask, TaskStateError } from '../rooms-tasks/task-state.js';
14
14
  import { allTaskContributions } from '../rooms-tasks/task-contributions.js';
15
15
  import { canonicalCid, listAllStatuses, markStatusSeen, statusAwaitsOwner, statusSeen, StatusError } from './status-store.js';
16
16
  export const FEED_PAGE_MAX = 200;
@@ -38,7 +38,27 @@ export function feedScope(query) {
38
38
  }
39
39
  throw new StatusError('invalid_request', 'scope must be global, agent or mission');
40
40
  }
41
- const inScope = (scope) => (item) => scope.kind === 'global' || (scope.kind === 'agent' ? item.author?.identity_cid === scope.identityCid : item.task_id === scope.taskId);
41
+ /**
42
+ * Which items a scope holds. A mission holds every status bound to it plus the statuses its current members published
43
+ * outside any mission (for example a permanent member's permission request), never their other missions' statuses.
44
+ */
45
+ function inScope(scope) {
46
+ if (scope.kind === 'global')
47
+ return () => true;
48
+ if (scope.kind === 'agent')
49
+ return item => item.author?.identity_cid === scope.identityCid;
50
+ const members = missionMembers(scope.taskId);
51
+ return item => item.task_id === scope.taskId
52
+ || (item.task_id === undefined && !item.projected && !!item.author?.identity_cid && members.has(item.author.identity_cid));
53
+ }
54
+ function missionMembers(taskId) {
55
+ try {
56
+ return new Set((getTask(taskId).member_roles ?? []).flatMap(member => member.identity_cid ? [member.identity_cid.toUpperCase()] : []));
57
+ }
58
+ catch {
59
+ return new Set();
60
+ }
61
+ }
42
62
  /** A mission Progress entry or To Review package as a projected status; its ID and revision follow the task record. */
43
63
  export function projectedItem(item) {
44
64
  const review = item.kind === 'review';
@@ -92,25 +112,36 @@ export function feedItem(status) {
92
112
  created_at: status.created_at, updated_at: status.updated_at,
93
113
  };
94
114
  }
95
- /** One chronological page; `after` continues after a returned status ID. Totals cover the whole scope. */
115
+ /**
116
+ * One chronological page; `after` continues after a returned status ID. Totals cover the whole scope.
117
+ *
118
+ * `eligible` lists only what still needs the Owner: unseen informational statuses and open questions or pending
119
+ * requests (both stay unseen until resolved). Totals, `opens_at` and pages then cover that set, so a feed opens at its
120
+ * first item and counts it, never the history already read. `after` stays a position in the whole scope: a status that
121
+ * became seen (and left the eligible set) still continues the listing after it.
122
+ */
96
123
  export function listFeed(scope, options = {}) {
97
124
  const limit = options.limit ?? 100;
98
125
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > FEED_PAGE_MAX)
99
126
  throw new StatusError('invalid_request', `limit must be 1-${FEED_PAGE_MAX}`);
100
127
  // One chronological sequence of native statuses and projected mission items.
101
128
  const projected = allTaskContributions();
102
- const all = [...listAllStatuses().map(feedItem), ...projected.items.map(projectedItem)].filter(inScope(scope))
129
+ const scoped = [...listAllStatuses().map(feedItem), ...projected.items.map(projectedItem)].filter(inScope(scope))
103
130
  .sort((a, b) => a.created_at.localeCompare(b.created_at) || a.status_id.localeCompare(b.status_id));
104
- let start = 0;
131
+ let from = 0;
105
132
  if (options.after !== undefined) {
106
- start = all.findIndex(item => item.status_id === options.after) + 1;
107
- if (!start)
133
+ from = scoped.findIndex(item => item.status_id === options.after) + 1;
134
+ if (!from)
108
135
  throw new StatusError('invalid_request', 'after must be a status ID in this scope');
109
136
  }
110
- const page = all.slice(start, start + limit);
137
+ const listed = scoped.map((item, position) => ({ item, position })).filter(({ item }) => !options.eligible || !item.seen);
138
+ const all = listed.map(({ item }) => item);
139
+ // The first listed item at or after the position following `after` in the whole scope.
140
+ const start = listed.findIndex(({ position }) => position >= from);
141
+ const page = start < 0 ? [] : all.slice(start, start + limit);
111
142
  const unseen = all.filter(item => !item.seen);
112
143
  return {
113
- items: page, next_after: start + page.length < all.length ? page.at(-1).status_id : null,
144
+ items: page, next_after: start >= 0 && start + page.length < all.length ? page.at(-1).status_id : null,
114
145
  total: all.length, unseen: unseen.length,
115
146
  open_questions: all.filter(item => item.awaits_owner).map(item => item.status_id),
116
147
  opens_at: unseen[0]?.status_id ?? all.at(-1)?.status_id ?? null,
@@ -118,5 +149,6 @@ export function listFeed(scope, options = {}) {
118
149
  caught_up: unseen.length === 0 && projected.unavailable === 0,
119
150
  unavailable_tasks: projected.unavailable,
120
151
  scope_version: createHash('sha256').update(JSON.stringify(all)).digest('hex').slice(0, 32),
152
+ ...(options.eligible ? { eligible: true } : {}),
121
153
  };
122
154
  }
@@ -14,7 +14,7 @@ export function sessionIdentityCid(stateDir) {
14
14
  }
15
15
  /** The status as an agent's conversation shows it: what any surface shows, without Owner-private or internal fields. */
16
16
  export function ledgerStatus(status) {
17
- const { version: _version, request_key: _key, seen_revision: _seen, notification_events: _events, ...visible } = status;
17
+ const { version: _version, request_key: _key, seen_revision: _seen, seen_notified: _notified, notification_events: _events, ...visible } = status;
18
18
  return visible;
19
19
  }
20
20
  /**
@@ -37,7 +37,7 @@ export function statusFleetError(error) {
37
37
  }
38
38
  /** The stored envelope plus the derived Owner state the cards render. */
39
39
  export const publicStatus = (status) => {
40
- const { version: _version, request_key: _key, seen_revision: _seen, notification_events: _events, attachment_stores: _stores, ...visible } = status;
40
+ const { version: _version, request_key: _key, seen_revision: _seen, seen_notified: _notified, notification_events: _events, attachment_stores: _stores, ...visible } = status;
41
41
  return { ...visible, seen: statusSeen(status), awaits_owner: statusAwaitsOwner(status) };
42
42
  };
43
43
  /** Owner answer and Try again routes for Fleet agents' questions. Both require an authenticated, CSRF-checked browser. */
@@ -66,12 +66,16 @@ export function registerStatusAnswerRoutes(app, services, auth, digestKey, answe
66
66
  });
67
67
  app.get('/api/v1/statuses', async (request) => {
68
68
  auth.authenticate(request);
69
- const { scope, agent, task, after, limit } = request.query;
70
- const extra = Object.keys(request.query).filter(key => !['scope', 'agent', 'task', 'after', 'limit'].includes(key));
69
+ const { scope, agent, task, after, limit, filter } = request.query;
70
+ const extra = Object.keys(request.query).filter(key => !['scope', 'agent', 'task', 'after', 'limit', 'filter'].includes(key));
71
71
  if (extra.length)
72
72
  throw new FleetError('invalid_request', `unexpected query ${extra[0]}`);
73
+ // `filter=eligible`: only unseen statuses and open questions or requests, counted and paged as their own set.
74
+ if (filter !== undefined && filter !== 'eligible')
75
+ throw new FleetError('invalid_request', 'filter must be eligible');
73
76
  try {
74
- return listFeed(feedScope({ scope, agent, task }), { ...(after === undefined ? {} : { after }), ...(limit === undefined ? {} : { limit: Number(limit) }) });
77
+ return listFeed(feedScope({ scope, agent, task }), { ...(after === undefined ? {} : { after }), ...(limit === undefined ? {} : { limit: Number(limit) }),
78
+ ...(filter === 'eligible' ? { eligible: true } : {}) });
75
79
  }
76
80
  catch (error) {
77
81
  throw statusFleetError(error);
@@ -108,6 +108,8 @@ export interface StatusRecord {
108
108
  answer?: StatusAnswer;
109
109
  /** The last revision the Owner has seen (informational statuses and ended questions only). */
110
110
  seen_revision?: number;
111
+ /** The seen revision whose notification rows were resolved (seen before that link existed: absent). */
112
+ seen_notified?: number;
111
113
  /** A harness permission request, exactly as the harness raised it (kind `permission` only). */
112
114
  permission?: PermissionDetails;
113
115
  /** Pending push work, committed atomically with the change that caused it and removed once the service accepted it. */
@@ -158,8 +160,9 @@ export declare class AlreadyAnsweredError extends StatusError {
158
160
  constructor(status: StatusRecord);
159
161
  }
160
162
  /**
161
- * One push event (`send`, one per publication or material revision) or the end of a pending question's notification
162
- * (`resolve`: answered, closed or superseded). Owner answers, seen changes and closes never push.
163
+ * One push event (`send`, one per publication or material revision) or the end of a status's notification
164
+ * (`resolve`: a question answered, closed or superseded; an update or alert seen). Owner answers, seen changes and
165
+ * closes never push.
163
166
  */
164
167
  export type StatusNotificationEvent = {
165
168
  op: 'send';
@@ -230,6 +233,11 @@ export declare function markStatusSeen(statusId: string, revision: number): {
230
233
  seen: boolean;
231
234
  changed: boolean;
232
235
  };
236
+ /**
237
+ * Statuses seen before seeing read their notification keep an unread row: resolve each one once, by its own event ID
238
+ * (`status:<id>:<revision>`), never by conversation or time. Idempotent; returns how many statuses it linked.
239
+ */
240
+ export declare function resolveSeenNotifications(): number;
233
241
  /** Statuses with push work still pending, oldest first. */
234
242
  export declare function pendingStatusNotifications(): StatusRecord[];
235
243
  /** The service accepted this event: remove it (and only it) from the status. Idempotent. */
@@ -41,6 +41,12 @@ export class AlreadyAnsweredError extends StatusError {
41
41
  const sendEvent = (status) => ({ op: 'send', eventId: `status:${status.status_id}:${status.revision}`, delivery: status.kind === 'question' ? 'until-resolved' : 'inbox' });
42
42
  /** Ending an unanswered open question resolves its pending notification. */
43
43
  const resolveEvents = (status) => status.kind === 'question' && status.state === 'active' && !status.answer ? [{ op: 'resolve', eventId: `status:${status.status_id}:${status.revision}` }] : [];
44
+ /**
45
+ * Resolves for the rows of revisions seen since the last link: every revision may have pushed (one row each); a
46
+ * revision that never did is "event not found". Questions and requests are resolved by their answer or decision.
47
+ */
48
+ const seenEvents = (status, revision) => status.kind === 'question' || status.kind === 'permission' ? []
49
+ : Array.from({ length: Math.max(0, revision - (status.seen_notified ?? 0)) }, (_, index) => ({ op: 'resolve', eventId: `status:${status.status_id}:${(status.seen_notified ?? 0) + index + 1}` }));
44
50
  const withEvents = (status, events) => events.length ? { ...status, notification_events: [...(status.notification_events ?? []), ...events] } : status;
45
51
  const CID = /^[A-F0-9]{64}$/;
46
52
  const STATUS_ID = /^st_[a-z0-9]{8,64}$/;
@@ -441,11 +447,40 @@ export function markStatusSeen(statusId, revision) {
441
447
  const current = readStatus(statusPath(cid, statusId));
442
448
  if (statusAwaitsOwner(current) || revision !== current.revision || (current.seen_revision ?? 0) >= revision)
443
449
  return { status: current, seen: statusSeen(current), changed: false };
444
- const updated = { ...current, seen_revision: revision };
450
+ // Seeing an update or alert in the feed or its session reads its notification too (the service's own row for
451
+ // this status, by its event ID), so the Notifications screen and unread totals follow. Questions and requests are
452
+ // resolved by their answer or decision instead.
453
+ const updated = withEvents({ ...current, seen_revision: revision, seen_notified: revision }, seenEvents(current, revision));
445
454
  writeStatus(updated);
446
455
  return { status: updated, seen: statusSeen(updated), changed: true };
447
456
  });
448
457
  }
458
+ /**
459
+ * Statuses seen before seeing read their notification keep an unread row: resolve each one once, by its own event ID
460
+ * (`status:<id>:<revision>`), never by conversation or time. Idempotent; returns how many statuses it linked.
461
+ */
462
+ export function resolveSeenNotifications() {
463
+ let linked = 0;
464
+ for (const cid of authors()) {
465
+ withSynchronousFileLock(authorLock(cid), () => {
466
+ for (const path of authorStatusFiles(cid)) {
467
+ let current;
468
+ try {
469
+ current = readStatus(path);
470
+ }
471
+ catch {
472
+ continue;
473
+ }
474
+ const seen = current.seen_revision ?? 0;
475
+ if (current.kind === 'question' || current.kind === 'permission' || seen <= (current.seen_notified ?? 0))
476
+ continue;
477
+ writeStatus(withEvents({ ...current, seen_notified: seen }, seenEvents(current, seen)));
478
+ linked++;
479
+ }
480
+ });
481
+ }
482
+ return linked;
483
+ }
449
484
  /** Statuses with push work still pending, oldest first. */
450
485
  export function pendingStatusNotifications() {
451
486
  return listAllStatuses().filter(status => status.notification_events?.length);
@@ -20,7 +20,7 @@ function author(bound) {
20
20
  }
21
21
  /** What the agent sees of its status: the stored envelope. */
22
22
  const publicStatus = (status) => {
23
- const { version: _version, request_key: _key, seen_revision: _seen, notification_events: _events, ...visible } = status;
23
+ const { version: _version, request_key: _key, seen_revision: _seen, seen_notified: _notified, notification_events: _events, ...visible } = status;
24
24
  return visible;
25
25
  };
26
26
  /**
@@ -62,7 +62,8 @@ export function registerStatusTools(server, binding, admit) {
62
62
  server.registerTool('fleet_status_publish', {
63
63
  description: 'Publish ONE self-contained status to the Owner\'s feed and devices: an "update" (progress worth knowing), an "alert" '
64
64
  + '(blocked or failed, needs attention) or a "question" (you need the Owner\'s input). Works with or without a mission. '
65
- + 'Every status is pushed to the Owner, so do not post routine chatter. A question waits for the Owner\'s answer, which is '
65
+ + 'Use it by default for anything that needs the Owner\'s attention or decision (including choosing a template, team or '
66
+ + 'preset), instead of asking in plain text. Every status is pushed to the Owner, so do not post routine chatter. A question waits for the Owner\'s answer, which is '
66
67
  + 'delivered to your session as a message and is readable with fleet_status_get. To replace your own open question, '
67
68
  + 'publish a new question with supersedes. Repeating a call with the same request_key and content returns the original status.',
68
69
  inputSchema: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ours.network/fleet",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "description": "Harness-agnostic fleet of persistent, identity-bound AI agents. Declarative fleet.yaml, managed native/ACP sessions, supervision, and ours.network messaging.",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-Apache-2.0",
@@ -38,7 +38,9 @@ persona: |
38
38
 
39
39
  For every new task:
40
40
  1. Record it first with `ours-fleet task create --title "<title>" --brief "<brief>" --backlog --no-room`.
41
- 2. Ask the owner which room template to use: `single`, `pair`, or `team`.
41
+ 2. Ask the owner which room template to use as a `question` status with `fleet_status_publish`:
42
+ mode `single`, options `single`, `pair` and `team` (mark one `recommended` when you have a
43
+ view), naming the task in the title. Continue when the answer arrives in this session.
42
44
  3. Resolve the exact launch plan without creating the room. Immediately before room creation,
43
45
  state in this conversation that you are about to create the room, listing the task, selected
44
46
  template, every member role and count, and each member's Agent Template,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "preset_revision": 14,
3
+ "preset_revision": 15,
4
4
  "brain_catalog_revision": 5,
5
5
  "description": "ours-fleet standard configuration presets"
6
6
  }