@birdybeep/cli 0.8.1 → 0.8.2
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/bin.cjs +29 -3
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-J45QGUDO.js → chunk-CZ4G735V.js} +49 -7
- package/dist/chunk-CZ4G735V.js.map +1 -0
- package/dist/index.cjs +29 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +7 -7
- package/dist/chunk-J45QGUDO.js.map +0 -1
package/dist/bin.js
CHANGED
|
@@ -227,7 +227,7 @@ async function dispatch(argv, deps) {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
// src/version.ts
|
|
230
|
-
var CLI_VERSION = "0.8.
|
|
230
|
+
var CLI_VERSION = "0.8.2".length > 0 ? "0.8.2" : "0.0.0";
|
|
231
231
|
|
|
232
232
|
// src/commands/agent.ts
|
|
233
233
|
import { claudeCodeAdapter } from "@birdybeep/claude-code";
|
|
@@ -820,18 +820,35 @@ import { randomBytes } from "crypto";
|
|
|
820
820
|
import { closeSync, openSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
821
821
|
import { tmpdir } from "os";
|
|
822
822
|
import { basename, dirname, join as join2 } from "path";
|
|
823
|
+
import { performance } from "perf_hooks";
|
|
823
824
|
import {
|
|
824
825
|
createSender as defaultCreateSender2,
|
|
826
|
+
DEFAULT_SEND_TIMEOUT_MS,
|
|
827
|
+
DEFAULT_TOTAL_BUDGET_MS,
|
|
825
828
|
resolveOnPath
|
|
826
829
|
} from "@birdybeep/agent-core";
|
|
827
|
-
import { isClaudeCodeHookPayload, runClaudeHook } from "@birdybeep/claude-code";
|
|
828
|
-
import { isCodexHookPayload, runCodexHook } from "@birdybeep/codex";
|
|
829
830
|
import {
|
|
831
|
+
configuredClaudeHookTimeoutSeconds,
|
|
832
|
+
isClaudeCodeHookPayload,
|
|
833
|
+
runClaudeHook
|
|
834
|
+
} from "@birdybeep/claude-code";
|
|
835
|
+
import {
|
|
836
|
+
configuredCodexHookTimeoutSeconds,
|
|
837
|
+
isCodexHookPayload,
|
|
838
|
+
runCodexHook
|
|
839
|
+
} from "@birdybeep/codex";
|
|
840
|
+
import {
|
|
841
|
+
configuredCopilotHookTimeoutSeconds,
|
|
830
842
|
isCopilotHookEventName,
|
|
831
843
|
isCopilotHookPayload,
|
|
832
844
|
runCopilotHook
|
|
833
845
|
} from "@birdybeep/copilot";
|
|
834
|
-
import {
|
|
846
|
+
import {
|
|
847
|
+
configuredCursorHookTimeoutSeconds,
|
|
848
|
+
isCursorHookEventName,
|
|
849
|
+
isCursorHookPayload,
|
|
850
|
+
runCursorHook
|
|
851
|
+
} from "@birdybeep/cursor";
|
|
835
852
|
import { isOpenCodeEventPayload, runOpenCodeHook } from "@birdybeep/opencode";
|
|
836
853
|
var RUNNERS = {
|
|
837
854
|
claude: runClaudeHook,
|
|
@@ -847,6 +864,21 @@ var HOOK_HARNESSES = [
|
|
|
847
864
|
"copilot"
|
|
848
865
|
];
|
|
849
866
|
var STDIN_READ_TIMEOUT_MS = 3e3;
|
|
867
|
+
var LEGACY_HOOK_RUNTIME_BUDGET_MS = 9e3;
|
|
868
|
+
function hookRuntimeBudgetMs(configuredTimeoutSeconds) {
|
|
869
|
+
if (configuredTimeoutSeconds === void 0 || !Number.isFinite(configuredTimeoutSeconds) || configuredTimeoutSeconds <= 0) {
|
|
870
|
+
return LEGACY_HOOK_RUNTIME_BUDGET_MS;
|
|
871
|
+
}
|
|
872
|
+
const configuredBudgetMs = Math.max(1, Math.floor(configuredTimeoutSeconds * 1e3) - 1e3);
|
|
873
|
+
return Math.min(LEGACY_HOOK_RUNTIME_BUDGET_MS, configuredBudgetMs);
|
|
874
|
+
}
|
|
875
|
+
function configuredHookTimeoutSeconds(harness) {
|
|
876
|
+
if (harness === "claude") return configuredClaudeHookTimeoutSeconds();
|
|
877
|
+
if (harness === "codex") return configuredCodexHookTimeoutSeconds();
|
|
878
|
+
if (harness === "cursor") return configuredCursorHookTimeoutSeconds();
|
|
879
|
+
if (harness === "copilot") return configuredCopilotHookTimeoutSeconds();
|
|
880
|
+
return void 0;
|
|
881
|
+
}
|
|
850
882
|
function withTimeout(promise, ms, fallback) {
|
|
851
883
|
return new Promise((resolve) => {
|
|
852
884
|
let settled = false;
|
|
@@ -967,15 +999,22 @@ function detachCodexNotifyWorker(payload) {
|
|
|
967
999
|
}
|
|
968
1000
|
}
|
|
969
1001
|
function createHookCommand(deps = {}) {
|
|
970
|
-
const makeSender = deps.createSender ?? ((baseUrl) => defaultCreateSender2({
|
|
1002
|
+
const makeSender = deps.createSender ?? ((baseUrl, budgetMs) => defaultCreateSender2({
|
|
1003
|
+
baseUrl,
|
|
1004
|
+
timeoutMs: Math.min(DEFAULT_SEND_TIMEOUT_MS, budgetMs),
|
|
1005
|
+
totalBudgetMs: budgetMs
|
|
1006
|
+
}));
|
|
971
1007
|
const readStdin = deps.readStdin ?? readStdinDefault;
|
|
972
1008
|
const stdinTimeoutMs = deps.stdinTimeoutMs ?? STDIN_READ_TIMEOUT_MS;
|
|
1009
|
+
const now = deps.now ?? (() => performance.now());
|
|
1010
|
+
const readConfiguredHookTimeoutSeconds = deps.configuredHookTimeoutSeconds ?? configuredHookTimeoutSeconds;
|
|
973
1011
|
const detachCodexNotify = deps.detachCodexNotify ?? detachCodexNotifyWorker;
|
|
974
1012
|
return {
|
|
975
1013
|
name: "hook",
|
|
976
1014
|
summary: "Internal: normalize + send an event fired by a harness hook",
|
|
977
1015
|
usage: "birdybeep hook <claude|codex|opencode|cursor|copilot> [copilot-event]",
|
|
978
1016
|
run: async (ctx) => {
|
|
1017
|
+
const hookStartedAt = now();
|
|
979
1018
|
const harness = ctx.args[0];
|
|
980
1019
|
if (!isHarnessName(harness)) {
|
|
981
1020
|
ctx.io.errline(`birdybeep hook: expected one of ${HOOK_HARNESSES.join("|")}`);
|
|
@@ -1041,7 +1080,10 @@ function createHookCommand(deps = {}) {
|
|
|
1041
1080
|
);
|
|
1042
1081
|
return EXIT.ERROR;
|
|
1043
1082
|
}
|
|
1044
|
-
const
|
|
1083
|
+
const runtimeBudgetMs = hookRuntimeBudgetMs(readConfiguredHookTimeoutSeconds(harness));
|
|
1084
|
+
const elapsedMs = Math.max(0, now() - hookStartedAt);
|
|
1085
|
+
const budgetMs = Math.max(1, Math.min(DEFAULT_TOTAL_BUDGET_MS, runtimeBudgetMs - elapsedMs));
|
|
1086
|
+
const sender = makeSender(resolveApiUrl(), budgetMs);
|
|
1045
1087
|
const result = await runHookCommand(harness, payload, sender, copilotEventName);
|
|
1046
1088
|
ctx.io.result({
|
|
1047
1089
|
harness: handler,
|
|
@@ -2262,4 +2304,4 @@ export {
|
|
|
2262
2304
|
buildCommands,
|
|
2263
2305
|
runCli
|
|
2264
2306
|
};
|
|
2265
|
-
//# sourceMappingURL=chunk-
|
|
2307
|
+
//# sourceMappingURL=chunk-CZ4G735V.js.map
|