@haywoodmarx/agent-pager 0.1.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.
Files changed (178) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +63 -0
  3. package/dist/src/broker/address.d.ts +49 -0
  4. package/dist/src/broker/address.js +110 -0
  5. package/dist/src/broker/broker.d.ts +665 -0
  6. package/dist/src/broker/broker.js +2270 -0
  7. package/dist/src/broker/database.d.ts +81 -0
  8. package/dist/src/broker/database.js +69 -0
  9. package/dist/src/broker/operator-projection.d.ts +291 -0
  10. package/dist/src/broker/operator-projection.js +722 -0
  11. package/dist/src/broker/protocol.d.ts +237 -0
  12. package/dist/src/broker/protocol.js +311 -0
  13. package/dist/src/broker/schema.d.ts +94 -0
  14. package/dist/src/broker/schema.js +454 -0
  15. package/dist/src/broker/snapshot.d.ts +171 -0
  16. package/dist/src/broker/snapshot.js +78 -0
  17. package/dist/src/configuration-defaults.d.ts +64 -0
  18. package/dist/src/configuration-defaults.js +48 -0
  19. package/dist/src/configuration.d.ts +76 -0
  20. package/dist/src/configuration.js +156 -0
  21. package/dist/src/implementations/claude/environment.d.ts +8 -0
  22. package/dist/src/implementations/claude/environment.js +9 -0
  23. package/dist/src/implementations/claude/gateway-cli.d.ts +2 -0
  24. package/dist/src/implementations/claude/gateway-cli.js +136 -0
  25. package/dist/src/implementations/claude/gateway-identity.d.ts +134 -0
  26. package/dist/src/implementations/claude/gateway-identity.js +103 -0
  27. package/dist/src/implementations/claude/gateway.d.ts +148 -0
  28. package/dist/src/implementations/claude/gateway.js +236 -0
  29. package/dist/src/implementations/claude/instructions.d.ts +33 -0
  30. package/dist/src/implementations/claude/instructions.js +64 -0
  31. package/dist/src/implementations/claude/manifest.d.ts +33 -0
  32. package/dist/src/implementations/claude/manifest.js +108 -0
  33. package/dist/src/implementations/claude/plugin-directory.d.ts +80 -0
  34. package/dist/src/implementations/claude/plugin-directory.js +137 -0
  35. package/dist/src/implementations/claude/session-continuation.d.ts +25 -0
  36. package/dist/src/implementations/claude/session-continuation.js +125 -0
  37. package/dist/src/implementations/claude/session-identity.d.ts +25 -0
  38. package/dist/src/implementations/claude/session-identity.js +31 -0
  39. package/dist/src/implementations/claude/session-start-cli.d.ts +2 -0
  40. package/dist/src/implementations/claude/session-start-cli.js +16 -0
  41. package/dist/src/implementations/claude/socket-delivery.d.ts +52 -0
  42. package/dist/src/implementations/claude/socket-delivery.js +159 -0
  43. package/dist/src/implementations/model.d.ts +162 -0
  44. package/dist/src/implementations/model.js +1 -0
  45. package/dist/src/implementations/opencode/adapter.d.ts +71 -0
  46. package/dist/src/implementations/opencode/adapter.js +94 -0
  47. package/dist/src/implementations/opencode/environment.d.ts +8 -0
  48. package/dist/src/implementations/opencode/environment.js +9 -0
  49. package/dist/src/implementations/opencode/manifest.d.ts +30 -0
  50. package/dist/src/implementations/opencode/manifest.js +93 -0
  51. package/dist/src/implementations/opencode/plugin-api.d.ts +120 -0
  52. package/dist/src/implementations/opencode/plugin-api.js +1 -0
  53. package/dist/src/implementations/opencode/plugin.d.ts +38 -0
  54. package/dist/src/implementations/opencode/plugin.js +303 -0
  55. package/dist/src/implementations/opencode/self-close-tool.d.ts +9 -0
  56. package/dist/src/implementations/opencode/self-close-tool.js +31 -0
  57. package/dist/src/implementations/orca/terminal.d.ts +48 -0
  58. package/dist/src/implementations/orca/terminal.js +154 -0
  59. package/dist/src/implementations/pi/broker-client.d.ts +56 -0
  60. package/dist/src/implementations/pi/broker-client.js +156 -0
  61. package/dist/src/implementations/pi/environment.d.ts +8 -0
  62. package/dist/src/implementations/pi/environment.js +9 -0
  63. package/dist/src/implementations/pi/extension.d.ts +57 -0
  64. package/dist/src/implementations/pi/extension.js +253 -0
  65. package/dist/src/implementations/pi/host-slots.d.ts +18 -0
  66. package/dist/src/implementations/pi/host-slots.js +27 -0
  67. package/dist/src/implementations/pi/manifest.d.ts +11 -0
  68. package/dist/src/implementations/pi/manifest.js +61 -0
  69. package/dist/src/implementations/pi/self-close-tool.d.ts +7 -0
  70. package/dist/src/implementations/pi/self-close-tool.js +27 -0
  71. package/dist/src/implementations/registry.d.ts +47 -0
  72. package/dist/src/implementations/registry.js +157 -0
  73. package/dist/src/implementations/session-key.d.ts +13 -0
  74. package/dist/src/implementations/session-key.js +19 -0
  75. package/dist/src/index.d.ts +27 -0
  76. package/dist/src/index.js +26 -0
  77. package/dist/src/launch/broker-lock.d.ts +257 -0
  78. package/dist/src/launch/broker-lock.js +644 -0
  79. package/dist/src/launch/cli.d.ts +37 -0
  80. package/dist/src/launch/cli.js +317 -0
  81. package/dist/src/launch/environment.d.ts +45 -0
  82. package/dist/src/launch/environment.js +48 -0
  83. package/dist/src/launch/launch.d.ts +235 -0
  84. package/dist/src/launch/launch.js +223 -0
  85. package/dist/src/launch/on-demand.d.ts +202 -0
  86. package/dist/src/launch/on-demand.js +435 -0
  87. package/dist/src/launch/runtime-composition.d.ts +88 -0
  88. package/dist/src/launch/runtime-composition.js +253 -0
  89. package/dist/src/launch/runtime.d.ts +79 -0
  90. package/dist/src/launch/runtime.js +196 -0
  91. package/dist/src/launch/service-system.d.ts +11 -0
  92. package/dist/src/launch/service-system.js +39 -0
  93. package/dist/src/launch/service.d.ts +173 -0
  94. package/dist/src/launch/service.js +492 -0
  95. package/dist/src/launch/skill.d.ts +57 -0
  96. package/dist/src/launch/skill.js +81 -0
  97. package/dist/src/launch/terminal.d.ts +26 -0
  98. package/dist/src/launch/terminal.js +43 -0
  99. package/dist/src/launch/workspace-branch.d.ts +10 -0
  100. package/dist/src/launch/workspace-branch.js +29 -0
  101. package/dist/src/messaging/delivery-client.d.ts +144 -0
  102. package/dist/src/messaging/delivery-client.js +261 -0
  103. package/dist/src/messaging/delivery.d.ts +75 -0
  104. package/dist/src/messaging/delivery.js +22 -0
  105. package/dist/src/messaging/inbox-socket.d.ts +98 -0
  106. package/dist/src/messaging/inbox-socket.js +278 -0
  107. package/dist/src/messaging/mcp.d.ts +53 -0
  108. package/dist/src/messaging/mcp.js +501 -0
  109. package/dist/src/messaging/notifications.d.ts +231 -0
  110. package/dist/src/messaging/notifications.js +489 -0
  111. package/dist/src/messaging/push-delivery.d.ts +77 -0
  112. package/dist/src/messaging/push-delivery.js +187 -0
  113. package/dist/src/messaging/tools.d.ts +11 -0
  114. package/dist/src/messaging/tools.js +102 -0
  115. package/dist/src/messaging/wake.d.ts +23 -0
  116. package/dist/src/messaging/wake.js +39 -0
  117. package/dist/src/operator/agent-projection.d.ts +102 -0
  118. package/dist/src/operator/agent-projection.js +249 -0
  119. package/dist/src/operator/commands.d.ts +50 -0
  120. package/dist/src/operator/commands.js +199 -0
  121. package/dist/src/operator/diagnostics.d.ts +21 -0
  122. package/dist/src/operator/diagnostics.js +22 -0
  123. package/dist/src/operator/protocol.d.ts +511 -0
  124. package/dist/src/operator/protocol.js +49 -0
  125. package/dist/src/operator/repository-system.d.ts +14 -0
  126. package/dist/src/operator/repository-system.js +150 -0
  127. package/dist/src/operator/repository.d.ts +79 -0
  128. package/dist/src/operator/repository.js +72 -0
  129. package/dist/src/operator/traffic-projection.d.ts +19 -0
  130. package/dist/src/operator/traffic-projection.js +229 -0
  131. package/dist/src/operator/transport.d.ts +87 -0
  132. package/dist/src/operator/transport.js +549 -0
  133. package/dist/src/operator/update-store.d.ts +53 -0
  134. package/dist/src/operator/update-store.js +162 -0
  135. package/dist/src/operator/updates.d.ts +94 -0
  136. package/dist/src/operator/updates.js +280 -0
  137. package/dist/src/operator/validation.d.ts +114 -0
  138. package/dist/src/operator/validation.js +916 -0
  139. package/dist/src/shared/guards.d.ts +59 -0
  140. package/dist/src/shared/guards.js +119 -0
  141. package/dist/src/shared/http.d.ts +30 -0
  142. package/dist/src/shared/http.js +50 -0
  143. package/dist/src/shared/row.d.ts +2 -0
  144. package/dist/src/shared/row.js +1 -0
  145. package/dist/src/shared/shell.d.ts +6 -0
  146. package/dist/src/shared/shell.js +8 -0
  147. package/dist/src/tui/actions.d.ts +166 -0
  148. package/dist/src/tui/actions.js +253 -0
  149. package/dist/src/tui/agent-tree.d.ts +125 -0
  150. package/dist/src/tui/agent-tree.js +663 -0
  151. package/dist/src/tui/app.d.ts +38 -0
  152. package/dist/src/tui/app.js +378 -0
  153. package/dist/src/tui/chrome.d.ts +86 -0
  154. package/dist/src/tui/chrome.js +85 -0
  155. package/dist/src/tui/client.d.ts +41 -0
  156. package/dist/src/tui/client.js +279 -0
  157. package/dist/src/tui/composition.d.ts +41 -0
  158. package/dist/src/tui/composition.js +146 -0
  159. package/dist/src/tui/message-views.d.ts +94 -0
  160. package/dist/src/tui/message-views.js +515 -0
  161. package/dist/src/tui/model.d.ts +414 -0
  162. package/dist/src/tui/model.js +758 -0
  163. package/dist/src/tui/presentation.d.ts +350 -0
  164. package/dist/src/tui/presentation.js +541 -0
  165. package/dist/src/tui/production.d.ts +79 -0
  166. package/dist/src/tui/production.js +253 -0
  167. package/dist/src/tui/run-terminal.d.ts +32 -0
  168. package/dist/src/tui/run-terminal.js +54 -0
  169. package/dist/src/tui/runtime.d.ts +113 -0
  170. package/dist/src/tui/runtime.js +189 -0
  171. package/dist/src/tui/theme.d.ts +49 -0
  172. package/dist/src/tui/theme.js +55 -0
  173. package/dist/src/tui/transport.d.ts +31 -0
  174. package/dist/src/tui/transport.js +255 -0
  175. package/dist/src/version.d.ts +11 -0
  176. package/dist/src/version.js +52 -0
  177. package/package.json +142 -0
  178. package/skills/pager/SKILL.md +112 -0
