@brunobracaioli/aibrain 0.4.0-beta.26 → 0.4.0-beta.28
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/README.md +14 -2
- package/dist/claude-observation.mjs +1 -1
- package/dist/cli.mjs +120 -6
- package/dist/engineering-pack.mjs +48 -2
- package/dist/guardrails-plugin.mjs +4 -1
- package/dist/launch-banner-art.json +40 -0
- package/dist/launch-banner.mjs +533 -0
- package/dist/launch.mjs +119 -26
- package/dist/managed-host.mjs +80 -0
- package/dist/manager/launch-role.mjs +1 -1
- package/dist/package.json +1 -1
- package/dist/token-guide.mjs +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,16 @@ roles. Nothing is written to `~/.codex`, `~/.agents` or the project, and the
|
|
|
30
30
|
session's folder is deleted on exit. An older Codex starts without the pack and
|
|
31
31
|
says `codex_outdated`.
|
|
32
32
|
|
|
33
|
+
In an interactive terminal (client `0.4.0-beta.28` or later), `aisac claude` and
|
|
34
|
+
`aisac codex` open with the AISAC Engineering banner: the brand mark, the ΛISΛC
|
|
35
|
+
wordmark and a status list in the stored language (host and version, method,
|
|
36
|
+
guardrails, MCP servers, role), drawn once right before the host starts. It needs
|
|
37
|
+
standard input, output and error on a terminal, 24-bit colour (`COLORTERM=truecolor`,
|
|
38
|
+
Windows Terminal, iTerm2, VS Code, WezTerm, Ghostty) or 256 colours (`TERM=*256color`),
|
|
39
|
+
and at least 48 columns (74 for the mark). Pipes, `NO_COLOR`, `TERM=dumb`, workers and
|
|
40
|
+
hosts that run once (`-p`, `--print`, `claude mcp`, `codex exec`) keep the plain lines.
|
|
41
|
+
`AISAC_NO_BANNER=1` turns the banner off.
|
|
42
|
+
|
|
33
43
|
`aisac init [dir]` (licensed accounts, client `0.4.0-beta.14` or later) writes the
|
|
34
44
|
AISAC skeleton into a new or existing project: `CLAUDE.md`, `AGENTS.md`,
|
|
35
45
|
`NOTES.example.md`, the `docs/` tree with its templates, a Claude Code rules file,
|
|
@@ -184,8 +194,10 @@ model requests or JEV calls are used by these compatibility probes.
|
|
|
184
194
|
This candidate supports a qualified private Codex installation as well as managed Claude
|
|
185
195
|
Code. Use `aisac setup --host-codex managed` or `aisac setup --host-claude managed` to keep
|
|
186
196
|
AISAC's executable choice independent of global CLI updates. `--host managed` selects it
|
|
187
|
-
for one launch.
|
|
188
|
-
|
|
197
|
+
for one launch. From `0.4.0-beta.27`, `aisac setup` checks the global hosts before the
|
|
198
|
+
disclosure and the token. At a terminal it offers the tested private copy when one is
|
|
199
|
+
incompatible; without a terminal it stops with the command to run. Downloads use the signed
|
|
200
|
+
manifest's exact lock and are checked before launch; your global executables remain unchanged. Explicit system mode stays authoritative,
|
|
189
201
|
and ambiguous legacy settings never authorize an automatic download. See
|
|
190
202
|
[managed hosts](../../docs/how-to/aibrain-subscriber-beta.md#managed-hosts) for consent,
|
|
191
203
|
environment overrides, cached/offline behavior and the shared-session-state limitation.
|
|
@@ -16,7 +16,7 @@ export const MAX_LOG_FILES = 3;
|
|
|
16
16
|
const LOCK_WAIT_MS = 250;
|
|
17
17
|
const LOCK_STALE_MS = 30_000;
|
|
18
18
|
const ADMISSION_MS = 60 * 60 * 1000;
|
|
19
|
-
export const ADAPTER_VERSION = '0.4.0-beta.
|
|
19
|
+
export const ADAPTER_VERSION = '0.4.0-beta.28';
|
|
20
20
|
const MAX_DIAGNOSTIC_COUNT = 10_000_000;
|
|
21
21
|
const MAX_DIAGNOSTIC_BYTES = 128 * 1024 * 1024;
|
|
22
22
|
const CHECKPOINT_BACKENDS = new Set(['native_store', 'private_file']);
|
package/dist/cli.mjs
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
resolveReleaseManifest,
|
|
45
45
|
} from './release-manifest.mjs';
|
|
46
46
|
import {
|
|
47
|
+
HOST_MODE_ENV,
|
|
47
48
|
isChannel,
|
|
48
49
|
isHostMode,
|
|
49
50
|
isUpdateMode,
|
|
@@ -65,6 +66,10 @@ import {
|
|
|
65
66
|
hostFallbackLine,
|
|
66
67
|
hostRecoveryLine,
|
|
67
68
|
resolveHostExecutable,
|
|
69
|
+
setupHostAnswerAccepted,
|
|
70
|
+
setupHostOffer,
|
|
71
|
+
setupHostQuestion,
|
|
72
|
+
setupHostRecoveryLine,
|
|
68
73
|
takeHostFlag,
|
|
69
74
|
} from './managed-host.mjs';
|
|
70
75
|
import { scanCommand, scanToolAvailability } from './engineering-scan.mjs';
|
|
@@ -82,7 +87,7 @@ import {
|
|
|
82
87
|
} from './launch-feedback.mjs';
|
|
83
88
|
import { parseCodexLaunchArgs } from './codex-permissions.mjs';
|
|
84
89
|
|
|
85
|
-
const VERSION = '0.4.0-beta.
|
|
90
|
+
const VERSION = '0.4.0-beta.28';
|
|
86
91
|
// The command is `aisac`; `aibrain` is an alias installed from the same entry.
|
|
87
92
|
const COMMAND = 'aisac';
|
|
88
93
|
/** `aisac scan` could not scan as asked (scan spec D6); 1 means findings, 2 a usage error. */
|
|
@@ -622,6 +627,108 @@ function requestedReleaseSettings(args) {
|
|
|
622
627
|
return { mode, channel, hostClaude, hostCodex };
|
|
623
628
|
}
|
|
624
629
|
|
|
630
|
+
/**
|
|
631
|
+
* @param {ReturnType<typeof requestedReleaseSettings>} release @param {'claude' | 'codex'} host
|
|
632
|
+
* @returns {ReturnType<typeof requestedReleaseSettings>}
|
|
633
|
+
*/
|
|
634
|
+
function withManagedHost(release, host) {
|
|
635
|
+
/** @type {import('./release-settings.mjs').HostMode} */
|
|
636
|
+
const managed = 'managed';
|
|
637
|
+
return host === 'claude'
|
|
638
|
+
? { ...release, hostClaude: managed }
|
|
639
|
+
: { ...release, hostCodex: managed };
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* The one question offering the signed private copy of an incompatible host (C8).
|
|
644
|
+
* @param {'claude' | 'codex'} host @param {{ version: string | null, reason: string }} compatibility
|
|
645
|
+
* @param {'pt-BR' | 'en'} locale
|
|
646
|
+
*/
|
|
647
|
+
async function askSetupHost(host, compatibility, locale) {
|
|
648
|
+
const rl = createInterface({ input: stdin, output: stdout });
|
|
649
|
+
try {
|
|
650
|
+
const question = setupHostQuestion(host, compatibility.version, compatibility.reason, locale);
|
|
651
|
+
return setupHostAnswerAccepted(await rl.question(question));
|
|
652
|
+
} catch {
|
|
653
|
+
return false;
|
|
654
|
+
} finally {
|
|
655
|
+
rl.close();
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Setup's check of each selected system host, before the disclosure and the token
|
|
661
|
+
* (spec aisac-host-upgrade-resilience C7, C8). A stored managed choice counts as the
|
|
662
|
+
* flag. An incompatible host is offered the signed private copy at a terminal; if not
|
|
663
|
+
* asked or the user says no, setup stops with the commands that fix it. Local only:
|
|
664
|
+
* nothing is downloaded or written here, and a compatible result is reused later.
|
|
665
|
+
* @param {'claude' | 'codex' | 'both'} clients
|
|
666
|
+
* @param {ReturnType<typeof requestedReleaseSettings>} requested
|
|
667
|
+
* @param {'pt-BR' | 'en'} locale
|
|
668
|
+
*/
|
|
669
|
+
async function preflightSetupHosts(clients, requested, locale) {
|
|
670
|
+
const settings = await readReleaseSettings(stateRoot());
|
|
671
|
+
let release = requested;
|
|
672
|
+
/** @type {import('./claude-compatibility.mjs').ClaudeCompatibility | null} */
|
|
673
|
+
let claude = null;
|
|
674
|
+
/** @type {Awaited<ReturnType<typeof resolveCodexCompatibility>> | null} */
|
|
675
|
+
let codex = null;
|
|
676
|
+
for (const host of /** @type {const} */ (['claude', 'codex'])) {
|
|
677
|
+
if (clients !== host && clients !== 'both') continue;
|
|
678
|
+
const flag = host === 'claude' ? release.hostClaude : release.hostCodex;
|
|
679
|
+
if (flag === undefined && settings.status === 'valid' && settings.hosts[host] === 'managed')
|
|
680
|
+
release = withManagedHost(release, host);
|
|
681
|
+
if ((host === 'claude' ? release.hostClaude : release.hostCodex) === 'managed') continue;
|
|
682
|
+
const executable = resolveNative(host);
|
|
683
|
+
// A missing host keeps its own error later in setup (`claude_not_found`, ...).
|
|
684
|
+
if (executable === null || (host === 'codex' && resolveNative('node') === null)) continue;
|
|
685
|
+
const compatibility =
|
|
686
|
+
host === 'claude'
|
|
687
|
+
? await resolveClaudeCompatibility(executable, PACKAGE_ROOT)
|
|
688
|
+
: await resolveCodexCompatibility(executable);
|
|
689
|
+
if (compatibility.status !== 'rejected') {
|
|
690
|
+
if (host === 'claude')
|
|
691
|
+
claude = /** @type {import('./claude-compatibility.mjs').ClaudeCompatibility} */ (
|
|
692
|
+
compatibility
|
|
693
|
+
);
|
|
694
|
+
else
|
|
695
|
+
codex = /** @type {Awaited<ReturnType<typeof resolveCodexCompatibility>>} */ (
|
|
696
|
+
compatibility
|
|
697
|
+
);
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
const offer = setupHostOffer({
|
|
701
|
+
host,
|
|
702
|
+
flag: flag ?? null,
|
|
703
|
+
env: process.env,
|
|
704
|
+
settings,
|
|
705
|
+
interactive: Boolean(stdin.isTTY && stdout.isTTY),
|
|
706
|
+
});
|
|
707
|
+
if (offer === 'ask' && (await askSetupHost(host, compatibility, locale))) {
|
|
708
|
+
release = withManagedHost(release, host);
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
const message =
|
|
712
|
+
host === 'claude'
|
|
713
|
+
? claudeCompatibilityError(
|
|
714
|
+
/** @type {import('./claude-compatibility.mjs').ClaudeCompatibility} */ (compatibility),
|
|
715
|
+
)
|
|
716
|
+
: codexCompatibilityError(
|
|
717
|
+
/** @type {Awaited<ReturnType<typeof resolveCodexCompatibility>>} */ (compatibility),
|
|
718
|
+
);
|
|
719
|
+
throw Object.assign(new Error(message), {
|
|
720
|
+
guide: setupHostRecoveryLine(
|
|
721
|
+
host,
|
|
722
|
+
compatibility.version,
|
|
723
|
+
compatibility.reason,
|
|
724
|
+
locale,
|
|
725
|
+
process.env[HOST_MODE_ENV] === 'system',
|
|
726
|
+
),
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
return { release, claude, codex };
|
|
730
|
+
}
|
|
731
|
+
|
|
625
732
|
/** @param {string[]} args */
|
|
626
733
|
async function setup(args) {
|
|
627
734
|
if (args.includes('--yes')) throw new Error('explicit_disclosure_flag_required');
|
|
@@ -667,7 +774,7 @@ async function setup(args) {
|
|
|
667
774
|
throw new Error('setup_undo_cannot_have_options');
|
|
668
775
|
const lang = option(args, '--lang');
|
|
669
776
|
if (lang !== undefined && !isPackLocale(lang)) throw new Error('invalid_lang');
|
|
670
|
-
|
|
777
|
+
let release = requestedReleaseSettings(args);
|
|
671
778
|
const previous = await readConfig();
|
|
672
779
|
// `--lang` alone only switches the language of an existing setup. Before the first
|
|
673
780
|
// setup it runs the full setup (token included) and stores the language at the end.
|
|
@@ -741,6 +848,11 @@ async function setup(args) {
|
|
|
741
848
|
throw new Error('host_claude_requires_claude_client');
|
|
742
849
|
if (clients === 'claude' && release.hostCodex !== undefined)
|
|
743
850
|
throw new Error('host_codex_requires_codex_client');
|
|
851
|
+
const locale = resolvePackLocale(lang ?? (await readStoredLocale(stateRoot())));
|
|
852
|
+
// The hosts are checked before the disclosure and the token (spec
|
|
853
|
+
// aisac-host-upgrade-resilience C7, C8): an incompatible host costs the user neither.
|
|
854
|
+
const preflight = await preflightSetupHosts(clients, release, locale);
|
|
855
|
+
release = preflight.release;
|
|
744
856
|
const endpoint = option(args, '--endpoint') ?? ENDPOINT;
|
|
745
857
|
validateEndpoint(endpoint);
|
|
746
858
|
const selection = selectedPolicy(args, previous, clients);
|
|
@@ -765,7 +877,6 @@ async function setup(args) {
|
|
|
765
877
|
)
|
|
766
878
|
throw new Error('disclosure_not_accepted');
|
|
767
879
|
const root = await ensureStateRoot();
|
|
768
|
-
const locale = resolvePackLocale(lang ?? (await readStoredLocale(root)));
|
|
769
880
|
const tokenPath = option(args, '--token-file');
|
|
770
881
|
if (!tokenPath && stdin.isTTY && stdout.isTTY)
|
|
771
882
|
console.log(`\n${tokenPromptGuide(locale, endpoint)}\n`);
|
|
@@ -781,9 +892,9 @@ async function setup(args) {
|
|
|
781
892
|
const node = resolveNative('node');
|
|
782
893
|
let claude = resolveNative('claude');
|
|
783
894
|
/** @type {Awaited<ReturnType<typeof resolveCodexCompatibility>> | null} */
|
|
784
|
-
let codexCompatibility =
|
|
895
|
+
let codexCompatibility = preflight.codex;
|
|
785
896
|
/** @type {import('./claude-compatibility.mjs').ClaudeCompatibility | null} */
|
|
786
|
-
let claudeCompatibility =
|
|
897
|
+
let claudeCompatibility = preflight.claude;
|
|
787
898
|
// A managed Claude host asked for at setup (ADR-0056 R4, FR5): the pinned copy is
|
|
788
899
|
// installed and probed in place of the user's binary, which may then be absent;
|
|
789
900
|
// when it cannot be, setup goes on with the user's binary and says why.
|
|
@@ -1442,7 +1553,10 @@ async function main(argv) {
|
|
|
1442
1553
|
}
|
|
1443
1554
|
if (command === 'claude' || command === 'codex') {
|
|
1444
1555
|
const config = await readConfig();
|
|
1445
|
-
if (!config || config.disclosedAt === undefined)
|
|
1556
|
+
if (!config || config.disclosedAt === undefined) {
|
|
1557
|
+
const locale = resolvePackLocale(await readStoredLocale(stateRoot()), process.env);
|
|
1558
|
+
throw setupTokenError('setup_required', locale, ENDPOINT);
|
|
1559
|
+
}
|
|
1446
1560
|
if (config.schemaVersion === 2 && config.disclosureVersion !== DISCLOSURE_VERSION)
|
|
1447
1561
|
throw new Error('disclosure_outdated');
|
|
1448
1562
|
if (config.clientSelection !== command && config.clientSelection !== 'both')
|
|
@@ -753,6 +753,46 @@ export function packNotice(outcome, locale, updateCommand = DEFAULT_UPDATE_COMMA
|
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
755
|
|
|
756
|
+
/**
|
|
757
|
+
* The same fact as `packNotice`, as an item of the launch banner (spec
|
|
758
|
+
* aisac-launch-banner FR1); null when the capability is not offered.
|
|
759
|
+
* @param {PackOutcome} outcome
|
|
760
|
+
* @param {PackLocale} locale
|
|
761
|
+
* @param {string} [updateCommand]
|
|
762
|
+
* @returns {import('./launch-banner.mjs').BannerItem | null}
|
|
763
|
+
*/
|
|
764
|
+
export function packBannerItem(outcome, locale, updateCommand = DEFAULT_UPDATE_COMMAND) {
|
|
765
|
+
const pt = locale === 'pt-BR';
|
|
766
|
+
const unavailable = pt ? 'Método indisponível' : 'Method unavailable';
|
|
767
|
+
const without = pt ? 'a sessão começa sem o método' : 'the session starts without the method';
|
|
768
|
+
switch (outcome.outcome) {
|
|
769
|
+
case 'loaded':
|
|
770
|
+
return {
|
|
771
|
+
tone: 'ok',
|
|
772
|
+
label: pt ? 'Método AISAC' : 'AISAC method',
|
|
773
|
+
detail: `${locale} · ${outcome.pack.packVersion.replace(/^sha256-/u, '')}`,
|
|
774
|
+
};
|
|
775
|
+
case 'inactive':
|
|
776
|
+
return {
|
|
777
|
+
tone: 'warn',
|
|
778
|
+
label: pt ? 'Licença inativa' : 'License inactive',
|
|
779
|
+
detail: outcome.purchaseUrl,
|
|
780
|
+
};
|
|
781
|
+
case 'unavailable':
|
|
782
|
+
return { tone: 'warn', label: unavailable, detail: `${outcome.reason} · ${without}` };
|
|
783
|
+
case 'rejected':
|
|
784
|
+
return outcome.reason === 'client_outdated'
|
|
785
|
+
? {
|
|
786
|
+
tone: 'warn',
|
|
787
|
+
label: pt ? 'Atualize o aisac' : 'Update aisac',
|
|
788
|
+
detail: `${updateCommand} · ${without}`,
|
|
789
|
+
}
|
|
790
|
+
: { tone: 'warn', label: unavailable, detail: `${outcome.reason} · ${without}` };
|
|
791
|
+
default:
|
|
792
|
+
return null;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
756
796
|
/**
|
|
757
797
|
* @param {PackOutcome} outcome
|
|
758
798
|
* @param {PackLocale} locale
|
|
@@ -780,7 +820,8 @@ function lastLaunchOf(outcome, locale, client) {
|
|
|
780
820
|
* packageRoot: string, client?: PackClient, hostSupported?: boolean, updateCommand?: string,
|
|
781
821
|
* env?: NodeJS.ProcessEnv, fetchImpl?: typeof fetch, timeoutMs?: number }} input
|
|
782
822
|
* @returns {Promise<{ pluginRoot: string | null,
|
|
783
|
-
* codex: import('./codex-engineering.mjs').CodexEngineering | null, line: string | null
|
|
823
|
+
* codex: import('./codex-engineering.mjs').CodexEngineering | null, line: string | null,
|
|
824
|
+
* item: import('./launch-banner.mjs').BannerItem | null }>}
|
|
784
825
|
*/
|
|
785
826
|
export async function prepareEngineeringPack(input) {
|
|
786
827
|
const client = input.client ?? 'claude';
|
|
@@ -819,7 +860,12 @@ export async function prepareEngineeringPack(input) {
|
|
|
819
860
|
await atomicJson(join(input.root, LAST_LAUNCH_FILE), lastLaunchOf(outcome, locale, client)).catch(
|
|
820
861
|
() => undefined,
|
|
821
862
|
);
|
|
822
|
-
return {
|
|
863
|
+
return {
|
|
864
|
+
pluginRoot,
|
|
865
|
+
codex,
|
|
866
|
+
line: packNotice(outcome, locale, input.updateCommand),
|
|
867
|
+
item: packBannerItem(outcome, locale, input.updateCommand),
|
|
868
|
+
};
|
|
823
869
|
}
|
|
824
870
|
|
|
825
871
|
/**
|
|
@@ -200,7 +200,8 @@ export async function readCodexGuardrails(input, dependencies = {}) {
|
|
|
200
200
|
* that waits for the user's review in `/hooks` is never called on.
|
|
201
201
|
* @param {{ root: string, packageRoot: string, executable: string, cwd: string, profile: string | undefined, environment: NodeJS.ProcessEnv }} input
|
|
202
202
|
* @param {{ listHooks?: typeof readCodexHookList }} [dependencies]
|
|
203
|
-
* @returns {Promise<{ value: string, line: string
|
|
203
|
+
* @returns {Promise<{ value: string, line: string, enabledCount: number,
|
|
204
|
+
* summary: import('./codex-hooks.mjs').CodexHooksSummary | null } | null>}
|
|
204
205
|
*/
|
|
205
206
|
export async function prepareCodexGuardrails(input, dependencies = {}) {
|
|
206
207
|
const read = await readCodexGuardrails(input, dependencies);
|
|
@@ -209,5 +210,7 @@ export async function prepareCodexGuardrails(input, dependencies = {}) {
|
|
|
209
210
|
return {
|
|
210
211
|
value: codexHooksValue(read.enabled, locale),
|
|
211
212
|
line: codexHooksLine(read.enabled.length, read.summary),
|
|
213
|
+
enabledCount: read.enabled.length,
|
|
214
|
+
summary: read.summary,
|
|
212
215
|
};
|
|
213
216
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"source": "clients/aibrain/art/brand-mark.webp",
|
|
4
|
+
"width": 22,
|
|
5
|
+
"height": 26,
|
|
6
|
+
"transparent": "------",
|
|
7
|
+
"colours": {
|
|
8
|
+
"left": "#15a4ec",
|
|
9
|
+
"right": "#6d2fea",
|
|
10
|
+
"light": "#dfe2f2"
|
|
11
|
+
},
|
|
12
|
+
"rows": [
|
|
13
|
+
"------------------------------------------------------------------------------------------------------------------------------------",
|
|
14
|
+
"------------------------------------------------a8a8acefeff3f7f7fbefeff3e9e9f2e9e9f2------------------------------------------------",
|
|
15
|
+
"------------------------------------------d7d5d7fcfcfef9f9fbefeff8e6e6efdfe0eee3e4f2eeeef3------------------------------------------",
|
|
16
|
+
"------------------------------------e1dfe1fdfbfdf7f7fbefeff3e4e5f1dedfebd8dbecdaddeee3e4f1edeefb------------------------------------",
|
|
17
|
+
"------------------------------e8ebedfcfcfff6f6f9ebebf3e3e3ebdddeeddcddecdaddf0d9dcefdcddf2e1e2f7edecf5------------------------------",
|
|
18
|
+
"------------------------f6f6f8f9f9fbf1f1f8e7e7eee0e1eedbdce9dddeede5e6f5e4e5f8dfe0f3dadcf4dadcf4dcdef3e2e4f9f5f3f8------------------",
|
|
19
|
+
"------------------f9f8fff5f5f9ededf1dfe1eedadce9dbddebdfe1efcccadfc3c1d6f1f0ffeae9f9dee0fad7d9f3cfd3f2ced2f1d7daeee1e4f8------------",
|
|
20
|
+
"------------e7e7ecf3f3f8e6e7f1dcdde7d3d8e7d5dae9dddfe6------------------51428fdccdffe4e4fed7d7f1c8ccf1c2c6ebc2c7e8c9ceef------------",
|
|
21
|
+
"------5e7090f5f5fbe5e5ebd7dbead1d5e4d0d5e7d9def0------------------------------452086bab5dfded9ffc6cbf3babfe7b4bae3b8bee78171b8------",
|
|
22
|
+
"------61707fd8d9e5dedfebcfd6e9cad1e4d2d8e6------------------------------------593b9c21116b8e7ed8cacef8b9bde7a9b0e0aab1e1776cb7------",
|
|
23
|
+
"------97b8c1666d7adae1eeccd4eacbd3e9dee3ec------------------------------------------4323bd1d0097555783b3b5e1a3aade9da4d8745fc28570d3",
|
|
24
|
+
"------8ee3f9304957adc6d4cad5ebcdd8ee------------------------------------------------6945f2330fbc150d512e266a8e94cc949ad26c55b68871d2",
|
|
25
|
+
"------8ad3e4519db7135f79ced7eadbe4f7------------------------------------------------------583faf2512a71a079c16164b7575aa6550af8b76d5",
|
|
26
|
+
"------6cd1e533b7e1005c868f95a7------------------------------------------------------------------3e1fdc2a0bc82916941d0a884d2e978b6cd5",
|
|
27
|
+
"------4bcfe70db6f8009ee00a1c3c------------------------------------------------------------------7250ff3715c7360fdd441deb2e0b7a8b68d7",
|
|
28
|
+
"------41cae305b2fb00a6ef2d6898------------------------------------------------------------------7c5cfc4525c54012ec481af4733ad8955cfa",
|
|
29
|
+
"------3fcae306b1fd00a2ee319cd0------------------------------------------------------------------------552dce5016f4561cfa8248ced197ff",
|
|
30
|
+
"------47cbe307affe009eed0291df------------------------------------------------------------------7a45f75b26d8621af36d25fe985acaf1b3ff",
|
|
31
|
+
"------6dc8de0bb3ff009eed007fe00282e3------------------------------------------------------3931597d35ff6820f07a22f08f37ffb87ed2ffc9ff",
|
|
32
|
+
"------86d6ff14bfff00a6ed077bde006acd0c5fb12b7ed03069ab19529413427a07366e224275001e51391089734ac37322f97726fd9633e7b754ffd4b1e2------",
|
|
33
|
+
"------8cc1f42cd3ff0ab1ea0b84ea006ad0064b9c003c8d032b5f002357011d450019410d093527234f7432ff6826f37e23f28c31ffb354e0e283ffefe3f2------",
|
|
34
|
+
"------------58e3ff2fbaea0b93fa0077de0753ad00419b022f68002760071e410013362f0a995732c1621cf66923fd912debac48ffcb8bdaffc3ff------------",
|
|
35
|
+
"------------------6bb6ff11b2ff0092e70761ca004fb8033b820032790e114e181b58461cf3461cf3621af0732bffaa49dfd675ffe8d5ea------------------",
|
|
36
|
+
"------------------------2396fc279aff097aec0063d513478c00266b1a089d3321b63a13ed421bf57223ea9041ffc589d9------------------------------",
|
|
37
|
+
"------------------------------------194a730838610b0f611114672217d3271bd83c18ed4925fa7f3cd4------------------------------------------",
|
|
38
|
+
"------------------------------------------------------2122ad3c35db4b44eb513ccb------------------------------------------------------"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The launch banner (spec aisac-launch-banner): the AISAC Engineering mark, the
|
|
3
|
+
* wordmark and a status list, drawn once before an interactive host starts. Every
|
|
4
|
+
* other launch keeps the plain lines. Pure functions plus a small collector; the
|
|
5
|
+
* caller hands in the terminal and the writer.
|
|
6
|
+
*/
|
|
7
|
+
import art from './launch-banner-art.json' with { type: 'json' };
|
|
8
|
+
|
|
9
|
+
/** @typedef {'full' | 'compact' | 'plain'} BannerMode */
|
|
10
|
+
/** @typedef {'truecolor' | '256'} ColourDepth */
|
|
11
|
+
/** @typedef {'ok' | 'warn' | 'info'} Tone */
|
|
12
|
+
/** @typedef {{ tone: Tone, label: string, detail: string }} BannerItem */
|
|
13
|
+
/** @typedef {[number, number, number]} Rgb */
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {{ isTTY?: boolean, columns?: number }} TerminalStream
|
|
16
|
+
* @typedef {{ stdin: TerminalStream, stdout: TerminalStream, stderr: TerminalStream,
|
|
17
|
+
* env: NodeJS.ProcessEnv }} Terminal
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export const FULL_MIN_COLUMNS = 74;
|
|
21
|
+
export const COMPACT_MIN_COLUMNS = 48;
|
|
22
|
+
const DEFAULT_COLUMNS = 80;
|
|
23
|
+
const MAX_VALUE_LENGTH = 120;
|
|
24
|
+
const MAX_LABEL_WIDTH = 24;
|
|
25
|
+
const INDENT = ' ';
|
|
26
|
+
const MARK_GAP = ' ';
|
|
27
|
+
const PIXEL_HEX_LENGTH = 6;
|
|
28
|
+
const GLYPH_HEIGHT = 8;
|
|
29
|
+
const GLYPH_GAP = 2;
|
|
30
|
+
const UPPER_HALF = '▀';
|
|
31
|
+
const LOWER_HALF = '▄';
|
|
32
|
+
const ESC = '\u001b';
|
|
33
|
+
const RESET = `${ESC}[0m`;
|
|
34
|
+
const FAINT = `${ESC}[2m`;
|
|
35
|
+
const ENGINEERING = 'E N G I N E E R I N G';
|
|
36
|
+
const TRUECOLOR_PROGRAMS = new Set(['iTerm.app', 'vscode', 'WezTerm', 'ghostty']);
|
|
37
|
+
const TONE_MARKS = { ok: '✓', warn: '!', info: '•' };
|
|
38
|
+
/** @type {Record<Tone, Rgb>} */
|
|
39
|
+
const TONE_COLOURS = { ok: [74, 222, 128], warn: [251, 191, 36], info: [125, 211, 252] };
|
|
40
|
+
/**
|
|
41
|
+
* Claude Code subcommands that print and exit; the first word only, so a first
|
|
42
|
+
* prompt (`aisac claude "fix the tests"`) still gets the banner.
|
|
43
|
+
*/
|
|
44
|
+
const CLAUDE_ONE_SHOT_SUBCOMMANDS = new Set([
|
|
45
|
+
'auth',
|
|
46
|
+
'config',
|
|
47
|
+
'doctor',
|
|
48
|
+
'install',
|
|
49
|
+
'mcp',
|
|
50
|
+
'migrate-installer',
|
|
51
|
+
'plugin',
|
|
52
|
+
'plugins',
|
|
53
|
+
'setup-token',
|
|
54
|
+
'update',
|
|
55
|
+
'upgrade',
|
|
56
|
+
]);
|
|
57
|
+
/** Flags that make either host print its version or its help and exit. */
|
|
58
|
+
const RUN_ONCE_FLAGS = new Set(['-h', '--help', '-v', '-V', '--version']);
|
|
59
|
+
/** Codex subcommands that open the terminal; any other subcommand runs once. */
|
|
60
|
+
const CODEX_INTERACTIVE_SUBCOMMANDS = new Set(['resume', 'fork']);
|
|
61
|
+
/** Upper-case pixel glyphs of the wordmark, ΛISΛC (A drawn without its bar). */
|
|
62
|
+
const GLYPHS = {
|
|
63
|
+
A: [
|
|
64
|
+
'....##....',
|
|
65
|
+
'...####...',
|
|
66
|
+
'..##..##..',
|
|
67
|
+
'..##..##..',
|
|
68
|
+
'.##....##.',
|
|
69
|
+
'.##....##.',
|
|
70
|
+
'##......##',
|
|
71
|
+
'##......##',
|
|
72
|
+
],
|
|
73
|
+
I: Array.from({ length: GLYPH_HEIGHT }, () => '##'),
|
|
74
|
+
S: [
|
|
75
|
+
'.#######',
|
|
76
|
+
'########',
|
|
77
|
+
'##......',
|
|
78
|
+
'#######.',
|
|
79
|
+
'.#######',
|
|
80
|
+
'......##',
|
|
81
|
+
'########',
|
|
82
|
+
'#######.',
|
|
83
|
+
],
|
|
84
|
+
C: [
|
|
85
|
+
'.#######',
|
|
86
|
+
'########',
|
|
87
|
+
'##......',
|
|
88
|
+
'##......',
|
|
89
|
+
'##......',
|
|
90
|
+
'##......',
|
|
91
|
+
'########',
|
|
92
|
+
'.#######',
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
const WORDMARK = /** @type {Array<keyof typeof GLYPHS>} */ (['A', 'I', 'S', 'A', 'C']);
|
|
96
|
+
|
|
97
|
+
// --- Text that did not come from this file -----------------------------------
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* A value from outside the client's source (a host version, a pack version, a
|
|
101
|
+
* reason, a URL): control and bidirectional characters removed, one line, cut at
|
|
102
|
+
* 120 characters (LB-D6).
|
|
103
|
+
* @param {string} value
|
|
104
|
+
*/
|
|
105
|
+
export function bannerText(value) {
|
|
106
|
+
const clean = String(value).replace(
|
|
107
|
+
/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/gu,
|
|
108
|
+
'',
|
|
109
|
+
);
|
|
110
|
+
return clean.length > MAX_VALUE_LENGTH ? `${clean.slice(0, MAX_VALUE_LENGTH - 1)}\u2026` : clean;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* An item for a source that only has its plain line (FR1, last row).
|
|
115
|
+
* @param {string} line
|
|
116
|
+
* @returns {BannerItem}
|
|
117
|
+
*/
|
|
118
|
+
export function itemFromLine(line) {
|
|
119
|
+
const text = line.replace(/^(AISAC Engineering|aisac): /u, '').replace(/\.$/u, '');
|
|
120
|
+
return { tone: 'info', label: text, detail: '' };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// --- When the banner is drawn (LB-D2, LB-D4, LB-D5) ---------------------------
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {NodeJS.ProcessEnv} env
|
|
127
|
+
* @returns {ColourDepth | null}
|
|
128
|
+
*/
|
|
129
|
+
export function colourDepth(env) {
|
|
130
|
+
const colourTerm = (env.COLORTERM ?? '').toLowerCase();
|
|
131
|
+
if (colourTerm === 'truecolor' || colourTerm === '24bit') return 'truecolor';
|
|
132
|
+
if (env.WT_SESSION) return 'truecolor';
|
|
133
|
+
if (TRUECOLOR_PROGRAMS.has(env.TERM_PROGRAM ?? '')) return 'truecolor';
|
|
134
|
+
if ((env.TERM ?? '').includes('256color')) return '256';
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Does the host run once and exit with these native arguments?
|
|
140
|
+
* @param {'claude' | 'codex'} host
|
|
141
|
+
* @param {readonly string[]} args
|
|
142
|
+
* @param {(args: string[]) => string | null} codexSubcommand
|
|
143
|
+
*/
|
|
144
|
+
function runsOnce(host, args, codexSubcommand) {
|
|
145
|
+
const native = args[0] === '--' ? args.slice(1) : [...args];
|
|
146
|
+
const options = native.slice(0, Math.max(0, native.indexOf('--')) || native.length);
|
|
147
|
+
if (options.some((argument) => RUN_ONCE_FLAGS.has(argument))) return true;
|
|
148
|
+
if (host === 'codex') {
|
|
149
|
+
const subcommand = codexSubcommand(native);
|
|
150
|
+
return subcommand !== null && !CODEX_INTERACTIVE_SUBCOMMANDS.has(subcommand);
|
|
151
|
+
}
|
|
152
|
+
if (options.some((argument) => argument === '-p' || argument.split('=', 1)[0] === '--print'))
|
|
153
|
+
return true;
|
|
154
|
+
return CLAUDE_ONE_SHOT_SUBCOMMANDS.has(native[0] ?? '');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {{ host: 'claude' | 'codex', args: readonly string[], roleKind: string | null,
|
|
159
|
+
* terminal: Terminal, codexSubcommand: (args: string[]) => string | null }} input
|
|
160
|
+
* @returns {{ mode: BannerMode, depth: ColourDepth | null, columns: number }}
|
|
161
|
+
*/
|
|
162
|
+
export function bannerMode(input) {
|
|
163
|
+
const { terminal } = input;
|
|
164
|
+
const columns = terminal.stderr.columns ?? DEFAULT_COLUMNS;
|
|
165
|
+
const plain = { mode: /** @type {BannerMode} */ ('plain'), depth: null, columns };
|
|
166
|
+
const env = terminal.env;
|
|
167
|
+
if (!terminal.stdin.isTTY || !terminal.stdout.isTTY || !terminal.stderr.isTTY) return plain;
|
|
168
|
+
if (env.TERM === 'dumb' || (env.NO_COLOR ?? '') !== '') return plain;
|
|
169
|
+
if ((env.AISAC_NO_BANNER ?? '') !== '' && env.AISAC_NO_BANNER !== '0') return plain;
|
|
170
|
+
if (input.roleKind === 'worker') return plain;
|
|
171
|
+
if (runsOnce(input.host, input.args, input.codexSubcommand)) return plain;
|
|
172
|
+
const depth = colourDepth(env);
|
|
173
|
+
if (depth === null || columns < COMPACT_MIN_COLUMNS) return plain;
|
|
174
|
+
return { mode: columns >= FULL_MIN_COLUMNS ? 'full' : 'compact', depth, columns };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// --- Items in the stored locale (FR1) ------------------------------------------
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @param {{ host: 'claude' | 'codex', version: string | null, status: string,
|
|
181
|
+
* managed: boolean, locale: string }} input
|
|
182
|
+
* @returns {BannerItem}
|
|
183
|
+
*/
|
|
184
|
+
export function hostItem(input) {
|
|
185
|
+
const pt = input.locale === 'pt-BR';
|
|
186
|
+
const name = input.host === 'claude' ? 'Claude Code' : 'Codex';
|
|
187
|
+
const qualified = input.status === 'qualified';
|
|
188
|
+
const state = pt
|
|
189
|
+
? qualified
|
|
190
|
+
? 'versão qualificada'
|
|
191
|
+
: 'verificado nesta máquina'
|
|
192
|
+
: qualified
|
|
193
|
+
? 'qualified version'
|
|
194
|
+
: 'checked on this machine';
|
|
195
|
+
const managed = input.managed ? (pt ? ' · cópia gerenciada' : ' · managed copy') : '';
|
|
196
|
+
return {
|
|
197
|
+
tone: 'ok',
|
|
198
|
+
label: `${name} ${bannerText(input.version ?? '?')}`,
|
|
199
|
+
detail: `${state}${managed}`,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* The plain line for a host newer than the qualified list (LB-D7).
|
|
205
|
+
* @param {'claude' | 'codex'} host
|
|
206
|
+
* @param {string} version
|
|
207
|
+
* @param {string} locale
|
|
208
|
+
*/
|
|
209
|
+
export function hostCheckedLine(host, version, locale) {
|
|
210
|
+
const name = host === 'claude' ? 'Claude Code' : 'Codex';
|
|
211
|
+
return locale === 'pt-BR'
|
|
212
|
+
? `aisac: ${name} ${version} verificado nesta máquina (versão mais nova que as qualificadas de ponta a ponta).`
|
|
213
|
+
: `aisac: ${name} ${version} checked on this machine (newer than the versions qualified end to end).`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @param {number} count
|
|
218
|
+
* @param {string} locale
|
|
219
|
+
* @returns {BannerItem}
|
|
220
|
+
*/
|
|
221
|
+
export function guardrailsItem(count, locale) {
|
|
222
|
+
const pt = locale === 'pt-BR';
|
|
223
|
+
const noun = count === 1 ? 'guardrail' : 'guardrails';
|
|
224
|
+
return {
|
|
225
|
+
tone: 'ok',
|
|
226
|
+
label: pt ? `${count} ${noun} ${count === 1 ? 'ativo' : 'ativos'}` : `${count} ${noun} on`,
|
|
227
|
+
detail: pt ? 'aisac hooks para mudar' : 'aisac hooks to change them',
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @param {number} enabledCount
|
|
233
|
+
* @param {{ on: unknown[], review: unknown[], off: unknown[], missing: unknown[] } | null} summary
|
|
234
|
+
* @param {string} locale
|
|
235
|
+
* @returns {BannerItem}
|
|
236
|
+
*/
|
|
237
|
+
export function codexGuardrailsItem(enabledCount, summary, locale) {
|
|
238
|
+
const pt = locale === 'pt-BR';
|
|
239
|
+
if (summary === null)
|
|
240
|
+
return {
|
|
241
|
+
tone: 'warn',
|
|
242
|
+
label: pt
|
|
243
|
+
? `${enabledCount} guardrails entregues ao Codex`
|
|
244
|
+
: `${enabledCount} guardrails handed to Codex`,
|
|
245
|
+
detail: pt ? 'aprove uma vez em /hooks no Codex' : 'approve them once in /hooks in Codex',
|
|
246
|
+
};
|
|
247
|
+
const total =
|
|
248
|
+
summary.on.length + summary.review.length + summary.off.length + summary.missing.length;
|
|
249
|
+
if (summary.on.length === total) return guardrailsItem(total, locale);
|
|
250
|
+
return {
|
|
251
|
+
tone: 'warn',
|
|
252
|
+
label: pt
|
|
253
|
+
? `${summary.on.length} de ${total} guardrails ativos`
|
|
254
|
+
: `${summary.on.length} of ${total} guardrails on`,
|
|
255
|
+
detail:
|
|
256
|
+
summary.review.length > 0
|
|
257
|
+
? pt
|
|
258
|
+
? 'aprove em /hooks no Codex'
|
|
259
|
+
: 'approve them in /hooks in Codex'
|
|
260
|
+
: pt
|
|
261
|
+
? 'veja /hooks no Codex · aisac hooks'
|
|
262
|
+
: 'see /hooks in Codex · aisac hooks',
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @param {{ ready: unknown[], missingEnv: Array<{ id: string, variable: string }> }} servers
|
|
268
|
+
* @param {'claude' | 'codex'} client
|
|
269
|
+
* @param {string} locale
|
|
270
|
+
* @returns {BannerItem[]}
|
|
271
|
+
*/
|
|
272
|
+
export function mcpItems(servers, client, locale) {
|
|
273
|
+
const pt = locale === 'pt-BR';
|
|
274
|
+
/** @type {BannerItem[]} */
|
|
275
|
+
const items = [];
|
|
276
|
+
const count = servers.ready.length;
|
|
277
|
+
if (count > 0) {
|
|
278
|
+
const login =
|
|
279
|
+
client === 'claude'
|
|
280
|
+
? pt
|
|
281
|
+
? 'login com /mcp'
|
|
282
|
+
: 'log in with /mcp'
|
|
283
|
+
: pt
|
|
284
|
+
? 'login com aisac mcp login <id>'
|
|
285
|
+
: 'log in with aisac mcp login <id>';
|
|
286
|
+
items.push({
|
|
287
|
+
tone: 'ok',
|
|
288
|
+
label: pt
|
|
289
|
+
? `${count} ${count === 1 ? 'servidor' : 'servidores'} MCP`
|
|
290
|
+
: `${count} MCP server${count === 1 ? '' : 's'}`,
|
|
291
|
+
detail: `${login} · ${pt ? 'aisac mcp para mudar' : 'aisac mcp to change them'}`,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
for (const skipped of servers.missingEnv)
|
|
295
|
+
items.push({
|
|
296
|
+
tone: 'warn',
|
|
297
|
+
label: `${bannerText(skipped.id)} ${pt ? 'ignorado' : 'skipped'}`,
|
|
298
|
+
detail: `${pt ? 'defina' : 'set'} ${bannerText(skipped.variable)}`,
|
|
299
|
+
});
|
|
300
|
+
return items;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// --- Drawing ---------------------------------------------------------------------
|
|
304
|
+
|
|
305
|
+
/** @param {string} hex */
|
|
306
|
+
function rgbOf(hex) {
|
|
307
|
+
const value = hex.replace(/^#/u, '');
|
|
308
|
+
return /** @type {Rgb} */ ([0, 2, 4].map((i) => Number.parseInt(value.slice(i, i + 2), 16)));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** @param {Rgb} rgb */
|
|
312
|
+
function xterm256([r, g, b]) {
|
|
313
|
+
const levels = [0, 95, 135, 175, 215, 255];
|
|
314
|
+
/** @param {number} v */
|
|
315
|
+
const step = (v) => (v < 48 ? 0 : v < 115 ? 1 : Math.floor((v - 35) / 40));
|
|
316
|
+
const cube = 16 + 36 * step(r) + 6 * step(g) + step(b);
|
|
317
|
+
const cubeRgb = [levels[step(r)], levels[step(g)], levels[step(b)]];
|
|
318
|
+
const grey = Math.max(0, Math.min(23, Math.round(((r + g + b) / 3 - 8) / 10)));
|
|
319
|
+
const greyValue = 8 + 10 * grey;
|
|
320
|
+
/** @param {number[]} other */
|
|
321
|
+
const distance = (other) =>
|
|
322
|
+
(r - (other[0] ?? 0)) ** 2 + (g - (other[1] ?? 0)) ** 2 + (b - (other[2] ?? 0)) ** 2;
|
|
323
|
+
return distance(cubeRgb) <= distance([greyValue, greyValue, greyValue]) ? cube : 232 + grey;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* @param {Rgb} rgb
|
|
328
|
+
* @param {ColourDepth} depth
|
|
329
|
+
* @param {'fg' | 'bg'} layer
|
|
330
|
+
*/
|
|
331
|
+
function sgr(rgb, depth, layer) {
|
|
332
|
+
const base = layer === 'fg' ? 38 : 48;
|
|
333
|
+
return depth === 'truecolor'
|
|
334
|
+
? `${base};2;${rgb[0]};${rgb[1]};${rgb[2]}`
|
|
335
|
+
: `${base};5;${xterm256(rgb)}`;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* One terminal line from pixel pairs: the upper half block carries the upper pixel
|
|
340
|
+
* as foreground and the lower one as background; a transparent pixel keeps the
|
|
341
|
+
* terminal's own background.
|
|
342
|
+
* @param {Array<Rgb | null>} upper
|
|
343
|
+
* @param {Array<Rgb | null>} lower
|
|
344
|
+
* @param {ColourDepth} depth
|
|
345
|
+
*/
|
|
346
|
+
function halfBlockLine(upper, lower, depth) {
|
|
347
|
+
let line = '';
|
|
348
|
+
for (let x = 0; x < upper.length; x += 1) {
|
|
349
|
+
const top = upper[x] ?? null;
|
|
350
|
+
const bottom = lower[x] ?? null;
|
|
351
|
+
if (top === null && bottom === null) line += `${RESET} `;
|
|
352
|
+
else if (top === null && bottom !== null)
|
|
353
|
+
line += `${RESET}${ESC}[${sgr(bottom, depth, 'fg')}m${LOWER_HALF}`;
|
|
354
|
+
else if (top !== null && bottom === null)
|
|
355
|
+
line += `${RESET}${ESC}[${sgr(top, depth, 'fg')}m${UPPER_HALF}`;
|
|
356
|
+
else if (top !== null && bottom !== null)
|
|
357
|
+
line += `${RESET}${ESC}[${sgr(top, depth, 'fg')};${sgr(bottom, depth, 'bg')}m${UPPER_HALF}`;
|
|
358
|
+
}
|
|
359
|
+
return `${line}${RESET}`;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** @param {Array<Array<Rgb | null>>} pixels */
|
|
363
|
+
function pixelLines(pixels, /** @type {ColourDepth} */ depth) {
|
|
364
|
+
const lines = [];
|
|
365
|
+
for (let y = 0; y < pixels.length; y += 2)
|
|
366
|
+
lines.push(halfBlockLine(pixels[y] ?? [], pixels[y + 1] ?? [], depth));
|
|
367
|
+
return lines;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** @returns {Array<Array<Rgb | null>>} */
|
|
371
|
+
function markPixels() {
|
|
372
|
+
return art.rows.map((row) => {
|
|
373
|
+
/** @type {Array<Rgb | null>} */
|
|
374
|
+
const pixels = [];
|
|
375
|
+
for (let x = 0; x < art.width; x += 1) {
|
|
376
|
+
const chunk = row.slice(x * PIXEL_HEX_LENGTH, (x + 1) * PIXEL_HEX_LENGTH);
|
|
377
|
+
pixels.push(chunk === art.transparent ? null : rgbOf(chunk));
|
|
378
|
+
}
|
|
379
|
+
return pixels;
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export const WORDMARK_WIDTH = WORDMARK.reduce(
|
|
384
|
+
(width, letter, index) => width + GLYPHS[letter][0].length + (index === 0 ? 0 : GLYPH_GAP),
|
|
385
|
+
0,
|
|
386
|
+
);
|
|
387
|
+
|
|
388
|
+
/** @returns {Array<Array<Rgb | null>>} */
|
|
389
|
+
function wordmarkPixels() {
|
|
390
|
+
const left = rgbOf(art.colours.left);
|
|
391
|
+
const right = rgbOf(art.colours.right);
|
|
392
|
+
/** @type {Array<Array<Rgb | null>>} */
|
|
393
|
+
const rows = Array.from({ length: GLYPH_HEIGHT }, () => Array(WORDMARK_WIDTH).fill(null));
|
|
394
|
+
let cursor = 0;
|
|
395
|
+
for (const letter of WORDMARK) {
|
|
396
|
+
const glyph = GLYPHS[letter];
|
|
397
|
+
glyph.forEach((line, y) =>
|
|
398
|
+
[...line].forEach((mark, x) => {
|
|
399
|
+
if (mark !== '#') return;
|
|
400
|
+
const t = (cursor + x) / (WORDMARK_WIDTH - 1);
|
|
401
|
+
/** @type {Array<Rgb | null>} */ (rows[y])[cursor + x] = /** @type {Rgb} */ (
|
|
402
|
+
[0, 1, 2].map((i) => Math.round(left[i] + (right[i] - left[i]) * t))
|
|
403
|
+
);
|
|
404
|
+
}),
|
|
405
|
+
);
|
|
406
|
+
cursor += (glyph[0]?.length ?? 0) + GLYPH_GAP;
|
|
407
|
+
}
|
|
408
|
+
return rows;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/** A line of the art: its escape sequences and how many cells it takes. */
|
|
412
|
+
/** @typedef {{ text: string, width: number }} Cells */
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* @param {BannerItem[]} items
|
|
416
|
+
* @param {ColourDepth} depth
|
|
417
|
+
* @returns {Cells[]}
|
|
418
|
+
*/
|
|
419
|
+
function itemLines(items, depth) {
|
|
420
|
+
const labels = items.map((item) => bannerText(item.label));
|
|
421
|
+
const labelWidth = Math.min(MAX_LABEL_WIDTH, Math.max(0, ...labels.map((l) => l.length)));
|
|
422
|
+
return items.map((item, index) => {
|
|
423
|
+
const label = (labels[index] ?? '').padEnd(labelWidth);
|
|
424
|
+
const detail = bannerText(item.detail);
|
|
425
|
+
const mark = `${ESC}[${sgr(TONE_COLOURS[item.tone], depth, 'fg')}m${TONE_MARKS[item.tone]}${RESET}`;
|
|
426
|
+
const tail = detail === '' ? '' : ` ${FAINT}${detail}${RESET}`;
|
|
427
|
+
return {
|
|
428
|
+
text: `${mark} ${label}${tail}`,
|
|
429
|
+
width: 2 + label.length + (detail === '' ? 0 : 2 + detail.length),
|
|
430
|
+
};
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* @param {Cells} cells
|
|
436
|
+
* @param {number} width
|
|
437
|
+
*/
|
|
438
|
+
function centred(cells, width) {
|
|
439
|
+
const left = Math.max(0, Math.floor((width - cells.width) / 2));
|
|
440
|
+
return { text: `${' '.repeat(left)}${cells.text}`, width: left + cells.width };
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* The banner text for `full` or `compact` (LB-D1, LB-D4). Ends with a newline.
|
|
445
|
+
* @param {{ items: BannerItem[], mode: 'full' | 'compact', columns: number,
|
|
446
|
+
* depth: ColourDepth }} input
|
|
447
|
+
*/
|
|
448
|
+
export function renderBanner(input) {
|
|
449
|
+
const { depth } = input;
|
|
450
|
+
const light = rgbOf(art.colours.light);
|
|
451
|
+
const wordmark = pixelLines(wordmarkPixels(), depth).map((text) => ({
|
|
452
|
+
text,
|
|
453
|
+
width: WORDMARK_WIDTH,
|
|
454
|
+
}));
|
|
455
|
+
const engineering = centred(
|
|
456
|
+
{ text: `${ESC}[${sgr(light, depth, 'fg')}m${ENGINEERING}${RESET}`, width: ENGINEERING.length },
|
|
457
|
+
WORDMARK_WIDTH,
|
|
458
|
+
);
|
|
459
|
+
const items = itemLines(input.items, depth);
|
|
460
|
+
const blank = { text: '', width: 0 };
|
|
461
|
+
if (input.mode === 'compact')
|
|
462
|
+
return `${[...wordmark, engineering, blank, ...items]
|
|
463
|
+
.map((line) => (line.text === '' ? '' : `${INDENT}${line.text}`))
|
|
464
|
+
.join('\n')}\n`;
|
|
465
|
+
const mark = pixelLines(markPixels(), depth);
|
|
466
|
+
const besideWidth = input.columns - INDENT.length - art.width - MARK_GAP.length;
|
|
467
|
+
const itemsBeside = items.every((item) => item.width <= besideWidth);
|
|
468
|
+
const right = [...wordmark, blank, engineering, ...(itemsBeside ? [blank, ...items] : [])];
|
|
469
|
+
const top = Math.max(0, Math.floor((mark.length - right.length) / 2));
|
|
470
|
+
const height = Math.max(mark.length, top + right.length);
|
|
471
|
+
const lines = [];
|
|
472
|
+
for (let row = 0; row < height; row += 1) {
|
|
473
|
+
const left = mark[row] ?? ' '.repeat(art.width);
|
|
474
|
+
const beside = right[row - top];
|
|
475
|
+
lines.push(
|
|
476
|
+
beside === undefined || beside.text === ''
|
|
477
|
+
? `${INDENT}${left}`
|
|
478
|
+
: `${INDENT}${left}${MARK_GAP}${beside.text}`,
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
if (!itemsBeside) lines.push('', ...items.map((item) => `${INDENT}${item.text}`));
|
|
482
|
+
return `${lines.join('\n')}\n`;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// --- The collector a launch uses -------------------------------------------------
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Plain mode writes each line when it is known, as before; banner mode keeps the
|
|
489
|
+
* items and draws them once, right before the host starts (LB-D3).
|
|
490
|
+
* @param {{ mode: BannerMode, depth: ColourDepth | null, columns: number,
|
|
491
|
+
* write: (text: string) => void }} options
|
|
492
|
+
*/
|
|
493
|
+
export function createLaunchNotices(options) {
|
|
494
|
+
/** @type {BannerItem[]} */
|
|
495
|
+
const items = [];
|
|
496
|
+
let drawn = false;
|
|
497
|
+
return {
|
|
498
|
+
/** @param {{ plain?: string | null, item?: BannerItem | null }} notice */
|
|
499
|
+
add(notice) {
|
|
500
|
+
if (options.mode === 'plain') {
|
|
501
|
+
if (notice.plain != null) options.write(`${notice.plain}\n`);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
const item = notice.item ?? (notice.plain == null ? null : itemFromLine(notice.plain));
|
|
505
|
+
if (item !== null) items.push(item);
|
|
506
|
+
},
|
|
507
|
+
/**
|
|
508
|
+
* Facts whose plain lines and items do not pair one to one.
|
|
509
|
+
* @param {string[]} plainLines
|
|
510
|
+
* @param {BannerItem[]} groupItems
|
|
511
|
+
*/
|
|
512
|
+
addGroup(plainLines, groupItems) {
|
|
513
|
+
if (options.mode === 'plain') {
|
|
514
|
+
for (const line of plainLines) options.write(`${line}\n`);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
items.push(...groupItems);
|
|
518
|
+
},
|
|
519
|
+
/** Draws the banner once; nothing in plain mode. */
|
|
520
|
+
draw() {
|
|
521
|
+
if (options.mode === 'plain' || drawn || options.depth === null) return;
|
|
522
|
+
drawn = true;
|
|
523
|
+
options.write(
|
|
524
|
+
renderBanner({
|
|
525
|
+
items,
|
|
526
|
+
mode: options.mode,
|
|
527
|
+
columns: options.columns,
|
|
528
|
+
depth: options.depth,
|
|
529
|
+
}),
|
|
530
|
+
);
|
|
531
|
+
},
|
|
532
|
+
};
|
|
533
|
+
}
|
package/dist/launch.mjs
CHANGED
|
@@ -74,7 +74,18 @@ import {
|
|
|
74
74
|
supportsClaudeBusRole,
|
|
75
75
|
supportsWorkerRole,
|
|
76
76
|
workerEnvironment,
|
|
77
|
+
codexSubcommand,
|
|
77
78
|
} from './manager/launch-role.mjs';
|
|
79
|
+
import {
|
|
80
|
+
bannerMode,
|
|
81
|
+
codexGuardrailsItem,
|
|
82
|
+
createLaunchNotices,
|
|
83
|
+
guardrailsItem,
|
|
84
|
+
hostCheckedLine,
|
|
85
|
+
hostItem,
|
|
86
|
+
itemFromLine,
|
|
87
|
+
mcpItems,
|
|
88
|
+
} from './launch-banner.mjs';
|
|
78
89
|
import { MANAGER_ROLE_ENV } from './manager/bus.mjs';
|
|
79
90
|
import { prepareManagerPlugin } from './manager/hooks.mjs';
|
|
80
91
|
import { prepareWorkerPlugin } from './manager/native-worker.mjs';
|
|
@@ -400,6 +411,39 @@ async function parseClaudeLaunchArgs(args, cwd) {
|
|
|
400
411
|
};
|
|
401
412
|
}
|
|
402
413
|
|
|
414
|
+
/**
|
|
415
|
+
* The status lines of one launch (spec aisac-launch-banner): plain lines written as
|
|
416
|
+
* they are known, or the banner drawn once before the host starts.
|
|
417
|
+
* @param {'claude' | 'codex'} host
|
|
418
|
+
* @param {readonly string[]} args The host's native arguments.
|
|
419
|
+
* @param {{ role?: { role?: { kind?: string } } | null }} launchOptions
|
|
420
|
+
* @param {{ terminal?: import('./launch-banner.mjs').Terminal }} dependencies
|
|
421
|
+
*/
|
|
422
|
+
function launchNotices(host, args, launchOptions, dependencies) {
|
|
423
|
+
const terminal = dependencies.terminal ?? {
|
|
424
|
+
stdin: process.stdin,
|
|
425
|
+
stdout: process.stdout,
|
|
426
|
+
stderr: process.stderr,
|
|
427
|
+
env: process.env,
|
|
428
|
+
};
|
|
429
|
+
const decided = bannerMode({
|
|
430
|
+
host,
|
|
431
|
+
args,
|
|
432
|
+
roleKind: launchOptions.role?.role?.kind ?? null,
|
|
433
|
+
terminal,
|
|
434
|
+
codexSubcommand,
|
|
435
|
+
});
|
|
436
|
+
return createLaunchNotices({ ...decided, write: (text) => process.stderr.write(text) });
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* A warning line of today, as a banner item.
|
|
441
|
+
* @param {string} line
|
|
442
|
+
*/
|
|
443
|
+
function warningNotice(line) {
|
|
444
|
+
return { plain: line, item: { ...itemFromLine(line), tone: /** @type {const} */ ('warn') } };
|
|
445
|
+
}
|
|
446
|
+
|
|
403
447
|
/** @param {string[]} args */
|
|
404
448
|
function assertCodexArgs(args) {
|
|
405
449
|
for (const argument of args) {
|
|
@@ -534,6 +578,7 @@ export async function readSessionServers(root, client, environment) {
|
|
|
534
578
|
* @property {typeof prepareManagerPlugin} [prepareManagerPlugin] Manager hook nudges plugin writer (ADR-0058)
|
|
535
579
|
* @property {typeof prepareWorkerPlugin} [prepareWorkerPlugin] Claude Code worker start-text plugin writer (ADR-0060)
|
|
536
580
|
* @property {typeof prepareClaudeBusWorkerPlugin} [prepareClaudeBusWorkerPlugin] Claude bus worker lifecycle plugin writer (MG13)
|
|
581
|
+
* @property {import('./launch-banner.mjs').Terminal} [terminal] The terminal the launch banner reads (spec aisac-launch-banner)
|
|
537
582
|
*/
|
|
538
583
|
|
|
539
584
|
/**
|
|
@@ -605,6 +650,7 @@ export async function launchClaude(config, root, args, dependencies = {}, launch
|
|
|
605
650
|
// or `--host` ask for it and it is installed, pinned and qualified; otherwise the
|
|
606
651
|
// user's own binary, with the reason on stderr when a managed launch fell back.
|
|
607
652
|
const locale = resolvePackLocale(await readStoredLocale(root), process.env);
|
|
653
|
+
const notices = launchNotices('claude', launchArgs.args, launchOptions, dependencies);
|
|
608
654
|
const host = await resolveHost({
|
|
609
655
|
host: 'claude',
|
|
610
656
|
root,
|
|
@@ -618,10 +664,17 @@ export async function launchClaude(config, root, args, dependencies = {}, launch
|
|
|
618
664
|
progress: (line) => process.stderr.write(`${line}\n`),
|
|
619
665
|
});
|
|
620
666
|
if (host.fallback !== null && host.compatibility?.status !== 'rejected')
|
|
621
|
-
|
|
667
|
+
notices.add(warningNotice(hostFallbackLine('claude', host, locale)));
|
|
622
668
|
if (host.recoveryReason !== null && host.recoveryReason !== undefined)
|
|
623
|
-
|
|
624
|
-
|
|
669
|
+
notices.add(
|
|
670
|
+
warningNotice(
|
|
671
|
+
hostRecoveryNoticeLine(
|
|
672
|
+
'claude',
|
|
673
|
+
host.version ?? host.pinned ?? 'unknown',
|
|
674
|
+
host.recoveryReason,
|
|
675
|
+
locale,
|
|
676
|
+
),
|
|
677
|
+
),
|
|
625
678
|
);
|
|
626
679
|
const executable = host.executable;
|
|
627
680
|
if (!executable) {
|
|
@@ -651,10 +704,19 @@ export async function launchClaude(config, root, args, dependencies = {}, launch
|
|
|
651
704
|
throw error;
|
|
652
705
|
}
|
|
653
706
|
const pinnedExecutable = compatibility.executable ?? executable;
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
707
|
+
notices.add({
|
|
708
|
+
plain:
|
|
709
|
+
compatibility.status === 'host_checked'
|
|
710
|
+
? hostCheckedLine('claude', compatibility.version ?? 'unknown', locale)
|
|
711
|
+
: null,
|
|
712
|
+
item: hostItem({
|
|
713
|
+
host: 'claude',
|
|
714
|
+
version: compatibility.version,
|
|
715
|
+
status: compatibility.status,
|
|
716
|
+
managed: host.mode === 'managed',
|
|
717
|
+
locale,
|
|
718
|
+
}),
|
|
719
|
+
});
|
|
658
720
|
const currentVersion = compatibility.version ?? nativeVersion(pinnedExecutable);
|
|
659
721
|
/** @type {import('./engineering-pack.mjs').LaunchHost} */
|
|
660
722
|
const launchHost = { name: 'claude', mode: host.mode, version: compatibility.version ?? null };
|
|
@@ -772,8 +834,9 @@ export async function launchClaude(config, root, args, dependencies = {}, launch
|
|
|
772
834
|
directory,
|
|
773
835
|
packageRoot: validated.packageRoot,
|
|
774
836
|
updateCommand: await updateCommandFor(root, validated.packageRoot),
|
|
775
|
-
}).catch(() => ({ pluginRoot: null, line: null }));
|
|
776
|
-
if (engineering.line !== null)
|
|
837
|
+
}).catch(() => ({ pluginRoot: null, line: null, item: null }));
|
|
838
|
+
if (engineering.line !== null)
|
|
839
|
+
notices.add({ plain: engineering.line, item: engineering.item ?? null });
|
|
777
840
|
// Guardrails need the license this launch confirmed (the pack loaded), and
|
|
778
841
|
// like the pack they never block the launch (spec aisac-engineering-extensions FR5).
|
|
779
842
|
const guardrails =
|
|
@@ -782,14 +845,18 @@ export async function launchClaude(config, root, args, dependencies = {}, launch
|
|
|
782
845
|
: await writeGuardrails({ directory, root, packageRoot: validated.packageRoot }).catch(
|
|
783
846
|
() => null,
|
|
784
847
|
);
|
|
785
|
-
if (guardrails !== null)
|
|
848
|
+
if (guardrails !== null)
|
|
849
|
+
notices.add({
|
|
850
|
+
plain: guardrails.line,
|
|
851
|
+
item: typeof guardrails.count === 'number' ? guardrailsItem(guardrails.count, locale) : null,
|
|
852
|
+
});
|
|
786
853
|
// Catalog servers need the same confirmed license, and never block the launch.
|
|
787
854
|
const servers =
|
|
788
855
|
engineering.pluginRoot === null
|
|
789
856
|
? null
|
|
790
857
|
: await readServers(root, 'claude', process.env).catch(() => null);
|
|
791
|
-
|
|
792
|
-
|
|
858
|
+
if (servers !== null)
|
|
859
|
+
notices.addGroup(mcpLaunchLines(servers, 'claude'), mcpItems(servers, 'claude', locale));
|
|
793
860
|
// A role (spec aisac-engineering-manager FR1, FR6-FR8, FR14) needs the same
|
|
794
861
|
// confirmed license and never blocks the launch; a second manager of the room,
|
|
795
862
|
// a taken worker name or a full room stops it here, before any host starts.
|
|
@@ -820,7 +887,7 @@ export async function launchClaude(config, root, args, dependencies = {}, launch
|
|
|
820
887
|
}
|
|
821
888
|
throw error;
|
|
822
889
|
}
|
|
823
|
-
|
|
890
|
+
notices.add({ plain: roleLaunchLine(role, locale) });
|
|
824
891
|
if (role.active && role.kind === 'manager') {
|
|
825
892
|
managerPlugin = await writeManagerPlugin({
|
|
826
893
|
directory,
|
|
@@ -906,6 +973,7 @@ export async function launchClaude(config, root, args, dependencies = {}, launch
|
|
|
906
973
|
environment.CLAUDE_CODE_ENABLE_FUNCTION_HOOKS = '1';
|
|
907
974
|
// The manager's hooks and `aisac workers --wait` read the room from here (FR9).
|
|
908
975
|
if (manager !== null) environment[MANAGER_ROLE_ENV] = manager.environmentValue;
|
|
976
|
+
notices.draw();
|
|
909
977
|
/** @type {import('node:child_process').ChildProcess} */
|
|
910
978
|
let child;
|
|
911
979
|
try {
|
|
@@ -1022,6 +1090,7 @@ export async function launchCodex(config, root, args, dependencies = {}, launchO
|
|
|
1022
1090
|
version: null,
|
|
1023
1091
|
});
|
|
1024
1092
|
const resolveHost = dependencies.resolveHost ?? resolveHostExecutable;
|
|
1093
|
+
const notices = launchNotices('codex', args, launchOptions, dependencies);
|
|
1025
1094
|
const host = await resolveHost({
|
|
1026
1095
|
host: 'codex',
|
|
1027
1096
|
root,
|
|
@@ -1035,10 +1104,17 @@ export async function launchCodex(config, root, args, dependencies = {}, launchO
|
|
|
1035
1104
|
progress: (line) => process.stderr.write(`${line}\n`),
|
|
1036
1105
|
});
|
|
1037
1106
|
if (host.fallback !== null && host.compatibility?.status !== 'rejected')
|
|
1038
|
-
|
|
1107
|
+
notices.add(warningNotice(hostFallbackLine('codex', host, locale)));
|
|
1039
1108
|
if (host.recoveryReason !== null && host.recoveryReason !== undefined)
|
|
1040
|
-
|
|
1041
|
-
|
|
1109
|
+
notices.add(
|
|
1110
|
+
warningNotice(
|
|
1111
|
+
hostRecoveryNoticeLine(
|
|
1112
|
+
'codex',
|
|
1113
|
+
host.version ?? host.pinned ?? 'unknown',
|
|
1114
|
+
host.recoveryReason,
|
|
1115
|
+
locale,
|
|
1116
|
+
),
|
|
1117
|
+
),
|
|
1042
1118
|
);
|
|
1043
1119
|
const executable = host.executable;
|
|
1044
1120
|
if (!executable) {
|
|
@@ -1072,10 +1148,19 @@ export async function launchCodex(config, root, args, dependencies = {}, launchO
|
|
|
1072
1148
|
await rm(directory, { recursive: true, force: true }).catch(() => undefined);
|
|
1073
1149
|
throw new Error('codex_version_unverified');
|
|
1074
1150
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1151
|
+
notices.add({
|
|
1152
|
+
plain:
|
|
1153
|
+
compatibility.status === 'protocol_match'
|
|
1154
|
+
? hostCheckedLine('codex', compatibility.version, locale)
|
|
1155
|
+
: null,
|
|
1156
|
+
item: hostItem({
|
|
1157
|
+
host: 'codex',
|
|
1158
|
+
version: compatibility.version,
|
|
1159
|
+
status: compatibility.status,
|
|
1160
|
+
managed: host.mode === 'managed',
|
|
1161
|
+
locale,
|
|
1162
|
+
}),
|
|
1163
|
+
});
|
|
1079
1164
|
/** @type {import('./engineering-pack.mjs').LaunchHost} */
|
|
1080
1165
|
const launchHost = { name: 'codex', mode: host.mode, version: compatibility.version };
|
|
1081
1166
|
await writeLaunchMarker(directory, {
|
|
@@ -1146,14 +1231,15 @@ export async function launchCodex(config, root, args, dependencies = {}, launchO
|
|
|
1146
1231
|
client: 'codex',
|
|
1147
1232
|
hostSupported: supportsCodexEngineering(compatibility.version),
|
|
1148
1233
|
updateCommand: await updateCommandFor(root, validated.packageRoot),
|
|
1149
|
-
}).catch(() => ({ pluginRoot: null, codex: null, line: null }));
|
|
1150
|
-
if (engineering.line !== null)
|
|
1234
|
+
}).catch(() => ({ pluginRoot: null, codex: null, line: null, item: null }));
|
|
1235
|
+
if (engineering.line !== null)
|
|
1236
|
+
notices.add({ plain: engineering.line, item: engineering.item ?? null });
|
|
1151
1237
|
if (engineering.codex != null) {
|
|
1152
1238
|
environment[CODEX_ENGINEERING_ENV] = JSON.stringify(engineering.codex);
|
|
1153
1239
|
// Catalog servers need the license the pack confirmed (spec extensions FR6).
|
|
1154
1240
|
const servers = await readServers(root, 'codex', environment).catch(() => null);
|
|
1155
|
-
|
|
1156
|
-
|
|
1241
|
+
if (servers !== null)
|
|
1242
|
+
notices.addGroup(mcpLaunchLines(servers, 'codex'), mcpItems(servers, 'codex', locale));
|
|
1157
1243
|
if (servers !== null && servers.ready.length > 0)
|
|
1158
1244
|
environment[CODEX_MCP_ENV] = JSON.stringify(servers.ready.map((entry) => entry.id));
|
|
1159
1245
|
// Guardrail hooks need the same license and a Codex measured with them
|
|
@@ -1170,7 +1256,13 @@ export async function launchCodex(config, root, args, dependencies = {}, launchO
|
|
|
1170
1256
|
: null;
|
|
1171
1257
|
if (guardrails !== null) {
|
|
1172
1258
|
environment[CODEX_HOOKS_ENV] = guardrails.value;
|
|
1173
|
-
|
|
1259
|
+
notices.add({
|
|
1260
|
+
plain: guardrails.line,
|
|
1261
|
+
item:
|
|
1262
|
+
typeof guardrails.enabledCount === 'number' && guardrails.summary !== undefined
|
|
1263
|
+
? codexGuardrailsItem(guardrails.enabledCount, guardrails.summary, locale)
|
|
1264
|
+
: null,
|
|
1265
|
+
});
|
|
1174
1266
|
}
|
|
1175
1267
|
}
|
|
1176
1268
|
// The worker role (spec aisac-engineering-manager FR1, D14) needs the license the
|
|
@@ -1199,7 +1291,7 @@ export async function launchCodex(config, root, args, dependencies = {}, launchO
|
|
|
1199
1291
|
await rm(directory, { recursive: true, force: true }).catch(() => undefined);
|
|
1200
1292
|
throw error;
|
|
1201
1293
|
}
|
|
1202
|
-
|
|
1294
|
+
notices.add({ plain: roleLaunchLine(role, roleLocale) });
|
|
1203
1295
|
if (role.active && role.kind === 'worker')
|
|
1204
1296
|
Object.assign(environment, workerEnvironment(role, packageRoot));
|
|
1205
1297
|
if (role.active && role.kind === 'manager') {
|
|
@@ -1258,6 +1350,7 @@ export async function launchCodex(config, root, args, dependencies = {}, launchO
|
|
|
1258
1350
|
await closeRole(role);
|
|
1259
1351
|
await rm(directory, { recursive: true, force: true }).catch(() => undefined);
|
|
1260
1352
|
};
|
|
1353
|
+
notices.draw();
|
|
1261
1354
|
/** @type {import('node:child_process').ChildProcess} */
|
|
1262
1355
|
let child;
|
|
1263
1356
|
try {
|
package/dist/managed-host.mjs
CHANGED
|
@@ -1194,3 +1194,83 @@ export function hostRecoveryNoticeLine(host, version, reason, locale) {
|
|
|
1194
1194
|
? `aisac: usando ${label} ${version} do pin privado assinado; o host do sistema foi recusado (${reason}).`
|
|
1195
1195
|
: `aisac: using signed managed ${label} ${version}; the system host was rejected (${reason}).`;
|
|
1196
1196
|
}
|
|
1197
|
+
|
|
1198
|
+
// Enter accepts: the user is in setup and the alternative is a stop.
|
|
1199
|
+
const SETUP_HOST_YES_ANSWERS = new Set(['', 's', 'sim', 'y', 'yes']);
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* Whether `aisac setup` may ask to use the signed private copy of an incompatible
|
|
1203
|
+
* system host (spec aisac-host-upgrade-resilience C8). Only a human at a terminal can
|
|
1204
|
+
* say yes. An explicit system choice (flag, environment or stored setting) vetoes the
|
|
1205
|
+
* question, and the stop's guide names the command instead.
|
|
1206
|
+
* @param {{ host: HostName, flag: HostMode | null, env: NodeJS.ProcessEnv,
|
|
1207
|
+
* settings: ReleaseSettings, interactive: boolean }} input
|
|
1208
|
+
* @returns {'ask' | 'guide'}
|
|
1209
|
+
*/
|
|
1210
|
+
export function setupHostOffer({ host, flag, env, settings, interactive }) {
|
|
1211
|
+
if (!interactive || flag === 'system' || env[HOST_MODE_ENV] === 'system') return 'guide';
|
|
1212
|
+
const stored =
|
|
1213
|
+
settings.hostSelectionStatus === 'valid' ? (settings.hostSelection?.[host] ?? null) : null;
|
|
1214
|
+
return stored?.mode === 'system' && stored.source === 'explicit' ? 'guide' : 'ask';
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
/** @param {string} answer */
|
|
1218
|
+
export function setupHostAnswerAccepted(answer) {
|
|
1219
|
+
return SETUP_HOST_YES_ANSWERS.has(answer.trim().toLowerCase());
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* The one setup question about an incompatible system host (C8).
|
|
1224
|
+
* @param {HostName} host @param {string | null} version @param {string} reason
|
|
1225
|
+
* @param {PackLocale} locale
|
|
1226
|
+
*/
|
|
1227
|
+
export function setupHostQuestion(host, version, reason, locale) {
|
|
1228
|
+
const label = HOST_LABELS[host];
|
|
1229
|
+
const versionText = version === null ? '' : ` ${version}`;
|
|
1230
|
+
return locale === 'pt-BR'
|
|
1231
|
+
? `\naisac: o ${label}${versionText} deste computador não é compatível com este cliente (${reason}).\nO aisac pode instalar uma cópia privada do ${label} na versão testada, usada só pelo aisac (download de algumas centenas de MB, uma vez). O ${label} global, o login e as configurações continuam como estão.\nInstalar e usar a cópia testada? [S/n] `
|
|
1232
|
+
: `\naisac: ${label}${versionText} on this computer is incompatible with this client (${reason}).\naisac can install a private copy of ${label} at the tested version, used only by aisac (a download of a few hundred MB, once). Your global ${label}, its login and its settings stay as they are.\nInstall and use the tested copy? [Y/n] `;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* The guide `aisac setup` prints when it stops on an incompatible system host (C8).
|
|
1237
|
+
* There is no session yet, so it names setup commands only; the global host is
|
|
1238
|
+
* offered an update only when it is older than the supported floor.
|
|
1239
|
+
* @param {HostName} host @param {string | null} version @param {string} reason
|
|
1240
|
+
* @param {PackLocale} locale @param {boolean} [systemEnvironmentOverride]
|
|
1241
|
+
*/
|
|
1242
|
+
export function setupHostRecoveryLine(
|
|
1243
|
+
host,
|
|
1244
|
+
version,
|
|
1245
|
+
reason,
|
|
1246
|
+
locale,
|
|
1247
|
+
systemEnvironmentOverride = false,
|
|
1248
|
+
) {
|
|
1249
|
+
const label = HOST_LABELS[host];
|
|
1250
|
+
const versionText = version === null ? '' : ` ${version}`;
|
|
1251
|
+
const setup = `aisac setup --host-${host} managed`;
|
|
1252
|
+
const older = host === 'claude' && reason === 'unsupported_stable_patch';
|
|
1253
|
+
if (locale === 'pt-BR')
|
|
1254
|
+
return [
|
|
1255
|
+
`O ${label}${versionText} deste computador não é compatível com este cliente do aisac (${reason}).`,
|
|
1256
|
+
systemEnvironmentOverride
|
|
1257
|
+
? `A variável AISAC_HOST_MODE=system está forçando o host do sistema. Remova essa variável e execute \`${setup}\` para o aisac usar uma cópia privada testada, sem mexer no ${label} global.`
|
|
1258
|
+
: `Para o aisac usar uma cópia privada testada, sem mexer no ${label} global, execute \`${setup}\`.`,
|
|
1259
|
+
...(older
|
|
1260
|
+
? [
|
|
1261
|
+
'Outra saída: atualize o Claude Code global com `claude update` e rode `aisac setup` de novo.',
|
|
1262
|
+
]
|
|
1263
|
+
: []),
|
|
1264
|
+
].join('\n');
|
|
1265
|
+
return [
|
|
1266
|
+
`${label}${versionText} on this computer is incompatible with this aisac client (${reason}).`,
|
|
1267
|
+
systemEnvironmentOverride
|
|
1268
|
+
? `AISAC_HOST_MODE=system is forcing the system host. Remove that variable and run \`${setup}\` so aisac uses a tested private copy without touching your global ${label}.`
|
|
1269
|
+
: `To have aisac use a tested private copy without touching your global ${label}, run \`${setup}\`.`,
|
|
1270
|
+
...(older
|
|
1271
|
+
? [
|
|
1272
|
+
'Alternatively, update your global Claude Code with `claude update` and run `aisac setup` again.',
|
|
1273
|
+
]
|
|
1274
|
+
: []),
|
|
1275
|
+
].join('\n');
|
|
1276
|
+
}
|
|
@@ -290,7 +290,7 @@ export function takeRoleFlags(args, host) {
|
|
|
290
290
|
* @param {string[]} args the native arguments, as `takeRoleFlags` leaves them
|
|
291
291
|
* @returns {string | null}
|
|
292
292
|
*/
|
|
293
|
-
function codexSubcommand(args) {
|
|
293
|
+
export function codexSubcommand(args) {
|
|
294
294
|
const native = args[0] === '--' ? args.slice(1) : args;
|
|
295
295
|
for (let index = 0; index < native.length; index += 1) {
|
|
296
296
|
const argument = /** @type {string} */ (native[index]);
|
package/dist/package.json
CHANGED
package/dist/token-guide.mjs
CHANGED
|
@@ -23,6 +23,8 @@ const TOKEN_FAILURES = Object.freeze({
|
|
|
23
23
|
*/
|
|
24
24
|
const SETUP_HINTS = Object.freeze({
|
|
25
25
|
'provider_free_probe_failed:mcp_invalid_input': 'clock',
|
|
26
|
+
// `aisac claude|codex` before any setup (spec aisac-host-upgrade-resilience C9).
|
|
27
|
+
setup_required: 'setup',
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
const TEXT = Object.freeze({
|
|
@@ -53,6 +55,8 @@ const TEXT = Object.freeze({
|
|
|
53
55
|
hints: {
|
|
54
56
|
clock:
|
|
55
57
|
'O AI Brain recusou a sondagem como entrada inválida (INVALID_INPUT). Causa mais comum: o relógio do sistema está adiantado em relação ao servidor; no WSL2 isso acontece depois de suspender o computador. Acerte o relógio (ex.: `sudo hwclock -s` ou reinicie o WSL) e rode `aisac setup` de novo. O token não precisa mudar.',
|
|
58
|
+
setup:
|
|
59
|
+
'O aisac ainda não está configurado neste computador. Execute `aisac setup` e depois rode este comando de novo.',
|
|
56
60
|
},
|
|
57
61
|
},
|
|
58
62
|
en: {
|
|
@@ -81,6 +85,8 @@ const TEXT = Object.freeze({
|
|
|
81
85
|
hints: {
|
|
82
86
|
clock:
|
|
83
87
|
'AI Brain rejected the probe as invalid input (INVALID_INPUT). Most common cause: the system clock is ahead of the server; on WSL2 this happens after the computer sleeps. Fix the clock (e.g. `sudo hwclock -s` or restart WSL) and run `aisac setup` again. The token does not need to change.',
|
|
88
|
+
setup:
|
|
89
|
+
'aisac is not set up on this computer yet. Run `aisac setup`, then run this command again.',
|
|
84
90
|
},
|
|
85
91
|
},
|
|
86
92
|
});
|
package/package.json
CHANGED