@ours.network/fleet 2.4.3 → 2.5.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 (96) hide show
  1. package/README.md +29 -32
  2. package/contrib/.claude-plugin/marketplace.json +1 -1
  3. package/contrib/claude-native/hooks/register.js +108 -31
  4. package/dist/agent-ours/mcp-endpoint.d.ts +3 -0
  5. package/dist/agent-ours/mcp-endpoint.js +3 -0
  6. package/dist/agent-ours/service.d.ts +3 -0
  7. package/dist/agent-ours/service.js +19 -2
  8. package/dist/application/conversation-history.js +2 -2
  9. package/dist/application/fleet-query-service.js +6 -3
  10. package/dist/application/native-claude-conversation.js +13 -2
  11. package/dist/application/native-conversation.d.ts +5 -0
  12. package/dist/application/native-conversation.js +30 -5
  13. package/dist/application/native-conversations.d.ts +3 -0
  14. package/dist/application/native-conversations.js +2 -0
  15. package/dist/application/role-creation-service.js +0 -3
  16. package/dist/application/session-control.d.ts +3 -0
  17. package/dist/application/session-control.js +5 -0
  18. package/dist/application/types.d.ts +5 -0
  19. package/dist/build-info.json +4 -4
  20. package/dist/cli.js +2 -3
  21. package/dist/config.d.ts +9 -2
  22. package/dist/config.js +15 -4
  23. package/dist/docs.d.ts +5 -7
  24. package/dist/docs.js +38 -46
  25. package/dist/doctor.js +4 -6
  26. package/dist/file-delivery/store.d.ts +12 -0
  27. package/dist/file-delivery/store.js +24 -2
  28. package/dist/fleet-command-audit.js +3 -2
  29. package/dist/fleet-proxy.js +0 -1
  30. package/dist/harness/hermes-permissions.js +1 -1
  31. package/dist/harness/hermes-session.js +0 -1
  32. package/dist/init-wizard.js +2 -2
  33. package/dist/lifecycle-summary.d.ts +3 -2
  34. package/dist/lifecycle-summary.js +2 -3
  35. package/dist/native-participation-cli.js +55 -10
  36. package/dist/native-participation.d.ts +174 -0
  37. package/dist/native-participation.js +67 -0
  38. package/dist/notifications/status-producer.d.ts +37 -0
  39. package/dist/notifications/status-producer.js +146 -0
  40. package/dist/permissions.d.ts +2 -3
  41. package/dist/permissions.js +3 -3
  42. package/dist/preset-migration.js +12 -0
  43. package/dist/rooms-tasks/cli.js +2 -6
  44. package/dist/rooms-tasks/deletion.js +3 -0
  45. package/dist/rooms-tasks/member-overrides.d.ts +2 -1
  46. package/dist/rooms-tasks/member-overrides.js +1 -4
  47. package/dist/rooms-tasks/task-contributions.d.ts +15 -0
  48. package/dist/rooms-tasks/task-contributions.js +13 -2
  49. package/dist/runner.js +24 -8
  50. package/dist/session/acp.d.ts +9 -29
  51. package/dist/session/acp.js +31 -308
  52. package/dist/session/codex-app-server.d.ts +9 -6
  53. package/dist/session/codex-app-server.js +19 -58
  54. package/dist/session/control.d.ts +5 -0
  55. package/dist/session/control.js +19 -3
  56. package/dist/session/conversation-types.d.ts +3 -2
  57. package/dist/session/status-notice.d.ts +24 -0
  58. package/dist/session/status-notice.js +38 -0
  59. package/dist/session/types.d.ts +2 -0
  60. package/dist/spawn.d.ts +1 -2
  61. package/dist/spawn.js +2 -6
  62. package/dist/statuses/permission-projection.d.ts +53 -0
  63. package/dist/statuses/permission-projection.js +317 -0
  64. package/dist/statuses/status-answers.d.ts +31 -0
  65. package/dist/statuses/status-answers.js +85 -0
  66. package/dist/statuses/status-feed.d.ts +85 -0
  67. package/dist/statuses/status-feed.js +122 -0
  68. package/dist/statuses/status-kinds.d.ts +15 -0
  69. package/dist/statuses/status-kinds.js +12 -0
  70. package/dist/statuses/status-ledger.d.ts +21 -0
  71. package/dist/statuses/status-ledger.js +80 -0
  72. package/dist/statuses/status-routes.d.ts +43 -0
  73. package/dist/statuses/status-routes.js +140 -0
  74. package/dist/statuses/status-store.d.ts +257 -0
  75. package/dist/statuses/status-store.js +605 -0
  76. package/dist/statuses/status-tools.d.ts +21 -0
  77. package/dist/statuses/status-tools.js +126 -0
  78. package/dist/supervisor/manager.js +11 -0
  79. package/dist/web/resource-views.d.ts +3 -1
  80. package/dist/web/resource-views.js +6 -2
  81. package/dist/web/runtime.js +21 -0
  82. package/dist/web/server.js +15 -0
  83. package/docs/acp-files.md +9 -7
  84. package/docs/native-session-participation.md +14 -0
  85. package/docs/validation/managed-cli-permissions.md +1 -1
  86. package/examples/fleet/agents/Alice.yaml +1 -1
  87. package/examples/fleet/agents/FleetCoordinator.yaml +1 -1
  88. package/examples/fleet.yaml +0 -1
  89. package/package.json +2 -2
  90. package/presets/fleet/agent_templates/Critic.yaml +1 -1
  91. package/presets/fleet/agent_templates/Developer.yaml +1 -1
  92. package/presets/fleet/agent_templates/Engineer.yaml +1 -1
  93. package/presets/fleet/agent_templates/LocalCoordinator.yaml +1 -1
  94. package/presets/fleet/agents/FleetCoordinator.yaml +1 -1
  95. package/presets/fleet.yaml +1 -1
  96. package/presets/manifest.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import { ConversationObservation } from './conversation-observation.js';
