jg-agent-hq 12.0.0 → 12.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.
- package/CHANGELOG.md +5 -0
- package/api/README.md +1 -1
- package/dist/providers/codex/adapter.js +2 -2
- package/dist/providers/codex/events.d.ts +1 -1
- package/dist/providers/codex/events.js +5 -0
- package/dist/sessions/sessions.js +1 -1
- package/dist/store/sessions/constants.js +1 -1
- package/dist/store/sessions/sessions.model.d.ts +3 -5
- package/dist/store/sessions/sessions.model.js +18 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 12.0.1
|
|
4
|
+
|
|
5
|
+
- 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.
|
|
6
|
+
- Keep the 12.0.0 storage schema unchanged. Existing databases, sessions and snapshots remain compatible.
|
|
7
|
+
|
|
3
8
|
## 12.0.0
|
|
4
9
|
|
|
5
10
|
To upgrade from 11.x:
|
package/api/README.md
CHANGED
|
@@ -395,7 +395,7 @@ Every summary also carries `continuedIn`. When Claude Code moves a chat into a n
|
|
|
395
395
|
|
|
396
396
|
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
397
|
|
|
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
|
|
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 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
399
|
|
|
400
400
|
`{ 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
401
|
|
|
@@ -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,
|
|
25
|
-
*
|
|
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({
|
|
@@ -163,7 +163,7 @@ const toActiveSummary = async (record, resolveRoot, claude) => {
|
|
|
163
163
|
continuedIn: null,
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
-
// an observed Codex session keeps
|
|
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
|
|
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
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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(
|
|
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/package.json
CHANGED