@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.
- package/README.md +29 -32
- package/contrib/.claude-plugin/marketplace.json +1 -1
- package/contrib/claude-native/hooks/register.js +108 -31
- package/dist/agent-ours/mcp-endpoint.d.ts +3 -0
- package/dist/agent-ours/mcp-endpoint.js +3 -0
- package/dist/agent-ours/service.d.ts +3 -0
- package/dist/agent-ours/service.js +19 -2
- package/dist/application/conversation-history.js +2 -2
- package/dist/application/fleet-query-service.js +6 -3
- package/dist/application/native-claude-conversation.js +13 -2
- package/dist/application/native-conversation.d.ts +5 -0
- package/dist/application/native-conversation.js +30 -5
- package/dist/application/native-conversations.d.ts +3 -0
- package/dist/application/native-conversations.js +2 -0
- package/dist/application/role-creation-service.js +0 -3
- package/dist/application/session-control.d.ts +3 -0
- package/dist/application/session-control.js +5 -0
- package/dist/application/types.d.ts +5 -0
- package/dist/build-info.json +4 -4
- package/dist/cli.js +2 -3
- package/dist/config.d.ts +9 -2
- package/dist/config.js +15 -4
- package/dist/docs.d.ts +5 -7
- package/dist/docs.js +38 -46
- package/dist/doctor.js +4 -6
- package/dist/file-delivery/store.d.ts +12 -0
- package/dist/file-delivery/store.js +24 -2
- package/dist/fleet-command-audit.js +3 -2
- package/dist/fleet-proxy.js +0 -1
- package/dist/harness/hermes-permissions.js +1 -1
- package/dist/harness/hermes-session.js +0 -1
- package/dist/init-wizard.js +2 -2
- package/dist/lifecycle-summary.d.ts +3 -2
- package/dist/lifecycle-summary.js +2 -3
- package/dist/native-participation-cli.js +55 -10
- package/dist/native-participation.d.ts +174 -0
- package/dist/native-participation.js +67 -0
- package/dist/notifications/status-producer.d.ts +37 -0
- package/dist/notifications/status-producer.js +146 -0
- package/dist/permissions.d.ts +2 -3
- package/dist/permissions.js +3 -3
- package/dist/preset-migration.js +12 -0
- package/dist/rooms-tasks/cli.js +2 -6
- package/dist/rooms-tasks/deletion.js +3 -0
- package/dist/rooms-tasks/member-overrides.d.ts +2 -1
- package/dist/rooms-tasks/member-overrides.js +1 -4
- package/dist/rooms-tasks/task-contributions.d.ts +15 -0
- package/dist/rooms-tasks/task-contributions.js +13 -2
- package/dist/runner.js +24 -8
- package/dist/session/acp.d.ts +9 -29
- package/dist/session/acp.js +31 -308
- package/dist/session/codex-app-server.d.ts +9 -6
- package/dist/session/codex-app-server.js +19 -58
- package/dist/session/control.d.ts +5 -0
- package/dist/session/control.js +19 -3
- package/dist/session/conversation-types.d.ts +3 -2
- package/dist/session/status-notice.d.ts +24 -0
- package/dist/session/status-notice.js +38 -0
- package/dist/session/types.d.ts +2 -0
- package/dist/spawn.d.ts +1 -2
- package/dist/spawn.js +2 -6
- package/dist/statuses/permission-projection.d.ts +53 -0
- package/dist/statuses/permission-projection.js +317 -0
- package/dist/statuses/status-answers.d.ts +31 -0
- package/dist/statuses/status-answers.js +85 -0
- package/dist/statuses/status-feed.d.ts +85 -0
- package/dist/statuses/status-feed.js +122 -0
- package/dist/statuses/status-kinds.d.ts +15 -0
- package/dist/statuses/status-kinds.js +12 -0
- package/dist/statuses/status-ledger.d.ts +21 -0
- package/dist/statuses/status-ledger.js +80 -0
- package/dist/statuses/status-routes.d.ts +43 -0
- package/dist/statuses/status-routes.js +140 -0
- package/dist/statuses/status-store.d.ts +257 -0
- package/dist/statuses/status-store.js +605 -0
- package/dist/statuses/status-tools.d.ts +21 -0
- package/dist/statuses/status-tools.js +126 -0
- package/dist/supervisor/manager.js +11 -0
- package/dist/web/resource-views.d.ts +3 -1
- package/dist/web/resource-views.js +6 -2
- package/dist/web/runtime.js +21 -0
- package/dist/web/server.js +15 -0
- package/docs/acp-files.md +9 -7
- package/docs/native-session-participation.md +14 -0
- package/docs/validation/managed-cli-permissions.md +1 -1
- package/examples/fleet/agents/Alice.yaml +1 -1
- package/examples/fleet/agents/FleetCoordinator.yaml +1 -1
- package/examples/fleet.yaml +0 -1
- package/package.json +2 -2
- package/presets/fleet/agent_templates/Critic.yaml +1 -1
- package/presets/fleet/agent_templates/Developer.yaml +1 -1
- package/presets/fleet/agent_templates/Engineer.yaml +1 -1
- package/presets/fleet/agent_templates/LocalCoordinator.yaml +1 -1
- package/presets/fleet/agents/FleetCoordinator.yaml +1 -1
- package/presets/fleet.yaml +1 -1
- package/presets/manifest.json +1 -1
package/README.md
CHANGED
|
@@ -389,7 +389,6 @@ defaults:
|
|
|
389
389
|
permissions: # common intent, translated by each harness/backend
|
|
390
390
|
approval: ask # ask | auto | allow (`deny` is a deprecated alias)
|
|
391
391
|
filesystem: workspace # read-only | workspace | unrestricted
|
|
392
|
-
unattended: deny # deny | wait
|
|
393
392
|
monitor:
|
|
394
393
|
mode: fleet # fleet (default) | native
|
|
395
394
|
worklog: # built-ins shown; set false to opt out
|
|
@@ -403,7 +402,7 @@ Agent Template document (\`~/fleet/agent_templates/Worker.yaml\`) is inert and r
|
|
|
403
402
|
```yaml
|
|
404
403
|
role: { ref: developer }
|
|
405
404
|
brain: { ref: claude-default }
|
|
406
|
-
permissions: { approval: ask, filesystem: workspace
|
|
405
|
+
permissions: { approval: ask, filesystem: workspace }
|
|
407
406
|
monitor: { mode: fleet, interrupt: after_tool }
|
|
408
407
|
loops: # optional; temporary launches only
|
|
409
408
|
progress:
|
|
@@ -826,31 +825,31 @@ owner-channel task route; a no-op Coordinator pass should complete silently.
|
|
|
826
825
|
|
|
827
826
|
### Never-prompt failure
|
|
828
827
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
agent does less than its briefing told it to, reports
|
|
832
|
-
distinguishes that from having done the work.
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
828
|
+
A permission mode that suppresses the prompt without granting the action
|
|
829
|
+
(Claude `dontAsk`) refuses a request **inside the harness** — no prompt, no
|
|
830
|
+
error, no log line. The agent does less than its briefing told it to, reports
|
|
831
|
+
success, and nothing distinguishes that from having done the work.
|
|
832
|
+
|
|
833
|
+
Every request that reaches Fleet waits for the Owner's answer, in the agent's
|
|
834
|
+
session or in the feed, with no timeout and no automatic denial, attached
|
|
835
|
+
console or not. It ends without an answer only when its turn or session really
|
|
836
|
+
ends. The retired `unattended` key is accepted and ignored, with one startup
|
|
837
|
+
warning naming the role. Fleet never decides a raised request itself:
|
|
838
|
+
`approval` only selects the harness's native mode, which decides whether a
|
|
839
|
+
request is raised at all, and the deprecated `deny` alias no longer refuses
|
|
840
|
+
anything. Owner decisions, and requests ended with their turn or session
|
|
841
|
+
(recorded as cancelled), are written to
|
|
842
|
+
`~/.ours-fleet/agents/<Name>/.session-events.jsonl` with the reason, and
|
|
843
|
+
`ours-fleet peek`/`attach` render them.
|
|
844
|
+
|
|
845
|
+
To catch an under-permissioned role **before** it runs, see the capability floor
|
|
846
|
+
below — `ours-fleet doctor` warns about it.
|
|
848
847
|
|
|
849
848
|
### The unattended capability floor
|
|
850
849
|
|
|
851
|
-
A fleet role runs with
|
|
852
|
-
|
|
853
|
-
|
|
850
|
+
A fleet role usually runs with nobody watching. Below the floor, each action of
|
|
851
|
+
its own briefing raises a permission request that waits for the Owner, and the
|
|
852
|
+
agent makes no progress meanwhile.
|
|
854
853
|
|
|
855
854
|
`ours-fleet config` and `ours-fleet doctor` therefore resolve each role's
|
|
856
855
|
neutral `permissions:` through its harness adapter and check what the resulting
|
|
@@ -865,10 +864,8 @@ native settings actually grant, against a fixed floor:
|
|
|
865
864
|
| `workspace-edit` | edit and test files in its working directory |
|
|
866
865
|
| `status-commands` | run the inspection commands its briefing prescribes |
|
|
867
866
|
|
|
868
|
-
`doctor` reports this per role as `unattended floor: <Role>`. A role
|
|
869
|
-
|
|
870
|
-
those requests with nobody to see it. With `unattended: wait` it **warns**,
|
|
871
|
-
since a human can still attach a console and answer.
|
|
867
|
+
`doctor` reports this per role as `unattended floor: <Role>`. A role that cannot
|
|
868
|
+
meet the floor **warns**: those requests will wait for the Owner's answer.
|
|
872
869
|
|
|
873
870
|
**Security meaning.** For native Codex, Fleet translates `ask` → `untrusted`,
|
|
874
871
|
`auto` → `on-request`, and `allow` → `never`; users configure only the Fleet
|
|
@@ -1396,7 +1393,6 @@ model: gpt-5.4
|
|
|
1396
1393
|
permissions:
|
|
1397
1394
|
approval: auto
|
|
1398
1395
|
filesystem: read-only
|
|
1399
|
-
unattended: deny
|
|
1400
1396
|
harness_options:
|
|
1401
1397
|
launcher: auto
|
|
1402
1398
|
monitor: true
|
|
@@ -1701,9 +1697,10 @@ or a model's claim does not prove that a tool works. Fleet adds no probe prompt.
|
|
|
1701
1697
|
|
|
1702
1698
|
These modes cover dangerous terminal command prompts and `write_file`/`patch`.
|
|
1703
1699
|
They do not provide universal approval for browser, memory, skills, delegation
|
|
1704
|
-
or MCP side effects. Native protected-action floors remain. Fleet
|
|
1705
|
-
|
|
1706
|
-
seconds
|
|
1700
|
+
or MCP side effects. Native protected-action floors remain. Fleet waits for the
|
|
1701
|
+
Owner without a timeout; Hermes's own tested native dangerous-command timeout of
|
|
1702
|
+
60 seconds still ends an unanswered request, which Fleet records as ended when
|
|
1703
|
+
its turn finishes. Workspace confinement is approximate without verified enforcing Fleet
|
|
1707
1704
|
isolation; unrestricted filesystem mode is also available. Read-only mode,
|
|
1708
1705
|
legacy approval `deny`, Fleet provider overrides, effort, model chains, native
|
|
1709
1706
|
monitoring and `after_tool` are unsupported.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"ours-fleet
|
|
1
|
+
{"name":"ours-fleet","owner":{"name":"ours.network"},"plugins":[{"name":"ours-fleet-native","source":"./claude-native","description":"Shared native Human conversation with local Fleet"}]}
|
|
@@ -1,59 +1,136 @@
|
|
|
1
|
+
// Event-driven bridge between this Claude session and the local Ours Fleet.
|
|
2
|
+
//
|
|
3
|
+
// Nothing runs on a timer. One long-lived `claude-watch` child per session says "input" when the App queues a
|
|
4
|
+
// prompt (and keeps Fleet's heartbeat); the one-shot `claude-bridge` exchange runs only when something
|
|
5
|
+
// happened: the session started or joined, a turn started or ended, a message was appended, or input arrived.
|
|
6
|
+
|
|
7
|
+
let launcher = null;
|
|
1
8
|
let polling = false;
|
|
9
|
+
let again = false;
|
|
10
|
+
let turnActive = false;
|
|
2
11
|
let submitting = null;
|
|
3
12
|
let active = null;
|
|
4
13
|
let activeTurn = null;
|
|
14
|
+
let lastFailure = null;
|
|
5
15
|
const correlations = {};
|
|
6
16
|
const finished = [];
|
|
7
17
|
|
|
18
|
+
// Run Fleet with the absolute Node and entry its participation hook was installed with. The session's PATH may
|
|
19
|
+
// resolve another `node` (an older system one) that Fleet refuses, which made every bridge call exit 1.
|
|
20
|
+
async function fleet($) {
|
|
21
|
+
if (launcher) return launcher;
|
|
22
|
+
const hooks = await $.settings.read({ key: 'hooks' }).catch(() => undefined);
|
|
23
|
+
for (const entries of Object.values(hooks ?? {})) {
|
|
24
|
+
for (const entry of Array.isArray(entries) ? entries : []) {
|
|
25
|
+
for (const hook of Array.isArray(entry?.hooks) ? entry.hooks : []) {
|
|
26
|
+
if (hook?.type === 'command' && typeof hook.command === 'string' && Array.isArray(hook.args)
|
|
27
|
+
&& hook.args.length === 3 && hook.args[1] === 'participation' && hook.args[2] === 'hook') {
|
|
28
|
+
launcher = [hook.command, hook.args[0]];
|
|
29
|
+
return launcher;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
launcher = ['ours-fleet'];
|
|
35
|
+
return launcher;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function failed($, text) {
|
|
39
|
+
const reason = String(text ?? '').trim().split('\n').filter(Boolean).at(-1) || 'no detail';
|
|
40
|
+
// One visible line per distinct failure; every occurrence goes to the debug log.
|
|
41
|
+
$.ui.log(`Ours Fleet bridge: ${reason}`, { to: 'debug' });
|
|
42
|
+
if (reason !== lastFailure) $.ui.log(`Ours Fleet could not exchange state with this session: ${reason}`);
|
|
43
|
+
lastFailure = reason;
|
|
44
|
+
}
|
|
45
|
+
|
|
8
46
|
async function pulse($) {
|
|
9
|
-
if (polling) return;
|
|
47
|
+
if (polling) { again = true; return; }
|
|
10
48
|
polling = true;
|
|
11
49
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
submitting =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
50
|
+
do {
|
|
51
|
+
again = false;
|
|
52
|
+
const id = await $.session.id();
|
|
53
|
+
const info = await $.session.info();
|
|
54
|
+
const tail = await $.session.messages({ last: 1 });
|
|
55
|
+
if (!Array.isArray(tail)) return;
|
|
56
|
+
const ready = !turnActive && submitting === null && active === null;
|
|
57
|
+
const response = await $.process.run([...await fleet($), 'participation', 'claude-bridge', id], {
|
|
58
|
+
stdin: JSON.stringify({ transcriptPath: info.transcriptPath, lastMessageId: tail.at(-1)?.uuid ?? null,
|
|
59
|
+
status: turnActive ? 'busy' : 'idle', correlations, finished, ready }),
|
|
60
|
+
timeoutMs: 10000,
|
|
61
|
+
});
|
|
62
|
+
if (response.exitCode !== 0) { failed($, response.stderr || `exit code ${response.exitCode}`); return; }
|
|
63
|
+
lastFailure = null;
|
|
64
|
+
const command = JSON.parse(response.stdout).command;
|
|
65
|
+
if (!command || submitting !== null || active !== null) continue;
|
|
66
|
+
submitting = command.clientId;
|
|
67
|
+
// Never claim terminal-local consent. The authenticated App Human supplies
|
|
68
|
+
// these words; Claude keeps the plugin origin and its own native controls.
|
|
69
|
+
$.prompt.submit({ text: command.text, asUser: true }).then(result => {
|
|
70
|
+
if (result?.drop) { finished.push({ clientId: command.clientId, outcome: 'cancelled' }); void pulse($); }
|
|
71
|
+
submitting = null;
|
|
72
|
+
}, () => {
|
|
73
|
+
finished.push({ clientId: command.clientId, outcome: 'failed' });
|
|
74
|
+
submitting = null;
|
|
75
|
+
void pulse($);
|
|
76
|
+
});
|
|
77
|
+
} while (again);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
failed($, error?.message ?? error);
|
|
33
80
|
} finally { polling = false; }
|
|
34
81
|
}
|
|
35
82
|
|
|
83
|
+
async function watch($) {
|
|
84
|
+
const id = await $.session.id();
|
|
85
|
+
const child = $.process.spawn({ argv: [...await fleet($), 'participation', 'claude-watch', id] });
|
|
86
|
+
let buffer = '';
|
|
87
|
+
for await (const piece of child) {
|
|
88
|
+
if (piece.stream === 'stderr') { failed($, piece.text); continue; }
|
|
89
|
+
if (piece.stream !== 'stdout') continue;
|
|
90
|
+
buffer += piece.text;
|
|
91
|
+
for (let end; (end = buffer.indexOf('\n')) >= 0;) {
|
|
92
|
+
const line = buffer.slice(0, end).trim();
|
|
93
|
+
buffer = buffer.slice(end + 1);
|
|
94
|
+
if (line === 'joined' || line === 'input') void pulse($);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
36
99
|
export function register(on) {
|
|
37
|
-
on('session.start', ($, e, next) => {
|
|
38
|
-
|
|
39
|
-
|
|
100
|
+
on('session.start', async ($, e, next) => {
|
|
101
|
+
const started = await next(e);
|
|
102
|
+
if (e.isInteractive) {
|
|
103
|
+
void pulse($);
|
|
104
|
+
void watch($).catch(error => failed($, `the Fleet watcher stopped (${error?.message ?? error})`));
|
|
105
|
+
}
|
|
106
|
+
return started;
|
|
40
107
|
});
|
|
41
108
|
on('session.append', ($, e, next) => {
|
|
42
109
|
if (submitting && e.agentId === undefined && e.message.type === 'user' && e.origin.kind === 'plugin' && e.origin.name === 'ours-fleet-native') {
|
|
43
110
|
correlations[e.uuid] = submitting;
|
|
44
111
|
active = submitting;
|
|
45
112
|
}
|
|
46
|
-
|
|
113
|
+
const result = next(e);
|
|
114
|
+
if (e.agentId === undefined) void pulse($);
|
|
115
|
+
return result;
|
|
47
116
|
});
|
|
48
117
|
on('turn.start', ($, e, next) => {
|
|
49
|
-
if (e.agentId === undefined
|
|
118
|
+
if (e.agentId === undefined) {
|
|
119
|
+
turnActive = true;
|
|
120
|
+
if (active && activeTurn === null) activeTurn = e.turnId;
|
|
121
|
+
void pulse($);
|
|
122
|
+
}
|
|
50
123
|
return next(e);
|
|
51
124
|
});
|
|
52
125
|
on('turn.complete', ($, e, next) => {
|
|
53
|
-
if (e.agentId === undefined
|
|
54
|
-
|
|
55
|
-
active
|
|
56
|
-
|
|
126
|
+
if (e.agentId === undefined) {
|
|
127
|
+
turnActive = false;
|
|
128
|
+
if (active && activeTurn === e.turnId) {
|
|
129
|
+
finished.push({ clientId: active, outcome: e.reason === 'aborted' ? 'cancelled' : e.reason === 'answer' ? 'completed' : 'failed' });
|
|
130
|
+
active = null;
|
|
131
|
+
activeTurn = null;
|
|
132
|
+
}
|
|
133
|
+
void pulse($);
|
|
57
134
|
}
|
|
58
135
|
return next(e);
|
|
59
136
|
});
|
|
@@ -7,6 +7,7 @@ import { FileCallbacks } from './file-rpc.js';
|
|
|
7
7
|
import type { AgentOursRuntime } from './runtime.js';
|
|
8
8
|
import { type ReminderToolBackend } from '../reminders/tools.js';
|
|
9
9
|
import { type TaskToolBinding } from '../rooms-tasks/task-tools.js';
|
|
10
|
+
import { type StatusToolBinding } from '../statuses/status-tools.js';
|
|
10
11
|
export interface EndpointOptions {
|
|
11
12
|
socket: string;
|
|
12
13
|
capability: string;
|
|
@@ -20,6 +21,8 @@ export interface EndpointOptions {
|
|
|
20
21
|
reminders?: () => ReminderToolBackend | undefined;
|
|
21
22
|
/** Task Progress / To review tools for the task this agent was launched for. */
|
|
22
23
|
task?: () => TaskToolBinding | undefined;
|
|
24
|
+
/** Status publish/close/get for this agent, with or without a task. */
|
|
25
|
+
status?: () => StatusToolBinding | undefined;
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* Listen on the bridge socket. A close unlinks it, but a predecessor that ended
|
|
@@ -8,6 +8,7 @@ import { FileCallbacks } from './file-rpc.js';
|
|
|
8
8
|
import { Wire } from './wire.js';
|
|
9
9
|
import { registerReminderTools } from '../reminders/tools.js';
|
|
10
10
|
import { registerTaskTools } from '../rooms-tasks/task-tools.js';
|
|
11
|
+
import { registerStatusTools } from '../statuses/status-tools.js';
|
|
11
12
|
const ORPHAN_PROBE_TIMEOUT_MS = 1_000;
|
|
12
13
|
function listenOnce(server, path) {
|
|
13
14
|
return new Promise((resolve, reject) => {
|
|
@@ -133,6 +134,8 @@ export async function startMcpEndpoint(options) {
|
|
|
133
134
|
registerReminderTools(mcp, options.reminders, admit);
|
|
134
135
|
if (options.task)
|
|
135
136
|
registerTaskTools(mcp, options.task, admit);
|
|
137
|
+
if (options.status)
|
|
138
|
+
registerStatusTools(mcp, options.status, admit);
|
|
136
139
|
wire.onClose = () => {
|
|
137
140
|
clearTimeout(deadline);
|
|
138
141
|
sockets.delete(wire);
|
|
@@ -5,6 +5,7 @@ import type { ResolvedRole } from '../config.js';
|
|
|
5
5
|
import { AgentOursRuntime } from './runtime.js';
|
|
6
6
|
import { startMcpEndpoint } from './mcp-endpoint.js';
|
|
7
7
|
import type { TaskToolBinding } from '../rooms-tasks/task-tools.js';
|
|
8
|
+
import type { StatusToolBinding } from '../statuses/status-tools.js';
|
|
8
9
|
export declare const privateRuntimeRoot: () => string;
|
|
9
10
|
export interface ManagedAgentService {
|
|
10
11
|
runtime: AgentOursRuntime;
|
|
@@ -30,6 +31,8 @@ export declare function currentChatFileHandler(options: {
|
|
|
30
31
|
}): NonNullable<Parameters<typeof startMcpEndpoint>[0]['currentChatFile']>;
|
|
31
32
|
/** Task membership comes from supervisor launch records, re-read per call so a restart cannot leave it stale. */
|
|
32
33
|
export declare function taskToolBinding(role: ResolvedRole, stateDir: string, cid: string | undefined): TaskToolBinding | undefined;
|
|
34
|
+
/** Every agent may publish statuses; the mission binding is added only when the supervisor launched it for a task. */
|
|
35
|
+
export declare function statusToolBinding(role: ResolvedRole, stateDir: string, cid: string | undefined): StatusToolBinding;
|
|
33
36
|
/** Only trusted launch orchestration may write this descriptor, never the child. */
|
|
34
37
|
export declare function storeRoomSecret(role: ResolvedRole): void;
|
|
35
38
|
export declare function storeTemporaryLaunch(role: ResolvedRole, action: string): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { chatFilePath } from '../file-delivery/reader.js';
|
|
2
|
-
import { ArtifactStore } from '../file-delivery/store.js';
|
|
2
|
+
import { ArtifactStore, artifactStoreKey, readDeliveredFile } from '../file-delivery/store.js';
|
|
3
|
+
import { conversationHasAttachment } from '../application/conversation-history.js';
|
|
3
4
|
import { resolve, basename, extname } from 'node:path';
|
|
4
5
|
import { socketPath as privateSocketPath } from '../socket-path.js';
|
|
5
6
|
import { randomBytes, randomUUID } from 'node:crypto';
|
|
@@ -36,7 +37,7 @@ export function currentChatFileHandler(options) {
|
|
|
36
37
|
const name = input.filename ?? basename(input.path);
|
|
37
38
|
if (!name || Buffer.byteLength(name) > 240 || /[\/\\\x00-\x1f]/.test(name) || name === '.' || name === '..')
|
|
38
39
|
throw Error('INVALID_FILENAME');
|
|
39
|
-
const mime = input.mime ?? { '.txt': 'text/plain', '.md': 'text/markdown', '.pdf': 'application/pdf', '.json': 'application/json', '.html': 'text/html', '.png': 'image/png' }[extname(name).toLowerCase()] ?? 'application/octet-stream';
|
|
40
|
+
const mime = input.mime ?? { '.txt': 'text/plain', '.md': 'text/markdown', '.pdf': 'application/pdf', '.json': 'application/json', '.html': 'text/html', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.gif': 'image/gif', '.webp': 'image/webp' }[extname(name).toLowerCase()] ?? 'application/octet-stream';
|
|
40
41
|
if (mime.length > 200 || !/^[A-Za-z0-9.+-]+\/[A-Za-z0-9.+-]+$/.test(mime))
|
|
41
42
|
throw Error('INVALID_MIME');
|
|
42
43
|
return sender(input, extra.signal, async (binding) => {
|
|
@@ -61,6 +62,21 @@ export function taskToolBinding(role, stateDir, cid) {
|
|
|
61
62
|
return undefined;
|
|
62
63
|
return { taskId, role: role.name, ...(cid ? { identityCid: cid } : {}), taskOwned: !!owned };
|
|
63
64
|
}
|
|
65
|
+
/** Every agent may publish statuses; the mission binding is added only when the supervisor launched it for a task. */
|
|
66
|
+
export function statusToolBinding(role, stateDir, cid) {
|
|
67
|
+
const task = taskToolBinding(role, stateDir, cid);
|
|
68
|
+
return {
|
|
69
|
+
role: role.name, ...(cid ? { identityCid: cid } : {}), ...(role.identity ? { displayName: role.identity } : {}), ...(task ? { task } : {}),
|
|
70
|
+
// Only files this agent itself delivered in its current conversation incarnation resolve.
|
|
71
|
+
attachment: async (id) => {
|
|
72
|
+
const { record } = await readDeliveredFile(stateDir, id);
|
|
73
|
+
// Only a file the Owner actually received in this conversation; an unpublished copy never resolves.
|
|
74
|
+
if (!await conversationHasAttachment(stateDir, record))
|
|
75
|
+
throw Error('ARTIFACT_NOT_PUBLISHED');
|
|
76
|
+
return { id: record.id, name: record.name, media_type: record.mimeType, size: record.size, sha256: record.sha256, store: artifactStoreKey(stateDir) };
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
64
80
|
function roomSecretPath(role) {
|
|
65
81
|
const startup = role.roomMemberStartup;
|
|
66
82
|
return join(privateRuntimeRoot(), 'room-inputs', binderKey(startup.room_identity_cid, JSON.stringify([role.name, startup.invite_id])) + '.json');
|
|
@@ -272,6 +288,7 @@ export async function prepareManagedAgent(role, stateDir, temporary) {
|
|
|
272
288
|
remoteDaemonFiles: true,
|
|
273
289
|
reminders: () => reminders,
|
|
274
290
|
task: () => taskToolBinding(role, stateDir, runtime.snapshot.cid),
|
|
291
|
+
status: () => statusToolBinding(role, stateDir, runtime.snapshot.cid),
|
|
275
292
|
currentChatFile: currentChatFileHandler({
|
|
276
293
|
role, cwd, store: new ArtifactStore(stateDir), sender: () => fileSender,
|
|
277
294
|
privateState: [privateRuntimeRoot(), join(stateRoot(), 'private-file-delivery'), profile.configPath, profile.credentialPath],
|
|
@@ -2,7 +2,7 @@ import { createReadStream } from 'node:fs';
|
|
|
2
2
|
import { open, readFile, readdir, stat } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { createInterface } from 'node:readline';
|
|
5
|
-
const HISTORICAL_KINDS = ['file.attached', 'fleet.task_created', 'prompt.admitted', 'message.chunk', 'message.replace', 'tool.upsert', 'tool.content_chunk', 'turn.completed'];
|
|
5
|
+
const HISTORICAL_KINDS = ['file.attached', 'fleet.task_created', 'status.published', 'status.updated', 'status.answered', 'status.closed', 'prompt.admitted', 'message.chunk', 'message.replace', 'tool.upsert', 'tool.content_chunk', 'turn.completed'];
|
|
6
6
|
/** Whether a ledger event belongs in the conversation: the live generation, or history of the resumed ACP session. */
|
|
7
7
|
export function conversationEventVisible(event, sessionGeneration, resumedSessionId) {
|
|
8
8
|
return event.source !== 'agent_replay' && (event.sessionGeneration === sessionGeneration || (!!resumedSessionId && HISTORICAL_KINDS.includes(event.kind) && event.acpSessionId === resumedSessionId));
|
|
@@ -343,7 +343,7 @@ export async function resumedConversationPage(stateDir, request, live, expectedS
|
|
|
343
343
|
const cursor = Number(event.seq);
|
|
344
344
|
if (!Number.isSafeInteger(cursor) || cursor <= after)
|
|
345
345
|
continue;
|
|
346
|
-
const historical = ['file.attached', 'fleet.task_created', 'prompt.admitted', 'message.chunk', 'message.replace', 'tool.upsert', 'tool.content_chunk', 'turn.completed'].includes(event.kind);
|
|
346
|
+
const historical = ['file.attached', 'fleet.task_created', 'status.published', 'status.updated', 'status.answered', 'status.closed', 'prompt.admitted', 'message.chunk', 'message.replace', 'tool.upsert', 'tool.content_chunk', 'turn.completed'].includes(event.kind);
|
|
347
347
|
const visible = event.source !== 'agent_replay' && (event.sessionGeneration === live.snapshot.sessionGeneration || (historical && event.acpSessionId === sessionId));
|
|
348
348
|
if (!visible) {
|
|
349
349
|
next = String(cursor);
|
|
@@ -6,6 +6,7 @@ import { SessionControlError } from '../session/types.js';
|
|
|
6
6
|
import { readExitRecord, readRestartLedger } from '../runner.js';
|
|
7
7
|
import { readDaemonRecoveryStatus } from '../daemon-recovery.js';
|
|
8
8
|
import { roleCapabilities } from './capabilities.js';
|
|
9
|
+
import { sessionIdentityCid } from '../statuses/status-ledger.js';
|
|
9
10
|
import { FleetError } from './errors.js';
|
|
10
11
|
const clean = (value, max = 512) => value.replace(/[\0-\x08\x0b\x0c\x0e-\x1f\x7f]/g, '').trim().slice(0, max);
|
|
11
12
|
function boundedText(path, max = 16 * 1024) {
|
|
@@ -150,8 +151,10 @@ export class FleetQueryService {
|
|
|
150
151
|
backend: this.options.supervisor.id, liveness: live.state,
|
|
151
152
|
nativeState: live.detail.split(/\s/)[0], detail: clean(live.detail),
|
|
152
153
|
};
|
|
154
|
+
// The agent's own identity: the author of its statuses, independent of any owner channel.
|
|
155
|
+
const identityCid = dir ? sessionIdentityCid(dir) : undefined;
|
|
153
156
|
return {
|
|
154
|
-
roleId: role.id, observedAt,
|
|
157
|
+
roleId: role.id, observedAt, ...(identityCid ? { identityCid } : {}),
|
|
155
158
|
overall: sessionOverall(supervisor, session, restart, monitor, isolation, problems),
|
|
156
159
|
supervisor, session,
|
|
157
160
|
restart: {
|
|
@@ -207,9 +210,9 @@ export class FleetQueryService {
|
|
|
207
210
|
};
|
|
208
211
|
}
|
|
209
212
|
}
|
|
213
|
+
// The App shows the harness (Claude Code, Codex) from config.harness, so the name carries only the session.
|
|
210
214
|
function nativeParticipantLabel(row) {
|
|
211
|
-
|
|
212
|
-
return row.title?.trim() ? `${clean(row.title, 160)} · ${harness}` : `${harness} · ${row.cwd ? clean(basename(row.cwd), 160) : 'Session'}`;
|
|
215
|
+
return row.title?.trim() ? clean(row.title, 160) : row.cwd ? clean(basename(row.cwd), 160) : 'Terminal session';
|
|
213
216
|
}
|
|
214
217
|
function nativeParticipantView(row, label) {
|
|
215
218
|
return {
|
|
@@ -77,8 +77,19 @@ export class NativeClaudeConversation {
|
|
|
77
77
|
}
|
|
78
78
|
commands() { if (!existsSync(this.directory))
|
|
79
79
|
return []; return readdirSync(this.directory).filter(n => /^input-[a-f0-9]+\.json$/.test(n)).map(n => JSON.parse(readFileSync(join(this.directory, n), 'utf8'))).sort((a, b) => a.sequence - b.sequence); }
|
|
80
|
-
async submit(text, clientId) {
|
|
81
|
-
|
|
80
|
+
async submit(text, clientId) {
|
|
81
|
+
const state = this.snapshot();
|
|
82
|
+
// The plugin's long-lived watcher keeps alive.json fresh; state.json changes only on session events.
|
|
83
|
+
let alive = 0;
|
|
84
|
+
try {
|
|
85
|
+
alive = Number(JSON.parse(readFileSync(join(this.directory, 'alive.json'), 'utf8')).at) || 0;
|
|
86
|
+
}
|
|
87
|
+
catch { }
|
|
88
|
+
if (Date.now() - Math.max(state.at, alive) > 15000)
|
|
89
|
+
throw new FleetError('capability_unavailable', 'The ours-fleet-native plugin is not running in this Claude session. Restart or resume the session in the terminal to send it input from the App.');
|
|
90
|
+
this.guard();
|
|
91
|
+
await withFileLock(join(this.directory, 'input.lock'), () => { this.guard(); const sequence = Math.max(0, ...this.commands().map(row => row.sequence)) + 1; atomicPrivateWrite(join(this.directory, 'input-' + createHash('sha256').update(clientId).digest('hex') + '.json'), { text, clientId, sequence }); });
|
|
92
|
+
}
|
|
82
93
|
async pulse(state) {
|
|
83
94
|
this.guard();
|
|
84
95
|
mkdirSync(this.directory, { recursive: true, mode: 0o700 });
|
|
@@ -41,6 +41,9 @@ export declare class NativeConversation implements RoleSessionControl {
|
|
|
41
41
|
private store;
|
|
42
42
|
private generation;
|
|
43
43
|
private seen;
|
|
44
|
+
/** Ledger time of each native message, and the latest time in the ledger. */
|
|
45
|
+
private times;
|
|
46
|
+
private lastAt;
|
|
44
47
|
private commands;
|
|
45
48
|
private completed;
|
|
46
49
|
private nativeState;
|
|
@@ -56,6 +59,8 @@ export declare class NativeConversation implements RoleSessionControl {
|
|
|
56
59
|
private commandPath;
|
|
57
60
|
private assertConnected;
|
|
58
61
|
private state;
|
|
62
|
+
private nativeAt;
|
|
63
|
+
private append;
|
|
59
64
|
private changed;
|
|
60
65
|
describe(): Promise<{
|
|
61
66
|
backend: "acp" | "codex-app-server";
|
|
@@ -13,6 +13,9 @@ export class NativeConversation {
|
|
|
13
13
|
store;
|
|
14
14
|
generation;
|
|
15
15
|
seen = new Map();
|
|
16
|
+
/** Ledger time of each native message, and the latest time in the ledger. */
|
|
17
|
+
times = new Map();
|
|
18
|
+
lastAt = '';
|
|
16
19
|
commands = new Map();
|
|
17
20
|
completed = new Set();
|
|
18
21
|
nativeState = { status: 'idle', messages: [], queued: [] };
|
|
@@ -31,8 +34,12 @@ export class NativeConversation {
|
|
|
31
34
|
for (let after;;) {
|
|
32
35
|
const page = this.store.page({ after, limit: 1000 });
|
|
33
36
|
for (const event of page.events) {
|
|
34
|
-
if (event.
|
|
37
|
+
if (event.at > this.lastAt)
|
|
38
|
+
this.lastAt = event.at;
|
|
39
|
+
if (event.messageId?.startsWith('native:')) {
|
|
35
40
|
this.seen.set(event.messageId, JSON.stringify(event.payload));
|
|
41
|
+
this.times.set(event.messageId, event.at);
|
|
42
|
+
}
|
|
36
43
|
if (event.kind === 'turn.completed' && event.promptId)
|
|
37
44
|
this.completed.add(event.promptId);
|
|
38
45
|
}
|
|
@@ -57,6 +64,24 @@ export class NativeConversation {
|
|
|
57
64
|
pendingPrompts: pending.map(c => ({ promptId: c.receipt.promptId, source: 'owner_admin_console', admittedAt: c.receipt.acceptedAt, bytes: 0 })),
|
|
58
65
|
pendingPromptCount: pending.length, activePromptIds: active.map(c => c.receipt.promptId), ...(this.failed ? { observationFailure: 'capture_failed' } : {}) };
|
|
59
66
|
}
|
|
67
|
+
// Apps order the conversation by event time. Native clocks are coarser than the ledger's (Codex reports a
|
|
68
|
+
// turn's start in whole seconds), so a reply could carry a time before the prompt admitted for it. A native
|
|
69
|
+
// message keeps the time it was first recorded with, and a new one is never placed before the ledger's end.
|
|
70
|
+
nativeAt(messageId, at) {
|
|
71
|
+
const known = this.times.get(messageId);
|
|
72
|
+
if (known)
|
|
73
|
+
return known;
|
|
74
|
+
const parsed = at && !Number.isNaN(Date.parse(at)) ? new Date(at).toISOString() : new Date().toISOString();
|
|
75
|
+
return parsed > this.lastAt ? parsed : new Date(Date.parse(this.lastAt) + 1).toISOString();
|
|
76
|
+
}
|
|
77
|
+
append(draft) {
|
|
78
|
+
const event = this.store.append(draft);
|
|
79
|
+
if (event.at > this.lastAt)
|
|
80
|
+
this.lastAt = event.at;
|
|
81
|
+
if (event.messageId?.startsWith('native:'))
|
|
82
|
+
this.times.set(event.messageId, event.at);
|
|
83
|
+
return event;
|
|
84
|
+
}
|
|
60
85
|
changed() { this.revision++; for (const listener of this.listeners)
|
|
61
86
|
listener(this.state()); }
|
|
62
87
|
async describe() { return { backend: this.options.harness === 'codex' ? 'codex-app-server' : 'acp', protocolVersion: 3, features: ['conversation_v3', 'conversation_live_complete', ...(this.options.correspondence ? ['agent_correspondence'] : [])], snapshot: await this.snapshot() }; }
|
|
@@ -84,8 +109,8 @@ export class NativeConversation {
|
|
|
84
109
|
const digest = JSON.stringify(payload);
|
|
85
110
|
if (this.seen.get(messageId) === digest)
|
|
86
111
|
continue;
|
|
87
|
-
this.
|
|
88
|
-
source: message.role === 'user' ? 'local_console' : 'agent', ...
|
|
112
|
+
this.append({ sessionGeneration: this.generation, kind: 'message.replace', messageId,
|
|
113
|
+
source: message.role === 'user' ? 'local_console' : 'agent', ...{ at: this.nativeAt(messageId, message.at) }, payload });
|
|
89
114
|
this.seen.set(messageId, digest);
|
|
90
115
|
}
|
|
91
116
|
for (const command of this.commands.values()) {
|
|
@@ -99,7 +124,7 @@ export class NativeConversation {
|
|
|
99
124
|
atomicPrivateWrite(this.commandPath(command.receipt.commandId), command);
|
|
100
125
|
}
|
|
101
126
|
if (finished) {
|
|
102
|
-
this.
|
|
127
|
+
this.append({ sessionGeneration: this.generation, kind: 'turn.completed', promptId: command.receipt.promptId, payload: { outcome: finished.outcome } });
|
|
103
128
|
this.completed.add(command.receipt.promptId);
|
|
104
129
|
}
|
|
105
130
|
}
|
|
@@ -135,7 +160,7 @@ export class NativeConversation {
|
|
|
135
160
|
throw new FleetError('capability_unavailable', 'History is available; load the Ours native Claude plugin to send input to this session');
|
|
136
161
|
// Finish any concurrent history capture before admitting a send, so its outgoing row cannot race the receipt.
|
|
137
162
|
const promptId = randomUUID();
|
|
138
|
-
const event = this.
|
|
163
|
+
const event = this.append({ sessionGeneration: this.generation, kind: 'prompt.admitted', promptId, commandId: request.commandId, source: 'owner_admin_console', actor: { browserSession: request.actorBrowserSession }, payload: { text: textBlock(request.text), queuedBehind: 0 } });
|
|
139
164
|
const receipt = { commandId: request.commandId, promptId, state: 'queued', queuedBehind: 0, acceptedAt: event.at, eventCursor: String(event.seq), sessionGeneration: this.generation };
|
|
140
165
|
const clientId = `ours-fleet-human:${this.options.cid}:${request.commandId}`;
|
|
141
166
|
const command = { digest, receipt, status: 'intent', clientId };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NativeParticipation } from '../native-participation.js';
|
|
1
2
|
import { NativeConversation } from './native-conversation.js';
|
|
2
3
|
import type { ConversationRoleObservation, ConversationRoleState } from './conversation-role-observer.js';
|
|
3
4
|
/** The web process owns projections, while native participation remains the authority for membership. */
|
|
@@ -15,5 +16,7 @@ export declare class NativeConversations {
|
|
|
15
16
|
}[];
|
|
16
17
|
session(id: string): Promise<NativeConversation | undefined>;
|
|
17
18
|
observe(id: string, listener: (state: ConversationRoleState) => void): ConversationRoleObservation;
|
|
19
|
+
/** The App's agent tools for a native participant, or undefined when the role is not one. */
|
|
20
|
+
oursTools(id: string): Promise<NativeParticipation | undefined>;
|
|
18
21
|
close(): void;
|
|
19
22
|
}
|
|
@@ -69,6 +69,8 @@ export class NativeConversations {
|
|
|
69
69
|
timer.unref();
|
|
70
70
|
return { snapshot: () => ({ ...state }), subscribe(fn) { listeners.add(fn); return { snapshot: { ...state }, unsubscribe: () => { listeners.delete(fn); } }; }, dispose() { clearInterval(timer); listeners.clear(); } };
|
|
71
71
|
}
|
|
72
|
+
/** The App's agent tools for a native participant, or undefined when the role is not one. */
|
|
73
|
+
async oursTools(id) { await this.initialize(); return this.list().some(row => row.name === id) ? this.registry : undefined; }
|
|
72
74
|
close() { for (const session of this.sessions.values())
|
|
73
75
|
session.close(); this.sessions.clear(); }
|
|
74
76
|
}
|
|
@@ -148,8 +148,6 @@ export class RoleCreationService {
|
|
|
148
148
|
: 'approval=allow maps to an elevated native permission mode');
|
|
149
149
|
if (request.permissions.filesystem === 'unrestricted')
|
|
150
150
|
warnings.push('filesystem=unrestricted grants access outside the workspace');
|
|
151
|
-
if (request.permissions.unattended === 'wait')
|
|
152
|
-
warnings.push('unattended permission requests may hold until a controller attaches');
|
|
153
151
|
if (request.lifetime === 'temporary')
|
|
154
152
|
warnings.push('temporary sessions are gone on exit or reboot');
|
|
155
153
|
const existingIdentity = await this.checkIdentity(request.name);
|
|
@@ -338,7 +336,6 @@ export class RoleCreationService {
|
|
|
338
336
|
identity: request.name, brain: request.brain, role: request.role, cwd: request.cwd,
|
|
339
337
|
coordinator: request.coordinator,
|
|
340
338
|
approval: request.permissions.approval, filesystem: request.permissions.filesystem,
|
|
341
|
-
unattended: request.permissions.unattended,
|
|
342
339
|
monitorConfig: request.monitor,
|
|
343
340
|
configPath: this.options.configPath,
|
|
344
341
|
surface: creationActionId ? 'web' : undefined, creationActionId,
|
|
@@ -78,6 +78,8 @@ export interface RoleSessionControl {
|
|
|
78
78
|
actorBrowserSession: string;
|
|
79
79
|
expectedSessionGeneration?: string;
|
|
80
80
|
requireIdle?: boolean;
|
|
81
|
+
/** Admit only into a session bound to this identity; refused by supervisors without `identity_bound_prompts`. */
|
|
82
|
+
expectedIdentityCid?: string;
|
|
81
83
|
source: 'owner_admin_console';
|
|
82
84
|
}): Promise<PromptReceipt>;
|
|
83
85
|
interruptPromptV2?(request: {
|
|
@@ -137,6 +139,7 @@ export declare class RoleSessionControlAdapter implements RoleSessionControl {
|
|
|
137
139
|
actorBrowserSession: string;
|
|
138
140
|
expectedSessionGeneration?: string;
|
|
139
141
|
requireIdle?: boolean;
|
|
142
|
+
expectedIdentityCid?: string;
|
|
140
143
|
source: 'owner_admin_console';
|
|
141
144
|
}): Promise<PromptReceipt>;
|
|
142
145
|
interruptPromptV2(request: {
|