@ours.network/fleet 2.4.4 → 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 (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 +2 -2
  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
package/dist/docs.js CHANGED
@@ -226,7 +226,7 @@ ours-fleet spawn [--temp] [Name | --name Name] \\
226
226
  --cwd /absolute/path --identity Identity --coordinator Coordinator \\
227
227
  --approval ask|auto|allow \\
228
228
  --filesystem read-only|workspace|unrestricted \\
229
- --unattended deny|wait --isolation-file /path/isolation.yaml
229
+ --isolation-file /path/isolation.yaml
230
230
  \`\`\`
231
231
 
232
232
  Permanent spawn writes \`~/fleet/agents/Name.yaml\` and starts a supervised role.
@@ -281,7 +281,7 @@ role's name or persona and is not inherited by agents it spawns:
281
281
  # fleet/agents/FleetCoordinator.yaml
282
282
  role: { ref: Coordinator }
283
283
  brain: { ref: codex-gpt-5-4-medium }
284
- permissions: { approval: auto, filesystem: workspace, unattended: deny }
284
+ permissions: { approval: auto, filesystem: workspace }
285
285
  managed_cli: [task-workflow]
286
286
  \`\`\`
287
287
 
@@ -400,7 +400,6 @@ defaults:
400
400
  permissions:
401
401
  approval: ask
402
402
  filesystem: workspace
403
- unattended: deny
404
403
  monitor:
405
404
  mode: fleet # fleet (default) | native
406
405
  watchdogs:
@@ -921,8 +920,13 @@ Prefer the harness-neutral \`permissions\` block:
921
920
  - \`approval: ask|auto|allow\`: portable permission policy. \`deny\` remains a
922
921
  deprecated, fail-closed compatibility alias for existing fleet files.
923
922
  - \`filesystem: read-only|workspace|unrestricted\`: filesystem intent
924
- - \`unattended: deny|wait\`: what a managed session does when no console can
925
- answer a request
923
+
924
+ Every permission request a harness raises waits for the Owner's answer, in the
925
+ agent's session or in the feed, with no timeout and no automatic denial, whether
926
+ or not a console is attached. It ends without an answer only when its turn or
927
+ session really ends (cancelled, closed, exited, or withdrawn by the harness). The
928
+ retired \`unattended\` key is still accepted and ignored, with one startup
929
+ warning naming the role.
926
930
 
927
931
  The backend translates this common intent. Native Codex app-server roles reject
928
932
  permission aliases in \`harness_options\`; Codex ACP and Claude retain their
@@ -954,37 +958,31 @@ directory, no identity reservation. Works for both permanent and \`--temp\` role
954
958
 
955
959
  The failure this section exists to prevent leaves no error message anywhere.
956
960
 
957
- An unattended role has no console. When the harness needs a permission decision
958
- there is nobody to ask, so the request is refused INSIDE the harness — no
959
- prompt, no error, no log line. The agent simply does less than its briefing told
960
- it to, reports success, and nothing distinguishes that from having done the
961
- work. Two settings produce it:
962
-
963
- 1. a permission mode that suppresses the prompt without granting the action
964
- (Claude \`dontAsk\`, which is why neutral \`allow\` maps to
965
- \`bypassPermissions\` instead); and
966
- 2. \`unattended: deny\`, which refuses every request that reaches it.
967
-
968
- **Automatic decisions are now recorded.** Every permission request decided
969
- without a human emits a completed event into
970
- \`~/.ours-fleet/agents/<Name>/.session-events.jsonl\` carrying the decision,
971
- whether policy or a person made it, the policy that produced it
972
- (\`permissions.unattended=deny\` vs \`permissions.approval=deny\`/\`=allow\`),
973
- the reason, and the option selected. \`ours-fleet peek\` and \`attach\` render
974
- them. Automatic denial asks for a one-shot rejection, never a standing one, so a
975
- single unattended refusal cannot disable a tool for the rest of the session.
976
-
977
- A role that can auto-deny logs one line at startup saying so.
961
+ A permission mode that suppresses the prompt without granting the action (Claude
962
+ \`dontAsk\`, which is why neutral \`allow\` maps to \`bypassPermissions\`
963
+ instead) refuses the request INSIDE the harness — no prompt, no error, no log
964
+ line. The agent simply does less than its briefing told it to, reports success,
965
+ and nothing distinguishes that from having done the work.
966
+
967
+ Every other request reaches Fleet and waits for the Owner (session or feed).
968
+ **Fleet never decides a raised request.** \`permissions.approval\` only selects
969
+ the harness's native mode, which decides whether a request is raised at all;
970
+ once raised, it waits — under every \`approval\` value, the deprecated
971
+ \`deny\` alias included. A request ends without the Owner's answer only when
972
+ its turn or session really ends or the harness withdraws it; that ending is
973
+ recorded as cancelled, never as an approval or a denial, in
974
+ \`~/.ours-fleet/agents/<Name>/.session-events.jsonl\` with the reason.
975
+ \`ours-fleet peek\` and \`attach\` render every decision and ending.
978
976
 
979
977
  To detect an under-permissioned role BEFORE it runs, use the capability floor
980
- below: \`ours-fleet doctor\` fails such a role rather than letting it discover
981
- the problem silently at work.
978
+ below: \`ours-fleet doctor\` warns about such a role, whose requests would each
979
+ wait for the Owner.
982
980
 
983
981
  ### The unattended capability floor
984
982
 
985
- An unattended role has no console, so a permission request cannot be answered —
986
- it is refused, silently, inside the harness. The agent then does less than it
987
- was told to and reports no error. To make that visible before launch,
983
+ An agent working alone needs its briefing's own actions to be granted natively;
984
+ otherwise each one raises a permission request that waits for the Owner's
985
+ answer and the agent makes no progress meanwhile. To make that visible before launch,
988
986
  \`ours-fleet config\` and \`ours-fleet doctor\` resolve each role's neutral
989
987
  permissions through its harness and check the result against a fixed floor:
990
988
 
@@ -995,10 +993,8 @@ permissions through its harness and check the result against a fixed floor:
995
993
  - \`workspace-edit\` — edit and test files in its working directory
996
994
  - \`status-commands\` — run the inspection commands its briefing prescribes
997
995
 
998
- \`doctor\` reports this per role as \`unattended floor: <Role>\`. A role with
999
- \`unattended: deny\` that cannot meet the floor FAILS doctor, because it will
1000
- deny those requests with nobody to see it; with \`unattended: wait\` it warns,
1001
- because a human can still attach and answer.
996
+ \`doctor\` reports this per role as \`unattended floor: <Role>\`. A role that
997
+ cannot meet the floor warns: those requests will wait for the Owner's answer.
1002
998
 
1003
999
  Security meaning: native Codex maps \`ask\` → \`untrusted\`, \`auto\` →
1004
1000
  \`on-request\`, and \`allow\` → \`never\`; its independent filesystem mapping is
@@ -1028,7 +1024,7 @@ still wins, as does an explicit native approval override. \`config\` and
1028
1024
  \`isolation:\` as the outer boundary for an \`allow\` ACP role. The live session
1029
1025
  reports both its effective normalized mode and the exact native mode selected.
1030
1026
 
1031
- See also: \`spawn --approval/--filesystem/--unattended\` set this intent at
1027
+ See also: \`spawn --approval/--filesystem\` set this intent at
1032
1028
  creation, and \`ours-fleet config\` prints each role's neutral settings, their
1033
1029
  native translation, and any warning — the same text \`doctor\` reports.
1034
1030
 
@@ -1498,10 +1494,8 @@ reconcile explicitly; no chain preserves detection-only behavior.
1498
1494
  *
1499
1495
  * \`forbidden\` is the more important half. The old skills prescribed
1500
1496
  * \`--approval ask --filesystem workspace --unattended deny\` as a blanket
1501
- * default while also telling the agent to stop at a failed doctor check — and
1502
- * that combination is exactly what \`doctor\` FAILS, because \`ask\` cannot
1503
- * guarantee unattended capabilities and \`deny\` makes the shortfall
1504
- * fatal. Following the skill produced a role the CLI then refused.
1497
+ * default; \`--unattended\` is retired (every permission request waits for the
1498
+ * Owner), so no variant may print it.
1505
1499
  */
1506
1500
  export const SPAWN_SKILL_CONTRACT = {
1507
1501
  /** Substrings every variant must contain (whitespace-normalised). */
@@ -1517,7 +1511,8 @@ export const SPAWN_SKILL_CONTRACT = {
1517
1511
  'unattended floor:',
1518
1512
  // The only intent that clears the floor, and the honest alternative.
1519
1513
  '--approval allow',
1520
- '--unattended wait',
1514
+ // Every permission request waits for the Owner (D6).
1515
+ 'waits for the Owner',
1521
1516
  // Creation-time isolation — the one new operator input this release adds.
1522
1517
  '--isolation-file',
1523
1518
  ],
@@ -1528,11 +1523,8 @@ export const SPAWN_SKILL_CONTRACT = {
1528
1523
  * This list only pins the specific claim that was wrong.
1529
1524
  */
1530
1525
  forbidden: [
1531
- // The contradictory blanket default both variants used to prescribe.
1532
- // `ask` cannot guarantee unattended capabilities, and `deny` makes the
1533
- // shortfall a doctor FAILURE — so the skill told you to build a role the
1534
- // CLI then refused, in the same breath as telling you to trust doctor.
1535
- '--approval ask --filesystem workspace --unattended deny',
1526
+ // The retired flag (D6), in any combination.
1527
+ '--unattended',
1536
1528
  '[TODO:',
1537
1529
  ],
1538
1530
  };
package/dist/doctor.js CHANGED
@@ -354,7 +354,7 @@ export async function doctor(opts = {}, exec = realExec, platform = process.plat
354
354
  continue;
355
355
  }
356
356
  const p = analysis.permissions;
357
- const summary = `approval=${p.approval} filesystem=${p.filesystem} unattended=${p.unattended}`
357
+ const summary = `approval=${p.approval} filesystem=${p.filesystem}`
358
358
  + ` -> ${formatNative(analysis.native)}`;
359
359
  checks.push({
360
360
  name: `permissions: ${analysis.role}`, ok: true,
@@ -368,17 +368,15 @@ export async function doctor(opts = {}, exec = realExec, platform = process.plat
368
368
  checks.push({
369
369
  name: `permission conflict: ${analysis.role}`, ok: true, detail: conflict.warning,
370
370
  });
371
- // The floor is checked BEFORE start: an under-permissioned unattended
372
- // role never reports its own failure, because the denial happens inside the
373
- // harness with nobody attached to see it.
371
+ // The floor is checked BEFORE start: below it, the agent's own briefing needs permission requests, and each
372
+ // waits for the Owner's answer (session or feed) before the turn continues.
374
373
  const floor = analysis.floor;
375
374
  checks.push({
376
375
  name: `unattended floor: ${analysis.role}`,
377
376
  ok: floor.meets || analysis.floorSeverity !== 'fail',
378
377
  detail: floor.meets
379
378
  ? `grants ${analysis.capabilities.join(', ')}`
380
- : `MISSING ${floor.missing.join(', ')} — with unattended=${p.unattended} these requests will `
381
- + `${p.unattended === 'deny' ? 'be denied silently' : 'block the turn'}; `
379
+ : `MISSING ${floor.missing.join(', ')} — these requests will wait for the Owner's answer; `
382
380
  + `grants only ${analysis.capabilities.join(', ') || '(nothing)'}`,
383
381
  });
