This commit is contained in:
Oleg Maslov
2026-09-02 10:14:22 +02:00
parent 0c3e2ead3b
commit b20b138fe4
771 changed files with 161561 additions and 9027 deletions

View File

@@ -64,6 +64,7 @@ export interface PreCompactExtracted {
const DEFAULT_RECALL_LIMIT = 20;
const PER_HIT_CONTENT_BUDGET = 240;
const DEFAULT_SUMMARY_BUDGET_CHARS = 400;
const DEFAULT_HOOK_SIGNAL_TIMEOUT_MS = 500;
export interface SessionStartOpts {
recallLimit?: number;
@@ -213,7 +214,10 @@ export async function runStopBody(
memoryWorkspace: result.workspace,
cwd: payload.cwd,
},
{ senderId: `${a.source}-hook` },
{
senderId: `${a.source}-hook`,
timeoutMs: DEFAULT_HOOK_SIGNAL_TIMEOUT_MS,
},
);
if (emitted) ctx.logger.debug('stop signal emitted', { id: emitted.id });
}

View File

@@ -58,6 +58,24 @@ export interface HookRunOptions {
}
const DEFAULT_LOGGER_PREFIX = 'hive-mind-hooks';
const HOOK_CLI_TIMEOUT_MS = 2_500;
/**
* Lifecycle hooks must fail open before Codex/Cursor's 5-second host timeout.
* One bounded attempt prevents the bridge default (four attempts) from keeping
* the host waiting after a stalled CLI process.
*/
export function buildHookBridgeOptions(
logger: Logger,
cliPath?: string,
): CliBridgeOptions {
return {
logger,
timeout_ms: HOOK_CLI_TIMEOUT_MS,
max_retries: 0,
...(cliPath !== undefined ? { cli_path: cliPath } : {}),
};
}
/**
* Parse `--cli-path <value>` from argv. Used by hook scripts to thread
@@ -129,8 +147,7 @@ export async function runHook<TPayload, TStdoutPayload>(
const reader = opts.readStdin ?? readStdinAsString;
const argv = opts.argv ?? process.argv.slice(2);
const argvFlags = parseHookArgs(argv);
const bridgeOpts: CliBridgeOptions = { logger };
if (argvFlags.cliPath !== undefined) bridgeOpts.cli_path = argvFlags.cliPath;
const bridgeOpts = buildHookBridgeOptions(logger, argvFlags.cliPath);
const bridge = opts.bridge ?? createCliBridge(bridgeOpts);
try {

View File

@@ -27,3 +27,6 @@ export * from './handlers-core.js';
// Fail-open hook runner + stdin/argv helpers (re-authored from the CC _shared.ts).
export * from './hook-shared.js';
// Cross-platform entrypoint detection for executable hook modules.
export { isDirectExecution } from '@waggle/hive-mind-shim-core';