jg-agent-hq 10.0.0 → 10.1.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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 10.1.0
4
+
5
+ - Add `codexDaemonLauncher` to `createAgentHq`: a command and its arguments that run `codex app-server daemon start`, such as `systemd-run --user --scope`. On Linux, Codex's shared daemon stays in the cgroup of whatever started it, so a host running as a systemd service that started it took it down, with the work of every terminal session on it, whenever the service stopped. Without the option, the start runs directly as before.
6
+
3
7
  ## 10.0.0
4
8
 
5
9
  - List Claude threads from an index in last-activity order, replacing the unused index in creation order, so a page no longer sorts every transcript of the workspace, and a continuation seeks into that index instead of scanning the pages before it. Active-session reads find an observed Claude session's transcript through an index on its native ID instead of scanning every indexed transcript.
package/api/README.md CHANGED
@@ -306,6 +306,8 @@ Both native inventory interfaces are unpaged. HQ accepts at most 4,096 native ro
306
306
 
307
307
  Trusted runtime construction also accepts `codexExtraSkillRoots?: string[]` and `claudeAdditionalDirectories?: string[]`. Paths must resolve to existing absolute directories. Codex receives them as capability roots of each thread HQ starts, so other sessions on the shared daemon, including terminal sessions, never see them. Forks inherit them. A session Codex later reloads from disk loses native discovery of those skills, while explicit invocation through the HQ catalog still works, because it names the skill file. Claude receives native `--add-dir` arguments, which also grant native file access to those directories. These inputs belong to the operator and cannot be changed through IPC commands. The installed `serve` command exposes repeated `--codex-extra-skill-root` and `--claude-additional-directory` flags. No global skill installation or coding-instruction change is performed.
308
308
 
309
+ `codexDaemonLauncher?: string[]`, also trusted, names a command and its arguments that run `codex app-server daemon start`, such as `['systemd-run', '--user', '--scope', '--quiet', '--collect']`. HQ runs the start through it, while the proxy still runs directly. Codex's daemon detaches into its own session, but on Linux it stays in the cgroup of whatever started it, so a host that runs as a systemd service and starts the daemon itself would take the daemon, and the work of every terminal session on it, down whenever the service stops. A new scope gives the daemon a lifetime of its own. The installed `serve` command doesn't expose it.
310
+
309
311
  ## Control reads and reconnect
310
312
 
311
313
  | Command | Fields | Result |
@@ -1,6 +1,8 @@
1
1
  import { type IAgentProviderFactory } from '../index.js';
2
2
  /**
3
3
  * Describes current Codex controls and lazily owns a connection to the shared app-server daemon.
4
+ * @param extraSkillRoots The capability roots of each thread HQ starts.
5
+ * @param daemonLauncher The command and arguments run before `codex app-server daemon start`.
4
6
  * @returns A built-in factory that preserves native settings, authentication and permission policy.
5
7
  */
6
- export declare const createCodexProviderFactory: (extraSkillRoots: string[]) => IAgentProviderFactory;
8
+ export declare const createCodexProviderFactory: (extraSkillRoots: string[], daemonLauncher: string[]) => IAgentProviderFactory;
@@ -12,12 +12,14 @@ import { MAX_LOADED_THREAD_PAGES } from './constants.js';
12
12
  import { createCodexEvents, toProviderThread } from './events.js';
13
13
  /**
14
14
  * Describes current Codex controls and lazily owns a connection to the shared app-server daemon.
15
+ * @param extraSkillRoots The capability roots of each thread HQ starts.
16
+ * @param daemonLauncher The command and arguments run before `codex app-server daemon start`.
15
17
  * @returns A built-in factory that preserves native settings, authentication and permission policy.
16
18
  */