2
2
  import { recordSessionOwnership } from './session-ownership.js';
3
3
  import { appendTaskCreated } from './task-notice.js';
4
+ import { appendStatusNotices } from './status-notice.js';
4
5
  import { createHash, randomUUID } from 'node:crypto';
5
6
  import { existsSync, readFileSync, writeFileSync } from 'node:fs';
6
7
  import { isAbsolute, join, resolve } from 'node:path';
@@ -10,8 +11,6 @@ import { SessionEvents } from './events.js';
10
11
  import { memberAuthority, memberBindings, pendingInventory, takeBatch, refuseAtRelease, RELEASE_GUARD_REFUSED, } from './prompt-batch.js';
11
12
  import { CodexAppServerTransport } from './codex-app-server-transport.js';
12
13
  import { CODEX_APP_SERVER_CANCEL_DEADLINE_EXCEEDED, SessionControlError, sessionBackendCapabilities, turnResult, } from './types.js';
13
- const PERMISSION_TIMEOUT_MS = 10 * 60_000;
14
- const CONTROLLER_GRACE_MS = 12_000;
15
14
  const INTERRUPT_SETTLE_MS = 15_000;
16
15
  const INTERRUPT_TERMINATE_GRACE_MS = 5_000;
17
16
  const TERMINAL_RECONCILE_QUIET_MS = 2_000;
