jg-agent-hq 13.5.6 → 13.5.8
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 +8 -0
- package/README.md +25 -142
- package/api/README.md +55 -1
- package/dist/providers/codex/transformers.js +4 -5
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 13.5.8
|
|
4
|
+
|
|
5
|
+
- Keep informational Codex messages in the transcript and out of question observers when their async delivery carries no questions. Preserve validation for question bundles.
|
|
6
|
+
|
|
7
|
+
## 13.5.7 — documentation navigation
|
|
8
|
+
|
|
9
|
+
- Keep the package overview concise and route setup, runtime ownership and delivery details to their canonical guides. Runtime behavior and public APIs are unchanged.
|
|
10
|
+
|
|
3
11
|
## 13.5.6
|
|
4
12
|
|
|
5
13
|
- Forward creation model, reasoning effort, Fast mode and output schema to the session's first turn for Codex and Claude. Keep startup-only settings on session creation, and preserve the same action identity and input admission checks.
|
package/README.md
CHANGED
|
@@ -1,156 +1,39 @@
|
|
|
1
1
|
# jg-agent-hq
|
|
2
2
|
|
|
3
|
-
A TypeScript library and local controller for applications that run
|
|
3
|
+
A TypeScript library and local controller for applications that run native Claude Code and Codex sessions. It owns local session control, prompts, results and recoverable storage through one API. Your application owns its interface, authentication and off-machine backups; the native CLIs supply their harnesses, tools, skills and sign-in.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Requires Node.js 24.15.0 or later on Linux or macOS. State safety relies on POSIX ownership and private directories. Windows is outside the supported host contract.
|
|
5
|
+
Requires Node.js 24.15.0 or later on Linux or macOS. State safety relies on POSIX ownership and private directories; Windows is outside the supported host contract.
|
|
8
6
|
|
|
9
7
|
## Installation
|
|
10
8
|
|
|
11
|
-
Install the package locally:
|
|
12
|
-
|
|
13
9
|
```sh
|
|
14
10
|
npm install jg-agent-hq
|
|
15
11
|
npx jg-agent-hq serve --state-root .runtime --workspace-root .
|
|
16
12
|
```
|
|
17
13
|
|
|
18
|
-
Install
|
|
19
|
-
|
|
20
|
-
This public package provides a local controller and browser-safe contracts. Applications own their UI, authentication and deployment. It does not include a hosted app or a user interface.
|
|
21
|
-
|
|
22
|
-
## Development
|
|
23
|
-
|
|
24
|
-
Use pnpm 12.4.0. Run `pnpm install --frozen-lockfile`, then `pnpm check:package` to build, exercise the built API and packed consumer, typecheck and check formatting. `pnpm test:unit` and `pnpm test:integration` select their own categories after a build. The private website workspace has separate checks; install Chromium with `pnpm --dir website exec playwright install chromium`, then run `pnpm --dir website check`. `pnpm check` runs both boundaries.
|
|
25
|
-
|
|
26
|
-
Work on `development`; reviewed changes reach `main` through a pull request. After both Node checks pass on `main`, `check.yml` publishes the exact consumer-tested tarball through npm's configured trusted publisher, then deploys the website. No local npm login or token is needed. An identical published version is skipped; changed contents require a new version.
|
|
27
|
-
|
|
28
|
-
[testing-commands:start]: #
|
|
29
|
-
|
|
30
|
-
## Testing
|
|
31
|
-
|
|
32
|
-
`pnpm test`, `pnpm check:package`, and `pnpm check` run essential coverage. Their `:full` counterparts retain complete package or package/website checks. Granular and focused commands remain complete by default. Full runs locally only on explicit request; see the [testing policy](https://github.com/jesusgraterol/jg-agent-hq/blob/main/docs/testing.md) for classification and affected-consumer checks.
|
|
33
|
-
|
|
34
|
-
CI qualifies the package on both supported Node versions through `pnpm check:package`. Website verification and deployment run separately through Pages after successful main publication; a website failure does not block npm publication.
|
|
35
|
-
|
|
36
|
-
Testing maintenance can reuse an existing version when only these six aggregate scripts and this marked testing-command block differ. All runtime files, dependencies, exports, installation scripts, other documentation, and file permissions remain protected by the release check. This narrow exception to the general version rule above skips publication; it does not change the installed package.
|
|
37
|
-
|
|
38
|
-
[testing-commands:end]: #
|
|
39
|
-
|
|
40
|
-
## Lock ownership
|
|
41
|
-
|
|
42
|
-
Callers supply a trusted state root. The runtime takes its locks through [jg-locks](https://jg-packages.jesusgraterol.dev/packages/jg-locks/) in the root's private `.runtime/locks` folder: `runtime` for the runtime's lifetime, whose owner nonce is the runtime epoch, and `snapshot` while a capture runs. A live holder of `runtime` refuses another startup, and capture waits up to 120 seconds for a live `snapshot` holder. A holder whose process is gone is never taken over automatically, because its child processes may remain alive. The one exception is a runtime that stopped without releasing the state root: when the host's `isPreviousRuntimeStopped` check proves no process of that runtime remains, the next runtime takes its `runtime` lock over with jg-locks' `recoverFrom`, together with a `snapshot` lock it left and its leftover socket. Recover any other dead holder with jg-locks after inspecting it. The locks coordinate cooperating processes and do not isolate hostile code running as the same OS user.
|
|
43
|
-
|
|
44
|
-
Machine-wide locks are separate. The `locks` read and `jg-agent-hq locks` list the named locks that scripts, agents and apps on the machine take through [jg-locks](https://jg-packages.jesusgraterol.dev/packages/jg-locks/), each with its holder, so an application built on jg-agent-hq can show them. The runtime only reads them; it never takes, waits for or recovers one. See [machine locks](api/README.md#machine-locks).
|
|
45
|
-
|
|
46
|
-
See the [API reference](api/README.md) and [error contracts](errors/README.md).
|
|
47
|
-
|
|
48
|
-
Intentional failures use `Exception` from `jg-exception`, with the named string codes in the error reference. Local clients use `PUBLIC_ERROR_CODES` and `PUBLIC_ERROR_MESSAGES` from `jg-agent-hq/contracts` for errors translated at the IPC boundary. Safe classifications remain separate from private diagnostic causes.
|
|
49
|
-
|
|
50
|
-
## Local controller
|
|
51
|
-
|
|
52
|
-
Install the providers you want and sign in through their native CLIs, then start `jg-agent-hq serve --state-root .runtime --workspace-root /path/to/workspace`. Run `jg-agent-hq status --state-root .runtime` in a client. `threads` lists the sessions of several folders and both providers by last activity, with the sessions the runtime created before their first turn, in pages whose cursor resumes each source where it stopped; see [session discovery](api/README.md#session-discovery). `thread`, `items` and `usage` read native information, and each item carries its time as `createdAt` (Unix milliseconds, null when unavailable); Codex uses recorded item lifecycle times for saved and live items, without substituting a shared turn time; `thread` answers from the runtime's records, its history unavailable, when its provider can't read it. `item-detail` reads what a developer inspects in one item: its command and output, tool call, file diffs and images, and `item-image` returns one of its images. `stop` waits for confirmed runtime shutdown.
|
|
53
|
-
|
|
54
|
-
The Node API exposes `createAgentHq({ stateRoot, allowedRoots })` and `requestAgentHq(stateRoot, command)`, whose results, like the runtime's `request`, are typed by their command's kind, and `getErrorKind(error)`, which reads an error's safe classification. The runtime's `runtimeEpoch` is the epoch actions name. Configuration comes from these trusted operator inputs. Coding-instruction files are not runtime configuration.
|
|
55
|
-
|
|
56
|
-
The controller owns its SQLite worker and native connections independently of client connections. As it starts, it connects to Codex and brings Claude's history index up to date in the background, without waiting for either or failing when a CLI is missing, which status then reports unavailable. Storage and managed-session reads work without an installed coding CLI; an unavailable provider does not disable another provider. Private state contains the runtime's locks, Unix socket and SQLite discovery metadata. Conversation histories remain in native storage; the runtime retains complete bounded final results on their action receipts. Browsing never resumes an external session or starts inference. Quota windows come from native account observations, with explicit stale and unavailable states. Usage reads include Codex credit balances and available earned-reset counts when reported, plus Claude five-hour and seven-day meters with their model/surface scopes and reset times.
|
|
57
|
-
|
|
58
|
-
Use `session-evidence` for newest-first historical evidence. It fits within 65,536 serialized bytes, retains exact native identities and content hashes, and continues large bodies in UTF-8 chunks. Select an item, turn or item kinds with filters. Provenance distinguishes native evidence from exact host submissions; historical text and quoted feedback never grant approval. See [bounded session evidence](api/README.md#bounded-session-evidence).
|
|
59
|
-
|
|
60
|
-
Trusted Node hosts can open the database described by `hq.storage` with `openHostDatabase(hq.storage)`, which applies the required connection settings, and keep application tables under their own prefix; the connection can't change the runtime's tables. jg-agent-hq reserves `agent_hq_`, validates its current schema stamp on startup, and leaves application schema ownership and `user_version` with the host. Pass `initializeHostStorage` to `createAgentHq` for host schema preparation under exclusive runtime ownership, before native providers reconnect or requests are admitted. For later host schema changes, use `hq.withStorageMaintenance(callback)`, which drains admitted work and rejects active native execution. Both callbacks own their connections and transactional rollback. The stamp records the package version that wrote the database, and startup refuses any other schema with an error naming that version; jg-agent-hq never migrates storage. See the [shared storage contract](api/README.md#shared-storage).
|
|
61
|
-
|
|
62
|
-
`hq.createSnapshot(destination)` captures local state through SQLite's backup API while agents keep working, including host tables and action.key, under the state root's `snapshot` lock; the host keeps its own connections from writing host tables until it resolves. It leaves out the index of Claude transcripts, which a restored runtime rebuilds from the transcripts on its first Claude history read, as a fresh one does. `restoreHqSnapshot({ snapshotDirectory, destination })` verifies the complete snapshot and stages it into a new private recovery workspace. `packHqSnapshot(snapshotDirectory, archivePath, key)` encrypts a snapshot into one AES-256-GCM file for off-machine copies, and `unpackHqSnapshot(archivePath, destination, key)` verifies and writes it back as a snapshot directory. Snapshots from another schema are refused by the package version that wrote them. Restored native ownership needs reconciliation and allowed roots must be selected explicitly. Hosts own the key and remote backups; a failed disk can lose changes since the last successful off-machine backup. See [snapshot and restore](api/README.md#snapshot-and-restore) and [recovery](docs/recovery.md).
|
|
63
|
-
|
|
64
|
-
Sessions started in a terminal show up too. Codex sessions on the shared daemon and Claude sessions from `claude agents --json` report a live state (`running`, `waiting`, `idle`, `closed`, `failed` or `unknown`) with external ownership. jg-agent-hq builds on what each CLI offers and never stops, wakes or drives a session a terminal runs: it adopts a Codex session the terminal holds between turns, through the shared daemon, and a Claude session only once no terminal runs it, while a Claude session's `terminal` field names the terminal that does. Every state change of a managed or observed session is recorded in order, with the session's folder; read them with `{ kind: 'session-states', afterSequence }` or `session-states`, and add `waitMs` to wait up to 30 seconds for the next one. `live-items` waits the same way for a window's next change, and cuts its text to `textLimit`; both long-polls are woken by the runtime's own changes, never a timer. `active-sessions` lists every running and waiting session with its workspace, and `observation-pace` polls Claude every 5 seconds instead of 30 while a client follows sessions live. See [session states](api/README.md#session-states). Verified inputs in saved history and live windows link to their acknowledged native action; authenticated browser inputs also carry their original optional `browserActionId`. Late acknowledgement refreshes the live revision, allowing pending UI to reconcile without another output token.
|
|
65
|
-
|
|
66
|
-
The providers are `codex` and `claude`. Capabilities report current operation support, provider/session scope and unavailable reasons. Native version labels are diagnostic metadata and never determine admission. Unknown essential control data fails explicitly. `jg-agent-hq/contracts` contains browser-safe schemas and types; importing it does not import the host runtime.
|
|
67
|
-
|
|
68
|
-
Use `--provider claude` for Claude history and usage; the default is `codex`, while `threads` lists both unless `--provider` names one. Claude connects as the runtime starts through its native structured CLI, with normal settings enabled and no user prompt. History reads need that process only for the runtime's first check of the CLI, and a usage result answers reads for 60 seconds. Usage requests explicitly disable the optional transcript-behavior scan. Its local history reader validates required identity, workspace and chain fields, tolerates additive fields and mixed version labels, keeps byte locations rather than conversation bodies in SQLite, and writes nothing for a transcript that hasn't changed. History, live items and evidence present items as the CLI shows them, with `notice` items, tool calls paired with their results, and each file change's files; unknown ordered content is presented as unsupported, and untrustworthy identity or ordering makes the affected read unavailable. File history cannot establish current execution state. See the [reader limits and freshness contract](api/README.md#claude-history).
|
|
69
|
-
|
|
70
|
-
Explicit actions create, name, adopt, resume, close and delete threads; send idle messages; steer an exact running turn; queue the next message; interrupt; and answer native questions, permissions or MCP elicitation. A create can carry the session's first message and a close can interrupt a running turn first, each as one action. `thread-delete` deletes a session no process runs from its CLI's storage, and the runtime's records of it, within its request. Actions have stable UUIDs and durable receipts, and the `actions` page carries each queued input's text. `action-wait` returns a receipt once it has its native thread ID or settles, woken by the runtime's own changes rather than polling, or as it stands when its timeout of at most 30 seconds passes. Repeating the same request returns its receipt; changing that UUID's payload conflicts. A lost acknowledgement stays uncertain until the exact native response arrives or the operator makes an explicit recovery choice. The runtime never resends uncertain input.
|
|
71
|
-
|
|
72
|
-
Claude can save a steer as a queued-command attachment without echoing a live user message. Reading that saved input through history, details or evidence confirms a submitted or uncertain delivery when its exact action, session, workspace, turn and original-text fingerprint match. The existing turn-completion history flush performs the same check. This also resolves receipts from an earlier runtime without restoring control or resending input.
|
|
73
|
-
|
|
74
|
-
A steering replay can arrive before the preceding turn's result even when Claude answers it in a following turn. That following completion can name the exact replayed input instead of HQ's generated live turn ID. The controller retains a bounded set of these observed identities within its process generation, consumes a matching completion once and retires them on a new explicit input or controller replacement. Unknown results remain unavailable. This changes no receipt ownership, storage schema or queue delivery and never resends input. Pending steers survive intervening native turns: only unconfirmed input expires after 30 continuous idle seconds, and saved confirmations retain their identity until live replay or controller teardown. Rejected results emit a bounded stderr diagnostic with validated UUIDs and a reason, never message bodies or paths.
|
|
75
|
-
|
|
76
|
-
Use `models --provider <id>` for native model and effort choices, and `configuration --provider <id> --workspace-root <path> [--thread-id <id>]` for known effective settings and paged native agent/profile metadata. Creation and explicit resume accept typed startup settings; messages can select a model and effort for the next turn. Startup instructions, native Claude agents and permission settings require an idle session restart. Capability schemas describe supported selections and change modes. Unknown settings remain explicit, and native configuration files stay with each CLI. See the [configuration contract](api/README.md#native-configuration).
|
|
77
|
-
|
|
78
|
-
Native execution settings, instructions, skills and tool permissions remain with each CLI. Claude uses an owned structured process per controlled session, closes it after 60 idle minutes and reopens it for the next input, and steers its active turn with a structured user message. Close other CLI controllers before confirming adoption, resume or recovery. The runtime coordinates sessions sharing one state directory; it cannot lock independently running native CLIs. Integrating browser hosts can use durable host-action admission and operator-scoped reconciliation through the programmatic API; see the [browser host contract](api/README.md#browser-host-integration). The standalone CLI advertises only commands it implements.
|
|
79
|
-
|
|
80
|
-
When Claude sends structurally valid evidence HQ cannot interpret, HQ suspends that session's controls and live interpretation while its native work continues. It closes the quarantined controller automatically only after fresh native idle, a known empty task snapshot and no unresolved requests establish that work has finished. Unknown evidence or an unanswered approval keeps it alive; confirmed `thread-close` with `interrupt: true` explicitly stops its owned process group, including unfinished background work. Identity and transport-integrity failures retain their shutdown handling.
|
|
81
|
-
|
|
82
|
-
A quarantined known Codex identity offers confirmed recovery in the current runtime without an HQ restart. Recovery verifies the native turn before and after joining, sends no input or settings, keeps earlier queues paused and leaves uncertain receipts unresolved. Previously managed sessions also rejoin automatically after connection loss or runtime restart when their verified latest turn changed, without resolving earlier receipts or releasing old queues. Unknown state, pending submissions and a turn changing during the join still require inspection and explicit recovery. Native turn IDs do not prove exclusive control; keep other controlling clients closed.
|
|
83
|
-
|
|
84
|
-
After verified owned-group shutdown and controller release, that conversation becomes managed and inactive without restarting HQ. Resume retains its native identity and history. Unacknowledged input stays uncertain, earlier queued work stays paused, and pending approvals expire. Unconfirmed shutdown or a competing native terminal keeps ownership uncertain; another controlled conversation remains usable. See [Claude connection recovery](docs/recovery.md#claude-connection-recovery).
|
|
85
|
-
|
|
86
|
-
Approval reads return indexed, cursor-paginated pending, answered and expired metadata after reconnect or restart. Sensitive presentation is available only while the exact native request is live. Native permissions require explicit responses; unknown request kinds or scopes are denied. See [native replies and reconnect reads](api/README.md#thread-control-and-live-input).
|
|
87
|
-
|
|
88
|
-
Codex asynchronous questions retain their explicit `asyncInput` metadata through live items, saved history, details and evidence. They do not replace ordinary final results or create native approval requests. Trusted Node hosts use `hq.observeAsyncInputs(listener)` to enqueue complete controlled-session observations and recovery work independently of browser reads. Hosts own durable question resolution and explicit ordinary-message or exact-turn steer answers. See [async questions](api/README.md#async-questions).
|
|
89
|
-
|
|
90
|
-
Durable state includes `action.key`, which must stay private and accompany its SQLite database. Queued undelivered inputs and complete bounded final results are saved; ordinary input bodies and question answers are not.
|
|
91
|
-
|
|
92
|
-
Text and skill inputs, and steers, can attach up to 8 workspace files by path and media type, 16 MiB in all and 256 KiB per text file. The runtime verifies their content hashes again before queued delivery or steering. Capabilities publish `inputSchema.steerMediaTypes` separately from general attachment support: Claude steers accept images and labeled UTF-8 text, but reject PDFs before writing. Ordinary Claude turn-start document encoding is unchanged. Output schemas use native Codex turn parameters or Claude's structured-session flag; complete validated results and known token usage remain available on selected receipts after reconnect. Live previews stay bounded and explicitly mark truncation. See [file inputs and complete results](api/README.md#file-inputs-and-complete-results).
|
|
93
|
-
|
|
94
|
-
Use `suggest-thread-name --topic "Build usage" --state-root <directory>` for an editable label of up to 64 characters. Creation adds an ordinal suffix when a name is occupied, keeping the complete label within that limit. `MAX_THREAD_NAME_LENGTH` from `jg-agent-hq/contracts` is the public limit. Actions and relationships retain immutable IDs.
|
|
95
|
-
|
|
96
|
-
Version 13 retains the 12.0.1 storage schema and action key without migration or reset, and leaves existing names intact. Upgrade runtime and consumers together: older strict response schemas reject names longer than 32 characters. Before a package downgrade, explicitly shorten every longer managed name through supported actions, resolving collisions. See [package downgrade](docs/recovery.md#package-downgrade).
|
|
97
|
-
|
|
98
|
-
Use `skills --workspace-root <directory> --state-root <directory>` to browse the native skill catalog a session started in that folder would have, with `--provider` (default `codex`), and add `--thread-id <id>` for a controlled session's own catalog. A skill input resolves its exact invocation from that catalog before it is sent. Missing native metadata is explicitly unavailable. The CLI loads all skill content and retains its permissions and invocation rules.
|
|
99
|
-
|
|
100
|
-
Use `jg-agent-hq request --state-root <directory>` with one closed request command on stdin for action and control reads. The [API reference](api/README.md) describes action envelopes, receipts and reconnect reads.
|
|
101
|
-
|
|
102
|
-
## Source examples
|
|
103
|
-
|
|
104
|
-
Follow the [complete session walkthrough](https://jg-agent-hq.jesusgraterol.dev/examples/), with copyable source and its result.
|
|
105
|
-
|
|
106
|
-
`examples/control-session.ts` creates a native session and reads its actual delivery, output, permission and usage observations.
|
|
107
|
-
|
|
108
|
-
These complete TypeScript examples use the public client and contracts. Start the local controller and sign in to the native CLIs first. The host supplies actual user decisions and keeps native permission handling separate. Retain request identities before submission; after an interrupted client call, inspect those receipts instead of rerunning a whole example. Examples are development sources, not package exports or automatic website actions.
|
|
109
|
-
|
|
110
|
-
`examples/shared-storage.ts` uses a trusted Node runtime to save a singleton application preference under the app\_ prefix through `openHostDatabase`, capture shared SQLite storage with `createSnapshot`, and verify the value after offline restore. It closes its own SQL connections and preserves the host's user_version. Select absent output directories and pause every other writer first. The application write commits before capture; a later backup failure does not roll it back. The recovered state still requires explicit allowed roots before execution.
|
|
111
|
-
|
|
112
|
-
The [qualification matrix](api/README.md#qualification) records native journeys, host coverage and remaining interface limits.
|
|
14
|
+
Install and sign in through the native providers separately. Follow [docs/getting-started.md](https://github.com/jesusgraterol/jg-agent-hq/blob/main/docs/getting-started.md) for usage and the complete source walkthrough.
|
|
113
15
|
|
|
114
16
|
## Project blueprint
|
|
115
17
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
-
|
|
138
|
-
- `api/README.md`: canonical public API reference.
|
|
139
|
-
- `errors/README.md`: stable application errors.
|
|
140
|
-
- `website/`: private public-site workspace with its own README and test/check commands; canonical documentation bodies remain in this root README and `api/README.md`.
|
|
141
|
-
- `docs/website.md`: durable website architecture, verification and generated-asset sources.
|
|
142
|
-
- `docs/architecture.md`: provider and database ownership, schema initialization and host maintenance.
|
|
143
|
-
- `docs/recovery.md`: local snapshot coverage, offline recovery and the host's remote durability responsibilities.
|
|
144
|
-
- [`docs/delivery.md`](https://github.com/jesusgraterol/jg-agent-hq/blob/main/docs/delivery.md): ordered development, main and npm publication stops, operators and release verification.
|
|
145
|
-
|
|
146
|
-
`/docs` is reserved for concise, quickly scannable documentation of essential durable concepts and processes. API references remain outside `/docs`.
|
|
147
|
-
|
|
148
|
-
## Testing
|
|
149
|
-
|
|
150
|
-
Tests consume built public exports. Unit tests cover application-owned decisions; integration tests use real temporary files, SQLite workers, IPC, child processes and an isolated tarball consumer. Synthetic CLIs replace only the external provider boundary. Every fixture removes its own resources. Production output excludes all test categories. `pnpm test` builds, then runs unit and integration suites. `pnpm check:package` is the task-completion check. Run changed integration files three consecutive times with retries disabled, using Vitest's `--repeats=2 --retry=0`.
|
|
151
|
-
|
|
152
|
-
The website's README and `docs/website.md` define its build-once check composition, category-specific scripts and owned preview/browser lifecycle. Root and website checks must both pass for task completion when workspace configuration or canonical site content changes.
|
|
153
|
-
|
|
154
|
-
The runtime fixture teardown is registered with the test runner as well as the callback, so a test timeout cannot restore environment variables during the next test.
|
|
155
|
-
|
|
156
|
-
Current local checks establish the tested host only. Release qualification must include the Node engines floor and current LTS; macOS operation requires its own runtime evidence.
|
|
18
|
+
| Need | Read | What it owns |
|
|
19
|
+
| ------------------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
20
|
+
| Start a controller or use the package | [docs/getting-started.md](https://github.com/jesusgraterol/jg-agent-hq/blob/main/docs/getting-started.md) | Installation, local control and source examples; canonical source for the website's /docs/ page. |
|
|
21
|
+
| Change a public integration | [api/README.md](api/README.md) | Node/browser contracts, commands, files, native control and complete results. |
|
|
22
|
+
| Locate code or prepare development | [docs/development.md](docs/development.md) | Contributor setup, command entry points and detailed module map. |
|
|
23
|
+
| Understand runtime ownership | [docs/architecture.md](docs/architecture.md) | Provider/storage boundaries, lifecycle and lock ownership. |
|
|
24
|
+
| Capture, restore or downgrade safely | [docs/recovery.md](docs/recovery.md) | Snapshot coverage, native reconciliation and host durability responsibilities. |
|
|
25
|
+
| Select verification | [docs/testing.md](docs/testing.md) | Built-public-export tests, essential/full selections, focused consumers and release identity rules. |
|
|
26
|
+
| Change the public website | [website/README.md](website/README.md), [docs/website.md](docs/website.md) | Workspace checks, safe content sources, asset ownership and delivery boundaries. |
|
|
27
|
+
| Resolve intentional failures | [errors/README.md](errors/README.md) | Stable codes/messages and public classifications. |
|
|
28
|
+
| Deliver source or publish a release | [docs/delivery.md](docs/delivery.md) | Ordered development/main/npm stops, operators and verified release handling. |
|
|
29
|
+
|
|
30
|
+
## Repository map
|
|
31
|
+
|
|
32
|
+
| Entry | Responsibility |
|
|
33
|
+
| ---------------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
34
|
+
| [src/](src/) | Public package boundary and local runtime, provider, session, action, storage and snapshot modules. |
|
|
35
|
+
| [examples/](examples/) | Complete client/session and trusted host-storage helpers. |
|
|
36
|
+
| [api/](api/), [errors/](errors/) | Public integration contracts and stable failures. |
|
|
37
|
+
| [scripts/](scripts/), [vitest/](vitest/) | Package/release tooling, disposable provider fixtures and category selection. |
|
|
38
|
+
| [website/](website/) | Private Astro workspace for the public package site. |
|
|
39
|
+
| [docs/](docs/) | Durable getting-started, architecture, development, testing and delivery guides. |
|
package/api/README.md
CHANGED
|
@@ -260,7 +260,7 @@ File timestamps and records do not prove that a native process is idle or a turn
|
|
|
260
260
|
|
|
261
261
|
## Async questions
|
|
262
262
|
|
|
263
|
-
An explicit Codex `agentMessage` with `delivery: 'async'` carries
|
|
263
|
+
An explicit Codex `agentMessage` with `delivery: 'async'` carries `asyncInput` when it includes a non-null `questions` field. The same metadata is available in live items, item details and every evidence fragment. Async messages with a missing or null `questions` field are informational notices. Their text remains visible in the transcript, and question observers receive no item for them. Text or a `questions` field alone never establishes async semantics.
|
|
264
264
|
|
|
265
265
|
Available metadata is `{ delivery: 'async', state: 'available', questions }`. Each ordered question has a nonempty `title` and optional ordered string `options`. Native `options: null` is normalized to an omitted `options` field for free-text questions. Question and choice strings retain their exact content, up to 8192 UTF-16 code units each, with at most 32 questions and 32 choices per question. The entire normalized `asyncInput` must fit `MAX_ASYNC_INPUT_BYTES` (32768 serialized UTF-8 bytes, including JSON escaping). Additive native fields are tolerated. Malformed contracts retain ordinary preview text and `{ delivery: 'async', state: 'unavailable', reason: 'invalid' }`; valid shapes over the byte budget use `reason: 'too-large'`. Choices are never shortened to fit a response. Evidence fitting accounts for metadata before selecting its text chunk; live memory accounting includes the complete serialized item, and saved/live reconciliation requires matching async metadata.
|
|
266
266
|
|
|
@@ -493,6 +493,8 @@ The operation matrix describes the implemented native interfaces and their expli
|
|
|
493
493
|
|
|
494
494
|
On 2026-11-10, Linux with Node.js 24.15.0 and Codex 0.167.0 qualified the built public async-input API in an owned disposable workspace. Actual `request_user_input_async` emission retained the exact question choices and managed/native/turn/item identities, matched saved native history, and left the ordinary `ASYNC_QUALIFICATION_FINAL` result intact. Terminating only that runtime's owned Codex proxy produced output-gap/reconnect signals; bounded native history recovered the same question without inference or input replay. The owned session was deleted and the runtime closed. Fixture tests additionally cover invalid/oversized metadata, evidence fitting, observer isolation and shutdown; macOS and other CLI/model configurations require separate native evidence.
|
|
495
495
|
|
|
496
|
+
The informational-notice fix in 13.5.8 was checked through the built public API on Linux with Node.js 24.15.0 and Codex 0.170.0. A native informational notice retained its transcript text and produced no question observation. A genuine asynchronous question reached the observer with its native item identity, appeared in saved history, and the ordinary final response was retained. The disposable native session was deleted and its controller closed.
|
|
497
|
+
|
|
496
498
|
On 2026-11-07, Codex 0.167.0 consumed image and labeled text input through `turn/steer` in the running turn. Claude Code 2.1.319 with claude-opus-5-5 and normal `auto` permissions consumed text/PDF document blocks at turn start, and image plus labeled text blocks in the original running turn. A native PDF steer was dropped, so it is excluded from Claude's steer media list. The repaired runtime journey verified exact browser/action/source identity, original first-text hash, separate persisted prompt blocks, unchanged saved image bytes, live/history reconciliation, and provenance after restart without resending. The queued prompt's graph UUID differs from its input's source UUID. Its projection rebuild was also checked against the retained real transcript and an older cached index. These checks establish the observed native shapes and provider versions, without using an origin override or changing turn-start encoding.
|
|
497
499
|
|
|
498
500
|
| Area | Executed evidence | Boundary |
|
|
@@ -513,3 +515,55 @@ On 2026-11-07, Codex 0.167.0 consumed image and labeled text input through `turn
|
|
|
513
515
|
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.
|
|
514
516
|
|
|
515
517
|
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.
|
|
518
|
+
|
|
519
|
+
## Controller overview
|
|
520
|
+
|
|
521
|
+
Intentional failures use `Exception` from `jg-exception`, with the named string codes in the error reference. Local clients use `PUBLIC_ERROR_CODES` and `PUBLIC_ERROR_MESSAGES` from `jg-agent-hq/contracts` for errors translated at the IPC boundary. Safe classifications remain separate from private diagnostic causes.
|
|
522
|
+
|
|
523
|
+
The Node API exposes `createAgentHq({ stateRoot, allowedRoots })` and `requestAgentHq(stateRoot, command)`, whose results, like the runtime's `request`, are typed by their command's kind, and `getErrorKind(error)`, which reads an error's safe classification. The runtime's `runtimeEpoch` is the epoch actions name. Configuration comes from these trusted operator inputs. Coding-instruction files are not runtime configuration.
|
|
524
|
+
|
|
525
|
+
The controller owns its SQLite worker and native connections independently of client connections. As it starts, it connects to Codex and brings Claude's history index up to date in the background, without waiting for either or failing when a CLI is missing, which status then reports unavailable. Storage and managed-session reads work without an installed coding CLI; an unavailable provider does not disable another provider. Private state contains the runtime's locks, Unix socket and SQLite discovery metadata. Conversation histories remain in native storage; the runtime retains complete bounded final results on their action receipts. Browsing never resumes an external session or starts inference. Quota windows come from native account observations, with explicit stale and unavailable states. Usage reads include Codex credit balances and available earned-reset counts when reported, plus Claude five-hour and seven-day meters with their model/surface scopes and reset times.
|
|
526
|
+
|
|
527
|
+
Use `session-evidence` for newest-first historical evidence. It fits within 65,536 serialized bytes, retains exact native identities and content hashes, and continues large bodies in UTF-8 chunks. Select an item, turn or item kinds with filters. Provenance distinguishes native evidence from exact host submissions; historical text and quoted feedback never grant approval. See [bounded session evidence](../api/README.md#bounded-session-evidence).
|
|
528
|
+
|
|
529
|
+
Trusted Node hosts can open the database described by `hq.storage` with `openHostDatabase(hq.storage)`, which applies the required connection settings, and keep application tables under their own prefix; the connection can't change the runtime's tables. jg-agent-hq reserves `agent_hq_`, validates its current schema stamp on startup, and leaves application schema ownership and `user_version` with the host. Pass `initializeHostStorage` to `createAgentHq` for host schema preparation under exclusive runtime ownership, before native providers reconnect or requests are admitted. For later host schema changes, use `hq.withStorageMaintenance(callback)`, which drains admitted work and rejects active native execution. Both callbacks own their connections and transactional rollback. The stamp records the package version that wrote the database, and startup refuses any other schema with an error naming that version; jg-agent-hq never migrates storage. See the [shared storage contract](../api/README.md#shared-storage).
|
|
530
|
+
|
|
531
|
+
`hq.createSnapshot(destination)` captures local state through SQLite's backup API while agents keep working, including host tables and action.key, under the state root's `snapshot` lock; the host keeps its own connections from writing host tables until it resolves. It leaves out the index of Claude transcripts, which a restored runtime rebuilds from the transcripts on its first Claude history read, as a fresh one does. `restoreHqSnapshot({ snapshotDirectory, destination })` verifies the complete snapshot and stages it into a new private recovery workspace. `packHqSnapshot(snapshotDirectory, archivePath, key)` encrypts a snapshot into one AES-256-GCM file for off-machine copies, and `unpackHqSnapshot(archivePath, destination, key)` verifies and writes it back as a snapshot directory. Snapshots from another schema are refused by the package version that wrote them. Restored native ownership needs reconciliation and allowed roots must be selected explicitly. Hosts own the key and remote backups; a failed disk can lose changes since the last successful off-machine backup. See [snapshot and restore](../api/README.md#snapshot-and-restore) and [recovery](../docs/recovery.md).
|
|
532
|
+
|
|
533
|
+
Sessions started in a terminal show up too. Codex sessions on the shared daemon and Claude sessions from `claude agents --json` report a live state (`running`, `waiting`, `idle`, `closed`, `failed` or `unknown`) with external ownership. jg-agent-hq builds on what each CLI offers and never stops, wakes or drives a session a terminal runs: it adopts a Codex session the terminal holds between turns, through the shared daemon, and a Claude session only once no terminal runs it, while a Claude session's `terminal` field names the terminal that does. Every state change of a managed or observed session is recorded in order, with the session's folder; read them with `{ kind: 'session-states', afterSequence }` or `session-states`, and add `waitMs` to wait up to 30 seconds for the next one. `live-items` waits the same way for a window's next change, and cuts its text to `textLimit`; both long-polls are woken by the runtime's own changes, never a timer. `active-sessions` lists every running and waiting session with its workspace, and `observation-pace` polls Claude every 5 seconds instead of 30 while a client follows sessions live. See [session states](../api/README.md#session-states). Verified inputs in saved history and live windows link to their acknowledged native action; authenticated browser inputs also carry their original optional `browserActionId`. Late acknowledgement refreshes the live revision, allowing pending UI to reconcile without another output token.
|
|
534
|
+
|
|
535
|
+
The providers are `codex` and `claude`. Capabilities report current operation support, provider/session scope and unavailable reasons. Native version labels are diagnostic metadata and never determine admission. Unknown essential control data fails explicitly. `jg-agent-hq/contracts` contains browser-safe schemas and types; importing it does not import the host runtime.
|
|
536
|
+
|
|
537
|
+
Use `--provider claude` for Claude history and usage; the default is `codex`, while `threads` lists both unless `--provider` names one. Claude connects as the runtime starts through its native structured CLI, with normal settings enabled and no user prompt. History reads need that process only for the runtime's first check of the CLI, and a usage result answers reads for 60 seconds. Usage requests explicitly disable the optional transcript-behavior scan. Its local history reader validates required identity, workspace and chain fields, tolerates additive fields and mixed version labels, keeps byte locations rather than conversation bodies in SQLite, and writes nothing for a transcript that hasn't changed. History, live items and evidence present items as the CLI shows them, with `notice` items, tool calls paired with their results, and each file change's files; unknown ordered content is presented as unsupported, and untrustworthy identity or ordering makes the affected read unavailable. File history cannot establish current execution state. See the [reader limits and freshness contract](../api/README.md#claude-history).
|
|
538
|
+
|
|
539
|
+
Explicit actions create, name, adopt, resume, close and delete threads; send idle messages; steer an exact running turn; queue the next message; interrupt; and answer native questions, permissions or MCP elicitation. A create can carry the session's first message and a close can interrupt a running turn first, each as one action. `thread-delete` deletes a session no process runs from its CLI's storage, and the runtime's records of it, within its request. Actions have stable UUIDs and durable receipts, and the `actions` page carries each queued input's text. `action-wait` returns a receipt once it has its native thread ID or settles, woken by the runtime's own changes rather than polling, or as it stands when its timeout of at most 30 seconds passes. Repeating the same request returns its receipt; changing that UUID's payload conflicts. A lost acknowledgement stays uncertain until the exact native response arrives or the operator makes an explicit recovery choice. The runtime never resends uncertain input.
|
|
540
|
+
|
|
541
|
+
Claude can save a steer as a queued-command attachment without echoing a live user message. Reading that saved input through history, details or evidence confirms a submitted or uncertain delivery when its exact action, session, workspace, turn and original-text fingerprint match. The existing turn-completion history flush performs the same check. This also resolves receipts from an earlier runtime without restoring control or resending input.
|
|
542
|
+
|
|
543
|
+
A steering replay can arrive before the preceding turn's result even when Claude answers it in a following turn. That following completion can name the exact replayed input instead of HQ's generated live turn ID. The controller retains a bounded set of these observed identities within its process generation, consumes a matching completion once and retires them on a new explicit input or controller replacement. Unknown results remain unavailable. This changes no receipt ownership, storage schema or queue delivery and never resends input. Pending steers survive intervening native turns: only unconfirmed input expires after 30 continuous idle seconds, and saved confirmations retain their identity until live replay or controller teardown. Rejected results emit a bounded stderr diagnostic with validated UUIDs and a reason, never message bodies or paths.
|
|
544
|
+
|
|
545
|
+
Use `models --provider <id>` for native model and effort choices, and `configuration --provider <id> --workspace-root <path> [--thread-id <id>]` for known effective settings and paged native agent/profile metadata. Creation and explicit resume accept typed startup settings; messages can select a model and effort for the next turn. Startup instructions, native Claude agents and permission settings require an idle session restart. Capability schemas describe supported selections and change modes. Unknown settings remain explicit, and native configuration files stay with each CLI. See the [configuration contract](../api/README.md#native-configuration).
|
|
546
|
+
|
|
547
|
+
Native execution settings, instructions, skills and tool permissions remain with each CLI. Claude uses an owned structured process per controlled session, closes it after 60 idle minutes and reopens it for the next input, and steers its active turn with a structured user message. Close other CLI controllers before confirming adoption, resume or recovery. The runtime coordinates sessions sharing one state directory; it cannot lock independently running native CLIs. Integrating browser hosts can use durable host-action admission and operator-scoped reconciliation through the programmatic API; see the [browser host contract](../api/README.md#browser-host-integration). The standalone CLI advertises only commands it implements.
|
|
548
|
+
|
|
549
|
+
When Claude sends structurally valid evidence HQ cannot interpret, HQ suspends that session's controls and live interpretation while its native work continues. It closes the quarantined controller automatically only after fresh native idle, a known empty task snapshot and no unresolved requests establish that work has finished. Unknown evidence or an unanswered approval keeps it alive; confirmed `thread-close` with `interrupt: true` explicitly stops its owned process group, including unfinished background work. Identity and transport-integrity failures retain their shutdown handling.
|
|
550
|
+
|
|
551
|
+
A quarantined known Codex identity offers confirmed recovery in the current runtime without an HQ restart. Recovery verifies the native turn before and after joining, sends no input or settings, keeps earlier queues paused and leaves uncertain receipts unresolved. Previously managed sessions also rejoin automatically after connection loss or runtime restart when their verified latest turn changed, without resolving earlier receipts or releasing old queues. Unknown state, pending submissions and a turn changing during the join still require inspection and explicit recovery. Native turn IDs do not prove exclusive control; keep other controlling clients closed.
|
|
552
|
+
|
|
553
|
+
After verified owned-group shutdown and controller release, that conversation becomes managed and inactive without restarting HQ. Resume retains its native identity and history. Unacknowledged input stays uncertain, earlier queued work stays paused, and pending approvals expire. Unconfirmed shutdown or a competing native terminal keeps ownership uncertain; another controlled conversation remains usable. See [Claude connection recovery](../docs/recovery.md#claude-connection-recovery).
|
|
554
|
+
|
|
555
|
+
Approval reads return indexed, cursor-paginated pending, answered and expired metadata after reconnect or restart. Sensitive presentation is available only while the exact native request is live. Native permissions require explicit responses; unknown request kinds or scopes are denied. See [native replies and reconnect reads](../api/README.md#thread-control-and-live-input).
|
|
556
|
+
|
|
557
|
+
Codex asynchronous questions retain their explicit `asyncInput` metadata through live items, saved history, details and evidence. They do not replace ordinary final results or create native approval requests. Trusted Node hosts use `hq.observeAsyncInputs(listener)` to enqueue complete controlled-session observations and recovery work independently of browser reads. Hosts own durable question resolution and explicit ordinary-message or exact-turn steer answers. See [async questions](../api/README.md#async-questions).
|
|
558
|
+
|
|
559
|
+
Durable state includes `action.key`, which must stay private and accompany its SQLite database. Queued undelivered inputs and complete bounded final results are saved; ordinary input bodies and question answers are not.
|
|
560
|
+
|
|
561
|
+
Text and skill inputs, and steers, can attach up to 8 workspace files by path and media type, 16 MiB in all and 256 KiB per text file. The runtime verifies their content hashes again before queued delivery or steering. Capabilities publish `inputSchema.steerMediaTypes` separately from general attachment support: Claude steers accept images and labeled UTF-8 text, but reject PDFs before writing. Ordinary Claude turn-start document encoding is unchanged. Output schemas use native Codex turn parameters or Claude's structured-session flag; complete validated results and known token usage remain available on selected receipts after reconnect. Live previews stay bounded and explicitly mark truncation. See [file inputs and complete results](../api/README.md#file-inputs-and-complete-results).
|
|
562
|
+
|
|
563
|
+
Use `suggest-thread-name --topic "Build usage" --state-root <directory>` for an editable label of up to 64 characters. Creation adds an ordinal suffix when a name is occupied, keeping the complete label within that limit. `MAX_THREAD_NAME_LENGTH` from `jg-agent-hq/contracts` is the public limit. Actions and relationships retain immutable IDs.
|
|
564
|
+
|
|
565
|
+
Version 13 retains the 12.0.1 storage schema and action key without migration or reset, and leaves existing names intact. Upgrade runtime and consumers together: older strict response schemas reject names longer than 32 characters. Before a package downgrade, explicitly shorten every longer managed name through supported actions, resolving collisions. See [package downgrade](../docs/recovery.md#package-downgrade).
|
|
566
|
+
|
|
567
|
+
Use `skills --workspace-root <directory> --state-root <directory>` to browse the native skill catalog a session started in that folder would have, with `--provider` (default `codex`), and add `--thread-id <id>` for a controlled session's own catalog. A skill input resolves its exact invocation from that catalog before it is sent. Missing native metadata is explicitly unavailable. The CLI loads all skill content and retains its permissions and invocation rules.
|
|
568
|
+
|
|
569
|
+
Use `jg-agent-hq request --state-root <directory>` with one closed request command on stdin for action and control reads. The [API reference](../api/README.md) describes action envelopes, receipts and reconnect reads.
|
|
@@ -74,9 +74,9 @@ const MessageSchema = z.object({ text: z.string() });
|
|
|
74
74
|
const NativeAsyncQuestionSchema = AsyncQuestionSchema.extend({
|
|
75
75
|
options: AsyncQuestionSchema.shape.options.nullable(),
|
|
76
76
|
}).transform(({ options, ...question }) => (options == null ? question : { ...question, options }));
|
|
77
|
-
/**
|
|
77
|
+
/** Normalizes async question bundles and leaves informational notices as transcript messages. */
|
|
78
78
|
const toAsyncInput = (item) => {
|
|
79
|
-
if (item.type !== 'agentMessage' || item.delivery !== 'async')
|
|
79
|
+
if (item.type !== 'agentMessage' || item.delivery !== 'async' || item.questions == null)
|
|
80
80
|
return undefined;
|
|
81
81
|
const questions = z.array(NativeAsyncQuestionSchema).min(1).max(32).safeParse(item.questions);
|
|
82
82
|
if (!questions.success)
|
|
@@ -210,6 +210,7 @@ export const toHistoryItem = ({ turnId, item, startedAtMs, completedAtMs }, full
|
|
|
210
210
|
const last = text.charCodeAt(end - 1);
|
|
211
211
|
if (end < text.length && last >= 0xd800 && last <= 0xdbff)
|
|
212
212
|
end -= 1;
|
|
213
|
+
const asyncInput = toAsyncInput(item);
|
|
213
214
|
return parseNative(HistoryItemSchema, {
|
|
214
215
|
nativeId: item.id,
|
|
215
216
|
turnId,
|
|
@@ -218,9 +219,7 @@ export const toHistoryItem = ({ turnId, item, startedAtMs, completedAtMs }, full
|
|
|
218
219
|
provenance: nativeProvenance(kind, kind === 'user-message' && typeof item.clientId === 'string' ? item.clientId : null, inputText),
|
|
219
220
|
text: text.slice(0, end),
|
|
220
221
|
isTruncated: end < text.length,
|
|
221
|
-
...(
|
|
222
|
-
? { asyncInput: toAsyncInput(item) }
|
|
223
|
-
: {}),
|
|
222
|
+
...(asyncInput ? { asyncInput } : {}),
|
|
224
223
|
// a Codex item holds its call and its result together
|
|
225
224
|
callId: null,
|
|
226
225
|
outcome,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jg-agent-hq",
|
|
3
|
-
"version": "13.5.
|
|
3
|
+
"version": "13.5.8",
|
|
4
4
|
"description": "Native Claude Code and Codex session control, history, usage and recoverable local storage for Node.js apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/node": "24.19.2",
|
|
62
|
+
"jg-plans": "0.6.1",
|
|
62
63
|
"prettier": "3.4.2",
|
|
63
64
|
"typescript": "6.0.3",
|
|
64
65
|
"vitest": "5.0.3"
|