@aisac/cli 0.0.0-stage → 0.4.0-beta.2

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 (35) hide show
  1. package/README.md +166 -2
  2. package/dist/assets/claude/.claude-plugin/plugin.json +147 -0
  3. package/dist/assets/claude/hooks/context-compaction.ts +6930 -0
  4. package/dist/assets/claude/hooks/hooks.json +3 -0
  5. package/dist/assets/claude/hooks/native-host-contract-runtime.ts +18 -0
  6. package/dist/assets/claude/hooks/native-host-contract.test.ts +51 -0
  7. package/dist/assets/claude/hooks/provider-window.js +263 -0
  8. package/dist/assets/claude/hooks/state-fitting.d.mts +47 -0
  9. package/dist/assets/claude/hooks/state-fitting.mjs +324 -0
  10. package/dist/assets/codex-context-compaction.mjs +4689 -0
  11. package/dist/assets/context-selection-fitting.mjs +194 -0
  12. package/dist/assets/context-state-fitting.mjs +324 -0
  13. package/dist/assets/context-telemetry-reporter.mjs +305 -0
  14. package/dist/assets/jev-paid-pilot-terminal.mjs +1066 -0
  15. package/dist/claude-checkpoint.mjs +1338 -0
  16. package/dist/claude-compatibility.mjs +506 -0
  17. package/dist/claude-observation.mjs +1338 -0
  18. package/dist/cli.mjs +771 -0
  19. package/dist/codex-compatibility.mjs +481 -0
  20. package/dist/codex-diagnostics.mjs +447 -0
  21. package/dist/codex-permissions.mjs +590 -0
  22. package/dist/codex-protocol-fingerprint.json +131 -0
  23. package/dist/context-telemetry.mjs +257 -0
  24. package/dist/engineering-pack-public-key.json +10 -0
  25. package/dist/engineering-pack.mjs +722 -0
  26. package/dist/engineering.mjs +194 -0
  27. package/dist/launch.mjs +690 -0
  28. package/dist/mcp.mjs +962 -0
  29. package/dist/monitor.mjs +133 -0
  30. package/dist/package.json +5 -0
  31. package/dist/platform.mjs +126 -0
  32. package/dist/policy.mjs +218 -0
  33. package/dist/state.mjs +408 -0
  34. package/dist/telemetry-report.mjs +133 -0
  35. package/package.json +24 -4
