jg-agent-hq 2.0.0 → 3.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 (75) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +4 -4
  3. package/api/README.md +51 -8
  4. package/dist/cli/cli.js +35 -3
  5. package/dist/cli/utilities.d.ts +3 -0
  6. package/dist/cli/utilities.js +30 -0
  7. package/dist/contracts/index.d.ts +2 -2
  8. package/dist/contracts/index.js +1 -1
  9. package/dist/contracts/types.d.ts +102 -0
  10. package/dist/contracts/types.js +24 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.js +2 -0
  13. package/dist/plans/authority.d.ts +2 -0
  14. package/dist/plans/authority.js +8 -0
  15. package/dist/plans/documents.d.ts +17 -0
  16. package/dist/plans/documents.js +24 -2
  17. package/dist/plans/files.js +3 -1
  18. package/dist/plans/plans.js +3 -1
  19. package/dist/plans/types.d.ts +5 -0
  20. package/dist/providers/claude/claude.js +2 -0
  21. package/dist/providers/claude/history/types.d.ts +23 -0
  22. package/dist/providers/claude/transformers.js +14 -1
  23. package/dist/providers/codex/codex.js +4 -0
  24. package/dist/providers/codex/transformers.js +30 -3
  25. package/dist/providers/codex/types.d.ts +34 -1
  26. package/dist/providers/codex/types.js +11 -2
  27. package/dist/runtime/runtime.d.ts +2 -0
  28. package/dist/runtime/runtime.js +2 -0
  29. package/dist/runtime/state/index.d.ts +1 -1
  30. package/dist/runtime/state/index.js +1 -1
  31. package/dist/runtime/state/state.d.ts +16 -1
  32. package/dist/runtime/state/state.js +94 -3
  33. package/dist/snapshots/capture.d.ts +14 -0
  34. package/dist/snapshots/capture.js +142 -0
  35. package/dist/snapshots/database.d.ts +2 -0
  36. package/dist/snapshots/database.js +15 -51
  37. package/dist/snapshots/fences.d.ts +15 -0
  38. package/dist/snapshots/fences.js +64 -0
  39. package/dist/snapshots/index.d.ts +2 -0
  40. package/dist/snapshots/index.js +3 -0
  41. package/dist/snapshots/snapshots.d.ts +4 -1
  42. package/dist/snapshots/snapshots.js +27 -113
  43. package/dist/snapshots/snapshots.worker.js +5 -1
  44. package/dist/snapshots/types.d.ts +11 -0
  45. package/dist/snapshots/types.js +5 -1
  46. package/dist/storage/index.d.ts +2 -1
  47. package/dist/storage/index.js +2 -1
  48. package/dist/storage/schema/constants.d.ts +2 -0
  49. package/dist/storage/schema/constants.js +3 -0
  50. package/dist/storage/schema/index.d.ts +4 -0
  51. package/dist/storage/schema/index.js +5 -0
  52. package/dist/storage/schema/schema.d.ts +16 -0
  53. package/dist/storage/schema/schema.js +73 -0
  54. package/dist/storage/schema/types.d.ts +17 -0
  55. package/dist/storage/schema/types.js +8 -0
  56. package/dist/storage/schema/v1-to-v2.sql +1 -0
  57. package/dist/storage/schema/v1.sql +538 -0
  58. package/dist/storage/types.d.ts +0 -5
  59. package/dist/storage/types.js +0 -6
  60. package/dist/storage/upgrade/index.d.ts +2 -0
  61. package/dist/storage/upgrade/index.js +2 -0
  62. package/dist/storage/upgrade/types.d.ts +61 -0
  63. package/dist/storage/upgrade/types.js +42 -0
  64. package/dist/storage/upgrade/upgrade.d.ts +33 -0
  65. package/dist/storage/upgrade/upgrade.js +196 -0
  66. package/dist/storage/upgrade/upgrade.worker.d.ts +1 -0
  67. package/dist/storage/upgrade/upgrade.worker.js +220 -0
  68. package/dist/store/schema.d.ts +2 -0
  69. package/dist/store/schema.js +16 -25
  70. package/dist/store/schema.sql +2 -1
  71. package/dist/store/store.d.ts +2 -0
  72. package/dist/store/store.js +2 -0
  73. package/docs/recovery.md +15 -1
  74. package/errors/README.md +34 -28
  75. package/package.json +2 -2
