jg-agent-hq 4.0.2 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +4 -4
  3. package/api/README.md +20 -12
  4. package/dist/cli/cli.js +23 -2
  5. package/dist/contracts/agent-tools/types.d.ts +2 -0
  6. package/dist/contracts/browser/types.d.ts +11 -0
  7. package/dist/contracts/constants.d.ts +1 -0
  8. package/dist/contracts/constants.js +2 -0
  9. package/dist/contracts/evidence/types.d.ts +4 -0
  10. package/dist/contracts/evidence/types.js +2 -1
  11. package/dist/contracts/index.d.ts +5 -5
  12. package/dist/contracts/index.js +3 -3
  13. package/dist/contracts/sessions/index.d.ts +2 -2
  14. package/dist/contracts/sessions/index.js +1 -1
  15. package/dist/contracts/sessions/types.d.ts +5 -0
  16. package/dist/contracts/sessions/types.js +2 -0
  17. package/dist/contracts/types.d.ts +242 -0
  18. package/dist/contracts/types.js +37 -5
  19. package/dist/providers/claude/agents/agents.d.ts +7 -3
  20. package/dist/providers/claude/agents/agents.js +33 -19
  21. package/dist/providers/claude/agents/constants.d.ts +2 -1
  22. package/dist/providers/claude/agents/constants.js +3 -2
  23. package/dist/providers/claude/claude.js +80 -30
  24. package/dist/providers/claude/control/control.d.ts +44 -5
  25. package/dist/providers/claude/control/control.js +425 -228
  26. package/dist/providers/claude/control/stream.js +22 -6
  27. package/dist/providers/claude/control/types.d.ts +7 -0
  28. package/dist/providers/claude/history/history.model.js +44 -27
  29. package/dist/providers/claude/history/types.d.ts +88 -0
  30. package/dist/providers/claude/history/types.js +15 -0
  31. package/dist/providers/claude/history/utilities.d.ts +6 -4
  32. package/dist/providers/claude/history/utilities.js +146 -52
  33. package/dist/providers/codex/adapter.js +33 -4
  34. package/dist/providers/codex/codex.js +5 -4
  35. package/dist/providers/codex/events.js +3 -1
  36. package/dist/providers/codex/transformers.d.ts +4 -2
  37. package/dist/providers/codex/transformers.js +80 -21
  38. package/dist/providers/codex/types.d.ts +4 -3
  39. package/dist/providers/registry/registry.js +12 -9
  40. package/dist/providers/registry/types.d.ts +1 -1
  41. package/dist/providers/registry/validations.js +7 -0
  42. package/dist/providers/types.d.ts +7 -1
  43. package/dist/runtime/runtime.js +20 -4
  44. package/dist/sessions/evidence/utilities.js +3 -1
  45. package/dist/sessions/index.d.ts +2 -2
  46. package/dist/sessions/index.js +3 -3
  47. package/dist/sessions/sessions.d.ts +11 -1
  48. package/dist/sessions/sessions.js +89 -7
  49. package/dist/sessions/utilities.d.ts +15 -0
  50. package/dist/sessions/utilities.js +19 -0
  51. package/dist/store/schema.sql +1 -1
  52. package/dist/store/sessions/index.d.ts +2 -0
  53. package/dist/store/sessions/index.js +2 -0
  54. package/dist/store/sessions/sessions.model.d.ts +9 -0
  55. package/dist/store/sessions/sessions.model.js +55 -0
  56. package/dist/store/sessions/types.d.ts +67 -0
  57. package/dist/store/sessions/types.js +36 -0
  58. package/dist/store/store.js +4 -0
  59. package/dist/store/store.worker.js +3 -0
  60. package/dist/store/types.d.ts +40 -0
  61. package/dist/store/types.js +1 -0
  62. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.1
4
+
5
+ - Index Claude transcripts with less memory. Each record is read once, instead of being copied again for every 64 KiB chunk it spans, and the SQLite worker's young generation is capped at 16 MiB. Indexing a 224 MB transcript held the runtime at about 200 MB instead of about 300 MB. The storage schema is unchanged, so databases and snapshots written by 5.0.0 open as they are.
6
+
7
+ ## 5.0.0
8
+
9
+ - Read `items` newest first, its only order, with its cursor continuing toward older items; it read oldest first before. `textLimit`, from 1 to 65,536 and 65,536 by default, cuts each item's text on a code-point boundary and marks it `isTruncated`. `nativeItemId` with its `turnId` returns that item alone; Codex finds it by reading that turn's items 128 at a time.
10
+ - Present history, live items and `session-evidence` as each CLI shows them, from one mapping per provider. History items gain `callId`, which pairs a tool call with its result, `outcome` and `files`, and the kinds gain `notice`; a provider's items must carry the new fields. Claude leaves out thinking and task notifications, and shows compaction summaries, local command output and interruption markers as notices, slash commands as `/name args`, `!` shell input and output as paired commands, Edit and Write results as file changes with their line counts, and results saved to a file as their size and preview. Codex leaves out reasoning, so a page can hold fewer items than its limit, and shows compaction as a notice and web searches and image views as tools. Outcome and files come from the full record before the text is cut.
11
+ - Start a Claude turn only at a message the operator sends, including a slash command; task notifications, compaction summaries, local command output and `!` shell records belong to the turn before them. The Claude index stores each entry's presented kind and visibility, so `session-evidence` kind filters match what `items` shows.
12
+ - Stop a managed Claude Code process whose session has been idle for 60 minutes, keeping the session idle with no state transition. Its skills, configuration and interrupt calls answer from what it kept, and input, renames, extension control and MCP reads reopen it with `--resume`, its settings and a new agent bridge. The session-less Claude read process closes after 5 minutes without a read.
13
+ - Add `active-sessions`, which returns every running and waiting session, managed and observed, with its workspace, at most 128 and newest state change first, and `observation-pace`, which polls Claude's active sessions every 5 seconds at `live` and every 30 at `background`. The runtime starts at `background`; it polled every 5 seconds before. Providers may implement `readObservedThread` so their observed sessions are listed. Both are also CLI commands.
14
+ - Change the storage schema in place. A database or snapshot written by 4.x is refused with `JG_AGENT_HQ_STORAGE_INVALID` naming the version that wrote it; start from a fresh state root.
15
+
3
16
  ## 4.0.2
