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
@@ -205,7 +205,7 @@ CREATE TABLE hq_claude_entry (
205
205
  workspace_root TEXT NOT NULL, native_id TEXT NOT NULL, uuid TEXT NOT NULL,
206
206
  parent_uuid TEXT, turn_id TEXT NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
207
207
  created_at INTEGER NOT NULL, is_visible INTEGER NOT NULL,
208
- item_kind TEXT NOT NULL CHECK (item_kind IN ('user-message','agent-message','command','tool','file-change','unsupported')),
208
+ item_kind TEXT NOT NULL CHECK (item_kind IN ('user-message','agent-message','command','tool','file-change','notice','unsupported')),
209
209
  is_current INTEGER NOT NULL, turn_start_offset INTEGER, anchor_id TEXT,
210
210
  CONSTRAINT hq_pk_ce__workspace_root_native_id_uuid PRIMARY KEY (workspace_root, native_id, uuid),
211
211
  CONSTRAINT hq_fk_ce__workspace_root_native_id FOREIGN KEY (workspace_root, native_id)
@@ -1 +1,3 @@
1
1
  export { SessionsModel } from './sessions.model.js';
2
+ export { ActiveSessionRecordSchema, ActiveSessionRecordsSchema } from './types.js';
3
+ export type { IActiveSessionRecord } from './types.js';
@@ -1,2 +1,4 @@
1
1
  // worker-owned observed sessions and transitions
2
2
  export { SessionsModel } from './sessions.model.js';
3
+ // active session records
4
+ export { ActiveSessionRecordSchema, ActiveSessionRecordsSchema } from './types.js';
@@ -1,5 +1,6 @@
1
1
  import type { DatabaseSync } from 'node:sqlite';
2
2
  import { type ISessionState, type ISessionTransition } from '../../contracts/index.js';
3
+ import { type IActiveSessionRecord } from './types.js';
3
4
  /** Owns observed session states and the session transition log on the SQLite worker. */
4
5
  export declare class SessionsModel {
5
6
  private readonly __database;
@@ -20,6 +21,14 @@ export declare class SessionsModel {
20
21
  nativeId: string;
21
22
  state: ISessionState;
22
23
  }[];
24
+ /**
25
+ * Reads running and waiting sessions, managed and observed, newest state change first.
26
+ * @returns At most `limit` records and whether more sessions are active.
27
+ */
28
+ active(limit: number): {
29
+ data: IActiveSessionRecord[];
30
+ isTruncated: boolean;
31
+ };
23
32
  /** Reads transitions after a sequence, in order, with one row of lookahead for continuation. */
24
33
  transitions(afterSequence: number, limit: number): {
25
34
  data: ISessionTransition[];
@@ -1,7 +1,41 @@
1
1
  import { z } from 'zod';
2
2
  import { SessionStateSchema, SessionTransitionSchema, } from '../../contracts/index.js';
3
+ import { ActiveSessionRecordSchema } from './types.js';
3
4
  // closed observed sessions are forgotten after the same seven days that transitions are kept
4
5
  const RETENTION_MS = 604_800_000;
6
+ const ActiveRowSchema = z.object({
7
+ provider: z.string(),
8
+ native_id: z.string(),
9
+ state: z.string(),
10
+ changed_at: z.number().int(),
11
+ thread: z.string().nullable(),
12
+ history: z.string().nullable(),
13
+ });
14
+ /*
15
+ * Running and waiting sessions by their latest state change. A stopping managed thread reports the
16
+ * state it stops, from its last transition, and an observed Claude session joins its indexed
17
+ * transcript, if any, by session ID.
18
+ */
19
+ const ACTIVE_SESSIONS = `SELECT provider, native_id, state, changed_at, thread, history FROM (
20
+ SELECT hq_thread.provider, hq_thread.native_id,
21
+ coalesce(map.session_state, (SELECT state FROM hq_session_transition WHERE thread_id = hq_thread.id ORDER BY sequence DESC LIMIT 1), 'unknown') AS state,
22
+ coalesce((SELECT recorded_at FROM hq_session_transition WHERE thread_id = hq_thread.id ORDER BY sequence DESC LIMIT 1), hq_thread.updated_at) AS changed_at,
23
+ json_object('id', hq_thread.id, 'ownership', hq_thread.ownership, 'name', hq_thread.name,
24
+ 'workspaceRoot', hq_thread.workspace_root, 'nativeLineage', json(hq_thread.native_lineage),
25
+ 'createdAt', hq_thread.created_at, 'updatedAt', hq_thread.updated_at) AS thread,
26
+ NULL AS history
27
+ FROM hq_thread INNER JOIN hq_session_state_map AS map ON map.thread_state = hq_thread.state
28
+ WHERE hq_thread.native_id IS NOT NULL AND (map.session_state IS NULL OR map.session_state IN ('running', 'waiting'))
29
+ UNION ALL
30
+ SELECT observed.provider, observed.native_id, observed.state, observed.observed_at, NULL,
31
+ CASE WHEN observed.provider = 'claude' THEN (
32
+ SELECT json_object('name', name, 'createdAt', created_at, 'updatedAt', updated_at,
33
+ 'isSupported', json(CASE WHEN supported = 1 THEN 'true' ELSE 'false' END))
34
+ FROM hq_claude_file WHERE native_id = observed.native_id AND workspace_state = 'matching'
35
+ ORDER BY updated_at DESC LIMIT 1
36
+ ) END
37
+ FROM hq_observed_session AS observed WHERE observed.state IN ('running', 'waiting')
38
+ ) WHERE state IN ('running', 'waiting') ORDER BY changed_at DESC, native_id DESC LIMIT ?`;
5
39
  const TransitionRowSchema = z.object({
6
40
  sequence: z.number().int(),
7
41
  provider: z.string(),
@@ -80,6 +114,27 @@ export class SessionsModel {
80
114
  return row ? [{ nativeId, state: SessionStateSchema.parse(row.state) }] : [];
81
115
  });
82
116
  }
117
+ /**
118
+ * Reads running and waiting sessions, managed and observed, newest state change first.
119
+ * @returns At most `limit` records and whether more sessions are active.
120
+ */
121
+ active(limit) {
122
+ const rows = this.__database
123
+ .prepare(ACTIVE_SESSIONS)
124
+ .all(limit + 1)
125
+ .map((row) => ActiveRowSchema.parse(row));
126
+ return {
127
+ data: rows.slice(0, limit).map((row) => ActiveSessionRecordSchema.parse({
128
+ provider: row.provider,
129
+ nativeId: row.native_id,
130
+ state: row.state,
131
+ changedAt: row.changed_at,
132
+ thread: row.thread === null ? null : JSON.parse(row.thread),
133
+ history: row.history === null ? null : JSON.parse(row.history),
134
+ })),
135
+ isTruncated: rows.length > limit,
136
+ };
137
+ }
83
138
  /** Reads transitions after a sequence, in order, with one row of lookahead for continuation. */
84
139
  transitions(afterSequence, limit) {
85
140
  const rows = this.__database
@@ -0,0 +1,67 @@
1
+ import { z } from 'zod';
2
+ export declare const ActiveSessionRecordSchema: z.ZodObject<{
3
+ provider: z.ZodString;
4
+ nativeId: z.ZodString;
5
+ state: z.ZodEnum<{
6
+ running: "running";
7
+ waiting: "waiting";
8
+ }>;
9
+ changedAt: z.ZodNumber;
10
+ thread: z.ZodNullable<z.ZodObject<{
11
+ id: z.ZodUUID;
12
+ ownership: z.ZodEnum<{
13
+ managed: "managed";
14
+ uncertain: "uncertain";
15
+ }>;
16
+ name: z.ZodString;
17
+ workspaceRoot: z.ZodString;
18
+ nativeLineage: z.ZodNullable<z.ZodObject<{
19
+ sessionId: z.ZodNullable<z.ZodString>;
20
+ parentThreadId: z.ZodNullable<z.ZodString>;
21
+ forkedFromId: z.ZodNullable<z.ZodString>;
22
+ }, z.core.$strip>>;
23
+ createdAt: z.ZodNumber;
24
+ updatedAt: z.ZodNumber;
25
+ }, z.core.$strip>>;
26
+ history: z.ZodNullable<z.ZodObject<{
27
+ name: z.ZodNullable<z.ZodString>;
28
+ createdAt: z.ZodNumber;
29
+ updatedAt: z.ZodNumber;
30
+ isSupported: z.ZodBoolean;
31
+ }, z.core.$strip>>;
32
+ }, z.core.$strip>;
33
+ export type IActiveSessionRecord = z.infer<typeof ActiveSessionRecordSchema>;
34
+ export declare const ActiveSessionRecordsSchema: z.ZodObject<{
35
+ data: z.ZodArray<z.ZodObject<{
36
+ provider: z.ZodString;
37
+ nativeId: z.ZodString;
38
+ state: z.ZodEnum<{
39
+ running: "running";
40
+ waiting: "waiting";
41
+ }>;
42
+ changedAt: z.ZodNumber;
43
+ thread: z.ZodNullable<z.ZodObject<{
44
+ id: z.ZodUUID;
45
+ ownership: z.ZodEnum<{
46
+ managed: "managed";
47
+ uncertain: "uncertain";
48
+ }>;
49
+ name: z.ZodString;
50
+ workspaceRoot: z.ZodString;
51
+ nativeLineage: z.ZodNullable<z.ZodObject<{
52
+ sessionId: z.ZodNullable<z.ZodString>;
53
+ parentThreadId: z.ZodNullable<z.ZodString>;
54
+ forkedFromId: z.ZodNullable<z.ZodString>;
55
+ }, z.core.$strip>>;
56
+ createdAt: z.ZodNumber;
57
+ updatedAt: z.ZodNumber;
58
+ }, z.core.$strip>>;
59
+ history: z.ZodNullable<z.ZodObject<{
60
+ name: z.ZodNullable<z.ZodString>;
61
+ createdAt: z.ZodNumber;
62
+ updatedAt: z.ZodNumber;
63
+ isSupported: z.ZodBoolean;
64
+ }, z.core.$strip>>;
65
+ }, z.core.$strip>>;
66
+ isTruncated: z.ZodBoolean;
67
+ }, z.core.$strip>;
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ import { NativeLineageSchema, SessionStateSchema } from '../../contracts/index.js';
3
+ /*
4
+ * One running or waiting session as the store knows it. A managed session carries its thread,
5
+ * and an observed Claude session its history index entry when its transcript is indexed; an
6
+ * observed session's workspace is resolved outside the store.
7
+ */
8
+ export const ActiveSessionRecordSchema = z.object({
9
+ provider: z.string(),
10
+ nativeId: z.string(),
11
+ state: SessionStateSchema.extract(['running', 'waiting']),
12
+ changedAt: z.number().int(),
13
+ thread: z
14
+ .object({
15
+ id: z.uuid(),
16
+ ownership: z.enum(['managed', 'uncertain']),
17
+ name: z.string(),
18
+ workspaceRoot: z.string(),
19
+ nativeLineage: NativeLineageSchema.nullable(),
20
+ createdAt: z.number().int(),
21
+ updatedAt: z.number().int(),
22
+ })
23
+ .nullable(),
24
+ history: z
25
+ .object({
26
+ name: z.string().nullable(),
27
+ createdAt: z.number().int(),
28
+ updatedAt: z.number().int(),
29
+ isSupported: z.boolean(),
30
+ })
31
+ .nullable(),
32
+ });
33
+ export const ActiveSessionRecordsSchema = z.object({
34
+ data: z.array(ActiveSessionRecordSchema).max(128),
35
+ isTruncated: z.boolean(),
36
+ });
@@ -9,6 +9,7 @@ import { BrowserReceiptSchema, ActionReceiptSchema, ActionPlanContextSchema, Man
9
9
  import { ClaudeHistoryReadSchema } from '../providers/claude/history/index.js';
10
10
  import { PlanWriteIntentSchema, PlanProjectionResultSchema } from '../plans/index.js';
11
11
  import { AdmissionResultSchema, ObservationResultSchema, DispatchSchema, ManagedThreadPageSchema, ActionPageSchema, LifecyclePageSchema, ApprovalIdentitySchema, ApprovalPageSchema, } from './control/index.js';
12
+ import { ActiveSessionRecordsSchema } from './sessions/index.js';
12
13
  import { StoreRequestSchema, StoreResponseSchema, } from './types.js';
13
14
  /**
14
15
  * Owns SQLite in one dedicated worker; requests and queued payloads are bounded.
@@ -24,6 +25,8 @@ export const createStore = async (databasePath, runtimeEpoch, actionKey) => {
24
25
  execArgv: process.execArgv.filter((argument, index, arguments_) => argument !== '--input-type' &&
25
26
  !argument.startsWith('--input-type=') &&
26
27
  arguments_[index - 1] !== '--input-type'),
28
+ // indexing a large transcript otherwise grows the young generation to V8's default maximum
29
+ resourceLimits: { maxYoungGenerationSizeMb: 16 },
27
30
  workerData: { databasePath, runtimeEpoch, actionKey },
28
31
  });
29
32
  let hasExited = false;
@@ -198,6 +201,7 @@ export const createStore = async (databasePath, runtimeEpoch, actionKey) => {
198
201
  },
199
202
  getSessionStates: (provider, nativeIds) => request({ kind: 'sessions-states', provider, nativeIds }, z.array(z.object({ nativeId: z.string(), state: SessionStateSchema }))),
200
203
  listSessionTransitions: (afterSequence, limit) => request({ kind: 'session-transitions', afterSequence, limit }, SessionTransitionPageSchema),
204
+ listActiveSessions: (limit) => request({ kind: 'sessions-active', limit }, ActiveSessionRecordsSchema),
201
205
  getThreadPlan: (threadId) => request({ kind: 'thread-plan-read', threadId }, ActionPlanContextSchema.nullable()),
202
206
  getPlanThreads: (directory) => request({ kind: 'plan-threads', directory }, z.array(z.uuid()).max(32)),
203
207
  peekQueued: (threadId) => request({ kind: 'queue-peek', threadId }, ActionReceiptSchema.nullable()),
@@ -132,6 +132,9 @@ const startWorker = async () => {
132
132
  case 'session-transitions':
133
133
  result = sessions.transitions(command.afterSequence, command.limit);
134
134
  break;
135
+ case 'sessions-active':
136
+ result = sessions.active(command.limit);
137
+ break;
135
138
  case 'thread-plan-read':
136
139
  result = plans.getThreadPlan(command.threadId);
137
140
  break;
@@ -9,6 +9,7 @@ import type { IClaudeHistoryRead } from '../providers/claude/history/index.js';
9
9
  import { type IStorageDescriptor } from '../storage/index.js';
10
10
  import { type IPlanWriteIntent, type IPlanProjection } from '../plans/index.js';
11
11
  import { type IAdmission, type INativeOutcome, type INativeObservation, type IControlPage, type IApprovalPageRequest, type IEventPage, type IApprovalRecord, type IAdmissionResult, type IDispatch, type IObservationResult } from './control/index.js';
12
+ import type { IActiveSessionRecord } from './sessions/index.js';
12
13
  export declare const StoreCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
13
14
  kind: z.ZodLiteral<"agent-identity">;
14
15
  query: z.ZodObject<{
@@ -1239,6 +1240,7 @@ export declare const StoreCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1239
1240
  tool: "tool";
1240
1241
  "agent-message": "agent-message";
1241
1242
  "file-change": "file-change";
1243
+ notice: "notice";
1242
1244
  }>>>;
1243
1245
  taskId: z.ZodUUID;
1244
1246
  }, z.core.$strict>;
@@ -2048,6 +2050,7 @@ export declare const StoreCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2048
2050
  tool: "tool";
2049
2051
  "agent-message": "agent-message";
2050
2052
  "file-change": "file-change";
2053
+ notice: "notice";
2051
2054
  }>>>;
2052
2055
  limit: z.ZodDefault<z.ZodNumber>;
2053
2056
  cursor: z.ZodOptional<z.ZodString>;
@@ -2340,6 +2343,8 @@ export declare const StoreCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2340
2343
  limit: z.ZodDefault<z.ZodNumber>;
2341
2344
  cursor: z.ZodOptional<z.ZodString>;
2342
2345
  turnId: z.ZodOptional<z.ZodString>;
2346
+ nativeItemId: z.ZodOptional<z.ZodString>;
2347
+ textLimit: z.ZodDefault<z.ZodNumber>;
2343
2348
  provider: z.ZodString;
2344
2349
  workspaceRoot: z.ZodString;
2345
2350
  nativeId: z.ZodString;
@@ -2698,6 +2703,14 @@ export declare const StoreCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2698
2703
  kind: z.ZodLiteral<"session-states">;
2699
2704
  afterSequence: z.ZodDefault<z.ZodNumber>;
2700
2705
  limit: z.ZodDefault<z.ZodNumber>;
2706
+ }, z.core.$strict>, z.ZodObject<{
2707
+ kind: z.ZodLiteral<"active-sessions">;
2708
+ }, z.core.$strict>, z.ZodObject<{
2709
+ kind: z.ZodLiteral<"observation-pace">;
2710
+ pace: z.ZodEnum<{
2711
+ live: "live";
2712
+ background: "background";
2713
+ }>;
2701
2714
  }, z.core.$strict>], "kind">;
2702
2715
  }, z.core.$strict>, z.ZodObject<{
2703
2716
  kind: z.ZodLiteral<"remember">;
@@ -2770,6 +2783,9 @@ export declare const StoreCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2770
2783
  kind: z.ZodLiteral<"session-transitions">;
2771
2784
  afterSequence: z.ZodNumber;
2772
2785
  limit: z.ZodNumber;
2786
+ }, z.core.$strict>, z.ZodObject<{
2787
+ kind: z.ZodLiteral<"sessions-active">;
2788
+ limit: z.ZodNumber;
2773
2789
  }, z.core.$strict>, z.ZodObject<{
2774
2790
  kind: z.ZodLiteral<"thread-plan-read">;
2775
2791
  threadId: z.ZodUUID;
@@ -4712,6 +4728,7 @@ export declare const StoreRequestSchema: z.ZodObject<{
4712
4728
  tool: "tool";
4713
4729
  "agent-message": "agent-message";
4714
4730
  "file-change": "file-change";
4731
+ notice: "notice";
4715
4732
  }>>>;
4716
4733
  taskId: z.ZodUUID;
4717
4734
  }, z.core.$strict>;
@@ -5521,6 +5538,7 @@ export declare const StoreRequestSchema: z.ZodObject<{
5521
5538
  tool: "tool";
5522
5539
  "agent-message": "agent-message";
5523
5540
  "file-change": "file-change";
5541
+ notice: "notice";
5524
5542
  }>>>;
5525
5543
  limit: z.ZodDefault<z.ZodNumber>;
5526
5544
  cursor: z.ZodOptional<z.ZodString>;
@@ -5813,6 +5831,8 @@ export declare const StoreRequestSchema: z.ZodObject<{
5813
5831
  limit: z.ZodDefault<z.ZodNumber>;
5814
5832
  cursor: z.ZodOptional<z.ZodString>;
5815
5833
  turnId: z.ZodOptional<z.ZodString>;
5834
+ nativeItemId: z.ZodOptional<z.ZodString>;
5835
+ textLimit: z.ZodDefault<z.ZodNumber>;
5816
5836
  provider: z.ZodString;
5817
5837
  workspaceRoot: z.ZodString;
5818
5838
  nativeId: z.ZodString;
@@ -6171,6 +6191,14 @@ export declare const StoreRequestSchema: z.ZodObject<{
6171
6191
  kind: z.ZodLiteral<"session-states">;
6172
6192
  afterSequence: z.ZodDefault<z.ZodNumber>;
6173
6193
  limit: z.ZodDefault<z.ZodNumber>;
6194
+ }, z.core.$strict>, z.ZodObject<{
6195
+ kind: z.ZodLiteral<"active-sessions">;
6196
+ }, z.core.$strict>, z.ZodObject<{
6197
+ kind: z.ZodLiteral<"observation-pace">;
6198
+ pace: z.ZodEnum<{
6199
+ live: "live";
6200
+ background: "background";
6201
+ }>;
6174
6202
  }, z.core.$strict>], "kind">;
6175
6203
  }, z.core.$strict>, z.ZodObject<{
6176
6204
  kind: z.ZodLiteral<"remember">;
@@ -6243,6 +6271,9 @@ export declare const StoreRequestSchema: z.ZodObject<{
6243
6271
  kind: z.ZodLiteral<"session-transitions">;
6244
6272
  afterSequence: z.ZodNumber;
6245
6273
  limit: z.ZodNumber;
6274
+ }, z.core.$strict>, z.ZodObject<{
6275
+ kind: z.ZodLiteral<"sessions-active">;
6276
+ limit: z.ZodNumber;
6246
6277
  }, z.core.$strict>, z.ZodObject<{
6247
6278
  kind: z.ZodLiteral<"thread-plan-read">;
6248
6279
  threadId: z.ZodUUID;
@@ -7165,6 +7196,15 @@ export type IStore = {
7165
7196
  data: ISessionTransition[];
7166
7197
  hasMore: boolean;
7167
7198
  }>;
7199
+ /** Reads running and waiting sessions, managed and observed, newest state change first.
7200
+ * @returns At most `limit` records and whether more sessions are active.
7201
+ * @throws
7202
+ * - JG_AGENT_HQ_STORE_FAILED: The HQ store failed
7203
+ */
7204
+ listActiveSessions(limit: number): Promise<{
7205
+ data: IActiveSessionRecord[];
7206
+ isTruncated: boolean;
7207
+ }>;
7168
7208
  /** Reads a thread's exact current plan binding.
7169
7209
  * @returns Its guided context, or null.
7170
7210
  * @throws
@@ -77,6 +77,7 @@ export const StoreCommandSchema = z.discriminatedUnion('kind', [
77
77
  afterSequence: z.number().int().nonnegative(),
78
78
  limit: z.number().int().min(1).max(128),
79
79
  }),
80
+ z.strictObject({ kind: z.literal('sessions-active'), limit: z.number().int().min(1).max(128) }),
80
81
  z.strictObject({ kind: z.literal('thread-plan-read'), threadId: z.uuid() }),
81
82
  z.strictObject({ kind: z.literal('plan-threads'), directory: z.string() }),
82
83
  z.strictObject({ kind: z.literal('queue-peek'), threadId: z.uuid() }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jg-agent-hq",
3
- "version": "4.0.2",
3
+ "version": "5.0.1",
4
4
  "description": "Native coding-agent session control, agent streams and durable collaboration for Node.js apps.",
5
5
  "type": "module",
6
6
  "license": "MIT",