package/errors/README.md CHANGED
@@ -26,33 +26,39 @@ Recovery never automatically deletes an inactive, unreadable, incomplete or unve
26
26
 
27
27
  These contracts use the named codes below. An Exception's `data.kind` classifies its safe wire mapping. Native codes, when present in diagnostic metadata, belong to the native protocol and are not HQ error codes. Claude control error responses carry `nativeRejection: true` internally because that protocol supplies no numeric error code. Internal diagnostic causes are never copied into IPC error responses.
28
28
 
29
- | Code | Stable message |
30
- | -------------------------------------- | ---------------------------------------------------------------- |
31
- | JG_AGENT_HQ_STATE_DIRECTORY_UNSAFE | The HQ state directory is unsafe |
32
- | JG_AGENT_HQ_STATE_FILE_UNSAFE | The HQ state file is unsafe |
33
- | JG_AGENT_HQ_RUNTIME_ALREADY_OWNED | The HQ runtime is already owned |
34
- | JG_AGENT_HQ_RUNTIME_OWNER_UNVERIFIABLE | The HQ runtime owner is unverifiable |
35
- | JG_AGENT_HQ_REQUEST_INVALID | The HQ request is invalid |
36
- | JG_AGENT_HQ_TARGET_FORBIDDEN | The HQ target is outside the allowed workspaces |
37
- | JG_AGENT_HQ_CURSOR_INVALID | The HQ cursor does not match this request |
38
- | JG_AGENT_HQ_CODEX_FAILED | The Codex integration failed |
39
- | JG_AGENT_HQ_CLAUDE_FAILED | The Claude integration failed |
40
- | JG_AGENT_HQ_CLAUDE_HISTORY_UNAVAILABLE | The Claude history is unavailable |
41
- | JG_AGENT_HQ_TRANSPORT_FAILED | The HQ transport failed |
42
- | JG_AGENT_HQ_STORE_FAILED | The HQ store failed |
43
- | JG_AGENT_HQ_STORAGE_INVALID | The HQ storage is invalid |
44
- | JG_AGENT_HQ_SNAPSHOT_INVALID | The HQ snapshot is invalid |
45
- | JG_AGENT_HQ_SNAPSHOT_FAILED | The HQ snapshot operation failed |
46
- | JG_AGENT_HQ_PROVIDER_FAILED | The HQ provider integration failed |
47
- | JG_AGENT_HQ_CAPABILITY_UNAVAILABLE | The HQ capability is unavailable |
48
- | JG_AGENT_HQ_RUNTIME_NOT_RUNNING | The HQ runtime is not running |
49
- | JG_AGENT_HQ_ACTION_CONFLICT | The HQ action conflicts with its recorded state |
50
- | JG_AGENT_HQ_COLLABORATION_FORBIDDEN | The HQ collaboration operation is not authorized |
51
- | JG_AGENT_HQ_COLLABORATION_CONFLICT | The HQ collaboration operation conflicts with its recorded state |
52
- | JG_AGENT_HQ_ACTION_KEY_UNAVAILABLE | The HQ action key is unavailable |
53
- | JG_AGENT_HQ_SKILL_UNAVAILABLE | The HQ skill is unavailable |
54
- | JG_AGENT_HQ_PLAN_INVALID | The HQ plan is invalid |
55
- | JG_AGENT_HQ_PLAN_FAILED | The HQ plan operation failed |
29
+ | Code | Stable message |
30
+ | --------------------------------------- | ---------------------------------------------------------------- |
31
+ | JG_AGENT_HQ_STATE_DIRECTORY_UNSAFE | The HQ state directory is unsafe |
32
+ | JG_AGENT_HQ_STATE_FILE_UNSAFE | The HQ state file is unsafe |
33
+ | JG_AGENT_HQ_RUNTIME_ALREADY_OWNED | The HQ runtime is already owned |
34
+ | JG_AGENT_HQ_RUNTIME_OWNER_UNVERIFIABLE | The HQ runtime owner is unverifiable |
35
+ | JG_AGENT_HQ_REQUEST_INVALID | The HQ request is invalid |
36
+ | JG_AGENT_HQ_TARGET_FORBIDDEN | The HQ target is outside the allowed workspaces |
37
+ | JG_AGENT_HQ_CURSOR_INVALID | The HQ cursor does not match this request |
38
+ | JG_AGENT_HQ_CODEX_FAILED | The Codex integration failed |
39
+ | JG_AGENT_HQ_CLAUDE_FAILED | The Claude integration failed |
40
+ | JG_AGENT_HQ_CLAUDE_HISTORY_UNAVAILABLE | The Claude history is unavailable |
41
+ | JG_AGENT_HQ_TRANSPORT_FAILED | The HQ transport failed |
42
+ | JG_AGENT_HQ_STORE_FAILED | The HQ store failed |
43
+ | JG_AGENT_HQ_STORAGE_INVALID | The HQ storage is invalid |
44
+ | JG_AGENT_HQ_STORAGE_UPGRADE_REQUIRED | The HQ storage requires an explicit upgrade |
45
+ | JG_AGENT_HQ_STORAGE_VERSION_UNSUPPORTED | The HQ storage version is unsupported |
46
+ | JG_AGENT_HQ_STORAGE_UPGRADE_FAILED | The HQ storage upgrade failed |
47
+ | JG_AGENT_HQ_STORAGE_UPGRADE_UNCERTAIN | The HQ storage upgrade requires reconciliation |
48
+ | JG_AGENT_HQ_SNAPSHOT_INVALID | The HQ snapshot is invalid |
49
+ | JG_AGENT_HQ_SNAPSHOT_FAILED | The HQ snapshot operation failed |
50
+ | JG_AGENT_HQ_PROVIDER_FAILED | The HQ provider integration failed |
51
+ | JG_AGENT_HQ_CAPABILITY_UNAVAILABLE | The HQ capability is unavailable |
52
+ | JG_AGENT_HQ_RUNTIME_NOT_RUNNING | The HQ runtime is not running |
53
+ | JG_AGENT_HQ_ACTION_CONFLICT | The HQ action conflicts with its recorded state |
54
+ | JG_AGENT_HQ_COLLABORATION_FORBIDDEN | The HQ collaboration operation is not authorized |
55
+ | JG_AGENT_HQ_COLLABORATION_CONFLICT | The HQ collaboration operation conflicts with its recorded state |
56
+ | JG_AGENT_HQ_ACTION_KEY_UNAVAILABLE | The HQ action key is unavailable |
57
+ | JG_AGENT_HQ_SKILL_UNAVAILABLE | The HQ skill is unavailable |
58
+ | JG_AGENT_HQ_PLAN_INVALID | The HQ plan is invalid |
59
+ | JG_AGENT_HQ_PLAN_FAILED | The HQ plan operation failed |
60
+
61
+ Storage version/upgrade-required errors use state-conflict. Upgrade failed/uncertain errors use operation-failed. An uncertain upgrade never retries or reverses automatically; trusted Node diagnostics retain the phase and selected verified backup when available. CLI presentation exposes only static canonical messages.
56
62
 
