@ours.network/fleet 2.5.0 → 2.5.2
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/build-info.json +4 -4
- package/dist/notifications/fleet-producer.js +40 -7
- package/dist/notifications/status-producer.js +8 -1
- package/dist/statuses/status-feed.d.ts +11 -1
- package/dist/statuses/status-feed.js +41 -9
- package/dist/statuses/status-ledger.js +1 -1
- package/dist/statuses/status-routes.js +8 -4
- package/dist/statuses/status-store.d.ts +10 -2
- package/dist/statuses/status-store.js +36 -1
- package/dist/statuses/status-tools.js +1 -1
- package/package.json +2 -2
package/dist/build-info.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.5.
|
|
3
|
-
"buildId": "
|
|
4
|
-
"commit": "
|
|
2
|
+
"version": "2.5.2",
|
|
3
|
+
"buildId": "99bb2c93b092",
|
|
4
|
+
"commit": "5a4d50b97af7d0b31122fd68baf7a59531330417",
|
|
5
5
|
"dirty": false,
|
|
6
|
-
"builtAt": "2026-12-
|
|
6
|
+
"builtAt": "2026-12-03T23:45:00.114Z",
|
|
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
|
-
|
|
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 (!
|
|
320
|
-
|
|
321
|
-
|
|
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() {
|
|
@@ -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
|
-
/**
|
|
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
|
-
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
131
|
+
let from = 0;
|
|
105
132
|
if (options.after !== undefined) {
|
|
106
|
-
|
|
107
|
-
if (!
|
|
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
|
|
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
|
|
162
|
-
* (`resolve`: answered, closed or superseded). Owner answers, seen changes and
|
|
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
|
-
|
|
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
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ours.network/fleet",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
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",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@agentclientprotocol/sdk": "^1.3.0",
|
|
52
52
|
"@fastify/websocket": "^11.2.0",
|
|
53
53
|
"@ours.network/cli": "5.1.0",
|
|
54
|
-
"@ours.network/mcp": "2.0.
|
|
54
|
+
"@ours.network/mcp": "2.0.7",
|
|
55
55
|
"@ours.network/sdk": "6.1.0",
|
|
56
56
|
"commander": "^12.1.0",
|
|
57
57
|
"fastify": "^5.5.0",
|