4
17
 
5
18
  - Read Claude sessions whose transcript holds a hidden record written before the record it follows, such as an instructions attachment or a scheduled-task event. The reader rejected the whole session, so HQ couldn't name or show it; it now holds the record back until its parent is indexed.
package/README.md CHANGED
@@ -49,11 +49,11 @@ Trusted Node hosts can open the database described by `hq.storage` and keep appl
49
49
 
50
50
  `createHqSnapshot(hq, destination)` captures local state through SQLite's backup API while agents keep working, including host tables, stored reports, action.key and registered plan companions. HQ-mediated plan writes wait for it; the host keeps its own connections from writing host tables until it resolves. A plan that changed during capture is marked, and restore withholds its execution authority. `inspectHqSnapshot(directory)` verifies the complete snapshot; `restoreHqSnapshot({ snapshotDirectory, destination })` validates 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 automation is paused, skill grants are revoked, 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).
51
51
 
52
- 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, and HQ sends them no input until they are closed there and handed over with `thread-adopt`. Every state change of a managed or observed session is recorded in order; read them with `{ kind: 'session-states', afterSequence }` or `session-states`. See [session states](api/README.md#session-states).
52
+ 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, and HQ sends them no input until they are closed there and handed over with `thread-adopt`. Every state change of a managed or observed session is recorded in order; read them with `{ kind: 'session-states', afterSequence }` or `session-states`. `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).
53
53
 
54
54
  Provider IDs are bounded lowercase identifiers. Codex and Claude are built in; trusted Node hosts can register additional `IAgentProviderFactory` implementations through `providerFactories`. 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.
55
55
 
56
- Use `--provider claude` for Claude history and usage; the default is `codex`. Claude connects lazily through its native structured CLI, with normal settings enabled and no user prompt. 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, and keeps byte locations rather than conversation bodies in SQLite. Unknown ordered content is presented as unsupported; 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).
56
+ Use `--provider claude` for Claude history and usage; the default is `codex`. Claude connects lazily through its native structured CLI, with normal settings enabled and no user prompt. 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, and keeps byte locations rather than conversation bodies in SQLite. 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).
57
57
 
58
58
  Explicit actions create, name, adopt, resume and close threads; send idle messages; steer an exact running turn; queue the next message; interrupt; and answer native questions, permissions or MCP elicitation. Actions have stable UUIDs and durable receipts. 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. HQ never resends uncertain input.
59
59
 
@@ -63,7 +63,7 @@ Use `account --provider <id>` for safe native account metadata, and `mcp-servers
63
63
 
64
64
  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).
65
65
 
66
- Native execution settings, instructions, skills and tool permissions remain with each CLI. Claude uses an owned structured process per controlled session and reports immediate steering as unavailable. Plan approval grants no native tool permission. Close other CLI controllers before confirming adoption, resume or recovery. HQ 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.
66
+ 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 reports immediate steering as unavailable. Plan approval grants no native tool permission. Close other CLI controllers before confirming adoption, resume or recovery. HQ 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.
67
67
 
68
68
  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).
69
69
 
