@ours.network/fleet 2.4.4 → 2.5.1

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 (84) hide show
  1. package/README.md +29 -32
  2. package/dist/agent-ours/mcp-endpoint.d.ts +3 -0
  3. package/dist/agent-ours/mcp-endpoint.js +3 -0
  4. package/dist/agent-ours/service.d.ts +3 -0
  5. package/dist/agent-ours/service.js +19 -2
  6. package/dist/application/conversation-history.js +2 -2
  7. package/dist/application/fleet-query-service.js +4 -1
  8. package/dist/application/role-creation-service.js +0 -3
  9. package/dist/application/session-control.d.ts +3 -0
  10. package/dist/application/session-control.js +5 -0
  11. package/dist/application/types.d.ts +5 -0
  12. package/dist/build-info.json +4 -4
  13. package/dist/cli.js +2 -3
  14. package/dist/config.d.ts +9 -2
  15. package/dist/config.js +15 -4
  16. package/dist/docs.d.ts +5 -7
  17. package/dist/docs.js +38 -46
  18. package/dist/doctor.js +4 -6
  19. package/dist/file-delivery/store.d.ts +12 -0
  20. package/dist/file-delivery/store.js +24 -2
  21. package/dist/fleet-command-audit.js +3 -2
  22. package/dist/fleet-proxy.js +0 -1
  23. package/dist/harness/hermes-permissions.js +1 -1
  24. package/dist/harness/hermes-session.js +0 -1
  25. package/dist/init-wizard.js +2 -2
  26. package/dist/lifecycle-summary.d.ts +3 -2
  27. package/dist/lifecycle-summary.js +2 -3
  28. package/dist/notifications/status-producer.d.ts +37 -0
  29. package/dist/notifications/status-producer.js +146 -0
  30. package/dist/permissions.d.ts +2 -3
  31. package/dist/permissions.js +3 -3
  32. package/dist/preset-migration.js +12 -0
  33. package/dist/rooms-tasks/cli.js +2 -6
  34. package/dist/rooms-tasks/deletion.js +3 -0
  35. package/dist/rooms-tasks/member-overrides.d.ts +2 -1
  36. package/dist/rooms-tasks/member-overrides.js +1 -4
  37. package/dist/rooms-tasks/task-contributions.d.ts +15 -0
  38. package/dist/rooms-tasks/task-contributions.js +13 -2
  39. package/dist/runner.js +24 -8
  40. package/dist/session/acp.d.ts +9 -29
  41. package/dist/session/acp.js +31 -308
  42. package/dist/session/codex-app-server.d.ts +9 -6
  43. package/dist/session/codex-app-server.js +19 -58
  44. package/dist/session/control.d.ts +5 -0
  45. package/dist/session/control.js +19 -3
  46. package/dist/session/conversation-types.d.ts +3 -2
  47. package/dist/session/status-notice.d.ts +24 -0
  48. package/dist/session/status-notice.js +38 -0
  49. package/dist/session/types.d.ts +2 -0
  50. package/dist/spawn.d.ts +1 -2
  51. package/dist/spawn.js +2 -6
  52. package/dist/statuses/permission-projection.d.ts +53 -0
  53. package/dist/statuses/permission-projection.js +317 -0
  54. package/dist/statuses/status-answers.d.ts +31 -0
  55. package/dist/statuses/status-answers.js +85 -0
  56. package/dist/statuses/status-feed.d.ts +85 -0
  57. package/dist/statuses/status-feed.js +122 -0
  58. package/dist/statuses/status-kinds.d.ts +15 -0
  59. package/dist/statuses/status-kinds.js +12 -0
  60. package/dist/statuses/status-ledger.d.ts +21 -0
  61. package/dist/statuses/status-ledger.js +80 -0
  62. package/dist/statuses/status-routes.d.ts +43 -0
  63. package/dist/statuses/status-routes.js +140 -0
  64. package/dist/statuses/status-store.d.ts +257 -0
  65. package/dist/statuses/status-store.js +605 -0
  66. package/dist/statuses/status-tools.d.ts +21 -0
  67. package/dist/statuses/status-tools.js +126 -0
  68. package/dist/supervisor/manager.js +11 -0
  69. package/dist/web/resource-views.d.ts +3 -1
  70. package/dist/web/resource-views.js +6 -2
  71. package/dist/web/server.js +15 -0
  72. package/docs/acp-files.md +9 -7
  73. package/docs/validation/managed-cli-permissions.md +1 -1
  74. package/examples/fleet/agents/Alice.yaml +1 -1
  75. package/examples/fleet/agents/FleetCoordinator.yaml +1 -1
  76. package/examples/fleet.yaml +0 -1
  77. package/package.json +3 -3
  78. package/presets/fleet/agent_templates/Critic.yaml +1 -1
  79. package/presets/fleet/agent_templates/Developer.yaml +1 -1
  80. package/presets/fleet/agent_templates/Engineer.yaml +1 -1
  81. package/presets/fleet/agent_templates/LocalCoordinator.yaml +1 -1
  82. package/presets/fleet/agents/FleetCoordinator.yaml +1 -1
  83. package/presets/fleet.yaml +1 -1
  84. package/presets/manifest.json +1 -1