57
63
  State safety rejects non-private ownership, symlinks and non-regular files. ACTION_KEY_UNAVAILABLE also rejects a valid-length key whose fingerprint differs from the database stamp, before opening a writer. Runtime ownership is never reclaimed automatically. Transport failure includes malformed, oversized or incomplete frames and bounded-request/lifecycle failures. Native history and subscription failures remain unavailable, never successful empty results. Claude control rejects missing or non-idle initialization, invalid native session identities and malformed lifecycle evidence. Failed delivery remains uncertain when no exact native rejection or acknowledgement establishes its outcome.
58
64
 
@@ -74,7 +80,7 @@ Input-file admission reuses REQUEST_INVALID for invalid media, malformed UTF-8 a
74
80
 
75
81
  Native form replies reuse REQUEST_INVALID for content outside the exact requested schema or response kind. Stale, expired, cross-thread or already answered request identities use ACTION_CONFLICT. Native writes without matching consumption evidence remain submitted or uncertain; expiry never proves a response was rejected. Unsupported native request variants are denied on their own native channel without granting permission.
76
82
 
77
- Plan validation rejects unsupported framing, duplicate or misplaced milestone IDs, invalid frontmatter boundaries, non-regular artifacts and oversized inputs. Plan operation failures retain safe operation diagnostics inside the trusted host. Document-lock contention uses ACTION_CONFLICT with reason document-locked. Document lock failures use PLAN_FAILED with the observed phase and a truthful not-applied or uncertain outcome. An applied write whose lock release fails keeps its prepared journal payload. A failed ledger acknowledgement is reconciled from durable state; an unavailable observation uses STORE_FAILED and keeps admission closed. Stale revisions, presentation hashes, replay payload conflicts, revoked authority and unresolved writes use the existing action-state conflict contract. Unresolved correspondence, unverified done evidence, live scope changes, stale runtime authority and unproven quiescence also use the action-state conflict contract. Failed native cleanup retains the checkpoint and closes the editing gate. Neither validation nor write recovery can grant native permissions. Whole-plan selection conflicts with a real breakdown, duplicate live implementation ownership, completed contracts and revoked implementation follow-up authority use the same action-state conflict contract. A valid sequence approval request for a plan without a sequence also conflicts.
83
+ Plan validation rejects unsupported framing, duplicate or misplaced milestone IDs, invalid frontmatter boundaries, non-regular artifacts and oversized inputs. Plan approval, finalization, sequence approval and authorization also reject a protocol 0.2 plan that fails the jg-plans check; `jg-plans check --directory <plan>` reports why. Reading such a plan is unaffected. Plan operation failures retain safe operation diagnostics inside the trusted host. Document-lock contention uses ACTION_CONFLICT with reason document-locked. Document lock failures use PLAN_FAILED with the observed phase and a truthful not-applied or uncertain outcome. An applied write whose lock release fails keeps its prepared journal payload. A failed ledger acknowledgement is reconciled from durable state; an unavailable observation uses STORE_FAILED and keeps admission closed. Stale revisions, presentation hashes, replay payload conflicts, revoked authority and unresolved writes use the existing action-state conflict contract. Unresolved correspondence, unverified done evidence, live scope changes, stale runtime authority and unproven quiescence also use the action-state conflict contract. Failed native cleanup retains the checkpoint and closes the editing gate. Neither validation nor write recovery can grant native permissions. Whole-plan selection conflicts with a real breakdown, duplicate live implementation ownership, completed contracts and revoked implementation follow-up authority use the same action-state conflict contract. A valid sequence approval request for a plan without a sequence also conflicts.
78
84
 
79
85
  Agent-tool admission reuses COLLABORATION_FORBIDDEN for an unknown/revoked bridge credential, stale native/runtime/turn binding or insufficient task membership. COLLABORATION_CONFLICT covers changed spawn identities and exhausted spawn capacity. Private credential parsing discards secret-bearing diagnostic causes. Credential setup/cleanup failures use TRANSPORT_FAILED. Native tool results and MCP failures contain only the existing safe public error classification and code. An admitted native spawn retains its durable failed/uncertain receipt; a tool timeout or lost client connection never proves native creation failed.
80
86
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jg-agent-hq",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
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",
@@ -51,7 +51,7 @@
51
51
  "jg-crypto": "0.3.0",
52
52
  "jg-exception": "^1.7.0",
53
53
  "jg-fs": "1.7.0",
54
- "jg-plans": "0.2.0",
54
+ "jg-plans": "0.3.0",
55
55
  "jg-utilities": "1.7.0",
56
56
  "zod": "^4.3.6"
57
57
  },