jg-agent-hq 9.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 +10 -0
- package/api/README.md +2 -0
- package/dist/providers/claude/claude.d.ts +1 -0
- package/dist/providers/claude/claude.js +1 -0
- package/dist/providers/claude/history/history.model.js +4 -2
- package/dist/providers/codex/adapter.d.ts +3 -1
- package/dist/providers/codex/adapter.js +4 -2
- package/dist/providers/codex/codex.d.ts +1 -1
- package/dist/providers/codex/codex.js +2 -2
- package/dist/providers/codex/rpc.d.ts +4 -1
- package/dist/providers/codex/rpc.js +9 -2
- package/dist/runtime/runtime.js +4 -1
- package/dist/runtime/types.d.ts +2 -0
- package/dist/runtime/types.js +2 -0
- package/dist/store/schema.sql +4 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
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
|
+
|
|
7
|
+
## 10.0.0
|
|
8
|
+
|
|
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.
|
|
10
|
+
- Document `JG_AGENT_HQ_TRANSPORT_FAILED` on `request`, which a Claude history read rejects with when it can't start Claude's CLI.
|
|
11
|
+
- Breaking: change the storage schema in place. A database or snapshot written by 9.x is refused with `JG_AGENT_HQ_STORAGE_INVALID` naming the version that wrote it; start from a fresh state root.
|
|
12
|
+
|
|
3
13
|
## 9.0.0
|
|
4
14
|
|
|
5
15
|
- Breaking: remove plans, collaboration, agent tools and the agent bridge. HQ no longer registers, locks or snapshots plans, runs collaboration tasks, streams or requests, starts agents from other agents, or gives the sessions it starts tools of its own. The `plan`, `thread-plan`, `collaboration` and `agent-tool` requests, the browser `plan` command and `BrowserThreadDetailSchema.plan`, the plan, collaboration and agent-tool contracts with `PlanActionScopeSchema` and `ActionPlanContextSchema`, `computePlanRevision`, `IPlanContract`, `IProviderAgentTools`, `IAgentToolDefinition`, `IAgentMcpLease`, a provider's `agentTools` and its `agentTools` capability, and the `agent-input` provenance source are gone.
|
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 |
|
|
@@ -94,6 +94,7 @@ export declare const createClaudeProvider: (store: IStore) => {
|
|
|
94
94
|
* @returns One bounded native-file read through the owned worker.
|
|
95
95
|
* @throws
|
|
96
96
|
* - JG_AGENT_HQ_CLAUDE_FAILED: The Claude integration failed
|
|
97
|
+
* - JG_AGENT_HQ_TRANSPORT_FAILED: The HQ transport failed
|
|
97
98
|
* - JG_AGENT_HQ_CLAUDE_HISTORY_UNAVAILABLE: The Claude history is unavailable
|
|
98
99
|
* - JG_AGENT_HQ_IMAGE_UNAVAILABLE: The HQ image is unavailable
|
|
99
100
|
* - JG_AGENT_HQ_STORE_FAILED: The HQ store failed
|
|
@@ -237,6 +237,7 @@ export const createClaudeProvider = (store) => {
|
|
|
237
237
|
* @returns One bounded native-file read through the owned worker.
|
|
238
238
|
* @throws
|
|
239
239
|
* - JG_AGENT_HQ_CLAUDE_FAILED: The Claude integration failed
|
|
240
|
+
* - JG_AGENT_HQ_TRANSPORT_FAILED: The HQ transport failed
|
|
240
241
|
* - JG_AGENT_HQ_CLAUDE_HISTORY_UNAVAILABLE: The Claude history is unavailable
|
|
241
242
|
* - JG_AGENT_HQ_IMAGE_UNAVAILABLE: The HQ image is unavailable
|
|
242
243
|
* - JG_AGENT_HQ_STORE_FAILED: The HQ store failed
|
|
@@ -120,13 +120,15 @@ export class ClaudeHistoryModel {
|
|
|
120
120
|
const seek = continuation ? this.__parseCursor(SeekSchema, continuation) : undefined;
|
|
121
121
|
if (!seek && !this.__refresh(directory, root))
|
|
122
122
|
return { kind: 'indexing' };
|
|
123
|
+
// a row-value seek, so a continuation starts in the index rather than scanning earlier pages
|
|
124
|
+
const after = seek ? 'AND (updated_at, native_id) < (?, ?)' : '';
|
|
123
125
|
const rows = this.__database
|
|
124
126
|
.prepare(`SELECT native_id, workspace_root, identity, file_size, modified_at, byte_offset, revision,
|
|
125
127
|
leaf_id, name, created_at, updated_at, supported, workspace_state FROM hq_claude_file
|
|
126
|
-
WHERE workspace_root = ? AND workspace_state = 'matching'
|
|
128
|
+
WHERE workspace_root = ? AND workspace_state = 'matching' ${after}
|
|
127
129
|
AND (? IS NULL OR instr(lower(coalesce(name, '')), lower(?)) > 0)
|
|
128
130
|
ORDER BY updated_at DESC, native_id DESC LIMIT ?`)
|
|
129
|
-
.all(root, seek
|
|
131
|
+
.all(root, ...(seek ? [seek.updatedAt, seek.nativeId] : []), command.search ?? null, command.search ?? null, command.limit + 1)
|
|
130
132
|
.map((row) => FileRowSchema.parse(row));
|
|
131
133
|
const page = rows.slice(0, command.limit);
|
|
132
134
|
const last = page.at(-1);
|
|
@@ -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(
|
|
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)}`, {
|
package/dist/runtime/runtime.js
CHANGED
|
@@ -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
|
-
{
|
|
67
|
+
{
|
|
68
|
+
factory: createCodexProviderFactory(codexExtraSkillRoots, parsed.data.codexDaemonLauncher ?? []),
|
|
69
|
+
isBuiltIn: true,
|
|
70
|
+
},
|
|
68
71
|
{
|
|
69
72
|
factory: createClaudeProviderFactory(store, claudeAdditionalDirectories),
|
|
70
73
|
isBuiltIn: true,
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -59,6 +60,7 @@ export type IAgentHq = {
|
|
|
59
60
|
* - JG_AGENT_HQ_ACTION_CONFLICT: The HQ action conflicts with its recorded state
|
|
60
61
|
* - JG_AGENT_HQ_CODEX_FAILED: The Codex integration failed
|
|
61
62
|
* - JG_AGENT_HQ_CLAUDE_FAILED: The Claude integration failed
|
|
63
|
+
* - JG_AGENT_HQ_TRANSPORT_FAILED: The HQ transport failed
|
|
62
64
|
* - JG_AGENT_HQ_CLAUDE_HISTORY_UNAVAILABLE: The Claude history is unavailable
|
|
63
65
|
* - JG_AGENT_HQ_IMAGE_UNAVAILABLE: The HQ image is unavailable
|
|
64
66
|
* - JG_AGENT_HQ_PROVIDER_FAILED: The HQ provider integration failed
|
package/dist/runtime/types.js
CHANGED
|
@@ -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/dist/store/schema.sql
CHANGED
|
@@ -140,8 +140,10 @@ CREATE TABLE hq_claude_file (
|
|
|
140
140
|
supported INTEGER NOT NULL, workspace_state TEXT NOT NULL,
|
|
141
141
|
CONSTRAINT hq_pk_cf__workspace_root_native_id PRIMARY KEY (workspace_root, native_id)
|
|
142
142
|
) STRICT;
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
-- the thread list's last-activity order, and an observed session's lookup by native ID alone
|
|
144
|
+
CREATE INDEX hq_idx_cf__workspace_root_updated_at_native_id_desc
|
|
145
|
+
ON hq_claude_file(workspace_root, updated_at DESC, native_id DESC);
|
|
146
|
+
CREATE INDEX hq_idx_cf__native_id_updated_at_desc ON hq_claude_file(native_id, updated_at DESC);
|
|
145
147
|
CREATE TABLE hq_claude_entry (
|
|
146
148
|
workspace_root TEXT NOT NULL, native_id TEXT NOT NULL, uuid TEXT NOT NULL,
|
|
147
149
|
parent_uuid TEXT, turn_id TEXT NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
|
package/package.json
CHANGED