384
382
  }
@@ -13,3 +13,15 @@ export declare function readDeliveredFile(stateDir: string, id: string): Promise
13
13
  record: DeliveredFile;
14
14
  bytes: Buffer;
15
15
  }>;
16
+ /** The key of the conversation-file store this incarnation writes to (recorded with a status's attachments). */
17
+ export declare function artifactStoreKey(stateDir: string): string;
18
+ /**
19
+ * A delivered file in the store recorded when its status was published. A status keeps referring to its
20
+ * files after the agent's session is replaced (`--fresh` changes only the incarnation key; stores are never
21
+ * deleted). The bytes are verified against their record, and the record must equal the metadata the status
22
+ * copied from it at publish.
23
+ */
24
+ export declare function findDeliveredFile(store: string, id: string, expected: Pick<DeliveredFile, 'name' | 'mimeType' | 'size' | 'sha256'>): Promise<{
25
+ record: DeliveredFile;
26
+ bytes: Buffer;
27
+ }>;
@@ -1,7 +1,7 @@
1
1
  import { createHash, randomUUID } from 'node:crypto';
2
2
  import { constants, mkdirSync, readFileSync, readdirSync, lstatSync, openSync, fstatSync, closeSync, renameSync, writeFileSync } from 'node:fs';
3
3
  import { open, unlink } from 'node:fs/promises';