17
- export const createCodexProviderFactory = (extraSkillRoots) => ({
19
+ export const createCodexProviderFactory = (extraSkillRoots, daemonLauncher) => ({
18
20
  id: 'codex',
19
21
  async create(context) {
20
- const native = await createCodexProvider(extraSkillRoots);
22
+ const native = await createCodexProvider(extraSkillRoots, daemonLauncher);
21
23
  // whether each session is observed, read once: Codex saves it and it's inside an allowed workspace
22
24
  const allowedSessions = new Map();
23
25
  let observations = Promise.resolve();
@@ -6,4 +6,4 @@ import { type ICodexProvider } from './types.js';
6
6
  * - JG_AGENT_HQ_CODEX_FAILED: The Codex integration failed
7
7
  * - JG_AGENT_HQ_TRANSPORT_FAILED: The HQ transport failed
8
8
  */
9
- export declare const createCodexProvider: (extraSkillRoots?: string[]) => Promise<ICodexProvider>;
9
+ export declare const createCodexProvider: (extraSkillRoots?: string[], daemonLauncher?: string[]) => Promise<ICodexProvider>;
@@ -22,7 +22,7 @@ import { toCodexConfiguration, toCodexSessionSettings, readCodexConfigurationObs
22
22
  * - JG_AGENT_HQ_CODEX_FAILED: The Codex integration failed
23
23
  * - JG_AGENT_HQ_TRANSPORT_FAILED: The HQ transport failed
24
24
  */
25
- export const createCodexProvider = async (extraSkillRoots = []) => {
25
+ export const createCodexProvider = async (extraSkillRoots = [], daemonLauncher = []) => {
26
26
  let latest = {
27
27
  provider: 'codex',
28
28
  state: 'unavailable',
@@ -95,7 +95,7 @@ export const createCodexProvider = async (extraSkillRoots = []) => {
95
95
  return latest;
96
96
  })());
97
97
  };
98
- rpc = await createCodexRpc({
98
+ rpc = await createCodexRpc(daemonLauncher, {
99
99
  request: (id, method, params) => {
100
100
  if (events)
101
101
  events.request(id, method, params);
@@ -3,12 +3,15 @@
3
3
  * daemon when no terminal session has, with bounded pending requests. The daemon's control socket
4
4
  * speaks WebSocket, which the proxy forwards as raw bytes. When the daemon restarts, the lost
5
5
  * connection's requests fail and the next request reconnects; nothing is sent again.
6
+ * @param daemonLauncher The command and arguments run before `codex app-server daemon start`, so a
7
+ * host can start the shared daemon outside its own service; empty runs the start directly.
8
+ * @param handlers The callbacks for native messages and connection changes.
6
9
  * @returns An initialized transport with exact action IDs and late-response callbacks.
7
10
  * @throws
8
11
  * - JG_AGENT_HQ_CODEX_FAILED: The Codex integration failed
9
12
  * - JG_AGENT_HQ_TRANSPORT_FAILED: The HQ transport failed
10
13
  */
11
- export declare const createCodexRpc: (handlers: {
14
+ export declare const createCodexRpc: (daemonLauncher: string[], handlers: {
12
15
  notify(method: string, params: unknown): void;
13
16
  request(id: string | number, method: string, params: unknown): void;
14
17
  lateResponse(id: string, result: unknown, error: unknown): void;
@@ -18,12 +18,19 @@ const EnvelopeSchema = z.object({
18
18
  * daemon when no terminal session has, with bounded pending requests. The daemon's control socket
19
19
  * speaks WebSocket, which the proxy forwards as raw bytes. When the daemon restarts, the lost
20
20
  * connection's requests fail and the next request reconnects; nothing is sent again.
21
+ * @param daemonLauncher The command and arguments run before `codex app-server daemon start`, so a
22
+ * host can start the shared daemon outside its own service; empty runs the start directly.
23
+ * @param handlers The callbacks for native messages and connection changes.
21
24
  * @returns An initialized transport with exact action IDs and late-response callbacks.
22
25
  * @throws
23
26
  * - JG_AGENT_HQ_CODEX_FAILED: The Codex integration failed
24
27
  * - JG_AGENT_HQ_TRANSPORT_FAILED: The HQ transport failed
25
28
  */
26
- export const createCodexRpc = async (handlers) => {
29
+ export const createCodexRpc = async (daemonLauncher, handlers) => {
30
+ const [launcherCommand, ...launcherArguments] = daemonLauncher;
31
+ const daemonStart = launcherCommand
32
+ ? [launcherCommand, [...launcherArguments, 'codex', 'app-server', 'daemon', 'start']]
33
+ : ['codex', ['app-server', 'daemon', 'start']];
27
34
  const manifest = z
28
35
  .object({ version: z.string() })
29
36
  .parse(JSON.parse(await readFile(new URL('../../../package.json', import.meta.url), 'utf8')));
@@ -138,7 +145,7 @@ export const createCodexRpc = async (handlers) => {
138
145
  */
139
146
  const open = async () => {
140
147
  try {
141
- await run('codex', ['app-server', 'daemon', 'start'], { timeout: 30_000, maxBuffer: 65_536 });
148
+ await run(...daemonStart, { timeout: 30_000, maxBuffer: 65_536 });
142
149
  }
143
150
  catch (cause) {
144
151
  throw new Exception(`The Codex integration failed: ${extractMessage(cause)}`, {
@@ -64,7 +64,10 @@ export const createAgentHq = async (options) => {
64
64
  actionKey = await prepareActionKey(stateRoot, databasePath);
65
65
  store = await createStore(databasePath, ownership.owner.nonce, actionKey);
66
66
  registry = createProviderRegistry([
67
- { factory: createCodexProviderFactory(codexExtraSkillRoots), isBuiltIn: true },
67
+ {
68
+ factory: createCodexProviderFactory(codexExtraSkillRoots, parsed.data.codexDaemonLauncher ?? []),
69
+ isBuiltIn: true,
70
+ },
68
71
  {
69
72
  factory: createClaudeProviderFactory(store, claudeAdditionalDirectories),
70
73
  isBuiltIn: true,
@@ -9,6 +9,7 @@ export declare const AgentHqOptionsSchema: z.ZodObject<{
9
9
  stateRoot: z.ZodString;
10
10
  allowedRoots: z.ZodArray<z.ZodString>;
11
11
  codexExtraSkillRoots: z.ZodOptional<z.ZodArray<z.ZodString>>;
12
+ codexDaemonLauncher: z.ZodOptional<z.ZodArray<z.ZodString>>;
12
13
  claudeAdditionalDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
13
14
  }, z.core.$strict>;
14
15
  export type IAgentHqOptions = z.infer<typeof AgentHqOptionsSchema>;
@@ -13,5 +13,7 @@ export const AgentHqOptionsSchema = z.strictObject({
13
13
  stateRoot: z.string().min(1).refine(isAbsolute),
14
14
  allowedRoots: z.array(z.string().min(1).refine(isAbsolute)).min(1).max(128),
15
15
  codexExtraSkillRoots: z.array(z.string().min(1).refine(isAbsolute)).max(128).optional(),
16
+ // a command and its arguments run before `codex app-server daemon start`, such as a new scope
17
+ codexDaemonLauncher: z.array(z.string().min(1)).min(1).max(16).optional(),
16
18
  claudeAdditionalDirectories: z.array(z.string().min(1).refine(isAbsolute)).max(128).optional(),
17
19
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jg-agent-hq",
3
- "version": "10.0.0",
3
+ "version": "10.1.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",