jg-agent-hq 12.0.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 13.0.0
4
+
5
+ - Accept managed-session names of 1 through 64 characters for create, adopt, rename and managed-thread responses. Export `MAX_THREAD_NAME_LENGTH` from `jg-agent-hq/contracts`; suggestions and atomic collision suffixes use the same limit. The lowercase ASCII alphabet, first-character rule, case-insensitive uniqueness and immutable identities are unchanged.
6
+ - This is a breaking producer-contract change: 12.x consumers with strict 32-character response schemas reject longer names. Upgrade runtime and consumers together.
7
+ - Keep the 12.0.1 storage schema, action key and host `user_version` unchanged. Existing names are retained. Before downgrading to 12.x, inventory managed sessions through bounded pages and explicitly shorten every name longer than 32, resolving collisions through supported rename actions. See [package downgrade](docs/recovery.md#package-downgrade).
8
+
9
+ ## 12.0.1
10
+
11
+ - Refresh the cached metadata of an observed Codex session on `thread/name/updated` and reconnect, so a terminal rename or cleared name reaches `active-sessions`. Metadata-only changes preserve the session's activity time and append no state transition; active-list reads still make no native calls.
12
+ - Keep the 12.0.0 storage schema unchanged. Existing databases, sessions and snapshots remain compatible.
13
+
3
14
  ## 12.0.0
4
15
 
5
16
  To upgrade from 11.x:
package/README.md CHANGED
@@ -77,7 +77,9 @@ Durable state includes `action.key`, which must stay private and accompany its S
77
77
 
78
78
  Text and skill inputs 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. 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).
79
79
 
80
- Use `suggest-thread-name --topic "Build usage" --state-root <directory>` for an editable label. Creation adds a short ordinal suffix when a name is occupied. Actions and relationships retain immutable IDs.
80
+ 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.
81
+
82
+ 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).
81
83
 
82
84
  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.
83
85
 