@@ -1,10 +1,11 @@
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 { spawn } from 'node:child_process';
5
6
  import { createHash, randomUUID } from 'node:crypto';
6
- import { existsSync, lstatSync, readFileSync, readlinkSync, realpathSync, writeFileSync, } from 'node:fs';
7
- import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path';
7
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
8
+ import { join, resolve } from 'node:path';
8
9
  import { Readable, Writable } from 'node:stream';
9
10
  import * as acp from '@agentclientprotocol/sdk';
10
11
  import { normalizeSessionUpdate } from './conversation-normalizer.js';
@@ -16,10 +17,6 @@ import { DEFAULT_STALL_TIMEOUT_MS, STALL_RECOVERY_PROMPT, StallWatchdog, StallTo
16
17
  import { ACP_CANCEL_DEADLINE_EXCEEDED, SessionControlError, classifyChildExit, sessionBackendCapabilities, turnResult, } from './types.js';
17
18
  const CANCEL_SETTLE_GRACE_MS = 15_000;
18
19
  const CANCEL_TERMINATE_GRACE_MS = 5_000;
19
- /** A permission no human answered is eventually a decision nobody made. */
20
- const PERMISSION_TIMEOUT_MS = 10 * 60_000;
21
- /** Wait 10–15 seconds before a vanished controller triggers the unattended policy. */
22
- const CONTROLLER_GRACE_MS = 12_000;
23
20
  /** Bound safe-boundary waiting without turning a hung tool into cancellation. */
24
21
  export const AFTER_TOOL_BOUNDARY_TIMEOUT_MS = 120_000;
25
22
  /**
@@ -41,119 +38,7 @@ const TERMINAL_TOOL_STATUSES = new Set(['completed', 'failed']);
41
38
  /** Consumed only by Fleet's authenticated bundled-Codex app-server proxy. */
42
39
  export const CODEX_DISABLE_INHERITED_MCP_ENV = 'OURS_FLEET_CODEX_DISABLE_INHERITED_MCP';
43
40
  const SCHEDULED_LOOP_REDACTION = '[scheduled-loop content redacted]';
44
- const MAX_CANONICAL_SYMLINK_DEPTH = 40;
45
41
  const scheduledTurn = (turn) => turn?.origin?.kind === 'scheduled-loop';
46
- /**
47
- * Two matching realpath observations narrow the opportunity for a concurrent
48
- * retarget, but are only an advisory consistency check: they do not lock the
49
- * path. A mutation after the completed check remains an unavoidable TOCTOU
50
- * window until ACP offers handle-based access.
51
- */
52
- function stableRealpath(path) {
53
- const first = realpathSync.native(path);
54
- const second = realpathSync.native(path);
55
- return first === second ? first : undefined;
56
- }
57
- /** Distinguish an absent component from a dangling symlink at that component. */
58
- function inspectMissingPath(path) {
59
- try {
60
- const stat = lstatSync(path);
61
- // realpath said ENOENT but lstat found a non-link: the path changed while
62
- // inspected, so there is no coherent canonical answer to trust.
63
- if (!stat.isSymbolicLink())
64
- return { kind: 'unsafe' };
65
- try {
66
- return { kind: 'symlink', target: resolve(dirname(path), readlinkSync(path)) };
67
- }
68
- catch {
69
- return { kind: 'unsafe' };
70
- }
71
- }
72
- catch (error) {
73
- return error.code === 'ENOENT'
74
- ? { kind: 'absent' }
75
- : { kind: 'unsafe' };
76
- }
77
- }
78
- /**
79
- * Canonicalize an existing path, or a not-yet-created target through its
80
- * nearest existing ancestor. Dangling links are followed explicitly because
81
- * realpath reports their absent target as ENOENT. Only genuine absence is
82
- * recoverable; loops, permissions, races, and every other error fail closed.
83
- */
84
- function canonicalTarget(path, symlinkDepth = 0) {
85
- let probe = resolve(path);
86
- const missing = [];
87
- while (true) {
88
- try {
89
- let canonical = stableRealpath(probe);
90
- if (!canonical)
91
- return undefined;
92
- // A component may have appeared while the ancestor search was in
93
- // progress. Re-walk the suffix so a newly-created symlink is resolved,
94
- // not treated as a lexical child of the old ancestor.
95
- let logical = probe;
96
- for (let i = 0; i < missing.length; i++) {
97
- logical = resolve(logical, missing[i]);
98
- try {
99
- const appeared = stableRealpath(logical);
100
- if (!appeared)
101
- return undefined;
102
- canonical = appeared;
103
- }
104
- catch (error) {
105
- if (error.code !== 'ENOENT')
106
- return undefined;
107
- const inspected = inspectMissingPath(logical);
108
- if (inspected.kind === 'unsafe')
109
- return undefined;
110
- if (inspected.kind === 'symlink') {
111
- if (symlinkDepth >= MAX_CANONICAL_SYMLINK_DEPTH)
112
- return undefined;
113
- return canonicalTarget(resolve(inspected.target, ...missing.slice(i + 1)), symlinkDepth + 1);
114
- }
115
- return resolve(canonical, ...missing.slice(i));
116
- }
117
- }
118
- return canonical;
119
- }
120
- catch (error) {
121
- if (error.code !== 'ENOENT')
122
- return undefined;
123
- const inspected = inspectMissingPath(probe);
124
- if (inspected.kind === 'unsafe')
125
- return undefined;
126
- if (inspected.kind === 'symlink') {
127
- if (symlinkDepth >= MAX_CANONICAL_SYMLINK_DEPTH)
128
- return undefined;
129
- return canonicalTarget(resolve(inspected.target, ...missing), symlinkDepth + 1);
130
- }
131
- const parent = dirname(probe);
132
- if (parent === probe)
133
- return undefined;
134
- missing.unshift(basename(probe));
135
- probe = parent;
136
- }
137
- }
138
- }
139
- function canonicallyWithin(root, candidates) {
140
- if (candidates.length === 0)
141
- return false;
142
- try {
143
- const firstRoot = realpathSync.native(root);
144
- const paths = candidates.map(canonicalTarget);
145
- const secondRoot = realpathSync.native(root);
146
- if (firstRoot !== secondRoot || paths.some(path => path === undefined))
147
- return false;
148
- return paths.every(candidate => {
149
- const rel = relative(firstRoot, candidate);
150
- return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));
151
- });
152
- }
153
- catch {
154
- return false;
155
- }
156
- }
157
42
  /**
158
43
  * Map typed prompt provenance to the conversation ledger's source vocabulary.
159
44
  * Only operator-authored local sources may persist prompt bodies; external
@@ -292,10 +177,7 @@ export class AcpSession {
292
177
  agentCapabilities;
293
178
  runtimeModel;
294
179
  reasoningEffort;
295
- controllerCount = 0;
296
180
  closing = false;
297
- /** Armed when the last controller detaches; unattended policy applies on fire. */
298
- controllerGrace;
299
181
  cancelEscalation;