@@ -159,8 +158,6 @@ export class CodexAppServerSession {
159
158
  /** Admitted prompt → the turn that carries it, while that turn is open. */
160
159
  sharedTurns = new Map();
161
160
  activeTurn;
162
- controllerCount = 0;
163
- controllerGrace;
164
161
  interruptForceKill;
165
162
  terminalReconcile;
166
163
  terminalReconcileInFlight = false;
@@ -404,8 +401,6 @@ export class CodexAppServerSession {
404
401
  if (!pending || !pending.options.some(option => option.optionId === optionId))
405
402
  return false;
406
403
  this.pendingPermissions.delete(permissionId);
407
- if (pending.expiry)
408
- clearTimeout(pending.expiry);
409
404
  const decision = optionId === 'allow_once' ? 'accept'
410
405
  : optionId === 'allow_session' ? 'acceptForSession'
411
406
  : optionId === 'cancel' ? 'cancel' : 'decline';
@@ -420,36 +415,17 @@ export class CodexAppServerSession {
420
415
  }
421
416
  eventsSince(seq) { return this.events.since(seq); }
422
417
  subscribe(listener) { return this.events.subscribe(listener); }
423
- setControllerAttached(attached) {
424
- const before = this.controllerCount;
425
- this.controllerCount = Math.max(0, this.controllerCount + (attached ? 1 : -1));
426
- if (attached) {
427
- if (this.controllerGrace)
428
- clearTimeout(this.controllerGrace);
429
- this.controllerGrace = undefined;
430
- }
431
- else if (before > 0 && this.controllerCount === 0 && this.pendingPermissions.size) {
432
- this.controllerGrace = setTimeout(() => {
433
- this.controllerGrace = undefined;
434
- if (this.controllerCount || this.options.permissions.unattended !== 'deny')
435
- return;
436
- for (const [id, pending] of [...this.pendingPermissions])
437
- this.autoResolvePermission(id, pending, 'permissions.unattended=deny', 'the last attached controller disconnected and the grace period expired');
438
- }, this.options.controllerGraceMs ?? CONTROLLER_GRACE_MS);
439
- this.controllerGrace.unref?.();
440
- }
441
- }
418
+ /** A pending permission request never depends on an attached controller: it waits for the Owner (D6). */
419
+ setControllerAttached(_attached) { }
442
420
  exitResult() { return this.exit ?? this.transport.exitResult(); }
443
421
  async close() {
444
422
  if (this.closing)
445
423
  return;
446
424
  this.closing = true;
447
- if (this.controllerGrace)
448
- clearTimeout(this.controllerGrace);
449
425
  this.clearInterruptForceKill();
450
426
  this.cancelTerminalReconciliation();
451
427
  for (const [id, pending] of [...this.pendingPermissions])
452
- this.autoResolvePermission(id, pending, undefined, 'the session closed');
428
+ this.endPermission(id, pending, 'the session closed while this request was pending');
453
429
  if (this.activeTurn)
454
430
  this.finishTurn('failed', 'Codex app-server session closed');
455
431
  this.readiness = 'failed';
@@ -465,6 +441,7 @@ export class CodexAppServerSession {
465
441
  return this.activeTurn && this.threadId ? { sessionGeneration: this.sessionGeneration, acpSessionId: this.threadId, promptId: this.activeTurn.promptId } : undefined;
466
442
  }
467
443
  recordTaskCreated(binding, notice) { appendTaskCreated(this.conversation, binding, notice); }
444
+ recordStatusNotices(entries) { return appendStatusNotices(this.conversation, { sessionGeneration: this.sessionGeneration, acpSessionId: this.threadId }, entries); }
468
445
  conversationPage(request = {}) {
469
446
  const floor = Number(this.conversationStartCursor ?? 0);
470
447
  const requested = Number(request.after ?? 0);
@@ -958,6 +935,10 @@ export class CodexAppServerSession {
958
935
  const active = this.activeTurn;
959
936
  if (!active)
960
937
  return;
938
+ // A request still pending when its turn really ends (completion, interrupt, failure) ends with it: recorded as
939
+ // cancelled, never as anyone's answer (D6). Settled while the turn is current so the record names it.
940
+ for (const [id, pending] of [...this.pendingPermissions])
941
+ this.endPermission(id, pending, 'the turn ended while this request was pending');
961
942
  this.cancelTerminalReconciliation();
962
943
  this.clearInterruptForceKill();
963
944
  this.activeTurn = undefined;
@@ -1130,33 +1111,17 @@ export class CodexAppServerSession {
1130
1111
  ...(method === 'item/permissions/requestApproval' && isObject(params.permissions)
1131
1112
  ? { requestedPermissions: params.permissions } : {}),
1132
1113
  };
1133
- // A generic permissions request is an explicit sandbox expansion. Portable
1134
- // `approval=allow` covers native operations inside the declared boundary;
1135
- // it must never silently widen filesystem or network authority.
1136
- if (this.options.permissions.approval === 'allow'
1137
- && method !== 'item/permissions/requestApproval'
1138
- && method !== 'mcpServer/elicitation/request') {
1139
- this.transport.respond(requestId, this.permissionResponse(pending, 'accept'));
1140
- this.resolvePermission(permissionId, pending, 'allowed', 'automatic', 'allow_once', 'permissions.approval=allow', 'the native request is inside the configured Codex boundary');
1141
- return;
1142
- }
1143
- const unattended = this.controllerCount === 0 && !this.controllerGrace
1144
- && this.options.permissions.unattended === 'deny';
1145
- if (this.options.permissions.approval === 'deny' || unattended) {
1146
- this.transport.respond(requestId, this.permissionResponse(pending, 'decline'));
1147
- this.resolvePermission(permissionId, pending, 'denied', 'automatic', 'deny_once', unattended ? 'permissions.unattended=deny' : 'permissions.approval=deny', unattended ? 'no controller is attached' : 'the role denies permission requests');
1148
- return;
1149
- }
1114
+ // D6: Fleet never settles a request Codex raised. `approval` only selects Codex's native approval policy and
1115
+ // sandbox, which decide whether a request is raised at all; every raised one waits for the Owner.
1116
+ // Every other request waits for the Owner, attached console or not, until the turn or session really ends (D6).
1150
1117
  this.readiness = 'awaiting_permission';
1151
- const timeoutMs = this.options.permissionTimeoutMs ?? PERMISSION_TIMEOUT_MS;
1152
- const expiresAt = new Date(Date.now() + timeoutMs).toISOString();
1153
1118
  const title = (method === 'mcpServer/elicitation/request'
1154
1119
  ? `${string(params.serverName) ?? 'MCP'}: ${string(params.message) ?? 'Confirmation requested'}`
1155
1120
  : undefined) ?? string(params.command) ?? string(params.reason)
1156
1121
  ?? (method === 'item/fileChange/requestApproval' ? 'Apply file changes'
1157
1122
  : method === 'item/permissions/requestApproval' ? 'Grant additional permissions'
1158
1123
  : 'Run command');
1159
- const presented = { toolCallId, title, options, expiresAt };
1124
+ const presented = { toolCallId, title, options };
1160
1125
  pending.presented = presented;
1161
1126
  this.pendingPermissions.set(permissionId, pending);
1162
1127
  this.events.emit('permission', {
@@ -1168,10 +1133,6 @@ export class CodexAppServerSession {
1168
1133
  permissionId, promptId: this.activeTurn?.promptId, turnId: this.activeTurn?.promptId,
1169
1134
  toolCallId, payload: presented,
1170
1135
  });
1171
- pending.expiry = setTimeout(() => {
1172
- this.autoResolvePermission(permissionId, pending, undefined, `no decision arrived within ${Math.round(timeoutMs / 1000)}s`);
1173
- }, timeoutMs);
1174
- pending.expiry.unref?.();
1175
1136
  this.observation.publish();
1176
1137
  }
1177
1138
  serverRequestResolved(params) {
@@ -1184,18 +1145,18 @@ export class CodexAppServerSession {
1184
1145
  return;
1185
1146
  const [permissionId, pending] = entry;
1186
1147
  this.pendingPermissions.delete(permissionId);
1187
- if (pending.expiry)
1188
- clearTimeout(pending.expiry);
1189
1148
  this.resolvePermission(permissionId, pending, 'cancelled', 'automatic', undefined, undefined, 'Codex resolved the native server request externally');
1190
1149
  }
1191
- autoResolvePermission(permissionId, pending, policy, reason) {
1150
+ /**
1151
+ * The session is ending with this request still pending: Codex gets a decline so its turn can finish, and the
1152
+ * record says the request ended without anyone's answer (cancelled), never that someone denied it.
1153
+ */
1154
+ endPermission(permissionId, pending, reason) {
1192
1155
  if (this.pendingPermissions.get(permissionId) === pending)
1193
1156
  this.pendingPermissions.delete(permissionId);
1194
- if (pending.expiry)
1195
- clearTimeout(pending.expiry);
1196
1157
  if (this.transport.isAlive())
1197
1158
  this.transport.respond(pending.requestId, this.permissionResponse(pending, 'decline'));
1198
- this.resolvePermission(permissionId, pending, 'denied', 'automatic', 'deny_once', policy, reason);
1159
+ this.resolvePermission(permissionId, pending, 'cancelled', 'automatic', undefined, undefined, reason);
1199
1160
  }
1200
1161
  resolvePermission(permissionId, pending, decision, decisionSource, optionId, policy, reason) {
1201
1162
  if (!this.pendingPermissions.size && this.readiness === 'awaiting_permission')
@@ -17,6 +17,8 @@ export interface ControlRequest {
17
17
  agentHistory?: AgentHistoryQuery;
18
18
  text?: string;
19
19
  expectedSessionGeneration?: string;
20
+ /** Admit only when this supervisor's bound identity CID is this one (`identity_bound_prompts`). */
21
+ expectedIdentityCid?: string;
20
22
  requireIdle?: boolean;
21
23
  promptId?: string;
22
24
  permissionId?: string;
@@ -113,6 +115,7 @@ export declare const controlSocketPath: (stateDir: string) => string;
113
115
  export declare const controlTokenPath: (stateDir: string) => string;
114
116
  /** Private, versioned JSONL control plane for CLI and future console frontends. */
115
117
  export declare class RoleControlServer {
118
+ private readonly stateDir;
116
119
  private readonly session;
117
120
  private readonly log;
118
121
  private readonly server;
@@ -132,6 +135,8 @@ export declare class RoleControlServer {
132
135
  setLayoutControl(handler: (request: LayoutControlRequest) => Promise<unknown>): void;
133
136
  private fleetSpawner?;
134
137
  private fleetAuditor?;
138
+ /** The identity CID this supervisor recorded for its managed bridge, upper-case; undefined when not bound. */
139
+ private boundIdentityCid;
135
140
  constructor(stateDir: string, session: AgentSession, log: (line: string) => void);
136
141
  start(): Promise<void>;
137
142
  close(): Promise<void>;
@@ -110,6 +110,7 @@ function sameToken(actual, supplied) {
110
110
  }
111
111
  /** Private, versioned JSONL control plane for CLI and future console frontends. */
112
112
  export class RoleControlServer {
113
+ stateDir;
113
114
  session;
114
115
  log;
115
116
  server;
@@ -129,7 +130,18 @@ export class RoleControlServer {
129
130
  setLayoutControl(handler) { this.layoutControl = handler; }
130
131
  fleetSpawner;
131
132
  fleetAuditor;
133
+ /** The identity CID this supervisor recorded for its managed bridge, upper-case; undefined when not bound. */
134
+ boundIdentityCid() {
135
+ try {
136
+ const cid = JSON.parse(readFileSync(join(this.stateDir, '.ours-bridge', 'descriptor.json'), 'utf8')).cid;
137
+ return typeof cid === 'string' && /^[A-Fa-f0-9]{64}$/.test(cid) ? cid.toUpperCase() : undefined;
138
+ }
139
+ catch {
140
+ return undefined;
141
+ }
142
+ }
132
143
  constructor(stateDir, session, log) {
144
+ this.stateDir = stateDir;
133
145
  this.session = session;
134
146
  this.log = log;
135
147
  this.socketPath = controlSocketPath(stateDir);
@@ -253,7 +265,7 @@ export class RoleControlServer {
253
265
  ...(this.correspondence ? ['agent_correspondence'] : []),
254
266
  ...(this.session.conversationPage ? ['conversation_v3'] : []),
255
267
  ...this.observationFeatures(),
256
- ...(this.session.submitPromptBrowser ? ['generation_bound_prompts'] : []),
268
+ ...(this.session.submitPromptBrowser ? ['generation_bound_prompts', 'identity_bound_prompts'] : []),
257
269
  ...(this.session.liveVoiceSupported ? ['idle_bound_prompts', 'targeted_voice_interrupt'] : []),
258
270
  ...(this.session.capabilities?.steering ? ['steering'] : []),
259
271
  ...(this.session.capabilities?.permissions ? ['permissions'] : []),
@@ -538,8 +550,8 @@ export class RoleControlServer {
538
550
  after: request.after === undefined ? undefined : String(request.after), limit: request.limit,
539
551
  }),
540
552
  });
541
- // A live conversation view is an attached controller: permission
542
- // requests must reach it instead of the unattended policy.
553
+ // A live conversation view is an attached controller (it can answer
554
+ // permission requests; requests wait for the Owner either way).
543
555
  const controller = request.controller !== false;
544
556
  if (controller)
545
557
  this.session.setControllerAttached(true);
@@ -558,6 +570,10 @@ export class RoleControlServer {
558
570
  throw new SessionControlError('rejected', 'commandId, text, actor and authenticated source are required');
559
571
  if (!this.session.submitPromptBrowser)
560
572
  throw new SessionControlError('rejected', 'browser prompt admission is unavailable for this role');
573
+ // Identity fence, checked by the receiving supervisor right before admission: its own bridge descriptor
574
+ // names the identity this session is bound to now.
575
+ if (request.expectedIdentityCid !== undefined && this.boundIdentityCid() !== request.expectedIdentityCid.toUpperCase())
576
+ throw new SessionControlError('rejected', 'identity_mismatch: this session is bound to a different identity');
561
577
  try {
562
578
  const receipt = await this.session.submitPromptBrowser({
563
579
  commandId: request.commandId, text: request.text,
@@ -1,4 +1,5 @@
1
1
  import type { TaskCreatedNotice } from './task-notice.js';
2
+ import type { StatusLedgerNotice } from './status-notice.js';
2
3
  import type { PromptOrigin, SessionSnapshot, TurnCancellationSource, TurnOutcome } from './types.js';
3
4
  /**
4
5
  * Durable conversation domain schema for managed-session consoles.
@@ -8,7 +9,7 @@ import type { PromptOrigin, SessionSnapshot, TurnCancellationSource, TurnOutcome
8
9
  * file touches the wire: transport updates are reduced into these shapes by a
9
10
  * session adapter, and the store assigns `seq`/`eventId`/timestamps.
10
11
  */
11
- export type ConversationEventKind = 'prompt.admitted' | 'prompt.started' | 'prompt.interrupt_requested' | 'message.chunk' | 'message.replace' | 'thought.chunk' | 'thought.replace' | 'plan.replace' | 'tool.upsert' | 'tool.content_chunk' | 'permission.requested' | 'permission.resolved' | 'file.attached' | 'fleet.task_created' | 'monitor.delivery' | 'usage.updated' | 'turn.state' | 'turn.completed' | 'session.state' | 'session.info' | 'session.ownership' | 'capabilities.updated' | 'error'
12
+ export type ConversationEventKind = 'prompt.admitted' | 'prompt.started' | 'prompt.interrupt_requested' | 'message.chunk' | 'message.replace' | 'thought.chunk' | 'thought.replace' | 'plan.replace' | 'tool.upsert' | 'tool.content_chunk' | 'permission.requested' | 'permission.resolved' | 'file.attached' | 'fleet.task_created' | 'status.published' | 'status.updated' | 'status.answered' | 'status.closed' | 'monitor.delivery' | 'usage.updated' | 'turn.state' | 'turn.completed' | 'session.state' | 'session.info' | 'session.ownership' | 'capabilities.updated' | 'error'
12
13
  /** A well-formed transport update this version cannot represent. Bounded, never a crash. */
13
14
  | 'unsupported';
14
15
  /** Where a conversation record came from. Typed provenance, never prompt text. */
@@ -242,7 +243,7 @@ export interface BoundedJson {
242
243
  }
243
244
  export type ConversationPayload = {
244
245
  attachment: import('../file-delivery/types.js').DeliveredFile;
245
- } | MessageChunkPayload | ThoughtChunkPayload | PlanReplacePayload | ToolUpsertPayload | UsageUpdatedPayload | SessionStatePayload | SessionInfoPayload | SessionOwnershipPayload | CapabilitiesUpdatedPayload | UnsupportedPayload | PromptAdmittedPayload | PromptStartedPayload | PromptInterruptRequestedPayload | PermissionRequestedPayload | PermissionResolvedPayload | TurnStatePayload | TurnCompletedPayload | MonitorDeliveryPayload | SessionLifecyclePayload | ErrorPayload | TaskCreatedNotice;
246
+ } | MessageChunkPayload | ThoughtChunkPayload | PlanReplacePayload | ToolUpsertPayload | UsageUpdatedPayload | SessionStatePayload | SessionInfoPayload | SessionOwnershipPayload | CapabilitiesUpdatedPayload | UnsupportedPayload | PromptAdmittedPayload | PromptStartedPayload | PromptInterruptRequestedPayload | PermissionRequestedPayload | PermissionResolvedPayload | TurnStatePayload | TurnCompletedPayload | MonitorDeliveryPayload | SessionLifecyclePayload | ErrorPayload | TaskCreatedNotice | StatusLedgerNotice;
246
247
  export interface ConversationEventV1 {
247
248
  schemaVersion: 1;
248
249
  roleId: string;
@@ -0,0 +1,24 @@
1
+ import type { ConversationEventStore } from './conversation-store.js';
2
+ export type StatusLedgerKind = 'status.published' | 'status.updated' | 'status.answered' | 'status.closed';
3
+ export declare const STATUS_LEDGER_KINDS: readonly StatusLedgerKind[];
4
+ /** One status change as recorded in its author's conversation. `status` is the status as it was at that change. */
5
+ export interface StatusLedgerNotice {
6
+ /** Stable per change (`<statusId>:published`, `<statusId>:answered:<submissionId>`, ...): appended at most once. */
7
+ key: string;
8
+ statusId: string;
9
+ revision: number;
10
+ status: Record<string, unknown>;
11
+ }
12
+ export interface StatusLedgerEntry {
13
+ kind: StatusLedgerKind;
14
+ notice: StatusLedgerNotice;
15
+ }
16
+ export interface StatusLedgerBinding {
17
+ sessionGeneration: string;
18
+ acpSessionId?: string;
19
+ }
20
+ /**
21
+ * Appends the status changes this conversation does not have yet, in order. Only the role's runner calls this, from
22
+ * the committed status store, never from model output. Returns how many were appended.
23
+ */
24
+ export declare function appendStatusNotices(store: ConversationEventStore, binding: StatusLedgerBinding, entries: StatusLedgerEntry[]): number;
@@ -0,0 +1,38 @@
1
+ export const STATUS_LEDGER_KINDS = ['status.published', 'status.updated', 'status.answered', 'status.closed'];
2
+ /** Keys already in each store; filled by one full scan, then kept current by this module's own appends (single writer). */
3
+ const recorded = new WeakMap();
4
+ function recordedKeys(store) {
5
+ let keys = recorded.get(store);
6
+ if (keys)
7
+ return keys;
8
+ keys = new Set();
9
+ let after;
10
+ do {
11
+ const page = store.page({ after, limit: 1000 });
12
+ for (const event of page.events)
13
+ if (STATUS_LEDGER_KINDS.includes(event.kind))
14
+ keys.add(event.payload.key);
15
+ if (!page.hasMore)
16
+ break;
17
+ after = page.nextCursor;
18
+ } while (after);
19
+ recorded.set(store, keys);
20
+ return keys;
21
+ }
22
+ /**
23
+ * Appends the status changes this conversation does not have yet, in order. Only the role's runner calls this, from
24
+ * the committed status store, never from model output. Returns how many were appended.
25
+ */
26
+ export function appendStatusNotices(store, binding, entries) {
27
+ const keys = recordedKeys(store);
28
+ let appended = 0;
29
+ for (const { kind, notice } of entries) {
30
+ if (keys.has(notice.key))
31
+ continue;
32
+ store.append({ kind, source: 'fleet_lifecycle', sessionGeneration: binding.sessionGeneration,
33
+ ...(binding.acpSessionId ? { acpSessionId: binding.acpSessionId } : {}), payload: notice });
34
+ keys.add(notice.key);
35
+ appended++;
36
+ }
37
+ return appended;
38
+ }
@@ -316,6 +316,8 @@ export interface AgentSession {
316
316
  snapshot(): SessionSnapshot;
317
317
  taskNoticeBinding?(): TaskNoticeBinding | undefined;
318
318
  recordTaskCreated?(binding: TaskNoticeBinding, notice: TaskCreatedNotice): void;
319
+ /** Append the status changes this conversation lacks (the runner's status projection only). Returns how many. */
320
+ recordStatusNotices?(entries: import('./status-notice.js').StatusLedgerEntry[]): number;
319
321
  conversationPage?(request: {
320
322
  after?: string;
321
323
  limit?: number;
package/dist/spawn.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { IsolationConfig } from './isolation/types.js';
2
2
  import type { AgentLoopsConfig } from './loops/config.js';
3
- import { type ApprovalMode, type FilesystemMode, type ResolvedRole, type MonitorConfig, type UnattendedMode, type RoomMemberStartup, type AgentDefinition, type AgentSelection } from './config.js';
3
+ import { type ApprovalMode, type FilesystemMode, type ResolvedRole, type MonitorConfig, type RoomMemberStartup, type AgentDefinition, type AgentSelection } from './config.js';
4
4
  import { type OpsDeps } from './ops.js';
5
5
  import { type CreationDeps, type CreationProvenance } from './creation.js';
6
6
  import './harness/claude-code.js';
@@ -26,7 +26,6 @@ export interface SpawnOpts {
26
26
  coordinator?: string;
27
27
  approval?: ApprovalMode;
28
28
  filesystem?: FilesystemMode;
29
- unattended?: UnattendedMode;
30
29
  /** Typed external monitor configuration used by trusted creation surfaces. */
31
30
  monitorConfig?: Partial<MonitorConfig>;
32
31
  /** Internal, non-sensitive provenance correlation for typed presentation layers. */
package/dist/spawn.js CHANGED
@@ -29,7 +29,7 @@ export function agentDefinitionFromSpawn(o) {
29
29
  if (o.agentDefinition) {
30
30
  if (o.brain !== undefined || o.role !== undefined || o.cwd !== undefined
31
31
  || o.coordinator !== undefined || o.approval !== undefined || o.filesystem !== undefined
32
- || o.unattended !== undefined || o.isolationFile !== undefined || o.monitorConfig !== undefined
32
+ || o.isolationFile !== undefined || o.monitorConfig !== undefined
33
33
  || o.loopsFile !== undefined)
34
34
  throw new Error('canonical agentDefinition conflicts with separate Agent fields');
35
35
  const definition = structuredClone(o.agentDefinition);
@@ -43,10 +43,9 @@ export function agentDefinitionFromSpawn(o) {
43
43
  throw new Error('--role is required (declared ID or inline mapping)');
44
44
  if (!o.brain)
45
45
  throw new Error('--brain is required (declared ID or inline mapping)');
46
- const permissions = o.approval || o.filesystem || o.unattended ? {
46
+ const permissions = o.approval || o.filesystem ? {
47
47
  ...(o.approval ? { approval: o.approval } : {}),
48
48
  ...(o.filesystem ? { filesystem: o.filesystem } : {}),
49
- ...(o.unattended ? { unattended: o.unattended } : {}),
50
49
  } : undefined;
51
50
  return {
52
51
  role: structuredClone(o.role), brain: structuredClone(o.brain),
@@ -132,8 +131,6 @@ export function validateSpawnOpts(o) {
132
131
  throw new Error(`invalid --approval '${o.approval}'; allowed: ask, auto, allow (deprecated alias: deny)`);
133
132
  if (o.filesystem && !['read-only', 'workspace', 'unrestricted'].includes(o.filesystem))
134
133
  throw new Error(`invalid --filesystem '${o.filesystem}'; allowed: read-only, workspace, unrestricted`);
135
- if (o.unattended && !['deny', 'wait'].includes(o.unattended))
136
- throw new Error(`invalid --unattended '${o.unattended}'; allowed: deny, wait`);
137
134
  if (!/^[A-Za-z0-9_-]+$/.test(o.name))
138
135
  throw new Error(`invalid role name '${o.name}'`);
139
136
  if (o.identity && !/^[A-Za-z0-9_-]+$/.test(o.identity))
@@ -213,7 +210,6 @@ function provenanceSettings(o, defaults, resolvedLoops = []) {
213
210
  coordinator: tagged('coordinator', provenanceOf(o.coordinator, undefined, undefined)),
214
211
  approval: tagged('approval', provenanceOf(o.approval, perms.approval, 'ask')),
215
212
  filesystem: tagged('filesystem', provenanceOf(o.filesystem, perms.filesystem, 'workspace')),
216
- unattended: tagged('unattended', provenanceOf(o.unattended, perms.unattended, 'deny')),
217
213
  isolation: o.isolationFile
218
214
  ? { value: 'declared via --isolation-file', source: 'cli' }
219
215
  : { value: defaults.isolation ? 'from fleet defaults' : undefined, source: defaults.isolation ? 'fleet-default' : 'built-in' },
@@ -0,0 +1,53 @@
1
+ import type { ConversationEventV1 } from '../session/conversation-types.js';
2
+ import type { AgentSession } from '../session/types.js';
3
+ import { type StatusAuthorBinding } from './status-store.js';
4
+ export { SESSION_ENDED_REASON } from './status-store.js';
5
+ type ProjectionSession = Pick<AgentSession, 'conversationSnapshot' | 'subscribeConversation'>;
6
+ type PermissionEvent = ConversationEventV1 & {
7
+ permissionId: string;
8
+ };
9
+ type Bindings = Record<string, StatusAuthorBinding & {
10
+ at: string;
11
+ }>;
12
+ /** Missing file: no bindings yet. Unreadable or corrupt: an error, never "empty" (it must not be overwritten). */
13
+ export declare function readBindings(stateDir: string): Bindings;
14
+ /** What the ledger's permission records cover: complete, or which generations may be missing records. */
15
+ export interface PermissionHistory {
16
+ events: PermissionEvent[];
17
+ /** Generations whose records may be incomplete; `all` when the gap cannot be attributed. */
18
+ uncertain: Set<string> | 'all';
19
+ /** Why coverage is incomplete, for the log. */
20
+ gaps: string[];
21
+ }
22
+ /**
23
+ * Every permission record in the role's conversation ledger, all generations, in order. Read-only. Coverage follows
24
+ * the store's own manifest: a generation it lists as failed (an append did not complete) is uncertain; a declared
25
+ * segment that is missing or unreadable, or a malformed record inside a segment, leaves every generation uncertain; a torn or malformed final record (a crash mid-append, or an append in progress)
26
+ * leaves uncertain the generation that wrote the segment's last complete record. Nothing may be inferred from the
27
+ * absence of a record in an uncertain generation.
28
+ */
29
+ export declare function permissionHistory(stateDir: string): PermissionHistory;
30
+ /**
31
+ * Mirrors this role's harness permission requests as `permission` statuses (feed card + one push until resolved).
32
+ * Runs in the role's runner and reads only its own conversation's permission records; it never decides, expires or
33
+ * answers anything (answers use the existing permission route).
34
+ *
35
+ * The role's conversation ledger is the source of truth. Reconciliation reads the whole ledger: every request gets its
36
+ * status with the author and mission bound for its generation; a recorded native resolution is applied as recorded; a
37
+ * request with no resolution from an earlier generation (one runner's session, a new UUID per start, so its in-memory
38
+ * request ended with that process and the route refuses it) is ended — but only from a complete history. Live
39
+ * requests are never ended here.
40
+ *
41
+ * Reconciliation runs at start, and again whenever work is outstanding (a store write failed, or the history or
42
+ * bindings could not be read) and the status store, the conversation ledger or the bindings change — the existing
43
+ * resource observer,
44
+ * no timer — so a request the harness is blocked on still reaches the feed once storage is usable again.
45
+ */
46
+ export declare function startPermissionProjection(session: ProjectionSession, options: {
47
+ stateDir: string;
48
+ binding: () => StatusAuthorBinding | undefined;
49
+ observe?: boolean;
50
+ }, log: (line: string) => void): {
51
+ reconcile(): boolean;
52
+ stop(): void;
53
+ };