4
- import { join } from 'node:path';
4
+ import { basename, join } from 'node:path';
5
5
  import { stateRoot } from '../paths.js';
6
6
  import { openDirectory, MAX_FILE_BYTES } from './reader.js';
7
7
  export function artifactDirectory(stateDir) {
@@ -93,9 +93,31 @@ export class ArtifactStore {
93
93
  }
94
94
  }
95
95
  export async function readDeliveredFile(stateDir, id) {
96
+ return readFromDirectory(artifactDirectory(stateDir), id);
97
+ }
98
+ /** The key of the conversation-file store this incarnation writes to (recorded with a status's attachments). */
99
+ export function artifactStoreKey(stateDir) {
100
+ return basename(artifactDirectory(stateDir));
101
+ }
102
+ /**
103
+ * A delivered file in the store recorded when its status was published. A status keeps referring to its
104
+ * files after the agent's session is replaced (`--fresh` changes only the incarnation key; stores are never
105
+ * deleted). The bytes are verified against their record, and the record must equal the metadata the status
106
+ * copied from it at publish.
107
+ */
108
+ export async function findDeliveredFile(store, id, expected) {
109
+ if (!/^[a-f0-9]{64}$/.test(store))
110
+ throw Error('ARTIFACT_NOT_FOUND');
111
+ const found = await readFromDirectory(join(stateRoot(), 'private-file-delivery', store), id);
112
+ const { record } = found;
113
+ if (record.name !== expected.name || record.mimeType !== expected.mimeType || record.size !== expected.size || record.sha256 !== expected.sha256)
114
+ throw Error('ARTIFACT_INTEGRITY_FAILED');
115
+ return found;
116
+ }
117
+ async function readFromDirectory(directory, id) {
96
118
  if (!/^[a-f0-9-]{36}$/.test(id))
97
119
  throw Error('ARTIFACT_NOT_FOUND');
98
- const root = await openDirectory(artifactDirectory(stateDir));
120
+ const root = await openDirectory(directory);
99
121
  const read = (suffix, max) => {
100
122
  const fd = openSync(`/proc/self/fd/${root.fd}/${id}.${suffix}`, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
101
123
  try {
@@ -454,7 +454,8 @@ function validConfiguration(value) {
454
454
  && (c.mission === undefined || (text(c.mission) && Array.from(String(c.mission)).length <= 80))
455
455
  && APPROVAL_MODES.has(String(c.approval))
456
456
  && FILESYSTEM_MODES.has(String(c.filesystem))
457
- && UNATTENDED_MODES.has(String(c.unattended))
457
+ // Retired (D6): accepted only from records written before it was removed.
458
+ && (c.unattended === undefined || UNATTENDED_MODES.has(String(c.unattended)))
458
459
  && record(c.permissionMode)
459
460
  && exact(c.permissionMode, ['fleetMode', 'nativeMode'])
460
461
  && FLEET_PERMISSION_MODES.has(String(c.permissionMode.fleetMode))
@@ -655,7 +656,7 @@ function agentConfigurationFieldGroups(configuration) {
655
656
  ['Effort', configuration.effort ? markdownProse(configuration.effort) : undefined],
656
657
  ['Approval', markdownProse(configuration.approval)],
657
658
  ['Filesystem', markdownProse(configuration.filesystem)],
658
- ['Wait', markdownProse(configuration.unattended)],
659
+ ['Wait', configuration.unattended ? markdownProse(configuration.unattended) : undefined],
659
660
  ['Fleet mode', markdownProse(configuration.permissionMode.fleetMode)],
660
661
  ['Native mode', markdownProse(configuration.permissionMode.nativeMode)],
661
662
  ], optional, tail: [
@@ -50,7 +50,6 @@ export function inheritCallerSpawnDefaults(caller, requested, configPath) {
50
50
  if (options.approval === undefined)
51
51
  take('approval', inheritedPermissionMode(caller));
52
52
  take('filesystem', caller.permissions.filesystem);
53
- take('unattended', caller.permissions.unattended);
54
53
  take('monitorConfig', structuredClone(caller.monitor));
55
54
  options.configPath = configPath;
56
55
  options.surface = 'agent';
@@ -29,7 +29,7 @@ export function translateHermesPermissions(permissions) {
29
29
  capabilities,
30
30
  warnings: [
31
31
  'Hermes modes mediate dangerous terminal commands and write_file/patch; browser, memory, skills, delegation and MCP side effects are not universally approval-mediated.',
32
- 'Unattended wait is bounded by Fleet’s 50-second permission timeout and the tested Hermes native 60-second dangerous-command timeout; protected-action floors remain active.',
32
+ 'Fleet waits for the Owner without a timeout; Hermes’s own native 60-second dangerous-command timeout still ends an unanswered request, which Fleet records as ended when its turn finishes; protected-action floors remain active.',
33
33
  ...(permissions.filesystem === 'workspace' ? ['Workspace confinement is an approximation unless enforcing Fleet isolation is verified on this platform.'] : []),
34
34
  ],
35
35
  };
@@ -73,7 +73,6 @@ export class HermesAgentSessionAdapter {
73
73
  inheritEnvironment: false, stateDir: options.stateDir, mode: 'fresh',
74
74
  permissions: options.permissions, modeId, requireMode: true,
75
75
  permissionMode: { fleetMode: options.permissionMode.fleetMode, nativeMode: modeId },
76
- permissionTimeoutMs: 50_000,
77
76
  mcpServers: options.managedOurs ? [...hermesMcpServers(role, env).filter(s => s.name !== 'ours'), options.managedOurs.server] : hermesMcpServers(role, env),
78
77
  scrubObsoleteOursAutostart: true,
79
78
  validateStartupResponse: async (initialized, created) => {
@@ -194,7 +194,7 @@ export function generateSetup(answers) {
194
194
  'api_version: ours.network/fleet/v2',
195
195
  '',
196
196
  'defaults:',
197
- ' permissions: { approval: ask, filesystem: workspace, unattended: deny }',
197
+ ' permissions: { approval: ask, filesystem: workspace }',
198
198
  '',
199
199
  ].join('\n'));
200
200
  for (const work of WORK_KINDS) {
@@ -233,7 +233,7 @@ export function generateSetup(answers) {
233
233
  `brain: { ref: ${PURPOSE_BRAINS[ROLE_WORK[role]].id} }`,
234
234
  'coordinator: FleetCoordinator',
235
235
  // Temporary default while the product is being tested: prepared agents work without asking.
236
- 'permissions: { approval: allow, filesystem: unrestricted, unattended: deny }',
236
+ 'permissions: { approval: allow, filesystem: unrestricted }',
237
237
  'monitor: { mode: fleet, interrupt: after_tool }',
238
238
  '',
239
239
  ].join('\n'));
@@ -1,4 +1,4 @@
1
- import type { AgentSelection, ApprovalMode, FilesystemMode, FleetPermissionMode, MonitorInterrupt, MonitorMode, ResolvedRole, SessionBackendId, UnattendedMode } from './config.js';
1
+ import type { AgentSelection, ApprovalMode, FilesystemMode, FleetPermissionMode, MonitorInterrupt, MonitorMode, ResolvedRole, SessionBackendId } from './config.js';
2
2
  import type { IsolationBackendId, NetworkMode, OnUnavailable } from './isolation/types.js';
3
3
  /**
4
4
  * Operator-facing launch configuration captured at the launch boundary from
@@ -29,7 +29,8 @@ export interface AgentLaunchConfiguration {
29
29
  mission?: string;
30
30
  approval: ApprovalMode;
31
31
  filesystem: FilesystemMode;
32
- unattended: UnattendedMode;
32
+ /** Retired (D6): present only in records written before every permission request waited for the Owner. */
33
+ unattended?: 'deny' | 'wait';
33
34
  /** Portable policy plus the exact native runtime mode after harness_options. */
34
35
  permissionMode: {
35
36
  fleetMode: FleetPermissionMode;
@@ -48,7 +48,6 @@ export function summarizeResolvedLaunch(role, origins) {
48
48
  ...(mission ? { mission } : {}),
49
49
  approval: role.permissions.approval,
50
50
  filesystem: role.permissions.filesystem,
51
- unattended: role.permissions.unattended,
52
51
  permissionMode: origins.permissionMode,
53
52
  monitor: { mode: role.monitor.mode, interrupt: role.monitor.interrupt },
54
53
  ...(role.isolation?.backend ? { isolation: {
@@ -108,8 +107,8 @@ function mandatoryComponents(configuration) {
108
107
  `harness ${markdownCode(configuration.harness)}`,
109
108
  `model ${configuration.model === null ? 'harness-default' : markdownCode(configuration.model)}`,
110
109
  configuration.effort ? `effort ${markdownProse(configuration.effort)}` : undefined,
111
- `approval=${configuration.approval}, filesystem=${configuration.filesystem}, `
112
- + `unattended=${configuration.unattended}`,
110
+ `approval=${configuration.approval}, filesystem=${configuration.filesystem}`
111
+ + (configuration.unattended ? `, unattended=${configuration.unattended}` : ''),
113
112
  `mode ${configuration.permissionMode.fleetMode}/${markdownProse(configuration.permissionMode.nativeMode)}`,
114
113
  ].filter((part) => Boolean(part));
115
114
  }
@@ -0,0 +1,37 @@
1
+ import { type StatusNotificationEvent, type StatusRecord } from '../statuses/status-store.js';
2
+ import type { ProducerConfig } from './outbox.js';
3
+ /** The notification service's own bounds, in UTF-16 code units (it checks `string.length`). Previews only: the card keeps the full text. */
4
+ export declare const PUSH_TITLE_MAX = 160, PUSH_BODY_MAX = 200;
5
+ /** Push text from the kind's template: the agent's name and the status title; the body's first line as a preview. */
6
+ export declare function statusPush(status: StatusRecord): {
7
+ title: string;
8
+ body: string;
9
+ };
10
+ /** The `/api/v1/send` or `/api/v1/resolve` request for one pending event. */
11
+ export declare function statusRequest(status: StatusRecord, event: StatusNotificationEvent): {
12
+ path: string;
13
+ body: Record<string, unknown>;
14
+ };
15
+ /**
16
+ * Sends the push and resolve events committed with each status change. Owned by the Fleet manager, so pushes do not
17
+ * depend on the web console. Events stay durable in their status until the service accepts them; per status they go
18
+ * strictly in order (a resolve never precedes its send). A rejected event is retained and retried on the recovery
19
+ * timer only; one status's failure does not block others.
20
+ */
21
+ export declare class StatusNotificationProducer {
22
+ private readonly config;
23
+ private readonly warn;
24
+ private readonly request;
25
+ private timer?;
26
+ private dirty;
27
+ private running?;
28
+ private stopped;
29
+ /** The last status a pass attempted; the next pass starts after it, so rejected events never starve later statuses. */
30
+ private cursor?;
31
+ private readonly shutdown;
32
+ constructor(config: ProducerConfig, warn?: (line: string) => void, request?: typeof fetch, observe?: boolean);
33
+ drain(): Promise<void>;
34
+ private retry;
35
+ private drainOnce;
36
+ close(): Promise<void>;
37
+ }
@@ -0,0 +1,146 @@
1
+ import { observeFleetResources } from '../application/resource-observer.js';
2
+ import { statusKind } from '../statuses/status-kinds.js';
3
+ import { acknowledgeStatusNotification, pendingStatusNotifications, statusesDir, } from '../statuses/status-store.js';
4
+ /** The notification service's own bounds, in UTF-16 code units (it checks `string.length`). Previews only: the card keeps the full text. */
5
+ export const PUSH_TITLE_MAX = 160, PUSH_BODY_MAX = 200;
6
+ /** Clip to `max` UTF-16 units, never splitting a code point; the ellipsis counts toward the limit. */
7
+ const clip = (text, max) => {
8
+ if (text.length <= max)
9
+ return text;
10
+ let out = '';
11
+ for (const point of text) {
12
+ if (out.length + point.length > max - 1)
13
+ break;
14
+ out += point;
15
+ }
16
+ return out + '…';
17
+ };
18
+ /** Push text from the kind's template: the agent's name and the status title; the body's first line as a preview. */
19
+ export function statusPush(status) {
20
+ const agent = status.author.display_name ?? status.author.role;
21
+ const template = statusKind(status.kind)?.push ?? '<Agent>: <title>';
22
+ const title = clip(template.replace('<Agent>', agent).replace('<title>', status.title).replace('<Mission>', status.task_id ?? ''), PUSH_TITLE_MAX);
23
+ const line = status.body.split('\n').map(text => text.replace(/^\s*(?:#{1,6}\s|>\s?|[-*+]\s|\d+\.\s)*/, '').trim()).find(Boolean);
24
+ return { title, body: clip(line ?? 'Open the feed', PUSH_BODY_MAX) };
25
+ }
26
+ /** The `/api/v1/send` or `/api/v1/resolve` request for one pending event. */
27
+ export function statusRequest(status, event) {
28
+ if (event.op === 'resolve')
29
+ return { path: '/api/v1/resolve', body: { eventId: event.eventId } };
30
+ return { path: '/api/v1/send', body: {
31
+ eventId: event.eventId, ...statusPush(status),
32
+ target: { kind: 'status', authorCid: status.author.identity_cid, statusId: status.status_id },
33
+ ...(status.task_id ? { taskId: status.task_id } : {}), delivery: event.delivery,
34
+ } };
35
+ }
36
+ /**
37
+ * Sends the push and resolve events committed with each status change. Owned by the Fleet manager, so pushes do not
38
+ * depend on the web console. Events stay durable in their status until the service accepts them; per status they go
39
+ * strictly in order (a resolve never precedes its send). A rejected event is retained and retried on the recovery
40
+ * timer only; one status's failure does not block others.
41
+ */
42
+ export class StatusNotificationProducer {
43
+ config;
44
+ warn;
45
+ request;
46
+ timer;
47
+ dirty = false;
48
+ running;
49
+ stopped = false;
50
+ /** The last status a pass attempted; the next pass starts after it, so rejected events never starve later statuses. */
51
+ cursor;
52
+ shutdown = new AbortController();
53
+ constructor(config, warn = () => { }, request = fetch, observe = true) {
54
+ this.config = config;
55
+ this.warn = warn;
56
+ this.request = request;
57
+ if (observe)
58
+ observeFleetResources({ retryWatchFailures: true, paths: [statusesDir()], roots: [] }, state => {
59
+ if (state.health !== 'healthy')
60
+ this.warn('Status notification observation unavailable; committed events retained');
61
+ else {
62
+ this.dirty = true;
63
+ void this.drain();
64
+ }
65
+ }, this.shutdown.signal);
66
+ void this.drain();
67
+ }
68
+ drain() {
69
+ if (this.stopped)
70
+ return Promise.resolve();
71
+ if (this.running) {
72
+ this.dirty = true;
73
+ return this.running;
74
+ }
75
+ this.dirty = false;
76
+ clearTimeout(this.timer);
77
+ this.timer = undefined;
78
+ this.running = this.drainOnce().catch(() => {
79
+ this.warn('Status notification snapshot unavailable; committed events retained');
80
+ this.retry();
81
+ }).finally(() => {
82
+ this.running = undefined;
83
+ if (this.dirty && !this.stopped) {
84
+ this.dirty = false;
85
+ void this.drain();
86
+ }
87
+ });
88
+ return this.running;
89
+ }
90
+ retry(delay = 3000) {
91
+ if (this.stopped || this.timer)
92
+ return;
93
+ this.timer = setTimeout(() => { this.timer = undefined; void this.drain(); }, delay);
94
+ this.timer.unref();
95
+ }
96
+ async drainOnce() {
97
+ const all = pendingStatusNotifications();
98
+ // Pending statuses come oldest first; continue after the last attempted one, wrapping around.
99
+ const cursor = this.cursor, after = (status) => !!cursor
100
+ && (status.created_at.localeCompare(cursor.created_at) || status.status_id.localeCompare(cursor.status_id)) > 0;
101
+ const start = cursor ? Math.max(0, all.findIndex(after)) : 0;
102
+ const pending = [...all.slice(start), ...all.slice(0, start)].slice(0, 64);
103
+ let retained = false;
104
+ for (const status of pending) {
105
+ if (this.stopped)
106
+ return;
107
+ this.cursor = { created_at: status.created_at, status_id: status.status_id };
108
+ for (const event of status.notification_events) {
109
+ if (this.stopped)
110
+ return;
111
+ const { path, body } = statusRequest(status, event);
112
+ try {
113
+ const response = await this.request(this.config.origin + path, {
114
+ method: 'POST', redirect: 'error', signal: AbortSignal.any([this.shutdown.signal, AbortSignal.timeout(10_000)]),
115
+ headers: { ...(this.config.gatewayCredential
116
+ ? { 'X-Ours-Api-Token': this.config.gatewayCredential, 'X-Ours-Notifications-Producer': this.config.token }
117
+ : { Authorization: `Bearer ${this.config.token}` }), 'Content-Type': 'application/json' },
118
+ body: JSON.stringify(body),
119
+ });
120
+ const text = await response.text().catch(() => '');
121
+ // A resolve for an event the service never admitted (dropped or deleted) has nothing left to end.
122
+ const nothingToResolve = event.op === 'resolve' && response.status === 404 && /event not found/.test(text);
123
+ if (!response.ok && !nothingToResolve) {
124
+ this.warn(response.status === 400 || (response.status === 404 && event.op === 'resolve')
125
+ ? 'Notification service does not support status events yet; committed status events retained'
126
+ : `Status notification delivery pending (HTTP ${response.status}); committed event retained`);
127
+ retained = true;
128
+ break;
129
+ }
130
+ acknowledgeStatusNotification(status.status_id, event.eventId, event.op);
131
+ }
132
+ catch {
133
+ this.warn('Status notification delivery pending; committed event retained');
134
+ retained = true;
135
+ break;
136
+ }
137
+ }
138
+ }
139
+ // Failures wait for the recovery timer; a full batch that went through continues at once.
140
+ if (retained)
141
+ this.retry();
142
+ else if (all.length > pending.length && pendingStatusNotifications().length)
143
+ this.dirty = true;
144
+ }
145
+ async close() { this.stopped = true; clearTimeout(this.timer); this.shutdown.abort(); await this.running; }
146
+ }
@@ -40,9 +40,8 @@ export interface RolePermissionAnalysis {
40
40
  /** Whether those capabilities clear the unattended floor. */
41
41
  floor?: FloorResult;
42
42
  /**
43
- * How hard a floor shortfall is. A role that auto-denies (`unattended: deny`)
44
- * silently does less than asked, so that is a failure; one that waits can at
45
- * least be rescued by a human attaching a console, so that is a warning.
43
+ * How hard a floor shortfall is. Every permission request waits for the
44
+ * Owner's answer (D6), so a shortfall delays the agent and is a warning.
46
45
  */
47
46
  floorSeverity?: 'fail' | 'warn';
48
47
  /** Native settings that contradict the neutral block; empty when they agree. */
@@ -88,7 +88,8 @@ export function analyzeRolePermissions(role) {
88
88
  ? findConflicts(role, neutral.native, adapter.nativePermissionOverrides(role.harness_options, role))
89
89
  : [];
90
90
  const floor = checkUnattendedFloor(translation.capabilities, requiredUnattendedFloor(role));
91
- const floorSeverity = role.permissions.unattended === 'deny' ? 'fail' : 'warn';
91
+ // Below the floor, requests wait for the Owner (D6): nothing is denied silently, so a shortfall warns.
92
+ const floorSeverity = 'warn';
92
93
  return {
93
94
  ...base,
94
95
  supported: true,
@@ -100,8 +101,7 @@ export function analyzeRolePermissions(role) {
100
101
  conflicts,
101
102
  floorWarning: floor.meets ? undefined : (`role '${role.name}': resolved ${role.harness} permissions do not meet the unattended ` +
102
103
  `capability floor — missing ${floor.missing.join(', ')} ` +
103
- `(${formatNative(translation.native)}; unattended=${role.permissions.unattended} means these ` +
104
- `requests will ${role.permissions.unattended === 'deny' ? 'be denied silently' : 'block the turn'})`),
104
+ `(${formatNative(translation.native)}; these requests will wait for the Owner's answer)`),
105
105
  warnings: [
106
106
  ...translation.warnings.map(w => `role '${role.name}': ${w}`),
107
107
  ...(inspection?.warning ? [`role '${role.name}': ${inspection.warning}`] : []),
@@ -109,6 +109,16 @@ const CURRENT_REQUEST_FINGERPRINTS = Object.freeze({
109
109
  'roles/LocalCoordinator.yaml': ['0fdbb9b56fedcf1897ad8044d6d88eaefcd5ccc48176860da3f7a1efe22da51d'],
110
110
  'roles/Coordinator.yaml': ['c9038f3e33068058884e2ae52f6d569c22c4d56fcdb345e9381866c6de38d9a9'],
111
111
  });
112
+ // The packaged revision-13 Agent Templates and FleetCoordinator before D6 retired `permissions.unattended`
113
+ // (every permission request now waits for the Owner). Untouched copies adopt the current text; edited ones
114
+ // stay, and their retired key is accepted, ignored and warned about at startup.
115
+ const UNATTENDED_RETIREMENT_FINGERPRINTS = Object.freeze({
116
+ 'agent_templates/LocalCoordinator.yaml': ['55ec7d79287e191937d08698ee801e147d376b5d46407d49594e25e6f056828c'],
117
+ 'agent_templates/Developer.yaml': ['3c3f80fa5dbeae805f171e2bf22111e632f19906bfe1ae32eb071392fce58a1d'],
118
+ 'agent_templates/Critic.yaml': ['bd8e70decd2c9a389e9c93aa9b61ae1941e23203518a474e30fb2d62014bcae9'],
119
+ 'agent_templates/Engineer.yaml': ['9b784c8be4cc1dec96501351c645124da862ebf603ea251851c23cae1725e463'],
120
+ 'agents/FleetCoordinator.yaml': ['fd72781a253afb356be34a287a09965e1bb6855954fe4d1b398b54269a1d5cd6'],
121
+ });
112
122
  const CURRENT_ROLE_DEFAULTS = new Set([
113
123
  'roles/Coordinator.yaml', 'roles/LocalCoordinator.yaml', 'roles/Developer.yaml', 'roles/Critic.yaml',
114
124
  'roles/Engineer.yaml',
@@ -243,6 +253,7 @@ export function migratePackagedRoleDefaults(configuration, options = {}, hooks =
243
253
  ...Object.keys(PEER_WAIT_REMINDER_FINGERPRINTS),
244
254
  ...Object.keys(REVIEW_PACKAGE_FINGERPRINTS),
245
255
  ...Object.keys(CURRENT_REQUEST_FINGERPRINTS),
256
+ ...Object.keys(UNATTENDED_RETIREMENT_FINGERPRINTS),
246
257
  ]);
247
258
  for (const relative of known) {
248
259
  const path = join(root, relative);
@@ -261,6 +272,7 @@ export function migratePackagedRoleDefaults(configuration, options = {}, hooks =
261
272
  ...(PEER_WAIT_REMINDER_FINGERPRINTS[relative] ?? []),
262
273
  ...(REVIEW_PACKAGE_FINGERPRINTS[relative] ?? []),
263
274
  ...(CURRENT_REQUEST_FINGERPRINTS[relative] ?? []),
275
+ ...(UNATTENDED_RETIREMENT_FINGERPRINTS[relative] ?? []),
264
276
  ].some(expected => expected !== undefined && actual === expected);
265
277
  if (recognized)
266
278
  (CURRENT_ROLE_DEFAULTS.has(relative) ? replacements : removals).push(path);