ctxtop 0.0.0-stage → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.antigravity-plugin/plugin.json +36 -0
- package/.claude-plugin/plugin.json +18 -0
- package/CHECKSUMS.sha256 +166 -0
- package/LICENSE +27 -0
- package/README.md +350 -2
- package/SECURITY.md +22 -0
- package/agents/ah-flash-scout.md +25 -0
- package/assets/advanced_view_loaded_420px.png +0 -0
- package/assets/hero-demo.svg +188 -0
- package/assets/logo.svg +19 -0
- package/assets/simple_view_lean_420px.png +0 -0
- package/assets/simple_view_loaded_420px.png +0 -0
- package/assets/social-preview.svg +72 -0
- package/assets/zone_c_step3_shield_full.png +0 -0
- package/bin/ah-statusline.mjs +175 -0
- package/bin/cli.mjs +3 -0
- package/bin/ctxtop.mjs +1799 -0
- package/commands/cost-radar.md +11 -0
- package/commands/evolve.md +10 -0
- package/commands/handoff.md +10 -0
- package/commands/horizon.md +10 -0
- package/commands/inspect.md +10 -0
- package/commands/precheck.md +10 -0
- package/config/default_flightcheck.json +133 -0
- package/config/modelCatalog.json +785 -0
- package/config/platformQuirks.json +19 -0
- package/hooks/handlers/compact-lifecycle.mjs +577 -0
- package/hooks/handlers/config-change.mjs +402 -0
- package/hooks/handlers/hookIo.mjs +311 -0
- package/hooks/handlers/hookIpcClient.mjs +83 -0
- package/hooks/handlers/post-model-switch.mjs +111 -0
- package/hooks/handlers/post-tool-use.mjs +366 -0
- package/hooks/handlers/pre-model-switch.mjs +1048 -0
- package/hooks/handlers/pre-tool-use.mjs +632 -0
- package/hooks/handlers/stop-gate.mjs +526 -0
- package/hooks/handlers/user-prompt-submit.mjs +367 -0
- package/hooks/hooks.json +131 -0
- package/hooks/post_invocation.mjs +13 -0
- package/hooks/post_tool_use.mjs +25 -0
- package/hooks/pre_invocation.mjs +14 -0
- package/hooks/pre_tool_use.mjs +97 -0
- package/hooks/register.js +726 -0
- package/hooks/session_start.mjs +24 -0
- package/hooks/stop.mjs +23 -0
- package/hooks.json +56 -0
- package/package.json +110 -4
- package/packages/antigravity/package.json +14 -0
- package/packages/antigravity/src/index.mjs +1 -0
- package/packages/claude-code/package.json +14 -0
- package/packages/claude-code/src/index.mjs +2 -0
- package/packages/core/package.json +14 -0
- package/packages/core/src/index.mjs +1 -0
- package/packages/engine-node/package.json +14 -0
- package/packages/engine-node/src/index.mjs +1 -0
- package/packages/mcp/package.json +17 -0
- package/packages/mcp/src/server.mjs +396 -0
- package/packages/pro/LICENSE-COMMERCIAL.md +19 -0
- package/packages/pro/README-SIGNING.md +30 -0
- package/packages/pro/package.json +16 -0
- package/packages/pro/src/index.mjs +3 -0
- package/packages/pro/src/team_finops_pack.mjs +241 -0
- package/packages/pro/workers/polar_webhook_worker.mjs +215 -0
- package/plugin.json +36 -0
- package/rules/AGENTS.md +10 -0
- package/sidecars/horizon-daemon/ipcServer.mjs +24 -0
- package/sidecars/horizon-daemon/server.mjs +2038 -0
- package/sidecars/horizon-daemon/sidecar.json +19 -0
- package/skills/cost-radar/SKILL.md +21 -0
- package/skills/evolve/SKILL.md +21 -0
- package/skills/handoff/SKILL.md +50 -0
- package/skills/horizon/SKILL.md +17 -0
- package/skills/inspect/SKILL.md +18 -0
- package/skills/precheck/SKILL.md +44 -0
- package/src/adapters/antigravity/index.mjs +109 -0
- package/src/adapters/claude-code/index.mjs +194 -0
- package/src/cli/cost_radar.mjs +70 -0
- package/src/cli/doctor.mjs +351 -0
- package/src/cli/horizon_hud.mjs +888 -0
- package/src/cli/init.mjs +425 -0
- package/src/cli/postmortem.mjs +515 -0
- package/src/coach/cacheGravityRouter.mjs +12 -0
- package/src/config/modelCatalog.json +704 -0
- package/src/config/platformQuirks.json +19 -0
- package/src/core/action_queue.mjs +264 -0
- package/src/core/ag_bridge.mjs +346 -0
- package/src/core/atomic_io.mjs +124 -0
- package/src/core/baseline.mjs +607 -0
- package/src/core/blindspot_sensors.mjs +399 -0
- package/src/core/bucket_b_runtime.mjs +1200 -0
- package/src/core/classifier.mjs +1757 -0
- package/src/core/coach/circuit_breakers.mjs +650 -0
- package/src/core/coach/contradiction_auditor.mjs +239 -0
- package/src/core/coach/effort_advisor.mjs +143 -0
- package/src/core/coach/handoff_hydrator.mjs +483 -0
- package/src/core/coach/progressive_checkpointer.mjs +551 -0
- package/src/core/coach/prompt_decomposer_coach.mjs +141 -0
- package/src/core/coach/reflector_queue.mjs +505 -0
- package/src/core/coach/saved_quota_ledger.mjs +615 -0
- package/src/core/coach/subagent_ipi_sanitizer.mjs +200 -0
- package/src/core/coach/subagent_phantom_auditor.mjs +261 -0
- package/src/core/coach/task_quota_router.mjs +955 -0
- package/src/core/coach/turn_zero_gate.mjs +574 -0
- package/src/core/compaction_coach.mjs +1126 -0
- package/src/core/config.mjs +214 -0
- package/src/core/constants.mjs +1987 -0
- package/src/core/detectors_det01_to_16.mjs +1523 -0
- package/src/core/doc_indexer.mjs +338 -0
- package/src/core/episodic_memory.mjs +135 -0
- package/src/core/fts5_output_compressor.mjs +359 -0
- package/src/core/git_ledger.mjs +189 -0
- package/src/core/handoff_audit.mjs +558 -0
- package/src/core/history.mjs +221 -0
- package/src/core/hook_diagnostics.mjs +158 -0
- package/src/core/horizon_classifier.mjs +326 -0
- package/src/core/horizon_config.mjs +802 -0
- package/src/core/host_watchdog.mjs +200 -0
- package/src/core/layer5_hygiene.mjs +1084 -0
- package/src/core/log_resolver.mjs +231 -0
- package/src/core/mcp_auditor.mjs +138 -0
- package/src/core/micro_skills_store.mjs +91 -0
- package/src/core/offenders.mjs +161 -0
- package/src/core/parser.mjs +1997 -0
- package/src/core/path_canonicalizer.mjs +73 -0
- package/src/core/paths.mjs +311 -0
- package/src/core/prefix_cache_shield.mjs +386 -0
- package/src/core/pro_license.mjs +385 -0
- package/src/core/prompt_rubric.mjs +518 -0
- package/src/core/pruner.mjs +433 -0
- package/src/core/quota.mjs +1860 -0
- package/src/core/rsi_instinct_engine.mjs +1197 -0
- package/src/core/rsl_clash_auditor.mjs +423 -0
- package/src/core/rsl_distiller.mjs +372 -0
- package/src/core/rsl_ledger.mjs +969 -0
- package/src/core/rsl_triage.mjs +909 -0
- package/src/core/sanitizer.mjs +121 -0
- package/src/core/session_auditor.mjs +658 -0
- package/src/core/session_forensics.mjs +303 -0
- package/src/core/session_timeline.mjs +358 -0
- package/src/core/settings.mjs +99 -0
- package/src/core/shared/detectors.mjs +1342 -0
- package/src/core/shared/fnv1a64.mjs +85 -0
- package/src/core/shared/handoff_schema.mjs +123 -0
- package/src/core/shared/index.mjs +5 -0
- package/src/core/shared/ipi_sanitizer.mjs +165 -0
- package/src/core/shared/micro_skills.mjs +1 -0
- package/src/core/shared/plugin_validator.mjs +202 -0
- package/src/core/shared/prompt_hygiene_governor.mjs +1 -0
- package/src/core/shield_manager.mjs +1417 -0
- package/src/core/sidecar_store.mjs +302 -0
- package/src/core/sprint_metrics.mjs +366 -0
- package/src/core/sqlite_client.mjs +283 -0
- package/src/core/storage_doctor.mjs +358 -0
- package/src/core/subagents.mjs +609 -0
- package/src/core/swarm_topology.mjs +360 -0
- package/src/core/task_quota_router.mjs +1656 -0
- package/src/core/telemetry/cache_ttl_watchdog.mjs +284 -0
- package/src/core/telemetry/scope_lock_registry.mjs +578 -0
- package/src/core/telemetry/shadow_file_detector.mjs +291 -0
- package/src/core/telemetry/trajectory_watcher.mjs +259 -0
- package/src/core/timeline_svg.mjs +236 -0
- package/src/core/tool_surgeon.mjs +305 -0
- package/src/core/trajectory_stitcher.mjs +645 -0
- package/src/core/u_shaped_optimizer.mjs +789 -0
- package/src/core/wal_hygiene.mjs +233 -0
- package/src/core-isomorphic/catalog/detectorCatalog.mjs +558 -0
- package/src/core-isomorphic/catalog/index.mjs +1 -0
- package/src/core-isomorphic/coach/cacheGravityRouter.mjs +1547 -0
- package/src/core-isomorphic/coach/microSkills.mjs +1 -0
- package/src/core-isomorphic/coach/promptHygieneGovernor.mjs +1 -0
- package/src/core-isomorphic/coach/repoCalibration.mjs +254 -0
- package/src/core-isomorphic/coach/resumeToolsetAuditor.mjs +321 -0
- package/src/core-isomorphic/coach/savedQuotaLedger.mjs +527 -0
- package/src/core-isomorphic/coach/smartCompactAdvisor.mjs +305 -0
- package/src/core-isomorphic/coach/stateBatonHydrator.mjs +810 -0
- package/src/core-isomorphic/coach/ttlWatchdog.mjs +464 -0
- package/src/core-isomorphic/config/anthropicModelCatalog.json +606 -0
- package/src/core-isomorphic/config/catalogLoader.mjs +1268 -0
- package/src/core-isomorphic/config/horizonConfig.mjs +1055 -0
- package/src/core-isomorphic/control/callTree.mjs +338 -0
- package/src/core-isomorphic/control/coachLatches.mjs +126 -0
- package/src/core-isomorphic/control/controlStateMachine.mjs +205 -0
- package/src/core-isomorphic/control/index.mjs +49 -0
- package/src/core-isomorphic/control/swarmWorktree.mjs +109 -0
- package/src/core-isomorphic/control/toolSuspension.mjs +197 -0
- package/src/core-isomorphic/diagnostics/drift_guard.mjs +382 -0
- package/src/core-isomorphic/diagnostics/index.mjs +9 -0
- package/src/core-isomorphic/diagnostics/micro_skills.mjs +471 -0
- package/src/core-isomorphic/diagnostics/prompt_hygiene_governor.mjs +888 -0
- package/src/core-isomorphic/economics/billingBlocks.mjs +251 -0
- package/src/core-isomorphic/economics/cacheGravity.mjs +369 -0
- package/src/core-isomorphic/economics/cliffBreaker.mjs +256 -0
- package/src/core-isomorphic/economics/driftLatency.mjs +433 -0
- package/src/core-isomorphic/economics/dualTtl.mjs +198 -0
- package/src/core-isomorphic/economics/index.mjs +47 -0
- package/src/core-isomorphic/economics/retentionRadar.mjs +348 -0
- package/src/core-isomorphic/guards/bucketBAlphaBeta.mjs +860 -0
- package/src/core-isomorphic/guards/bucketBGamma.mjs +442 -0
- package/src/core-isomorphic/guards/bucketBHeuristics.mjs +37 -0
- package/src/core-isomorphic/guards/circuitBreakers.mjs +1202 -0
- package/src/core-isomorphic/guards/det01_03_shell_secret.mjs +1184 -0
- package/src/core-isomorphic/guards/det04_12_thrash_rot.mjs +572 -0
- package/src/core-isomorphic/guards/det13_20_mcp_scope.mjs +913 -0
- package/src/core-isomorphic/guards/docIndexCore.mjs +446 -0
- package/src/core-isomorphic/guards/losslessPostSanitizer.mjs +317 -0
- package/src/core-isomorphic/guards/slopsquatGate.mjs +551 -0
- package/src/core-isomorphic/index.js +27 -0
- package/src/core-isomorphic/telemetry/otelExporter.mjs +187 -0
- package/src/core-isomorphic/telemetry/scopeLockRegistry.mjs +522 -0
- package/src/core-isomorphic/telemetry/sprintMetrics.mjs +327 -0
- package/src/core-isomorphic/telemetry/swarmTopology.mjs +152 -0
- package/src/core-isomorphic/telemetry/telemetryBridge.mjs +1156 -0
- package/src/core-isomorphic/ui/brailleSparkline.mjs +142 -0
- package/src/core-isomorphic/ui/costRadarSvg.mjs +276 -0
- package/src/core-isomorphic/ui/horizonGrid.mjs +475 -0
- package/src/core-isomorphic/ui/horizonPanelHtml.mjs +1237 -0
- package/src/core-isomorphic/ui/modViews.mjs +1504 -0
- package/src/core-isomorphic/ui/pdfReceiptGenerator.mjs +329 -0
- package/src/core-isomorphic/ustf/index.mjs +7 -0
- package/src/core-isomorphic/ustf/normalizer.mjs +512 -0
- package/src/core-isomorphic/ustf/schema.mjs +186 -0
- package/src/core-isomorphic/utils/runtime.mjs +962 -0
- package/src/demo/synthetic_states.mjs +661 -0
- package/src/diagnostics/bugReportGenerator.mjs +253 -0
- package/src/diagnostics/claudeHookCapabilities.mjs +396 -0
- package/src/diagnostics/doctorEngine.mjs +295 -0
- package/src/engine-node/db/index.mjs +58 -0
- package/src/engine-node/db/jsonl_fallback.mjs +184 -0
- package/src/engine-node/db/probe.mjs +342 -0
- package/src/engine-node/db/sqlite_wrapper.mjs +122 -0
- package/src/engine-node/index.mjs +12 -0
- package/src/engine-node/ipc/client.mjs +447 -0
- package/src/engine-node/ipc/index.mjs +22 -0
- package/src/engine-node/ipc/protocol.mjs +177 -0
- package/src/engine-node/ipc/server.mjs +445 -0
- package/src/engine-node/offloader/index.mjs +6 -0
- package/src/engine-node/offloader/tool_offloader.mjs +241 -0
- package/src/engine-node/sensors/blindspots.mjs +376 -0
- package/src/engine-node/sensors/git_merge_tree.mjs +223 -0
- package/src/engine-node/sensors/index.mjs +7 -0
- package/src/hooks/antigravity_rsl_hook.mjs +250 -0
- package/src/hooks/claude_rsl_hook.mjs +288 -0
- package/src/hooks/portfolio_runtime.mjs +858 -0
- package/src/hooks/post_invocation.mjs +611 -0
- package/src/hooks/pre_invocation.mjs +1725 -0
- package/src/hooks/session_start.mjs +199 -0
- package/src/shims/agy_cli_compressor.mjs +705 -0
- package/src/shims/agy_git_guard.mjs +749 -0
- package/src/shims/ah_log_query.mjs +39 -0
- package/src/ui/costRadarSvg.mjs +6 -0
- package/src/ui/horizonGrid.mjs +1 -0
- package/src/ui/horizonPanelHtml.mjs +1 -0
- package/src/ui/horizon_panel.css +167 -0
- package/src/ui/horizon_panel.js +212 -0
- package/src/ui/modViews.mjs +1 -0
- package/src/utils/modelSwitchTelemetry.mjs +308 -0
- package/src/utils/nodeIo.mjs +59 -0
- package/src/utils/runtime.mjs +1 -0
- package/src/utils/sessionCalibration.mjs +657 -0
- package/src/webview/advanced_view.html +1808 -0
- package/src/webview/horizon_panel.html +12397 -0
- package/src/webview/registry.mjs +80 -0
- package/src/webview/simple_view.html +1370 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file hooks/handlers/hookIpcClient.mjs
|
|
3
|
+
* Warm Micro-IPC Hook Dispatcher with Standalone Fallback (Features 29 & 30).
|
|
4
|
+
*
|
|
5
|
+
* Forwards PreToolUse and PostToolUse hook events to the warm Horizon Daemon IPC
|
|
6
|
+
* socket/pipe (<0.8ms SLA), automatically and silently falling back to standalone
|
|
7
|
+
* CLI evaluation within 15ms if the daemon is offline.
|
|
8
|
+
* Strictly 0 npm dependencies (uses only standard node:* built-ins).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { MicroIpcClient } from '../../src/engine-node/ipc/client.mjs';
|
|
12
|
+
import { runPreToolUseHook } from './pre-tool-use.mjs';
|
|
13
|
+
import { runPostToolUseHook } from './post-tool-use.mjs';
|
|
14
|
+
|
|
15
|
+
let sharedClient = null;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns or creates the shared MicroIpcClient instance for hook handlers.
|
|
19
|
+
*
|
|
20
|
+
* @param {object} [options]
|
|
21
|
+
* @returns {MicroIpcClient}
|
|
22
|
+
*/
|
|
23
|
+
export function getHookIpcClient(options = {}) {
|
|
24
|
+
if (!sharedClient || options.ipcPath) {
|
|
25
|
+
sharedClient = new MicroIpcClient({
|
|
26
|
+
connectTimeoutMs: options.connectTimeoutMs ?? 15,
|
|
27
|
+
requestTimeoutMs: options.requestTimeoutMs ?? 500,
|
|
28
|
+
...options
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return sharedClient;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Dispatches a PreToolUse hook invocation over warm Micro-IPC with fallback to local execution.
|
|
36
|
+
*
|
|
37
|
+
* @param {object} payload
|
|
38
|
+
* @param {object} [options]
|
|
39
|
+
* @returns {Promise<{ source: 'ipc' | 'fallback', result: object, fallbackReason?: string }>}
|
|
40
|
+
*/
|
|
41
|
+
export async function dispatchPreToolUseWithFallback(payload, options = {}) {
|
|
42
|
+
const client = getHookIpcClient(options);
|
|
43
|
+
return client.callWithFallback(
|
|
44
|
+
'hook.preToolUse',
|
|
45
|
+
payload,
|
|
46
|
+
async (p) => runPreToolUseHook(p, options),
|
|
47
|
+
{
|
|
48
|
+
connectTimeoutMs: options.connectTimeoutMs ?? 15,
|
|
49
|
+
requestTimeoutMs: options.requestTimeoutMs ?? 600000
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Dispatches a PostToolUse hook invocation over warm Micro-IPC with fallback to local execution.
|
|
56
|
+
*
|
|
57
|
+
* @param {object} payload
|
|
58
|
+
* @param {object} [options]
|
|
59
|
+
* @returns {Promise<{ source: 'ipc' | 'fallback', result: object, fallbackReason?: string }>}
|
|
60
|
+
*/
|
|
61
|
+
export async function dispatchPostToolUseWithFallback(payload, options = {}) {
|
|
62
|
+
const client = getHookIpcClient(options);
|
|
63
|
+
return client.callWithFallback(
|
|
64
|
+
'hook.postToolUse',
|
|
65
|
+
payload,
|
|
66
|
+
async (p) => runPostToolUseHook(p, options),
|
|
67
|
+
{ connectTimeoutMs: options.connectTimeoutMs ?? 15 }
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Closes and resets the shared MicroIpcClient instance.
|
|
73
|
+
*
|
|
74
|
+
* @returns {Promise<void>}
|
|
75
|
+
*/
|
|
76
|
+
export async function closeHookIpcClient() {
|
|
77
|
+
if (sharedClient) {
|
|
78
|
+
const client = sharedClient;
|
|
79
|
+
sharedClient = null;
|
|
80
|
+
await client.close();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file hooks/handlers/post-model-switch.mjs
|
|
3
|
+
* Standalone Node CLI handler for Claude Code `PostModelSwitch` (`DET-08` acceptance telemetry).
|
|
4
|
+
*
|
|
5
|
+
* Contract note (Claude Code 2.1.x):
|
|
6
|
+
* Any `stdout` emitted on `PostModelSwitch` with exit 0 is injected as model context on the
|
|
7
|
+
* next turn, so this handler MUST return empty `stdout` and `stderr` with exit code `0`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { recordPostModelSwitchEvent } from '../../src/utils/modelSwitchTelemetry.mjs';
|
|
11
|
+
import {
|
|
12
|
+
readBreakerStateSnapshot,
|
|
13
|
+
writeBreakerStateSnapshot
|
|
14
|
+
} from '../../src/core-isomorphic/guards/circuitBreakers.mjs';
|
|
15
|
+
import { isCliEntrypoint, readStdinJsonAsync, exitPassThrough } from './hookIo.mjs';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Evaluate `PostModelSwitch` payload and update local acceptance telemetry.
|
|
19
|
+
*
|
|
20
|
+
* @param {object} [event={}]
|
|
21
|
+
* @param {object} [options={}]
|
|
22
|
+
* @returns {{ exitCode: number, stdout: string, stderr: string, telemetryRecorded: boolean }}
|
|
23
|
+
*/
|
|
24
|
+
export function runPostModelSwitchHook(event = {}, options = {}) {
|
|
25
|
+
let telemetryRecorded = false;
|
|
26
|
+
const shouldRecordTelemetry =
|
|
27
|
+
options.recordSwitchTelemetry !== false &&
|
|
28
|
+
Boolean(
|
|
29
|
+
options.cliInvocation ||
|
|
30
|
+
options.homeDir ||
|
|
31
|
+
options.telemetryPath ||
|
|
32
|
+
options.recordSwitchTelemetry ||
|
|
33
|
+
globalThis.process?.env?.AH_MODEL_SWITCH_TELEMETRY_PATH
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (shouldRecordTelemetry) {
|
|
37
|
+
try {
|
|
38
|
+
recordPostModelSwitchEvent(event, {
|
|
39
|
+
homeDir: options.homeDir,
|
|
40
|
+
telemetryPath: options.telemetryPath
|
|
41
|
+
});
|
|
42
|
+
telemetryRecorded = true;
|
|
43
|
+
} catch {
|
|
44
|
+
// Fail-open: never block or inject stdout context on PostModelSwitch telemetry error
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Item 4.4: Clear pending_downshift once the model switch actually executes
|
|
49
|
+
const shouldPersistBreaker =
|
|
50
|
+
options.persistState !== false &&
|
|
51
|
+
Boolean(event.cwd || options.cwd || options.breakerStatePath || options.cliInvocation);
|
|
52
|
+
if (shouldPersistBreaker) {
|
|
53
|
+
try {
|
|
54
|
+
const sessionId = event.session_id || event.sessionId || 'default';
|
|
55
|
+
const cwdOptions = event.cwd && !options.cwd ? { ...options, cwd: event.cwd } : options;
|
|
56
|
+
const snap = readBreakerStateSnapshot(sessionId, cwdOptions);
|
|
57
|
+
if (snap && (snap.pending_downshift || snap.pendingDownshiftModel || snap.justCompacted)) {
|
|
58
|
+
writeBreakerStateSnapshot(
|
|
59
|
+
sessionId,
|
|
60
|
+
{
|
|
61
|
+
...snap,
|
|
62
|
+
updatedAt: Date.now(),
|
|
63
|
+
pending_downshift: null,
|
|
64
|
+
pendingDownshiftModel: null,
|
|
65
|
+
justCompacted: false
|
|
66
|
+
},
|
|
67
|
+
cwdOptions
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
// Fail-open on local state cleanup
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
exitCode: 0,
|
|
77
|
+
stdout: '',
|
|
78
|
+
stderr: '',
|
|
79
|
+
telemetryRecorded
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Fail-open CLI runner for `PostModelSwitch`.
|
|
85
|
+
* Always exits `0` with empty stdout/stderr so no extra context is injected.
|
|
86
|
+
*
|
|
87
|
+
* @param {object} [cliOptions={}]
|
|
88
|
+
*/
|
|
89
|
+
export async function executePostModelSwitchCli(cliOptions = {}) {
|
|
90
|
+
const readPayload = cliOptions.readPayload || readStdinJsonAsync;
|
|
91
|
+
const runHook = cliOptions.runHook || runPostModelSwitchHook;
|
|
92
|
+
const ioOverride = cliOptions.ioOverride || {};
|
|
93
|
+
const isRealCliRun =
|
|
94
|
+
!cliOptions.ioOverride && !cliOptions.readPayload && !cliOptions.runHook;
|
|
95
|
+
try {
|
|
96
|
+
const payload = await readPayload(cliOptions.timeoutMs);
|
|
97
|
+
runHook(payload, {
|
|
98
|
+
cliInvocation: isRealCliRun,
|
|
99
|
+
...(cliOptions.hookOptions || {})
|
|
100
|
+
});
|
|
101
|
+
} catch {
|
|
102
|
+
// Fail-open on stdin parse timeout or telemetry errors
|
|
103
|
+
}
|
|
104
|
+
exitPassThrough(ioOverride.exitFn);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (isCliEntrypoint(import.meta.url)) {
|
|
108
|
+
executePostModelSwitchCli().catch(() => {
|
|
109
|
+
exitPassThrough();
|
|
110
|
+
});
|
|
111
|
+
}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file hooks/handlers/post-tool-use.mjs
|
|
3
|
+
* Tier 2 Command Hook handler for `PostToolUse` (`Bash|PowerShell|Grep|Glob|Task|Agent|WebFetch|mcp__.*`).
|
|
4
|
+
* Runs lossless output sanitization, 100% critical error-line recovery,
|
|
5
|
+
* >4,000 token programmatic artifact offloading (excluding workspace `Read`),
|
|
6
|
+
* and `DET-19` subagent IPI boundary & Unicode tag stripping (`ISS-034`, `ISS-053`).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { sanitizePostToolOutput } from '../../src/core-isomorphic/guards/losslessPostSanitizer.mjs';
|
|
10
|
+
import {
|
|
11
|
+
CircuitBreakerEngine,
|
|
12
|
+
evaluateDet19SubagentIpiSanitizer,
|
|
13
|
+
readBreakerStateSnapshot,
|
|
14
|
+
writeBreakerStateSnapshot
|
|
15
|
+
} from '../../src/core-isomorphic/guards/circuitBreakers.mjs';
|
|
16
|
+
import { loadHorizonConfig, resolveDetectorOverride } from '../../src/core-isomorphic/config/horizonConfig.mjs';
|
|
17
|
+
import { recordWorkspaceShellOutcome } from '../../src/core-isomorphic/coach/microSkills.mjs';
|
|
18
|
+
import { evaluateTaskBoundaryTurn } from '../../src/core-isomorphic/coach/smartCompactAdvisor.mjs';
|
|
19
|
+
import { recordSavingsReceipt } from '../../src/core-isomorphic/coach/savedQuotaLedger.mjs';
|
|
20
|
+
import { readLiveStateSnapshot } from '../../src/core-isomorphic/telemetry/telemetryBridge.mjs';
|
|
21
|
+
import { resolveEffectiveRates, computeTotalPromptTokens } from '../../src/core-isomorphic/config/catalogLoader.mjs';
|
|
22
|
+
import { runBucketBPostToolPass } from '../../src/core/bucket_b_runtime.mjs';
|
|
23
|
+
import { handleClaudeRslHook } from '../../src/hooks/claude_rsl_hook.mjs';
|
|
24
|
+
import {
|
|
25
|
+
isCliEntrypoint,
|
|
26
|
+
readStdinJsonAsync,
|
|
27
|
+
exitPassThrough,
|
|
28
|
+
exitDiagnosticZero,
|
|
29
|
+
exitWithStdoutJson
|
|
30
|
+
} from './hookIo.mjs';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Extracts text from a string or structured `tool_response` object.
|
|
34
|
+
* @param {object} event
|
|
35
|
+
* @returns {string}
|
|
36
|
+
*/
|
|
37
|
+
function extractPostToolText(event = {}) {
|
|
38
|
+
const resp = event.tool_response ?? event.tool_output ?? event.toolOutput ?? event.output;
|
|
39
|
+
if (typeof resp === 'string') return resp;
|
|
40
|
+
if (resp && typeof resp === 'object') {
|
|
41
|
+
const parts = [resp.stdout, resp.stderr, resp.output, resp.content, resp.error]
|
|
42
|
+
.filter((x) => typeof x === 'string' && x.length > 0);
|
|
43
|
+
if (parts.length > 0) return parts.join('\n');
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
return resp !== undefined && resp !== null ? String(resp) : '';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Determines whether a completed tool call failed (`is_error`, non-zero `exit_code`, etc.).
|
|
51
|
+
* @param {object} event
|
|
52
|
+
* @returns {boolean}
|
|
53
|
+
*/
|
|
54
|
+
function didToolExecutionFail(event = {}) {
|
|
55
|
+
if (
|
|
56
|
+
event.is_error === true ||
|
|
57
|
+
event.isError === true ||
|
|
58
|
+
event.succeeded === false ||
|
|
59
|
+
Boolean(event.tool_error || event.error) ||
|
|
60
|
+
(typeof event.exit_code === 'number' && event.exit_code !== 0) ||
|
|
61
|
+
(typeof event.exitCode === 'number' && event.exitCode !== 0)
|
|
62
|
+
) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
const resp = event.tool_response;
|
|
66
|
+
if (resp && typeof resp === 'object') {
|
|
67
|
+
if (
|
|
68
|
+
resp.is_error === true ||
|
|
69
|
+
resp.isError === true ||
|
|
70
|
+
resp.succeeded === false ||
|
|
71
|
+
resp.status === 'error' ||
|
|
72
|
+
resp.status === 'failed' ||
|
|
73
|
+
Boolean(resp.error) ||
|
|
74
|
+
(typeof resp.exit_code === 'number' && resp.exit_code !== 0) ||
|
|
75
|
+
(typeof resp.exitCode === 'number' && resp.exitCode !== 0) ||
|
|
76
|
+
(typeof resp.returncode === 'number' && resp.returncode !== 0)
|
|
77
|
+
) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Evaluates a `PostToolUse` hook payload and returns the contract response.
|
|
86
|
+
* @param {object} event
|
|
87
|
+
* @param {object} [options={}]
|
|
88
|
+
*/
|
|
89
|
+
export function runPostToolUseHook(event = {}, options = {}) {
|
|
90
|
+
const toolName = String(event.tool_name || event.toolName || 'Bash');
|
|
91
|
+
const rawOutput = extractPostToolText(event);
|
|
92
|
+
const tier1Active = Boolean(
|
|
93
|
+
options.tier1ModActive ||
|
|
94
|
+
event.tier1ModActive ||
|
|
95
|
+
globalThis.process?.env?.AH_TIER1_MOD_ACTIVE === '1'
|
|
96
|
+
);
|
|
97
|
+
if (tier1Active && /^(Grep|Glob)$/i.test(toolName) && rawOutput.length < 16000 && !didToolExecutionFail(event)) {
|
|
98
|
+
return {
|
|
99
|
+
exitCode: 0,
|
|
100
|
+
stdout: '',
|
|
101
|
+
stderr: '',
|
|
102
|
+
fastPath: 'tier1_mod_active',
|
|
103
|
+
sanitized: { modified: false, offloaded: false }
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const sessionId = event.session_id || event.sessionId || 'default';
|
|
107
|
+
const cwdOptions = event.cwd && !options.cwd ? { ...options, cwd: event.cwd } : options;
|
|
108
|
+
const horizonConfig = options.horizonConfig || loadHorizonConfig(cwdOptions);
|
|
109
|
+
|
|
110
|
+
const hasExplicitCwd = Boolean(event.cwd || options.cwd);
|
|
111
|
+
let loadedPriorSnap = null;
|
|
112
|
+
const shouldPersistState =
|
|
113
|
+
options.persistState !== false &&
|
|
114
|
+
Boolean(event.cwd || options.cwd || options.breakerStatePath || options.persistState);
|
|
115
|
+
|
|
116
|
+
if (shouldPersistState) {
|
|
117
|
+
if (hasExplicitCwd && options.enableRsl !== false) {
|
|
118
|
+
try {
|
|
119
|
+
handleClaudeRslHook(event, { ...cwdOptions, event: 'PostToolUse' });
|
|
120
|
+
} catch {
|
|
121
|
+
// Fail open for RSL step telemetry
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const failed = didToolExecutionFail(event);
|
|
125
|
+
const priorSnap = readBreakerStateSnapshot(sessionId, cwdOptions);
|
|
126
|
+
loadedPriorSnap = priorSnap;
|
|
127
|
+
const engine = new CircuitBreakerEngine({
|
|
128
|
+
...cwdOptions,
|
|
129
|
+
horizonConfig,
|
|
130
|
+
mode: event.mode || options.mode || horizonConfig.flightMode || 'COACH',
|
|
131
|
+
initialState: priorSnap
|
|
132
|
+
});
|
|
133
|
+
const toolInput = event.tool_input || event.toolInput || {};
|
|
134
|
+
const cmdStr = String(toolInput.command || toolInput.cmd || event.command || '');
|
|
135
|
+
const rawExit =
|
|
136
|
+
event.exit_code ??
|
|
137
|
+
event.exitCode ??
|
|
138
|
+
event.tool_response?.exit_code ??
|
|
139
|
+
event.tool_response?.exitCode;
|
|
140
|
+
engine.recordToolOutcome(!failed, toolName);
|
|
141
|
+
if (/^(Bash|PowerShell|pwsh|cmd|sh|run_command|execute_bash)$/i.test(toolName)) {
|
|
142
|
+
engine.recordVerificationOutcome({
|
|
143
|
+
succeeded: !failed,
|
|
144
|
+
command: cmdStr,
|
|
145
|
+
outputText: rawOutput
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (failed && engine.modifiedFilesInTurn.size > 0) {
|
|
149
|
+
// If a test command failed, code edits remain unverified
|
|
150
|
+
engine.codeEditedSinceLastTest = true;
|
|
151
|
+
}
|
|
152
|
+
const boundaryEval = evaluateTaskBoundaryTurn(
|
|
153
|
+
{
|
|
154
|
+
toolName,
|
|
155
|
+
command: cmdStr,
|
|
156
|
+
failed,
|
|
157
|
+
exitCode: typeof rawExit === 'number' ? rawExit : (failed ? 1 : 0)
|
|
158
|
+
},
|
|
159
|
+
engine.taskBoundaryState
|
|
160
|
+
);
|
|
161
|
+
engine.taskBoundaryState = {
|
|
162
|
+
openFailure: boundaryEval.openFailure,
|
|
163
|
+
editsSinceBoundary: boundaryEval.editsSinceBoundary,
|
|
164
|
+
lastBoundarySuggestedTurn: engine.taskBoundaryState?.lastBoundarySuggestedTurn ?? null
|
|
165
|
+
};
|
|
166
|
+
const nextTurnBoundaryReached =
|
|
167
|
+
boundaryEval.detectorState === 'mid_debug'
|
|
168
|
+
? false
|
|
169
|
+
: boundaryEval.boundaryDetected
|
|
170
|
+
? true
|
|
171
|
+
: Boolean(priorSnap?.turnBoundaryReached);
|
|
172
|
+
const nextTurnMidDebug =
|
|
173
|
+
boundaryEval.detectorState === 'mid_debug'
|
|
174
|
+
? true
|
|
175
|
+
: boundaryEval.boundaryDetected
|
|
176
|
+
? false
|
|
177
|
+
: Boolean(priorSnap?.turnMidDebug);
|
|
178
|
+
if (Array.isArray(event.active_background_tasks || event.activeBackgroundTasks)) {
|
|
179
|
+
engine.activeBackgroundTasks = (event.active_background_tasks || event.activeBackgroundTasks)
|
|
180
|
+
.filter(Boolean)
|
|
181
|
+
.map((t) => (typeof t === 'string' ? t : String(t?.id || t?.command || 'bg_task')));
|
|
182
|
+
}
|
|
183
|
+
writeBreakerStateSnapshot(
|
|
184
|
+
sessionId,
|
|
185
|
+
{
|
|
186
|
+
...engine.exportStateSnapshot(),
|
|
187
|
+
turnBoundaryReached: nextTurnBoundaryReached,
|
|
188
|
+
turnMidDebug: nextTurnMidDebug
|
|
189
|
+
},
|
|
190
|
+
cwdOptions
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
// RSI-04 ('micro-skills'): Capture shell failure -> recovery pairs within <= 3 turns
|
|
194
|
+
if (/^(Bash|PowerShell|pwsh|cmd|sh)$/i.test(toolName) && resolveDetectorOverride('micro-skills', horizonConfig) !== 'off') {
|
|
195
|
+
if (cmdStr) {
|
|
196
|
+
recordWorkspaceShellOutcome(
|
|
197
|
+
{
|
|
198
|
+
command: cmdStr,
|
|
199
|
+
exitCode: typeof rawExit === 'number' ? rawExit : (failed ? 1 : 0),
|
|
200
|
+
turn: Number(event.turnId ?? event.turn_id ?? event.turn ?? 1),
|
|
201
|
+
sessionId: String(sessionId),
|
|
202
|
+
confirmSessions: Number(horizonConfig.thresholds?.microSkillConfirmSessions ?? 2)
|
|
203
|
+
},
|
|
204
|
+
cwdOptions
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (!loadedPriorSnap && options.bucketBShadow !== false && hasExplicitCwd && /^(?:Grep|Glob)$/i.test(toolName)) {
|
|
211
|
+
loadedPriorSnap = readBreakerStateSnapshot(sessionId, cwdOptions);
|
|
212
|
+
}
|
|
213
|
+
const bAlphaPost =
|
|
214
|
+
options.bucketBShadow === false
|
|
215
|
+
? { triggered: false, updatedOutput: rawOutput, savedTokens: 0 }
|
|
216
|
+
: runBucketBPostToolPass({
|
|
217
|
+
platform: 'claude',
|
|
218
|
+
sessionId,
|
|
219
|
+
cwd: event.cwd || options.cwd || '',
|
|
220
|
+
hasExplicitCwd,
|
|
221
|
+
toolName,
|
|
222
|
+
toolInput: event.tool_input || event.toolInput || {},
|
|
223
|
+
rawOutput,
|
|
224
|
+
lastUserPrompt: event.prompt || loadedPriorSnap?.lastUserPrompt || '',
|
|
225
|
+
activeFiles: event.activeFiles || loadedPriorSnap?.modifiedFilesInTurn || [],
|
|
226
|
+
dirtyFiles: event.dirtyFiles || [],
|
|
227
|
+
lastEditedFile:
|
|
228
|
+
event.lastEditedFile || (loadedPriorSnap?.modifiedFilesInTurn || []).slice(-1)[0] || '',
|
|
229
|
+
webFetchesInTurn: Number(event.webFetchesInTurn || 1),
|
|
230
|
+
options: {
|
|
231
|
+
...options,
|
|
232
|
+
mode: event.mode || options.mode || horizonConfig.flightMode,
|
|
233
|
+
horizonConfig
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const effectiveRawOutput = bAlphaPost.triggered ? bAlphaPost.updatedOutput : rawOutput;
|
|
238
|
+
|
|
239
|
+
const sanitized = sanitizePostToolOutput(
|
|
240
|
+
{
|
|
241
|
+
toolName,
|
|
242
|
+
toolOutput: effectiveRawOutput
|
|
243
|
+
},
|
|
244
|
+
cwdOptions
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
let finalOutput = sanitized.updatedToolOutput;
|
|
248
|
+
let wasModified = sanitized.sanitized || Boolean(bAlphaPost.triggered);
|
|
249
|
+
|
|
250
|
+
// Apply DET-19 IPI sanitizer if output comes from a subagent (Task/Agent/agentId) or external WebFetch/MCP tool
|
|
251
|
+
const isSubagentSource =
|
|
252
|
+
Boolean(event.agentId || event.subagentId) || /^(Task|Agent)$/i.test(toolName);
|
|
253
|
+
const isUntrustedSource =
|
|
254
|
+
isSubagentSource || /^(WebFetch|mcp__.+)$/i.test(toolName);
|
|
255
|
+
|
|
256
|
+
if (
|
|
257
|
+
isUntrustedSource &&
|
|
258
|
+
finalOutput &&
|
|
259
|
+
resolveDetectorOverride('DET-19', horizonConfig) !== 'off'
|
|
260
|
+
) {
|
|
261
|
+
const ipi = evaluateDet19SubagentIpiSanitizer({
|
|
262
|
+
text: finalOutput,
|
|
263
|
+
wrapUntrusted: isSubagentSource
|
|
264
|
+
});
|
|
265
|
+
if (ipi.triggered || isSubagentSource) {
|
|
266
|
+
finalOutput = ipi.sanitizedText;
|
|
267
|
+
wasModified = true;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const totalSavedTokens = sanitized.savedTokens + Number(bAlphaPost.savedTokens || 0);
|
|
272
|
+
if (
|
|
273
|
+
totalSavedTokens > 0 &&
|
|
274
|
+
options.recordLedger !== false &&
|
|
275
|
+
(sanitized.savedTokens > 0 || hasExplicitCwd || options.ledgerPath || options.recordLedger === true)
|
|
276
|
+
) {
|
|
277
|
+
const liveState = options.telemetryState || readLiveStateSnapshot(sessionId, cwdOptions);
|
|
278
|
+
const rawEventModel =
|
|
279
|
+
typeof event.model === 'string'
|
|
280
|
+
? event.model
|
|
281
|
+
: event.model?.id || event.model?.model_id || event.modelId || event.model_id;
|
|
282
|
+
const modelId = rawEventModel || liveState?.modelId || 'claude-sonnet-5-5';
|
|
283
|
+
const usageSource =
|
|
284
|
+
event.usage || event.context_window?.current_usage || liveState?.contextWindow || {};
|
|
285
|
+
const totalPromptTokens = computeTotalPromptTokens(usageSource);
|
|
286
|
+
const rates = resolveEffectiveRates(modelId, totalPromptTokens, cwdOptions);
|
|
287
|
+
const computedSavedUSD =
|
|
288
|
+
rates && !rates.unknownModel && Number.isFinite(rates.inputPer1M)
|
|
289
|
+
? Number(((totalSavedTokens / 1_000_000) * rates.inputPer1M).toFixed(6))
|
|
290
|
+
: 0;
|
|
291
|
+
|
|
292
|
+
recordSavingsReceipt(
|
|
293
|
+
{
|
|
294
|
+
sessionId,
|
|
295
|
+
modelId: rates.unknownModel ? (rates.rawModelId || modelId) : rates.modelId,
|
|
296
|
+
category: sanitized.offloaded
|
|
297
|
+
? 'ARTIFACT_OFFLOAD_4K'
|
|
298
|
+
: sanitized.savedTokens > 0
|
|
299
|
+
? 'LOSSLESS_POST_SANITIZER'
|
|
300
|
+
: bAlphaPost.code || 'BUCKET_B_POST_SHIELD',
|
|
301
|
+
savedTokens: totalSavedTokens,
|
|
302
|
+
savedUSD: computedSavedUSD,
|
|
303
|
+
detail: `${toolName} output compressed (+${totalSavedTokens} tokens saved)`
|
|
304
|
+
},
|
|
305
|
+
cwdOptions
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (!wasModified) {
|
|
310
|
+
return {
|
|
311
|
+
exitCode: 0,
|
|
312
|
+
stdout: '',
|
|
313
|
+
stderr: '',
|
|
314
|
+
sanitized
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// ISS-034: updatedMCPToolOutput applies strictly to MCP tools; built-in tools use additionalContext!
|
|
319
|
+
const isMcpTool = /^mcp__/i.test(toolName);
|
|
320
|
+
const hookSpecificOutput = isMcpTool
|
|
321
|
+
? {
|
|
322
|
+
hookEventName: 'PostToolUse',
|
|
323
|
+
updatedMCPToolOutput: finalOutput
|
|
324
|
+
}
|
|
325
|
+
: {
|
|
326
|
+
hookEventName: 'PostToolUse',
|
|
327
|
+
additionalContext: finalOutput
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
return {
|
|
331
|
+
exitCode: 0,
|
|
332
|
+
stdout: JSON.stringify({ hookSpecificOutput }),
|
|
333
|
+
stderr: '',
|
|
334
|
+
sanitized,
|
|
335
|
+
hookSpecificOutput
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* CLI runner for `PostToolUse` (`ISS-035`).
|
|
341
|
+
* Non-blocking post hook: logs diagnostic to stderr and exits `0` on uncaught error.
|
|
342
|
+
*
|
|
343
|
+
* @param {object} [cliOptions={}]
|
|
344
|
+
*/
|
|
345
|
+
export async function executePostToolUseCli(cliOptions = {}) {
|
|
346
|
+
const readPayload = cliOptions.readPayload || readStdinJsonAsync;
|
|
347
|
+
const runHook = cliOptions.runHook || runPostToolUseHook;
|
|
348
|
+
const ioOverride = cliOptions.ioOverride || {};
|
|
349
|
+
try {
|
|
350
|
+
const payload = await readPayload(cliOptions.timeoutMs);
|
|
351
|
+
const res = runHook(payload, { persistState: true, ...(cliOptions.hookOptions || {}) });
|
|
352
|
+
if (res.stdout) {
|
|
353
|
+
exitWithStdoutJson(res.stdout, ioOverride);
|
|
354
|
+
} else {
|
|
355
|
+
exitPassThrough(ioOverride.exitFn);
|
|
356
|
+
}
|
|
357
|
+
} catch (err) {
|
|
358
|
+
exitDiagnosticZero(err?.message || String(err), 'PostToolUse', ioOverride);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (isCliEntrypoint(import.meta.url)) {
|
|
363
|
+
executePostToolUseCli().catch((err) => {
|
|
364
|
+
exitDiagnosticZero(err?.message || String(err), 'PostToolUse');
|
|
365
|
+
});
|
|
366
|
+
}
|