@@ -119,7 +119,7 @@ The [qualification matrix](api/README.md#qualification) records native journeys,
119
119
  - `src/providers/registry/`: lazy factories, normalized provider evidence, bounded lifecycle and source isolation.
120
120
  - `src/providers/inputs/` and `src/providers/results/`: checked file delivery and complete native result validation.
121
121
  - `src/providers/configuration/` and `src/providers/lineage/`: bounded native choices and confirmed immutable session relationships.
122
- - `src/sessions/`: authorized discovery with live session states, bounded evidence and provenance, cursor-bound history reads and short label suggestions.
122
+ - `src/sessions/`: authorized discovery with live session states, the active-session list, bounded evidence and provenance, cursor-bound history reads and short label suggestions.
123
123
  - `src/plans/`: execution digests, milestone finalization, revision checkpoints, retained verification and explicit plan authority.
124
124
  - `src/skills/`: bounded native catalogs, invocation previews and explicit input preparation.
125
125
  - `src/accounts/` and `src/extensions/`: safe account observations and authorized, bounded native MCP inventories.
package/api/README.md CHANGED
@@ -78,7 +78,7 @@ The socket accepts at most 32 simultaneous connections. Requests are bounded to
78
78
 
79
79
  Factories receive canonical allowed roots, the runtime epoch, a cancellation signal and runtime-owned event callbacks. They return `IAgentProvider`, which owns native protocol validation, processes, authentication, capabilities, history, skill invocation spelling and concrete session controls. Each operation receives a bounded `IProviderCall.signal`. Factories must clean up partial initialization before rejecting; `close()` must be idempotent and confirm that owned resources stopped. HQ retains ownership evidence when cleanup cannot be confirmed. Failed construction is not automatically replayed.
80
80
 
81
- `IAgentProviderEvents` carries normalized observations, items, deltas, prompts, outcomes, observed session states and connection loss. `session(nativeId, state)` reports the live state of a session another client drives inside the allowed workspaces; HQ ignores it for sessions it controls. `validateInput` rejects unsupported media/output options before admission and again at dispatch. `startTurn` receives content-bound `IProviderInputFile` bytes read by HQ. A turn-completed observation may carry a validated complete result whose state must match that observation. Registration binds provider identity. Echo each supplied request ID unchanged; HQ derives its action identity and verifies the exact receipt, runtime, provider, native session and workspace. A late create/fork/resume/unarchive/revert outcome also supplies verified native session metadata. Unknown control states cannot establish success or idle ownership. Callback metadata may grow additively; known identity and state fields remain validated. Native permission requests keep their exact reply channel and validation. An unsupported request is denied rather than approved.
81
+ `IAgentProviderEvents` carries normalized observations, items, deltas, prompts, outcomes, observed session states and connection loss. `session(nativeId, state)` reports the live state of a session another client drives inside the allowed workspaces; HQ ignores it for sessions it controls. An adapter that reports such sessions may implement the optional `readObservedThread(nativeId)`, returning the session's summary with the workspace it runs in; without it, those sessions are left out of `active-sessions`. `validateInput` rejects unsupported media/output options before admission and again at dispatch. `startTurn` receives content-bound `IProviderInputFile` bytes read by HQ. A turn-completed observation may carry a validated complete result whose state must match that observation. Registration binds provider identity. Echo each supplied request ID unchanged; HQ derives its action identity and verifies the exact receipt, runtime, provider, native session and workspace. A late create/fork/resume/unarchive/revert outcome also supplies verified native session metadata. Unknown control states cannot establish success or idle ownership. Callback metadata may grow additively; known identity and state fields remain validated. Native permission requests keep their exact reply channel and validation. An unsupported request is denied rather than approved.
82
82
 
83
83
  `{ kind: 'capabilities', provider, threadId? }` returns `IProviderCapabilities`. The optional managed thread must belong to that provider and an allowed workspace. The response includes provider/session scope, observation time, concrete operation support, and supported HQ input/configuration schemas. Each operation is `supported`, `unsupported`, `unavailable` or `unknown`, with a structured reason when support cannot be established. Supported settings describe whether a change is live or requires an idle restart. Configuration schemas describe typed session and turn settings, their live or idle-restart change mode, and native permission/sandbox choices. Model and effort values come from the native model catalog. Capabilities are observations, not permission grants or execution authority.
84
84
 
@@ -127,7 +127,7 @@ Import `HqRequestSchema`, `HqResponseSchema` and their inferred types from `jg-a
127
127
  | `sessions` | `provider`, `workspaceRoot` | Byte-bounded discovery with exact IDs; optional `search` |
128
128
  | `thread` | `provider`, `workspaceRoot`, `nativeId` | One native thread's metadata |
129
129
  | `turns` | Same target fields | Paged native turn metadata without hydrating items |
130
- | `items` | Same target fields | Paged persisted native items; optional `turnId` |
130
+ | `items` | Same target fields | Newest-first persisted native items; optional `turnId`, `textLimit` and `nativeItemId` |
131
131
  | `session-evidence` | Same target fields | Newest-first bounded evidence, exact references and full normalized text continuation |
132
132
  | `account` | `provider` | Safe native account metadata with explicit unavailable observations |
133
133
  | `mcp-servers` | Managed `threadId` | Paged configured native MCP server identity, connection and auth metadata |
@@ -136,7 +136,9 @@ Import `HqRequestSchema`, `HqResponseSchema` and their inferred types from `jg-a
136
136
  | `login` | `actionId` | Live authentication presentation or known terminal state |
137
137
  | `usage` | `provider` | Actual subscription observations |
138
138
 
139
- 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 descending creation order for threads, descending turns and ascending items. Claude orders discovery by creation time/native UUID descending and history by native chain position ascending. Workspace authorization is rechecked for each request, independently of cursor validation, before selected-thread items are fetched.
139
+ 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 descending creation order for threads, descending turns and descending items. Claude orders discovery by creation time/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.
140
+
141
+ `items` reads newest first, its only order, and its cursor continues toward older items. `textLimit`, from 1 to 65,536 and 65,536 by default, cuts each item's `text` to that many UTF-16 code units on a code-point boundary and marks it `isTruncated`. `nativeItemId` with its `turnId`, and without a cursor, returns that item alone, cut at `textLimit` like any page; a hidden item, an unknown one, or one outside that turn returns an empty page. Codex has no lookup of one item, so it reads that turn's items, 128 at a time, until it finds the item.
140
142
 
141
143
  Threads expose native state, the live session `state` described under [session states](#session-states), `historyState` (`available` or `unavailable`), ownership (`external`, `managed` or `uncertain`) and nullable `managedId`. A managed thread uses its HQ name; an external thread retains its nullable native name. Timestamps use Unix milliseconds. Discovery projections are not authoritative transcript history and never cache a conversation body. Repeated Codex history reads go to its native APIs so a completed turn whose items have not flushed can be read again later. There is no resume-to-read behavior or Codex transcript-file parser.
142
144
 
@@ -144,7 +146,7 @@ Threads expose native state, the live session `state` described under [session s
144
146
 
145
147
  `sessions` and `session-evidence` enforce a 65,536-byte total serialized response budget, including the IPC envelope. Both accept `limit` (default 32, maximum 128) and an opaque `cursor`. A request inspects at most eight source items, so it may return fewer than its limit. Continue until `nextCursor` is null, including when a filtered page is empty. Discovery preserves every matching identity rather than selecting an agent by an ambiguous native label. Native display names are limited to 1,024 UTF-8 bytes with `isNameTruncated`; exact managed/native IDs remain unchanged.
146
148
 
147
- `session-evidence` selects `provider`, `workspaceRoot`, `nativeId`, and optional `turnId`, `nativeItemId` and `kinds` (the history item kinds). Items arrive newest first. Each fragment has `reference: { provider, nativeId, turnId, itemId, sha256 }`, `text`, `offsetBytes`, `totalBytes`, `isComplete`, `contentState`, native type, kind and provenance. The hash identifies the complete normalized UTF-8 text, not the fragment or raw transcript record. Non-text native blocks retain explicit labels; this API does not return raw provider payloads or binary attachments. `isComplete` is true only on the final fragment of supported, untruncated normalized text. `contentState` distinguishes available content, unsupported native content and a provider preview. Concatenate fragments for one exact reference in byte-offset order and verify its total length and hash. Empty native history returns an empty terminal page; missing or unverifiable history reports its provider's unavailable error.
149
+ `session-evidence` selects `provider`, `workspaceRoot`, `nativeId`, and optional `turnId`, `nativeItemId` and `kinds` (the history item kinds, matching the kinds `items` presents). Items arrive newest first. Each fragment has `reference: { provider, nativeId, turnId, itemId, sha256 }`, `text`, `offsetBytes`, `totalBytes`, `isComplete`, `contentState`, native type, kind and provenance. The hash identifies the complete normalized UTF-8 text, not the fragment or raw transcript record. Non-text native blocks retain explicit labels; this API does not return raw provider payloads or binary attachments. `isComplete` is true only on the final fragment of supported, untruncated normalized text. `contentState` distinguishes available content, unsupported native content and a provider preview. Concatenate fragments for one exact reference in byte-offset order and verify its total length and hash. Empty native history returns an empty terminal page; missing or unverifiable history reports its provider's unavailable error.
148
150
 
149
151
  Text chunks contain at most 32,768 UTF-8 bytes and shrink when escaping or metadata consumes the response budget. Cursors bind all query fields and the content of a partially consumed native page. Changed content, changed query scope or a changed Claude chain revision uses CURSOR_INVALID; start a fresh read rather than joining different evidence. New native pages use the provider's continuation, not an immutable transcript snapshot. Newly arriving or removed history may therefore require a fresh discovery/evidence read. Authorization is rechecked on every request before content access, and no alternate raw-file path bypasses a denial.
150
152
 
@@ -209,7 +211,7 @@ Selected action receipts expose nullable `result: { state, format, text, structu
209
211
 
210
212
  ## Claude history
211
213
 
212
- 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. An unavailable native lane requires restarting the host after resolving the native problem.
214
+ 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 one; 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.
213
215
 
214
216
  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.
215
217
 
@@ -219,9 +221,9 @@ The existing SQLite worker incrementally records file identity, complete-line of
219
221
 
220
222
  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.
221
223
 
222
- Selected history reads refresh only that file, retain incomplete tails, and detect truncation or replaced identity. Changed branch/file revisions invalidate item and turn continuations. Only the current parent-linked conversation chain is returned. Text is reread from the native file for the selected page and normalized as plain text. Tool calls show their native name and input; tool results have kind `tool`. Other non-text content has explicit native block labels. An unknown record containing content is returned as an `unsupported` item when its identity and chain are trustworthy; it cannot imply an agent response, idle state or completion. Each selected page reads at most 4 MiB of record bytes beyond its first record and returns at most 4 MiB of serialized item presentation, so a large-text page can contain fewer rows than its requested limit.
224
+ Selected history reads refresh only that file, retain incomplete tails, and detect truncation or replaced identity. Changed branch/file revisions invalidate item and turn continuations. Only the current parent-linked conversation chain is returned. Text is reread from the native file for the selected page and normalized as plain text. Thinking blocks are left out, and a record holding only thinking is hidden, as are `<task-notification>` records. Compaction summaries, `<local-command-stdout>` output and interruption markers are `notice` items, and a slash command is a `user-message` reading `/name args`. A `!` shell input and its output are `command` items, the output's `callId` being the input's UUID. A tool call shows its native name and input, with the block's ID as `callId`, which is null for a record calling several tools; its result is a `tool` item carrying that ID, `failed` when it has `is_error` and `succeeded` otherwise. An Edit or Write result whose metadata has a `filePath` and a `structuredPatch` is a `file-change` item reading the path and its patch lines, or a created file's content, every line of which counts as added. A result Claude Code saved to a file reads `Output too large (<size>), saved to a file` followed by its preview, without the file's path. Other non-text content has explicit native block labels. The index stores each entry's presented kind and visibility, so evidence kind filters match `items` and hidden records never shorten a page. An unknown record containing content is returned as an `unsupported` item when its identity and chain are trustworthy; it cannot imply an agent response, idle state or completion. Each selected page reads at most 4 MiB of record bytes beyond its first record and returns at most 4 MiB of serialized item presentation, so a large-text page can contain fewer rows than its requested limit.
223
225
 
224
- File timestamps and records do not prove that a native process is idle or a turn completed. Claude file-backed thread and turn states are therefore `unknown`, with no invented completion timestamp. Explicit native custom titles are preserved; a missing title remains null. File-backed grouping follows native user records and parent links, including generated user-record markers; it is not an authoritative execution boundary.
226
+ File timestamps and records do not prove that a native process is idle or a turn completed. Claude file-backed thread and turn states are therefore `unknown`, with no invented completion timestamp. Explicit native custom titles are preserved; a missing title remains null. A turn starts at a message the operator sends, including a slash command; task notifications, compaction summaries, local command output, interruption markers and `!` shell records belong to the turn before them. Grouping follows parent links and is not an authoritative execution boundary.
225
227
 
226
228
  ## Thread control and live input
227
229
 
@@ -273,7 +275,7 @@ Each record contains identity, `kind`, `isBlocking`, `state`, `replyActionId`, t
273
275
 
274
276
  ### Claude native control
275
277
 
276
- Each controlled session has one persistent native `claude` process in the authorized workspace. 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.
278
+ 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, closes the process and releases its agent bridge, 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, its kept settings and a new agent bridge; a collaboration request reopens it with the HQ envelope directly. 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.
277
279
 
278
280
  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.
279
281
 
@@ -283,7 +285,7 @@ Claude questions use exact question text as their answer identity and expose whe
283
285
 
284
286
  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.
285
287
 
286
- Partial text uses temporary live identities until the final native message UUID arrives; that replacement shares the existing global live-item budget. Native thinking content is not copied into text presentation. Persisted history reconciles matching final items through the same content normalizer. Closing the session proves owned process-group exit, including native background children, before HQ releases control.
288
+ Partial text uses temporary live identities until the final native message UUID arrives; that replacement shares the existing global live-item budget. Live frames and streaming previews follow the history presentation: thinking is left out, task notifications aren't shown, and a live Edit or Write result is a file change. Persisted history reconciles matching final items through the same content normalizer. Closing the session proves owned process-group exit, including native background children, before HQ releases control.
287
289
 
288
290
  ## Native skill catalog
289
291
 
@@ -317,14 +319,16 @@ Control pages default to 32 and cap at 128. Seek cursors are bound to their comp
317
319
 
318
320
  Live item presentation is bounded to 128 items per cached thread, 32 windows and 4 MiB of serialized presentation across the runtime, including escaped text and identifiers. This leaves room inside the IPC response limit. Display text uses the same truncation contract as native history. Eviction, an unavailable window or missing chunks sets `hasGap`. Completed items remain `awaiting-flush` after thread closure until a native history page contains exactly matching normalized content or the bounded cache evicts them. Read persisted history and the live window together after reconnect; a process restart cannot reconstruct unflushed in-memory content.
319
321
 
320
- Items expose only normalized presentation fields. User/agent text, commands and file changes have explicit kinds. Unknown native kinds report `unsupported` without copying arbitrary payloads. Display text is bounded to 65,536 UTF-16 code units without splitting a surrogate pair; `isTruncated` reports omissions. An unsupported or oversized native transport frame fails explicitly.
322
+ Items expose only normalized presentation fields, and one mapping per provider presents `items`, live items and `session-evidence` alike, as the provider's CLI shows them. Kinds are `user-message`, `agent-message`, `command`, `tool`, `file-change`, `notice` and `unsupported`. `callId` pairs a tool call with its result, or is null. `outcome` is `succeeded`, `failed`, or null when unknown or still running. `files` lists each file a file change touched, at most 128, with its added and removed lines, and is empty on other items. `outcome` and `files` come from the full native record, so `textLimit` never changes them. Unknown native kinds report `unsupported` without copying arbitrary payloads. Display text is bounded to 65,536 UTF-16 code units without splitting a surrogate pair; `isTruncated` reports omissions. An unsupported or oversized native transport frame fails explicitly.
323
+
324
+ Codex leaves `reasoning` items out as it reads them, so a Codex page can hold fewer items than its limit. `contextCompaction` is a `notice` with empty text, because Codex records no summary. `webSearch` and `imageView` are `tool` items reading the query or the image path. A command, file change or tool call takes its `outcome` from its `status`: `completed` succeeded, and `failed` or `declined` failed. `files` counts each change's diff, and an added or deleted file without hunks counts its whole content. A Codex item holds its call and its result together, so its `callId` is null. Claude's rules are under [Claude history](#claude-history).
321
325
 
322
326
  ## Session states
323
327
 
324
328
  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. Hand it over with `thread-adopt` once it is closed in its terminal, which Codex reports as unloaded.
325
329
 
326
330
  - **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`. 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.
327
- - **Claude.** While the runtime runs, HQ runs `claude agents --json` every 5 seconds, each run limited to 10 seconds and 65,536 bytes of output, and joins its entries to Claude discovery by `sessionId`. `busy` is running, `waiting` (an interactive session's question or permission prompt) and `blocked` (a background session) are waiting, and `idle` is idle; an entry missing from a run is closed. A failed, late, oversized or malformed run changes nothing. Sessions HQ manages keep their managed records.
331
+ - **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`. `busy` is running, `waiting` (an interactive session's question or permission prompt) and `blocked` (a background session) are waiting, and `idle` is idle; an entry missing from a run is closed. A failed, late, oversized or malformed run changes nothing. Sessions HQ manages keep their managed records.
328
332
 
329
333
  `{ 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`.
330
334
 
@@ -341,6 +345,10 @@ Every session has a live state: `running`, `waiting` (on the operator), `idle`,
341
345
 
342
346
  Transitions survive restarts. Each new transition deletes up to 128 transitions older than seven days, and closed observed sessions are forgotten after seven days. A managed session's stopping phase records no transition of its own.
343
347
 
348
+ `{ kind: 'active-sessions' }` returns every running and waiting session, managed and observed, at most 128 and newest state change first, with `isTruncated` when more are active. Each comes as the summary `threads` returns, with its workspace root, name and timestamps. A managed session reads them from its HQ record. An observed Claude session's workspace is the `cwd` the latest `claude agents --json` run reported, so it is left out until the first run after the runtime starts lists it; its name and timestamps come from its indexed transcript, and are null and its state's change time while the transcript isn't indexed. An observed Codex session's summary comes from `thread/read`, and other providers' observed sessions from their optional `readObservedThread`. A session outside the allowed workspaces, or one its provider can't read, is left out.
349
+
350
+ `{ kind: 'observation-pace', pace: 'live' | 'background' }` sets the Claude poll to every 5 seconds or every 30, taking effect with an immediate run; the runtime starts at `background`. A host sets `live` while a client follows sessions live.
351
+
344
352
  When the Codex daemon restarts, HQ's connection ends: its sessions become uncertain, observed Codex sessions become unknown, and nothing is sent again. The provider reports unavailable until the next Codex read reconnects; recover uncertain sessions with `thread-recover`.
345
353
 
346
354
  ## Subscription observations
@@ -365,7 +373,7 @@ Every usage read requests current native observations; the last successful snaps
365
373
 
366
374
  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.
367
375
 
368
- `jg-agent-hq session-states --state-root <directory> [--after-sequence <sequence>] [--limit <1..128>]` reads one page of session state transitions.
376
+ `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, and `jg-agent-hq observation-pace --state-root <directory> --pace live|background` sets the Claude poll's pace.
369
377
 
370
378
  `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.
371
379
 
package/dist/cli/cli.js CHANGED
@@ -32,6 +32,7 @@ const main = async () => {
32
32
  'native-id': { type: 'string' },
33
33
  'turn-id': { type: 'string' },
34
34
  'native-item-id': { type: 'string' },
35
+ 'text-limit': { type: 'string' },
35
36
  'evidence-kind': { type: 'string', multiple: true },
36
37
  'thread-id': { type: 'string' },
37
38
  'server-name': { type: 'string' },
@@ -44,6 +45,7 @@ const main = async () => {
44
45
  cursor: { type: 'string' },
45
46
  limit: { type: 'string' },
46
47
  'after-sequence': { type: 'string' },
48
+ pace: { type: 'string' },
47
49
  search: { type: 'string' },
48
50
  provider: { type: 'string' },
49
51
  help: { type: 'boolean', short: 'h' },
@@ -51,7 +53,7 @@ const main = async () => {
51
53
  });
52
54
  const [kind] = positionals;
53
55
  if (values.help || !kind || kind === 'help') {
54
- process.stdout.write('jg-agent-hq serve|status|stop|capabilities|threads|thread|turns|items|sessions|session-evidence|usage|account|models|configuration|mcp-servers|mcp-tools|mcp-resources|managed-thread-name|suggest-thread-name|skills|skill-preview|plan-status|plan-milestones|session-states|request --state-root <path> [--provider <provider-id>] [--workspace-root <path>] [--native-id <id>] [--limit <1..128>] [--cursor <cursor>] [--name <name>] [--topic <topic>] [--thread-id <id>] [--server-name <name>] [--skill-id <id>] [--arguments <text>] [--directory <path>] [--after-sequence <sequence>]\nserve accepts repeated --codex-extra-skill-root and --claude-additional-directory, and --coordination-root for a separate existing coordination directory.\nsession-evidence accepts --native-item-id and repeated --evidence-kind.\nrequest reads one validated HQ command as JSON from stdin.\n');
56
+ process.stdout.write('jg-agent-hq serve|status|stop|capabilities|threads|thread|turns|items|sessions|session-evidence|usage|account|models|configuration|mcp-servers|mcp-tools|mcp-resources|managed-thread-name|suggest-thread-name|skills|skill-preview|plan-status|plan-milestones|session-states|active-sessions|observation-pace|request --state-root <path> [--provider <provider-id>] [--workspace-root <path>] [--native-id <id>] [--limit <1..128>] [--cursor <cursor>] [--name <name>] [--topic <topic>] [--thread-id <id>] [--server-name <name>] [--skill-id <id>] [--arguments <text>] [--directory <path>] [--after-sequence <sequence>]\nserve accepts repeated --codex-extra-skill-root and --claude-additional-directory, and --coordination-root for a separate existing coordination directory.\nsession-evidence accepts --native-item-id and repeated --evidence-kind.\nitems reads newest first and accepts --text-limit <1..65536>, and --native-item-id with --turn-id for one item.\nobservation-pace takes --pace <live|background>.\nrequest reads one validated HQ command as JSON from stdin.\n');
55
57
  return;
56
58
  }
57
59
  if (positionals.length !== 1 || !values['state-root'])
@@ -109,6 +111,7 @@ const main = async () => {
109
111
  values['native-id'] ||
110
112
  values['turn-id'] ||
111
113
  values['native-item-id'] ||
114
+ values['text-limit'] ||
112
115
  values['evidence-kind'] ||
113
116
  values['thread-id'] ||
114
117
  values['skill-id'] ||
@@ -217,7 +220,24 @@ const main = async () => {
217
220
  process.stdout.write(`${JSON.stringify({ schemaVersion: 1, ...(await requestAgentHq(stateRoot, parsed.data)) })}\n`);
218
221
  return;
219
222
  }
220
- if (values.directory || values['after-sequence'])
223
+ if (kind === 'active-sessions' || kind === 'observation-pace') {
224
+ const allowed = new Set(kind === 'observation-pace' ? ['state-root', 'pace'] : ['state-root']);
225
+ if (Object.keys(values).some((key) => !allowed.has(key)))
226
+ throw new Exception('The HQ request is invalid', {
227
+ code: 'JG_AGENT_HQ_REQUEST_INVALID',
228
+ data: { kind: 'invalid-request' },
229
+ });
230
+ const parsed = HqRequestSchema.safeParse(kind === 'active-sessions' ? { kind } : { kind, pace: values.pace });
231
+ if (!parsed.success)
232
+ throw new Exception('The HQ request is invalid', {
233
+ code: 'JG_AGENT_HQ_REQUEST_INVALID',
234
+ data: { kind: 'invalid-request' },
235
+ cause: parsed.error,
236
+ });
237
+ process.stdout.write(`${JSON.stringify({ schemaVersion: 1, ...(await requestAgentHq(stateRoot, parsed.data)) })}\n`);
238
+ return;
239
+ }
240
+ if (values.directory || values['after-sequence'] || values.pace)
221
241
  throw new Exception('The HQ request is invalid', {
222
242
  code: 'JG_AGENT_HQ_REQUEST_INVALID',
223
243
  data: { kind: 'invalid-request' },
@@ -247,6 +267,7 @@ const main = async () => {
247
267
  ['nativeId', values['native-id']],
248
268
  ['turnId', values['turn-id']],
249
269
  ['nativeItemId', values['native-item-id']],
270
+ ['textLimit', values['text-limit'] === undefined ? undefined : Number(values['text-limit'])],
250
271
  ['kinds', values['evidence-kind']],
251
272
  ['threadId', values['thread-id']],
252
273
  ['serverName', values['server-name']],
@@ -87,6 +87,7 @@ export declare const AgentToolCallSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
87
87
  tool: "tool";
88
88
  "agent-message": "agent-message";
89
89
  "file-change": "file-change";
90
+ notice: "notice";
90
91
  }>>>;
91
92
  taskId: z.ZodUUID;
92
93
  }, z.core.$strict>;
@@ -425,6 +426,7 @@ export declare const AgentToolRequestSchema: z.ZodObject<{
425
426
  tool: "tool";
426
427
  "agent-message": "agent-message";
427
428
  "file-change": "file-change";
429
+ notice: "notice";
428
430
  }>>>;
429
431
  taskId: z.ZodUUID;
430
432
  }, z.core.$strict>;
@@ -1310,6 +1310,7 @@ export declare const BrowserThreadDetailSchema: z.ZodObject<{
1310
1310
  tool: "tool";
1311
1311
  "agent-message": "agent-message";
1312
1312
  "file-change": "file-change";
1313
+ notice: "notice";
1313
1314
  }>;
1314
1315
  provenance: z.ZodObject<{
1315
1316
  origin: z.ZodEnum<{
@@ -1333,6 +1334,16 @@ export declare const BrowserThreadDetailSchema: z.ZodObject<{
1333
1334
  }, z.core.$strip>;
1334
1335
  text: z.ZodString;
1335
1336
  isTruncated: z.ZodBoolean;
1337
+ callId: z.ZodNullable<z.ZodString>;
1338
+ outcome: z.ZodNullable<z.ZodEnum<{
1339
+ failed: "failed";
1340
+ succeeded: "succeeded";
1341
+ }>>;
1342
+ files: z.ZodArray<z.ZodObject<{
1343
+ path: z.ZodString;
1344
+ added: z.ZodNumber;
1345
+ removed: z.ZodNumber;
1346
+ }, z.core.$strip>>;
1336
1347
  state: z.ZodEnum<{
1337
1348
  active: "active";
1338
1349
  "awaiting-flush": "awaiting-flush";
@@ -1,5 +1,6 @@
1
1
  export declare const DEFAULT_PAGE_SIZE = 32;
2
2
  export declare const MAX_PAGE_SIZE = 128;
3
+ export declare const MAX_ITEM_TEXT_LENGTH = 65536;
3
4
  export declare const PUBLIC_ERROR_CODES: {
4
5
  readonly 'invalid-request': "JG_AGENT_HQ_CLIENT_INVALID_REQUEST";
5
6
  readonly 'authentication-required': "JG_AGENT_HQ_CLIENT_AUTHENTICATION_REQUIRED";
@@ -1,6 +1,8 @@
1
1
  // trusted-boundary page sizes for growing collections
2
2
  export const DEFAULT_PAGE_SIZE = 32;
3
3
  export const MAX_PAGE_SIZE = 128;
4
+ // the most text one history item carries, in UTF-16 code units
5
+ export const MAX_ITEM_TEXT_LENGTH = 65_536;
4
6
  // stable client codes for failures translated at IPC and browser boundaries
5
7
  export const PUBLIC_ERROR_CODES = {
6
8
  'invalid-request': 'JG_AGENT_HQ_CLIENT_INVALID_REQUEST',
@@ -35,6 +35,7 @@ export declare const HistoryKindSchema: z.ZodEnum<{
35
35
  tool: "tool";
36
36
  "agent-message": "agent-message";
37
37
  "file-change": "file-change";
38
+ notice: "notice";
38
39
  }>;
39
40
  export declare const EvidenceRequestSchema: z.ZodObject<{
40
41
  kind: z.ZodLiteral<"session-evidence">;
@@ -50,6 +51,7 @@ export declare const EvidenceRequestSchema: z.ZodObject<{
50
51
  tool: "tool";
51
52
  "agent-message": "agent-message";
52
53
  "file-change": "file-change";
54
+ notice: "notice";
53
55
  }>>>;
54
56
  limit: z.ZodDefault<z.ZodNumber>;
55
57
  cursor: z.ZodOptional<z.ZodString>;
@@ -70,6 +72,7 @@ export declare const EvidenceItemSchema: z.ZodObject<{
70
72
  tool: "tool";
71
73
  "agent-message": "agent-message";
72
74
  "file-change": "file-change";
75
+ notice: "notice";
73
76
  }>;
74
77
  nativeType: z.ZodString;
75
78
  provenance: z.ZodObject<{
@@ -119,6 +122,7 @@ export declare const EvidencePageSchema: z.ZodObject<{
119
122
  tool: "tool";
120
123
  "agent-message": "agent-message";
121
124
  "file-change": "file-change";
125
+ notice: "notice";
122
126
  }>;
123
127
  nativeType: z.ZodString;
124
128
  provenance: z.ZodObject<{
@@ -33,6 +33,7 @@ export const HistoryKindSchema = z.enum([
33
33
  'command',
34
34
  'tool',
35
35
  'file-change',
36
+ 'notice',
36
37
  'unsupported',
37
38
  ]);
38
39
  export const EvidenceRequestSchema = z.strictObject({
@@ -42,7 +43,7 @@ export const EvidenceRequestSchema = z.strictObject({
42
43
  nativeId: NativeIdSchema,
43
44
  turnId: NativeIdSchema.optional(),
44
45
  nativeItemId: NativeIdSchema.optional(),
45
- kinds: z.array(HistoryKindSchema).min(1).max(6).optional(),
46
+ kinds: z.array(HistoryKindSchema).min(1).max(7).optional(),
46
47
  limit: z.number().int().min(1).max(128).default(32),
47
48
  cursor: CursorSchema.optional(),
48
49
  });
@@ -2,11 +2,11 @@ export { AccountControlCommandSchema, LoginObservationSchema, LoginRequestSchema
2
2
  export type { IAccountControlCommand, ILoginObservation, INativeControlResult, } from './accounts/index.js';
3
3
  export { ExtensionControlCommandSchema } from './extensions/index.js';
4
4
  export type { IExtensionControlCommand } from './extensions/index.js';
5
- export { DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
6
- export { HqRequestSchema, ThreadSummarySchema, TurnSummarySchema, HistoryItemSchema, LiveItemsSchema, UsageWindowSchema, UsageSnapshotSchema, UsageCreditsSchema, UsageResetCreditsSchema, UsageWindowScopeSchema, RuntimeStatusSchema, HqResponseSchema, ErrorKindSchema, IpcRequestSchema, IpcResponseSchema, } from './types.js';
5
+ export { DEFAULT_PAGE_SIZE, MAX_ITEM_TEXT_LENGTH, MAX_PAGE_SIZE, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
6
+ export { HqRequestSchema, ThreadSummarySchema, ActiveSessionsSchema, TurnSummarySchema, HistoryFileSchema, HistoryItemSchema, LiveItemsSchema, UsageWindowSchema, UsageSnapshotSchema, UsageCreditsSchema, UsageResetCreditsSchema, UsageWindowScopeSchema, RuntimeStatusSchema, HqResponseSchema, ErrorKindSchema, IpcRequestSchema, IpcResponseSchema, } from './types.js';
7
7
  export { ProviderIdSchema, ProviderCapabilitySchema, ProviderCapabilitySetSchema, ProviderCapabilitiesSchema, ProviderStatusSchema, MAX_PROVIDERS, } from './providers/index.js';
8
8
  export type { IProviderId, IProviderCapability, IProviderCapabilitySet, IProviderCapabilities, IProviderStatus, } from './providers/index.js';
9
- export type { IHqRequest, IHqRequestInput, IThreadSummary, ITurnSummary, IHistoryItem, IUsageSnapshot, IUsageCredits, IUsageResetCredits, IUsageWindowScope, IRuntimeStatus, IHqResponse, IErrorKind, IIpcResponse, } from './types.js';
9
+ export type { IHqRequest, IHqRequestInput, IThreadSummary, IActiveSessions, ITurnSummary, IHistoryFile, IHistoryItem, IUsageSnapshot, IUsageCredits, IUsageResetCredits, IUsageWindowScope, IRuntimeStatus, IHqResponse, IErrorKind, IIpcResponse, } from './types.js';
10
10
  export { NativeLineageSchema } from './identities/index.js';
11
11
  export type { INativeLineage } from './identities/index.js';
12
12
  export { ProviderModelSchema, ProviderModelsRequestSchema, ProviderModelPageSchema, } from './models/index.js';
@@ -43,5 +43,5 @@ export type { ICollaborationActor, IMessageAuthor, IDispatchFailure, IDispatchBl
43
43
  export { AgentIdentityArgumentsSchema, AgentSpawnArgumentsSchema, AgentToolCallSchema, AgentToolRequestSchema, AgentToolResultSchema, } from './agent-tools/index.js';
44
44
  export type { IAgentSpawnArguments, IAgentToolCall, IAgentToolName, IAgentToolRequest, IAgentToolResult, } from './agent-tools/index.js';
45
45
  export { SessionDiscoveryRequestSchema } from './evidence/index.js';
46
- export { SessionStateSchema, SessionTransitionReasonSchema, SessionTransitionSchema, SessionTransitionPageSchema, } from './sessions/index.js';
47
- export type { ISessionState, ISessionTransitionReason, ISessionTransition, } from './sessions/index.js';
46
+ export { SessionStateSchema, SessionTransitionReasonSchema, SessionTransitionSchema, SessionTransitionPageSchema, ObservationPaceSchema, } from './sessions/index.js';
47
+ export type { ISessionState, ISessionTransitionReason, ISessionTransition, IObservationPace, } from './sessions/index.js';
@@ -2,9 +2,9 @@
2
2
  export { AccountControlCommandSchema, LoginObservationSchema, LoginRequestSchema, NativeControlResultSchema, } from './accounts/index.js';
3
3
  export { ExtensionControlCommandSchema } from './extensions/index.js';
4
4
  // constants
5
- export { DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
5
+ export { DEFAULT_PAGE_SIZE, MAX_ITEM_TEXT_LENGTH, MAX_PAGE_SIZE, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
6
6
  // wire contracts
7
- export { HqRequestSchema, ThreadSummarySchema, TurnSummarySchema, HistoryItemSchema, LiveItemsSchema, UsageWindowSchema, UsageSnapshotSchema, UsageCreditsSchema, UsageResetCreditsSchema, UsageWindowScopeSchema, RuntimeStatusSchema, HqResponseSchema, ErrorKindSchema, IpcRequestSchema, IpcResponseSchema, } from './types.js';
7
+ export { HqRequestSchema, ThreadSummarySchema, ActiveSessionsSchema, TurnSummarySchema, HistoryFileSchema, HistoryItemSchema, LiveItemsSchema, UsageWindowSchema, UsageSnapshotSchema, UsageCreditsSchema, UsageResetCreditsSchema, UsageWindowScopeSchema, RuntimeStatusSchema, HqResponseSchema, ErrorKindSchema, IpcRequestSchema, IpcResponseSchema, } from './types.js';
8
8
  // provider identity and capability discovery
9
9
  export { ProviderIdSchema, ProviderCapabilitySchema, ProviderCapabilitySetSchema, ProviderCapabilitiesSchema, ProviderStatusSchema, MAX_PROVIDERS, } from './providers/index.js';
10
10
  // native identities
@@ -43,4 +43,4 @@ export { COLLABORATION_LIMITS, CollaborationActorSchema, MessageAuthorSchema, Di
43
43
  export { AgentIdentityArgumentsSchema, AgentSpawnArgumentsSchema, AgentToolCallSchema, AgentToolRequestSchema, AgentToolResultSchema, } from './agent-tools/index.js';
44
44
  export { SessionDiscoveryRequestSchema } from './evidence/index.js';
45
45
  // session states and transitions
46
- export { SessionStateSchema, SessionTransitionReasonSchema, SessionTransitionSchema, SessionTransitionPageSchema, } from './sessions/index.js';
46
+ export { SessionStateSchema, SessionTransitionReasonSchema, SessionTransitionSchema, SessionTransitionPageSchema, ObservationPaceSchema, } from './sessions/index.js';
@@ -1,2 +1,2 @@
1
- export { SessionStateSchema, SessionTransitionReasonSchema, SessionTransitionSchema, SessionTransitionPageSchema, } from './types.js';
2
- export type { ISessionState, ISessionTransitionReason, ISessionTransition } from './types.js';
1
+ export { SessionStateSchema, SessionTransitionReasonSchema, SessionTransitionSchema, SessionTransitionPageSchema, ObservationPaceSchema, } from './types.js';
2
+ export type { ISessionState, ISessionTransitionReason, ISessionTransition, IObservationPace, } from './types.js';
@@ -1,2 +1,2 @@
1
1
  // session states and transitions
2
- export { SessionStateSchema, SessionTransitionReasonSchema, SessionTransitionSchema, SessionTransitionPageSchema, } from './types.js';
2
+ export { SessionStateSchema, SessionTransitionReasonSchema, SessionTransitionSchema, SessionTransitionPageSchema, ObservationPaceSchema, } from './types.js';
@@ -19,6 +19,11 @@ export declare const SessionTransitionReasonSchema: z.ZodEnum<{
19
19
  disappeared: "disappeared";
20
20
  }>;
21
21
  export type ISessionTransitionReason = z.infer<typeof SessionTransitionReasonSchema>;
22
+ export declare const ObservationPaceSchema: z.ZodEnum<{
23
+ live: "live";
24
+ background: "background";
25
+ }>;
26
+ export type IObservationPace = z.infer<typeof ObservationPaceSchema>;
22
27
  export declare const SessionTransitionSchema: z.ZodObject<{
23
28
  sequence: z.ZodNumber;
24
29
  provider: z.ZodString;
@@ -21,6 +21,8 @@ export const SessionTransitionReasonSchema = z.enum([
21
21
  'disappeared',
22
22
  'closed',
23
23
  ]);
24
+ // how often Claude's active sessions are polled: `live` every 5 seconds, `background` every 30
25
+ export const ObservationPaceSchema = z.enum(['live', 'background']);
24
26
  /*
25
27
  * One recorded state change, in sequence order. A managed session carries its HQ thread ID and
26
28
  * may have no native ID while it is created; an observed session has only its native identity.