300
182
  cancelForceKill;
301
183
  cancelRecoveryReason;
@@ -1064,7 +946,7 @@ export class AcpSession {
1064
946
  });
1065
947
  }
1066
948
  for (const [permissionId, pending] of [...this.pendingPermissions])
1067
- this.settlePendingAutomatically(permissionId, pending, 'cancelled', undefined, 'the turn was cancelled while this request was pending');
949
+ this.settlePendingAutomatically(permissionId, pending, 'the turn was cancelled while this request was pending');
1068
950
  if (active && this.activeTurn === active) {
1069
951
  active.cancellationWait ??= this.awaitCancellationSettlement(active);
1070
952
  await active.cancellationWait;
@@ -1147,8 +1029,6 @@ export class AcpSession {
1147
1029
  if (!pending || !chosen)
1148
1030
  return false;
1149
1031
  this.pendingPermissions.delete(permissionId);
1150
- if (pending.expiry)
1151
- clearTimeout(pending.expiry);
1152
1032
  pending.resolve({ outcome: { outcome: 'selected', optionId } });
1153
1033
  const decision = chosen.kind.startsWith('reject') ? 'denied' : 'allowed';
1154
1034
  if (decision === 'allowed')
@@ -1191,52 +1071,20 @@ export class AcpSession {
1191
1071
  subscribe(listener) {
1192
1072
  return this.events.subscribe(listener);
1193
1073
  }
1194
- setControllerAttached(attached) {
1195
- const before = this.controllerCount;
1196
- this.controllerCount = Math.max(0, this.controllerCount + (attached ? 1 : -1));
1197
- if (attached) {
1198
- if (this.controllerGrace)
1199
- clearTimeout(this.controllerGrace);
1200
- this.controllerGrace = undefined;
1201
- return;
1202
- }
1203
- // The LAST controller just walked away with permissions possibly pending.
1204
- // Nothing is decided yet: a reconnect within the grace keeps everything
1205
- // alive; only its expiry hands the pendings to the unattended policy.
1206
- if (before > 0 && this.controllerCount === 0 && this.pendingPermissions.size > 0)
1207
- this.armControllerGrace();
1208
- }
1209
- armControllerGrace() {
1210
- if (this.controllerGrace)
1211
- clearTimeout(this.controllerGrace);
1212
- this.controllerGrace = setTimeout(() => {
1213
- this.controllerGrace = undefined;
1214
- if (this.controllerCount > 0 || this.options.permissions.unattended !== 'deny')
1215
- return;
1216
- for (const [permissionId, pending] of [...this.pendingPermissions])
1217
- this.settlePendingAutomatically(permissionId, pending, 'denied', 'permissions.unattended=deny', 'the last attached controller disconnected and the grace period expired');
1218
- }, this.options.controllerGraceMs ?? CONTROLLER_GRACE_MS);
1219
- this.controllerGrace.unref?.();
1220
- }
1221
1074
  /**
1222
- * Settle one pending request without a human decision — unattended policy,
1223
- * expiry, or cancellation — and leave the same durable evidence a manual
1224
- * decision would. A denial selects the agent's own one-shot reject option;
1225
- * everything else resolves as cancelled toward the agent.
1075
+ * Controllers come and go; a pending permission request never depends on one being attached. It waits for the
1076
+ * Owner's answer (session or feed) until the turn or session really ends (D6).
1077
+ */
1078
+ setControllerAttached(_attached) { }
1079
+ /**
1080
+ * End one pending request because its turn or session really ended (cancel, close, a withdrawn tool call), and
1081
+ * leave the same durable evidence a decision would. It is never a decision: the agent sees it as cancelled.
1226
1082
  */
1227
- settlePendingAutomatically(permissionId, pending, decision, policy, reason) {
1083
+ settlePendingAutomatically(permissionId, pending, reason) {
1228
1084
  if (!this.pendingPermissions.delete(permissionId))
1229
1085
  return;
1230
- if (pending.expiry)
1231
- clearTimeout(pending.expiry);
1232
- const rejectOption = decision === 'denied'
1233
- ? pending.options.find(option => option.kind === 'reject_once')
1234
- ?? pending.options.find(option => option.kind === 'reject_always')
1235
- : undefined;
1236
- pending.resolve(rejectOption
1237
- ? { outcome: { outcome: 'selected', optionId: rejectOption.optionId } }
1238
- : { outcome: { outcome: 'cancelled' } });
1239
- const settled = decision === 'denied' && !rejectOption ? 'cancelled' : decision;
1086
+ pending.resolve({ outcome: { outcome: 'cancelled' } });
1087
+ const settled = 'cancelled';
1240
1088
  this.releasePermission(pending.toolCallId, permissionId);
1241
1089
  if (this.pendingPermissions.size === 0 && this.readiness === 'awaiting_permission')
1242
1090
  this.readiness = 'running';
@@ -1246,11 +1094,9 @@ export class AcpSession {
1246
1094
  permissionId,
1247
1095
  toolCallId: pending.eventToolCallId,
1248
1096
  status: 'completed',
1249
- decision: settled === 'expired' ? 'cancelled' : settled,
1097
+ decision: settled,
1250
1098
  decisionSource: 'automatic',
1251
- policy,
1252
1099
  reason,
1253
- optionId: rejectOption?.optionId,
1254
1100
  });
1255
1101
  this.conversation.appendSafe({
1256
1102
  kind: 'permission.resolved', sessionGeneration: this.sessionGeneration,
@@ -1258,9 +1104,7 @@ export class AcpSession {
1258
1104
  promptId: this.activeTurn?.id, turnId: this.activeTurn?.id,
1259
1105
  toolCallId: pending.eventToolCallId,
1260
1106
  payload: {
1261
- decision: settled, decisionSource: 'automatic',
1262
- ...(policy ? { policy } : {}), reason,
1263
- ...(rejectOption ? { optionId: rejectOption.optionId } : {}),
1107
+ decision: settled, decisionSource: 'automatic', reason,
1264
1108
  },
1265
1109
  });
1266
1110
  this.observation.publish();
@@ -1287,7 +1131,7 @@ export class AcpSession {
1287
1131
  const onAbort = () => {
1288
1132
  for (const [id, pending] of this.pendingPermissions)
1289
1133
  if (pending.toolCallId === toolCallId)
1290
- this.settlePendingAutomatically(id, pending, 'cancelled', undefined, 'File send cancelled');
1134
+ this.settlePendingAutomatically(id, pending, 'File send cancelled');
1291
1135
  };
1292
1136
  signal.addEventListener('abort', onAbort, { once: true });
1293
1137
  let answer;
@@ -1295,7 +1139,7 @@ export class AcpSession {
1295
1139
  answer = await this.requestPermission({ sessionId: sessionId, toolCall: {
1296
1140
  toolCallId, title: 'Send file to this ACP chat: ' + (input.filename ?? input.path), kind: 'read', status: 'pending',
1297
1141
  locations: [{ path: resolve(this.options.cwd, input.path) }],
1298
- }, options: [{ optionId: 'send', name: 'Send file', kind: 'allow_once' }, { optionId: 'deny', name: 'Do not send', kind: 'reject_once' }] }, policy);
1142
+ }, options: [{ optionId: 'send', name: 'Send file', kind: 'allow_once' }, { optionId: 'deny', name: 'Do not send', kind: 'reject_once' }] });
1299
1143
  }
1300
1144
  finally {
1301
1145
  signal.removeEventListener('abort', onAbort);
@@ -1329,12 +1173,9 @@ export class AcpSession {
1329
1173
  if (this.cancelForceKill)
1330
1174
  clearTimeout(this.cancelForceKill);
1331
1175
  this.cancelForceKill = undefined;
1332
- if (this.controllerGrace)
1333
- clearTimeout(this.controllerGrace);
1334
- this.controllerGrace = undefined;
1335
1176
  this.releaseSteeringOccupancy('session closed');
1336
1177
  for (const [permissionId, pending] of [...this.pendingPermissions])
1337
- this.settlePendingAutomatically(permissionId, pending, 'cancelled', undefined, 'the session closed while this request was pending');
1178
+ this.settlePendingAutomatically(permissionId, pending, 'the session closed while this request was pending');
1338
1179
  this.releaseAllTools();
1339
1180
  if (this.sessionId && this.agentCapabilities?.sessionCapabilities?.close != null) {
1340
1181
  await this.connection.agent.request(acp.methods.agent.session.close, { sessionId: this.sessionId }).catch(() => undefined);
@@ -1637,6 +1478,9 @@ export class AcpSession {
1637
1478
  async runSinglePrompt(text, turnId = randomUUID(), origin, members = [{ promptId: turnId, text, origin }]) {
1638
1479
  let completionPayload;
1639
1480
  const closeMembers = (payload) => {
1481
+ // A request still pending when its turn ends (the harness stopped waiting, e.g. its own timeout) ended with it.
1482
+ for (const [permissionId, pending] of [...this.pendingPermissions])
1483
+ this.settlePendingAutomatically(permissionId, pending, 'the turn ended while this request was pending');
1640
1484
  for (const member of members)
1641
1485
  this.conversation.appendSafe({
1642
1486
  kind: 'turn.completed', sessionGeneration: this.sessionGeneration,
@@ -1756,61 +1600,17 @@ export class AcpSession {
1756
1600
  this.steeringRequests--;
1757
1601
  }
1758
1602
  }
1759
- requestPermission(params, neutralPolicy) {
1760
- // `kinds` is a PRIORITY order. Scanning the agent's option array instead
1761
- // (`options.find(o => kinds.includes(o.kind))`) hands the choice to whatever
1762
- // order the agent happened to list, which is exactly how an automatic denial
1763
- // could land on `reject_always`.
1764
- const choose = (kinds) => {
1765
- for (const kind of kinds) {
1766
- const option = params.options.find(o => o.kind === kind);
1767
- if (option)
1768
- return option;
1769
- }
1770
- return undefined;
1771
- };
1603
+ requestPermission(params) {
1772
1604
  const toolCallId = params.toolCall.toolCallId;
1773
1605
  const permissionId = randomUUID();
1774
- // Permission is part of the tool lifecycle. Reserve before any policy or
1775
- // human decision so a monitor wake cannot slip between request and answer.
1606
+ // Permission is part of the tool lifecycle. Reserve before the Owner's decision so a monitor wake cannot slip
1607
+ // between request and answer.
1776
1608
  this.reservePermission(toolCallId, permissionId);
1777
- if (!neutralPolicy && this.isEffectiveCodexProtectedMcpApproval(params)) {
1778
- // Protected MCP approval is already the tool's narrow gate. Never turn
1779
- // this one decision into an adapter-wide standing grant.
1780
- const option = choose(['allow_once']);
1781
- const response = this.settleAutomatically(params, option, 'allowed', 'permissionMode.fleetMode=allow', 'the trusted Codex adapter authenticated a protected MCP approval request');
1782
- if (option)
1783
- this.allowPermission(toolCallId, permissionId);
1784
- else
1785
- this.releasePermission(toolCallId, permissionId);
1786
- return Promise.resolve(response);
1787
- }
1788
- if ((neutralPolicy ?? this.options.permissions).approval === 'allow' && this.withinAutomaticBoundary(params, neutralPolicy)) {
1789
- const option = choose(['allow_always', 'allow_once']);
1790
- const response = this.settleAutomatically(params, option, 'allowed', 'permissions.approval=allow', `the request is inside the ${(neutralPolicy ?? this.options.permissions).filesystem} boundary`);
1791
- if (option)
1792
- this.allowPermission(toolCallId, permissionId);
1793
- else
1794
- this.releasePermission(toolCallId, permissionId);
1795
- return Promise.resolve(response);
1796
- }
1797
- // A live grace window still counts as attended: the controller may be
1798
- // mid-reconnect, and denying instantly is exactly what the grace prevents.
1799
- const unattended = this.controllerCount === 0 && !this.controllerGrace
1800
- && (neutralPolicy ?? this.options.permissions).unattended === 'deny';
1801
- if ((neutralPolicy ?? this.options.permissions).approval === 'deny' || unattended) {
1802
- // reject_once FIRST: `reject_always` teaches the agent a standing rule from
1803
- // a decision no human made, so one unattended denial would silently disable
1804
- // the tool for the rest of the session.
1805
- const option = choose(['reject_once', 'reject_always']);
1806
- const response = this.settleAutomatically(params, option, 'denied', unattended ? 'permissions.unattended=deny' : 'permissions.approval=deny', unattended
1807
- ? 'no controller is attached, so the request cannot be shown to anyone'
1808
- : 'the role denies every permission request by policy');
1809
- this.releasePermission(toolCallId, permissionId);
1810
- return Promise.resolve(response);
1811
- }
1812
- const timeoutMs = this.options.permissionTimeoutMs ?? PERMISSION_TIMEOUT_MS;
1813
- const expiresAt = new Date(Date.now() + timeoutMs).toISOString();
1609
+ // D6: Fleet never settles a raised request — the harness's own or Fleet's own (send a file to this chat) — not by
1610
+ // `approval` (which only selects the native mode, deciding whether a harness raises a request at all), not by a
1611
+ // protected-MCP rule, not by expiry.
1612
+ // Every raised request waits for the Owner, with or without an attached console, for as long as the turn and
1613
+ // session last (D6): no expiry and no automatic decision.
1814
1614
  const presented = {
1815
1615
  toolCallId: scheduledTurn(this.activeTurn) ? 'scheduled-loop-tool' : toolCallId,
1816
1616
  title: scheduledTurn(this.activeTurn)
@@ -1820,7 +1620,6 @@ export class AcpSession {
1820
1620
  name: scheduledTurn(this.activeTurn) ? option.kind : option.name,
1821
1621
  kind: option.kind,
1822
1622
  })),
1823
- expiresAt,
1824
1623
  };
1825
1624
  return new Promise(resolve => {
1826
1625
  const pending = {
@@ -1828,10 +1627,6 @@ export class AcpSession {
1828
1627
  toolCallId,
1829
1628
  eventToolCallId: scheduledTurn(this.activeTurn) ? 'scheduled-loop-tool' : toolCallId,
1830
1629
  };
1831
- pending.expiry = setTimeout(() => {
1832
- this.settlePendingAutomatically(permissionId, pending, 'expired', undefined, `no decision arrived within ${Math.round(timeoutMs / 1000)}s`);
1833
- }, timeoutMs);
1834
- pending.expiry.unref?.();
1835
1630
  this.pendingPermissions.set(permissionId, pending);
1836
1631
  this.readiness = 'awaiting_permission';
1837
1632
  this.events.emit('permission', {
@@ -1847,79 +1642,6 @@ export class AcpSession {
1847
1642
  this.observation.publish();
1848
1643
  });
1849
1644
  }
1850
- /**
1851
- * Resolve a permission request from policy alone and leave a record of it.
1852
- * Nothing else in the system can observe an automatic decision, so an
1853
- * unrecorded one is indistinguishable from a request that was never made.
1854
- */
1855
- settleAutomatically(params, option, decision, policy, reason) {
1856
- const settled = option ? decision : 'cancelled';
1857
- this.events.emit('permission', {
1858
- turnId: this.activeTurn?.id,
1859
- origin: this.activeTurn?.origin,
1860
- permissionId: randomUUID(),
1861
- toolCallId: this.activeTurn?.origin?.kind === 'scheduled-loop'
1862
- ? 'scheduled-loop-tool' : params.toolCall.toolCallId,
1863
- status: 'completed',
1864
- decision: settled,
1865
- decisionSource: 'automatic',
1866
- policy,
1867
- reason: option ? reason : `${reason}, but the agent offered no matching option`,
1868
- optionId: option?.optionId,
1869
- title: this.activeTurn?.origin?.kind === 'scheduled-loop'
1870
- ? 'Scheduled-loop permission requested' : params.toolCall.title ?? 'Permission requested',
1871
- options: params.options.map(o => ({
1872
- optionId: o.optionId,
1873
- name: this.activeTurn?.origin?.kind === 'scheduled-loop' ? o.kind : o.name,
1874
- kind: o.kind,
1875
- })),
1876
- });
1877
- this.conversation.appendSafe({
1878
- kind: 'permission.resolved', sessionGeneration: this.sessionGeneration,
1879
- acpSessionId: this.sessionId, permissionId: randomUUID(),
1880
- promptId: this.activeTurn?.id, turnId: this.activeTurn?.id,
1881
- toolCallId: scheduledTurn(this.activeTurn) ? 'scheduled-loop-tool' : params.toolCall.toolCallId,
1882
- payload: {
1883
- decision: settled,
1884
- decisionSource: 'automatic', policy, reason,
1885
- ...(option ? { optionId: option.optionId } : {}),
1886
- },
1887
- });
1888
- return option
1889
- ? { outcome: { outcome: 'selected', optionId: option.optionId } }
1890
- : { outcome: { outcome: 'cancelled' } };
1891
- }
1892
- withinAutomaticBoundary(params, policy) {
1893
- const filesystem = (policy ?? this.options.permissions).filesystem;
1894
- if (filesystem === 'unrestricted')
1895
- return true;
1896
- if (filesystem === 'read-only' && params.toolCall.kind !== 'read')
1897
- return false;
1898
- const locations = params.toolCall.locations ?? [];
1899
- if (locations.length === 0)
1900
- return false;
1901
- const cwd = resolve(this.options.cwd);
1902
- return canonicallyWithin(cwd, locations.map(location => resolve(location.path)));
1903
- }
1904
- /**
1905
- * Codex ACP 1.1.7 marks its protected MCP elicitation bridge on a locationless
1906
- * execute request. The marker is meaningful only together with the runner's
1907
- * independently supplied, adapter-authenticated metadata vocabulary and effective
1908
- * mode: an arbitrary ACP process cannot gain this path by copying `_meta` alone.
1909
- * Exact option ids/kinds bind recognition to the protected-MCP shape and keep
1910
- * malformed requests on the ordinary fail-closed path.
1911
- */
1912
- isEffectiveCodexProtectedMcpApproval(params) {
1913
- const locations = params.toolCall.locations ?? [];
1914
- return this.options.permissionMetadataSource === 'codex-acp'
1915
- && this.options.permissionMode?.fleetMode === 'allow'
1916
- && params.toolCall.kind === 'execute'
1917
- && params.toolCall.status === 'pending'
1918
- && locations.length === 0
1919
- && params._meta?.is_mcp_tool_approval === true
1920
- && params.options.some(option => option.optionId === 'allow_once' && option.kind === 'allow_once')
1921
- && params.options.some(option => option.optionId === 'decline' && option.kind === 'reject_once');
1922
- }
1923
1645
  /** Pinned codex-acp 1.1.7 structured metadata, never stderr or assistant text. */
1924
1646
  recordStallMetadata(update) {
1925
1647
  if (this.options.permissionMetadataSource !== 'codex-acp'
@@ -2138,6 +1860,7 @@ export class AcpSession {
2138
1860
  return this.activeTurn && this.sessionId ? { sessionGeneration: this.sessionGeneration, acpSessionId: this.sessionId, promptId: this.activeTurn.id } : undefined;
2139
1861
  }
2140
1862
  recordTaskCreated(binding, notice) { appendTaskCreated(this.conversation, binding, notice); }
1863
+ recordStatusNotices(entries) { return appendStatusNotices(this.conversation, { sessionGeneration: this.sessionGeneration, acpSessionId: this.sessionId }, entries); }
2141
1864
  conversationPage(request = {}) {
2142
1865
  const floor = Number(this.conversationStartCursor ?? 0);
2143
1866
  const requested = Number(request.after ?? 0);
@@ -1,4 +1,5 @@
1
1
  import { type TaskNoticeBinding, type TaskCreatedNotice } from './task-notice.js';
2
+ import { type StatusLedgerEntry } from './status-notice.js';
2
3
  import type { CommonPermissions } from '../config.js';
3
4
  import type { ConversationEventV1, ConversationObservationState, ConversationSnapshot, PromptOrigin, PromptReceipt, SubmitPromptCommand } from './conversation-types.js';
4
5
  import { type PendingPrompt } from './prompt-batch.js';
@@ -24,8 +25,6 @@ export interface CodexAppServerSessionOptions {
24
25
  config?: Record<string, unknown>;
25
26
  addDirs?: string[];
26
27
  log(line: string): void;
27
- permissionTimeoutMs?: number;
28
- controllerGraceMs?: number;
29
28
  interruptSettleMs?: number;
30
29
  interruptTerminateGraceMs?: number;
31
30
  terminalReconcileQuietMs?: number;
@@ -76,8 +75,6 @@ export declare class CodexAppServerSession implements AgentSession {
76
75
  /** Admitted prompt → the turn that carries it, while that turn is open. */
77
76
  private readonly sharedTurns;
78
77
  private activeTurn?;
79
- private controllerCount;
80
- private controllerGrace?;
81
78
  private interruptForceKill?;
82
79
  private terminalReconcile?;
83
80
  private terminalReconcileInFlight;
@@ -107,11 +104,13 @@ export declare class CodexAppServerSession implements AgentSession {
107
104
  respondPermissionV2(permissionId: string, optionId: string, sessionGeneration: string): 'accepted' | 'stale';
108
105
  eventsSince(seq: number): SessionEvent[];
109
106
  subscribe(listener: (event: SessionEvent) => void): () => void;
110
- setControllerAttached(attached: boolean): void;
107
+ /** A pending permission request never depends on an attached controller: it waits for the Owner (D6). */
108
+ setControllerAttached(_attached: boolean): void;
111
109
  exitResult(): ExitRecord | null;
112
110
  close(): Promise<void>;
113
111
  taskNoticeBinding(): TaskNoticeBinding | undefined;
114
112
  recordTaskCreated(binding: TaskNoticeBinding, notice: TaskCreatedNotice): void;
113
+ recordStatusNotices(entries: StatusLedgerEntry[]): number;
115
114
  conversationPage(request?: {
116
115
  after?: string;
117
116
  limit?: number;
@@ -155,7 +154,11 @@ export declare class CodexAppServerSession implements AgentSession {
155
154
  private serverRequest;
156
155
  private requestPermission;
157
156
  private serverRequestResolved;
158
- private autoResolvePermission;
157
+ /**
158
+ * The session is ending with this request still pending: Codex gets a decline so its turn can finish, and the
159
+ * record says the request ended without anyone's answer (cancelled), never that someone denied it.
160
+ */
161
+ private endPermission;
159
162
  private resolvePermission;
160
163
  private currentEvent;
161
164
  private isActiveNotification;