jg-agent-hq 8.0.2 → 9.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.
Files changed (232) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +18 -37
  3. package/api/README.md +51 -243
  4. package/dist/actions/actions.d.ts +5 -50
  5. package/dist/actions/actions.js +49 -190
  6. package/dist/actions/reads.d.ts +3 -2
  7. package/dist/actions/reads.js +12 -5
  8. package/dist/actions/waits/index.d.ts +1 -0
  9. package/dist/actions/waits/index.js +2 -0
  10. package/dist/actions/waits/waits.d.ts +37 -0
  11. package/dist/actions/waits/waits.js +107 -0
  12. package/dist/cli/cli.js +6 -56
  13. package/dist/contracts/actions/index.d.ts +2 -4
  14. package/dist/contracts/actions/index.js +1 -3
  15. package/dist/contracts/actions/types.d.ts +135 -142
  16. package/dist/contracts/actions/types.js +12 -22
  17. package/dist/contracts/browser/types.d.ts +12 -605
  18. package/dist/contracts/browser/types.js +2 -5
  19. package/dist/contracts/evidence/types.d.ts +4 -7
  20. package/dist/contracts/evidence/types.js +2 -8
  21. package/dist/contracts/index.d.ts +5 -16
  22. package/dist/contracts/index.js +4 -15
  23. package/dist/contracts/locks/index.d.ts +2 -0
  24. package/dist/contracts/locks/index.js +2 -0
  25. package/dist/contracts/locks/types.d.ts +50 -0
  26. package/dist/contracts/locks/types.js +36 -0
  27. package/dist/contracts/providers/types.d.ts +0 -38
  28. package/dist/contracts/providers/types.js +0 -1
  29. package/dist/contracts/results/types.js +1 -1
  30. package/dist/contracts/sessions/types.d.ts +2 -0
  31. package/dist/contracts/sessions/types.js +7 -1
  32. package/dist/contracts/skills/types.d.ts +1 -0
  33. package/dist/contracts/skills/types.js +5 -0
  34. package/dist/contracts/types.d.ts +4526 -12307
  35. package/dist/contracts/types.js +13 -12
  36. package/dist/index.d.ts +0 -3
  37. package/dist/index.js +0 -2
  38. package/dist/providers/claude/adapter.js +1 -11
  39. package/dist/providers/claude/claude.d.ts +6 -3
  40. package/dist/providers/claude/claude.js +49 -9
  41. package/dist/providers/claude/control/control.d.ts +2 -20
  42. package/dist/providers/claude/control/control.js +88 -155
  43. package/dist/providers/claude/control/permissions.d.ts +0 -9
  44. package/dist/providers/claude/control/permissions.js +0 -22
  45. package/dist/providers/claude/control/skills.js +1 -0
  46. package/dist/providers/claude/control/stream.js +1 -34
  47. package/dist/providers/claude/control/types.d.ts +0 -3
  48. package/dist/providers/claude/history/history.model.d.ts +9 -0
  49. package/dist/providers/claude/history/history.model.js +77 -43
  50. package/dist/providers/claude/history/types.d.ts +284 -3045
  51. package/dist/providers/claude/history/types.js +1 -0
  52. package/dist/providers/claude/rpc.d.ts +0 -5
  53. package/dist/providers/claude/rpc.js +0 -3
  54. package/dist/providers/codex/adapter.js +2 -12
  55. package/dist/providers/codex/codex.d.ts +1 -2
  56. package/dist/providers/codex/codex.js +2 -100
  57. package/dist/providers/codex/types.d.ts +2 -4
  58. package/dist/providers/registry/registry.d.ts +0 -2
  59. package/dist/providers/registry/registry.js +0 -7
  60. package/dist/providers/types.d.ts +4 -6
  61. package/dist/providers/types.js +3 -2
  62. package/dist/runtime/runtime.js +10 -81
  63. package/dist/runtime/types.d.ts +1 -18
  64. package/dist/runtime/types.js +0 -1
  65. package/dist/sessions/sessions.js +0 -1
  66. package/dist/skills/skills.js +3 -0
  67. package/dist/snapshots/archive/archive.js +2 -23
  68. package/dist/snapshots/capture.d.ts +2 -5
  69. package/dist/snapshots/capture.js +4 -85
  70. package/dist/snapshots/constants.d.ts +0 -1
  71. package/dist/snapshots/constants.js +1 -6
  72. package/dist/snapshots/database.d.ts +2 -3
  73. package/dist/snapshots/database.js +9 -114
  74. package/dist/snapshots/fences.d.ts +3 -5
  75. package/dist/snapshots/fences.js +3 -15
  76. package/dist/snapshots/files.d.ts +3 -1
  77. package/dist/snapshots/files.js +15 -4
  78. package/dist/snapshots/snapshots.d.ts +6 -7
  79. package/dist/snapshots/snapshots.js +9 -16
  80. package/dist/snapshots/types.d.ts +5 -81
  81. package/dist/snapshots/types.js +7 -30
  82. package/dist/storage/constants.d.ts +1 -0
  83. package/dist/storage/constants.js +5 -1
  84. package/dist/storage/types.d.ts +1 -0
  85. package/dist/storage/types.js +1 -0
  86. package/dist/store/control/constants.d.ts +3 -2
  87. package/dist/store/control/constants.js +3 -1
  88. package/dist/store/control/control.model.d.ts +1 -11
  89. package/dist/store/control/control.model.js +10 -131
  90. package/dist/store/control/transformers.d.ts +6 -3
  91. package/dist/store/control/transformers.js +6 -5
  92. package/dist/store/control/types.d.ts +91 -170
  93. package/dist/store/control/types.js +5 -7
  94. package/dist/store/schema.js +1 -1
  95. package/dist/store/schema.sql +3 -360
  96. package/dist/store/sessions/sessions.model.d.ts +10 -6
  97. package/dist/store/sessions/sessions.model.js +19 -2
  98. package/dist/store/snapshot.d.ts +10 -0
  99. package/dist/store/snapshot.js +37 -0
  100. package/dist/store/store.js +1 -54
  101. package/dist/store/store.worker.js +5 -97
  102. package/dist/store/types.d.ts +241 -4802
  103. package/dist/store/types.js +1 -44
  104. package/docs/recovery.md +10 -6
  105. package/errors/README.md +29 -39
  106. package/package.json +3 -4
  107. package/dist/agent-tools/agent-tools.d.ts +0 -6
  108. package/dist/agent-tools/agent-tools.js +0 -181
  109. package/dist/agent-tools/constants.d.ts +0 -7
  110. package/dist/agent-tools/constants.js +0 -45
  111. package/dist/agent-tools/index.d.ts +0 -4
  112. package/dist/agent-tools/index.js +0 -4
  113. package/dist/agent-tools/mcp/index.d.ts +0 -1
  114. package/dist/agent-tools/mcp/index.js +0 -2
  115. package/dist/agent-tools/mcp/mcp.d.ts +0 -7
  116. package/dist/agent-tools/mcp/mcp.js +0 -50
  117. package/dist/agent-tools/types.d.ts +0 -64
  118. package/dist/agent-tools/types.js +0 -1
  119. package/dist/agent-tools/utilities.d.ts +0 -13
  120. package/dist/agent-tools/utilities.js +0 -37
  121. package/dist/collaboration/collaboration.d.ts +0 -7
  122. package/dist/collaboration/collaboration.js +0 -119
  123. package/dist/collaboration/constants.d.ts +0 -2
  124. package/dist/collaboration/constants.js +0 -3
  125. package/dist/collaboration/dispatch/dispatch.d.ts +0 -12
  126. package/dist/collaboration/dispatch/dispatch.js +0 -148
  127. package/dist/collaboration/dispatch/index.d.ts +0 -3
  128. package/dist/collaboration/dispatch/index.js +0 -4
  129. package/dist/collaboration/dispatch/types.d.ts +0 -632
  130. package/dist/collaboration/dispatch/types.js +0 -44
  131. package/dist/collaboration/grants/grants.d.ts +0 -45
  132. package/dist/collaboration/grants/grants.js +0 -131
  133. package/dist/collaboration/grants/index.d.ts +0 -1
  134. package/dist/collaboration/grants/index.js +0 -2
  135. package/dist/collaboration/identity/credentials.d.ts +0 -17
  136. package/dist/collaboration/identity/credentials.js +0 -182
  137. package/dist/collaboration/identity/index.d.ts +0 -4
  138. package/dist/collaboration/identity/index.js +0 -4
  139. package/dist/collaboration/identity/types.d.ts +0 -171
  140. package/dist/collaboration/identity/types.js +0 -87
  141. package/dist/collaboration/index.d.ts +0 -3
  142. package/dist/collaboration/index.js +0 -3
  143. package/dist/collaboration/types.d.ts +0 -25
  144. package/dist/collaboration/types.js +0 -1
  145. package/dist/contracts/agent-tools/index.d.ts +0 -2
  146. package/dist/contracts/agent-tools/index.js +0 -2
  147. package/dist/contracts/agent-tools/types.d.ts +0 -697
  148. package/dist/contracts/agent-tools/types.js +0 -125
  149. package/dist/contracts/collaboration/index.d.ts +0 -4
  150. package/dist/contracts/collaboration/index.js +0 -4
  151. package/dist/contracts/collaboration/reports/constants.d.ts +0 -1
  152. package/dist/contracts/collaboration/reports/constants.js +0 -2
  153. package/dist/contracts/collaboration/reports/index.d.ts +0 -3
  154. package/dist/contracts/collaboration/reports/index.js +0 -3
  155. package/dist/contracts/collaboration/reports/types.d.ts +0 -69
  156. package/dist/contracts/collaboration/reports/types.js +0 -53
  157. package/dist/contracts/collaboration/types.d.ts +0 -6734
  158. package/dist/contracts/collaboration/types.js +0 -696
  159. package/dist/contracts/plans/index.d.ts +0 -6
  160. package/dist/contracts/plans/index.js +0 -6
  161. package/dist/contracts/plans/types.d.ts +0 -1788
  162. package/dist/contracts/plans/types.js +0 -278
  163. package/dist/plans/admission.d.ts +0 -288
  164. package/dist/plans/admission.js +0 -393
  165. package/dist/plans/authority.d.ts +0 -21
  166. package/dist/plans/authority.js +0 -207
  167. package/dist/plans/documents.d.ts +0 -80
  168. package/dist/plans/documents.js +0 -238
  169. package/dist/plans/evidence.d.ts +0 -11
  170. package/dist/plans/evidence.js +0 -211
  171. package/dist/plans/files.d.ts +0 -55
  172. package/dist/plans/files.js +0 -264
  173. package/dist/plans/finalization.d.ts +0 -11
  174. package/dist/plans/finalization.js +0 -30
  175. package/dist/plans/index.d.ts +0 -5
  176. package/dist/plans/index.js +0 -6
  177. package/dist/plans/plans.d.ts +0 -325
  178. package/dist/plans/plans.js +0 -803
  179. package/dist/plans/projections.d.ts +0 -13
  180. package/dist/plans/projections.js +0 -67
  181. package/dist/plans/revisions.d.ts +0 -50
  182. package/dist/plans/revisions.js +0 -181
  183. package/dist/plans/types.d.ts +0 -114
  184. package/dist/plans/types.js +0 -43
  185. package/dist/plans/utilities.d.ts +0 -36
  186. package/dist/plans/utilities.js +0 -62
  187. package/dist/snapshots/artifacts.d.ts +0 -16
  188. package/dist/snapshots/artifacts.js +0 -75
  189. package/dist/store/collaboration/authority.d.ts +0 -228
  190. package/dist/store/collaboration/authority.js +0 -128
  191. package/dist/store/collaboration/collaboration.model.d.ts +0 -412
  192. package/dist/store/collaboration/collaboration.model.js +0 -254
  193. package/dist/store/collaboration/constants.d.ts +0 -13
  194. package/dist/store/collaboration/constants.js +0 -14
  195. package/dist/store/collaboration/dispatch.d.ts +0 -19
  196. package/dist/store/collaboration/dispatch.js +0 -197
  197. package/dist/store/collaboration/identity.d.ts +0 -21
  198. package/dist/store/collaboration/identity.js +0 -146
  199. package/dist/store/collaboration/index.d.ts +0 -3
  200. package/dist/store/collaboration/index.js +0 -5
  201. package/dist/store/collaboration/invocation.d.ts +0 -21
  202. package/dist/store/collaboration/invocation.js +0 -162
  203. package/dist/store/collaboration/messages.d.ts +0 -54
  204. package/dist/store/collaboration/messages.js +0 -157
  205. package/dist/store/collaboration/outcomes.d.ts +0 -11
  206. package/dist/store/collaboration/outcomes.js +0 -216
  207. package/dist/store/collaboration/queries.d.ts +0 -23
  208. package/dist/store/collaboration/queries.js +0 -259
  209. package/dist/store/collaboration/reports.d.ts +0 -37
  210. package/dist/store/collaboration/reports.js +0 -117
  211. package/dist/store/collaboration/requests.d.ts +0 -22
  212. package/dist/store/collaboration/requests.js +0 -111
  213. package/dist/store/collaboration/search.d.ts +0 -13
  214. package/dist/store/collaboration/search.js +0 -58
  215. package/dist/store/collaboration/spawn.d.ts +0 -33
  216. package/dist/store/collaboration/spawn.js +0 -96
  217. package/dist/store/collaboration/streams.d.ts +0 -13
  218. package/dist/store/collaboration/streams.js +0 -100
  219. package/dist/store/collaboration/tasks.d.ts +0 -20
  220. package/dist/store/collaboration/tasks.js +0 -169
  221. package/dist/store/collaboration/transformers.d.ts +0 -56
  222. package/dist/store/collaboration/transformers.js +0 -179
  223. package/dist/store/collaboration/types.d.ts +0 -25
  224. package/dist/store/collaboration/types.js +0 -8
  225. package/dist/store/collaboration/utilities.d.ts +0 -23
  226. package/dist/store/collaboration/utilities.js +0 -77
  227. package/dist/store/collaboration/waits.d.ts +0 -26
  228. package/dist/store/collaboration/waits.js +0 -114
  229. package/dist/store/plans/index.d.ts +0 -1
  230. package/dist/store/plans/index.js +0 -2
  231. package/dist/store/plans/plans.model.d.ts +0 -47
  232. package/dist/store/plans/plans.model.js +0 -179
