@aria_asi/cli 0.2.37 → 0.2.38
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/dist/aria-connector/src/connectors/codex.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/codex.js +0 -42
- package/dist/aria-connector/src/connectors/codex.js.map +1 -1
- package/dist/assets/hooks/aria-pre-tool-gate.mjs +53 -0
- package/dist/assets/hooks/aria-pre-tool-use.mjs +75 -0
- package/dist/assets/hooks/lib/first-class-coach.mjs +3 -3
- package/dist/runtime/coach-kernel.mjs +8 -2
- package/dist/runtime/hooks/aria-pre-tool-gate.mjs +53 -0
- package/dist/runtime/hooks/aria-pre-tool-use.mjs +75 -0
- package/dist/runtime/hooks/lib/first-class-coach.mjs +3 -3
- package/dist/runtime/manifest.json +1 -1
- package/dist/runtime/sdk/BUNDLED.json +1 -1
- package/dist/sdk/BUNDLED.json +1 -1
- package/hooks/aria-pre-tool-gate.mjs +53 -0
- package/hooks/aria-pre-tool-use.mjs +75 -0
- package/hooks/lib/first-class-coach.mjs +3 -3
- package/package.json +1 -1
- package/runtime-src/coach-kernel.mjs +8 -2
- package/src/connectors/codex.ts +0 -42
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../../src/connectors/codex.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../../src/connectors/codex.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAioC/C,wBAAsB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAkBxE"}
|
|
@@ -500,7 +500,6 @@ try {
|
|
|
500
500
|
function buildCodexPreToolHook() {
|
|
501
501
|
return `#!/usr/bin/env node
|
|
502
502
|
import {
|
|
503
|
-
getHarnessClient,
|
|
504
503
|
inferSessionId,
|
|
505
504
|
classifyAction,
|
|
506
505
|
summarizeTarget,
|
|
@@ -509,14 +508,11 @@ import {
|
|
|
509
508
|
makeEvidenceRef,
|
|
510
509
|
recordCoachPhase,
|
|
511
510
|
saveTurnState,
|
|
512
|
-
runGovernanceGate,
|
|
513
|
-
updateTaskProjectLedger,
|
|
514
511
|
formatCodexRecoveryBlock,
|
|
515
512
|
emitJson,
|
|
516
513
|
} from './lib/runtime-client.mjs';
|
|
517
514
|
|
|
518
515
|
const event = readEventFromStdin();
|
|
519
|
-
const client = getHarnessClient();
|
|
520
516
|
const sessionId = inferSessionId(event);
|
|
521
517
|
const action = classifyAction(event);
|
|
522
518
|
const target = summarizeTarget(event);
|
|
@@ -554,35 +550,6 @@ try {
|
|
|
554
550
|
}),
|
|
555
551
|
});
|
|
556
552
|
}
|
|
557
|
-
const actionCheck = await client.checkAction(action, target);
|
|
558
|
-
if (actionCheck?.allowed === false) {
|
|
559
|
-
emitJson({
|
|
560
|
-
decision: 'block',
|
|
561
|
-
reason: formatCodexRecoveryBlock({
|
|
562
|
-
surface: 'codex-pre-tool-action',
|
|
563
|
-
reason: actionCheck?.reason || \`Aria denied \${action}\`,
|
|
564
|
-
next: '6. Add the required verification/cognition contract for the action, then request the tool again.',
|
|
565
|
-
}),
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
updateTaskProjectLedger({
|
|
569
|
-
platform: 'codex',
|
|
570
|
-
phase: 'pre_tool',
|
|
571
|
-
source: 'codex-pre-tool-hook',
|
|
572
|
-
event: { ...event, sessionId, cwd: process.cwd() },
|
|
573
|
-
evidence: { action_ref: requestRef },
|
|
574
|
-
});
|
|
575
|
-
runGovernanceGate({
|
|
576
|
-
sessionId,
|
|
577
|
-
sourceRuntime: 'codex',
|
|
578
|
-
surface: 'codex-pre-tool-use',
|
|
579
|
-
text: JSON.stringify(event).slice(0, 8000),
|
|
580
|
-
action,
|
|
581
|
-
toolName,
|
|
582
|
-
isDeploy: action === 'deploy',
|
|
583
|
-
isMutation: action === 'write' || action === 'delete',
|
|
584
|
-
evidence: requestRef,
|
|
585
|
-
});
|
|
586
553
|
const tools = Array.isArray(state?.tools) ? state.tools.slice(-24) : [];
|
|
587
554
|
tools.push({
|
|
588
555
|
at: new Date().toISOString(),
|
|
@@ -685,7 +652,6 @@ import {
|
|
|
685
652
|
formatValidationFailure,
|
|
686
653
|
formatCodexRecoveryBlock,
|
|
687
654
|
isAriaControlBlock,
|
|
688
|
-
runGovernanceGate,
|
|
689
655
|
updateTaskProjectLedger,
|
|
690
656
|
evaluateTaskProjectClaim,
|
|
691
657
|
recordBlockedTaskProjectClaim,
|
|
@@ -750,14 +716,6 @@ try {
|
|
|
750
716
|
}),
|
|
751
717
|
});
|
|
752
718
|
}
|
|
753
|
-
runGovernanceGate({
|
|
754
|
-
sessionId,
|
|
755
|
-
sourceRuntime: 'codex',
|
|
756
|
-
surface: 'codex-stop',
|
|
757
|
-
text: text.slice(0, 8000),
|
|
758
|
-
isOutputCloseout: true,
|
|
759
|
-
evidence: outputRef,
|
|
760
|
-
});
|
|
761
719
|
const validation = await runtimePost('/validate-output', {
|
|
762
720
|
text,
|
|
763
721
|
sessionId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../../../src/connectors/codex.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAE9H,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,aAAa,EACb,YAAY,GACb,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,0B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jE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAkB;IACnD,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;IAEhD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,CAAC,WAAW,QAAQ,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC3B,kBAAkB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACnC,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACxC,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACrC,iBAAiB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAClC,0BAA0B,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC3C,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1068,6 +1068,59 @@ if (emergencyGateOff.off) {
|
|
|
1068
1068
|
|
|
1069
1069
|
const toolName = event.tool_name ?? event.toolName ?? '';
|
|
1070
1070
|
const toolInput = event.tool_input ?? event.toolInput ?? {};
|
|
1071
|
+
|
|
1072
|
+
// Coach Kernel routing — single source of truth, run before all hook-native checks.
|
|
1073
|
+
try {
|
|
1074
|
+
const _coachUrl = `${HOME}/.aria/runtime/runtime.env`;
|
|
1075
|
+
const _coachBase = existsSync(_coachUrl)
|
|
1076
|
+
? String(readFileSync(_coachUrl, 'utf8')).match(/ARIA_RUNTIME_URL=(http:\/\/[^ \n]+)/)?.[1] || 'http://127.0.0.1:4319'
|
|
1077
|
+
: 'http://127.0.0.1:4319';
|
|
1078
|
+
const _coachToken = (() => {
|
|
1079
|
+
const tp = `${HOME}/.aria/owner-token`;
|
|
1080
|
+
if (existsSync(tp)) return readFileSync(tp, 'utf8').trim();
|
|
1081
|
+
const lp = `${HOME}/.aria/license.json`;
|
|
1082
|
+
if (existsSync(lp)) {
|
|
1083
|
+
try { const lt = JSON.parse(readFileSync(lp, 'utf8')); return lt.token || lt.harnessToken || ''; } catch { return ''; }
|
|
1084
|
+
}
|
|
1085
|
+
return process.env.ARIA_API_KEY || process.env.ARIA_MASTER_TOKEN || '';
|
|
1086
|
+
})();
|
|
1087
|
+
const _coachHeaders = { 'Content-Type': 'application/json' };
|
|
1088
|
+
if (_coachToken) _coachHeaders.Authorization = `Bearer ${_coachToken}`;
|
|
1089
|
+
const _cmd = String(toolInput?.command || '');
|
|
1090
|
+
const _coachPayload = {
|
|
1091
|
+
phase: 'pre_tool',
|
|
1092
|
+
requestId: `claude-pre-tool:${Date.now()}`,
|
|
1093
|
+
sessionId: String(toolInput?.session_id || process.env.HOOK_SESSION_ID || 'claude-unknown').slice(0, 80),
|
|
1094
|
+
surface: 'claude-hooks',
|
|
1095
|
+
lane: 'claude_native_hooks',
|
|
1096
|
+
action: (() => {
|
|
1097
|
+
const t = _cmd.toLowerCase();
|
|
1098
|
+
if (/\b(?:kubectl\s+(?:apply|set|rollout|delete|create|replace|scale)|helm\s+(?:upgrade|install|uninstall)|terraform\s+(?:apply|destroy)|docker\s+(?:push|build\s+.*--push)|deploy)\b/i.test(t)) return 'deploy';
|
|
1099
|
+
if (/\b(?:rm\s+-[rRfF]+\S*|sudo\s+|systemctl\s+(?:stop|disable|mask|kill)|kill\s+-[9K]|pkill\s+-[9K]|chmod\s+777|git\s+(?:push\s+--force|reset\s+--hard)|docker\s+rm\s+-f)\b/i.test(t)) return 'delete';
|
|
1100
|
+
return '';
|
|
1101
|
+
})(),
|
|
1102
|
+
target: JSON.stringify(toolInput).slice(0, 2000),
|
|
1103
|
+
text: _cmd.slice(0, 1000),
|
|
1104
|
+
metadata: { source: 'claude-pre-tool-gate', toolName },
|
|
1105
|
+
};
|
|
1106
|
+
const _coachResp = await fetch(`${_coachBase}/coach/phase`, {
|
|
1107
|
+
method: 'POST', headers: _coachHeaders, body: JSON.stringify(_coachPayload),
|
|
1108
|
+
signal: AbortSignal.timeout(2000),
|
|
1109
|
+
});
|
|
1110
|
+
if (_coachResp.ok) {
|
|
1111
|
+
const _coachBody = await _coachResp.json();
|
|
1112
|
+
if (_coachBody?.permitted === false && _coachBody?.decision === 'hard_block') {
|
|
1113
|
+
audit('block-coach-authoritative', `reasons=${(_coachBody.reasons||[]).join(',')}`);
|
|
1114
|
+
console.log(JSON.stringify({
|
|
1115
|
+
decision: 'block',
|
|
1116
|
+
reason: ['Aria Coach blocked this action before execution.', '', `Reason: ${(_coachBody.reasons||['coach_policy']).slice(0,3).join('; ')}`, '', _coachBody.clientMessage || 'Remove the high-risk condition and retry.'].join('\n'),
|
|
1117
|
+
hookSpecificOutput: { hookEventName: 'PreToolUse', coach_decision: _coachBody.decision, coach_reasons: _coachBody.reasons },
|
|
1118
|
+
}));
|
|
1119
|
+
process.exit(2);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
} catch { /* Coach unreachable — fall through to hook-native checks */ }
|
|
1123
|
+
|
|
1071
1124
|
const transcriptPath = event.transcript_path ?? event.transcriptPath;
|
|
1072
1125
|
|
|
1073
1126
|
// Gate every action tool — every tool that mutates state must go through
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getHarnessClient,
|
|
4
|
+
inferSessionId,
|
|
5
|
+
classifyAction,
|
|
6
|
+
summarizeTarget,
|
|
7
|
+
readEventFromStdin,
|
|
8
|
+
loadTurnState,
|
|
9
|
+
makeEvidenceRef,
|
|
10
|
+
recordCoachPhase,
|
|
11
|
+
saveTurnState,
|
|
12
|
+
formatCodexRecoveryBlock,
|
|
13
|
+
emitJson,
|
|
14
|
+
} from './lib/runtime-client.mjs';
|
|
15
|
+
|
|
16
|
+
const event = readEventFromStdin();
|
|
17
|
+
const sessionId = inferSessionId(event);
|
|
18
|
+
const action = classifyAction(event);
|
|
19
|
+
const target = summarizeTarget(event);
|
|
20
|
+
const state = loadTurnState(sessionId);
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
if (!state?.preReceiptId && !state?.userText) {
|
|
24
|
+
emitJson({
|
|
25
|
+
decision: 'block',
|
|
26
|
+
reason: formatCodexRecoveryBlock({
|
|
27
|
+
surface: 'codex-pre-tool',
|
|
28
|
+
reason: 'this turn has no pre-turn Mizan receipt',
|
|
29
|
+
next: '6. Re-submit the prompt so cognition is established before tool use, then request the tool again.',
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const toolName = String(event?.tool_name || event?.toolName || '').trim() || null;
|
|
34
|
+
const requestRef = makeEvidenceRef('codex_tool_request', { action, toolName, target }, { sessionId });
|
|
35
|
+
const coach = await recordCoachPhase('pre_tool', {
|
|
36
|
+
requestId: state?.traceId || sessionId,
|
|
37
|
+
sessionId,
|
|
38
|
+
text: target,
|
|
39
|
+
action,
|
|
40
|
+
target,
|
|
41
|
+
evidenceRefs: [requestRef],
|
|
42
|
+
metadata: { source: 'codex-pre-tool-hook', toolName, requireVerify: action === 'deploy' || action === 'delete' },
|
|
43
|
+
});
|
|
44
|
+
if (coach?.permitted === false) {
|
|
45
|
+
emitJson({
|
|
46
|
+
decision: 'block',
|
|
47
|
+
reason: formatCodexRecoveryBlock({
|
|
48
|
+
surface: 'codex-pre-tool-coach',
|
|
49
|
+
reason: coach.clientMessage || 'Coach Kernel denied ' + action,
|
|
50
|
+
next: '6. Add the required evidence/cognition contract, then request the tool again.',
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const tools = Array.isArray(state?.tools) ? state.tools.slice(-24) : [];
|
|
55
|
+
tools.push({
|
|
56
|
+
at: new Date().toISOString(),
|
|
57
|
+
action,
|
|
58
|
+
toolName,
|
|
59
|
+
target,
|
|
60
|
+
evidenceRef: makeEvidenceRef('tool_request', { action, toolName, target }, { sessionId }),
|
|
61
|
+
});
|
|
62
|
+
saveTurnState(sessionId, {
|
|
63
|
+
tools,
|
|
64
|
+
lastEvent: 'PreToolUse',
|
|
65
|
+
});
|
|
66
|
+
process.exit(0);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
emitJson({
|
|
69
|
+
decision: 'block',
|
|
70
|
+
reason: formatCodexRecoveryBlock({
|
|
71
|
+
surface: 'codex-pre-tool-hook',
|
|
72
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -243,10 +243,10 @@ function summarizeRuntimeToolTarget(event = {}) {
|
|
|
243
243
|
|
|
244
244
|
function inferRuntimeAction(event = {}, phase = '') {
|
|
245
245
|
const haystack = `${phase}\n${summarizeRuntimeToolTarget(event)}\n${stableJson(event).slice(0, 6000)}`;
|
|
246
|
-
if (/\b(?:kubectl\s+(?:apply|set|rollout|delete)|helm\s+upgrade|terraform\s+apply|docker\s+push|deploy)\b/i.test(haystack)) return 'deploy';
|
|
247
|
-
if (/\b(?:rm\s+-[rRfF]
|
|
246
|
+
if (/\b(?:kubectl\s+(?:apply|set|rollout|delete|create|replace|scale)|helm\s+(?:upgrade|install|uninstall)|terraform\s+(?:apply|destroy)|docker\s+(?:push|build\s+.*--push)|deploy)\b/i.test(haystack)) return 'deploy';
|
|
247
|
+
if (/\b(?:rm\s+-[rRfF]+\S*|drop\s+(?:table|database|schema|collection|index)|git\s+(?:reset\s+--hard|push\s+--force|push\s+--delete)|sudo\s+|systemctl\s+(?:stop|disable|mask|kill)|kill\s+-[9K]|pkill\s+-[9K]|chmod\s+777|docker\s+rm\s+-f)\b/i.test(haystack)) return 'delete';
|
|
248
|
+
if (/\b(?:--no-verify|--no-gpg-sign)\b/i.test(haystack)) return 'delete';
|
|
248
249
|
if (phase === 'stop' || phase === 'pre_emit') return 'release';
|
|
249
|
-
if (phase === 'pre_tool' || phase === 'post_tool') return 'write';
|
|
250
250
|
return '';
|
|
251
251
|
}
|
|
252
252
|
|
|
@@ -192,6 +192,9 @@ export function normalizeCoachEvent(input = {}) {
|
|
|
192
192
|
return record;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
const DESTRUCTIVE_RX = /\b(?:rm\s+-[rRfF]+\S*|drop\s+(?:table|database|schema|collection|index)|git\s+(?:reset\s+--hard|push\s+--force|push\s+--delete)|sudo\s+|systemctl\s+(?:stop|disable|mask|kill)|kill\s+-[9K]|pkill\s+-[9K]|--no-verify|--no-gpg-sign|kubectl\s+(?:delete|scale\s+--replicas=0|rollout\s+undo)|docker\s+rm\s+-f|chmod\s+777|wget|curl.*\|\s*(?:ba)?sh)\b/i;
|
|
196
|
+
const DEPLOY_RX = /\b(?:kubectl\s+(?:apply|set|rollout|delete|create|replace|scale)|helm\s+(?:upgrade|install|uninstall)|terraform\s+(?:apply|destroy)|docker\s+(?:push|build\s+.*--push))\b/i;
|
|
197
|
+
|
|
195
198
|
export function evaluateCoachEvent(event = {}) {
|
|
196
199
|
const normalized = event.phase ? event : normalizeCoachEvent(event);
|
|
197
200
|
const text = normalized.rawText || normalized.text_preview || '';
|
|
@@ -210,10 +213,10 @@ export function evaluateCoachEvent(event = {}) {
|
|
|
210
213
|
highRisk.push('required_skill_unavailable_before_generation');
|
|
211
214
|
}
|
|
212
215
|
if (TOOL_PHASES.has(normalized.phase) || action) {
|
|
213
|
-
if ((action === 'delete' ||
|
|
216
|
+
if ((action === 'delete' || DESTRUCTIVE_RX.test(text)) && normalized.metadata?.approved !== true) {
|
|
214
217
|
highRisk.push('unapproved_destructive_action');
|
|
215
218
|
}
|
|
216
|
-
if ((action === 'deploy' ||
|
|
219
|
+
if ((action === 'deploy' || DEPLOY_RX.test(text)) && !hasVerifyEvidence(normalized, text)) {
|
|
217
220
|
highRisk.push('unverified_deploy_or_infra_mutation');
|
|
218
221
|
}
|
|
219
222
|
}
|
|
@@ -229,6 +232,9 @@ export function evaluateCoachEvent(event = {}) {
|
|
|
229
232
|
repairable.push('unsupported_completion_or_verification_claim');
|
|
230
233
|
}
|
|
231
234
|
}
|
|
235
|
+
if (normalized.missing_skill_ids.length > 0 && !normalized.metadata?.skillsAdvisoryOnly) {
|
|
236
|
+
repairable.push('required_skills_not_loaded');
|
|
237
|
+
}
|
|
232
238
|
if (normalized.lane.includes('unmanaged') || normalized.metadata?.complianceGuarantee === 'best_effort_only') {
|
|
233
239
|
warnings.push('unmanaged_direct_provider_best_effort_only');
|
|
234
240
|
}
|
|
@@ -1068,6 +1068,59 @@ if (emergencyGateOff.off) {
|
|
|
1068
1068
|
|
|
1069
1069
|
const toolName = event.tool_name ?? event.toolName ?? '';
|
|
1070
1070
|
const toolInput = event.tool_input ?? event.toolInput ?? {};
|
|
1071
|
+
|
|
1072
|
+
// Coach Kernel routing — single source of truth, run before all hook-native checks.
|
|
1073
|
+
try {
|
|
1074
|
+
const _coachUrl = `${HOME}/.aria/runtime/runtime.env`;
|
|
1075
|
+
const _coachBase = existsSync(_coachUrl)
|
|
1076
|
+
? String(readFileSync(_coachUrl, 'utf8')).match(/ARIA_RUNTIME_URL=(http:\/\/[^ \n]+)/)?.[1] || 'http://127.0.0.1:4319'
|
|
1077
|
+
: 'http://127.0.0.1:4319';
|
|
1078
|
+
const _coachToken = (() => {
|
|
1079
|
+
const tp = `${HOME}/.aria/owner-token`;
|
|
1080
|
+
if (existsSync(tp)) return readFileSync(tp, 'utf8').trim();
|
|
1081
|
+
const lp = `${HOME}/.aria/license.json`;
|
|
1082
|
+
if (existsSync(lp)) {
|
|
1083
|
+
try { const lt = JSON.parse(readFileSync(lp, 'utf8')); return lt.token || lt.harnessToken || ''; } catch { return ''; }
|
|
1084
|
+
}
|
|
1085
|
+
return process.env.ARIA_API_KEY || process.env.ARIA_MASTER_TOKEN || '';
|
|
1086
|
+
})();
|
|
1087
|
+
const _coachHeaders = { 'Content-Type': 'application/json' };
|
|
1088
|
+
if (_coachToken) _coachHeaders.Authorization = `Bearer ${_coachToken}`;
|
|
1089
|
+
const _cmd = String(toolInput?.command || '');
|
|
1090
|
+
const _coachPayload = {
|
|
1091
|
+
phase: 'pre_tool',
|
|
1092
|
+
requestId: `claude-pre-tool:${Date.now()}`,
|
|
1093
|
+
sessionId: String(toolInput?.session_id || process.env.HOOK_SESSION_ID || 'claude-unknown').slice(0, 80),
|
|
1094
|
+
surface: 'claude-hooks',
|
|
1095
|
+
lane: 'claude_native_hooks',
|
|
1096
|
+
action: (() => {
|
|
1097
|
+
const t = _cmd.toLowerCase();
|
|
1098
|
+
if (/\b(?:kubectl\s+(?:apply|set|rollout|delete|create|replace|scale)|helm\s+(?:upgrade|install|uninstall)|terraform\s+(?:apply|destroy)|docker\s+(?:push|build\s+.*--push)|deploy)\b/i.test(t)) return 'deploy';
|
|
1099
|
+
if (/\b(?:rm\s+-[rRfF]+\S*|sudo\s+|systemctl\s+(?:stop|disable|mask|kill)|kill\s+-[9K]|pkill\s+-[9K]|chmod\s+777|git\s+(?:push\s+--force|reset\s+--hard)|docker\s+rm\s+-f)\b/i.test(t)) return 'delete';
|
|
1100
|
+
return '';
|
|
1101
|
+
})(),
|
|
1102
|
+
target: JSON.stringify(toolInput).slice(0, 2000),
|
|
1103
|
+
text: _cmd.slice(0, 1000),
|
|
1104
|
+
metadata: { source: 'claude-pre-tool-gate', toolName },
|
|
1105
|
+
};
|
|
1106
|
+
const _coachResp = await fetch(`${_coachBase}/coach/phase`, {
|
|
1107
|
+
method: 'POST', headers: _coachHeaders, body: JSON.stringify(_coachPayload),
|
|
1108
|
+
signal: AbortSignal.timeout(2000),
|
|
1109
|
+
});
|
|
1110
|
+
if (_coachResp.ok) {
|
|
1111
|
+
const _coachBody = await _coachResp.json();
|
|
1112
|
+
if (_coachBody?.permitted === false && _coachBody?.decision === 'hard_block') {
|
|
1113
|
+
audit('block-coach-authoritative', `reasons=${(_coachBody.reasons||[]).join(',')}`);
|
|
1114
|
+
console.log(JSON.stringify({
|
|
1115
|
+
decision: 'block',
|
|
1116
|
+
reason: ['Aria Coach blocked this action before execution.', '', `Reason: ${(_coachBody.reasons||['coach_policy']).slice(0,3).join('; ')}`, '', _coachBody.clientMessage || 'Remove the high-risk condition and retry.'].join('\n'),
|
|
1117
|
+
hookSpecificOutput: { hookEventName: 'PreToolUse', coach_decision: _coachBody.decision, coach_reasons: _coachBody.reasons },
|
|
1118
|
+
}));
|
|
1119
|
+
process.exit(2);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
} catch { /* Coach unreachable — fall through to hook-native checks */ }
|
|
1123
|
+
|
|
1071
1124
|
const transcriptPath = event.transcript_path ?? event.transcriptPath;
|
|
1072
1125
|
|
|
1073
1126
|
// Gate every action tool — every tool that mutates state must go through
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getHarnessClient,
|
|
4
|
+
inferSessionId,
|
|
5
|
+
classifyAction,
|
|
6
|
+
summarizeTarget,
|
|
7
|
+
readEventFromStdin,
|
|
8
|
+
loadTurnState,
|
|
9
|
+
makeEvidenceRef,
|
|
10
|
+
recordCoachPhase,
|
|
11
|
+
saveTurnState,
|
|
12
|
+
formatCodexRecoveryBlock,
|
|
13
|
+
emitJson,
|
|
14
|
+
} from './lib/runtime-client.mjs';
|
|
15
|
+
|
|
16
|
+
const event = readEventFromStdin();
|
|
17
|
+
const sessionId = inferSessionId(event);
|
|
18
|
+
const action = classifyAction(event);
|
|
19
|
+
const target = summarizeTarget(event);
|
|
20
|
+
const state = loadTurnState(sessionId);
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
if (!state?.preReceiptId && !state?.userText) {
|
|
24
|
+
emitJson({
|
|
25
|
+
decision: 'block',
|
|
26
|
+
reason: formatCodexRecoveryBlock({
|
|
27
|
+
surface: 'codex-pre-tool',
|
|
28
|
+
reason: 'this turn has no pre-turn Mizan receipt',
|
|
29
|
+
next: '6. Re-submit the prompt so cognition is established before tool use, then request the tool again.',
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const toolName = String(event?.tool_name || event?.toolName || '').trim() || null;
|
|
34
|
+
const requestRef = makeEvidenceRef('codex_tool_request', { action, toolName, target }, { sessionId });
|
|
35
|
+
const coach = await recordCoachPhase('pre_tool', {
|
|
36
|
+
requestId: state?.traceId || sessionId,
|
|
37
|
+
sessionId,
|
|
38
|
+
text: target,
|
|
39
|
+
action,
|
|
40
|
+
target,
|
|
41
|
+
evidenceRefs: [requestRef],
|
|
42
|
+
metadata: { source: 'codex-pre-tool-hook', toolName, requireVerify: action === 'deploy' || action === 'delete' },
|
|
43
|
+
});
|
|
44
|
+
if (coach?.permitted === false) {
|
|
45
|
+
emitJson({
|
|
46
|
+
decision: 'block',
|
|
47
|
+
reason: formatCodexRecoveryBlock({
|
|
48
|
+
surface: 'codex-pre-tool-coach',
|
|
49
|
+
reason: coach.clientMessage || 'Coach Kernel denied ' + action,
|
|
50
|
+
next: '6. Add the required evidence/cognition contract, then request the tool again.',
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const tools = Array.isArray(state?.tools) ? state.tools.slice(-24) : [];
|
|
55
|
+
tools.push({
|
|
56
|
+
at: new Date().toISOString(),
|
|
57
|
+
action,
|
|
58
|
+
toolName,
|
|
59
|
+
target,
|
|
60
|
+
evidenceRef: makeEvidenceRef('tool_request', { action, toolName, target }, { sessionId }),
|
|
61
|
+
});
|
|
62
|
+
saveTurnState(sessionId, {
|
|
63
|
+
tools,
|
|
64
|
+
lastEvent: 'PreToolUse',
|
|
65
|
+
});
|
|
66
|
+
process.exit(0);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
emitJson({
|
|
69
|
+
decision: 'block',
|
|
70
|
+
reason: formatCodexRecoveryBlock({
|
|
71
|
+
surface: 'codex-pre-tool-hook',
|
|
72
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -243,10 +243,10 @@ function summarizeRuntimeToolTarget(event = {}) {
|
|
|
243
243
|
|
|
244
244
|
function inferRuntimeAction(event = {}, phase = '') {
|
|
245
245
|
const haystack = `${phase}\n${summarizeRuntimeToolTarget(event)}\n${stableJson(event).slice(0, 6000)}`;
|
|
246
|
-
if (/\b(?:kubectl\s+(?:apply|set|rollout|delete)|helm\s+upgrade|terraform\s+apply|docker\s+push|deploy)\b/i.test(haystack)) return 'deploy';
|
|
247
|
-
if (/\b(?:rm\s+-[rRfF]
|
|
246
|
+
if (/\b(?:kubectl\s+(?:apply|set|rollout|delete|create|replace|scale)|helm\s+(?:upgrade|install|uninstall)|terraform\s+(?:apply|destroy)|docker\s+(?:push|build\s+.*--push)|deploy)\b/i.test(haystack)) return 'deploy';
|
|
247
|
+
if (/\b(?:rm\s+-[rRfF]+\S*|drop\s+(?:table|database|schema|collection|index)|git\s+(?:reset\s+--hard|push\s+--force|push\s+--delete)|sudo\s+|systemctl\s+(?:stop|disable|mask|kill)|kill\s+-[9K]|pkill\s+-[9K]|chmod\s+777|docker\s+rm\s+-f)\b/i.test(haystack)) return 'delete';
|
|
248
|
+
if (/\b(?:--no-verify|--no-gpg-sign)\b/i.test(haystack)) return 'delete';
|
|
248
249
|
if (phase === 'stop' || phase === 'pre_emit') return 'release';
|
|
249
|
-
if (phase === 'pre_tool' || phase === 'post_tool') return 'write';
|
|
250
250
|
return '';
|
|
251
251
|
}
|
|
252
252
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundledAt": "2026-05-04T03:
|
|
2
|
+
"bundledAt": "2026-05-04T03:38:32.939Z",
|
|
3
3
|
"sdkFiles": 12,
|
|
4
4
|
"runtimeTemplate": "/home/hamzaibrahim1/rei-ai-brain/packages/aria-connector/runtime-src",
|
|
5
5
|
"gateRuntimeSource": "/home/hamzaibrahim1/rei-ai-brain/packages/aria-gate-runtime/dist",
|
package/dist/sdk/BUNDLED.json
CHANGED
|
@@ -1068,6 +1068,59 @@ if (emergencyGateOff.off) {
|
|
|
1068
1068
|
|
|
1069
1069
|
const toolName = event.tool_name ?? event.toolName ?? '';
|
|
1070
1070
|
const toolInput = event.tool_input ?? event.toolInput ?? {};
|
|
1071
|
+
|
|
1072
|
+
// Coach Kernel routing — single source of truth, run before all hook-native checks.
|
|
1073
|
+
try {
|
|
1074
|
+
const _coachUrl = `${HOME}/.aria/runtime/runtime.env`;
|
|
1075
|
+
const _coachBase = existsSync(_coachUrl)
|
|
1076
|
+
? String(readFileSync(_coachUrl, 'utf8')).match(/ARIA_RUNTIME_URL=(http:\/\/[^ \n]+)/)?.[1] || 'http://127.0.0.1:4319'
|
|
1077
|
+
: 'http://127.0.0.1:4319';
|
|
1078
|
+
const _coachToken = (() => {
|
|
1079
|
+
const tp = `${HOME}/.aria/owner-token`;
|
|
1080
|
+
if (existsSync(tp)) return readFileSync(tp, 'utf8').trim();
|
|
1081
|
+
const lp = `${HOME}/.aria/license.json`;
|
|
1082
|
+
if (existsSync(lp)) {
|
|
1083
|
+
try { const lt = JSON.parse(readFileSync(lp, 'utf8')); return lt.token || lt.harnessToken || ''; } catch { return ''; }
|
|
1084
|
+
}
|
|
1085
|
+
return process.env.ARIA_API_KEY || process.env.ARIA_MASTER_TOKEN || '';
|
|
1086
|
+
})();
|
|
1087
|
+
const _coachHeaders = { 'Content-Type': 'application/json' };
|
|
1088
|
+
if (_coachToken) _coachHeaders.Authorization = `Bearer ${_coachToken}`;
|
|
1089
|
+
const _cmd = String(toolInput?.command || '');
|
|
1090
|
+
const _coachPayload = {
|
|
1091
|
+
phase: 'pre_tool',
|
|
1092
|
+
requestId: `claude-pre-tool:${Date.now()}`,
|
|
1093
|
+
sessionId: String(toolInput?.session_id || process.env.HOOK_SESSION_ID || 'claude-unknown').slice(0, 80),
|
|
1094
|
+
surface: 'claude-hooks',
|
|
1095
|
+
lane: 'claude_native_hooks',
|
|
1096
|
+
action: (() => {
|
|
1097
|
+
const t = _cmd.toLowerCase();
|
|
1098
|
+
if (/\b(?:kubectl\s+(?:apply|set|rollout|delete|create|replace|scale)|helm\s+(?:upgrade|install|uninstall)|terraform\s+(?:apply|destroy)|docker\s+(?:push|build\s+.*--push)|deploy)\b/i.test(t)) return 'deploy';
|
|
1099
|
+
if (/\b(?:rm\s+-[rRfF]+\S*|sudo\s+|systemctl\s+(?:stop|disable|mask|kill)|kill\s+-[9K]|pkill\s+-[9K]|chmod\s+777|git\s+(?:push\s+--force|reset\s+--hard)|docker\s+rm\s+-f)\b/i.test(t)) return 'delete';
|
|
1100
|
+
return '';
|
|
1101
|
+
})(),
|
|
1102
|
+
target: JSON.stringify(toolInput).slice(0, 2000),
|
|
1103
|
+
text: _cmd.slice(0, 1000),
|
|
1104
|
+
metadata: { source: 'claude-pre-tool-gate', toolName },
|
|
1105
|
+
};
|
|
1106
|
+
const _coachResp = await fetch(`${_coachBase}/coach/phase`, {
|
|
1107
|
+
method: 'POST', headers: _coachHeaders, body: JSON.stringify(_coachPayload),
|
|
1108
|
+
signal: AbortSignal.timeout(2000),
|
|
1109
|
+
});
|
|
1110
|
+
if (_coachResp.ok) {
|
|
1111
|
+
const _coachBody = await _coachResp.json();
|
|
1112
|
+
if (_coachBody?.permitted === false && _coachBody?.decision === 'hard_block') {
|
|
1113
|
+
audit('block-coach-authoritative', `reasons=${(_coachBody.reasons||[]).join(',')}`);
|
|
1114
|
+
console.log(JSON.stringify({
|
|
1115
|
+
decision: 'block',
|
|
1116
|
+
reason: ['Aria Coach blocked this action before execution.', '', `Reason: ${(_coachBody.reasons||['coach_policy']).slice(0,3).join('; ')}`, '', _coachBody.clientMessage || 'Remove the high-risk condition and retry.'].join('\n'),
|
|
1117
|
+
hookSpecificOutput: { hookEventName: 'PreToolUse', coach_decision: _coachBody.decision, coach_reasons: _coachBody.reasons },
|
|
1118
|
+
}));
|
|
1119
|
+
process.exit(2);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
} catch { /* Coach unreachable — fall through to hook-native checks */ }
|
|
1123
|
+
|
|
1071
1124
|
const transcriptPath = event.transcript_path ?? event.transcriptPath;
|
|
1072
1125
|
|
|
1073
1126
|
// Gate every action tool — every tool that mutates state must go through
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getHarnessClient,
|
|
4
|
+
inferSessionId,
|
|
5
|
+
classifyAction,
|
|
6
|
+
summarizeTarget,
|
|
7
|
+
readEventFromStdin,
|
|
8
|
+
loadTurnState,
|
|
9
|
+
makeEvidenceRef,
|
|
10
|
+
recordCoachPhase,
|
|
11
|
+
saveTurnState,
|
|
12
|
+
formatCodexRecoveryBlock,
|
|
13
|
+
emitJson,
|
|
14
|
+
} from './lib/runtime-client.mjs';
|
|
15
|
+
|
|
16
|
+
const event = readEventFromStdin();
|
|
17
|
+
const sessionId = inferSessionId(event);
|
|
18
|
+
const action = classifyAction(event);
|
|
19
|
+
const target = summarizeTarget(event);
|
|
20
|
+
const state = loadTurnState(sessionId);
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
if (!state?.preReceiptId && !state?.userText) {
|
|
24
|
+
emitJson({
|
|
25
|
+
decision: 'block',
|
|
26
|
+
reason: formatCodexRecoveryBlock({
|
|
27
|
+
surface: 'codex-pre-tool',
|
|
28
|
+
reason: 'this turn has no pre-turn Mizan receipt',
|
|
29
|
+
next: '6. Re-submit the prompt so cognition is established before tool use, then request the tool again.',
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const toolName = String(event?.tool_name || event?.toolName || '').trim() || null;
|
|
34
|
+
const requestRef = makeEvidenceRef('codex_tool_request', { action, toolName, target }, { sessionId });
|
|
35
|
+
const coach = await recordCoachPhase('pre_tool', {
|
|
36
|
+
requestId: state?.traceId || sessionId,
|
|
37
|
+
sessionId,
|
|
38
|
+
text: target,
|
|
39
|
+
action,
|
|
40
|
+
target,
|
|
41
|
+
evidenceRefs: [requestRef],
|
|
42
|
+
metadata: { source: 'codex-pre-tool-hook', toolName, requireVerify: action === 'deploy' || action === 'delete' },
|
|
43
|
+
});
|
|
44
|
+
if (coach?.permitted === false) {
|
|
45
|
+
emitJson({
|
|
46
|
+
decision: 'block',
|
|
47
|
+
reason: formatCodexRecoveryBlock({
|
|
48
|
+
surface: 'codex-pre-tool-coach',
|
|
49
|
+
reason: coach.clientMessage || 'Coach Kernel denied ' + action,
|
|
50
|
+
next: '6. Add the required evidence/cognition contract, then request the tool again.',
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const tools = Array.isArray(state?.tools) ? state.tools.slice(-24) : [];
|
|
55
|
+
tools.push({
|
|
56
|
+
at: new Date().toISOString(),
|
|
57
|
+
action,
|
|
58
|
+
toolName,
|
|
59
|
+
target,
|
|
60
|
+
evidenceRef: makeEvidenceRef('tool_request', { action, toolName, target }, { sessionId }),
|
|
61
|
+
});
|
|
62
|
+
saveTurnState(sessionId, {
|
|
63
|
+
tools,
|
|
64
|
+
lastEvent: 'PreToolUse',
|
|
65
|
+
});
|
|
66
|
+
process.exit(0);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
emitJson({
|
|
69
|
+
decision: 'block',
|
|
70
|
+
reason: formatCodexRecoveryBlock({
|
|
71
|
+
surface: 'codex-pre-tool-hook',
|
|
72
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -243,10 +243,10 @@ function summarizeRuntimeToolTarget(event = {}) {
|
|
|
243
243
|
|
|
244
244
|
function inferRuntimeAction(event = {}, phase = '') {
|
|
245
245
|
const haystack = `${phase}\n${summarizeRuntimeToolTarget(event)}\n${stableJson(event).slice(0, 6000)}`;
|
|
246
|
-
if (/\b(?:kubectl\s+(?:apply|set|rollout|delete)|helm\s+upgrade|terraform\s+apply|docker\s+push|deploy)\b/i.test(haystack)) return 'deploy';
|
|
247
|
-
if (/\b(?:rm\s+-[rRfF]
|
|
246
|
+
if (/\b(?:kubectl\s+(?:apply|set|rollout|delete|create|replace|scale)|helm\s+(?:upgrade|install|uninstall)|terraform\s+(?:apply|destroy)|docker\s+(?:push|build\s+.*--push)|deploy)\b/i.test(haystack)) return 'deploy';
|
|
247
|
+
if (/\b(?:rm\s+-[rRfF]+\S*|drop\s+(?:table|database|schema|collection|index)|git\s+(?:reset\s+--hard|push\s+--force|push\s+--delete)|sudo\s+|systemctl\s+(?:stop|disable|mask|kill)|kill\s+-[9K]|pkill\s+-[9K]|chmod\s+777|docker\s+rm\s+-f)\b/i.test(haystack)) return 'delete';
|
|
248
|
+
if (/\b(?:--no-verify|--no-gpg-sign)\b/i.test(haystack)) return 'delete';
|
|
248
249
|
if (phase === 'stop' || phase === 'pre_emit') return 'release';
|
|
249
|
-
if (phase === 'pre_tool' || phase === 'post_tool') return 'write';
|
|
250
250
|
return '';
|
|
251
251
|
}
|
|
252
252
|
|
package/package.json
CHANGED
|
@@ -192,6 +192,9 @@ export function normalizeCoachEvent(input = {}) {
|
|
|
192
192
|
return record;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
const DESTRUCTIVE_RX = /\b(?:rm\s+-[rRfF]+\S*|drop\s+(?:table|database|schema|collection|index)|git\s+(?:reset\s+--hard|push\s+--force|push\s+--delete)|sudo\s+|systemctl\s+(?:stop|disable|mask|kill)|kill\s+-[9K]|pkill\s+-[9K]|--no-verify|--no-gpg-sign|kubectl\s+(?:delete|scale\s+--replicas=0|rollout\s+undo)|docker\s+rm\s+-f|chmod\s+777|wget|curl.*\|\s*(?:ba)?sh)\b/i;
|
|
196
|
+
const DEPLOY_RX = /\b(?:kubectl\s+(?:apply|set|rollout|delete|create|replace|scale)|helm\s+(?:upgrade|install|uninstall)|terraform\s+(?:apply|destroy)|docker\s+(?:push|build\s+.*--push))\b/i;
|
|
197
|
+
|
|
195
198
|
export function evaluateCoachEvent(event = {}) {
|
|
196
199
|
const normalized = event.phase ? event : normalizeCoachEvent(event);
|
|
197
200
|
const text = normalized.rawText || normalized.text_preview || '';
|
|
@@ -210,10 +213,10 @@ export function evaluateCoachEvent(event = {}) {
|
|
|
210
213
|
highRisk.push('required_skill_unavailable_before_generation');
|
|
211
214
|
}
|
|
212
215
|
if (TOOL_PHASES.has(normalized.phase) || action) {
|
|
213
|
-
if ((action === 'delete' ||
|
|
216
|
+
if ((action === 'delete' || DESTRUCTIVE_RX.test(text)) && normalized.metadata?.approved !== true) {
|
|
214
217
|
highRisk.push('unapproved_destructive_action');
|
|
215
218
|
}
|
|
216
|
-
if ((action === 'deploy' ||
|
|
219
|
+
if ((action === 'deploy' || DEPLOY_RX.test(text)) && !hasVerifyEvidence(normalized, text)) {
|
|
217
220
|
highRisk.push('unverified_deploy_or_infra_mutation');
|
|
218
221
|
}
|
|
219
222
|
}
|
|
@@ -229,6 +232,9 @@ export function evaluateCoachEvent(event = {}) {
|
|
|
229
232
|
repairable.push('unsupported_completion_or_verification_claim');
|
|
230
233
|
}
|
|
231
234
|
}
|
|
235
|
+
if (normalized.missing_skill_ids.length > 0 && !normalized.metadata?.skillsAdvisoryOnly) {
|
|
236
|
+
repairable.push('required_skills_not_loaded');
|
|
237
|
+
}
|
|
232
238
|
if (normalized.lane.includes('unmanaged') || normalized.metadata?.complianceGuarantee === 'best_effort_only') {
|
|
233
239
|
warnings.push('unmanaged_direct_provider_best_effort_only');
|
|
234
240
|
}
|
package/src/connectors/codex.ts
CHANGED
|
@@ -525,7 +525,6 @@ try {
|
|
|
525
525
|
function buildCodexPreToolHook(): string {
|
|
526
526
|
return `#!/usr/bin/env node
|
|
527
527
|
import {
|
|
528
|
-
getHarnessClient,
|
|
529
528
|
inferSessionId,
|
|
530
529
|
classifyAction,
|
|
531
530
|
summarizeTarget,
|
|
@@ -534,14 +533,11 @@ import {
|
|
|
534
533
|
makeEvidenceRef,
|
|
535
534
|
recordCoachPhase,
|
|
536
535
|
saveTurnState,
|
|
537
|
-
runGovernanceGate,
|
|
538
|
-
updateTaskProjectLedger,
|
|
539
536
|
formatCodexRecoveryBlock,
|
|
540
537
|
emitJson,
|
|
541
538
|
} from './lib/runtime-client.mjs';
|
|
542
539
|
|
|
543
540
|
const event = readEventFromStdin();
|
|
544
|
-
const client = getHarnessClient();
|
|
545
541
|
const sessionId = inferSessionId(event);
|
|
546
542
|
const action = classifyAction(event);
|
|
547
543
|
const target = summarizeTarget(event);
|
|
@@ -579,35 +575,6 @@ try {
|
|
|
579
575
|
}),
|
|
580
576
|
});
|
|
581
577
|
}
|
|
582
|
-
const actionCheck = await client.checkAction(action, target);
|
|
583
|
-
if (actionCheck?.allowed === false) {
|
|
584
|
-
emitJson({
|
|
585
|
-
decision: 'block',
|
|
586
|
-
reason: formatCodexRecoveryBlock({
|
|
587
|
-
surface: 'codex-pre-tool-action',
|
|
588
|
-
reason: actionCheck?.reason || \`Aria denied \${action}\`,
|
|
589
|
-
next: '6. Add the required verification/cognition contract for the action, then request the tool again.',
|
|
590
|
-
}),
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
updateTaskProjectLedger({
|
|
594
|
-
platform: 'codex',
|
|
595
|
-
phase: 'pre_tool',
|
|
596
|
-
source: 'codex-pre-tool-hook',
|
|
597
|
-
event: { ...event, sessionId, cwd: process.cwd() },
|
|
598
|
-
evidence: { action_ref: requestRef },
|
|
599
|
-
});
|
|
600
|
-
runGovernanceGate({
|
|
601
|
-
sessionId,
|
|
602
|
-
sourceRuntime: 'codex',
|
|
603
|
-
surface: 'codex-pre-tool-use',
|
|
604
|
-
text: JSON.stringify(event).slice(0, 8000),
|
|
605
|
-
action,
|
|
606
|
-
toolName,
|
|
607
|
-
isDeploy: action === 'deploy',
|
|
608
|
-
isMutation: action === 'write' || action === 'delete',
|
|
609
|
-
evidence: requestRef,
|
|
610
|
-
});
|
|
611
578
|
const tools = Array.isArray(state?.tools) ? state.tools.slice(-24) : [];
|
|
612
579
|
tools.push({
|
|
613
580
|
at: new Date().toISOString(),
|
|
@@ -712,7 +679,6 @@ import {
|
|
|
712
679
|
formatValidationFailure,
|
|
713
680
|
formatCodexRecoveryBlock,
|
|
714
681
|
isAriaControlBlock,
|
|
715
|
-
runGovernanceGate,
|
|
716
682
|
updateTaskProjectLedger,
|
|
717
683
|
evaluateTaskProjectClaim,
|
|
718
684
|
recordBlockedTaskProjectClaim,
|
|
@@ -777,14 +743,6 @@ try {
|
|
|
777
743
|
}),
|
|
778
744
|
});
|
|
779
745
|
}
|
|
780
|
-
runGovernanceGate({
|
|
781
|
-
sessionId,
|
|
782
|
-
sourceRuntime: 'codex',
|
|
783
|
-
surface: 'codex-stop',
|
|
784
|
-
text: text.slice(0, 8000),
|
|
785
|
-
isOutputCloseout: true,
|
|
786
|
-
evidence: outputRef,
|
|
787
|
-
});
|
|
788
746
|
const validation = await runtimePost('/validate-output', {
|
|
789
747
|
text,
|
|
790
748
|
sessionId,
|