@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.cjs
CHANGED
|
@@ -813,6 +813,7 @@ var import_node_crypto = require("crypto");
|
|
|
813
813
|
var import_node_fs4 = require("fs");
|
|
814
814
|
var import_node_os2 = require("os");
|
|
815
815
|
var import_node_path2 = require("path");
|
|
816
|
+
var import_node_perf_hooks = require("perf_hooks");
|
|
816
817
|
var import_agent_core5 = require("@birdybeep/agent-core");
|
|
817
818
|
var import_claude_code4 = require("@birdybeep/claude-code");
|
|
818
819
|
var import_codex3 = require("@birdybeep/codex");
|
|
@@ -833,6 +834,21 @@ var HOOK_HARNESSES = [
|
|
|
833
834
|
"copilot"
|
|
834
835
|
];
|
|
835
836
|
var STDIN_READ_TIMEOUT_MS = 3e3;
|
|
837
|
+
var LEGACY_HOOK_RUNTIME_BUDGET_MS = 9e3;
|
|
838
|
+
function hookRuntimeBudgetMs(configuredTimeoutSeconds) {
|
|
839
|
+
if (configuredTimeoutSeconds === void 0 || !Number.isFinite(configuredTimeoutSeconds) || configuredTimeoutSeconds <= 0) {
|
|
840
|
+
return LEGACY_HOOK_RUNTIME_BUDGET_MS;
|
|
841
|
+
}
|
|
842
|
+
const configuredBudgetMs = Math.max(1, Math.floor(configuredTimeoutSeconds * 1e3) - 1e3);
|
|
843
|
+
return Math.min(LEGACY_HOOK_RUNTIME_BUDGET_MS, configuredBudgetMs);
|
|
844
|
+
}
|
|
845
|
+
function configuredHookTimeoutSeconds(harness) {
|
|
846
|
+
if (harness === "claude") return (0, import_claude_code4.configuredClaudeHookTimeoutSeconds)();
|
|
847
|
+
if (harness === "codex") return (0, import_codex3.configuredCodexHookTimeoutSeconds)();
|
|
848
|
+
if (harness === "cursor") return (0, import_cursor4.configuredCursorHookTimeoutSeconds)();
|
|
849
|
+
if (harness === "copilot") return (0, import_copilot3.configuredCopilotHookTimeoutSeconds)();
|
|
850
|
+
return void 0;
|
|
851
|
+
}
|
|
836
852
|
function withTimeout(promise, ms, fallback) {
|
|
837
853
|
return new Promise((resolve) => {
|
|
838
854
|
let settled = false;
|
|
@@ -953,15 +969,22 @@ function detachCodexNotifyWorker(payload) {
|
|
|
953
969
|
}
|
|
954
970
|
}
|
|
955
971
|
function createHookCommand(deps = {}) {
|
|
956
|
-
const makeSender = deps.createSender ?? ((baseUrl) => (0, import_agent_core5.createSender)({
|
|
972
|
+
const makeSender = deps.createSender ?? ((baseUrl, budgetMs) => (0, import_agent_core5.createSender)({
|
|
973
|
+
baseUrl,
|
|
974
|
+
timeoutMs: Math.min(import_agent_core5.DEFAULT_SEND_TIMEOUT_MS, budgetMs),
|
|
975
|
+
totalBudgetMs: budgetMs
|
|
976
|
+
}));
|
|
957
977
|
const readStdin = deps.readStdin ?? readStdinDefault;
|
|
958
978
|
const stdinTimeoutMs = deps.stdinTimeoutMs ?? STDIN_READ_TIMEOUT_MS;
|
|
979
|
+
const now = deps.now ?? (() => import_node_perf_hooks.performance.now());
|
|
980
|
+
const readConfiguredHookTimeoutSeconds = deps.configuredHookTimeoutSeconds ?? configuredHookTimeoutSeconds;
|
|
959
981
|
const detachCodexNotify = deps.detachCodexNotify ?? detachCodexNotifyWorker;
|
|
960
982
|
return {
|
|
961
983
|
name: "hook",
|
|
962
984
|
summary: "Internal: normalize + send an event fired by a harness hook",
|
|
963
985
|
usage: "birdybeep hook <claude|codex|opencode|cursor|copilot> [copilot-event]",
|
|
964
986
|
run: async (ctx) => {
|
|
987
|
+
const hookStartedAt = now();
|
|
965
988
|
const harness = ctx.args[0];
|
|
966
989
|
if (!isHarnessName(harness)) {
|
|
967
990
|
ctx.io.errline(`birdybeep hook: expected one of ${HOOK_HARNESSES.join("|")}`);
|
|
@@ -1027,7 +1050,10 @@ function createHookCommand(deps = {}) {
|
|
|
1027
1050
|
);
|
|
1028
1051
|
return EXIT.ERROR;
|
|
1029
1052
|
}
|
|
1030
|
-
const
|
|
1053
|
+
const runtimeBudgetMs = hookRuntimeBudgetMs(readConfiguredHookTimeoutSeconds(harness));
|
|
1054
|
+
const elapsedMs = Math.max(0, now() - hookStartedAt);
|
|
1055
|
+
const budgetMs = Math.max(1, Math.min(import_agent_core5.DEFAULT_TOTAL_BUDGET_MS, runtimeBudgetMs - elapsedMs));
|
|
1056
|
+
const sender = makeSender(resolveApiUrl(), budgetMs);
|
|
1031
1057
|
const result = await runHookCommand(harness, payload, sender, copilotEventName);
|
|
1032
1058
|
ctx.io.result({
|
|
1033
1059
|
harness: handler,
|
|
@@ -1188,7 +1214,7 @@ async function pairTokenPoll(apiUrl, deviceCode, fetchImpl, machineFingerprint,
|
|
|
1188
1214
|
}
|
|
1189
1215
|
|
|
1190
1216
|
// src/version.ts
|
|
1191
|
-
var CLI_VERSION = "0.8.
|
|
1217
|
+
var CLI_VERSION = "0.8.2".length > 0 ? "0.8.2" : "0.0.0";
|
|
1192
1218
|
|
|
1193
1219
|
// src/commands/setup.ts
|
|
1194
1220
|
var import_claude_code5 = require("@birdybeep/claude-code");
|