@@ -0,0 +1,37 @@
1
+ import type { IActionReceipt, IActionWait, IHqRequest } from '../../contracts/index.js';
2
+ type IActionWaitUntil = Extract<IHqRequest, {
3
+ kind: 'action-wait';
4
+ }>['until'];
5
+ /**
6
+ * Holds waits on action receipts. The actions module notifies it after each change it makes to a
7
+ * receipt, and a wait reads its receipt again only then, never on a timer.
8
+ */
9
+ export declare class ActionWaits {
10
+ private readonly __read;
11
+ private readonly __waiters;
12
+ private __isClosed;
13
+ /** Reads receipts through the store the actions module writes them with. */
14
+ constructor(read: (actionId: string) => Promise<IActionReceipt | null>);
15
+ /** Wakes the waits on one action. */
16
+ notifyAction(actionId: string): void;
17
+ /** Wakes the waits on the actions of one thread. */
18
+ notifyThread(threadId: string): void;
19
+ /** Wakes every wait, after a change that can touch any receipt. */
20
+ notifyAll(): void;
21
+ /** Ends every wait and refuses new ones, once the runtime starts closing. */
22
+ close(): void;
23
+ /**
24
+ * Waits until an action's receipt has a native thread ID (`native`) or a final delivery state
25
+ * (`settled`), or until `timeoutMs` passes.
26
+ * @param actionId The action.
27
+ * @param until What the wait waits for.
28
+ * @param timeoutMs The most milliseconds to wait.
29
+ * @returns A promise that resolves to the receipt, null for an unknown action, and whether the
30
+ * time ran out before the receipt reached it.
31
+ * @throws
32
+ * - JG_AGENT_HQ_RUNTIME_NOT_RUNNING: The HQ runtime is not running
33
+ * - JG_AGENT_HQ_STORE_FAILED: The HQ store failed
34
+ */
35
+ wait(actionId: string, until: IActionWaitUntil, timeoutMs: number): Promise<IActionWait>;
36
+ }
37
+ export {};
@@ -0,0 +1,107 @@
1
+ import { Exception } from 'jg-exception';
2
+ // deliveries a receipt keeps until late native evidence or an operator's recovery changes them
3
+ const SETTLED_DELIVERIES = new Set([
4
+ 'acknowledged',
5
+ 'uncertain',
6
+ 'failed',
7
+ 'canceled',
8
+ ]);
9
+ /**
10
+ * Tells whether a receipt reached what its wait waits for. A native wait also ends once the
11
+ * receipt settles without a native thread ID, which it can't then get by itself.
12
+ */
13
+ const isReached = (receipt, until) => SETTLED_DELIVERIES.has(receipt.delivery) ||
14
+ (until === 'native' && receipt.nativeThreadId !== null);
15
+ /**
16
+ * Holds waits on action receipts. The actions module notifies it after each change it makes to a
17
+ * receipt, and a wait reads its receipt again only then, never on a timer.
18
+ */
19
+ export class ActionWaits {
20
+ __read;
21
+ __waiters = new Set();
22
+ __isClosed = false;
23
+ /** Reads receipts through the store the actions module writes them with. */
24
+ constructor(read) {
25
+ this.__read = read;
26
+ }
27
+ /** Wakes the waits on one action. */
28
+ notifyAction(actionId) {
29
+ for (const waiter of this.__waiters)
30
+ if (waiter.isReading || waiter.actionId === actionId)
31
+ waiter.wake();
32
+ }
33
+ /** Wakes the waits on the actions of one thread. */
34
+ notifyThread(threadId) {
35
+ for (const waiter of this.__waiters)
36
+ if (waiter.isReading || waiter.threadId === threadId)
37
+ waiter.wake();
38
+ }
39
+ /** Wakes every wait, after a change that can touch any receipt. */
40
+ notifyAll() {
41
+ for (const waiter of this.__waiters)
42
+ waiter.wake();
43
+ }
44
+ /** Ends every wait and refuses new ones, once the runtime starts closing. */
45
+ close() {
46
+ this.__isClosed = true;
47
+ this.notifyAll();
48
+ }
49
+ /**
50
+ * Waits until an action's receipt has a native thread ID (`native`) or a final delivery state
51
+ * (`settled`), or until `timeoutMs` passes.
52
+ * @param actionId The action.
53
+ * @param until What the wait waits for.
54
+ * @param timeoutMs The most milliseconds to wait.
55
+ * @returns A promise that resolves to the receipt, null for an unknown action, and whether the
56
+ * time ran out before the receipt reached it.
57
+ * @throws
58
+ * - JG_AGENT_HQ_RUNTIME_NOT_RUNNING: The HQ runtime is not running
59
+ * - JG_AGENT_HQ_STORE_FAILED: The HQ store failed
60
+ */
61
+ async wait(actionId, until, timeoutMs) {
62
+ let resume = () => undefined;
63
+ let isTimedOut = false;
64
+ const waiter = {
65
+ actionId,
66
+ threadId: null,
67
+ isReading: false,
68
+ isWoken: true,
69
+ wake: () => {
70
+ waiter.isWoken = true;
71
+ resume();
72
+ },
73
+ };
74
+ const timer = setTimeout(() => {
75
+ isTimedOut = true;
76
+ waiter.wake();
77
+ }, timeoutMs);
78
+ // registered before the first read, so no change after that read is missed
79
+ this.__waiters.add(waiter);
80
+ try {
81
+ for (;;) {
82
+ if (!waiter.isWoken)
83
+ await new Promise((resolve) => {
84
+ resume = resolve;
85
+ });
86
+ if (this.__isClosed)
87
+ throw new Exception('The HQ runtime is not running', {
88
+ code: 'JG_AGENT_HQ_RUNTIME_NOT_RUNNING',
89
+ data: { kind: 'state-conflict' },
90
+ });
91
+ waiter.isWoken = false;
92
+ waiter.isReading = true;
93
+ const receipt = await this.__read(actionId);
94
+ waiter.isReading = false;
95
+ if (!receipt || isReached(receipt, until))
96
+ return { receipt, isTimedOut: false };
97
+ if (isTimedOut)
98
+ return { receipt, isTimedOut: true };
99
+ waiter.threadId = receipt.threadId;
100
+ }
101
+ }
102
+ finally {
103
+ clearTimeout(timer);
104
+ this.__waiters.delete(waiter);
105
+ }
106
+ }
107
+ }
package/dist/cli/cli.js CHANGED
@@ -7,27 +7,13 @@ import { HqRequestSchema } from '../contracts/index.js';
7
7
  import { requestAgentHq } from '../ipc/index.js';