package/README.md CHANGED
@@ -1,3 +1,167 @@
1
- # Temporary Holding Version
1
+ # aisac
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The AISAC client for Claude Code and Codex on Linux/WSL with Node.js 22 or newer:
4
+ AI Brain memory, context management and, for AISAC Founding Cohort members,
5
+ AISAC Engineering.
6
+
7
+ The command is `aisac`. `aibrain` is an alias for the same program, so existing
8
+ scripts and habits keep working. The same files are published as `@aisac/cli`
9
+ and, for existing installs, `@brunobracaioli/aibrain`. Install only one of them:
10
+ both provide the `aisac` and `aibrain` commands. State stays in `~/.aibrain`.
11
+
12
+ `aisac setup` and `aisac doctor` report the AISAC Engineering license
13
+ (`active`, `inactive` or `unavailable`). The server decides; the client only
14
+ shows the answer and sends the request only to the configured AI Brain address.
15
+ `aisac status` stays offline.
16
+
17
+ For licensed accounts, `aisac claude` downloads the AISAC Engineering pack for
18
+ the session, verifies its Ed25519 signature against the key pinned in this
19
+ release, and loads it as the `aisac-engineering` plugin from the session's
20
+ private folder, which is deleted on exit. Any failure starts Claude without the
21
+ pack. `aisac setup --lang pt-BR|en` picks the pack language without a network
22
+ call. The pack is never part of this npm package.
23
+
24
+ Codex capture also requires the `flock` utility from `util-linux`, normally
25
+ included in Linux/WSL. The launcher and doctor check availability before a
26
+ monitored Codex session starts. Capture coordination is released by the kernel
27
+ after a process exits unexpectedly. An unidentifiable empty lock left by an
28
+ older client requires a verified support migration; do not delete checkpoints,
29
+ notes or lock files to work around a reported storage error.
30
+
31
+ The reviewed native compatibility set is Claude Code 2.1.294, 2.1.295, 2.1.296,
32
+ 2.1.299, 2.1.300, 2.1.301, 2.1.302 or 2.1.303, and Codex CLI 0.161.0,
33
+ 0.162.0, 0.162.1, 0.163.0 or 0.164.0. A newer stable Codex 0.x release may continue only
34
+ after its locally generated experimental protocol schemas and transport flags
35
+ match the bundled adapter contract; prereleases, older releases and new majors
36
+ remain rejected. Starting with beta14, newer stable Claude 2.1 patches can
37
+ continue after isolated strict plugin validation, required hook/API checks and
38
+ an enabled-hook test in the native offline runner. Doctor distinguishes
39
+ `host_checked` from `qualified`; this check does not establish full behavioral
40
+ equivalence with a tested native release. Unknown older patches, prereleases
41
+ and other major/minor families remain rejected. No credentials, conversations,
42
+ model requests or JEV calls are used by these compatibility probes.
43
+
44
+ Beta17 refreshes the Codex contract to 0.164.0, including its image-generation
45
+ record formats. Native launch/resume qualification is separate from a new
46
+ model/JEV compaction qualification. A later native release that changes the
47
+ consumed contract can still require an AI Brain compatibility update.
48
+
49
+ The Codex terminal bridge permits the native session picker's separate read-only
50
+ connection while keeping the primary conversation and monitor intact. A picker
51
+ cannot compact, start a turn, inject history or take ownership of the primary
52
+ connection. Its failure or timeout closes only that auxiliary connection.
53
+
54
+ ```sh
55
+ # Install the published beta:
56
+ npm install -g @aisac/cli@beta
57
+ aisac setup --client both
58
+ aisac doctor --json
59
+ aisac claude
60
+ aisac codex
61
+ ```
62
+
63
+ To move from `@brunobracaioli/aibrain` to `@aisac/cli`, close running sessions,
64
+ then run `npm uninstall -g @brunobracaioli/aibrain` before
65
+ `npm install -g @aisac/cli@beta`. Setup, notes and checkpoints are kept.
66
+
67
+ Installation does not contact AI Brain, change native client configuration, or
68
+ enable all paid accounts. Setup requires an existing AI Brain PAT, explicit
69
+ versioned disclosure, and successful provider-free pilot access. Claude and
70
+ Codex continue to own their own authentication. Windows native is unsupported;
71
+ run the beta inside WSL. Pricing and general customer activation are outside
72
+ this beta.
73
+
74
+ For reviewed noninteractive automation only, use a private token file and
75
+ explicitly acknowledge the displayed disclosure with
76
+ `aibrain setup --client both --token-file /private/path/brain.pat
77
+ --accept-disclosure`.
78
+
79
+ For a CI-reviewed tarball, use `aisac-cli-*.tgz` with
80
+ `npm install -g ./aisac-cli-*.tgz` (the same files are also packed as
81
+ `brunobracaioli-aibrain-*.tgz`); registry installation is gated on the
82
+ operator's npm review and authentication.
83
+
84
+ For users of an earlier unscoped review tarball, close its client sessions,
85
+ run `npm uninstall -g aibrain`, and install this scoped package. Local
86
+ `~/.aibrain` state, notes, and checkpoints are retained.
87
+
88
+ This `0.3` client adds configurable context profiles. A fresh
89
+ setup defaults to `upstream`: 60% trigger, 0.5 keep threshold, six recent items
90
+ protected, and broader completed text-tool eligibility in Claude. Existing
91
+ schema1 configurations keep their previous behavior. After a reviewed v2 backend
92
+ and client release, opt in explicitly with:
93
+
94
+ ```sh
95
+ aibrain setup --client both --context-profile upstream
96
+ # Or retain conservative retention with the v2 protocol:
97
+ aibrain setup --client both --context-profile conservative
98
+ ```
99
+
100
+ Use `aibrain --help` for individual overrides. Claude-only flags are rejected for
101
+ Codex-only setup. Status and doctor show effective settings without custom goal
102
+ text; they do not claim that a live session is being monitored. Codex keeps native
103
+ compaction and recovery notes in the same thread. The backend checks paid access
104
+ and unchanged shared quotas before any JEV request.
105
+
106
+ The `0.3.0-beta.14` Claude launcher uses the durable context strategy and
107
+ records bounded recovery reasons when native summary proof cannot be confirmed:
108
+ JEV selects compatible historical tool evidence, bounded private notes retain
109
+ the selected text, and Claude core summarizes the reduced input. The next
110
+ prompt restores those notes in the same session after verifying native state.
111
+ The final native context contains a summary; this is not summary-free transcript
112
+ replacement. Direct hook-owned history replacement remains experimental because
113
+ resume can replay older content in affected Claude versions.
114
+
115
+ The notes preserve only the selected retained text that fits the local bound;
116
+ oversized entries are omitted as whole entries and counted. The separate full
117
+ checkpoint has its own retention. Neither path guarantees perfect preservation
118
+ of every internal host field. Shadow prefiltering continues to observe without
119
+ changing tool results. Native qualification and publication evidence is tracked
120
+ in the [release record](https://github.com/brunobracaioli/mcp-ai-brain/blob/main/docs/reference/claude-durable-context-2026-10-14.md).
121
+
122
+ The launcher grants the native clients the provider-free `brain_context_budget`
123
+ read alongside the existing context tools. It is a short-lived advisory snapshot,
124
+ not a billing meter, reservation, or provider authorization; atomic admission
125
+ remains authoritative.
126
+
127
+ Codex diagnostics are kept in the launched adapter's private state directory.
128
+ `aibrain diagnostics --client codex --json` shows only bounded stages, closed
129
+ reasons, pseudonymous session identifiers, client versions, and small numeric
130
+ counters. Prompts, notes, paths, credentials, raw errors, and app-server stdout
131
+ are excluded.
132
+
133
+ Beta12 reads large Codex histories in bounded pages and keeps their complete
134
+ contents in verified private capture segments. It checks history again before
135
+ selection and before native compaction; notes and recovery stay in the same
136
+ thread. Older captures remain readable. A single turn exceeding 8 MiB, a capture
137
+ exceeding the bounded page/item/128 MiB limits, or exhausted private storage is
138
+ reported explicitly. Such a failure does not authorize discarding protected
139
+ history or retrying a paid operation. The private capture directory remains
140
+ bounded to 256 MiB and 128 managed files, with current recovery references
141
+ protected from cleanup.
142
+
143
+ Claude plan diagnostics distinguish response parsing, identity, expiry and
144
+ history changes. A text JSON plan can use the same 256 KiB limit as structured
145
+ plans; smaller budget/error envelopes retain their separate limits. These local
146
+ diagnostics contain format names and numeric sizes, never plan contents.
147
+
148
+ Context dashboard telemetry is disabled for fresh and existing configurations.
149
+ Enable it only after reviewing the extended disclosure:
150
+
151
+ ```sh
152
+ aibrain setup --client both --telemetry on --accept-disclosure
153
+ ```
154
+
155
+ Omit `--telemetry` to preserve the stored choice, or use `--telemetry off` to stop
156
+ future-launch reports. Settings are captured when a client starts, so close and
157
+ restart currently monitored sessions after opting out to stop their reporting.
158
+ Enabled reports use the existing authenticated MCP transport and
159
+ contain only a hashed native session key, random lifecycle identifiers, native
160
+ client version, phase, timestamps, numeric counts, and allowed measurements or
161
+ reasons. Prompts, notes, paths, tool names, credentials, and raw errors are not
162
+ reported. The dashboard shows a 30-day visible window; physical cleanup runs on
163
+ the next successful daily cleanup. Delivery failure never fails or triggers a
164
+ context operation.
165
+
166
+ Read the [canonical subscriber beta guide](https://github.com/brunobracaioli/mcp-ai-brain/blob/main/docs/how-to/aibrain-subscriber-beta.md)
167
+ for setup, support, disclosure, limits, and disable procedures.
@@ -0,0 +1,147 @@
1
+ {
2
+ "name": "ai-brain-context-compaction",
3
+ "version": "0.3.0-beta.14",
4
+ "author": { "name": "AISAC" },
5
+ "description": "AI Brain paid-plan context monitoring with conservative Claude compaction fallback.",
6
+ "hooks": "./hooks/hooks.json",
7
+ "userConfig": {
8
+ "policyVersion": {
9
+ "type": "number",
10
+ "title": "Context policy version",
11
+ "description": "Use 2 for configurable broader parity; omit or use 1 to preserve legacy behavior.",
12
+ "default": 1
13
+ },
14
+ "brainServer": {
15
+ "type": "string",
16
+ "title": "AI Brain MCP server",
17
+ "description": "The name of the already authenticated AI Brain MCP server. The hook uses that connection and never accepts a JEV key.",
18
+ "default": "brain"
19
+ },
20
+ "compactAtPercent": {
21
+ "type": "number",
22
+ "title": "Context threshold",
23
+ "description": "Request host compaction at or above this reported context percentage.",
24
+ "default": 85
25
+ },
26
+ "keepThreshold": {
27
+ "type": "number",
28
+ "title": "JEV keep threshold",
29
+ "description": "V2 score threshold for retaining eligible content.",
30
+ "default": 0.5
31
+ },
32
+ "preserveRecentMessages": {
33
+ "type": "number",
34
+ "title": "Recent messages to preserve",
35
+ "description": "Number of recent messages pinned before scoring.",
36
+ "default": 6
37
+ },
38
+ "minReductionRatio": {
39
+ "type": "number",
40
+ "title": "Minimum reduction ratio",
41
+ "description": "Minimum configured reduction required before returning a candidate.",
42
+ "default": 0.25
43
+ },
44
+ "truncateHeadChars": {
45
+ "type": "number",
46
+ "title": "Truncated result head characters",
47
+ "description": "Unicode-safe head size for eligible result truncation.",
48
+ "default": 300
49
+ },
50
+ "maxStateTokens": {
51
+ "type": "number",
52
+ "title": "Maximum scoring state units",
53
+ "description": "Upper bound for the provider scoring state.",
54
+ "default": 25000
55
+ },
56
+ "maxRequestTokens": {
57
+ "type": "number",
58
+ "title": "Maximum scoring request units",
59
+ "description": "Upper bound for the provider scoring request.",
60
+ "default": 30000
61
+ },
62
+ "toolPolicy": {
63
+ "type": "string",
64
+ "title": "Claude tool policy",
65
+ "description": "Use read_only or compatible v2 eligibility.",
66
+ "default": "compatible"
67
+ },
68
+ "goal": {
69
+ "type": "string",
70
+ "title": "Private task goal",
71
+ "description": "Optional bounded private task goal sent in the redacted projection.",
72
+ "default": ""
73
+ },
74
+ "enabled": {
75
+ "type": "boolean",
76
+ "title": "Enable automatic compaction",
77
+ "description": "Requires explicit local opt-in and AI Brain disclosure; failures use Claude's built-in fallback.",
78
+ "default": false
79
+ },
80
+ "disclosed": {
81
+ "type": "boolean",
82
+ "title": "Projection disclosure acknowledged",
83
+ "description": "Allow the redacted projection to be sent to AI Brain for the paid-gated plan.",
84
+ "default": false
85
+ },
86
+ "preservationMode": {
87
+ "type": "string",
88
+ "title": "Claude preservation mode",
89
+ "description": "preserve_internal keeps handled messages intact. upstream_compatible rebuilds selected handled read messages from exposed fields and may lose hidden engine metadata.",
90
+ "default": "preserve_internal"
91
+ },
92
+ "compactionStrategy": {
93
+ "type": "string",
94
+ "title": "Compaction strategy",
95
+ "description": "direct_experimental returns a hook-owned transcript; native_summary_notes delegates the final summary to Claude core and keeps selected evidence in private notes.",
96
+ "default": "direct_experimental"
97
+ },
98
+ "diagnosticMode": {
99
+ "type": "boolean",
100
+ "title": "Emit runtime diagnostics",
101
+ "description": "Opt-in content-free hook entry diagnostics for local pilot verification.",
102
+ "default": false
103
+ },
104
+ "telemetryEnabled": {
105
+ "type": "boolean",
106
+ "title": "Enable context dashboard telemetry",
107
+ "description": "Opt-in operational telemetry for the authenticated Contexto dashboard. The launcher enables this only after the extended AI Brain disclosure.",
108
+ "default": false
109
+ },
110
+ "telemetryDisclosed": {
111
+ "type": "boolean",
112
+ "title": "Context telemetry disclosure acknowledged",
113
+ "description": "Permit content-free lifecycle reports containing a hashed session key, bounded measurements, counts, phases and reasons.",
114
+ "default": false
115
+ },
116
+ "telemetryClientVersion": {
117
+ "type": "string",
118
+ "title": "Native Claude version",
119
+ "description": "Launcher-provided native semver used to label telemetry; empty values keep telemetry inactive.",
120
+ "default": ""
121
+ },
122
+ "telemetryNodePath": {
123
+ "type": "string",
124
+ "title": "Owned telemetry Node path",
125
+ "description": "Launcher-provided absolute Node executable path for the report helper.",
126
+ "default": ""
127
+ },
128
+ "telemetryHelperPath": {
129
+ "type": "string",
130
+ "title": "Owned telemetry helper path",
131
+ "description": "Launcher-provided absolute report-only helper path.",
132
+ "default": ""
133
+ },
134
+ "telemetryStateDir": {
135
+ "type": "string",
136
+ "title": "Owned telemetry state path",
137
+ "description": "Launcher-provided private aibrain state directory for the helper.",
138
+ "default": ""
139
+ },
140
+ "telemetryConfigDigest": {
141
+ "type": "string",
142
+ "title": "Owned telemetry configuration binding",
143
+ "description": "Launcher-provided binding for the private endpoint, token and disclosure state.",
144
+ "default": ""
145
+ }
146
+ }
147
+ }