package/api/README.md CHANGED
@@ -19,7 +19,7 @@ Intentional Node API failures use `Exception` from `jg-exception`. The [error re
19
19
 
20
20
  - Requests and responses: `HqRequestSchema`, `IHqRequest`, `IHqRequestInput`, `HqResponseSchema`, `IHqResponse`, `IHqResponseOf`, `RuntimeStatusSchema`, `IRuntimeStatus`, `IpcRequestSchema`, `IpcResponseSchema` and `IIpcResponse`; see [read commands](#read-commands).
21
21
  - Errors: `ErrorKindSchema`, `IErrorKind`, `PUBLIC_ERROR_CODES` and `PUBLIC_ERROR_MESSAGES`; see the [public error messages](../errors/README.md#public-error-messages).
22
- - Limits: `DEFAULT_PAGE_SIZE` and `MAX_PAGE_SIZE` for pages, `MAX_WORKSPACE_ROOTS` for one `threads` read, `MAX_ACTION_BYTES` for an action envelope, `MAX_WAIT_MS` for receipt waits and long-polls, and `MAX_ITEM_TEXT_LENGTH`, `MAX_ITEM_IMAGES` and `MAX_ITEM_IMAGE_BYTES` for items.
22
+ - Limits: `DEFAULT_PAGE_SIZE` and `MAX_PAGE_SIZE` for pages, `MAX_WORKSPACE_ROOTS` for one `threads` read, `MAX_THREAD_NAME_LENGTH` for complete managed-session names, `MAX_ACTION_BYTES` for an action envelope, `MAX_WAIT_MS` for receipt waits and long-polls, and `MAX_ITEM_TEXT_LENGTH`, `MAX_ITEM_IMAGES` and `MAX_ITEM_IMAGE_BYTES` for items.
23
23
  - Providers and models: `ProviderIdSchema`, `IProviderId`, `ProviderCapabilitySchema`, `IProviderCapability`, `ProviderCapabilitySetSchema`, `IProviderCapabilitySet`, `ProviderCapabilitiesSchema`, `IProviderCapabilities`, `ProviderStatusSchema`, `IProviderStatus`, `ProviderModelSchema`, `IProviderModel`, `ProviderModelsRequestSchema`, `IProviderModelsRequest`, `ProviderModelPageSchema` and `IProviderModelPage`; see [providers and capabilities](#providers-and-capabilities).
24
24
  - Sessions and history: `ThreadsPageSchema`, `IThreadsPage`, `ThreadSummarySchema`, `IThreadSummary`, `SessionTerminalSchema`, `ISessionTerminal`, `ActiveSessionsSchema`, `IActiveSessions`, `HistoryItemSchema`, `IHistoryItem`, `HistoryFileSchema`, `IHistoryFile`, `ItemDetailSchema`, `IItemDetail`, `ItemImageSchema`, `IItemImage`, `ItemImageMediaTypeSchema`, `IItemImageMediaType`, `LiveItemsSchema`, `NativeLineageSchema` and `INativeLineage`; see [session discovery](#session-discovery).
25
25
  - Session states: `SessionStateSchema`, `ISessionState`, `SessionTransitionReasonSchema`, `ISessionTransitionReason`, `SessionTransitionSchema`, `ISessionTransition`, `SessionTransitionPageSchema`, `ObservationPaceSchema` and `IObservationPace`; see [session states](#session-states).
@@ -263,7 +263,9 @@ Send `{ kind: 'action', action: { id, runtimeEpoch, command } }`. Generate one U
263
263
 
264
264
  Message and queue input is a closed union: `{ kind: 'text', text }` or `{ kind: 'skill', skillId, arguments }`. Text is nonempty and at most 65,536 characters; skill arguments may be empty and cap at 16,384 characters. The envelope's UTF-8 limit still applies. A selected skill is resolved through the target thread's current native catalog before admission. Unavailable, missing or disabled selections cannot dispatch. Normal text needs no catalog read. Steering retains its `text` field and exact active-turn target.
265
265
 
266
- Names use lowercase ASCII letters, digits and hyphens, start with a letter or digit, and have at most 32 characters. Names are unique without regard to case in one state directory. Creation and adoption resolve collisions atomically with ordinal suffixes such as `build-usage-2`, truncating the base to keep the complete name within 32 characters. Explicit rename rejects an occupied or pending name. Provider/native-session pairs remain unique. At most 32 native sessions are controlled concurrently; close idle sessions to release capacity. Native discovery remains independent of that limit. Confirm that other native CLI controllers are closed before adoption, resume or recovery. An unloaded native status cannot prove another CLI has stopped. The runtime provides exclusive coordination within one canonical state directory; it does not impose a global lock on independent CLIs. Recovery is permitted only after the producing runtime has stopped and its ownership evidence has been inspected.
266
+ Names use lowercase ASCII letters, digits and hyphens, start with a letter or digit, and have at most 64 characters, the public `MAX_THREAD_NAME_LENGTH` from `jg-agent-hq/contracts`. The same bound applies to create, adopt, rename and managed-thread responses. Names are unique without regard to case in one state directory. Creation and adoption resolve collisions atomically with ordinal suffixes such as `build-usage-2`, truncating the base to keep the complete name within 64 characters. Explicit rename rejects an occupied or pending name. Provider/native-session pairs remain unique. At most 32 native sessions are controlled concurrently; close idle sessions to release capacity. Native discovery remains independent of that limit. Confirm that other native CLI controllers are closed before adoption, resume or recovery. An unloaded native status cannot prove another CLI has stopped. The runtime provides exclusive coordination within one canonical state directory; it does not impose a global lock on independent CLIs. Recovery is permitted only after the producing runtime has stopped and its ownership evidence has been inspected.
267
+
268
+ Version 13 expands the producer contract: a 12.x consumer's strict 32-character schema rejects a response containing a longer managed name. Run matching runtime and consumer releases. Storage remains compatible with 12.0.1, but a package downgrade first requires shortening all longer managed names with supported rename actions and resolving collisions; see [package downgrade](../docs/recovery.md#package-downgrade).
267
269
 
268
270
  Codex may keep an idle native thread loaded after `thread/unsubscribe`, as when a terminal still holds it. An explicitly confirmed resume may reacquire that thread when its known managed control is inactive and managed, without settings overrides. Active native threads, uncertain managed ownership and already controlled idle sessions remain blocked. Other adoption and recovery checks are unchanged.
269
271
 
@@ -395,7 +397,7 @@ Every summary also carries `continuedIn`. When Claude Code moves a chat into a n
395
397
 
396
398
  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.
397
399
 
398
- `{ kind: 'active-sessions' }` returns every running and waiting session, managed and observed, and every idle session with `backgroundCommands` above 0, 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 managed 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 workspace, name and creation time are the ones its record kept from the runtime's first read of it, so a later rename in another client doesn't show; its update time is its state's change time, and its native state and lineage are unknown. The read itself asks no provider anything. A session outside the allowed workspaces is left out.
400
+ `{ kind: 'active-sessions' }` returns every running and waiting session, managed and observed, and every idle session with `backgroundCommands` above 0, 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 managed 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 workspace, name and creation time come from its latest confirmed metadata, refreshed once on a `thread/name/updated` notification and when the shared connection rejoins the session. A renamed or cleared name updates that record without changing the activity time or appending a state transition. Its update time is its state's change time, and its native state and lineage are unknown. The read itself asks no provider anything. A session outside the allowed workspaces is left out.
399
401
 
400
402
  `{ 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.
401
403
 
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { ACTION_PHASES, MAX_ACTION_BYTES } from '../constants.js';
2
+ import { ACTION_PHASES, MAX_ACTION_BYTES, MAX_THREAD_NAME_LENGTH } from '../constants.js';
3
3
  import { ProviderIdSchema } from '../providers/index.js';
4
4
  import { SessionSettingsSchema, TurnSettingsSchema } from '../configuration/index.js';
5
5
  import { MessageInputSchema, NativeSkillInputSchema } from '../skills/index.js';
@@ -15,7 +15,10 @@ export const PreparedInputSchema = z.object({
15
15
  });
16
16
  // explicit local intent; native RPC methods and arbitrary configuration are never accepted
17
17
  const ThreadIdSchema = z.uuid();
18
- const NameSchema = z.string().regex(/^[a-z0-9][a-z0-9-]{0,31}$/);
18
+ const NameSchema = z
19
+ .string()
20
+ .max(MAX_THREAD_NAME_LENGTH)
21
+ .regex(/^[a-z0-9][a-z0-9-]*$/);
19
22
  const TextSchema = z.string().min(1).max(65_536);
20
23
  const ActiveTargetFields = { threadId: ThreadIdSchema, expectedTurnId: NativeIdSchema };
21
24
  export const ActionCommandSchema = z.discriminatedUnion('kind', [
@@ -1,6 +1,7 @@
1
1
  export declare const DEFAULT_PAGE_SIZE = 32;
2
2
  export declare const MAX_PAGE_SIZE = 128;
3
3
  export declare const MAX_WORKSPACE_ROOTS = 64;
4
+ export declare const MAX_THREAD_NAME_LENGTH = 64;
4
5
  export declare const MAX_ACTION_BYTES = 32768;
5
6
  export declare const MAX_WAIT_MS = 30000;
6
7
  export declare const ACTION_PHASES: readonly ["create", "resume", "name", "turn", "steer", "interrupt", "clean", "close", "delete", "reply"];
@@ -3,6 +3,8 @@ export const DEFAULT_PAGE_SIZE = 32;
3
3
  export const MAX_PAGE_SIZE = 128;
4
4
  // the most folders one `threads` read lists, so its cursor carries every source's continuation
5
5
  export const MAX_WORKSPACE_ROOTS = 64;
6
+ // the complete editable managed-session label, including any collision suffix
7
+ export const MAX_THREAD_NAME_LENGTH = 64;
6
8
  // the largest action envelope HQ admits, in UTF-8 bytes of its JSON
7
9
  export const MAX_ACTION_BYTES = 32_768;
8
10
  // the longest a receipt wait or a long-poll waits for a change, in milliseconds
@@ -1,4 +1,4 @@
1
- export { ACTION_PHASES, DEFAULT_PAGE_SIZE, MAX_ITEM_IMAGE_BYTES, MAX_ITEM_IMAGES, MAX_ITEM_TEXT_LENGTH, MAX_ACTION_BYTES, MAX_PAGE_SIZE, MAX_WAIT_MS, MAX_WORKSPACE_ROOTS, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
1
+ export { ACTION_PHASES, DEFAULT_PAGE_SIZE, MAX_ITEM_IMAGE_BYTES, MAX_ITEM_IMAGES, MAX_ITEM_TEXT_LENGTH, MAX_ACTION_BYTES, MAX_PAGE_SIZE, MAX_THREAD_NAME_LENGTH, MAX_WAIT_MS, MAX_WORKSPACE_ROOTS, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
2
2
  export { HqRequestSchema, SessionTerminalSchema, ThreadSummarySchema, ActiveSessionsSchema, ThreadsPageSchema, HistoryFileSchema, HistoryItemSchema, ItemImageMediaTypeSchema, ItemDetailSchema, ItemImageSchema, LiveItemsSchema, UsageWindowSchema, UsageSnapshotSchema, UsageCreditsSchema, UsageResetCreditsSchema, UsageWindowScopeSchema, RuntimeStatusSchema, HqResponseSchema, ErrorKindSchema, IpcRequestSchema, IpcResponseSchema, } from './types.js';
3
3
  export { ProviderIdSchema, ProviderCapabilitySchema, ProviderCapabilitySetSchema, ProviderCapabilitiesSchema, ProviderStatusSchema, } from './providers/index.js';
4
4
  export type { IProviderId, IProviderCapability, IProviderCapabilitySet, IProviderCapabilities, IProviderStatus, } from './providers/index.js';
@@ -1,5 +1,5 @@
1
1
  // constants
2
- export { ACTION_PHASES, DEFAULT_PAGE_SIZE, MAX_ITEM_IMAGE_BYTES, MAX_ITEM_IMAGES, MAX_ITEM_TEXT_LENGTH, MAX_ACTION_BYTES, MAX_PAGE_SIZE, MAX_WAIT_MS, MAX_WORKSPACE_ROOTS, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
2
+ export { ACTION_PHASES, DEFAULT_PAGE_SIZE, MAX_ITEM_IMAGE_BYTES, MAX_ITEM_IMAGES, MAX_ITEM_TEXT_LENGTH, MAX_ACTION_BYTES, MAX_PAGE_SIZE, MAX_THREAD_NAME_LENGTH, MAX_WAIT_MS, MAX_WORKSPACE_ROOTS, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
3
3
  // wire contracts
4
4
  export { HqRequestSchema, SessionTerminalSchema, ThreadSummarySchema, ActiveSessionsSchema, ThreadsPageSchema, HistoryFileSchema, HistoryItemSchema, ItemImageMediaTypeSchema, ItemDetailSchema, ItemImageSchema, LiveItemsSchema, UsageWindowSchema, UsageSnapshotSchema, UsageCreditsSchema, UsageResetCreditsSchema, UsageWindowScopeSchema, RuntimeStatusSchema, HqResponseSchema, ErrorKindSchema, IpcRequestSchema, IpcResponseSchema, } from './types.js';
5
5
  // provider identity and capability discovery
@@ -21,8 +21,8 @@ export const createCodexProviderFactory = (extraSkillRoots, daemonLauncher) => (
21
21
  async create(context) {
22
22
  const native = await createCodexProvider(extraSkillRoots, daemonLauncher);
23
23
  /*
24
- * Each session's workspace, name and creation time, read once, or null for one that isn't
25
- * observed: Codex doesn't save it, or it runs outside the allowed workspaces.
24
+ * Each session's workspace, name and creation time, refreshed on reconnect and rename, or
25
+ * null for one Codex doesn't save or that runs outside the allowed workspaces.
26
26
  */
27
27
  const observedThreads = new Map();
28
28
  let observations = Promise.resolve();
@@ -7,4 +7,4 @@ export declare const toProviderThread: (thread: INativeThread) => IProviderThrea
7
7
  * Converts Codex protocol events to provider-bound evidence without owning action ledger state.
8
8
  * @returns The callbacks installed on the native Codex connection.
9
9
  */
10
- export declare const createCodexEvents: (native: ICodexProvider, events: IAgentProviderEvents, observeSession: (nativeId: string, state: ISessionState) => void, observeLoaded: () => void) => ICodexEvents;
10
+ export declare const createCodexEvents: (native: ICodexProvider, events: IAgentProviderEvents, observeSession: (nativeId: string, state: ISessionState | null) => void, observeLoaded: () => void) => ICodexEvents;
@@ -146,6 +146,11 @@ export const createCodexEvents = (native, events, observeSession, observeLoaded)
146
146
  const { threadId, status } = parseNative(z.object({ threadId: NativeIdSchema, status: NativeThreadStatusSchema }), params);
147
147
  observeSession(threadId, toSessionState(status));
148
148
  }
149
+ else if (method === 'thread/name/updated') {
150
+ const { threadId } = parseNative(z.object({ threadId: NativeIdSchema }), params);
151
+ // read current metadata once, including a cleared name, without inventing a state change
152
+ observeSession(threadId, null);
153
+ }
149
154
  else if (method === 'thread/settings/updated') {
150
155
  // the thread record leaves the tier out, so a turn that changes it is followed here
151
156
  const { threadId, threadSettings } = parseNative(z.object({
@@ -1,12 +1,13 @@
1
+ import { MAX_THREAD_NAME_LENGTH } from '../../contracts/index.js';
1
2
  /** Suggests a short, editable ASCII label without treating it as a session identity. */
2
3
  export const suggestThreadName = (topic) => topic
3
4
  .toLowerCase()
4
5
  .replace(/[^a-z0-9]+/g, '-')
5
6
  .replace(/^-+|-+$/g, '')
6
- .slice(0, 32)
7
+ .slice(0, MAX_THREAD_NAME_LENGTH)
7
8
  .replace(/-+$/g, '') || 'session';
8
9
  /** Adds an ordinal while keeping the complete label within the native-facing limit. */
9
10
  export const suffixThreadName = (name, ordinal) => {
10
11
  const suffix = `-${ordinal}`;
11
- return `${name.slice(0, 32 - suffix.length).replace(/-+$/g, '')}${suffix}`;
12
+ return `${name.slice(0, MAX_THREAD_NAME_LENGTH - suffix.length).replace(/-+$/g, '')}${suffix}`;
12
13
  };
@@ -163,7 +163,7 @@ const toActiveSummary = async (record, resolveRoot, claude) => {
163
163
  continuedIn: null,
164
164
  };
165
165
  }
166
- // an observed Codex session keeps what the first read of it found
166
+ // an observed Codex session keeps its latest confirmed metadata
167
167
  if (!record.observed)
168
168
  return null;
169
169
  const workspaceRoot = await resolveRoot(record.observed.workspaceRoot);
@@ -4,7 +4,7 @@ export const RETENTION_MS = 604_800_000;
4
4
  * Running and waiting sessions by their latest state change, with the idle ones among the included
5
5
  * sessions, which run background commands. A managed thread is active only while a runtime binds
6
6
  * it, which its runtime epoch index finds; a stopping one reports the state it stops, from its
7
- * last transition. An observed Codex session carries what the first read of it found, and an
7
+ * last transition. An observed Codex session carries its latest confirmed metadata, and an
8
8
  * observed Claude session joins its indexed transcript, if any, by session ID. The included
9
9
  * sessions are one JSON array of [provider, native ID] pairs.
10
10
  */
@@ -9,11 +9,9 @@ export declare class SessionsModel {
9
9
  /** Uses the existing worker connection without owning its lifecycle. */
10
10
  constructor(database: DatabaseSync, statements: IStatements);
11
11
  /**
12
- * Records the states of sessions HQ doesn't manage, and on a session's first record what its
13
- * provider's first read of it found; the schema's triggers append the transitions, each with the
14
- * session's folder. A Claude session's folder follows the poll's listing, while a Codex session
15
- * keeps the one its first read found. A complete observation also closes every open session of
16
- * that provider it omits.
12
+ * Records the states and latest metadata of sessions HQ doesn't manage. Metadata-only changes
13
+ * preserve the activity time and append no state transition. A complete observation also closes
14
+ * every open session of that provider it omits.
17
15
  */
18
16
  observe(provider: IProviderId, sessions: IObservedSession[], isComplete: boolean): void;
19
17
  /** Marks a provider's open observed sessions unknown after its native connection was lost. */
@@ -9,11 +9,9 @@ export class SessionsModel {
9
9
  this.__statements = statements;
10
10
  }
11
11
  /**
12
- * Records the states of sessions HQ doesn't manage, and on a session's first record what its
13
- * provider's first read of it found; the schema's triggers append the transitions, each with the
14
- * session's folder. A Claude session's folder follows the poll's listing, while a Codex session
15
- * keeps the one its first read found. A complete observation also closes every open session of
16
- * that provider it omits.
12
+ * Records the states and latest metadata of sessions HQ doesn't manage. Metadata-only changes
13
+ * preserve the activity time and append no state transition. A complete observation also closes
14
+ * every open session of that provider it omits.
17
15
  */
18
16
  observe(provider, sessions, isComplete) {
19
17
  const now = Date.now();
@@ -32,7 +30,21 @@ export class SessionsModel {
32
30
  if ((session.state === 'closed' || session.state === 'unknown') &&
33
31
  !this.__statements.get('SELECT 1 FROM agent_hq_observed_session WHERE provider = ? AND native_id = ?', provider, session.nativeId))
34
32
  continue;
35
- this.__statements.run('INSERT INTO agent_hq_observed_session (provider, native_id, state, observed_at, workspace_root, name, created_at) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (provider, native_id) DO UPDATE SET state = excluded.state, observed_at = excluded.observed_at, workspace_root = coalesce(excluded.workspace_root, agent_hq_observed_session.workspace_root) WHERE agent_hq_observed_session.state != excluded.state', provider, session.nativeId, session.state, now, session.thread?.workspaceRoot ?? session.workspaceRoot ?? null, session.thread?.name ?? null, session.thread?.createdAt ?? null);
33
+ this.__statements.run(`INSERT INTO agent_hq_observed_session (provider, native_id, state, observed_at, workspace_root, name, created_at)
34
+ VALUES (?, ?, ?, ?, ?, ?, ?)
35
+ ON CONFLICT (provider, native_id) DO UPDATE SET
36
+ state = excluded.state,
37
+ observed_at = CASE WHEN agent_hq_observed_session.state != excluded.state
38
+ THEN excluded.observed_at ELSE agent_hq_observed_session.observed_at END,
39
+ workspace_root = coalesce(excluded.workspace_root, agent_hq_observed_session.workspace_root),
40
+ name = CASE WHEN excluded.created_at IS NOT NULL
41
+ THEN excluded.name ELSE agent_hq_observed_session.name END,
42
+ created_at = coalesce(excluded.created_at, agent_hq_observed_session.created_at)
43
+ WHERE agent_hq_observed_session.state != excluded.state
44
+ OR agent_hq_observed_session.workspace_root IS NOT coalesce(excluded.workspace_root, agent_hq_observed_session.workspace_root)
45
+ OR (excluded.created_at IS NOT NULL AND
46
+ (agent_hq_observed_session.name IS NOT excluded.name
47
+ OR agent_hq_observed_session.created_at IS NOT excluded.created_at))`, provider, session.nativeId, session.state, now, session.thread?.workspaceRoot ?? session.workspaceRoot ?? null, session.thread?.name ?? null, session.thread?.createdAt ?? null);
36
48
  }
37
49
  if (isComplete) {
38
50
  const listed = new Set(sessions.map((session) => session.nativeId));
package/docs/recovery.md CHANGED
@@ -24,6 +24,12 @@ Recover repositories and native files separately. Source paths are retained as e
24
24
 
25
25
  Roll back by restoring an earlier snapshot into a new recovery workspace; never overwrite the current state root. A snapshot from another schema is refused with an error naming the package version that wrote it, so restore it with that version. Rollback accepts losing every change made after that snapshot, including host changes and later runtime receipts. Reconcile native ownership before enabling work.
26
26
 
27
+ ## Package downgrade
28
+
29
+ Version 13.0.0 uses the same storage schema as 12.0.1, including the existing action key and host `user_version`; startup accepts that schema without migration or reset. The writing package version is diagnostic. Snapshot capture and restore retain longer managed names under the same schema.
30
+
31
+ The expanded name contract is still a breaking change for older consumers: 12.x strict schemas reject managed names longer than 32 characters. Before installing 12.x, pause new session creation and naming actions, inventory every managed session using bounded `managed-threads` pages for each workspace, and use 13.x supported `thread-rename` actions to shorten each longer name. Resolve occupied or pending-name conflicts and verify the complete inventory contains no name longer than 32 before switching runtime and consumers together. Renaming retains the managed and native identities. Do not edit the database or stamp, reset storage, or replay session creation to make a downgrade work. Keep the existing database and `action.key` together.
32
+
27
33
  ## Off-machine durability
28
34
 
29
35
  The development helper examples/shared-storage.ts demonstrates a host-owned application table, maintenance, capture and offline restore using public exports. Capture already returns verified metadata, so the helper avoids an immediate extra full-database inspection. Its application transaction commits independently of capture. Inspect the restored values before starting a recovered runtime with explicitly chosen roots.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jg-agent-hq",
3
- "version": "12.0.0",
3
+ "version": "13.0.0",
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",