@@ -0,0 +1,511 @@
1
+ import type { AgentId, MessageState } from "../broker/protocol.js";
2
+ /**
3
+ * Identifies the operator wire contract implemented by this process.
4
+ *
5
+ * Every envelope that carries this number is rejected outright when it does not match exactly, so a
6
+ * bump locks out every differently-versioned peer at that boundary immediately. Bump only for a
7
+ * breaking change: one where a peer on the other version would misinterpret data it receives, or
8
+ * must reject data the other version considers valid.
9
+ *
10
+ * Every operator shape is closed by `exactFields` (`src/shared/guards.ts`): it rejects any key outside
11
+ * its permitted set. That makes adding a field to a validated shape breaking in one direction no matter
12
+ * how absence is handled — a consumer built before the field existed rejects a producer's row that now
13
+ * carries it, with "unexpected field". Nothing below excuses that direction; it is a real, if narrow,
14
+ * cost of adding a field, accepted here rather than bumped, because bumping would not remove that one
15
+ * record-shaped rejection — it would only replace it with an earlier, wholesale "incompatible_version"
16
+ * that blocks every exchange between the two peers, including ones neither side's change affects.
17
+ *
18
+ * The other direction — a consumer built after the field existed, reading a producer that never sent
19
+ * it — is safe without a bump, and is the direction the additive-field exception actually covers: adding
20
+ * an optional field is not a breaking change on its own, provided every validator treats the field's
21
+ * absence identically to an explicit wire-level absence marker (`null`, where the field allows one). An
22
+ * older producer's row that never had the key and a newer producer's row that sends it absent must
23
+ * validate identically.
24
+ */
25
+ export declare const OPERATOR_PROTOCOL_VERSION = 2;
26
+ /** Bounds the UTF-8 JSON payload carried by one snapshot transfer. */
27
+ export declare const OPERATOR_SNAPSHOT_TOTAL_LIMIT_BYTES: number;
28
+ /** Selects the raw byte count encoded by every non-final snapshot chunk. */
29
+ export declare const OPERATOR_SNAPSHOT_CHUNK_BYTES: number;
30
+ /** Bounds every newline-delimited server frame after JSON encoding. */
31
+ export declare const OPERATOR_TRANSPORT_FRAME_LIMIT_BYTES: number;
32
+ /** Represents JSON data that is safe to cross the operator boundary. */
33
+ export type OperatorJsonValue = null | boolean | number | string | OperatorJsonValue[] | OperatorJsonObject;
34
+ /** Represents an object whose values are safe to cross the operator boundary. */
35
+ export type OperatorJsonObject = {
36
+ [key: string]: OperatorJsonValue;
37
+ };
38
+ /** Identifies one position in an epoch-scoped operator event stream. */
39
+ export type OperatorCursor = {
40
+ /** Identifies the operator wire contract used at this position. */
41
+ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
42
+ /** Identifies the broker generation that owns the sequence. */
43
+ epoch: string;
44
+ /** Identifies the last event incorporated into local state. */
45
+ sequence: number;
46
+ };
47
+ /** Identifies a repository used only to group operator presentation state. */
48
+ export type OperatorRepository = {
49
+ /** Identifies this presentation projection without granting broker authority. */
50
+ id: string;
51
+ /** Supplies the resolved repository root. */
52
+ rootPath: string;
53
+ /** Names the repository by the shortest trailing path segments no other repository shares. */
54
+ name: string;
55
+ };
56
+ /** Describes whether an agent runs at its repository root or in a linked worktree. */
57
+ export type OperatorWorktree = {
58
+ /** Reports that the agent runs at the repository root. */
59
+ kind: "repository_root";
60
+ /** Prevents a root agent from carrying a second grouping path. */
61
+ path: null;
62
+ } | {
63
+ /** Reports that the agent runs in a linked worktree. */
64
+ kind: "worktree";
65
+ /** Supplies the resolved worktree path shown as agent detail. */
66
+ path: string;
67
+ };
68
+ /** Reports whether an implementation version is available. */
69
+ export type OperatorImplementationVersion = {
70
+ /** Reports that the provider supplied a version. */
71
+ known: true;
72
+ /** Supplies the provider-owned version without interpretation. */
73
+ value: string;
74
+ } | {
75
+ /** Reports that the provider did not supply a version. */
76
+ known: false;
77
+ };
78
+ /** Describes persisted implementation identity and optional installed-provider presentation data. */
79
+ export type OperatorImplementation = {
80
+ /** Reports that the implementation provider is available to the projection boundary. */
81
+ available: true;
82
+ /** Supplies the provider id without closing the protocol over installed implementations. */
83
+ id: string;
84
+ /** Supplies the provider-owned display label. */
85
+ displayName: string;
86
+ /** Reports the persisted implementation version when known. */
87
+ version: OperatorImplementationVersion;
88
+ /** Carries public provider-owned JSON without interpreting its keys or values. */
89
+ metadata: OperatorJsonObject;
90
+ } | {
91
+ /** Reports that no installed provider can supply presentation metadata. */
92
+ available: false;
93
+ /** Preserves a persisted provider id. */
94
+ id: string;
95
+ /** Reports the persisted implementation version when known. */
96
+ version: OperatorImplementationVersion;
97
+ } | {
98
+ /** Reports that no implementation identity was persisted. */
99
+ available: false;
100
+ /** Distinguishes absent identity from an unavailable installed provider. */
101
+ id: null;
102
+ /** Cannot report a version without a persisted implementation identity. */
103
+ version: {
104
+ known: false;
105
+ };
106
+ };
107
+ /** Reports the exhaustive adapter connectivity state exposed to operator consumers. */
108
+ export type OperatorAdapterState = {
109
+ /** Reports an attached adapter with a current lease. */
110
+ state: "connected";
111
+ /** Records the most recent broker observation. */
112
+ lastSeenAt: number;
113
+ } | {
114
+ /** Reports that no active adapter is attached. */
115
+ state: "disconnected";
116
+ /** Records the last observation when one exists. */
117
+ lastSeenAt: number | null;
118
+ } | {
119
+ /** Reports that the selected adapter lease elapsed. */
120
+ state: "expired";
121
+ /** Records the last observation when one exists. */
122
+ lastSeenAt: number | null;
123
+ };
124
+ /** Describes an operator-visible agent without changing broker routing identity. */
125
+ export type OperatorAgent = {
126
+ /** Identifies the durable broker agent. */
127
+ id: AgentId;
128
+ /** Supplies the current routable alias. */
129
+ alias: string;
130
+ /** Lists earlier aliases retained for identity inspection. */
131
+ previousAliases: string[];
132
+ /** Names the workspace half of the address that reaches this agent from anywhere. */
133
+ workspace: string;
134
+ /** Records the durable registration time used for stable ordering. */
135
+ registeredAt: number;
136
+ /** Reports the durable identity lifecycle independently of adapter health. */
137
+ lifecycle: "active" | "terminal" | "reaped";
138
+ /**
139
+ * Records when an operator archived this identity, or null while it is not archived.
140
+ *
141
+ * Archiving does not change the lifecycle: the identity stays resumable, and reattaching under the
142
+ * same session clears this.
143
+ */
144
+ archivedAt: number | null;
145
+ /**
146
+ * Reports whether the recorded workspace path still resolves on the broker's machine.
147
+ *
148
+ * Presentation-only, like the rest of repository grouping: a removed workspace archives its
149
+ * agents in the operator view without changing broker lifecycle, routing, or addressability.
150
+ */
151
+ workspaceAvailable: boolean;
152
+ /** Preserves identities that control broker routing and authorization. */
153
+ brokerIdentity: {
154
+ /** Identifies the broker team. */
155
+ teamId: string;
156
+ /** Identifies the broker workspace. */
157
+ workspaceId: string;
158
+ };
159
+ /** Supplies presentation grouping separately from broker authority. */
160
+ repository: {
161
+ /** Identifies the operator repository projection. */
162
+ repositoryId: string;
163
+ /** Supplies worktree detail without adding another grouping level. */
164
+ worktree: OperatorWorktree;
165
+ };
166
+ /** Reports the selected adapter state exhaustively. */
167
+ adapter: OperatorAdapterState;
168
+ /** Carries open provider identity and public provider-owned metadata. */
169
+ implementation: OperatorImplementation;
170
+ };
171
+ /** Describes retained message content available to the operator. */
172
+ export type OperatorMessageBody = {
173
+ /** Carries the message content. */
174
+ content: OperatorJsonValue;
175
+ /** Carries the exact observer-only representation used by raw-copy actions. */
176
+ rawCopy: string;
177
+ /** Records serialized content size. */
178
+ sizeBytes: number;
179
+ /** Identifies the retained content representation. */
180
+ contentType: string;
181
+ };
182
+ /** Describes one public delivery lifecycle observation. */
183
+ export type OperatorDeliveryLifecycleEntry = {
184
+ /** Identifies this entry within the durable delivery audit. */
185
+ id: number;
186
+ /** Records when the observation occurred. */
187
+ at: number;
188
+ /** Names the broker-owned observation without constraining future providers. */
189
+ type: string;
190
+ /** Carries a delivery state only when the observation established one. */
191
+ state: MessageState | null;
192
+ };
193
+ /** Describes one accepted delivery and its globally ordered traffic position. */
194
+ export type OperatorAcceptedDelivery = {
195
+ /** Distinguishes an accepted delivery from a control audit. */
196
+ kind: "accepted_delivery";
197
+ /** Selects this member unambiguously across the complete traffic union. */
198
+ trafficId: string;
199
+ /** Identifies the durable message. */
200
+ messageId: string;
201
+ /** Orders this row across every traffic kind. */
202
+ trafficPosition: number;
203
+ /** Orders all accepted traffic across both agent directions. */
204
+ acceptedSequence: number;
205
+ /** Identifies the sending agent. */
206
+ fromAgentId: AgentId;
207
+ /** Identifies the resolved recipient agent. */
208
+ toAgentId: AgentId;
209
+ /** Preserves the broker team that authorized the delivery. */
210
+ teamId: string;
211
+ /** Preserves the broker workspace that scoped the delivery. */
212
+ workspaceId: string;
213
+ /** Records durable message acceptance time. */
214
+ acceptedAt: number;
215
+ /** Carries the one-line subject the sender supplied with the message. */
216
+ subject: string;
217
+ /** Carries the sender-supplied message type. */
218
+ type: string;
219
+ /** Reports every reachable durable delivery state. */
220
+ state: MessageState;
221
+ /** Carries public content availability. */
222
+ body: OperatorMessageBody;
223
+ /** Lists ordered public lifecycle observations. */
224
+ lifecycle: OperatorDeliveryLifecycleEntry[];
225
+ };
226
+ /** Describes durable acceptance of an operator ping command without claiming delivery. */
227
+ export type OperatorPingAudit = {
228
+ /** Distinguishes a control audit from peer traffic. */
229
+ kind: "ping_audit";
230
+ /** Selects this member unambiguously across the complete traffic union. */
231
+ trafficId: string;
232
+ /** Identifies the durable audit row. */
233
+ auditId: string;
234
+ /** Orders this row across every traffic kind. */
235
+ trafficPosition: number;
236
+ /** Correlates the accepted command with its body-free wake. */
237
+ controlId: string;
238
+ /** Identifies the requested target. */
239
+ targetAgentId: AgentId;
240
+ /** Identifies the class of actor that requested the control wake. */
241
+ actor: "operator";
242
+ /** Records command acceptance time without implying wake delivery. */
243
+ acceptedAt: number;
244
+ };
245
+ /** One member per durable traffic kind. */
246
+ export type OperatorTraffic = OperatorAcceptedDelivery | OperatorPingAudit;
247
+ /** Represents a complete authoritative operator projection at one cursor. */
248
+ export type OperatorSnapshot = {
249
+ /** Identifies the operator wire contract. */
250
+ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
251
+ /** Identifies the broker generation that produced the snapshot. */
252
+ epoch: string;
253
+ /** Identifies the last event already reflected by this snapshot. */
254
+ cursor: OperatorCursor;
255
+ /** Records when the projection was generated. */
256
+ generatedAt: number;
257
+ /** Lists presentation-only repository projections. */
258
+ repositories: OperatorRepository[];
259
+ /** Lists projected agents. */
260
+ agents: OperatorAgent[];
261
+ /** Lists durable traffic and audit projections. */
262
+ traffic: OperatorTraffic[];
263
+ };
264
+ /** Represents an authoritative state change following an operator snapshot. */
265
+ export type OperatorStateEvent = {
266
+ /** Identifies a repository replacement. */ type: "repository_upserted";
267
+ /** Carries its value. */ repository: OperatorRepository;
268
+ } | {
269
+ /** Identifies a repository removal. */ type: "repository_removed";
270
+ /** Identifies its value. */ repositoryId: string;
271
+ } | {
272
+ type: "agent_upserted"; /** Carries its value. */
273
+ agent: OperatorAgent;
274
+ } | {
275
+ type: "agent_removed"; /** Identifies its value. */
276
+ agentId: AgentId;
277
+ } | {
278
+ /** Identifies a traffic replacement. */ type: "traffic_upserted";
279
+ /** Carries its value. */ traffic: OperatorTraffic;
280
+ } | {
281
+ type: "traffic_removed"; /** Identifies its value. */
282
+ trafficId: string;
283
+ };
284
+ /** Carries one ordered authoritative state event. */
285
+ export type OperatorEventEnvelope = {
286
+ /** Identifies the operator wire contract. */
287
+ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
288
+ /** Identifies the broker generation that emitted the event. */
289
+ epoch: string;
290
+ /** Orders this event monotonically within its epoch. */
291
+ sequence: number;
292
+ /** Carries the authoritative state observation. */
293
+ event: OperatorStateEvent;
294
+ };
295
+ /** Represents an operator request without treating it as authoritative state. */
296
+ export type OperatorCommand = {
297
+ /** Requests a body-free control wake for one agent. */
298
+ type: "ping_agent";
299
+ /** Identifies the target using broker identity, not repository projection. */
300
+ targetAgentId: AgentId;
301
+ } | {
302
+ /** Requests expiry of one accepted delivery. */
303
+ type: "expire_message";
304
+ /** Identifies the broker message to expire. */
305
+ messageId: string;
306
+ } | {
307
+ /** Requests that one agent identity be retired into its repository's archive. */
308
+ type: "archive_agent";
309
+ /** Identifies the target using broker identity, not repository projection. */
310
+ targetAgentId: AgentId;
311
+ };
312
+ /** Carries one versioned operator command request. */
313
+ export type OperatorCommandEnvelope = {
314
+ /** Identifies the operator wire contract. */
315
+ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
316
+ /** Correlates command admission independently from state events. */
317
+ commandId: string;
318
+ /** Records when the operator submitted the command. */
319
+ issuedAt: number;
320
+ /** Carries the requested operation without presentation authority. */
321
+ command: OperatorCommand;
322
+ };
323
+ /**
324
+ * Names every stable category a command rejection can carry.
325
+ *
326
+ * Closed at the wire, so a rejection reason a peer cannot interpret is a validation failure rather
327
+ * than an opaque string the operator is shown verbatim.
328
+ */
329
+ export declare const OPERATOR_REJECTION_REASONS: readonly ["command_id_conflict", "target_unavailable", "conflict", "rejected", "wake_budget", "duplicate_control_id", "pending_control_limit", "admission_in_progress", "internal_error"];
330
+ /** Supplies the stable public category a rejected command reports. */
331
+ export type OperatorRejectionReason = (typeof OPERATOR_REJECTION_REASONS)[number];
332
+ /** Reports command admission separately from authoritative state changes. */
333
+ export type OperatorCommandResult = {
334
+ /** Identifies the operator wire contract. */
335
+ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
336
+ /** Identifies ping command acceptance. */
337
+ type: "ping_accepted";
338
+ /** Reports that the broker accepted the command request. */
339
+ status: "accepted";
340
+ /** Correlates the result with the submitted command. */
341
+ commandId: string;
342
+ /** Records broker acceptance time. */
343
+ acceptedAt: number;
344
+ /** Correlates the durable ping audit and body-free wake. */
345
+ controlId: string;
346
+ } | {
347
+ /** Identifies the operator wire contract. */
348
+ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
349
+ /** Identifies message-expiry command acceptance. */
350
+ type: "expiry_accepted";
351
+ /** Reports that the broker accepted the command request. */
352
+ status: "accepted";
353
+ /** Correlates the result with the submitted command. */
354
+ commandId: string;
355
+ /** Records broker acceptance time. */
356
+ acceptedAt: number;
357
+ } | {
358
+ /** Identifies the operator wire contract. */
359
+ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
360
+ /** Identifies agent-archive command acceptance. */
361
+ type: "archive_accepted";
362
+ /** Reports that the broker accepted the command request. */
363
+ status: "accepted";
364
+ /** Correlates the result with the submitted command. */
365
+ commandId: string;
366
+ /** Records broker acceptance time. */
367
+ acceptedAt: number;
368
+ } | {
369
+ /** Identifies the operator wire contract. */
370
+ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
371
+ /** Identifies command rejection before authoritative state changes. */
372
+ type: "command_rejected";
373
+ /** Reports that the broker rejected command admission. */
374
+ status: "rejected";
375
+ /** Correlates the result with the submitted command. */
376
+ commandId: string;
377
+ /** Supplies the stable public rejection category. */
378
+ reason: OperatorRejectionReason;
379
+ };
380
+ /** Narrows one validated command envelope to the selected command member. */
381
+ export type OperatorCommandEnvelopeFor<Type extends OperatorCommand["type"]> = Omit<OperatorCommandEnvelope, "command"> & {
382
+ /** Carries the command member selected by its discriminant. */
383
+ command: Extract<OperatorCommand, {
384
+ type: Type;
385
+ }>;
386
+ };
387
+ /** Correlates a validated result with the only command kind it can answer. */
388
+ export type OperatorCorrelatedCommandResult = {
389
+ /** Carries the originating ping request. */
390
+ command: OperatorCommandEnvelopeFor<"ping_agent">;
391
+ /** Carries ping acceptance or a command-agnostic rejection. */
392
+ result: Extract<OperatorCommandResult, {
393
+ type: "ping_accepted" | "command_rejected";
394
+ }>;
395
+ } | {
396
+ /** Carries the originating expiry request. */
397
+ command: OperatorCommandEnvelopeFor<"expire_message">;
398
+ /** Carries expiry acceptance or a command-agnostic rejection. */
399
+ result: Extract<OperatorCommandResult, {
400
+ type: "expiry_accepted" | "command_rejected";
401
+ }>;
402
+ } | {
403
+ /** Carries the originating archive request. */
404
+ command: OperatorCommandEnvelopeFor<"archive_agent">;
405
+ /** Carries archive acceptance or a command-agnostic rejection. */
406
+ result: Extract<OperatorCommandResult, {
407
+ type: "archive_accepted" | "command_rejected";
408
+ }>;
409
+ };
410
+ /** Classifies one event relative to a consumer cursor without conflating recovery actions. */
411
+ export type OperatorCursorResult = {
412
+ /** Permits applying the next event. */ type: "apply";
413
+ /** Carries the validated event. */ event: OperatorEventEnvelope;
414
+ /** Supplies the next cursor. */ cursor: OperatorCursor;
415
+ } | {
416
+ /** Reports an event already incorporated. */ type: "duplicate";
417
+ /** Records the duplicate position. */ sequence: number;
418
+ } | {
419
+ /** Reports a missing position before this event. */ type: "gap";
420
+ /** Records the required next position. */ expectedSequence: number;
421
+ /** Records the received position. */ receivedSequence: number;
422
+ } | {
423
+ /** Reports an event from another broker generation. */ type: "stale_epoch";
424
+ /** Identifies the current generation. */ currentEpoch: string;
425
+ /** Identifies the received generation. */ receivedEpoch: string;
426
+ } | {
427
+ /** Reports an unsupported event contract. */ type: "incompatible_version";
428
+ /** Identifies the supported contract. */ supportedVersion: typeof OPERATOR_PROTOCOL_VERSION;
429
+ /** Records the received version. */ receivedVersion: number;
430
+ };
431
+ /** Carries one client-to-server request on the operator transport. */
432
+ export type OperatorTransportRequest = {
433
+ /** Identifies a subscription request. */ type: "subscribe";
434
+ /** Identifies the operator wire contract requested by the client. */ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
435
+ /** Resumes strictly after this position, or requests a fresh snapshot when absent. */ cursor?: OperatorCursor;
436
+ } | {
437
+ /** Identifies a liveness acknowledgement. */ type: "ack";
438
+ /** Identifies the operator wire contract used by the client. */ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
439
+ /** Reports the latest server position observed by the client. */ cursor: OperatorCursor;
440
+ } | {
441
+ /** Identifies a non-authoritative operator command request. */ type: "command";
442
+ /** Identifies the operator wire contract used by the client. */ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
443
+ /** Carries one validated command envelope. */ command: OperatorCommandEnvelope;
444
+ };
445
+ /** Explains why a client must replace rather than incrementally advance local state. */
446
+ export type OperatorResyncReason = "cursor_gap" | "epoch_changed" | "stream_unavailable";
447
+ /** Bounds the public text carried by one diagnostic field. */
448
+ export declare const OPERATOR_DIAGNOSTIC_TEXT_LIMIT = 160;
449
+ /** Classifies how much attention one diagnostic asks of an operator. */
450
+ export type OperatorDiagnosticSeverity = "info" | "warning" | "error";
451
+ /**
452
+ * Reports one operator-visible condition without carrying message or identity content.
453
+ *
454
+ * Diagnostics explain why the surface looks as it does. They never carry a body or an alias.
455
+ */
456
+ export type OperatorDiagnostic = {
457
+ /** Records when the condition was observed. */
458
+ at: number;
459
+ /** Distinguishes a condition the broker reported from one the client observed itself. */
460
+ origin: "broker" | "client";
461
+ /** Classifies the attention the condition asks for. */
462
+ severity: OperatorDiagnosticSeverity;
463
+ /** Names the subsystem the condition arose in. */
464
+ scope: string;
465
+ /** States the condition in operator-facing language. */
466
+ summary: string;
467
+ };
468
+ /** Carries one bounded server-to-client operator transport frame. */
469
+ export type OperatorTransportFrame = {
470
+ /** Begins an authoritative snapshot transfer. */ type: "snapshot_begin";
471
+ /** Identifies the operator wire contract used by the transfer. */
472
+ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
473
+ /** Distinguishes cold hydration from required state replacement. */ mode: "initial" | "replacement";
474
+ /** Identifies the position reflected by the transferred snapshot. */ cursor: OperatorCursor;
475
+ /** Identifies the byte-to-text encoding used by ordered chunks. */ encoding: "base64";
476
+ /** Records the UTF-8 JSON byte count before base64 encoding. */ totalBytes: number;
477
+ /** Records the exact number of ordered chunk frames that follow. */ chunkCount: number;
478
+ } | {
479
+ /** Carries one ordered section of an active snapshot transfer. */ type: "snapshot_chunk";
480
+ /** Identifies the operator wire contract used by the transfer. */
481
+ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
482
+ /** Identifies this zero-based chunk position. */ index: number;
483
+ /** Carries base64-encoded raw snapshot bytes. */ data: string;
484
+ } | {
485
+ /** Completes an authoritative snapshot transfer. */ type: "snapshot_end";
486
+ /** Identifies the operator wire contract used by the transfer. */
487
+ protocolVersion: typeof OPERATOR_PROTOCOL_VERSION;
488
+ /** Repeats the transferred snapshot position for atomic validation. */ cursor: OperatorCursor;
489
+ /** Repeats the raw byte count for atomic validation. */ totalBytes: number;
490
+ /** Repeats the ordered chunk count for atomic validation. */ chunkCount: number;
491
+ } | {
492
+ /** Carries one strictly ordered authoritative change. */ type: "event";
493
+ /** Supplies the durable event envelope. */ envelope: OperatorEventEnvelope;
494
+ } | {
495
+ /** Requires replacement before any further event can be applied. */ type: "resync_required";
496
+ /** Identifies the recovery condition without advancing the client cursor. */ reason: OperatorResyncReason;
497
+ } | {
498
+ /** Reports that the requested wire contract cannot be served. */ type: "incompatible_version";
499
+ /** Identifies the only contract supported by this server. */ supportedVersion: typeof OPERATOR_PROTOCOL_VERSION;
500
+ /** Records the client-requested contract. */ receivedVersion: number;
501
+ } | {
502
+ /** Reports one operator-visible condition alongside the authoritative stream. */ type: "diagnostic";
503
+ /** Carries the content-free diagnostic. */ diagnostic: OperatorDiagnostic;
504
+ } | {
505
+ /** Requests a bounded client liveness acknowledgement. */ type: "heartbeat";
506
+ /** Supplies the latest durable position known to the server. */ cursor: OperatorCursor;
507
+ /** Records when the server emitted this liveness probe. */ sentAt: number;
508
+ } | {
509
+ /** Carries one correlated non-authoritative command outcome. */ type: "command_result";
510
+ /** Carries the validated command result. */ result: OperatorCommandResult;
511
+ };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Identifies the operator wire contract implemented by this process.
3
+ *
4
+ * Every envelope that carries this number is rejected outright when it does not match exactly, so a
5
+ * bump locks out every differently-versioned peer at that boundary immediately. Bump only for a
6
+ * breaking change: one where a peer on the other version would misinterpret data it receives, or
7
+ * must reject data the other version considers valid.
8
+ *
9
+ * Every operator shape is closed by `exactFields` (`src/shared/guards.ts`): it rejects any key outside
10
+ * its permitted set. That makes adding a field to a validated shape breaking in one direction no matter
11
+ * how absence is handled — a consumer built before the field existed rejects a producer's row that now
12
+ * carries it, with "unexpected field". Nothing below excuses that direction; it is a real, if narrow,
13
+ * cost of adding a field, accepted here rather than bumped, because bumping would not remove that one
14
+ * record-shaped rejection — it would only replace it with an earlier, wholesale "incompatible_version"
15
+ * that blocks every exchange between the two peers, including ones neither side's change affects.
16
+ *
17
+ * The other direction — a consumer built after the field existed, reading a producer that never sent
18
+ * it — is safe without a bump, and is the direction the additive-field exception actually covers: adding
19
+ * an optional field is not a breaking change on its own, provided every validator treats the field's
20
+ * absence identically to an explicit wire-level absence marker (`null`, where the field allows one). An
21
+ * older producer's row that never had the key and a newer producer's row that sends it absent must
22
+ * validate identically.
23
+ */
24
+ export const OPERATOR_PROTOCOL_VERSION = 2;
25
+ /** Bounds the UTF-8 JSON payload carried by one snapshot transfer. */
26
+ export const OPERATOR_SNAPSHOT_TOTAL_LIMIT_BYTES = 512 * 1_024 * 1_024;
27
+ /** Selects the raw byte count encoded by every non-final snapshot chunk. */
28
+ export const OPERATOR_SNAPSHOT_CHUNK_BYTES = 48 * 1_024;
29
+ /** Bounds every newline-delimited server frame after JSON encoding. */
30
+ export const OPERATOR_TRANSPORT_FRAME_LIMIT_BYTES = 128 * 1_024;
31
+ /**
32
+ * Names every stable category a command rejection can carry.
33
+ *
34
+ * Closed at the wire, so a rejection reason a peer cannot interpret is a validation failure rather
35
+ * than an opaque string the operator is shown verbatim.
36
+ */
37
+ export const OPERATOR_REJECTION_REASONS = [
38
+ "command_id_conflict",
39
+ "target_unavailable",
40
+ "conflict",
41
+ "rejected",
42
+ "wake_budget",
43
+ "duplicate_control_id",
44
+ "pending_control_limit",
45
+ "admission_in_progress",
46
+ "internal_error",
47
+ ];
48
+ /** Bounds the public text carried by one diagnostic field. */
49
+ export const OPERATOR_DIAGNOSTIC_TEXT_LIMIT = 160;
@@ -0,0 +1,14 @@
1
+ import { type RepositoryProjectionDependencies } from "./repository.js";
2
+ /** Bounds each Git command's complete captured output. */
3
+ export declare const REPOSITORY_GIT_OUTPUT_LIMIT = 65536;
4
+ /** Configures the concrete Git process boundary. */
5
+ export type SystemRepositoryProjectionOptions = {
6
+ /** Selects the Git executable without mutating process PATH. */
7
+ gitExecutable?: string;
8
+ };
9
+ /**
10
+ * Compose production filesystem and Git discovery adapters.
11
+ * @param options - Optional executable override for isolated verification.
12
+ * @returns Dependencies whose process execution is isolated from pure projection logic.
13
+ */
14
+ export declare function createSystemRepositoryProjectionDependencies(options?: SystemRepositoryProjectionOptions): RepositoryProjectionDependencies;