8
8
  import { createAgentHq } from '../runtime/index.js';
9
9
  import { readRuntimeOwner } from '../runtime/state/index.js';
10
- import { serveAgentBridge } from '../agent-tools/mcp/index.js';
11
- import { AGENT_BRIDGE_FILE_ENV } from '../agent-tools/index.js';
12
10
  import { toCliError } from './utilities.js';
13
11
  /** Runs the installed CLI without creating provider work merely to read history. */
14
12
  const main = async () => {
15
- if (process.argv[2] === 'agent-bridge') {
16
- const credentialPath = process.env[AGENT_BRIDGE_FILE_ENV];
17
- if (process.argv.length !== 3 || !credentialPath)
18
- throw new Exception('The HQ request is invalid', {
19
- code: 'JG_AGENT_HQ_REQUEST_INVALID',
20
- data: { kind: 'invalid-request' },
21
- });
22
- await serveAgentBridge(credentialPath);
23
- return;
24
- }
25
13
  const { values, positionals } = parseArgs({
26
14
  allowPositionals: true,
27
15
  options: {
28
16
  'state-root': { type: 'string' },
29
- 'coordination-root': { type: 'string' },
30
- directory: { type: 'string' },
31
17
  'workspace-root': { type: 'string', multiple: true },
32
18
  'native-id': { type: 'string' },
33
19
  'turn-id': { type: 'string' },
@@ -54,7 +40,7 @@ const main = async () => {
54
40
  });
55
41
  const [kind] = positionals;
56
42
  if (values.help || !kind || kind === 'help') {
57
- process.stdout.write('jg-agent-hq serve|status|stop|capabilities|threads|thread|turns|items|item-detail|item-image|sessions|session-evidence|usage|account|models|configuration|mcp-servers|mcp-tools|mcp-resources|managed-thread-name|suggest-thread-name|skills|skill-preview|plan-status|plan-milestones|session-states|active-sessions|unstarted-threads|observation-pace|request --state-root <path> [--provider <provider-id>] [--workspace-root <path>] [--native-id <id>] [--limit <1..128>] [--cursor <cursor>] [--name <name>] [--topic <topic>] [--thread-id <id>] [--server-name <name>] [--skill-id <id>] [--arguments <text>] [--directory <path>] [--after-sequence <sequence>]\nserve accepts repeated --codex-extra-skill-root and --claude-additional-directory, and --coordination-root for a separate existing coordination directory.\nsession-evidence accepts --native-item-id and repeated --evidence-kind.\nitems reads newest first and accepts --text-limit <1..65536>, and --native-item-id with --turn-id for one item.\nitem-detail reads the detail of one item and takes --native-item-id and --turn-id.\nitem-image reads one image of an item and also takes --index <0..63>.\nobservation-pace takes --pace <live|background>.\nrequest reads one validated HQ command as JSON from stdin.\n');
43
+ process.stdout.write('jg-agent-hq serve|status|stop|capabilities|threads|thread|turns|items|item-detail|item-image|sessions|session-evidence|usage|account|models|configuration|mcp-servers|mcp-tools|mcp-resources|managed-thread-name|suggest-thread-name|skills|skill-preview|session-states|active-sessions|unstarted-threads|observation-pace|locks|request --state-root <path> [--provider <provider-id>] [--workspace-root <path>] [--native-id <id>] [--limit <1..128>] [--cursor <cursor>] [--name <name>] [--topic <topic>] [--thread-id <id>] [--server-name <name>] [--skill-id <id>] [--arguments <text>] [--after-sequence <sequence>]\nserve accepts repeated --codex-extra-skill-root and --claude-additional-directory.\nsession-evidence accepts --native-item-id and repeated --evidence-kind.\nitems reads newest first and accepts --text-limit <1..65536>, and --native-item-id with --turn-id for one item.\nitem-detail reads the detail of one item and takes --native-item-id and --turn-id.\nitem-image reads one image of an item and also takes --index <0..63>.\nobservation-pace takes --pace <live|background>.\nlocks lists the jg-locks locks on this machine with their holders; HQ never takes them.\nrequest reads one validated HQ command as JSON from stdin, such as action-wait.\n');
58
44
  return;
59
45
  }
60
46
  if (positionals.length !== 1 || !values['state-root'])
@@ -108,8 +94,7 @@ const main = async () => {
108
94
  return;
109
95
  }
110
96
  if (kind === 'serve') {
111
- if (values.directory ||
112
- values['native-id'] ||
97
+ if (values['native-id'] ||
113
98
  values['turn-id'] ||
114
99
  values['native-item-id'] ||
115
100
  values.index ||
@@ -131,9 +116,6 @@ const main = async () => {
131
116
  });
132
117
  const runtime = await createAgentHq({
133
118
  stateRoot,
134
- coordinationRoot: values['coordination-root']
135
- ? resolve(values['coordination-root'])
136
- : undefined,
137
119
  allowedRoots: roots,
138
120
  codexExtraSkillRoots: values['codex-extra-skill-root']?.map((path) => resolve(path)),
139
121
  claudeAdditionalDirectories: values['claude-additional-directory']?.map((path) => resolve(path)),
@@ -159,9 +141,7 @@ const main = async () => {
159
141
  }
160
142
  return;
161
143
  }
162
- if (values['codex-extra-skill-root'] ||
163
- values['claude-additional-directory'] ||
164
- values['coordination-root'])
144
+ if (values['codex-extra-skill-root'] || values['claude-additional-directory'])
165
145
  throw new Exception('The HQ request is invalid', {
166
146
  code: 'JG_AGENT_HQ_REQUEST_INVALID',
167
147
  data: { kind: 'invalid-request' },
@@ -171,36 +151,6 @@ const main = async () => {
171
151
  code: 'JG_AGENT_HQ_REQUEST_INVALID',
172
152
  data: { kind: 'invalid-request' },
173
153
  });
174
- if (kind === 'plan-status' || kind === 'plan-milestones') {
175
- const allowed = new Set([
176
- 'state-root',
177
- 'directory',
178
- ...(kind === 'plan-milestones' ? ['limit', 'cursor'] : []),
179
- ]);
180
- if (!values.directory || Object.keys(values).some((key) => !allowed.has(key)))
181
- throw new Exception('The HQ request is invalid', {
182
- code: 'JG_AGENT_HQ_REQUEST_INVALID',
183
- data: { kind: 'invalid-request' },
184
- });
185
- const parsed = HqRequestSchema.safeParse({
186
- kind: 'plan',
187
- command: {
188
- kind: kind === 'plan-status' ? 'status' : 'milestones',
189
- target: { directory: resolve(values.directory) },
190
- ...(kind === 'plan-milestones'
191
- ? { limit: values.limit === undefined ? 32 : Number(values.limit), cursor: values.cursor }
192
- : {}),
193
- },
194
- });
195
- if (!parsed.success)
196
- throw new Exception('The HQ request is invalid', {
197
- code: 'JG_AGENT_HQ_REQUEST_INVALID',
198
- data: { kind: 'invalid-request' },
199
- cause: parsed.error,
200
- });
201
- process.stdout.write(`${JSON.stringify({ schemaVersion: 1, ...(await requestAgentHq(stateRoot, parsed.data)) })}\n`);
202
- return;
203
- }
204
154
  if (kind === 'session-states') {
205
155
  const allowed = new Set(['state-root', 'after-sequence', 'limit']);
206
156
  if (Object.keys(values).some((key) => !allowed.has(key)))
@@ -222,14 +172,14 @@ const main = async () => {
222
172
  process.stdout.write(`${JSON.stringify({ schemaVersion: 1, ...(await requestAgentHq(stateRoot, parsed.data)) })}\n`);
223
173
  return;
224
174
  }
225
- if (kind === 'active-sessions' || kind === 'observation-pace') {
175
+ if (kind === 'active-sessions' || kind === 'observation-pace' || kind === 'locks') {
226
176
  const allowed = new Set(kind === 'observation-pace' ? ['state-root', 'pace'] : ['state-root']);
227
177
  if (Object.keys(values).some((key) => !allowed.has(key)))
228
178
  throw new Exception('The HQ request is invalid', {
229
179
  code: 'JG_AGENT_HQ_REQUEST_INVALID',
230
180
  data: { kind: 'invalid-request' },
231
181
  });
232
- const parsed = HqRequestSchema.safeParse(kind === 'active-sessions' ? { kind } : { kind, pace: values.pace });
182
+ const parsed = HqRequestSchema.safeParse(kind === 'observation-pace' ? { kind, pace: values.pace } : { kind });
233
183
  if (!parsed.success)
234
184
  throw new Exception('The HQ request is invalid', {
235
185
  code: 'JG_AGENT_HQ_REQUEST_INVALID',
@@ -239,7 +189,7 @@ const main = async () => {
239
189
  process.stdout.write(`${JSON.stringify({ schemaVersion: 1, ...(await requestAgentHq(stateRoot, parsed.data)) })}\n`);
240
190
  return;
241
191
  }
242
- if (values.directory || values['after-sequence'] || values.pace)
192
+ if (values['after-sequence'] || values.pace)
243
193
  throw new Exception('The HQ request is invalid', {
244
194
  code: 'JG_AGENT_HQ_REQUEST_INVALID',
245
195
  data: { kind: 'invalid-request' },
@@ -1,4 +1,2 @@
1
- export { PreparedInputSchema, ActionCommandSchema, ActionEnvelopeSchema, ActionReceiptSchema, ActionSummarySchema, ManagedThreadSchema, NativeApprovalSchema, NativeApprovalSummarySchema, ApprovalPresentationSchema, NativeElicitationSchema, LifecycleEventSchema, } from './types.js';
2
- export type { IPreparedInput, IActionCommand, IActionEnvelope, IActionReceipt, IActionSummary, IManagedThread, INativeApproval, INativeApprovalSummary, IApprovalPresentation, INativeElicitation, ILifecycleEvent, } from './types.js';
3
- export { PlanActionScopeSchema, ActionPlanContextSchema } from './types.js';
4
- export type { IPlanActionScope, IActionPlanContext } from './types.js';
1
+ export { PreparedInputSchema, ActionCommandSchema, ActionEnvelopeSchema, ActionReceiptSchema, ActionSummarySchema, ActionWaitSchema, ManagedThreadSchema, NativeApprovalSchema, NativeApprovalSummarySchema, ApprovalPresentationSchema, NativeElicitationSchema, LifecycleEventSchema, } from './types.js';
2
+ export type { IPreparedInput, IActionCommand, IActionEnvelope, IActionReceipt, IActionSummary, IActionWait, IManagedThread, INativeApproval, INativeApprovalSummary, IApprovalPresentation, INativeElicitation, ILifecycleEvent, } from './types.js';
@@ -1,4 +1,2 @@
1
1
  // action and control contracts
2
- export { PreparedInputSchema, ActionCommandSchema, ActionEnvelopeSchema, ActionReceiptSchema, ActionSummarySchema, ManagedThreadSchema, NativeApprovalSchema, NativeApprovalSummarySchema, ApprovalPresentationSchema, NativeElicitationSchema, LifecycleEventSchema, } from './types.js';
3
- // guided plan scope
4
- export { PlanActionScopeSchema, ActionPlanContextSchema } from './types.js';
2
+ export { PreparedInputSchema, ActionCommandSchema, ActionEnvelopeSchema, ActionReceiptSchema, ActionSummarySchema, ActionWaitSchema, ManagedThreadSchema, NativeApprovalSchema, NativeApprovalSummarySchema, ApprovalPresentationSchema, NativeElicitationSchema, LifecycleEventSchema, } from './types.js';
@@ -263,49 +263,6 @@ export declare const ActionCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
263
263
  kind: z.ZodLiteral<"native-reply">;
264
264
  }, z.core.$strict>], "kind">;
265
265
  export type IActionCommand = z.infer<typeof ActionCommandSchema>;
266
- export declare const PlanActionScopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
267
- kind: z.ZodLiteral<"execution">;
268
- authorizationId: z.ZodUUID;
269
- milestoneId: z.ZodNullable<z.ZodUUID>;
270
- mode: z.ZodEnum<{
271
- supervised: "supervised";
272
- auto: "auto";
273
- }>;
274
- revision: z.ZodObject<{
275
- planDigest: z.ZodString;
276
- breakdownDigest: z.ZodNullable<z.ZodString>;
277
- }, z.core.$strict>;
278
- }, z.core.$strict>, z.ZodObject<{
279
- kind: z.ZodLiteral<"planning">;
280
- revisionId: z.ZodUUID;
281
- invocationId: z.ZodUUID;
282
- }, z.core.$strict>], "kind">;
283
- export type IPlanActionScope = z.infer<typeof PlanActionScopeSchema>;
284
- export declare const ActionPlanContextSchema: z.ZodObject<{
285
- directory: z.ZodString;
286
- scope: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
287
- kind: z.ZodLiteral<"execution">;
288
- authorizationId: z.ZodUUID;
289
- milestoneId: z.ZodNullable<z.ZodUUID>;
290
- mode: z.ZodEnum<{
291
- supervised: "supervised";
292
- auto: "auto";
293
- }>;
294
- revision: z.ZodObject<{
295
- planDigest: z.ZodString;
296
- breakdownDigest: z.ZodNullable<z.ZodString>;
297
- }, z.core.$strict>;
298
- }, z.core.$strict>, z.ZodObject<{
299
- kind: z.ZodLiteral<"planning">;
300
- revisionId: z.ZodUUID;
301
- invocationId: z.ZodUUID;
302
- }, z.core.$strict>], "kind">>;
303
- observedRevision: z.ZodObject<{
304
- planDigest: z.ZodString;
305
- breakdownDigest: z.ZodNullable<z.ZodString>;
306
- }, z.core.$strict>;
307
- }, z.core.$strict>;
308
- export type IActionPlanContext = z.infer<typeof ActionPlanContextSchema>;
309
266
  export declare const ActionEnvelopeSchema: z.ZodObject<{
310
267
  id: z.ZodUUID;
311
268
  runtimeEpoch: z.ZodUUID;
@@ -546,47 +503,6 @@ export declare const ActionEnvelopeSchema: z.ZodObject<{
546
503
  expectedTurnId: z.ZodString;
547
504
  kind: z.ZodLiteral<"native-reply">;
548
505
  }, z.core.$strict>], "kind">;
549
- plan: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
550
- kind: z.ZodLiteral<"execution">;
551
- authorizationId: z.ZodUUID;
552
- milestoneId: z.ZodNullable<z.ZodUUID>;
553
- mode: z.ZodEnum<{
554
- supervised: "supervised";
555
- auto: "auto";
556
- }>;
557
- revision: z.ZodObject<{
558
- planDigest: z.ZodString;
559
- breakdownDigest: z.ZodNullable<z.ZodString>;
560
- }, z.core.$strict>;
561
- }, z.core.$strict>, z.ZodObject<{
562
- kind: z.ZodLiteral<"planning">;
563
- revisionId: z.ZodUUID;
564
- invocationId: z.ZodUUID;
565
- }, z.core.$strict>], "kind">>;
566
- expectedPlan: z.ZodOptional<z.ZodNullable<z.ZodObject<{
567
- directory: z.ZodString;
568
- scope: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
569
- kind: z.ZodLiteral<"execution">;
570
- authorizationId: z.ZodUUID;
571
- milestoneId: z.ZodNullable<z.ZodUUID>;
572
- mode: z.ZodEnum<{
573
- supervised: "supervised";
574
- auto: "auto";
575
- }>;
576
- revision: z.ZodObject<{
577
- planDigest: z.ZodString;
578
- breakdownDigest: z.ZodNullable<z.ZodString>;
579
- }, z.core.$strict>;
580
- }, z.core.$strict>, z.ZodObject<{
581
- kind: z.ZodLiteral<"planning">;
582
- revisionId: z.ZodUUID;
583
- invocationId: z.ZodUUID;
584
- }, z.core.$strict>], "kind">>;
585
- observedRevision: z.ZodObject<{
586
- planDigest: z.ZodString;
587
- breakdownDigest: z.ZodNullable<z.ZodString>;
588
- }, z.core.$strict>;
589
- }, z.core.$strict>>>;
590
506
  }, z.core.$strict>;
591
507
  export type IActionEnvelope = z.infer<typeof ActionEnvelopeSchema>;
592
508
  export declare const ActionReceiptSchema: z.ZodObject<{
@@ -629,6 +545,7 @@ export declare const ActionReceiptSchema: z.ZodObject<{
629
545
  applied: "applied";
630
546
  }>>;
631
547
  threadId: z.ZodNullable<z.ZodUUID>;
548
+ nativeThreadId: z.ZodNullable<z.ZodString>;
632
549
  nativeTurnId: z.ZodNullable<z.ZodString>;
633
550
  nativeRequestId: z.ZodNullable<z.ZodString>;
634
551
  delivery: z.ZodEnum<{
@@ -651,30 +568,6 @@ export declare const ActionReceiptSchema: z.ZodObject<{
651
568
  "operation-failed": "operation-failed";
652
569
  }>>;
653
570
  relatedActionId: z.ZodNullable<z.ZodUUID>;
654
- planContext: z.ZodNullable<z.ZodObject<{
655
- directory: z.ZodString;
656
- scope: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
657
- kind: z.ZodLiteral<"execution">;
658
- authorizationId: z.ZodUUID;
659
- milestoneId: z.ZodNullable<z.ZodUUID>;
660
- mode: z.ZodEnum<{
661
- supervised: "supervised";
662
- auto: "auto";
663
- }>;
664
- revision: z.ZodObject<{
665
- planDigest: z.ZodString;
666
- breakdownDigest: z.ZodNullable<z.ZodString>;
667
- }, z.core.$strict>;
668
- }, z.core.$strict>, z.ZodObject<{
669
- kind: z.ZodLiteral<"planning">;
670
- revisionId: z.ZodUUID;
671
- invocationId: z.ZodUUID;
672
- }, z.core.$strict>], "kind">>;
673
- observedRevision: z.ZodObject<{
674
- planDigest: z.ZodString;
675
- breakdownDigest: z.ZodNullable<z.ZodString>;
676
- }, z.core.$strict>;
677
- }, z.core.$strict>>;
678
571
  queuedInput: z.ZodNullable<z.ZodObject<{
679
572
  text: z.ZodString;
680
573
  skill: z.ZodNullable<z.ZodObject<{
@@ -772,15 +665,21 @@ export declare const ActionSummarySchema: z.ZodObject<{
772
665
  interrupted: "interrupted";
773
666
  }>>;
774
667
  id: z.ZodUUID;
775
- runtimeEpoch: z.ZodUUID;
776
668
  failure: z.ZodNullable<z.ZodEnum<{
777
669
  "state-conflict": "state-conflict";
778
670
  "access-denied": "access-denied";
779
671
  "agent-unavailable": "agent-unavailable";
780
672
  "operation-failed": "operation-failed";
781
673
  }>>;
674
+ runtimeEpoch: z.ZodUUID;
675
+ digest: z.ZodString;
676
+ controlState: z.ZodNullable<z.ZodEnum<{
677
+ held: "held";
678
+ accepted: "accepted";
679
+ applied: "applied";
680
+ }>>;
782
681
  nativeTurnId: z.ZodNullable<z.ZodString>;
783
- updatedAt: z.ZodNumber;
682
+ nativeRequestId: z.ZodNullable<z.ZodString>;
784
683
  delivery: z.ZodEnum<{
785
684
  failed: "failed";
786
685
  canceled: "canceled";
@@ -789,40 +688,134 @@ export declare const ActionSummarySchema: z.ZodObject<{
789
688
  submitted: "submitted";
790
689
  acknowledged: "acknowledged";
791
690
  }>;
792
- digest: z.ZodString;
793
- controlState: z.ZodNullable<z.ZodEnum<{
794
- held: "held";
795
- accepted: "accepted";
796
- applied: "applied";
797
- }>>;
798
- nativeRequestId: z.ZodNullable<z.ZodString>;
799
691
  relatedActionId: z.ZodNullable<z.ZodUUID>;
800
- planContext: z.ZodNullable<z.ZodObject<{
801
- directory: z.ZodString;
802
- scope: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
803
- kind: z.ZodLiteral<"execution">;
804
- authorizationId: z.ZodUUID;
805
- milestoneId: z.ZodNullable<z.ZodUUID>;
806
- mode: z.ZodEnum<{
807
- supervised: "supervised";
808
- auto: "auto";
809
- }>;
810
- revision: z.ZodObject<{
811
- planDigest: z.ZodString;
812
- breakdownDigest: z.ZodNullable<z.ZodString>;
813
- }, z.core.$strict>;
814
- }, z.core.$strict>, z.ZodObject<{
815
- kind: z.ZodLiteral<"planning">;
816
- revisionId: z.ZodUUID;
817
- invocationId: z.ZodUUID;
818
- }, z.core.$strict>], "kind">>;
819
- observedRevision: z.ZodObject<{
820
- planDigest: z.ZodString;
821
- breakdownDigest: z.ZodNullable<z.ZodString>;
822
- }, z.core.$strict>;
823
- }, z.core.$strict>>;
692
+ updatedAt: z.ZodNumber;
824
693
  }, z.core.$strip>;
825
694
  export type IActionSummary = z.infer<typeof ActionSummarySchema>;
695
+ export declare const ActionWaitSchema: z.ZodObject<{
696
+ receipt: z.ZodNullable<z.ZodObject<{
697
+ id: z.ZodUUID;
698
+ digest: z.ZodString;
699
+ runtimeEpoch: z.ZodUUID;
700
+ kind: z.ZodEnum<{
701
+ message: "message";
702
+ interrupt: "interrupt";
703
+ steer: "steer";
704
+ "account-login": "account-login";
705
+ "account-login-cancel": "account-login-cancel";
706
+ "account-logout": "account-logout";
707
+ "skills-reload": "skills-reload";
708
+ "mcp-reload": "mcp-reload";
709
+ "mcp-reconnect": "mcp-reconnect";
710
+ "mcp-set-enabled": "mcp-set-enabled";
711
+ "mcp-login": "mcp-login";
712
+ "plugins-reload": "plugins-reload";
713
+ "thread-create": "thread-create";
714
+ "thread-adopt": "thread-adopt";
715
+ "thread-resume": "thread-resume";
716
+ "thread-close": "thread-close";
717
+ "thread-fork": "thread-fork";
718
+ "thread-archive": "thread-archive";
719
+ "thread-unarchive": "thread-unarchive";
720
+ "thread-compact": "thread-compact";
721
+ "thread-revert": "thread-revert";
722
+ "thread-recover": "thread-recover";
723
+ "thread-rename": "thread-rename";
724
+ queue: "queue";
725
+ "queue-send": "queue-send";
726
+ "queue-cancel": "queue-cancel";
727
+ "native-reply": "native-reply";
728
+ }>;
729
+ provider: z.ZodNullable<z.ZodString>;
730
+ controlState: z.ZodNullable<z.ZodEnum<{
731
+ held: "held";
732
+ accepted: "accepted";
733
+ applied: "applied";
734
+ }>>;
735
+ threadId: z.ZodNullable<z.ZodUUID>;
736
+ nativeThreadId: z.ZodNullable<z.ZodString>;
737
+ nativeTurnId: z.ZodNullable<z.ZodString>;
738
+ nativeRequestId: z.ZodNullable<z.ZodString>;
739
+ delivery: z.ZodEnum<{
740
+ failed: "failed";
741
+ canceled: "canceled";
742
+ uncertain: "uncertain";
743
+ queued: "queued";
744
+ submitted: "submitted";
745
+ acknowledged: "acknowledged";
746
+ }>;
747
+ completion: z.ZodNullable<z.ZodEnum<{
748
+ completed: "completed";
749
+ failed: "failed";
750
+ interrupted: "interrupted";
751
+ }>>;
752
+ failure: z.ZodNullable<z.ZodEnum<{
753
+ "state-conflict": "state-conflict";
754
+ "access-denied": "access-denied";
755
+ "agent-unavailable": "agent-unavailable";
756
+ "operation-failed": "operation-failed";
757
+ }>>;
758
+ relatedActionId: z.ZodNullable<z.ZodUUID>;
759
+ queuedInput: z.ZodNullable<z.ZodObject<{
760
+ text: z.ZodString;
761
+ skill: z.ZodNullable<z.ZodObject<{
762
+ name: z.ZodString;
763
+ path: z.ZodNullable<z.ZodString>;
764
+ }, z.core.$strip>>;
765
+ files: z.ZodArray<z.ZodObject<{
766
+ path: z.ZodString;
767
+ mediaType: z.ZodEnum<{
768
+ "image/png": "image/png";
769
+ "image/jpeg": "image/jpeg";
770
+ "image/webp": "image/webp";
771
+ "image/gif": "image/gif";
772
+ "application/pdf": "application/pdf";
773
+ "text/plain": "text/plain";
774
+ }>;
775
+ sha256: z.ZodString;
776
+ bytes: z.ZodNumber;
777
+ }, z.core.$strict>>;
778
+ settings: z.ZodObject<{
779
+ model: z.ZodOptional<z.ZodString>;
780
+ effort: z.ZodOptional<z.ZodString>;
781
+ outputSchema: z.ZodOptional<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodJSONSchema>, unknown>>;
782
+ }, z.core.$strict>;
783
+ }, z.core.$strip>>;
784
+ result: z.ZodNullable<z.ZodObject<{
785
+ state: z.ZodEnum<{
786
+ completed: "completed";
787
+ failed: "failed";
788
+ interrupted: "interrupted";
789
+ }>;
790
+ format: z.ZodEnum<{
791
+ text: "text";
792
+ "json-schema": "json-schema";
793
+ }>;
794
+ text: z.ZodNullable<z.ZodString>;
795
+ structuredOutput: z.ZodNullable<z.ZodJSONSchema>;
796
+ isComplete: z.ZodBoolean;
797
+ failure: z.ZodNullable<z.ZodEnum<{
798
+ "native-error": "native-error";
799
+ "invalid-structured-output": "invalid-structured-output";
800
+ "result-too-large": "result-too-large";
801
+ "missing-result": "missing-result";
802
+ }>>;
803
+ usage: z.ZodNullable<z.ZodObject<{
804
+ inputTokens: z.ZodNullable<z.ZodNumber>;
805
+ outputTokens: z.ZodNullable<z.ZodNumber>;
806
+ cachedInputTokens: z.ZodNullable<z.ZodNumber>;
807
+ scope: z.ZodEnum<{
808
+ turn: "turn";
809
+ thread: "thread";
810
+ }>;
811
+ }, z.core.$strip>>;
812
+ }, z.core.$strip>>;
813
+ createdAt: z.ZodNumber;
814
+ updatedAt: z.ZodNumber;
815
+ }, z.core.$strip>>;
816
+ isTimedOut: z.ZodBoolean;
817
+ }, z.core.$strip>;
818
+ export type IActionWait = z.infer<typeof ActionWaitSchema>;
826
819
  export declare const ManagedThreadSchema: z.ZodObject<{
827
820
  id: z.ZodUUID;
828
821
  provider: z.ZodString;
@@ -848,11 +841,11 @@ export declare const ManagedThreadSchema: z.ZodObject<{
848
841
  completed: "completed";
849
842
  failed: "failed";
850
843
  interrupted: "interrupted";
851
- "waiting-input": "waiting-input";
852
844
  running: "running";
853
845
  creating: "creating";
854
846
  inactive: "inactive";
855
847
  starting: "starting";
848
+ "waiting-input": "waiting-input";
856
849
  "waiting-approval": "waiting-approval";
857
850
  stopping: "stopping";
858
851
  }>;