@aria_asi/cli 0.2.26 → 0.2.30
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/CLIENT-ONBOARDING.md +282 -0
- package/bin/aria.js +1140 -14
- package/dist/aria-connector/src/auth-commands.d.ts +1 -0
- package/dist/aria-connector/src/auth-commands.d.ts.map +1 -1
- package/dist/aria-connector/src/auth-commands.js +89 -41
- package/dist/aria-connector/src/auth-commands.js.map +1 -1
- package/dist/aria-connector/src/chat.d.ts +3 -0
- package/dist/aria-connector/src/chat.d.ts.map +1 -1
- package/dist/aria-connector/src/chat.js +146 -8
- package/dist/aria-connector/src/chat.js.map +1 -1
- package/dist/aria-connector/src/codebase-scanner.d.ts +2 -2
- package/dist/aria-connector/src/codebase-scanner.d.ts.map +1 -1
- package/dist/aria-connector/src/codebase-scanner.js +1 -1
- package/dist/aria-connector/src/codebase-scanner.js.map +1 -1
- package/dist/aria-connector/src/config.d.ts +12 -0
- package/dist/aria-connector/src/config.d.ts.map +1 -1
- package/dist/aria-connector/src/config.js +2 -0
- package/dist/aria-connector/src/config.js.map +1 -1
- package/dist/aria-connector/src/connectors/claude-code.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/claude-code.js +80 -24
- package/dist/aria-connector/src/connectors/claude-code.js.map +1 -1
- package/dist/aria-connector/src/connectors/codebase-awareness.d.ts +37 -0
- package/dist/aria-connector/src/connectors/codebase-awareness.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/codebase-awareness.js +335 -0
- package/dist/aria-connector/src/connectors/codebase-awareness.js.map +1 -0
- package/dist/aria-connector/src/connectors/codex.d.ts +3 -0
- package/dist/aria-connector/src/connectors/codex.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/codex.js +248 -0
- package/dist/aria-connector/src/connectors/codex.js.map +1 -0
- package/dist/aria-connector/src/connectors/cognitive-skills.d.ts +2 -0
- package/dist/aria-connector/src/connectors/cognitive-skills.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/cognitive-skills.js +47 -0
- package/dist/aria-connector/src/connectors/cognitive-skills.js.map +1 -0
- package/dist/aria-connector/src/connectors/opencode.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/opencode.js +90 -4
- package/dist/aria-connector/src/connectors/opencode.js.map +1 -1
- package/dist/aria-connector/src/connectors/repo-git-hooks.d.ts +3 -0
- package/dist/aria-connector/src/connectors/repo-git-hooks.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/repo-git-hooks.js +87 -0
- package/dist/aria-connector/src/connectors/repo-git-hooks.js.map +1 -0
- package/dist/aria-connector/src/connectors/repo-guard.d.ts +19 -0
- package/dist/aria-connector/src/connectors/repo-guard.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/repo-guard.js +509 -0
- package/dist/aria-connector/src/connectors/repo-guard.js.map +1 -0
- package/dist/aria-connector/src/connectors/runtime.d.ts +2 -0
- package/dist/aria-connector/src/connectors/runtime.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/runtime.js +330 -0
- package/dist/aria-connector/src/connectors/runtime.js.map +1 -0
- package/dist/aria-connector/src/connectors/shell.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/shell.js +78 -13
- package/dist/aria-connector/src/connectors/shell.js.map +1 -1
- package/dist/aria-connector/src/connectors/syncd.d.ts +27 -0
- package/dist/aria-connector/src/connectors/syncd.d.ts.map +1 -0
- package/dist/aria-connector/src/connectors/syncd.js +405 -0
- package/dist/aria-connector/src/connectors/syncd.js.map +1 -0
- package/dist/aria-connector/src/decisions.d.ts +207 -0
- package/dist/aria-connector/src/decisions.d.ts.map +1 -0
- package/dist/aria-connector/src/decisions.js +291 -0
- package/dist/aria-connector/src/decisions.js.map +1 -0
- package/dist/aria-connector/src/garden-control-plane.d.ts.map +1 -1
- package/dist/aria-connector/src/garden-control-plane.js +74 -17
- package/dist/aria-connector/src/garden-control-plane.js.map +1 -1
- package/dist/aria-connector/src/github-connect.d.ts +18 -0
- package/dist/aria-connector/src/github-connect.d.ts.map +1 -0
- package/dist/aria-connector/src/github-connect.js +117 -0
- package/dist/aria-connector/src/github-connect.js.map +1 -0
- package/dist/aria-connector/src/harness-client.d.ts +15 -0
- package/dist/aria-connector/src/harness-client.d.ts.map +1 -1
- package/dist/aria-connector/src/harness-client.js +106 -3
- package/dist/aria-connector/src/harness-client.js.map +1 -1
- package/dist/aria-connector/src/hive-client.d.ts +30 -0
- package/dist/aria-connector/src/hive-client.d.ts.map +1 -1
- package/dist/aria-connector/src/hive-client.js +124 -5
- package/dist/aria-connector/src/hive-client.js.map +1 -1
- package/dist/aria-connector/src/index.d.ts +13 -2
- package/dist/aria-connector/src/index.d.ts.map +1 -1
- package/dist/aria-connector/src/index.js +10 -1
- package/dist/aria-connector/src/index.js.map +1 -1
- package/dist/aria-connector/src/lib/aristotle-noor-wire.d.ts +102 -0
- package/dist/aria-connector/src/lib/aristotle-noor-wire.d.ts.map +1 -0
- package/dist/aria-connector/src/lib/aristotle-noor-wire.js +231 -0
- package/dist/aria-connector/src/lib/aristotle-noor-wire.js.map +1 -0
- package/dist/aria-connector/src/providers/types.d.ts +5 -0
- package/dist/aria-connector/src/providers/types.d.ts.map +1 -1
- package/dist/aria-connector/src/runtime-proof.d.ts +45 -0
- package/dist/aria-connector/src/runtime-proof.d.ts.map +1 -0
- package/dist/aria-connector/src/runtime-proof.js +340 -0
- package/dist/aria-connector/src/runtime-proof.js.map +1 -0
- package/dist/aria-connector/src/self-update.d.ts +2 -1
- package/dist/aria-connector/src/self-update.d.ts.map +1 -1
- package/dist/aria-connector/src/self-update.js +84 -8
- package/dist/aria-connector/src/self-update.js.map +1 -1
- package/dist/aria-connector/src/setup-wizard.d.ts.map +1 -1
- package/dist/aria-connector/src/setup-wizard.js +34 -2
- package/dist/aria-connector/src/setup-wizard.js.map +1 -1
- package/dist/assets/hooks/aria-agent-handoff.mjs +224 -0
- package/dist/assets/hooks/aria-agent-ledger-merge.mjs +164 -0
- package/dist/assets/hooks/aria-architect-fallback.mjs +267 -0
- package/dist/assets/hooks/aria-cognition-substrate-binding.mjs +668 -0
- package/dist/assets/hooks/aria-discovery-record.mjs +101 -0
- package/dist/assets/hooks/aria-harness-via-sdk.mjs +412 -0
- package/dist/assets/hooks/aria-import-resolution-gate.mjs +330 -0
- package/dist/assets/hooks/aria-outcome-record.mjs +84 -0
- package/dist/assets/hooks/aria-pre-emit-dryrun.mjs +294 -0
- package/dist/assets/hooks/aria-pre-text-gate.mjs +112 -0
- package/dist/assets/hooks/aria-pre-tool-gate.mjs +2133 -0
- package/dist/assets/hooks/aria-preprompt-consult.mjs +438 -0
- package/dist/assets/hooks/aria-preturn-memory-gate.mjs +570 -0
- package/dist/assets/hooks/aria-repo-doctrine-gate.mjs +397 -0
- package/dist/assets/hooks/aria-stop-gate.mjs +1551 -0
- package/dist/assets/hooks/aria-trigger-autolearn.mjs +229 -0
- package/dist/assets/hooks/aria-userprompt-abandon-detect.mjs +192 -0
- package/dist/assets/hooks/doctrine_trigger_map.json +479 -0
- package/dist/assets/hooks/lib/canonical-lenses.mjs +64 -0
- package/dist/assets/hooks/lib/gate-audit.mjs +43 -0
- package/dist/assets/hooks/test-aria-preturn-memory-gate.mjs +245 -0
- package/dist/assets/hooks/test-tier-lens-labeling.mjs +399 -0
- package/dist/assets/opencode-plugins/harness-context/index.js +60 -0
- package/dist/assets/opencode-plugins/harness-context/inject-context.mjs +179 -0
- package/dist/assets/opencode-plugins/harness-context/package.json +9 -0
- package/dist/assets/opencode-plugins/harness-gate/index.js +248 -0
- package/dist/assets/opencode-plugins/harness-outcome/index.js +129 -0
- package/dist/assets/opencode-plugins/harness-role/index.js +77 -0
- package/dist/assets/opencode-plugins/harness-role/package.json +9 -0
- package/dist/assets/opencode-plugins/harness-stop/index.js +241 -0
- package/dist/runtime/discipline/CLAUDE.md +339 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-essence/SKILL.md +63 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-essence/references/domain-matrix.md +80 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-essence/references/evolution-loop.md +30 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-essence/references/readable-cognition.md +27 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-forge-guardrails/SKILL.md +35 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-forge-guardrails/references/checklist.md +31 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-repo-doctrine/SKILL.md +39 -0
- package/dist/runtime/discipline/skills/aria-cognition/forge-quality-rules/SKILL.md +43 -0
- package/dist/runtime/discipline/skills/aria-cognition/ghazali-8lens/SKILL.md +38 -0
- package/dist/runtime/discipline/skills/aria-cognition/istiqra-induction/SKILL.md +26 -0
- package/dist/runtime/discipline/skills/aria-cognition/ladunni-22/SKILL.md +35 -0
- package/dist/runtime/discipline/skills/aria-cognition/mizan/SKILL.md +72 -0
- package/dist/runtime/discipline/skills/aria-cognition/nadia/SKILL.md +38 -0
- package/dist/runtime/discipline/skills/aria-cognition/nadia-psi/SKILL.md +38 -0
- package/dist/runtime/discipline/skills/aria-cognition/predictor/SKILL.md +25 -0
- package/dist/runtime/discipline/skills/aria-cognition/qiyas-analogy/SKILL.md +26 -0
- package/dist/runtime/discipline/skills/aria-cognition/soul-domains/SKILL.md +25 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-aristotle-intra-phase/SKILL.md +81 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-aristotle-post-phase/SKILL.md +98 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-aristotle-pre-phase/SKILL.md +99 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-deploy/SKILL.md +127 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-no-stripping/SKILL.md +117 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-onboarding/SKILL.md +112 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-output-discipline/SKILL.md +102 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-substrate-binding/SKILL.md +121 -0
- package/dist/runtime/doctor.mjs +23 -0
- package/dist/runtime/local-phase.mjs +650 -0
- package/dist/runtime/manifest.json +15 -0
- package/dist/runtime/mizan-scheduler.mjs +331 -0
- package/dist/runtime/package.json +6 -0
- package/dist/runtime/provider-proxy.mjs +594 -0
- package/dist/runtime/sdk/BUNDLED.json +5 -0
- package/dist/runtime/sdk/index.d.ts +477 -0
- package/dist/runtime/sdk/index.js +1469 -0
- package/dist/runtime/sdk/index.js.map +1 -0
- package/dist/runtime/sdk/package.json +8 -0
- package/dist/runtime/sdk/runWithCognition.d.ts +77 -0
- package/dist/runtime/sdk/runWithCognition.js +157 -0
- package/dist/runtime/sdk/runWithCognition.js.map +1 -0
- package/dist/runtime/service.mjs +3058 -0
- package/dist/runtime/vendor/aria-gate-runtime/index.d.ts +53 -0
- package/dist/runtime/vendor/aria-gate-runtime/index.d.ts.map +1 -0
- package/dist/runtime/vendor/aria-gate-runtime/index.js +292 -0
- package/dist/runtime/vendor/aria-gate-runtime/index.js.map +1 -0
- package/dist/runtime/vendor/aria-gate-runtime/package.json +6 -0
- package/dist/sdk/BUNDLED.json +2 -2
- package/dist/sdk/index.d.ts +283 -0
- package/dist/sdk/index.js +622 -85
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/runWithCognition.d.ts +77 -0
- package/dist/sdk/runWithCognition.js +157 -0
- package/dist/sdk/runWithCognition.js.map +1 -0
- package/hooks/aria-agent-handoff.mjs +11 -1
- package/hooks/aria-architect-fallback.mjs +109 -40
- package/hooks/aria-cognition-substrate-binding.mjs +668 -0
- package/hooks/aria-harness-via-sdk.mjs +34 -21
- package/hooks/aria-import-resolution-gate.mjs +330 -0
- package/hooks/aria-outcome-record.mjs +5 -1
- package/hooks/aria-pre-emit-dryrun.mjs +294 -0
- package/hooks/aria-pre-tool-gate.mjs +828 -41
- package/hooks/aria-preprompt-consult.mjs +113 -13
- package/hooks/aria-preturn-memory-gate.mjs +298 -6
- package/hooks/aria-repo-doctrine-gate.mjs +397 -0
- package/hooks/aria-stop-gate.mjs +739 -76
- package/hooks/aria-userprompt-abandon-detect.mjs +5 -1
- package/hooks/doctrine_trigger_map.json +209 -15
- package/hooks/lib/canonical-lenses.mjs +64 -0
- package/hooks/lib/gate-audit.mjs +43 -0
- package/opencode-plugins/harness-context/index.js +1 -1
- package/opencode-plugins/harness-context/inject-context.mjs +82 -23
- package/opencode-plugins/harness-gate/index.js +248 -0
- package/opencode-plugins/harness-outcome/index.js +129 -0
- package/opencode-plugins/harness-stop/index.js +241 -0
- package/package.json +9 -3
- package/runtime-src/doctor.mjs +23 -0
- package/runtime-src/local-phase.mjs +650 -0
- package/runtime-src/mizan-scheduler.mjs +331 -0
- package/runtime-src/provider-proxy.mjs +594 -0
- package/runtime-src/service.mjs +3058 -0
- package/scripts/bundle-sdk.mjs +317 -0
- package/scripts/install-client.sh +176 -0
- package/scripts/publish-all.sh +344 -0
- package/scripts/publish-docker.sh +27 -0
- package/scripts/validate-hook-contracts.mjs +54 -0
- package/scripts/validate-skill-prompts.mjs +95 -0
- package/skills/aria-cognition/aria-essence/SKILL.md +63 -0
- package/skills/aria-cognition/aria-essence/references/domain-matrix.md +80 -0
- package/skills/aria-cognition/aria-essence/references/evolution-loop.md +30 -0
- package/skills/aria-cognition/aria-essence/references/readable-cognition.md +27 -0
- package/skills/aria-cognition/aria-forge-guardrails/SKILL.md +35 -0
- package/skills/aria-cognition/aria-forge-guardrails/references/checklist.md +31 -0
- package/skills/aria-cognition/aria-repo-doctrine/SKILL.md +39 -0
- package/skills/aria-cognition/forge-quality-rules/SKILL.md +43 -0
- package/skills/aria-cognition/ghazali-8lens/SKILL.md +38 -0
- package/skills/aria-cognition/istiqra-induction/SKILL.md +26 -0
- package/skills/aria-cognition/ladunni-22/SKILL.md +35 -0
- package/skills/aria-cognition/mizan/SKILL.md +72 -0
- package/skills/aria-cognition/nadia/SKILL.md +38 -0
- package/skills/aria-cognition/nadia-psi/SKILL.md +38 -0
- package/skills/aria-cognition/predictor/SKILL.md +25 -0
- package/skills/aria-cognition/qiyas-analogy/SKILL.md +26 -0
- package/skills/aria-cognition/soul-domains/SKILL.md +25 -0
- package/src/auth-commands.ts +111 -45
- package/src/chat.ts +174 -13
- package/src/codebase-scanner.ts +4 -0
- package/src/config.ts +15 -0
- package/src/connectors/claude-code.ts +79 -25
- package/src/connectors/codebase-awareness.ts +408 -0
- package/src/connectors/codex.ts +274 -0
- package/src/connectors/cognitive-skills.ts +51 -0
- package/src/connectors/opencode.ts +93 -4
- package/src/connectors/repo-git-hooks.ts +86 -0
- package/src/connectors/repo-guard.ts +589 -0
- package/src/connectors/runtime.ts +374 -0
- package/src/connectors/shell.ts +83 -14
- package/src/connectors/syncd.ts +488 -0
- package/src/decisions.ts +469 -0
- package/src/garden-control-plane.ts +101 -26
- package/src/github-connect.ts +143 -0
- package/src/harness-client.ts +128 -3
- package/src/hive-client.ts +165 -5
- package/src/index.ts +41 -2
- package/src/lib/aristotle-noor-wire.ts +310 -0
- package/src/providers/types.ts +6 -0
- package/src/runtime-proof.ts +392 -0
- package/src/self-update.ts +89 -8
- package/src/setup-wizard.ts +37 -2
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
|
|
5
|
+
export interface RuntimeProofTelemetry {
|
|
6
|
+
available: boolean;
|
|
7
|
+
source?: string;
|
|
8
|
+
reason?: string;
|
|
9
|
+
runtimeStatus?: string;
|
|
10
|
+
hiveCycleCount?: number;
|
|
11
|
+
hiveTasksCompleted?: number;
|
|
12
|
+
hiveTasksFailed?: number;
|
|
13
|
+
turns?: number;
|
|
14
|
+
interceptions?: number;
|
|
15
|
+
qualityGatedOutcomes?: number;
|
|
16
|
+
hallucinationStops?: number;
|
|
17
|
+
blockedUnsafeActions?: number;
|
|
18
|
+
qualityScore?: number;
|
|
19
|
+
qualityStatus?: string;
|
|
20
|
+
complianceState?: string;
|
|
21
|
+
packetHash?: string;
|
|
22
|
+
passRatePercentToday?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface RuntimeProofSnapshot {
|
|
26
|
+
provider?: string;
|
|
27
|
+
model?: string;
|
|
28
|
+
promptTokens?: number;
|
|
29
|
+
completionTokens?: number;
|
|
30
|
+
totalTokens?: number;
|
|
31
|
+
latencyMs?: number;
|
|
32
|
+
harnessTurns?: number;
|
|
33
|
+
llmDispatches?: number;
|
|
34
|
+
toolDispatches?: number;
|
|
35
|
+
mcpToolCalls?: number;
|
|
36
|
+
gateSeverity?: 'pass' | 'warn' | 'block' | string;
|
|
37
|
+
capHit?: boolean;
|
|
38
|
+
telemetry?: RuntimeProofTelemetry;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface RuntimeProofFetchArgs {
|
|
42
|
+
sessionId: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface RuntimeProofFormatOpts {
|
|
46
|
+
mode?: 'ansi' | 'plain';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const ANSI_GREY_OPEN = '\x1b[90m';
|
|
50
|
+
const ANSI_RESET = '\x1b[0m';
|
|
51
|
+
const HARNESS_BASE_URL =
|
|
52
|
+
process.env.ARIA_HIVE_RUNTIME_URL ||
|
|
53
|
+
process.env.ARIA_HARNESS_BASE_URL ||
|
|
54
|
+
process.env.ARIA_HARNESS_URL ||
|
|
55
|
+
'https://harness.ariasos.com';
|
|
56
|
+
const OWNER_TOKEN_PATH = path.join(homedir(), '.aria', 'owner-token');
|
|
57
|
+
const LICENSE_PATH = path.join(homedir(), '.aria', 'license.json');
|
|
58
|
+
|
|
59
|
+
export async function enrichRuntimeProof(
|
|
60
|
+
base: RuntimeProofSnapshot,
|
|
61
|
+
args: RuntimeProofFetchArgs,
|
|
62
|
+
): Promise<RuntimeProofSnapshot> {
|
|
63
|
+
const telemetry = await fetchRuntimeProofTelemetry(args);
|
|
64
|
+
return {
|
|
65
|
+
...base,
|
|
66
|
+
telemetry,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function fetchRuntimeProofTelemetry(
|
|
71
|
+
args: RuntimeProofFetchArgs,
|
|
72
|
+
): Promise<RuntimeProofTelemetry> {
|
|
73
|
+
const authHeaders = resolveHarnessAuthHeaders();
|
|
74
|
+
const candidates = [
|
|
75
|
+
{
|
|
76
|
+
source: 'aria-telemetry-badge-metrics',
|
|
77
|
+
url: `${HARNESS_BASE_URL}/api/telemetry/badge-metrics?sessionId=${encodeURIComponent(args.sessionId)}&surface=aria-cli`,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
source: 'aria-telemetry-public-proof',
|
|
81
|
+
url: `${HARNESS_BASE_URL}/api/telemetry/public-proof?sessionId=${encodeURIComponent(args.sessionId)}&surface=aria-cli`,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
source: 'aria-telemetry-public-proof-path',
|
|
85
|
+
url: `${HARNESS_BASE_URL}/api/telemetry/public-proof/${encodeURIComponent(args.sessionId)}`,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
source: 'hive-runtime-status',
|
|
89
|
+
url: `${HARNESS_BASE_URL}/hive/status`,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
source: 'hive-runtime-status-api',
|
|
93
|
+
url: `${HARNESS_BASE_URL}/api/hive/status`,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
source: 'proof-layer-summary',
|
|
97
|
+
url: `${HARNESS_BASE_URL}/api/metrics/proof-layer/summary?window=24h`,
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
let lastReason = 'telemetry endpoint unavailable';
|
|
102
|
+
|
|
103
|
+
for (const candidate of candidates) {
|
|
104
|
+
try {
|
|
105
|
+
const response = await fetch(candidate.url, {
|
|
106
|
+
headers: authHeaders,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
if (response.status === 401 || response.status === 403 || response.status === 404) {
|
|
110
|
+
lastReason = `${candidate.source}:${response.status}`;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!response.ok) {
|
|
115
|
+
lastReason = `${candidate.source}:${response.status}`;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const payload = await response.json() as Record<string, unknown>;
|
|
120
|
+
const parsed = parseTelemetryPayload(candidate.source, payload);
|
|
121
|
+
if (parsed.available) {
|
|
122
|
+
return parsed;
|
|
123
|
+
}
|
|
124
|
+
lastReason = parsed.reason || `${candidate.source}:no-proof-fields`;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
lastReason = `${candidate.source}:${error instanceof Error ? error.message : String(error)}`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
available: false,
|
|
132
|
+
reason: lastReason,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function formatRuntimeProofLine(
|
|
137
|
+
proof: RuntimeProofSnapshot,
|
|
138
|
+
opts: RuntimeProofFormatOpts = {},
|
|
139
|
+
): string {
|
|
140
|
+
const parts: string[] = [];
|
|
141
|
+
const surface = [proof.provider, proof.model].filter(Boolean).join('/');
|
|
142
|
+
if (surface) parts.push(`proof ${surface}`);
|
|
143
|
+
else parts.push('proof');
|
|
144
|
+
|
|
145
|
+
if (proof.promptTokens !== undefined || proof.completionTokens !== undefined || proof.totalTokens !== undefined) {
|
|
146
|
+
const prompt = proof.promptTokens ?? '?';
|
|
147
|
+
const completion = proof.completionTokens ?? '?';
|
|
148
|
+
const total = proof.totalTokens ?? deriveTotalTokens(proof.promptTokens, proof.completionTokens);
|
|
149
|
+
const totalSuffix = total !== undefined ? ` (${total})` : '';
|
|
150
|
+
parts.push(`tok ${prompt}/${completion}${totalSuffix}`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (proof.harnessTurns !== undefined) parts.push(`turns ${proof.harnessTurns}`);
|
|
154
|
+
if (proof.llmDispatches !== undefined) parts.push(`llm ${proof.llmDispatches}`);
|
|
155
|
+
if (proof.toolDispatches !== undefined) parts.push(`tools ${proof.toolDispatches}`);
|
|
156
|
+
if (proof.mcpToolCalls !== undefined) parts.push(`mcp ${proof.mcpToolCalls}`);
|
|
157
|
+
if (proof.gateSeverity) parts.push(`gate ${proof.gateSeverity}`);
|
|
158
|
+
if (proof.capHit) parts.push('cap hit');
|
|
159
|
+
|
|
160
|
+
if (proof.telemetry?.available) {
|
|
161
|
+
if (proof.telemetry.source) parts.push(`src ${proof.telemetry.source}`);
|
|
162
|
+
if (proof.telemetry.runtimeStatus) parts.push(`hive ${proof.telemetry.runtimeStatus}`);
|
|
163
|
+
if (proof.telemetry.hiveCycleCount !== undefined) parts.push(`cycles ${proof.telemetry.hiveCycleCount}`);
|
|
164
|
+
if (proof.telemetry.hiveTasksCompleted !== undefined) parts.push(`hive-ok ${proof.telemetry.hiveTasksCompleted}`);
|
|
165
|
+
if (proof.telemetry.hiveTasksFailed !== undefined) parts.push(`hive-fail ${proof.telemetry.hiveTasksFailed}`);
|
|
166
|
+
if (proof.telemetry.turns !== undefined && proof.harnessTurns === undefined) {
|
|
167
|
+
parts.push(`tele-turns ${proof.telemetry.turns}`);
|
|
168
|
+
}
|
|
169
|
+
if (proof.telemetry.interceptions !== undefined) parts.push(`intercepts ${proof.telemetry.interceptions}`);
|
|
170
|
+
if (proof.telemetry.qualityGatedOutcomes !== undefined) parts.push(`gated ${proof.telemetry.qualityGatedOutcomes}`);
|
|
171
|
+
if (proof.telemetry.blockedUnsafeActions !== undefined) parts.push(`unsafe ${proof.telemetry.blockedUnsafeActions}`);
|
|
172
|
+
if (proof.telemetry.hallucinationStops !== undefined) parts.push(`hallu ${proof.telemetry.hallucinationStops}`);
|
|
173
|
+
if (proof.telemetry.qualityScore !== undefined) parts.push(`quality ${formatQualityScore(proof.telemetry.qualityScore)}`);
|
|
174
|
+
if (proof.telemetry.qualityStatus) parts.push(`status ${proof.telemetry.qualityStatus}`);
|
|
175
|
+
if (proof.telemetry.passRatePercentToday !== undefined) parts.push(`pass24h ${proof.telemetry.passRatePercentToday}%`);
|
|
176
|
+
if (proof.telemetry.packetHash) parts.push(`packet ${proof.telemetry.packetHash.slice(0, 12)}`);
|
|
177
|
+
if (proof.telemetry.complianceState) parts.push(`compliance ${proof.telemetry.complianceState}`);
|
|
178
|
+
} else if (proof.telemetry?.reason) {
|
|
179
|
+
parts.push(`src ${proof.telemetry.reason}`);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (proof.latencyMs !== undefined) parts.push(`${Math.round(proof.latencyMs)}ms`);
|
|
183
|
+
|
|
184
|
+
const body = parts.join(' | ');
|
|
185
|
+
if ((opts.mode ?? 'plain') === 'ansi') {
|
|
186
|
+
return `${ANSI_GREY_OPEN}${body}${ANSI_RESET}`;
|
|
187
|
+
}
|
|
188
|
+
return body;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function parseTelemetryPayload(source: string, payload: Record<string, unknown>): RuntimeProofTelemetry {
|
|
192
|
+
if (source === 'proof-layer-summary') {
|
|
193
|
+
return parseProofLayerSummary(payload);
|
|
194
|
+
}
|
|
195
|
+
if (source === 'hive-runtime-status' || source === 'hive-runtime-status-api') {
|
|
196
|
+
return parseHiveRuntimeStatus(source, payload);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const turns = findNumber(payload, ['turns', 'harnessed_turns', 'loop_turns']);
|
|
200
|
+
const interceptions = findNumber(payload, ['interceptions', 'intercepts', 'intercept_count']);
|
|
201
|
+
const qualityGatedOutcomes = findNumber(payload, ['quality_gated_outcomes', 'qualityGatedOutcomes', 'gated_outcomes']);
|
|
202
|
+
const hallucinationStops = findNumber(payload, ['hallucination_stops', 'hallucinationStops', 'hallucination_blocks']);
|
|
203
|
+
const blockedUnsafeActions = findNumber(payload, ['blocked_unsafe_actions', 'blockedUnsafeActions', 'unsafe_blocks']);
|
|
204
|
+
const qualityScore = findNumber(payload, ['quality_score', 'qualityScore']);
|
|
205
|
+
const qualityStatus = findString(payload, ['quality_status', 'qualityStatus']);
|
|
206
|
+
const complianceState = findString(payload, ['compliance_state', 'complianceState']);
|
|
207
|
+
const packetHash = findString(payload, ['packet_hash', 'packetHash', 'harness_packet_hash']);
|
|
208
|
+
const passRatePercentToday = normalizePercent(findNumber(payload, ['pass_rate_percent_today', 'passRatePercentToday', 'pass_rate']));
|
|
209
|
+
|
|
210
|
+
const available =
|
|
211
|
+
turns !== undefined ||
|
|
212
|
+
interceptions !== undefined ||
|
|
213
|
+
qualityGatedOutcomes !== undefined ||
|
|
214
|
+
hallucinationStops !== undefined ||
|
|
215
|
+
blockedUnsafeActions !== undefined ||
|
|
216
|
+
qualityScore !== undefined ||
|
|
217
|
+
qualityStatus !== undefined ||
|
|
218
|
+
complianceState !== undefined ||
|
|
219
|
+
packetHash !== undefined ||
|
|
220
|
+
passRatePercentToday !== undefined;
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
available,
|
|
224
|
+
source,
|
|
225
|
+
reason: available ? undefined : `${source}:no-proof-fields`,
|
|
226
|
+
turns,
|
|
227
|
+
interceptions,
|
|
228
|
+
qualityGatedOutcomes,
|
|
229
|
+
hallucinationStops,
|
|
230
|
+
blockedUnsafeActions,
|
|
231
|
+
qualityScore,
|
|
232
|
+
qualityStatus,
|
|
233
|
+
complianceState,
|
|
234
|
+
packetHash,
|
|
235
|
+
passRatePercentToday,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function parseProofLayerSummary(payload: Record<string, unknown>): RuntimeProofTelemetry {
|
|
240
|
+
const decisions = readObject(payload.decisions);
|
|
241
|
+
const gateBlocks = readObject(payload.gate_blocks);
|
|
242
|
+
const recentIntercepts = Array.isArray(payload.recent_intercepts) ? payload.recent_intercepts : [];
|
|
243
|
+
const passRateRaw = readNumber(decisions?.pass_rate);
|
|
244
|
+
const passRatePercentToday = normalizePercent(passRateRaw);
|
|
245
|
+
const qualityGatedOutcomes = readNumber(gateBlocks?.total);
|
|
246
|
+
const blockedUnsafeActions = readNumber(gateBlocks?.open_blocking);
|
|
247
|
+
|
|
248
|
+
const available =
|
|
249
|
+
passRatePercentToday !== undefined ||
|
|
250
|
+
qualityGatedOutcomes !== undefined ||
|
|
251
|
+
blockedUnsafeActions !== undefined ||
|
|
252
|
+
recentIntercepts.length > 0;
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
available,
|
|
256
|
+
source: 'proof-layer-summary',
|
|
257
|
+
reason: available ? undefined : 'proof-layer-summary:no-proof-fields',
|
|
258
|
+
interceptions: recentIntercepts.length > 0 ? recentIntercepts.length : undefined,
|
|
259
|
+
qualityGatedOutcomes,
|
|
260
|
+
blockedUnsafeActions,
|
|
261
|
+
passRatePercentToday,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function parseHiveRuntimeStatus(source: string, payload: Record<string, unknown>): RuntimeProofTelemetry {
|
|
266
|
+
const runtimeStatus = findString(payload, ['status']);
|
|
267
|
+
const hiveCycleCount = findNumber(payload, ['cycleCount']);
|
|
268
|
+
const hiveTasksCompleted = findNumber(payload, ['tasksCompleted']);
|
|
269
|
+
const hiveTasksFailed = findNumber(payload, ['tasksFailed']);
|
|
270
|
+
const available =
|
|
271
|
+
runtimeStatus !== undefined ||
|
|
272
|
+
hiveCycleCount !== undefined ||
|
|
273
|
+
hiveTasksCompleted !== undefined ||
|
|
274
|
+
hiveTasksFailed !== undefined;
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
available,
|
|
278
|
+
source,
|
|
279
|
+
reason: available ? undefined : `${source}:no-runtime-fields`,
|
|
280
|
+
runtimeStatus,
|
|
281
|
+
hiveCycleCount,
|
|
282
|
+
hiveTasksCompleted,
|
|
283
|
+
hiveTasksFailed,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function resolveHarnessAuthHeaders(): Record<string, string> {
|
|
288
|
+
const ownerToken = readTrimmedFile(OWNER_TOKEN_PATH);
|
|
289
|
+
if (ownerToken) {
|
|
290
|
+
return {
|
|
291
|
+
Authorization: `Bearer ${ownerToken}`,
|
|
292
|
+
'x-aria-owner': 'true',
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const licenseToken = readLicenseToken();
|
|
297
|
+
if (licenseToken) {
|
|
298
|
+
return {
|
|
299
|
+
Authorization: `Bearer ${licenseToken}`,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return {};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function readLicenseToken(): string {
|
|
307
|
+
if (!fs.existsSync(LICENSE_PATH)) return '';
|
|
308
|
+
try {
|
|
309
|
+
const raw = fs.readFileSync(LICENSE_PATH, 'utf-8');
|
|
310
|
+
const parsed = JSON.parse(raw) as { token?: unknown; jti?: unknown };
|
|
311
|
+
if (typeof parsed.token === 'string' && parsed.token.trim()) return parsed.token.trim();
|
|
312
|
+
if (typeof parsed.jti === 'string' && parsed.jti.trim()) return parsed.jti.trim();
|
|
313
|
+
} catch {
|
|
314
|
+
return '';
|
|
315
|
+
}
|
|
316
|
+
return '';
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function readTrimmedFile(filePath: string): string {
|
|
320
|
+
if (!fs.existsSync(filePath)) return '';
|
|
321
|
+
try {
|
|
322
|
+
return fs.readFileSync(filePath, 'utf-8').trim();
|
|
323
|
+
} catch {
|
|
324
|
+
return '';
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function deriveTotalTokens(promptTokens?: number, completionTokens?: number): number | undefined {
|
|
329
|
+
if (promptTokens === undefined && completionTokens === undefined) return undefined;
|
|
330
|
+
return (promptTokens ?? 0) + (completionTokens ?? 0);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function formatQualityScore(value: number): string {
|
|
334
|
+
if (value <= 1) {
|
|
335
|
+
return `${Math.round(value * 100)}%`;
|
|
336
|
+
}
|
|
337
|
+
return `${Math.round(value)}`;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function normalizePercent(value: number | undefined): number | undefined {
|
|
341
|
+
if (value === undefined) return undefined;
|
|
342
|
+
if (value <= 1) return Math.round(value * 100);
|
|
343
|
+
return Math.round(value);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function findNumber(root: unknown, keys: string[]): number | undefined {
|
|
347
|
+
const value = findValue(root, new Set(keys));
|
|
348
|
+
return readNumber(value);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function findString(root: unknown, keys: string[]): string | undefined {
|
|
352
|
+
const value = findValue(root, new Set(keys));
|
|
353
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function findValue(root: unknown, keys: Set<string>, seen = new Set<unknown>()): unknown {
|
|
357
|
+
if (!root || typeof root !== 'object') return undefined;
|
|
358
|
+
if (seen.has(root)) return undefined;
|
|
359
|
+
seen.add(root);
|
|
360
|
+
|
|
361
|
+
if (Array.isArray(root)) {
|
|
362
|
+
for (const item of root) {
|
|
363
|
+
const found = findValue(item, keys, seen);
|
|
364
|
+
if (found !== undefined) return found;
|
|
365
|
+
}
|
|
366
|
+
return undefined;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const record = root as Record<string, unknown>;
|
|
370
|
+
for (const [key, value] of Object.entries(record)) {
|
|
371
|
+
if (keys.has(key)) return value;
|
|
372
|
+
}
|
|
373
|
+
for (const value of Object.values(record)) {
|
|
374
|
+
const found = findValue(value, keys, seen);
|
|
375
|
+
if (found !== undefined) return found;
|
|
376
|
+
}
|
|
377
|
+
return undefined;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function readObject(value: unknown): Record<string, unknown> | undefined {
|
|
381
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return undefined;
|
|
382
|
+
return value as Record<string, unknown>;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function readNumber(value: unknown): number | undefined {
|
|
386
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
387
|
+
if (typeof value === 'string' && value.trim()) {
|
|
388
|
+
const parsed = Number(value);
|
|
389
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
390
|
+
}
|
|
391
|
+
return undefined;
|
|
392
|
+
}
|
package/src/self-update.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// self-update — checks the npm registry for newer @aria_asi/cli versions
|
|
2
|
-
// and
|
|
3
|
-
// their tooling); just informs.
|
|
2
|
+
// and auto-installs them in the background by default.
|
|
4
3
|
//
|
|
5
4
|
// Direction: Hamza 2026-04-26 — "does the package auto update when we
|
|
6
5
|
// enhance it on our enhance? so we can continually improve all night using
|
|
7
6
|
// arias background work we should imrpove to do that once we finish".
|
|
8
7
|
// This is the primitive that closes the overnight-improvement loop:
|
|
9
8
|
// Aria publishes 0.2.5 / 0.3.0 / etc.; clients see the notice on their
|
|
10
|
-
// next `aria <cmd>` invocation;
|
|
9
|
+
// next `aria <cmd>` invocation; Aria upgrades itself in the background.
|
|
11
10
|
//
|
|
12
11
|
// Doctrine bindings:
|
|
13
12
|
// - feedback_no_demos.md — real overnight evolution, real registry check
|
|
@@ -22,21 +21,30 @@
|
|
|
22
21
|
// - Reads ~/.aria/last-update-check timestamp; if checked <24h ago, skip
|
|
23
22
|
// - GET registry.npmjs.org/@aria_asi/cli for latest dist-tag
|
|
24
23
|
// - semver-compare; if newer, return {updateAvailable: true, latest, current, message}
|
|
24
|
+
// - Launches npm install -g @aria_asi/cli@latest in the background
|
|
25
|
+
// unless ARIA_SELF_UPDATE_MODE=notify|off
|
|
26
|
+
// - Tracks per-version attempts so it doesn't thrash on every invocation
|
|
25
27
|
// - Write timestamp on every check (success or skip-due-to-rate-limit)
|
|
26
28
|
// - Failures are silent (network down, registry blip — never block CLI startup)
|
|
27
29
|
//
|
|
28
30
|
// Privacy: the request to npmjs only sends User-Agent (npm registry public).
|
|
29
31
|
// No client identity, no telemetry beyond what the public registry already logs.
|
|
30
32
|
|
|
31
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
|
|
33
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, openSync } from 'node:fs';
|
|
34
|
+
import { spawn } from 'node:child_process';
|
|
32
35
|
import { homedir } from 'node:os';
|
|
33
36
|
import { join, dirname, resolve } from 'node:path';
|
|
34
37
|
import { fileURLToPath } from 'node:url';
|
|
35
38
|
|
|
36
39
|
const ARIA_DIR = join(homedir(), '.aria');
|
|
37
40
|
const LAST_CHECK_PATH = join(ARIA_DIR, 'last-update-check');
|
|
41
|
+
const AUTO_UPDATE_STATE_PATH = join(ARIA_DIR, 'self-update-state.json');
|
|
42
|
+
const AUTO_UPDATE_LOG_PATH = join(ARIA_DIR, 'self-update.log');
|
|
38
43
|
const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000; // 24h
|
|
44
|
+
const AUTO_UPDATE_RETRY_MS = 6 * 60 * 60 * 1000; // 6h
|
|
39
45
|
const REGISTRY_URL = 'https://registry.npmjs.org/@aria_asi%2Fcli';
|
|
46
|
+
const PACKAGE_NAME = '@aria_asi/cli';
|
|
47
|
+
const AUTO_UPDATE_MODE = (process.env.ARIA_SELF_UPDATE_MODE || 'auto').toLowerCase();
|
|
40
48
|
|
|
41
49
|
export interface UpdateCheckResult {
|
|
42
50
|
ok: boolean;
|
|
@@ -47,6 +55,11 @@ export interface UpdateCheckResult {
|
|
|
47
55
|
reason?: string;
|
|
48
56
|
}
|
|
49
57
|
|
|
58
|
+
interface AutoUpdateState {
|
|
59
|
+
lastAttemptVersion?: string;
|
|
60
|
+
lastAttemptAt?: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
50
63
|
/**
|
|
51
64
|
* Find the package's own version by walking up from this file's runtime
|
|
52
65
|
* path until we hit the package.json with name @aria_asi/cli.
|
|
@@ -94,6 +107,69 @@ function compareSemver(a: string, b: string): number {
|
|
|
94
107
|
return pa.pre.localeCompare(pb.pre);
|
|
95
108
|
}
|
|
96
109
|
|
|
110
|
+
function loadAutoUpdateState(): AutoUpdateState {
|
|
111
|
+
try {
|
|
112
|
+
if (!existsSync(AUTO_UPDATE_STATE_PATH)) return {};
|
|
113
|
+
return JSON.parse(readFileSync(AUTO_UPDATE_STATE_PATH, 'utf-8')) as AutoUpdateState;
|
|
114
|
+
} catch {
|
|
115
|
+
return {};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function saveAutoUpdateState(state: AutoUpdateState): void {
|
|
120
|
+
try {
|
|
121
|
+
if (!existsSync(ARIA_DIR)) mkdirSync(ARIA_DIR, { recursive: true, mode: 0o700 });
|
|
122
|
+
writeFileSync(AUTO_UPDATE_STATE_PATH, JSON.stringify(state, null, 2) + '\n', { mode: 0o600 });
|
|
123
|
+
} catch {
|
|
124
|
+
// best effort only
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function canRetryVersion(latest: string): boolean {
|
|
129
|
+
const state = loadAutoUpdateState();
|
|
130
|
+
if (state.lastAttemptVersion !== latest) return true;
|
|
131
|
+
if (!state.lastAttemptAt) return true;
|
|
132
|
+
return Date.now() - state.lastAttemptAt >= AUTO_UPDATE_RETRY_MS;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function launchAutoInstall(latest: string): { started: boolean; reason?: string } {
|
|
136
|
+
if (AUTO_UPDATE_MODE === 'off') {
|
|
137
|
+
return { started: false, reason: 'self-update disabled' };
|
|
138
|
+
}
|
|
139
|
+
if (AUTO_UPDATE_MODE === 'notify') {
|
|
140
|
+
return { started: false, reason: 'notify-only mode' };
|
|
141
|
+
}
|
|
142
|
+
if (!canRetryVersion(latest)) {
|
|
143
|
+
return { started: false, reason: 'recent attempt already made' };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
if (!existsSync(ARIA_DIR)) mkdirSync(ARIA_DIR, { recursive: true, mode: 0o700 });
|
|
148
|
+
const logFd = openSync(AUTO_UPDATE_LOG_PATH, 'a', 0o600);
|
|
149
|
+
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
150
|
+
const child = spawn(
|
|
151
|
+
npmCmd,
|
|
152
|
+
['install', '-g', `${PACKAGE_NAME}@${latest}`],
|
|
153
|
+
{
|
|
154
|
+
detached: true,
|
|
155
|
+
stdio: ['ignore', logFd, logFd],
|
|
156
|
+
env: process.env,
|
|
157
|
+
},
|
|
158
|
+
);
|
|
159
|
+
child.unref();
|
|
160
|
+
saveAutoUpdateState({
|
|
161
|
+
lastAttemptVersion: latest,
|
|
162
|
+
lastAttemptAt: Date.now(),
|
|
163
|
+
});
|
|
164
|
+
return { started: true };
|
|
165
|
+
} catch (error) {
|
|
166
|
+
return {
|
|
167
|
+
started: false,
|
|
168
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
97
173
|
/**
|
|
98
174
|
* Check the registry for the latest @aria_asi/cli version. Rate-limited
|
|
99
175
|
* to once per CHECK_INTERVAL_MS (24h) via a timestamp file in ~/.aria.
|
|
@@ -150,20 +226,25 @@ export async function checkForUpdate(opts: { force?: boolean } = {}): Promise<Up
|
|
|
150
226
|
current,
|
|
151
227
|
latest,
|
|
152
228
|
updateAvailable: true,
|
|
153
|
-
message: `I have an update: v${latest} (you're on v${current})
|
|
229
|
+
message: `I have an update: v${latest} (you're on v${current}).`,
|
|
154
230
|
};
|
|
155
231
|
}
|
|
156
232
|
|
|
157
233
|
/**
|
|
158
|
-
* Convenience: check +
|
|
234
|
+
* Convenience: check + auto-install if available. Falls back to notice-only
|
|
235
|
+
* when auto-upgrade is disabled or can't be launched. Non-blocking, silent
|
|
159
236
|
* on errors. Called from bin/aria.js on startup.
|
|
160
237
|
*/
|
|
161
238
|
export async function maybePrintUpdateNotice(): Promise<void> {
|
|
162
239
|
try {
|
|
163
240
|
const result = await checkForUpdate();
|
|
164
241
|
if (result.ok && result.updateAvailable && result.message) {
|
|
165
|
-
|
|
166
|
-
|
|
242
|
+
const autoInstall = result.latest ? launchAutoInstall(result.latest) : { started: false, reason: 'missing latest version' };
|
|
243
|
+
if (autoInstall.started) {
|
|
244
|
+
process.stderr.write(` ${result.message} Updating in the background now.\n`);
|
|
245
|
+
} else {
|
|
246
|
+
process.stderr.write(` ${result.message} Run 'npm install -g ${PACKAGE_NAME}@latest' if you want it immediately.\n`);
|
|
247
|
+
}
|
|
167
248
|
}
|
|
168
249
|
} catch {/* never block startup */}
|
|
169
250
|
}
|
package/src/setup-wizard.ts
CHANGED
|
@@ -22,8 +22,14 @@ import { loadConfig, updateConfig, type AriaConfig, type LinkedRepo } from './co
|
|
|
22
22
|
import { scanCodebase, schemaImageToText } from './codebase-scanner.js';
|
|
23
23
|
import { updatePersona } from './persona.js';
|
|
24
24
|
import { connectClaudeCode } from './connectors/claude-code.js';
|
|
25
|
+
import { connectCodex } from './connectors/codex.js';
|
|
26
|
+
import { connectGitHub, getGitHubStatus } from './github-connect.js';
|
|
25
27
|
|
|
26
|
-
const HARNESS_URL =
|
|
28
|
+
const HARNESS_URL =
|
|
29
|
+
process.env.ARIA_HIVE_RUNTIME_URL ||
|
|
30
|
+
process.env.ARIA_HARNESS_BASE_URL ||
|
|
31
|
+
process.env.ARIA_HARNESS_URL ||
|
|
32
|
+
'https://harness.ariasos.com';
|
|
27
33
|
const HARNESS_TOKEN = process.env.ARIA_HARNESS_TOKEN || '';
|
|
28
34
|
const ARIA_DIR = join(homedir(), '.aria');
|
|
29
35
|
const LICENSE_PATH = join(ARIA_DIR, 'license.json');
|
|
@@ -98,6 +104,8 @@ export async function runSetupWizard(): Promise<void> {
|
|
|
98
104
|
if (!userMessage) userMessage = resp.depthOptions[0]?.signal ?? 'next';
|
|
99
105
|
}
|
|
100
106
|
|
|
107
|
+
await maybeOfferGitHubConnect(ask);
|
|
108
|
+
|
|
101
109
|
console.log('\n✅ Setup complete. Run `aria status` anytime.\n');
|
|
102
110
|
} finally {
|
|
103
111
|
rl.close();
|
|
@@ -134,6 +142,30 @@ async function callConverse(body: {
|
|
|
134
142
|
}
|
|
135
143
|
}
|
|
136
144
|
|
|
145
|
+
async function maybeOfferGitHubConnect(ask: (q: string) => Promise<string>): Promise<void> {
|
|
146
|
+
const status = getGitHubStatus();
|
|
147
|
+
if (!status.ghInstalled || status.authenticated) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const raw = (await ask('\nOptional: connect GitHub now for repo workflows and private package access? [y/N] ')).trim().toLowerCase();
|
|
152
|
+
if (raw !== 'y' && raw !== 'yes') {
|
|
153
|
+
console.log(' skipping GitHub for now — you can run `aria github connect` later.');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
const result = connectGitHub({ interactive: true });
|
|
159
|
+
if (!result.ok) {
|
|
160
|
+
console.warn(` ⚠ GitHub connect did not complete: ${result.error || 'unknown error'}`);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
for (const line of result.logs) console.log(` ${line}`);
|
|
164
|
+
} catch (err) {
|
|
165
|
+
console.warn(` ⚠ GitHub connect hit an error: ${err instanceof Error ? err.message : String(err)}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
137
169
|
async function applyConfigWrites(writes: ConfigWrite[]): Promise<void> {
|
|
138
170
|
for (const w of writes) {
|
|
139
171
|
try {
|
|
@@ -218,7 +250,10 @@ async function applyConfigWrites(writes: ConfigWrite[]): Promise<void> {
|
|
|
218
250
|
// canonical connector entry point.
|
|
219
251
|
try {
|
|
220
252
|
const config = loadConfig();
|
|
221
|
-
const logs =
|
|
253
|
+
const logs = [
|
|
254
|
+
...(await connectClaudeCode(config, { force: w.force === true })),
|
|
255
|
+
...(await connectCodex(config)),
|
|
256
|
+
];
|
|
222
257
|
for (const line of logs) console.log(` ${line}`);
|
|
223
258
|
} catch (err) {
|
|
224
259
|
console.warn(` ⚠ Gate install hit an error: ${err instanceof Error ? err.message : String(err)}`);
|