jg-agent-hq 8.0.2 → 10.0.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/CHANGELOG.md +22 -0
- package/README.md +18 -37
- package/api/README.md +51 -243
- package/dist/actions/actions.d.ts +5 -50
- package/dist/actions/actions.js +49 -190
- package/dist/actions/reads.d.ts +3 -2
- package/dist/actions/reads.js +12 -5
- package/dist/actions/waits/index.d.ts +1 -0
- package/dist/actions/waits/index.js +2 -0
- package/dist/actions/waits/waits.d.ts +37 -0
- package/dist/actions/waits/waits.js +107 -0
- package/dist/cli/cli.js +6 -56
- package/dist/contracts/actions/index.d.ts +2 -4
- package/dist/contracts/actions/index.js +1 -3
- package/dist/contracts/actions/types.d.ts +135 -142
- package/dist/contracts/actions/types.js +12 -22
- package/dist/contracts/browser/types.d.ts +12 -605
- package/dist/contracts/browser/types.js +2 -5
- package/dist/contracts/evidence/types.d.ts +4 -7
- package/dist/contracts/evidence/types.js +2 -8
- package/dist/contracts/index.d.ts +5 -16
- package/dist/contracts/index.js +4 -15
- package/dist/contracts/locks/index.d.ts +2 -0
- package/dist/contracts/locks/index.js +2 -0
- package/dist/contracts/locks/types.d.ts +50 -0
- package/dist/contracts/locks/types.js +36 -0
- package/dist/contracts/providers/types.d.ts +0 -38
- package/dist/contracts/providers/types.js +0 -1
- package/dist/contracts/results/types.js +1 -1
- package/dist/contracts/sessions/types.d.ts +2 -0
- package/dist/contracts/sessions/types.js +7 -1
- package/dist/contracts/skills/types.d.ts +1 -0
- package/dist/contracts/skills/types.js +5 -0
- package/dist/contracts/types.d.ts +4526 -12307
- package/dist/contracts/types.js +13 -12
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -2
- package/dist/providers/claude/adapter.js +1 -11
- package/dist/providers/claude/claude.d.ts +7 -3
- package/dist/providers/claude/claude.js +50 -9
- package/dist/providers/claude/control/control.d.ts +2 -20
- package/dist/providers/claude/control/control.js +88 -155
- package/dist/providers/claude/control/permissions.d.ts +0 -9
- package/dist/providers/claude/control/permissions.js +0 -22
- package/dist/providers/claude/control/skills.js +1 -0
- package/dist/providers/claude/control/stream.js +1 -34
- package/dist/providers/claude/control/types.d.ts +0 -3
- package/dist/providers/claude/history/history.model.d.ts +9 -0
- package/dist/providers/claude/history/history.model.js +81 -45
- package/dist/providers/claude/history/types.d.ts +284 -3045
- package/dist/providers/claude/history/types.js +1 -0
- package/dist/providers/claude/rpc.d.ts +0 -5
- package/dist/providers/claude/rpc.js +0 -3
- package/dist/providers/codex/adapter.js +2 -12
- package/dist/providers/codex/codex.d.ts +1 -2
- package/dist/providers/codex/codex.js +2 -100
- package/dist/providers/codex/types.d.ts +2 -4
- package/dist/providers/registry/registry.d.ts +0 -2
- package/dist/providers/registry/registry.js +0 -7
- package/dist/providers/types.d.ts +4 -6
- package/dist/providers/types.js +3 -2
- package/dist/runtime/runtime.js +10 -81
- package/dist/runtime/types.d.ts +2 -18
- package/dist/runtime/types.js +0 -1
- package/dist/sessions/sessions.js +0 -1
- package/dist/skills/skills.js +3 -0
- package/dist/snapshots/archive/archive.js +2 -23
- package/dist/snapshots/capture.d.ts +2 -5
- package/dist/snapshots/capture.js +4 -85
- package/dist/snapshots/constants.d.ts +0 -1
- package/dist/snapshots/constants.js +1 -6
- package/dist/snapshots/database.d.ts +2 -3
- package/dist/snapshots/database.js +9 -114
- package/dist/snapshots/fences.d.ts +3 -5
- package/dist/snapshots/fences.js +3 -15
- package/dist/snapshots/files.d.ts +3 -1
- package/dist/snapshots/files.js +15 -4
- package/dist/snapshots/snapshots.d.ts +6 -7
- package/dist/snapshots/snapshots.js +9 -16
- package/dist/snapshots/types.d.ts +5 -81
- package/dist/snapshots/types.js +7 -30
- package/dist/storage/constants.d.ts +1 -0
- package/dist/storage/constants.js +5 -1
- package/dist/storage/types.d.ts +1 -0
- package/dist/storage/types.js +1 -0
- package/dist/store/control/constants.d.ts +3 -2
- package/dist/store/control/constants.js +3 -1
- package/dist/store/control/control.model.d.ts +1 -11
- package/dist/store/control/control.model.js +10 -131
- package/dist/store/control/transformers.d.ts +6 -3
- package/dist/store/control/transformers.js +6 -5
- package/dist/store/control/types.d.ts +91 -170
- package/dist/store/control/types.js +5 -7
- package/dist/store/schema.js +1 -1
- package/dist/store/schema.sql +7 -362
- package/dist/store/sessions/sessions.model.d.ts +10 -6
- package/dist/store/sessions/sessions.model.js +19 -2
- package/dist/store/snapshot.d.ts +10 -0
- package/dist/store/snapshot.js +37 -0
- package/dist/store/store.js +1 -54
- package/dist/store/store.worker.js +5 -97
- package/dist/store/types.d.ts +241 -4802
- package/dist/store/types.js +1 -44
- package/docs/recovery.md +10 -6
- package/errors/README.md +29 -39
- package/package.json +3 -4
- package/dist/agent-tools/agent-tools.d.ts +0 -6
- package/dist/agent-tools/agent-tools.js +0 -181
- package/dist/agent-tools/constants.d.ts +0 -7
- package/dist/agent-tools/constants.js +0 -45
- package/dist/agent-tools/index.d.ts +0 -4
- package/dist/agent-tools/index.js +0 -4
- package/dist/agent-tools/mcp/index.d.ts +0 -1
- package/dist/agent-tools/mcp/index.js +0 -2
- package/dist/agent-tools/mcp/mcp.d.ts +0 -7
- package/dist/agent-tools/mcp/mcp.js +0 -50
- package/dist/agent-tools/types.d.ts +0 -64
- package/dist/agent-tools/types.js +0 -1
- package/dist/agent-tools/utilities.d.ts +0 -13
- package/dist/agent-tools/utilities.js +0 -37
- package/dist/collaboration/collaboration.d.ts +0 -7
- package/dist/collaboration/collaboration.js +0 -119
- package/dist/collaboration/constants.d.ts +0 -2
- package/dist/collaboration/constants.js +0 -3
- package/dist/collaboration/dispatch/dispatch.d.ts +0 -12
- package/dist/collaboration/dispatch/dispatch.js +0 -148
- package/dist/collaboration/dispatch/index.d.ts +0 -3
- package/dist/collaboration/dispatch/index.js +0 -4
- package/dist/collaboration/dispatch/types.d.ts +0 -632
- package/dist/collaboration/dispatch/types.js +0 -44
- package/dist/collaboration/grants/grants.d.ts +0 -45
- package/dist/collaboration/grants/grants.js +0 -131
- package/dist/collaboration/grants/index.d.ts +0 -1
- package/dist/collaboration/grants/index.js +0 -2
- package/dist/collaboration/identity/credentials.d.ts +0 -17
- package/dist/collaboration/identity/credentials.js +0 -182
- package/dist/collaboration/identity/index.d.ts +0 -4
- package/dist/collaboration/identity/index.js +0 -4
- package/dist/collaboration/identity/types.d.ts +0 -171
- package/dist/collaboration/identity/types.js +0 -87
- package/dist/collaboration/index.d.ts +0 -3
- package/dist/collaboration/index.js +0 -3
- package/dist/collaboration/types.d.ts +0 -25
- package/dist/collaboration/types.js +0 -1
- package/dist/contracts/agent-tools/index.d.ts +0 -2
- package/dist/contracts/agent-tools/index.js +0 -2
- package/dist/contracts/agent-tools/types.d.ts +0 -697
- package/dist/contracts/agent-tools/types.js +0 -125
- package/dist/contracts/collaboration/index.d.ts +0 -4
- package/dist/contracts/collaboration/index.js +0 -4
- package/dist/contracts/collaboration/reports/constants.d.ts +0 -1
- package/dist/contracts/collaboration/reports/constants.js +0 -2
- package/dist/contracts/collaboration/reports/index.d.ts +0 -3
- package/dist/contracts/collaboration/reports/index.js +0 -3
- package/dist/contracts/collaboration/reports/types.d.ts +0 -69
- package/dist/contracts/collaboration/reports/types.js +0 -53
- package/dist/contracts/collaboration/types.d.ts +0 -6734
- package/dist/contracts/collaboration/types.js +0 -696
- package/dist/contracts/plans/index.d.ts +0 -6
- package/dist/contracts/plans/index.js +0 -6
- package/dist/contracts/plans/types.d.ts +0 -1788
- package/dist/contracts/plans/types.js +0 -278
- package/dist/plans/admission.d.ts +0 -288
- package/dist/plans/admission.js +0 -393
- package/dist/plans/authority.d.ts +0 -21
- package/dist/plans/authority.js +0 -207
- package/dist/plans/documents.d.ts +0 -80
- package/dist/plans/documents.js +0 -238
- package/dist/plans/evidence.d.ts +0 -11
- package/dist/plans/evidence.js +0 -211
- package/dist/plans/files.d.ts +0 -55
- package/dist/plans/files.js +0 -264
- package/dist/plans/finalization.d.ts +0 -11
- package/dist/plans/finalization.js +0 -30
- package/dist/plans/index.d.ts +0 -5
- package/dist/plans/index.js +0 -6
- package/dist/plans/plans.d.ts +0 -325
- package/dist/plans/plans.js +0 -803
- package/dist/plans/projections.d.ts +0 -13
- package/dist/plans/projections.js +0 -67
- package/dist/plans/revisions.d.ts +0 -50
- package/dist/plans/revisions.js +0 -181
- package/dist/plans/types.d.ts +0 -114
- package/dist/plans/types.js +0 -43
- package/dist/plans/utilities.d.ts +0 -36
- package/dist/plans/utilities.js +0 -62
- package/dist/snapshots/artifacts.d.ts +0 -16
- package/dist/snapshots/artifacts.js +0 -75
- package/dist/store/collaboration/authority.d.ts +0 -228
- package/dist/store/collaboration/authority.js +0 -128
- package/dist/store/collaboration/collaboration.model.d.ts +0 -412
- package/dist/store/collaboration/collaboration.model.js +0 -254
- package/dist/store/collaboration/constants.d.ts +0 -13
- package/dist/store/collaboration/constants.js +0 -14
- package/dist/store/collaboration/dispatch.d.ts +0 -19
- package/dist/store/collaboration/dispatch.js +0 -197
- package/dist/store/collaboration/identity.d.ts +0 -21
- package/dist/store/collaboration/identity.js +0 -146
- package/dist/store/collaboration/index.d.ts +0 -3
- package/dist/store/collaboration/index.js +0 -5
- package/dist/store/collaboration/invocation.d.ts +0 -21
- package/dist/store/collaboration/invocation.js +0 -162
- package/dist/store/collaboration/messages.d.ts +0 -54
- package/dist/store/collaboration/messages.js +0 -157
- package/dist/store/collaboration/outcomes.d.ts +0 -11
- package/dist/store/collaboration/outcomes.js +0 -216
- package/dist/store/collaboration/queries.d.ts +0 -23
- package/dist/store/collaboration/queries.js +0 -259
- package/dist/store/collaboration/reports.d.ts +0 -37
- package/dist/store/collaboration/reports.js +0 -117
- package/dist/store/collaboration/requests.d.ts +0 -22
- package/dist/store/collaboration/requests.js +0 -111
- package/dist/store/collaboration/search.d.ts +0 -13
- package/dist/store/collaboration/search.js +0 -58
- package/dist/store/collaboration/spawn.d.ts +0 -33
- package/dist/store/collaboration/spawn.js +0 -96
- package/dist/store/collaboration/streams.d.ts +0 -13
- package/dist/store/collaboration/streams.js +0 -100
- package/dist/store/collaboration/tasks.d.ts +0 -20
- package/dist/store/collaboration/tasks.js +0 -169
- package/dist/store/collaboration/transformers.d.ts +0 -56
- package/dist/store/collaboration/transformers.js +0 -179
- package/dist/store/collaboration/types.d.ts +0 -25
- package/dist/store/collaboration/types.js +0 -8
- package/dist/store/collaboration/utilities.d.ts +0 -23
- package/dist/store/collaboration/utilities.js +0 -77
- package/dist/store/collaboration/waits.d.ts +0 -26
- package/dist/store/collaboration/waits.js +0 -114
- package/dist/store/plans/index.d.ts +0 -1
- package/dist/store/plans/index.js +0 -2
- package/dist/store/plans/plans.model.d.ts +0 -47
- package/dist/store/plans/plans.model.js +0 -179
package/api/README.md
CHANGED
|
@@ -20,17 +20,17 @@ All operations may expose the relevant intentional contracts in [errors](../erro
|
|
|
20
20
|
|
|
21
21
|
## Shared storage
|
|
22
22
|
|
|
23
|
-
`hq.storage` returns an independent `IStorageDescriptor` containing the canonical `databasePath`, `schemaHash`, `reservedPrefix` (`hq_`), and required `connectionSettings`: `foreignKeys` true, `busyTimeoutMs` 5000, `journalMode` wal, and `
|
|
23
|
+
`hq.storage` returns an independent `IStorageDescriptor` containing the canonical `databasePath`, `schemaHash`, `reservedPrefix` (`hq_`), and required `connectionSettings`: `foreignKeys` true, `busyTimeoutMs` 5000, `journalMode` wal, `synchronous` full, and `journalSizeLimitBytes` 16,777,216. Exported Node types are `IStorageDescriptor` and `IStorageMaintenanceOperation<T>`. No database handle, storage callback, raw SQL command or storage path is exposed by browser contracts or IPC.
|
|
24
24
|
|
|
25
|
-
For node:sqlite, open the host connection with `new DatabaseSync(storage.databasePath, { timeout: storage.connectionSettings.busyTimeoutMs, enableForeignKeyConstraints: storage.connectionSettings.foreignKeys })`. These options enable foreign keys and a 5,000 ms busy timeout; the descriptor itself is not a DatabaseSync options object. See the [Node 24 SQLite API](https://nodejs.org/download/release/v24.15.0/docs/api/sqlite.html#new-databasesyncpath-options). Keep WAL mode and FULL synchronization; do not change database-wide settings while HQ is running. Hosts own their table prefix, definitions, connection lifetime and user_version. HQ-owned tables and indexes are reserved. A nonempty database requires the current singleton hq_schema stamp, which records the schema hash, the SHA-256 fingerprint of action.key and the package version that wrote the database. Startup rejects any other schema with JG_AGENT_HQ_STORAGE_INVALID before opening a writer; its message names that package version, or reports another jg-agent-hq version when the stamp records none. Rejected storage remains unchanged. A different valid-length key fails with JG_AGENT_HQ_ACTION_KEY_UNAVAILABLE before a writer opens. Fresh initialization is transactional.
|
|
25
|
+
For node:sqlite, open the host connection with `new DatabaseSync(storage.databasePath, { timeout: storage.connectionSettings.busyTimeoutMs, enableForeignKeyConstraints: storage.connectionSettings.foreignKeys })`. These options enable foreign keys and a 5,000 ms busy timeout; the descriptor itself is not a DatabaseSync options object. See the [Node 24 SQLite API](https://nodejs.org/download/release/v24.15.0/docs/api/sqlite.html#new-databasesyncpath-options). Keep WAL mode and FULL synchronization; do not change database-wide settings while HQ is running. Run `PRAGMA journal_size_limit` with `journalSizeLimitBytes` on a connection that writes: SQLite shrinks the WAL file back to that size after a checkpoint only on the connection whose write starts the WAL over, and HQ's own connection already does. Hosts own their table prefix, definitions, connection lifetime and user_version. HQ-owned tables and indexes are reserved. A nonempty database requires the current singleton hq_schema stamp, which records the schema hash, the SHA-256 fingerprint of action.key and the package version that wrote the database. Startup rejects any other schema with JG_AGENT_HQ_STORAGE_INVALID before opening a writer; its message names that package version, or reports another jg-agent-hq version when the stamp records none. Rejected storage remains unchanged. A different valid-length key fails with JG_AGENT_HQ_ACTION_KEY_UNAVAILABLE before a writer opens. Fresh initialization is transactional.
|
|
26
26
|
|
|
27
|
-
`await hq.withStorageMaintenance(operation)` passes the storage descriptor to the async operation and returns its result. It closes admission before draining accepted HQ operations, allows their awaited nested calls and required native evidence to finish, and checks for active native execution
|
|
27
|
+
`await hq.withStorageMaintenance(operation)` passes the storage descriptor to the async operation and returns its result. It closes admission before draining accepted HQ operations, allows their awaited nested calls and required native evidence to finish, and checks for active native execution before invoking the callback. Concurrent maintenance, new HQ requests, browser host effects and shutdown conflict while maintenance is held. During the callback, native event persistence waits in its existing bounded lane, and an already accepted scheduled stop waits for release. The callback must not call HQ, start native work or leave transactions open. Its errors propagate unchanged; it owns rollback and reconciliation for its SQL effects. After success or failure, HQ admission resumes. Calls after shutdown use JG_AGENT_HQ_RUNTIME_NOT_RUNNING.
|
|
28
28
|
|
|
29
29
|
The host must coordinate every application connection that can write during maintenance. A shared file gives SQLite transaction isolation, not an atomic transaction spanning host SQL and HQ API calls. HQ does not expose its worker connection. Snapshot scheduling and remote backup operations belong to the host application.
|
|
30
30
|
|
|
31
31
|
## Snapshot and restore
|
|
32
32
|
|
|
33
|
-
Import createHqSnapshot, inspectHqSnapshot, restoreHqSnapshot, packHqSnapshot and unpackHqSnapshot from jg-agent-hq in a trusted Node host. They are absent from browser contracts
|
|
33
|
+
Import createHqSnapshot, inspectHqSnapshot, restoreHqSnapshot, packHqSnapshot and unpackHqSnapshot from jg-agent-hq in a trusted Node host. They are absent from browser contracts and IPC. The exported types are IHqSnapshotInspection, IHqRestoreOptions and IHqRestoreResult.
|
|
34
34
|
|
|
35
35
|
| Operation | Contract |
|
|
36
36
|
| ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -38,29 +38,29 @@ Import createHqSnapshot, inspectHqSnapshot, restoreHqSnapshot, packHqSnapshot an
|
|
|
38
38
|
| `inspectHqSnapshot(directory)` | Validate the complete private snapshot without changing it. Returns IHqSnapshotInspection. |
|
|
39
39
|
| `packHqSnapshot(snapshotDirectory, archivePath, key)` | Inspect the snapshot, then encrypt it into one new private file at an absent absolute path under an existing canonical parent. Returns the snapshot's IHqSnapshotInspection. |
|
|
40
40
|
| `unpackHqSnapshot(archivePath, destination, key)` | Decrypt and verify an archive, then write it into an absent snapshot directory and inspect it. Returns IHqSnapshotInspection. |
|
|
41
|
-
| `restoreHqSnapshot({ snapshotDirectory, destination })` | Validate before creating an absent recovery destination, copy and validate staged files, then expose
|
|
41
|
+
| `restoreHqSnapshot({ snapshotDirectory, destination })` | Validate before creating an absent recovery destination, copy and validate staged files, then expose the recovered state directory. Returns IHqRestoreResult. All proposed destination connections must be stopped. |
|
|
42
42
|
|
|
43
|
-
Capture runs as admitted HQ work, so host maintenance excludes it, and holds the
|
|
43
|
+
Capture runs as admitted HQ work, so host maintenance excludes it, and holds the HQ lock in the state root throughout, waiting for another holder under the lock's 120-second default. Native turns, ownership changes and evidence keep flowing: the store worker backs up the database through its own connection in bounded steps, then compacts that copy in one short step that holds the worker. Host connections must not write host tables for the complete capture, because a write from another connection restarts or splits SQLite's backup. Attached databases and external files are outside this coherence contract.
|
|
44
44
|
|
|
45
|
-
SQLite's worker-owned backup API includes committed WAL data and every table in the main database, including application tables and
|
|
45
|
+
SQLite's worker-owned backup API includes committed WAL data and every table in the main database, including application tables. The snapshot leaves out the rows of the Claude history index, `hq_claude_file` and `hq_claude_entry`, which make up most of a database that has read Claude sessions: the worker deletes them from a full copy beside the destination, writes the snapshot database from that copy with `VACUUM INTO`, which keeps every table's rowids, syncs it and removes the full copy. The resulting database needs no WAL sidecar. The snapshot also contains the private 32-byte action.key. Capture binds the original canonical state root and checks the key against its startup hash, rejecting a key replaced while the runtime is open. File copy and SHA-256 use 65,536-byte buffers. There is no repository scan, transcript copy or artifact cache, and no workspace file is captured.
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
manifest.jsonl holds exactly three records: header, database and action-key. The header records the schema hash, the package version that captured it, the source state root and the allowed roots. A final complete.json binds the complete manifest hash and record count. Directories are private (0700), files are private (0600), and destinations are created exclusively. Runtime sockets, owner records, process IDs and provider authentication are excluded.
|
|
48
48
|
|
|
49
|
-
Inspection
|
|
49
|
+
Inspection reads the header's schema hash and package version before its shape, then verifies each listed regular file, rejects links, unsafe paths and any further record, and checks the current HQ schema stamp and database/key pairing and SQLite integrity/foreign keys. A snapshot whose header or database comes from another schema is refused with STORAGE_INVALID, naming the package version that wrote it, before any restore output is reserved. Full database verification runs in a dedicated worker. Inspection returns the directory, manifest hash and header. Hashes detect corruption and bind content; they do not authenticate a snapshot supplied by an untrusted party.
|
|
50
50
|
|
|
51
|
-
Restore leaves every existing destination untouched, including an empty directory, repository or live state root. Use a new directory. It validates the source before reserving that directory and validates the staged copy independently against the initially inspected manifest hash before changing
|
|
51
|
+
Restore leaves every existing destination untouched, including an empty directory, repository or live state root. Use a new directory. It validates the source before reserving that directory and validates the staged copy independently against the initially inspected manifest hash before changing recovered state. On success, stateRoot points to destination/state, recovery.jsonl retains the source manifest and recovered.json records completion. Caught failures remove only the operation's newly created output. A crash can leave incomplete output; do not open it as a recovered runtime.
|
|
52
52
|
|
|
53
|
-
Restored
|
|
53
|
+
Restored live approvals expire and queued input loses readiness. Submitted actions retain uncertainty. Managed native identities become uncertain and require explicit ownership reconciliation. IDs and historical receipts remain intact. No native operation runs during restore.
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
Call createAgentHq with the returned stateRoot and an explicitly selected allowedRoots array. Runtime construction never imports source root permissions from the snapshot and always assigns a new epoch. Native source workspace paths remain evidence and are not rewritten. Recover repository and native files separately; restore never overwrites a source repository. The recovered runtime rebuilds the Claude history index from the native transcripts on its first Claude history read, as a fresh state root does, so a Claude session is listed again once its transcript is on the machine. Make explicit native ownership decisions before resuming work. Source paths outside the newly selected roots remain unavailable.
|
|
56
56
|
|
|
57
|
-
These exports use SNAPSHOT_INVALID for incomplete, corrupt, unsafe or occupied snapshot, archive or recovery selections, for a key that is not 32 bytes and for an archive that fails authentication, and SNAPSHOT_FAILED for operational copy, backup, lock
|
|
57
|
+
These exports use SNAPSHOT_INVALID for incomplete, corrupt, unsafe or occupied snapshot, archive or recovery selections, for a key that is not 32 bytes and for an archive that fails authentication, and SNAPSHOT_FAILED for operational copy, backup, lock, worker or cleanup failures, including a lock held by a dead owner. Capture additionally exposes ACTION_CONFLICT while host maintenance runs or when the HQ lock wait expires. Inspection/restore expose STORAGE_INVALID for a snapshot from another schema. Operational messages retain private diagnostic causes; no snapshot exception is exposed through public RPC.
|
|
58
58
|
|
|
59
59
|
An archive is a fixed format identifier, a fresh 12-byte IV, the AES-256-GCM ciphertext of every snapshot file in manifest order, each behind its path and length, and the 16-byte authentication tag. The key is a 32-byte Buffer the host supplies and keeps; HQ never stores it. Unpacking decrypts the whole archive into a private temporary file beside the destination and verifies the tag before trusting any byte or creating the destination, so a wrong key, a modified byte or a truncation is refused with SNAPSHOT_INVALID and writes nothing. It then writes only the manifest's listed paths at exactly their listed sizes, refuses unlisted, repeated or missing entries, and runs inspectHqSnapshot on the result; any failure removes the destination and the temporary file. Packing removes a partial archive on failure. Both stream in 65,536-byte chunks.
|
|
60
60
|
|
|
61
61
|
Snapshot directories are plaintext local state; archives are the encrypted form for off-machine copies. The host owns the key and its recovery, scheduling, uploads, retention and last-success status. A disk failure can lose every change after the last successful off-machine backup. A local snapshot alone provides no remote durability. See the [recovery workflow](../docs/recovery.md).
|
|
62
62
|
|
|
63
|
-
Native snapshot qualification on 2026-10-23 used Codex 0.164.0 (gpt-6.1-sol) and Claude Code 2.1.309 (claude-opus-5-5)
|
|
63
|
+
Native snapshot qualification on 2026-10-23 used Codex 0.164.0 (gpt-6.1-sol) and Claude Code 2.1.309 (claude-opus-5-5) with controlled native sessions. Quiescent capture, offline restore and explicit root selection changed the runtime epoch and left both providers idle on the recovered runtime. Claude read-tool permissions received exact explicit replies. These observations do not establish a native version admission rule.
|
|
64
64
|
|
|
65
65
|
## Runtime lifecycle
|
|
66
66
|
|
|
@@ -137,6 +137,7 @@ Import `HqRequestSchema`, `HqResponseSchema` and their inferred types from `jg-a
|
|
|
137
137
|
| `provider-actions` | `provider` | Paged global action metadata, including authentication receipts |
|
|
138
138
|
| `login` | `actionId` | Live authentication presentation or known terminal state |
|
|
139
139
|
| `usage` | `provider` | Actual subscription observations |
|
|
140
|
+
| `locks` | None | The machine's jg-locks locks and their holders; see [machine locks](#machine-locks) |
|
|
140
141
|
|
|
141
142
|
Paged commands accept `limit` (default 32, maximum 128) and an opaque `cursor`. Continue with exactly the same command, target, filters and limit. The cursor binds those fields to the provider continuation. Codex requests threads by last activity (`updated_at`), descending, with descending turns and descending items. Claude orders discovery by last activity, the later of a transcript's modification time and its newest record, then native UUID, descending, turns by native chain position ascending and items by native chain position descending. Workspace authorization is rechecked for each request, independently of cursor validation, before selected-thread items are fetched.
|
|
142
143
|
|
|
@@ -175,7 +176,7 @@ Concrete action commands use the existing `{ kind: 'action', action: { id, runti
|
|
|
175
176
|
|
|
176
177
|
Capabilities distinguish each operation. Extension changes require an idle owned session and cannot bypass a permission wait. Codex MCP reload queues a native refresh for all loaded sessions, so HQ requires those sessions to be idle and fences new execution until its outcome is known. Claude reconnect and enable/disable target one session server. Skill reload uses the runtime-authorized managed workspace and retains explicit-only native commands. Plugin reload preserves native configuration and reports `held` when the native interface defers the change. A reload applied with native plugin errors retains `controlState: 'applied'` and `completion: 'failed'`. HQ does not install plugins, forward arbitrary RPC, replace MCP configuration, disable normal hooks or inject global settings.
|
|
177
178
|
|
|
178
|
-
Receipts include nullable `provider` and `controlState` (`accepted`, `applied`, `held`). Native login initiation is acknowledged as `accepted`, with null `completion`; it does not claim authentication succeeded. Exact native completion sets `completed`, `failed` or `interrupted`. A matching cancellation acknowledgement records interruption even when its failure notification arrives first. OAuth completion matches the exact native login ID and, for MCP, the server and session as well. Unknown completion identities do not resolve another action.
|
|
179
|
+
Receipts include nullable `provider` and `controlState` (`accepted`, `applied`, `held`). Native login initiation is acknowledged as `accepted`, with null `completion`; it does not claim authentication succeeded. Exact native completion sets `completed`, `failed` or `interrupted`. A matching cancellation acknowledgement records interruption even when its failure notification arrives first. OAuth completion matches the exact native login ID and, for MCP, the server and session as well. Unknown completion identities do not resolve another action.
|
|
179
180
|
|
|
180
181
|
`login` returns `state` (`pending`, `completed`, `failed`, `canceled`, `unavailable`), nullable `authorizationUrl`, `canCancel` and nullable `observedAt`. URLs are sensitive live presentation: HQ never opens them automatically or persists them, login IDs or tokens. Codex exposes its native ChatGPT browser login and cancellation, logout and configured MCP OAuth. Claude's interactive login and MCP OAuth commands have no qualified structured challenge surface and remain explicitly unsupported. Claude logout uses the native CLI, discards human-oriented output, confirms process-group shutdown and invalidates account-derived observations. Unconfirmed logout cleanup remains owned by the provider and prevents HQ from releasing runtime ownership.
|
|
181
182
|
|
|
@@ -191,7 +192,7 @@ Native qualification on 2026-10-23 used Codex 0.163.0 and Claude Code 2.1.309. B
|
|
|
191
192
|
|
|
192
193
|
`configuration` accepts `provider`, authorized `workspaceRoot`, optional managed `threadId`, `limit` and `cursor`. Session selection must match both provider and workspace. The result includes `nativeId`, `workingDirectory`, known `effective` settings, bounded `instructionSources` with `isComplete`, and one page of native `choices` (`agent` or `profile`). Null means unknown or unavailable, never a fabricated default. A null `choices` value means the optional native inventory is unavailable; an empty array means a known empty inventory. Effective settings remain readable when Claude omits its optional agent catalog. Native inventory is bounded to 4096 entries; choice continuation binds the query and inventory revision. Instruction source paths are metadata only; HQ does not load those files through this operation. Claude uses an owned session's settings or a disposable workspace-scoped read process with no user prompt. At most four workspace read processes run concurrently; cancellation and runtime shutdown confirm their exit, including reads still initializing. Unconfirmed cleanup retains runtime ownership. Whole configuration documents, source layers and credentials are not returned.
|
|
193
194
|
|
|
194
|
-
`thread-create` and `thread-resume` accept optional `settings`: `model`, `effort`, `outputSchema`, `permissionMode`, `systemInstructions`, `developerInstructions`, plus Codex `sandbox` or Claude `nativeAgent`. The workspace is the native working directory. Codex system/developer instructions map to native base/developer overrides. Claude system instructions use `--system-prompt`, and developer instructions use `--append-system-prompt`. Omitted fields keep native defaults. These are explicit native settings, separate from
|
|
195
|
+
`thread-create` and `thread-resume` accept optional `settings`: `model`, `effort`, `outputSchema`, `permissionMode`, `systemInstructions`, `developerInstructions`, plus Codex `sandbox` or Claude `nativeAgent`. The workspace is the native working directory. Codex system/developer instructions map to native base/developer overrides. Claude system instructions use `--system-prompt`, and developer instructions use `--append-system-prompt`. Omitted fields keep native defaults. These are explicit native settings, separate from native tool approvals. The action envelope byte limit still applies.
|
|
195
196
|
|
|
196
197
|
Startup settings require an idle restart, using close followed by explicit resume; they cannot be attached to active input. Codex may retain a loaded idle thread after unsubscribe and ignores resume overrides there. HQ rejects startup overrides on such a thread; restart the HQ runtime's native connection before applying them. It never acknowledges an ignored model change. Claude opens a new native process for explicit resume, preserving the exact native session ID. Native profile selection and Codex native agent selection are not exposed as startup overrides; discovery does not imply a supported setting change.
|
|
197
198
|
|
|
@@ -209,7 +210,7 @@ Codex supports PNG, JPEG, WebP and UTF-8 text. Images use native `image` data in
|
|
|
209
210
|
|
|
210
211
|
Select a bounded JSON `outputSchema` in session settings or, for Codex, on a message/queue entry. Schemas are limited to 8,192 serialized UTF-8 bytes, 16 levels and 1,024 visited nodes, and must be supported by the installed Zod JSON Schema validator. External references are rejected and no remote schema is retrieved. Codex sends the selected schema as `turn/start.outputSchema`. Claude starts its owned structured process with `--json-schema`; a different schema requires close and explicit resume of the same native session. Its capability descriptor marks this as `idle-restart`.
|
|
211
212
|
|
|
212
|
-
Selected action receipts expose nullable `result: { state, format, text, structuredOutput, isComplete, failure, usage }`. Results come from the complete native final message/result, independently of the 65,536-character history/live preview. The serialized result budget is 8,257,536 UTF-8 bytes, leaving 128 KiB of the 8 MiB IPC frame for action
|
|
213
|
+
Selected action receipts expose nullable `result: { state, format, text, structuredOutput, isComplete, failure, usage }`. Results come from the complete native final message/result, independently of the 65,536-character history/live preview. The serialized result budget is 8,257,536 UTF-8 bytes, leaving 128 KiB of the 8 MiB IPC frame for action and transport metadata. Structured results retain the complete parsed value with `text: null`, avoiding a second escaped copy of the same JSON. This admits a 1 MiB UTF-8 result even when JSON escaping expands its content. HQ validates native structured output against the requested schema without stripping fields. Invalid or missing schema output fails the turn; oversized capture fails explicitly with no saved excerpt. Invalid but bounded JSON remains untrusted evidence in `structuredOutput`. The result is saved with native turn completion, survives a runtime restart and is omitted from action-list reads.
|
|
213
214
|
|
|
214
215
|
`failure` is null or `native-error`, `invalid-structured-output`, `result-too-large`, or `missing-result`. A native turn can complete without a final assistant message; without a requested schema, that remains completed with `isComplete: false` and `missing-result`. It cannot supply a complete report. Interrupted native execution remains interrupted unless capture itself exceeds the result budget. None of these outcomes causes automatic replay.
|
|
215
216
|
|
|
@@ -217,13 +218,13 @@ Selected action receipts expose nullable `result: { state, format, text, structu
|
|
|
217
218
|
|
|
218
219
|
## Claude history
|
|
219
220
|
|
|
220
|
-
Claude connects on its first read through `claude --print --input-format stream-json --output-format stream-json --verbose`. No user prompt, bare mode, permission bypass or SDK dependency is used. Runtime status reports this adapter as `idle`, `ready` or `unavailable`, with its observed CLI version. This session-less process closes after 5 minutes without a read and opens again on the next
|
|
221
|
+
Claude connects on its first read through `claude --print --input-format stream-json --output-format stream-json --verbose`. No user prompt, bare mode, permission bypass or SDK dependency is used. Runtime status reports this adapter as `idle`, `ready` or `unavailable`, with its observed CLI version. History reads start this process only until it has once started and initialized: the runtime keeps that check, so later history reads use the transcripts alone, while usage, models and other reads that use the connection still open it. This session-less process closes after 5 minutes without a read and opens again on the next read that needs it; while it is closed, status reports `idle` with the last observed version. An unavailable native lane requires restarting the host after resolving the native problem.
|
|
221
222
|
|
|
222
223
|
The structured CLI interface has no session-history listing operation. The Claude-owned reader therefore uses direct UUID JSONL files in the native project's directory beneath `CLAUDE_CONFIG_DIR`, or the normal `.claude` directory. CLI and transcript version labels do not gate reads. Required session identity, workspace, parent links, timestamps and message roles are validated, while additive fields and mixed version labels are tolerated. Claude Code can write a hidden record, such as an attachment or a scheduled-task event, a few lines before the record it follows; the reader holds it back until that parent is indexed, and one whose parent the read doesn't reach starts a turn of its own. A message whose parent is unknown is never accepted. Encoded project keys longer than 200 characters, directory/file links, malformed required fields and records larger than 8 MiB report unavailable. Discovery never recurses into subdirectories, including excluded directories. Unsupported discovered sessions have `historyState: unavailable`; they do not prevent supported sessions from being listed.
|
|
223
224
|
|
|
224
225
|
Discovery verifies the workspace recorded inside each transcript before returning its identity or title. A matching native directory name alone is insufficient because punctuation replacement can produce colliding directory keys. Native working directories may be the selected workspace or its subdirectories, including removed subdirectories. The nearest existing path ancestor must resolve inside the workspace without excluded segments; sibling paths and symlink escapes are rejected. Foreign workspaces are omitted. If a file's workspace cannot be established, discovery reports unavailable rather than inventing an empty result.
|
|
225
226
|
|
|
226
|
-
The existing SQLite worker incrementally records file identity, complete-line offsets, message identities and parent links. It does not save message bodies. File identity includes the current reader projection revision and a native prefix hash, so source changes invalidate the derived projection. Each worker batch inspects at most 128 directory entries and reads at most 16 MiB of new transcript bytes, one file at a time, which fits the largest record. The adapter continues batches with a host-event-loop yield between them, within a 30-second operation budget. If that budget is reached, the read reports unavailable and subsequent reads continue indexing. At most four incomplete discovery iterators remain open. Shutdown closes them. Discovery continuations use that projection without starting another directory scan; start a fresh first page to refresh discovery.
|
|
227
|
+
The existing SQLite worker incrementally records file identity, complete-line offsets, message identities and parent links. It does not save message bodies. File identity includes the current reader projection revision and a native prefix hash, so source changes invalidate the derived projection. Each worker batch inspects at most 128 directory entries and reads at most 16 MiB of new transcript bytes, one file at a time, which fits the largest record. The adapter continues batches with a host-event-loop yield between them, within a 30-second operation budget. If that budget is reached, the read reports unavailable and subsequent reads continue indexing. At most four incomplete discovery iterators remain open. Shutdown closes them. Discovery continuations use that projection without starting another directory scan; start a fresh first page to refresh discovery. A transcript whose identity, size and modification time match a projection that reached its end is neither read nor written again. Each directory scan keeps the transcripts it has seen in memory, and only a complete scan removes the others from the projection, so reads over unchanged transcripts write nothing to SQLite. No additional cache infrastructure or browser cache is used.
|
|
227
228
|
|
|
228
229
|
Current-chain membership and turn starts are indexed as metadata. Ordinary item and turn continuations seek those indexes; they do not walk the full chain per page. A changed branch rebuilds membership before exposing that revision. Repeated native message identities can replace content while retaining their parent; a changed parent for the same identity is an unsupported format.
|
|
229
230
|
|
|
@@ -237,7 +238,7 @@ Send `{ kind: 'action', action: { id, runtimeEpoch, command } }`. Generate one U
|
|
|
237
238
|
|
|
238
239
|
| Action | Fields and behavior |
|
|
239
240
|
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
240
|
-
| `thread-fork` | Source `threadId`, child `name`. Requires an idle owned source or an inactive managed source. Creates a distinct native session and retains `forkedFromThreadId` and exact native lineage
|
|
241
|
+
| `thread-fork` | Source `threadId`, child `name`. Requires an idle owned source or an inactive managed source. Creates a distinct native session and retains `forkedFromThreadId` and exact native lineage. |
|
|
241
242
|
| `thread-archive` | Idle owned `threadId`. Confirms native background cleanup, archives natively and releases control. |
|
|
242
243
|
| `thread-unarchive` | Inactive archived `threadId`. Unarchives the exact native session and leaves it inactive. |
|
|
243
244
|
| `thread-compact` | Idle owned `threadId`. Records native admission separately from its correlated turn completion. Clears the live presentation and requires a fresh history read. |
|
|
@@ -262,7 +263,7 @@ Names use lowercase ASCII letters, digits and hyphens, start with a letter or di
|
|
|
262
263
|
|
|
263
264
|
Codex may keep an idle native thread loaded after `thread/unsubscribe`, as when a terminal still holds it. An explicitly confirmed resume may reacquire that thread when its known HQ control is inactive and managed, without settings overrides. Active native threads, uncertain HQ ownership and already controlled idle sessions remain blocked. Other adoption and recovery checks are unchanged.
|
|
264
265
|
|
|
265
|
-
Receipts separate `delivery` (`queued`, `submitted`, `acknowledged`, `uncertain`, `failed`, `canceled`) from nullable native turn `completion` (`completed`, `failed`, `interrupted`). Acknowledgement means the exact native request was accepted, not that the turn or tool completed. Permission replies remain submitted after a pipe write and become acknowledged only when Codex resolves the exact native request or Claude returns a tool-result block for the exact tool-use identity. Claude cancellation expires the prompt and leaves an unacknowledged written reply uncertain. Resolution does not prove a tool ran. The receipt includes HQ/native identity, request phase, digest, timestamps, safe failure classification and optional related action. Only selected receipts expose undelivered `queuedInput` and the nullable complete native `result`; collection reads omit
|
|
266
|
+
Receipts separate `delivery` (`queued`, `submitted`, `acknowledged`, `uncertain`, `failed`, `canceled`) from nullable native turn `completion` (`completed`, `failed`, `interrupted`). Acknowledgement means the exact native request was accepted, not that the turn or tool completed. Permission replies remain submitted after a pipe write and become acknowledged only when Codex resolves the exact native request or Claude returns a tool-result block for the exact tool-use identity. Claude cancellation expires the prompt and leaves an unacknowledged written reply uncertain. Resolution does not prove a tool ran. The receipt includes HQ/native identity, request phase, digest, timestamps, safe failure classification and optional related action. Only selected receipts expose `nativeThreadId`, the native session of the action's thread once HQ records it, undelivered `queuedInput` and the nullable complete native `result`; collection reads omit all three. Queued input retains prepared text, native skill identity, content-bound file references and explicit turn settings, never file bytes or skill content. It is cleared after delivery acknowledgement or cancellation.
|
|
266
267
|
|
|
267
268
|
A missing acknowledgement never triggers an automatic resend. Exact late responses reconcile delivery, including completion that arrived first. Native output loss marks the affected provider controls and submitted work uncertain. A Claude process failure affects its own session; a Codex transport failure affects its Codex cohort. Restart quarantines controls from an interrupted runtime; explicit recovery preserves the HQ identity and name. Successful shutdown proves native process-group exit before marking controls inactive. Unknown creation without a native identity remains uncertain.
|
|
268
269
|
|
|
@@ -281,13 +282,13 @@ Each record contains identity, `kind`, `isBlocking`, `state`, `replyActionId`, t
|
|
|
281
282
|
|
|
282
283
|
### Claude native control
|
|
283
284
|
|
|
284
|
-
Each controlled session has one native `claude` process in the authorized workspace while it is in use. A session idle for 60 minutes since its last turn ended, or since it opened, gives up its process: HQ reads its native settings once
|
|
285
|
+
Each controlled session has one native `claude` process in the authorized workspace while it is in use. A session idle for 60 minutes since its last turn ended, or since it opened, gives up its process: HQ reads its native settings once and closes the process, and the session stays idle with no state transition. Its skills and configuration reads answer from what it kept, an interrupt is refused as for any idle session, and stopping or releasing it needs no process. Input, renames, extension control and MCP reads first reopen it with `--resume`, or `--session-id` when it never had input, and its kept settings. A parked session keeps its controlled-thread slot, of 32 per runtime, and a runtime restart treats it like any other managed Claude session. A running or waiting session is never stopped. HQ adds structured input/output, replayed user-message acknowledgements, partial-message output and `--permission-prompt-tool=stdio`. It applies only explicitly selected startup options, including model, instructions or an output schema. It preserves normal native settings, session persistence and permission handling. Native skills remain available. Native idle initialization, session identity and matching acknowledgements establish capability. Version labels and missing diagnostic version metadata do not disable compatible controls or file history.
|
|
285
286
|
|
|
286
287
|
Creation chooses a native UUID without inference, then names that exact session. Resume uses native `--resume` and verifies the session-id fence on the name control before marking the session idle. The operator's handoff confirmation establishes that another CLI controller is closed; file timestamps and file-backed unknown states do not establish this. Independently running CLIs are outside HQ's state-directory coordination boundary.
|
|
287
288
|
|
|
288
289
|
An ordinary message is submitted only while idle. Its native UUID becomes the turn identity. A matching native replay or result acknowledges delivery, and the native result establishes completion. A request-success envelope can acknowledge a name change or interruption without a response body. HQ never writes queued follow-up input into Claude's own busy queue; the shared HQ queue dispatches it only after the previous result. Interruption acknowledgement alone does not establish a stop. An error result is classified as interrupted only when the qualified native interruption marker was observed for an explicitly interrupted input. Other terminal errors remain failed.
|
|
289
290
|
|
|
290
|
-
Claude questions use exact question text as their answer identity and expose whether multiple selections are supported. Claude can_use_tool permissions use response `{ kind: 'decision', decision: 'accept' | 'decline' }`; question replies use `{ kind: 'answers', answers }`. The response kind `permission` with a turn/session scope belongs to Codex additional permissions. Tool permissions offer `accept` or `decline` for the displayed input only. Complete request details include native policy hints and reasons as untrusted display data; none authorizes a response. Unsupported permission fields or interaction surfaces receive an unsupported-request error. Requests requiring a native interaction card cannot be answered with generic approval; supported `AskUserQuestion` cards use their typed answer contract. Session-wide permission changes are unavailable; HQ does not apply native permission suggestions automatically. A
|
|
291
|
+
Claude questions use exact question text as their answer identity and expose whether multiple selections are supported. Claude can_use_tool permissions use response `{ kind: 'decision', decision: 'accept' | 'decline' }`; question replies use `{ kind: 'answers', answers }`. The response kind `permission` with a turn/session scope belongs to Codex additional permissions. Tool permissions offer `accept` or `decline` for the displayed input only. Complete request details include native policy hints and reasons as untrusted display data; none authorizes a response. Unsupported permission fields or interaction surfaces receive an unsupported-request error. Requests requiring a native interaction card cannot be answered with generic approval; supported `AskUserQuestion` cards use their typed answer contract. Session-wide permission changes are unavailable; HQ does not apply native permission suggestions automatically. A reply is written through the separate control channel and acknowledged only by the matching tool result. Tool execution can still fail after that acknowledgement. Reused raw request IDs in different CLI processes have distinct controller scopes. Prompt bodies and replies remain out of SQLite.
|
|
291
292
|
|
|
292
293
|
Both providers support turn-correlated MCP `form` and `url` elicitation. Forms use bounded local JSON Schema validation (8 KiB, 16 levels, 1,024 nodes); responses stay within the action envelope’s 32 KiB budget. Unknown modes, unsupported schemas and Codex requests without a native turn are denied. Elicitation URLs are HTTP(S) links without embedded credentials; applications decide how to display or open them. Never render native strings as HTML or terminal instructions, and never infer a permission decision from model output or form metadata. Codex acknowledges an elicitation reply through its exact native request-resolution event. Claude supplies no equivalent form-reply acknowledgement: a successful write stays submitted, and terminal completion or cancellation expires the request and makes its unresolved reply uncertain. Retrying that same action returns its receipt without sending again.
|
|
293
294
|
|
|
@@ -295,7 +296,7 @@ Partial text uses temporary live identities until the final native message UUID
|
|
|
295
296
|
|
|
296
297
|
## Native skill catalog
|
|
297
298
|
|
|
298
|
-
`skills` accepts `threadId`, optional `search`, `limit` (default 32, maximum 128) and `cursor`. It operates on a controlled session and never adopts or resumes an external session. Codex uses native `skills/list` for that thread's authorized workspace, plus the skills in the operator's Codex extra roots; Claude uses that session's native initialization command list, which includes explicit-only skills. Its refresh endpoint omits those skills, so HQ does not use it. Close and explicitly resume the session to refresh Claude's catalog. Inactive or unsupported sessions report `unavailable`, with no successful-empty fallback. Native discovery errors produce `partial` and an `unavailableCount`. `observedAt` records when the native inventory was observed; it stays fixed for a Claude session and is null when unavailable.
|
|
299
|
+
`skills` accepts `threadId`, optional `search`, `limit` (default 32, maximum 128) and `cursor`. It operates on a controlled session and never adopts or resumes an external session. Codex uses native `skills/list` for that thread's authorized workspace, plus the skills in the operator's Codex extra roots; Claude uses that session's native initialization command list, which includes explicit-only skills. Its refresh endpoint omits those skills, so HQ does not use it. Close and explicitly resume the session to refresh Claude's catalog. Inactive or unsupported sessions report `unavailable`, with no successful-empty fallback. Native discovery errors produce `partial` and an `unavailableCount`. `observedAt` records when the native inventory was observed; it stays fixed for a Claude session and is null when unavailable. `invocationPrefix` is the text that starts a skill invocation in the provider's native input, `/` for Claude and `$` for Codex, and is null when unavailable; a provider adapter supplies it with its inventory in `IProviderSkills`.
|
|
299
300
|
|
|
300
301
|
Rows contain an opaque `id`, native `name`, `description`, nullable `argumentHint`, `kind`, `path`, `scope`, `prerequisites` and `requiresExplicitInvocation`, plus native availability as `isEnabled`. Codex supplies skill identity, source/scope, enabled state and declared tool prerequisites. Claude supplies native command names, descriptions, argument hints and a built-in marker when available. Missing fields are null or `kind: 'unavailable'`; HQ does not inspect skill files to infer them. The one exception is Codex extra roots, which native discovery does not list: HQ reads each skill's single-line `name` and `description` frontmatter from `<root>/<directory>/SKILL.md`, reports it with scope `host`, skips linked directories and files, and counts unreadable entries in `unavailableCount`. A native skill with the same name takes precedence. Declared prerequisites are metadata, not proof that an integration is connected. Invocation rules remain with the CLI, including explicit-only skills.
|
|
301
302
|
|
|
@@ -314,11 +315,14 @@ Trusted runtime construction also accepts `codexExtraSkillRoots?: string[]` and
|
|
|
314
315
|
| `managed-thread-name` | `name` | One HQ record or null, with case-insensitive lookup and the same workspace authorization. |
|
|
315
316
|
| `suggest-thread-name` | `topic` | An editable lowercase label, with a currently free suffix when needed. This read does not reserve it. |
|
|
316
317
|
| `receipt` | `actionId` | One receipt or null. |
|
|
318
|
+
| `action-wait` | `actionId`, `until`, `timeoutMs` | The receipt once it reaches `until`, or as it stands when `timeoutMs` passes, with `isTimedOut`. |
|
|
317
319
|
| `actions` | `threadId`, optional `limit`, `cursor` | Creation/UUID seek page of action metadata without queued bodies. |
|
|
318
320
|
| `events` | `threadId`, optional `after` (default 0), `limit` | Ascending durable sequence page and `hasMore`; continue after the final sequence. |
|
|
319
321
|
| `approvals` | `threadId`, optional `state`, `limit`, `cursor` | Durable approval metadata pages with nullable live presentation. |
|
|
320
322
|
| `live-items` | `threadId` | Active/awaiting-flush item window, `hasGap`, `revision` and `unchanged`. Optional `afterRevision` omits bodies for an unchanged window. |
|
|
321
323
|
|
|
324
|
+
`{ kind: 'action-wait', actionId, until, timeoutMs }` waits on one receipt instead of polling `receipt`, and returns `{ receipt, isTimedOut }`. `until: 'native'` returns once the receipt has a `nativeThreadId`, as soon as HQ records a created or forked session's native ID, and `until: 'settled'` once its `delivery` is `acknowledged`, `uncertain`, `failed` or `canceled`, which only late native evidence or an operator's recovery changes. A `native` wait also returns once the receipt settles without a native thread ID, such as after a failed creation, because nothing can then give it one. `timeoutMs`, from 1 to 30,000, bounds the wait; when it passes first, the receipt comes as it stands with `isTimedOut: true`. An unknown action returns a null receipt at once. The receipt's workspace is authorized as for `receipt`. HQ reads the receipt again only after the actions module records a change that can affect it, never on a timer. A wait still running when the runtime starts closing ends at once with RUNTIME_NOT_RUNNING. A wait is admitted work, so `withStorageMaintenance` waits for it to end, and over IPC it holds one of the 32 connections; its 30-second limit fits the 35-second IPC deadline.
|
|
325
|
+
|
|
322
326
|
The installed CLI exposes `managed-thread-name --name <name>` and `suggest-thread-name --topic <topic>`. Suggestions normalize punctuation to hyphens, keep at most 32 characters, and use `session` when the topic contains no ASCII letters or digits. Creation checks availability again inside its admission transaction. All action targets, histories and relationships continue to use immutable HQ/native identities. Name lookup never adopts, resumes or starts a native session.
|
|
323
327
|
|
|
324
328
|
Control pages default to 32 and cap at 128. Seek cursors are bound to their complete query and ordering. Reads recheck allowed workspaces. Rejected controls retain their known thread association, and native availability failures appear in each affected thread's replay. Lifecycle replay contains metadata, not token or tool output. Each provider has a bounded native lifecycle backlog; overflow stops that source and marks its state uncertain rather than losing events silently. Other providers retain their independent connection and admission state.
|
|
@@ -333,12 +337,12 @@ Codex leaves `reasoning` items out as it reads them, so a Codex page can hold fe
|
|
|
333
337
|
|
|
334
338
|
Every session has a live state: `running`, `waiting` (on the operator), `idle`, `closed`, `failed` or `unknown`. A managed session reports it from its HQ record. A session another client drives is observed and listed with `ownership: 'external'`; HQ sends it no input until `thread-adopt` records it as managed, and never stops, wakes or drives a session a terminal runs. A managed session HQ closed is observed again, so a terminal that continues it shows its state.
|
|
335
339
|
|
|
336
|
-
A Claude session's summary carries `terminal`: `{ kind: 'interactive' }`, or `{ kind: 'background', attachId }` with the short ID `claude attach` takes, while the latest `claude agents --json` run lists it with a `pid`, and null otherwise; Codex summaries always carry null. While it is set, `thread-adopt` and `thread-resume` of the session, and input to it, are refused with JG_AGENT_HQ_ACTION_CONFLICT, so a session HQ runs that a terminal resumed takes nothing from HQ until the terminal closes it.
|
|
340
|
+
A Claude session's summary carries `terminal`: `{ kind: 'interactive' }`, or `{ kind: 'background', attachId }` with the short ID `claude attach` takes, while the latest `claude agents --json` run lists it with a `pid`, and null otherwise; Codex summaries always carry null. While it is set, `thread-adopt` and `thread-resume` of the session, and input to it, are refused with JG_AGENT_HQ_ACTION_CONFLICT, so a session HQ runs that a terminal resumed takes nothing from HQ until the terminal closes it. An approval request of a Codex turn reaches every client the daemon serves; when another answers first, HQ's prompt expires.
|
|
337
341
|
|
|
338
342
|
- **Codex.** The shared daemon broadcasts every thread's status. HQ records the states of sessions inside the allowed workspaces, reading each session's workspace once, and their items stay readable with `items`. A session already running when the connection opens reports no change, so each time the connection opens, including after a reconnect, HQ reads the daemon's loaded threads (`thread/loaded/list`, 128 a page, at most 8 pages) and records each one's state from its status. An ephemeral session, which Codex doesn't save, such as a helper session Codex starts itself, is never observed. Observation runs while the Codex connection is open; the connection opens on the first Codex request.
|
|
339
343
|
- **Claude.** While the runtime runs, HQ runs `claude agents --json` every 30 seconds, or every 5 seconds at the `live` pace, each run limited to 10 seconds and 65,536 bytes of output, and joins its entries to Claude discovery by `sessionId`. An entry without a `pid` isn't running, whatever its `state` says, so it counts as missing. Otherwise `status: "busy"` and a background session's `state: "working"` are running, `status: "waiting"` (a question or a permission prompt, for either kind of session) and an interactive `status: "blocked"` are waiting, `status: "idle"` is idle, and anything else is unknown; an entry missing from a run is closed. Entries whose `pid` is a native process this runtime started, its managed sessions and its metadata process, are left out. A failed, late, oversized or malformed run changes nothing. Sessions HQ manages keep their managed records.
|
|
340
344
|
|
|
341
|
-
`{ kind: 'session-states', afterSequence?, limit? }` returns state transitions in sequence order after `afterSequence` (default 0), at most `limit` per page (default 32, maximum 128), with `hasMore`. Continue after the last returned `sequence`. Each transition has `sequence`, `provider`, nullable `nativeId`, nullable `threadId` (managed sessions only), `ownership`, nullable `previousState`, `state`, `reason` and `recordedAt`.
|
|
345
|
+
`{ kind: 'session-states', afterSequence?, limit? }` returns state transitions in sequence order after `afterSequence` (default 0), at most `limit` per page (default 32, maximum 128), with `hasMore`. Continue after the last returned `sequence`. Each transition has `sequence`, `provider`, nullable `nativeId`, nullable `threadId` (managed sessions only), `ownership`, nullable `previousState`, `state`, `reason` and `recordedAt`. Every page also returns `latestSequence`, the highest sequence ever issued, or 0 before the first, so a reader can start after it to follow only new transitions, and `isReset`, true when the reader can't continue exactly after `afterSequence`: it is above `latestSequence`, as after a fresh state root or the restore of an older snapshot, or it is above 0 and its own transition was pruned. The page still holds the transitions after `afterSequence` that remain.
|
|
342
346
|
|
|
343
347
|
| Reason | When |
|
|
344
348
|
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -375,221 +379,29 @@ Usage retains actual bucket/window identities, optional native labels, reported
|
|
|
375
379
|
|
|
376
380
|
Claude uses the experimental `get_usage` control with `skip_behaviors: true`, and validates the native `rate_limits.limits` rows rather than inferring quotas from session costs or reading credentials. The [published provider control types](https://app.unpkg.com/@anthropic-ai/claude-agent-sdk@0.3.301/files/sdk.d.ts) describe this protocol; HQ invokes the installed CLI directly. Independent model/surface windows stay separate. Null percentages are omitted; zero is retained when reported. Unsupported shapes are unavailable. Claude does not report ordinary-usage permission, so it remains null. Recognized session and weekly groups have normalized five-hour and seven-day periods; unknown groups retain their native identity with period other and a null duration. No private OAuth endpoint, credential scrape or status-line execution is used.
|
|
377
381
|
|
|
378
|
-
Every usage read requests current native observations
|
|
379
|
-
|
|
380
|
-
## CLI
|
|
381
|
-
|
|
382
|
-
`jg-agent-hq serve --state-root <directory> --workspace-root <directory>` starts the host. Repeat `--workspace-root` to authorize several roots. Client commands use `--state-root`; history commands also use one `--workspace-root` and, where required, `--native-id`. History and usage accept `--provider codex|claude` (default `codex`). Paged commands support `--limit` and `--cursor`; items support `--turn-id`; thread discovery supports `--search`. CLI paths resolve from the caller's working directory. There are no shell commands or raw native RPC passthroughs.
|
|
383
|
-
|
|
384
|
-
Output is one JSON line with `schemaVersion: 1`. Read output includes the command `kind` and `result`. Startup reports `kind: ready`. Confirmed shutdown reports `kind: stop` with `result.state: stopped`. Failure output goes to stderr with a safe error kind/message and exit status 1. The CLI never prints diagnostic causes or native payloads in an error response.
|
|
385
|
-
|
|
386
|
-
`jg-agent-hq session-states --state-root <directory> [--after-sequence <sequence>] [--limit <1..128>]` reads one page of session state transitions. `jg-agent-hq active-sessions --state-root <directory>` reads the active sessions, `jg-agent-hq unstarted-threads --state-root <directory> --workspace-root <path> [--provider <provider-id>]` reads the unstarted threads, and `jg-agent-hq observation-pace --state-root <directory> --pace live|background` sets the Claude poll's pace.
|
|
387
|
-
|
|
388
|
-
`jg-agent-hq request --state-root <directory>` reads one complete HQ request from stdin, validates it, and prints the usual response. It accepts no extra target flags. This exposes action and reconnect operations without putting message text or question answers in command-line arguments. Its `stop` response acknowledges admission; use the dedicated `stop` command for confirmed shutdown.
|
|
389
|
-
|
|
390
|
-
## Plan coordination
|
|
391
|
-
|
|
392
|
-
`computePlanRevision({ body, metadata, milestones })` is the pure Node API for execution identity. `metadata` contains JSON-safe `extensions`: every frontmatter field except the administrative ones. Object keys use strict deterministic JSON, so their order is not contractual; array order is. The exact parsed body, including its line endings, is contractual.
|
|
393
|
-
|
|
394
|
-
Send `{ kind: 'plan', command }` through the existing local request API. Every command selects `target: { directory }`, an absolute directory inside an allowed workspace. HQ reads plans through jg-plans observations and keeps every frontmatter field, including plan `id`, in `extensions`, except the administrative ones. Only `created_at`, `updated_at`, `revision` and `status` are administrative. Malformed, non-mapping or non-JSON metadata fails closed. Plans without `protocol: "0.2"` get no preferred-document conformance gate. A plan that declares protocol 0.2 must pass the jg-plans check at each stage that grants authority: plan approval needs plan.md to conform on its own, while finalization, sequence approval, authorization and execution checks need plan.md and milestones.md to conform together. A nonconforming plan stays readable, so `status`, inspection and revision workflows continue. `approve`, `finalize` and `authorize` reject it with `JG_AGENT_HQ_PLAN_INVALID`, and `check-execution` and admission stay closed.
|
|
395
|
-
|
|
396
|
-
Milestone contracts retain every requirement byte outside observed status/identity lines, plus preamble and all intervening/trailing shared sections. Only recognized Overview table spans and the three valid `jg_skills` binding fields are excluded; other milestone metadata remains contractual. HQ does not regenerate Overview tables. Statuses must be exactly pending, in progress or done, and milestone IDs/order participate in sequence identity. Ordinal renumbering alone does not change a milestone's identity. jg-breakdown assigns every milestone ID through jg-plans; HQ never assigns one. When present, a skills binding must match the current plan id, revision and fingerprint excluding exactly the four administrative keys. A matching binding never grants HQ approval or execution permission.
|
|
397
|
-
|
|
398
|
-
| Command kind | Required fields and result |
|
|
399
|
-
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
400
|
-
| `status` | `target`. Returns current execution revisions, full inspection hashes, `skillsBinding` (`absent`, `current` or `stale`), approval state and a bounded coordination summary with the completion count and `unmatchedEvidence`: current receipts whose milestone ID no longer appears in the sequence. |
|
|
401
|
-
| `milestones` | `target`, optional `limit` (default 32, maximum 128) and `cursor`. Returns a bounded ordered seek page. |
|
|
402
|
-
| `register` | `target`. Records the directory so snapshots capture its plan files, after checking it is an allowed directory outside excluded archive/backup paths. It takes no document locks and reads no plan file, so the plan may not exist yet. Returns `{ directory }`. |
|
|
403
|
-
| `finalize` | `target`, `action`, `expected`. Requires every milestone to carry the ID jg-breakdown assigned, records the current revision and returns the unchanged milestone file. Receipts of a milestone the sequence no longer marks done stop counting. |
|
|
404
|
-
| `begin-revision` | `target`, `action`, `expected`, `intent: 'plan' \| 'breakdown'`, `threadIds`, `checkouts`. Closes execution admission and starts owned interruption/checkpoint work. |
|
|
405
|
-
| `revision-invoke` | `target`, `action`, `expected`, `revisionId`, `skill: 'jg-plan' \| 'jg-breakdown'`. Explicitly opens the next native planning invocation after proven quiescence. It sends no model input itself. |
|
|
406
|
-
| `complete` | `target`, `action`, `expected`, `milestoneId`, actual `checks` and selected `checkouts`. Retains the verified contract/check references and actual worktree fingerprints, then advances the marker. |
|
|
407
|
-
| `approve` | `target`, `action`, `expected`, `scope: 'plan' \| 'sequence'`, `presentationHash`. The hash must match the exact presented plan or finalized sequence. Sequence approval also requires current plan approval. |
|
|
408
|
-
| `revoke` | `target`, `action`, `expected`, `scope: 'plan' \| 'sequence' \| 'execution' \| 'all'`. Revoking a plan also revokes sequence and execution authority; revoking a sequence also revokes execution authority. |
|
|
409
|
-
| `authorize` | `target`, `action`, `expected`, `mode: 'supervised' \| 'auto'`, selected unique `milestoneIds` (empty only for a plan without a breakdown). Records permission for this exact execution scope without starting an agent. |
|
|
410
|
-
| `check-execution` | `target`, `expected`, `authorizationId`, nullable `milestoneId`, `mode`. Rejects missing, revoked, stale, wrong-mode or out-of-scope authority. It sends no native input. |
|
|
411
|
-
|
|
412
|
-
`expected` is the exact `{ planDigest, breakdownDigest }` returned by inspection. Each mutating `action` has a UUID `id`, `operatorId` and `source: { kind: 'user-action' | 'user-message', reference }`. These are trusted local operator inputs. The module never infers approval from natural-language claims, an agent response or imported feedback. Its owner-only local IPC and files do not isolate hostile code executing as the same OS user. Native permissions remain separate action kinds with their own exact native request identities.
|
|
413
|
-
|
|
414
|
-
Milestones are optional. Finalizing a plan with no milestone file returns `content: null` and does not create a file. That unit needs plan approval and explicit execution authorization, with `milestoneIds: []`; execution checks, completion and native execution scopes select it with `milestoneId: null`. A real breakdown requires a nonempty selection of its stable IDs and its separate sequence approval. Null cannot select a milestone or bypass sequence approval. Whole-plan completion retains its exact plan contract/digest, actual check references and checkout evidence, with null shared-sequence digest. Completed work cannot be authorized again under that unchanged contract.
|
|
415
|
-
|
|
416
|
-
Skills bindings are optional for generic HQ plans. When present, their syntax must be valid and their plan ID, revision and structural fingerprint must match before finalization or execution. A valid but stale binding remains visible in status: plan approval and explicit revision invocations remain available so jg-plan can retain the old sequence until jg-breakdown refreshes its coverage. Malformed bindings fail as invalid artifacts. A stale binding never supplies sequence approval or completion, even when semantic execution digests are unchanged.
|
|
417
|
-
|
|
418
|
-
Every milestone has one `**Milestone ID:** <uuid>`, written by jg-breakdown, immediately below its `**Status:**` line. Blank lines may separate the heading from its status; no intervening requirement prose is allowed. In a protocol 0.2 sequence, a milestone's `**Acceptance criteria:**` coverage line follows its ID line and is milestone contract prose. Finalization rejects a missing, duplicate, malformed or misplaced ID and inconsistent framing, changes no file and returns the complete file for presentation before approval. Outside a revision, a changed finalized contract must begin a revision before it is finalized again. A raw or changed sequence cannot inherit finalized status or sequence authority. A done marker remains visible but blocks execution without a current completion receipt for its milestone ID.
|
|
419
|
-
|
|
420
|
-
The milestone contract includes its stable UUID, title without its ordinal, all requirement prose, shared sequence requirements and the approval statement. Status and identity marker lines are excluded from the prose; only the derived Overview table is excluded from shared text. Prose next to that table remains contractual. Sequence order is significant. Renumbering preserves execution identity; changed requirements, dependencies, scope or order require applicable approval. Full-file hashes preserve exact UTF-8 bytes and are distinct from semantic execution revisions. Administrative frontmatter, session labels, status advancement and coordination receipts do not change execution digests.
|
|
421
|
-
|
|
422
|
-
Plan and milestone artifacts are bounded to 1 MiB each; coordination evidence is bounded to 8 MiB and a sequence to 1,024 milestones. Reads do not scan planning trees. Milestone pages use ordinal seek ordering with unique ascending ordinals. Cursors bind the selected directory, page size, execution revisions and exact milestone inspection hash. Any changed artifact requires a fresh page; renumbering or status-only edits still preserve approval. A SQLite projection is rebuilt only when the selected milestone file's full hash changes. Every read verifies its source file; the projection is replaceable and never grants authority.
|
|
423
|
-
|
|
424
|
-
Mutations acquire the HQ metadata lock at `<coordinationRoot>/.runtime/hq.lock` (`coordinationRoot` defaults to `stateRoot`), then the public jg-plans document locks in plan-before-milestones order. Use `serve --coordination-root <directory>` when coordination ownership is separate from runtime storage. Locks cover bounded observation, preparation, journaling and file application; no model turn or native stop wait holds them. A busy document lock becomes `JG_AGENT_HQ_ACTION_CONFLICT` with the safe `document-locked` reason. There is no automatic stale-lock takeover.
|
|
425
|
-
|
|
426
|
-
SQLite persists exact prepared plan/milestone sources and timestamps before application. A plan source of null means keep; milestone operations are explicitly keep, write with source, or remove. A null recorded before-plan hash permits only coordination work. Replay accepts only each recorded baseline or its exact desired state. Markdown is applied before coordination. Every HQ replacement uses jg-fs checked atomic writes with explicit 0600; absent targets are created exclusively and privately before content is written. Strict bounded, same-handle, single-link reads remain in HQ. Inspection alone never changes file permissions.
|
|
427
|
-
|
|
428
|
-
After file durability succeeds, document locks must release successfully before SQLite marks the intent completed and clears its write bodies; HQ metadata ownership remains held through completion. A write, sync or release failure retains the prepared payload and closes admission. A crash after release and before completion is replayable. A failed completion acknowledgement is reconciled against the durable ledger: confirmed completion succeeds, an uncommitted intent stays pending, and an unknown outcome remains closed. Retry only the same original action and payload after inspection; changed files or payloads conflict. Nonparticipating writers still have a final comparison-to-replacement/removal race; these operations are not a multi-file transaction.
|
|
429
|
-
|
|
430
|
-
Accepted implementation input prepares aggregate and selected pending milestone progress before native admission. Message, queue and steering requests record accepted implementation scope; an in-progress marker does not assert that a provider has started or completed a turn. Progress is journaled and released before current authority is checked again for native admission. A retry of the same native action can finish its retained progress intent without regenerating timestamps; it still needs current runtime/authorization checks. Native control and permission actions do not advance progress.
|
|
431
|
-
|
|
432
|
-
Only accepted completion evidence advances a milestone to done. Aggregate done requires the complete current execution contract, applicable current approval/finalization and verified completion; administrative done markers alone do not provide them. Progress-only plan changes preserve revision and set updated_at once in the saved prepared source. An unchanged plan preserves its timestamp. The current finalization receipt retains the operator event, semantic revision, nullable canonical file hash and timestamp independently of write recovery bodies. Status reads expose pendingActionId for unresolved writes and never approve or resume work.
|
|
433
|
-
|
|
434
|
-
The installed `plan-status` and `plan-milestones` commands accept `--state-root` and `--directory`; the latter also accepts `--limit` and `--cursor`. Use `request` for the closed JSON mutation commands. The result is a tagged `status`, `milestones`, `registered`, `finalized` or `execution-check` object within the outer `plan` response. A retried finalization returns current status when its finalized artifact no longer exists or has changed.
|
|
435
|
-
|
|
436
|
-
### Revision and progress recovery
|
|
437
|
-
|
|
438
|
-
Begin revision before invoking a planning skill. Execution admission closes under the shared short lock. The runtime interrupts exactly the affected managed threads and verifies their native background cleanup before granting an editing lease. It retains a checkpoint of contracts, UUIDs/status, original completion records, selected checkout claims and actual Git/file fingerprints. Metadata locks are released during native planning. Failed or uncertain cleanup keeps editing blocked. Stop jobs belong to the runtime and survive a client disconnect. A runtime restart requires an explicit new planning invocation; it never adopts the editing lease automatically.
|
|
439
|
-
|
|
440
|
-
The local host supplies checkout evidence as `{ repository, directory, claimReference, paths }`. Paths are exact relative task paths. The core streams their contents, records link targets without following them, includes missing paths as deletions, and captures the current Git branch/HEAD. It does not stage or reset files and rejects traversal, parent-link escapes, `.git` and excluded archive/backup directories. Check commands and references are trusted operator evidence; this primitive does not execute arbitrary submitted commands or treat an imported agent claim as verification.
|
|
441
|
-
|
|
442
|
-
After native `jg-plan` revises the contract and an explicitly requested `jg-breakdown` regenerates a needed sequence, close the planning controller before finalization. jg-breakdown owns milestone identity and progress: it keeps the ID and status of a milestone whose requirements still hold and assigns new IDs to new work. Finalization carries completion evidence by milestone ID, so rewording keeps a verified completion without new checks. A milestone the new sequence no longer marks done has its receipts reopened, and done credit returns only with a new completion. Evidence whose milestone ID left the sequence stays in coordination.json and appears in status as `unmatchedEvidence` until the ID returns. A done marker without a current receipt for its ID blocks the plan.
|
|
443
|
-
|
|
444
|
-
A whole-plan checkpoint retains null milestones and an empty milestone inventory. When a revision removes a sequence because the remaining scope no longer needs one, its milestone evidence becomes unmatched; absence alone never resets progress, and whole-plan execution still needs plan approval and fresh authorization.
|
|
445
|
-
|
|
446
|
-
Finalization is journaled like other plan writes; retry the same action and payload after a partial write. Present the complete milestone file before sequence approval. Applicable plan and sequence approvals are required again after digest changes. Approval does not resume work: send a fresh `authorize` with the intended mode and scope. Execution authority is also bound to the current runtime epoch.
|
|
447
|
-
|
|
448
|
-
Guided native input adds `plan: { kind: 'execution', authorizationId, milestoneId, mode, revision }` or `{ kind: 'planning', revisionId, invocationId }` to its action envelope. The controller binds this context atomically to the managed thread. Planning starts with the exact authorized native skill. A live thread cannot switch scopes; close it before an explicit resume under a different scope. Queued input retains its original scope and cannot run under stale approval or during revision. Ordinary input on a bound thread retains that exact scope and remains subject to its current gate, including after revocation or completion. It cannot silently become unscoped input. Renaming and explicit replies to an existing native permission/question remain separate, revision-guarded controls; neither starts a new implementation turn or restores execution authority. Native permissions still require the exact pending request.
|
|
449
|
-
|
|
450
|
-
Selected status/admission/queue observations detect external contract edits or milestone deletion, persist a closed gate and request exact bound-thread interruption. These observations grant no operator authority and report uncertain in-flight effects. The finalized baseline retains identities and progress, so a later revision checkpoint starts from them after direct CLI edits. Invalid artifacts fail explicitly. No directory scan or filesystem watcher is used. Status projects Revising, approval/breakdown requirements, Ready, In progress, Completed and Blocked independently of provider process state.
|
|
451
|
-
|
|
452
|
-
coordination.json has a hard size and record bound and rejects growth beyond it without discarding evidence.
|
|
453
|
-
|
|
454
|
-
## Task collaboration
|
|
455
|
-
|
|
456
|
-
Use `{ kind: 'collaboration', actor, command }` through `hq.request`, `requestAgentHq`, or the CLI's JSON `request` command. The response is `{ kind: 'collaboration', result }`. These are trusted same-user host/IPC operations. Applications authenticate operators and supply `{ kind: 'host', operatorRef }`; HQ compares that reference with the task owner. A host acting for a managed agent supplies `{ kind: 'agent', agentId }`. This actor field is not an authentication mechanism for an untrusted client. Agent IDs are immutable managed-thread UUIDs, separate from provider/native IDs and display names.
|
|
457
|
-
|
|
458
|
-
Every mutation has an `id` UUID. Creation uses that same UUID for the new task, stream, grant or message/request. Mutations return `{ kind: 'operation', operation }`, retaining the normalized command digest, actor, task, command kind and exact original result. Repeating the same identity and command returns that receipt; changing its payload conflicts. `operation-read` selects a receipt without replaying the effect. Reads return their selected result directly. Current membership/owner checks apply to replays and selected reads.
|
|
459
|
-
|
|
460
|
-
`task-create` requires `workspaceRoot`, `title`, `policy` and nullable `plan`. The policy specifies `providers`, `workspaceRoots`, `effects`, `canSpawn`, `canManagePeerSubscriptions`, `canExecuteRequests`, `automaticDispatch`, positive `concurrencyLimit`, nonnegative `spawnLimit` and `automaticTurnLimit`. No execution limits are inferred from a role. The policy must include the task workspace. Workspace roots and plan directories resolve through the runtime's allowed roots; metadata path prefixes are normalized relative paths, with `''` selecting a whole workspace. References identify evidence and do not grant filesystem access.
|
|
382
|
+
Every Codex usage read requests current native observations. A Claude usage read is answered by the previous read's result, without asking Claude, until 60 seconds after that read finished; the freshness rules above still apply to it. An auth notification, a rate-limit event or a closed connection ends that minute early, and one that arrives during a read keeps its result from answering later reads. Otherwise the last successful snapshot is retained only to explain freshness after a failure. Multiple simultaneous reads share one pending refresh.
|
|
461
383
|
|
|
462
|
-
|
|
384
|
+
## Machine locks
|
|
463
385
|
|
|
464
|
-
|
|
465
|
-
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
466
|
-
| `task-read`, `task-policy-set`, `task-plan-set`, `task-state-set` | Setters are owner-only and require `expectedRevision` plus `policy`, nullable `plan`, or `state`. Policy/plan share `policyRevision`; lifecycle uses `lifecycleRevision`. Active, paused and stopped states remain separate from native session state. |
|
|
467
|
-
| `tasks-list` | Uses `workspaceRoot` instead of `taskId`; returns only the host owner's tasks. |
|
|
468
|
-
| `agent-add`, `agent-read`, `agents-list`, `agent-policy-set`, `agent-state-set`, `agent-revoke` | Membership changes are owner-only. Add selects an existing `agentId`, nullable `parentAgentId`, nullable `role`, and `permissions`. Provider/workspace come from the managed thread. Set/revoke require current `expectedRevision`; reinstating a revoked membership also requires it. Child permissions cannot exceed their parent's current effective permissions when added or changed. |
|
|
469
|
-
| `grant-issue`, `grant-read`, `grants-list`, `grant-revoke` | Owner-only issue/revoke; read selects `grantId`, revoke also requires `expectedRevision`. Issue fields are nullable `eligibleAgentIds` (null means task-wide), exact `skills: [{name, mode}]`, `effects`, `scopes: [{workspaceRoot, pathPrefixes}]` and nullable `plan`. Grants start at revision 1; revocation increments revision. |
|
|
470
|
-
| `stream-create`, `stream-read`, `streams-list`, `stream-archive` | Create supplies `title`/`purpose`. Read/archive select `streamId`; archive supplies `isArchived` and requires the host owner or creating agent. List optionally filters `isArchived` or the calling agent's `subscribed: true` streams. Archiving preserves history and outstanding requests. |
|
|
471
|
-
| `subscription-set`, `subscription-read`, `subscription-advance` | Set/read select `streamId` and `agentId`. Set supplies `isActive`, `notify`, and optional `historyLimit` from 1 to 128 when joining. Agents manage themselves or peers only with current peer-management permission; the host owner can manage either. New subscriptions start at the stream's current boundary. Explicit historical notification is bounded. Advance selects `streamId` and monotonic `throughSequence` for the calling agent. Unsubscribe preserves existing assignments and delivery records. |
|
|
472
|
-
| `message-publish`, `messages-list`, `messages-search`, `message-read`, `message-ack` | Publication fields are described below. List/search optionally select `streamId`; search requires a literal nonempty `query`. Selected read/ack use `messageId`. Only a delivery recipient can acknowledge. |
|
|
473
|
-
| `request-read`, `requests-list`, `request-claim`, `request-resolve`, `request-cancel`, `request-reassign` | Selected operations use `requestId`. List optionally filters `agentId` (target or assignee) and `state`. Claim requires an eligible active agent; claimable work additionally requires an active stream subscription. Resolve requires an assigned, non-dispatched request, `outcome: 'completed' \| 'failed'` and 1–16 evidence `references`. Cancellation is available to the requester, assignee or owner. Reassign is requester/owner-only and requires `expectedAssigneeAgentId` plus `targetAgentId`; it requires no active or uncertain dispatch. Canceling dispatched work retains its binding until terminal collection and requests interruption of the exact native turn. |
|
|
474
|
-
| `deliveries-list`, `status`, `fanout-recover`, `operation-read` | Delivery list optionally selects `recipientAgentId` and `state: 'unacknowledged' \| 'undelivered' \| 'all'`, defaulting to unacknowledged; agents can read only their own deliveries. Status reports capped counts and `hasMore`, including undelivered and unacknowledged counts, current revisions and background fan-out/dispatch failure. Owner-only recovery schedules another bounded pass. Receipt read selects `operationId`, returning null when absent. |
|
|
386
|
+
`{ kind: 'locks' }` lists the named locks that scripts, agents and apps on this machine take through [jg-locks](https://jg-packages.jesusgraterol.dev/packages/jg-locks/), as jg-locks' `listLocks()` returns them: `{ data, isTruncated }`, at most 256 present locks sorted by name, with `isTruncated` when more exist. Each lock is `{ name, state, owner, isOwnerAlive }`, mirroring jg-locks' `ILockState`, and `LockStateSchema` and `LocksSchema` validate them. `state` is `held`, `owner-gone`, `ownerless`, `other-host`, `recovery-in-progress` or `unexpected-entries`, since free locks aren't listed. `owner` is `{ pid, nonce, hostname, program, cwd, startedAt, metadata }`, or null when its owner.json can't be read, and `isOwnerAlive` is null when there is no owner or it runs on another host.
|
|
475
387
|
|
|
476
|
-
|
|
388
|
+
The locks folder is `JG_LOCKS_ROOT` when it is set in the runtime's environment, otherwise jg-locks' default state folder, such as `~/.local/state/jg-locks` on Linux. A folder that doesn't exist yet holds no locks, and the read never creates it. HQ only reads this folder: it never takes, waits for, releases or recovers a lock there, so recover a dead holder with `jg-locks recover <name> --nonce <nonce>`. HQ's own `.runtime/hq.lock`, under [lock lifecycle](#lock-lifecycle), is separate. A `JG_LOCKS_ROOT` that isn't an absolute path fails with jg-locks' `LOCK_ROOT_INVALID`.
|
|
477
389
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
A request publication supplies exactly one assignment mode: a `targetAgentId` with `claimable: false`, or null with `claimable: true`. Its other fields are nullable `skill: {name, mode}`, nullable `grantId`/`grantRevision`, bounded `arguments`, `effects`, `scopes`, nullable `plan`, `targetReferences` and optional `returnStreamId`. A selected skill requires an exact unrevoked grant revision. Publication and claim check current policy and scopes; claim also checks the receiving agent's eligibility. Requests without a skill require no invented skill grant. `jg-execute` auto requests must explicitly cover commit and push effects. Grants do not replace workflow approval, native permissions or actual dispatch admission.
|
|
481
|
-
|
|
482
|
-
Artifact references select a report ID/hash, repository path with commit/hash and optional line range, native provider/session/turn/item/hash, or exact plan revision/milestone. Selected `message-read` returns the exact body and a bounded reference page, with byte/reference offsets and optional continuation. Collaboration responses fit within 65,536 serialized bytes; commands leave room inside the existing 65,536-byte IPC request envelope. Oversized input fails without partial publication.
|
|
483
|
-
|
|
484
|
-
Broadcast notifications do not assign each subscriber work. Notification intent, native delivery (`nativeActionId`/`deliveredAt`), explicit `acknowledgedAt`, subscription read position, request claim and resolution remain independent. Information, reads and acknowledgements do not submit native input. Authorized directed request intent can wake the separate dispatcher. Directed intent persists even for an unsubscribed recipient. Subscriber fan-out runs in batches of at most 32 with transactionally retained progress; restart resumes it. A failed batch leaves durable intent and exposes `JG_AGENT_HQ_STORE_FAILED` in `status.fanoutFailure` until explicit recovery or runtime restart. The host owner can inspect all task metadata; revoked members cannot read or replay operations. Paused participants retain historical reads, while fresh claims require active task/member state.
|
|
485
|
-
|
|
486
|
-
Authorization failures use `JG_AGENT_HQ_COLLABORATION_FORBIDDEN`; conflicting command identities, assignments, lifecycle revisions and terminal transitions use `JG_AGENT_HQ_COLLABORATION_CONFLICT`. IPC maps these to the existing safe access-denied/state-conflict errors. Native execution and plan approval remain separate contracts.
|
|
487
|
-
|
|
488
|
-
### Directed requests and exact reports
|
|
489
|
-
|
|
490
|
-
An idle directed recipient runs when `policy.automaticDispatch` is enabled, or when the owner commits `request-dispatch` with `requestId`. A claimed request is eligible through its one assignee. Busy requests retain `pendingActionId` and a visible `dispatchBlockedReason`; HQ submits at a safe native boundary. Admission atomically reserves one active dispatch per agent across tasks, task concurrency and one cumulative `automaticTurnCount` for an automatic attempt. Explicit host dispatch/input/resumption does not consume that automatic budget. Already admitted failed or uncertain attempts retain their consumed count. No timer or model turn polls for work.
|
|
491
|
-
|
|
492
|
-
Each dispatch uses the existing native action ledger and an immutable selected invocation context. `currentActionId` stays held through terminal outcome collection, so ordinary queued input cannot run ahead of it. `lastActionId`, `lastReportId`, `dispatchCount`, `requiredAuthority`, `failureReason` and blocked reasons remain inspectable on the request. Known ownership, exact assignment, current task/member policy, selected grant revision and plan authority are checked again before native submission. Read-only plan assessment verifies the selected ID/revision without replacing the recipient's implementation binding. Writable planned work requires the existing exact approved native plan scope. Requests do not approve a plan or answer native permissions.
|
|
493
|
-
|
|
494
|
-
The native response is a closed object:
|
|
495
|
-
|
|
496
|
-
```ts
|
|
497
|
-
{
|
|
498
|
-
requestId: string | null;
|
|
499
|
-
outcome: 'completed' | 'waiting-children' | 'needs-input' | 'paused' | 'failed';
|
|
500
|
-
childRequestIds: string[];
|
|
501
|
-
report: string;
|
|
502
|
-
requiredAuthority: 'requester' | 'operator' | null;
|
|
503
|
-
}
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
Delegated work uses the exact request UUID. Only needs-input specifies `requiredAuthority`; other outcomes use null. Only waiting-children specifies a nonempty unique `childRequestIds` array; other outcomes use an empty array. The normal Markdown report stays inside `report`. HQ validates the envelope against the exact native action, assignee, provider, session and turn, without another model. Completed means the assignee claims completion. It is not approval or acceptance. Failed assignee reports remain exact evidence. Missing, malformed, wrongly bound or oversized output produces a labeled runtime failure, never a manufactured agent report. Native interruption retains interrupted state; uncertain native delivery retains the unresolved binding and never automatically resends.
|
|
507
|
-
|
|
508
|
-
The shared native schema omits an external dialect reference because the qualified Claude CLI rejects that reference during initialization. Codex selects this schema per turn. Claude installs it through one confirmed idle process restart, retaining native identity, instructions, permission settings, model and effort. An empty session reuses its same session ID; a session with input resumes its existing history. No global native configuration changes. Subsequent ordinary Claude conversations return `requestId: null` and HQ unwraps their report into the normal text result. Explicit unrelated output schemas retain their normal native selection contract.
|
|
509
|
-
|
|
510
|
-
| Command | Required selection and behavior |
|
|
511
|
-
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
512
|
-
| `request-dispatch` | Owner-only `requestId`; explicitly schedules eligible pending work even when automatic dispatch is disabled. |
|
|
513
|
-
| `request-input` | `requestId`, exact `expectedActionId` and bounded `body`. Only the owner or the recorded requester may answer a requester checkpoint; operator checkpoints require the owner. The linked immutable input message reserves one next action. Agent answers require active membership and normal automatic policy/limits. |
|
|
514
|
-
| `request-resume` | Owner-only `requestId`, `expectedActionId`, current `expectedAgentRevision`, current `expectedTaskRevision` and `body`. Resumes interrupted work or reactivates a paused parent wait under current authority, preserving its continuation reservation; a paused task must first be activated explicitly. |
|
|
515
|
-
| `request-authorize` | Owner-only `requestId`, nullable exact `expectedActionId`, nullable `grantId`/`grantRevision` and nullable `plan`. Refreshes the selected authority at an input/interruption/child-wait checkpoint, or before the first queued attempt. Null action selects work with no prior attempt. Skill, mode, effects, arguments and scopes stay selected; this command grants no plan approval. |
|
|
516
|
-
| `request-collect` | Owner-only `requestId` and `actionId`; selects already saved native evidence. Returns the immutable collection or null while evidence is unsettled. It accepts no model-provided completion text and never submits input. |
|
|
517
|
-
| `invocation-read` | Agent-only `taskId`; returns the one active verified invocation or null. It includes selected request scope, action/turn binding, compact grant issuer/revision, immutable parent/return route, bounded child-wait state, continuation generation/result references and linked input identity/author. Read request and input message bodies separately. |
|
|
518
|
-
| `report-read` | `reportId` and optional `cursor`, scoped by `taskId`. Returns metadata, exact UTF-8 `text`, `offsetBytes`, `isComplete` and `nextCursor`. |
|
|
519
|
-
|
|
520
|
-
Collection atomically commits the request transition, exact report, bounded reply, return delivery intent and immutable receipt. Repeated collection returns the original receipt. A canceled request keeps its canceled state if terminal evidence arrives later. Explicit idle ownership recovery or reattachment (`thread-recover` or `thread-resume`) may close canceled uncertain work, recording `recoveryActionId`; the native receipt remains uncertain. Reports and replies remain readable after task pause or grant revocation, subject to current task visibility. Runtime diagnostics use a runtime author. Native input acceptance sets `nativeActionId`/`deliveredAt`; it neither acknowledges a message nor resolves its request.
|
|
521
|
-
|
|
522
|
-
Reports have a fixed 1,048,576 UTF-8 byte ceiling. HQ rejects malformed UTF-16 or oversize output rather than replacing characters or storing a truncated report. Metadata records immutable report/request/action/reply IDs, server-derived agent author, native provenance, byte count and SHA-256. Replies carry a labeled excerpt and report ID/hash. `report-read` uses bounded database substring reads with an actor/task/report/hash-bound cursor, keeping the entire response within 65,536 serialized bytes. Native history availability does not affect these reads.
|
|
523
|
-
|
|
524
|
-
`messages-search` merges bounded message and report FTS5 seeks in deterministic message sequence order. A report hit returns its associated reply and optional `reportMatch: {reportId, sha256, excerpt}`. Searches do not load full report bodies into Node or scan all reports; SQLite generates excerpts only for selected fixed-capacity indexed hits. There is no report cache, transcript mirror or general artifact subsystem. `status.dispatchFailure` exposes a failed recovery pass; owner `fanout-recover` also schedules dispatch recovery.
|
|
525
|
-
|
|
526
|
-
### Parent waits and continuations
|
|
527
|
-
|
|
528
|
-
A delegated `message-publish` supplies `parentRequestId` matching the publishing agent's active assigned invocation in the same task. HQ records that parent and its exact native action immutably. Child effects, paths and plan scope cannot exceed the active parent selection; recipient task permissions and selected skill grants are checked separately. Root publications omit this field. A host or an unrelated invocation cannot forge a child relationship.
|
|
529
|
-
|
|
530
|
-
A waiting-children envelope names 1–32 unique direct children and retains every still-incomplete child from the recorded wait. HQ stores `childRequestIds`, an incremented `waitGeneration` and one `continuationActionId` on the parent. It releases native-turn capacity while preserving the assignee, incomplete request and plan binding. Registering a wait and collecting a child result check readiness in the same SQLite transaction. An early result cannot be lost. Resolved success, resolved failure and cancellation satisfy terminal waits; interruption and input questions do not. Reporting completed while a direct child remains unfinished produces `children-pending`, with a failed runtime outcome rather than parent completion. Invalid wait relationships produce `invalid-child-wait`.
|
|
531
|
-
|
|
532
|
-
All terminal children, or an unconsumed requester clarification from a named child, can reserve one next native action for that generation. The existing action ledger owns admission, busy queueing, uncertainty and replay. Continuation packets carry bounded child states, action/report IDs and hashes, and short excerpts; full payloads use `hq_report_read`. Native acceptance marks only the included report deliveries and clarification triggers as delivered/consumed. Later questions remain pending for the next wait generation. An agent may answer its direct child's requester checkpoint with `hq_request_input` and yield again. Operator-only questions require the host and never wake a parent to supply approval.
|
|
533
|
-
|
|
534
|
-
The parent retains its scope and rechecks current lifecycle, grants, plan revision and resource limits at admission. Paused, interrupted, revoked, canceled or resolved parents do not restart from child traffic. Current host authorization/resumption may unblock a saved wait; it does not replace an uncertain action. Restart recovers recorded wait conditions and reservations without starting a native controller. Explicit native reattachment remains necessary after shutdown. Ending a parent does not cancel its children, and late reports remain readable. Continuation acceptance, acknowledgement and replies never become new child-result triggers. `hq_identity.waiting` returns at most 32 authorized wait summaries plus `hasMore`; use bounded `hq_requests_list` for further inspection.
|
|
535
|
-
|
|
536
|
-
Native qualification on 2026-10-23 exercised complete Codex-to-Claude, Claude-to-Codex and Codex-to-Codex parent/child journeys without skills. Each child completed once; each parent yielded and completed on its second turn. Reports were checked byte-for-byte and by SHA-256. Native tool permissions were answered only for the selected HQ task operations.
|
|
537
|
-
|
|
538
|
-
## Agent tools
|
|
539
|
-
|
|
540
|
-
Controlled sessions receive the same closed tools through provider-bound Codex dynamic callbacks or Claude's session-specific stdio MCP configuration. `operations.agentTools` reports availability separately from other controls. Codex dynamic tools are experimental. New HQ-created sessions declare them at `thread/start`; the native resume/fork interfaces retain their own tool configuration. An adopted or reconnected Codex session without observed registration reports unknown support until a native callback establishes it. No version label controls this decision. Claude adds one server using `--mcp-config`, preserving normal settings and other configured servers. Native permission prompts still require explicit replies.
|
|
541
|
-
|
|
542
|
-
`hq_identity({taskId?, limit?, cursor?})` returns `{identity, pending}`. Identity contains the immutable managed `agentId`, provider/native ID, runtime epoch, workspace, bounded task summaries, selected task, membership (including parent/role), child purpose and effective permissions. The compact `invocation` identifies active assigned work and its blocked reason. Active invocation selects its task by default; otherwise identity selects an unambiguous single membership; otherwise the caller selects an authorized `taskId`. The selector grants nothing. Pending work uses the task status counts. Identity is reconstructed from current durable records after compaction and explicit resume, without injecting stream history.
|
|
543
|
-
|
|
544
|
-
| Tools | Inputs and results |
|
|
545
|
-
| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
546
|
-
| `hq_agents_list`, `hq_streams_list`, `hq_stream_create`, `hq_subscription_set` | The corresponding collaboration command fields without `kind` or an actor. |
|
|
547
|
-
| `hq_messages_list`, `hq_messages_search`, `hq_message_read`, `hq_message_publish`, `hq_message_ack` | The corresponding bounded collaboration command fields; HQ supplies the author. |
|
|
548
|
-
| `hq_request_read`, `hq_requests_list`, `hq_request_claim`, `hq_request_resolve` | Current request relationships/waits and explicit non-dispatched resolution. |
|
|
549
|
-
| `hq_invocation_read`, `hq_report_read`, `hq_request_input` | Verified invocation, exact report chunks and linked requester input through the corresponding collaboration commands. |
|
|
550
|
-
| `hq_deliveries_list` | `taskId`, optional `limit` and `cursor`; returns only the calling agent's unacknowledged inbox. |
|
|
551
|
-
| `hq_sessions_list`, `hq_session_evidence_read` | The corresponding native read fields plus `taskId`, checked against effective read/provider/workspace permissions. |
|
|
552
|
-
| `hq_agent_spawn` | `id`, `taskId`, explicit `provider`, `workspaceRoot` and a nonempty bounded `purpose`; returns `{taskId, agentId, receipt}` from the native action ledger. |
|
|
553
|
-
|
|
554
|
-
Native connection identity or an opaque bridge credential supplies the sender. No tool accepts an authoritative actor, runtime epoch or sender ID, issues host grants, approves a plan, expands directories or changes native permissions. Each call checks current membership and policy. During an active dispatch, non-identity tools also recheck its selected grant and scope. Session reads and spawning cannot expand its selected workspace access. Tool arguments are closed schemas; safe results contain one text block with exact bounded JSON and `isError`. Core payloads fit within 65,536 serialized bytes, and native text wrappers account separately for JSON escaping. Calls are bounded to 32 outstanding operations and a 30-second gateway deadline; cancellation never proves an admitted native effect failed.
|
|
555
|
-
|
|
556
|
-
Spawn capacity is reserved transactionally with the new managed thread, parent link and copied effective task permissions, narrowed to the parent's active invocation when present. The task's `spawnCount` is cumulative and cannot exceed `policy.spawnLimit`. A rejected admission consumes no slot; an admitted failed or uncertain native creation retains its reservation. Reuse the same `id` and arguments to inspect that receipt. HQ never resends an uncertain creation. A new child has a distinct managed ID and no inherited plan approval or exact-agent skill eligibility. Either provider may create either provider. Native subagent calls resolve to their owner unless native lineage proves an independent managed binding; a shared MCP credential cannot distinguish native children.
|
|
557
|
-
|
|
558
|
-
The stdio entry is `jg-agent-hq agent-bridge`. Its only credential input is `JG_AGENT_HQ_BRIDGE_FILE`, a private short-lived file path supplied in the session MCP environment. The opaque token stays out of argv, prompts, SQLite, native configuration and snapshots. Files are 0600 under an owned 0700 system temporary directory, revoked and removed when their session closes, and rotated on reconnect/runtime restart. Runtime shutdown drains tool calls and removes its files/directory. The installed `@modelcontextprotocol/server` owns stdio framing, cancellation and negotiation. Stdout is protocol-only. Trusted factory contexts receive `IProviderAgentTools`, with JSON descriptors, a provider-bound callback and a revocable MCP lease; the Node package exports its descriptor/lease types.
|
|
559
|
-
|
|
560
|
-
Native qualification on 2026-10-23 used Codex 0.164.0 and Claude Code 2.1.309. Each called `hq_identity` and created an authorized child with the other provider through `hq_agent_spawn`; HQ confirmed the native creation receipts and parent memberships. Both then resumed their same managed/native identities after runtime restart, compacted, and called `hq_identity` again with the new runtime epoch, confirmed through native tool evidence. Claude's tool permissions received explicit per-call replies. Owned controllers, bridges and credential files shut down cleanly. These observations qualify those paths on this host; version labels remain diagnostics.
|
|
561
|
-
|
|
562
|
-
Directed-request qualification on 2026-10-23 used Codex 0.164.0 and Claude Code 2.1.309. Each called `hq_invocation_read` under its selected request, completed in one native turn, and returned an exact report retained by HQ. Native tool evidence confirmed the request/action binding; Claude's read-only MCP permission received an explicit reply. Report reads survived controller shutdown/restart without another model turn. The shared envelope uses no external schema-dialect reference; native version labels remain diagnostic.
|
|
563
|
-
|
|
564
|
-
## Native skill delegation
|
|
565
|
-
|
|
566
|
-
A directed request may select an installed native skill by exact name, mode and current host-issued grant. HQ reads the recipient's native catalog and formats the invocation through that provider. Codex receives its native skill name/path selection; Claude receives its native slash invocation. Missing, disabled, ambiguous or unreadable metadata produces a retained skill-unavailable dispatch reason without sending plain text instead. Reload or repair the native catalog, then explicitly retry dispatch or allow an authorized recovery event. HQ never reads or rewrites skill instructions.
|
|
567
|
-
|
|
568
|
-
The immutable action command binds the coordination packet, while private preparation adds native skill presentation. Full arguments and mode come from the verified request, rather than being copied into each continuation. The session-bound hq_invocation_read returns the exact task, request, assignee, action, selected grant and current scope/plan/lifecycle. Verify it before acting. Native user-role framing, environment variables, quoted feedback and pasted grant IDs prove no operator authority.
|
|
569
|
-
|
|
570
|
-
| Workflow need | HQ mapping |
|
|
571
|
-
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
572
|
-
| Verify delegated entry and mode | hq_invocation_read; use request.specification and the selected grant, not packet claims. |
|
|
573
|
-
| Read exact session evidence | hq_sessions_list and hq_session_evidence_read with authorized references, bounded pages/chunks and provenance. Denial never permits raw-history fallback. |
|
|
574
|
-
| Read review findings | hq_message_read or hq_report_read for the exact authorized reference; report hashes bind content. |
|
|
575
|
-
| Finish a read-only assessment | Return the native structured envelope. HQ stores/transports the report without a mutating tool or another inference turn. |
|
|
576
|
-
| Wait for child work | Return waiting-children with unique direct childRequestIds; continuation carries bounded states and report references. |
|
|
577
|
-
| Require selection/approval | Return needs-input with requiredAuthority operator; requester is for ordinary clarification only. |
|
|
578
|
-
| Pause/resume | Return paused under a pause grant. The host explicitly resumes against current lifecycle revisions; child results and earlier grants cannot resume it. |
|
|
390
|
+
## CLI
|
|
579
391
|
|
|
580
|
-
|
|
392
|
+
`jg-agent-hq serve --state-root <directory> --workspace-root <directory>` starts the host. Repeat `--workspace-root` to authorize several roots. Client commands use `--state-root`; history commands also use one `--workspace-root` and, where required, `--native-id`. History and usage accept `--provider codex|claude` (default `codex`). Paged commands support `--limit` and `--cursor`; items support `--turn-id`; thread discovery supports `--search`. CLI paths resolve from the caller's working directory. There are no shell commands or raw native RPC passthroughs.
|
|
581
393
|
|
|
582
|
-
|
|
394
|
+
Output is one JSON line with `schemaVersion: 1`. Read output includes the command `kind` and `result`. Startup reports `kind: ready`. Confirmed shutdown reports `kind: stop` with `result.state: stopped`. Failure output goes to stderr with a safe error kind/message and exit status 1. The CLI never prints diagnostic causes or native payloads in an error response.
|
|
583
395
|
|
|
584
|
-
|
|
396
|
+
`jg-agent-hq session-states --state-root <directory> [--after-sequence <sequence>] [--limit <1..128>]` reads one page of session state transitions. `jg-agent-hq active-sessions --state-root <directory>` reads the active sessions, `jg-agent-hq unstarted-threads --state-root <directory> --workspace-root <path> [--provider <provider-id>]` reads the unstarted threads, `jg-agent-hq observation-pace --state-root <directory> --pace live|background` sets the Claude poll's pace, and `jg-agent-hq locks --state-root <directory>` lists the machine locks.
|
|
585
397
|
|
|
586
|
-
|
|
398
|
+
`jg-agent-hq request --state-root <directory>` reads one complete HQ request from stdin, validates it, and prints the usual response. It accepts no extra target flags. This exposes action and reconnect operations, such as `action-wait`, without putting message text or question answers in command-line arguments. Its `stop` response acknowledges admission; use the dedicated `stop` command for confirmed shutdown.
|
|
587
399
|
|
|
588
400
|
## Browser host integration
|
|
589
401
|
|
|
590
|
-
`jg-agent-hq/contracts` exports closed `BrowserActionSchema`, `BrowserCommandSchema` and `BrowserReceiptSchema` contracts, plus `BrowserThreadDetailSchema`, a bounded view of one managed thread with its
|
|
402
|
+
`jg-agent-hq/contracts` exports closed `BrowserActionSchema`, `BrowserCommandSchema` and `BrowserReceiptSchema` contracts, plus `BrowserThreadDetailSchema`, a bounded view of one managed thread with its pending approvals, live items and recent actions. These schemas contain generic identities, not a deployment registry or private handler implementation. They do not expose native RPC, executables or provider configuration. Standalone IPC continues to support only its existing owned commands.
|
|
591
403
|
|
|
592
|
-
A trusted Node host calls `runtime.performBrowserAction(request, operatorId, execute)` after validating its signed operator identity. The host supplies one dispatcher function in process. It must validate every target against its registry, check operation-specific revisions/turns, and normalize approval provenance to that authenticated operator. Never accept a callback, operator identity or handler name from HTTP input. The request has a stable UUID, current runtime epoch and one closed command: native
|
|
404
|
+
A trusted Node host calls `runtime.performBrowserAction(request, operatorId, execute)` after validating its signed operator identity. The host supplies one dispatcher function in process. It must validate every target against its registry, check operation-specific revisions/turns, and normalize approval provenance to that authenticated operator. Never accept a callback, operator identity or handler name from HTTP input. The request has a stable UUID, current runtime epoch and one closed command: native. The complete serialized request is limited to 2 MiB; nested native commands retain their tighter limits.
|
|
593
405
|
|
|
594
406
|
SQLite records an HMAC digest and receipt before invoking the dispatcher. The same UUID and identical normalized request returns the stored receipt without invoking it again. Changed payloads or operators conflict. New requests require the current epoch. Replaying a saved request after restart reconciles it without granting execution authority. Submitted receipts from another runtime become uncertain. Dispatcher failure also leaves the receipt uncertain because its effects may already have committed. This state never automatically resends an effect.
|
|
595
407
|
|
|
@@ -597,23 +409,19 @@ The dispatcher receives a server-owned `nativeActionId`; use this ID for a nativ
|
|
|
597
409
|
|
|
598
410
|
Live reads accept `afterRevision`. A matching revision returns `unchanged: true` with an empty data array; retain the displayed window. A changed revision returns the complete bounded window. Revisions belong to one runtime. After reconnect to a new runtime, discard the revision and refresh native history. Token bodies stay in the existing bounded memory window and are never copied into lifecycle or browser-action tables.
|
|
599
411
|
|
|
600
|
-
`thread-plan` accepts a managed `threadId` and returns its nullable `ActionPlanContextSchema`. The host verifies the thread's registered checkout before exposing it. It is read-only and grants no execution authority.
|
|
601
|
-
|
|
602
412
|
## Qualification
|
|
603
413
|
|
|
604
414
|
The operation matrix describes the implemented native interfaces and their explicit unavailable surfaces. Executed qualification is narrower than every possible model, configuration and account state. Native versions below are observations, never admission rules.
|
|
605
415
|
|
|
606
|
-
| Area | Executed evidence
|
|
607
|
-
| ------------------------------- |
|
|
608
|
-
| Provider integration | Public contract tests route a third provider, isolate unavailable providers and tolerate additive fields and future version labels. Native lifecycle, configuration, files, account and extension checks are listed in their sections above.
|
|
609
|
-
|
|
|
610
|
-
|
|
|
611
|
-
|
|
|
612
|
-
|
|
|
613
|
-
|
|
|
614
|
-
| Claude active sessions | Claude Code 2.1.310 answered `claude agents --json` in 0.16 s. Interactive entries carry `status` (`busy`, `waiting`, `idle`) and `pid`; background entries carry `id` and `state` (`blocked`). Sessions HQ starts in structured mode are listed as interactive under their HQ name and disappear after close. | The list describes running processes only; history still comes from transcripts. |
|
|
615
|
-
| Host coverage | Linux x86_64 package checks passed on Node 24.15.0 and 24.22.1. Integrated delegation ran on the floor; identity, native interaction and recovery also ran on 24.22.1. | No macOS host was available for this run. Windows is outside the declared host contract. |
|
|
416
|
+
| Area | Executed evidence | Boundary |
|
|
417
|
+
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
418
|
+
| Provider integration | Public contract tests route a third provider, isolate unavailable providers and tolerate additive fields and future version labels. Native lifecycle, configuration, files, account and extension checks are listed in their sections above. | Each additional adapter needs its own native qualification. |
|
|
419
|
+
| Identity and native interaction | Both providers retained managed/native identities after compaction and reconnect with a fresh runtime epoch. Codex interruption and continuation passed. Claude AskUserQuestion and scoped MCP permission replies used exact native identities. | A timed-out compaction retained uncertain delivery even when completion later arrived; it was not resent. Explicit resume followed confirmed controller shutdown. |
|
|
420
|
+
| Recovery | After removing all eight qualification transcripts, offline recovery retained the host preference and providers stayed idle. | Native transcripts, repository files and authentication remain separate recovery responsibilities. |
|
|
421
|
+
| Shared Codex daemon | Codex 0.164.0: a terminal `codex` session ran on the shared daemon and appeared in `thread/list`. Without subscribing, HQ saw its `thread/status/changed`; after rejoining with `thread/resume`, HQ received the terminal's live turn and item notifications. A thread HQ created appeared in the terminal's `codex resume` picker, and closing HQ's connection left the daemon and the terminal session running. The daemon confirmed HQ's interrupt and close. Per-thread skill roots and output schemas worked on HQ threads, while another client's catalog and thread never saw the roots. Sessions read their own thread ID from `CODEX_THREAD_ID`. | A terminal started with `-c` overrides runs its thread in its own process (`source: cli`): it is listed, but a second writer is refused, so it cannot be followed live. The restart check ran against a separate app-server on its own socket rather than the shared daemon, which was serving other work: within one keepalive interval the session became uncertain and nothing was resent. A session Codex reloads from disk loses its capability roots. |
|
|
422
|
+
| Claude active sessions | Claude Code 2.1.310 answered `claude agents --json` in 0.16 s. Interactive entries carry `status` (`busy`, `waiting`, `idle`) and `pid`; background entries carry `id` and `state` (`blocked`). Sessions HQ starts in structured mode are listed as interactive under their HQ name and disappear after close. | The list describes running processes only; history still comes from transcripts. |
|
|
423
|
+
| Host coverage | Linux x86_64 package checks passed on Node 24.15.0 and 24.22.1. Identity, native interaction and recovery ran on the floor and on 24.22.1. | No macOS host was available for this run. Windows is outside the declared host contract. |
|
|
616
424
|
|
|
617
|
-
The
|
|
425
|
+
The identity and recovery checks used gpt-6.1-sol with medium effort and claude-opus-5-5 with medium effort in disposable workspaces on 2026-10-23. The shared-daemon and Claude active-session checks ran on 2026-10-25 with the installed CLIs' default models in disposable workspaces. The [Node release index](https://nodejs.org/dist/index.json) identified 24.22.1 as the current LTS patch at qualification time. Local checks do not establish a published npm release or a deployed website.
|
|
618
426
|
|
|
619
|
-
Native model/output budgets also bound structured results. A generation that ends with incomplete JSON remains failed
|
|
427
|
+
Native model/output budgets also bound structured results. A generation that ends with incomplete JSON remains failed; its bounded native result stays on the action receipt. Claude output schemas belong to session startup or explicit idle resume, as described in the configuration contract. Its unavailable steering, archive/revert, resource catalog and interactive authentication surfaces remain explicit in the operation matrix.
|