@nifrajs/agent-protocol 3.2.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.
@@ -0,0 +1,302 @@
1
+ /**
2
+ * Additive run-lifecycle contracts: content-free run snapshots, evidence-event envelopes, handoff
3
+ * snapshots, feature negotiation, and cursor resume. These layer on top of the orchestration value
4
+ * contracts without changing `AGENT_PROTOCOL_VERSION`, and - like the evidence contract - carry no
5
+ * payload content.
6
+ *
7
+ * Two decoder disciplines live here on purpose:
8
+ * - Transport decoders ({@link parseRunSnapshot}, {@link parseHandoffSnapshot},
9
+ * {@link parseRunPlanRef}, and the envelope of {@link parseRunEvidenceEvent}) are lenient about
10
+ * unknown additive fields so a newer host can add optional metadata without breaking an older
11
+ * client. They still reject any {@link FORBIDDEN_CONTENT_KEYS} so a payload can never ride along.
12
+ * - The evidence sink stays strict: the inner record of a {@link RunEvidenceEvent} is validated by
13
+ * {@link parseRunEvidence}, which accepts only the declared content-free keys.
14
+ */
15
+ import { FORBIDDEN_CONTENT_KEYS, parseRunEvidence, RunContractError, } from "./orchestration.js";
16
+ /** Run-lifecycle contract version. Additive to the session `AGENT_PROTOCOL_VERSION`. */
17
+ export const RUN_LIFECYCLE_VERSION = 1;
18
+ const RUN_LIFECYCLE_STATES = [
19
+ "submitted",
20
+ "running",
21
+ "paused",
22
+ "succeeded",
23
+ "failed",
24
+ "cancelled",
25
+ ];
26
+ const HANDOFF_STATUSES = ["pending", "accepted", "declined"];
27
+ /** The stable dedupe identity for an evidence record. */
28
+ export function evidenceEventId(runId, seq) {
29
+ return `${runId}:${seq}`;
30
+ }
31
+ /**
32
+ * Reconcile requested features against the offered set. A requested feature the host does not offer
33
+ * is reported as unsupported rather than silently dropped, so a client can degrade deliberately.
34
+ */
35
+ export function negotiateFeatures(offered, requested) {
36
+ const offeredSet = new Set(offered);
37
+ const granted = new Set();
38
+ const unsupported = new Set();
39
+ for (const feature of requested) {
40
+ if (offeredSet.has(feature))
41
+ granted.add(feature);
42
+ else
43
+ unsupported.add(feature);
44
+ }
45
+ return {
46
+ granted: Object.freeze([...granted].sort()),
47
+ unsupported: Object.freeze([...unsupported].sort()),
48
+ };
49
+ }
50
+ /** Sentinel cursor meaning "before any record". A fresh subscription passes this or `undefined`. */
51
+ export const CURSOR_BEFORE_ALL = -1;
52
+ /**
53
+ * Resume an ordered, seq-keyed window from a cursor.
54
+ *
55
+ * The window must be sorted by ascending, strictly increasing `seq`. `cursor` is the last seq the
56
+ * client already holds; `undefined` (or {@link CURSOR_BEFORE_ALL}) means the client holds nothing.
57
+ * If the record immediately after the cursor was already evicted from the bounded window, a gap
58
+ * exists and this returns `resync_required` with reason `stale_cursor` rather than silently skipping.
59
+ */
60
+ export function resumeFromCursor(window, cursor) {
61
+ let previous = Number.NEGATIVE_INFINITY;
62
+ for (const entry of window) {
63
+ if (!Number.isSafeInteger(entry.seq) || entry.seq < 0)
64
+ throw new RunContractError("cursor window seq must be a non-negative integer");
65
+ if (entry.seq <= previous)
66
+ throw new RunContractError("cursor window must be sorted by strictly increasing seq");
67
+ previous = entry.seq;
68
+ }
69
+ const from = cursor === undefined ? CURSOR_BEFORE_ALL : cursor;
70
+ if (!Number.isSafeInteger(from) || from < CURSOR_BEFORE_ALL)
71
+ throw new RunContractError("cursor must be a safe integer >= -1");
72
+ if (window.length === 0)
73
+ return {
74
+ status: "ok",
75
+ events: Object.freeze([]),
76
+ nextCursor: Math.max(from, CURSOR_BEFORE_ALL),
77
+ };
78
+ const earliest = window[0].seq;
79
+ const latest = window[window.length - 1].seq;
80
+ // A real cursor whose next record (from + 1) predates our window lost a gap to eviction. A fresh
81
+ // subscriber (CURSOR_BEFORE_ALL) has no continuity expectation and always takes the whole window.
82
+ if (from >= 0 && from + 1 < earliest)
83
+ return { status: "resync_required", reason: "stale_cursor", earliest, latest };
84
+ const events = window.filter((entry) => entry.seq > from);
85
+ const nextCursor = events.length > 0 ? events[events.length - 1].seq : from;
86
+ return { status: "ok", events: Object.freeze(events), nextCursor };
87
+ }
88
+ // ── Decoders ──────────────────────────────────────────────────────────────────────────────────
89
+ const HEX64 = /^[0-9a-f]{64}$/;
90
+ function isRecord(value) {
91
+ return typeof value === "object" && value !== null && !Array.isArray(value);
92
+ }
93
+ function assertNoForbiddenKeys(record, where) {
94
+ for (const key of FORBIDDEN_CONTENT_KEYS) {
95
+ if (key in record)
96
+ throw new RunContractError(`${where} carries forbidden content key '${key}'`);
97
+ }
98
+ }
99
+ function str(record, key, where) {
100
+ const value = record[key];
101
+ if (typeof value !== "string" || value.length === 0)
102
+ throw new RunContractError(`${where}.${key} must be a non-empty string`);
103
+ return value;
104
+ }
105
+ function nonNegInt(record, key, where) {
106
+ const value = record[key];
107
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
108
+ throw new RunContractError(`${where}.${key} must be a non-negative integer`);
109
+ return value;
110
+ }
111
+ /** Decode a content-free plan reference. Lenient about unknown additive keys, never content. */
112
+ export function parseRunPlanRef(value) {
113
+ if (!isRecord(value))
114
+ throw new RunContractError("run plan ref must be an object");
115
+ assertNoForbiddenKeys(value, "run plan ref");
116
+ const digest = str(value, "digest", "run plan ref");
117
+ if (!HEX64.test(digest))
118
+ throw new RunContractError("run plan ref.digest must be sha256 hex");
119
+ return {
120
+ id: str(value, "id", "run plan ref"),
121
+ digest,
122
+ nodeCount: nonNegInt(value, "nodeCount", "run plan ref"),
123
+ };
124
+ }
125
+ function parseCounters(value) {
126
+ if (!isRecord(value))
127
+ throw new RunContractError("run snapshot.counters must be an object");
128
+ assertNoForbiddenKeys(value, "run snapshot.counters");
129
+ return {
130
+ total: nonNegInt(value, "total", "run snapshot.counters"),
131
+ completed: nonNegInt(value, "completed", "run snapshot.counters"),
132
+ failed: nonNegInt(value, "failed", "run snapshot.counters"),
133
+ };
134
+ }
135
+ /**
136
+ * Decode a bounded run snapshot. Forward-compatible: unknown additive fields are ignored so an
137
+ * older client tolerates a newer host. Forbidden content keys are still rejected.
138
+ */
139
+ export function parseRunSnapshot(value) {
140
+ if (!isRecord(value))
141
+ throw new RunContractError("run snapshot must be an object");
142
+ assertNoForbiddenKeys(value, "run snapshot");
143
+ if (value.version !== RUN_LIFECYCLE_VERSION)
144
+ throw new RunContractError(`run snapshot.version must be ${RUN_LIFECYCLE_VERSION}`);
145
+ const state = value.state;
146
+ if (typeof state !== "string" || !RUN_LIFECYCLE_STATES.includes(state))
147
+ throw new RunContractError("run snapshot.state is invalid");
148
+ const cursor = value.cursor;
149
+ if (typeof cursor !== "number" || !Number.isSafeInteger(cursor) || cursor < CURSOR_BEFORE_ALL)
150
+ throw new RunContractError("run snapshot.cursor must be a safe integer >= -1");
151
+ const snapshot = {
152
+ version: RUN_LIFECYCLE_VERSION,
153
+ runId: str(value, "runId", "run snapshot"),
154
+ plan: parseRunPlanRef(value.plan),
155
+ state: state,
156
+ cursor,
157
+ counters: parseCounters(value.counters),
158
+ updatedAt: nonNegInt(value, "updatedAt", "run snapshot"),
159
+ ...(value.failureCode !== undefined
160
+ ? { failureCode: str(value, "failureCode", "run snapshot") }
161
+ : {}),
162
+ };
163
+ return snapshot;
164
+ }
165
+ /**
166
+ * Decode an evidence-event envelope. The envelope is forward-compatible, but the inner record is
167
+ * validated strictly by {@link parseRunEvidence}, and its identity must match `${runId}:${seq}`.
168
+ */
169
+ export function parseRunEvidenceEvent(value) {
170
+ if (!isRecord(value))
171
+ throw new RunContractError("run evidence event must be an object");
172
+ assertNoForbiddenKeys(value, "run evidence event");
173
+ if (value.version !== RUN_LIFECYCLE_VERSION)
174
+ throw new RunContractError(`run evidence event.version must be ${RUN_LIFECYCLE_VERSION}`);
175
+ const evidence = parseRunEvidence(value.evidence);
176
+ const expected = evidenceEventId(evidence.runId, evidence.seq);
177
+ if (value.eventId !== undefined && value.eventId !== expected)
178
+ throw new RunContractError("run evidence event.eventId must match the inner record identity");
179
+ return { version: RUN_LIFECYCLE_VERSION, eventId: expected, evidence };
180
+ }
181
+ /**
182
+ * Decode a handoff snapshot. Forward-compatible about unknown additive fields; forbidden content
183
+ * keys are rejected.
184
+ */
185
+ export function parseHandoffSnapshot(value) {
186
+ if (!isRecord(value))
187
+ throw new RunContractError("handoff snapshot must be an object");
188
+ assertNoForbiddenKeys(value, "handoff snapshot");
189
+ if (value.version !== RUN_LIFECYCLE_VERSION)
190
+ throw new RunContractError(`handoff snapshot.version must be ${RUN_LIFECYCLE_VERSION}`);
191
+ const status = value.status;
192
+ if (typeof status !== "string" || !HANDOFF_STATUSES.includes(status))
193
+ throw new RunContractError("handoff snapshot.status is invalid");
194
+ const snapshot = {
195
+ version: RUN_LIFECYCLE_VERSION,
196
+ runId: str(value, "runId", "handoff snapshot"),
197
+ nodeId: str(value, "nodeId", "handoff snapshot"),
198
+ seq: nonNegInt(value, "seq", "handoff snapshot"),
199
+ from: str(value, "from", "handoff snapshot"),
200
+ to: str(value, "to", "handoff snapshot"),
201
+ status: status,
202
+ ...(value.reason !== undefined ? { reason: str(value, "reason", "handoff snapshot") } : {}),
203
+ };
204
+ return snapshot;
205
+ }
206
+ /**
207
+ * The negotiated command surface for the inbox: a superset of {@link BoundaryOp} plus the read verbs
208
+ * `list` and `inspect`. A host advertises the subset it supports; a client drives only the granted
209
+ * commands. Order here is the canonical advertisement order.
210
+ */
211
+ export const BOUNDARY_COMMANDS = [
212
+ "list",
213
+ "inspect",
214
+ "approve",
215
+ "deny",
216
+ "assign",
217
+ "resolve",
218
+ "expire",
219
+ "cancel",
220
+ ];
221
+ /** True when both coordinates address the same boundary at the same child vector. */
222
+ export function coordinatesMatch(a, b) {
223
+ return (a.runId === b.runId &&
224
+ a.nodeId === b.nodeId &&
225
+ a.capability === b.capability &&
226
+ a.requestId === b.requestId &&
227
+ a.vector === b.vector);
228
+ }
229
+ /** True while `now` is strictly before the coordinate's expiry. At or past expiry fails closed. */
230
+ export function coordinateIsFresh(coordinate, now) {
231
+ return now < coordinate.expiresAt;
232
+ }
233
+ /**
234
+ * Monotonic child-vector check: a newly opened boundary must advance strictly past the run's last
235
+ * allocated vector. A non-advancing vector is a replay and is refused. `last` is `-1` before any
236
+ * boundary has opened for the run.
237
+ */
238
+ export function vectorAdvances(last, next) {
239
+ return Number.isSafeInteger(next) && next > last;
240
+ }
241
+ const APPROVAL_TRANSITIONS = {
242
+ pending: { approve: "approved", deny: "denied", expire: "expired", cancel: "cancelled" },
243
+ approved: {},
244
+ denied: {},
245
+ expired: {},
246
+ cancelled: {},
247
+ };
248
+ const HANDOFF_TRANSITIONS = {
249
+ pending: {
250
+ assign: "assigned",
251
+ accept: "accepted",
252
+ decline: "declined",
253
+ expire: "expired",
254
+ cancel: "cancelled",
255
+ },
256
+ assigned: {
257
+ accept: "accepted",
258
+ decline: "declined",
259
+ resolve: "resolved",
260
+ expire: "expired",
261
+ cancel: "cancelled",
262
+ },
263
+ accepted: { resolve: "resolved", expire: "expired", cancel: "cancelled" },
264
+ declined: {},
265
+ resolved: {},
266
+ expired: {},
267
+ cancelled: {},
268
+ };
269
+ /** The next approval state for an op, or `undefined` when the transition is illegal. */
270
+ export function nextApprovalState(from, op) {
271
+ return APPROVAL_TRANSITIONS[from][op];
272
+ }
273
+ /** The next handoff state for an op, or `undefined` when the transition is illegal. */
274
+ export function nextHandoffState(from, op) {
275
+ return HANDOFF_TRANSITIONS[from][op];
276
+ }
277
+ /** True once a boundary state accepts no further op. */
278
+ export function isTerminalApprovalState(state) {
279
+ return Object.keys(APPROVAL_TRANSITIONS[state]).length === 0;
280
+ }
281
+ /** True once a handoff state accepts no further op. */
282
+ export function isTerminalHandoffState(state) {
283
+ return Object.keys(HANDOFF_TRANSITIONS[state]).length === 0;
284
+ }
285
+ /**
286
+ * Decode a decision coordinate. Content-free: forbidden payload keys are rejected, and only the
287
+ * declared structural fields are read. `vector` and `expiresAt` must be non-negative safe integers.
288
+ */
289
+ export function parseDecisionCoordinate(value) {
290
+ if (!isRecord(value))
291
+ throw new RunContractError("decision coordinate must be an object");
292
+ assertNoForbiddenKeys(value, "decision coordinate");
293
+ return {
294
+ runId: str(value, "runId", "decision coordinate"),
295
+ nodeId: str(value, "nodeId", "decision coordinate"),
296
+ capability: str(value, "capability", "decision coordinate"),
297
+ requestId: str(value, "requestId", "decision coordinate"),
298
+ vector: nonNegInt(value, "vector", "decision coordinate"),
299
+ expiresAt: nonNegInt(value, "expiresAt", "decision coordinate"),
300
+ };
301
+ }
302
+ //# sourceMappingURL=run-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-lifecycle.js","sourceRoot":"","sources":["../src/run-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,GAEjB,MAAM,oBAAoB,CAAA;AAE3B,wFAAwF;AACxF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAU,CAAA;AAW/C,MAAM,oBAAoB,GAAiC;IACzD,WAAW;IACX,SAAS;IACT,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,WAAW;CACZ,CAAA;AAKD,MAAM,gBAAgB,GAA6B,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;AAgEtF,yDAAyD;AACzD,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,GAAW;IACxD,OAAO,GAAG,KAAK,IAAI,GAAG,EAAE,CAAA;AAC1B,CAAC;AAYD;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAA0B,EAC1B,SAA4B;IAE5B,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAA;IACnC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAA;IACjC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAA;IACrC,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;QAChC,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;;YAC5C,WAAW,CAAC,GAAG,CAA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zD,MAAM,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,qBAAqB,CAAC;QACzD,SAAS,EAAE,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,qBAAqB,CAAC;KAChE,CAAA;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@nifrajs/agent-protocol",
3
+ "version": "3.2.0",
4
+ "description": "Small backend-neutral session and event protocol for Nifra coding agents.",
5
+ "keywords": [
6
+ "bun",
7
+ "typescript",
8
+ "nifra",
9
+ "agent",
10
+ "protocol",
11
+ "rpc"
12
+ ],
13
+ "type": "module",
14
+ "main": "./dist/index.js",
15
+ "module": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "bun": "./src/index.ts",
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "src"
27
+ ],
28
+ "sideEffects": false,
29
+ "scripts": {
30
+ "build": "tsc -p tsconfig.build.json && bun run ../../scripts/fix-dts.ts dist"
31
+ },
32
+ "license": "MIT",
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/nifrajs/nifra.git",
39
+ "directory": "packages/agent-protocol"
40
+ },
41
+ "bugs": {
42
+ "url": "https://github.com/nifrajs/nifra/issues"
43
+ },
44
+ "homepage": "https://github.com/nifrajs/nifra#readme"
45
+ }