@pushary/agent-hooks 1.7.3 → 1.8.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/CHANGELOG.md +10 -0
- package/README.md +13 -1
- package/data/cursor-plugin/scripts/pushary-gate.mjs +2 -21
- package/data/cursor-plugin/scripts/redaction.mjs +51 -0
- package/data/vscode-plugin/scripts/pushary-gate.mjs +1 -21
- package/data/vscode-plugin/scripts/redaction.mjs +51 -0
- package/dist/bin/pushary-bell-hook.js +23 -23
- package/dist/bin/pushary-bell.js +9 -9
- package/dist/bin/pushary-claude.js +26 -26
- package/dist/bin/pushary-clean.js +91 -107
- package/dist/bin/pushary-codex-bridge.js +18 -18
- package/dist/bin/pushary-codex-hook.js +42 -43
- package/dist/bin/pushary-codex.js +13 -13
- package/dist/bin/pushary-connect.js +13 -13
- package/dist/bin/pushary-cowork.js +5 -5
- package/dist/bin/pushary-daemon.js +27 -27
- package/dist/bin/pushary-disconnect.js +18 -18
- package/dist/bin/pushary-doctor.js +85 -79
- package/dist/bin/pushary-elicitation-hook.js +25 -25
- package/dist/bin/pushary-gemini-bridge.js +12 -12
- package/dist/bin/pushary-gemini-hook.js +29 -30
- package/dist/bin/pushary-hook.js +32 -32
- package/dist/bin/pushary-login.js +12 -12
- package/dist/bin/pushary-logout.js +7 -7
- package/dist/bin/pushary-mcp.js +85 -28
- package/dist/bin/pushary-mode.js +9 -9
- package/dist/bin/pushary-notification-hook.js +28 -28
- package/dist/bin/pushary-opencode-hook.js +28 -29
- package/dist/bin/pushary-permission-denied-hook.js +32 -32
- package/dist/bin/pushary-permission-hook.js +31 -31
- package/dist/bin/pushary-post-hook.js +28 -28
- package/dist/bin/pushary-prompt-hook.js +28 -28
- package/dist/bin/pushary-session-end-hook.js +28 -28
- package/dist/bin/pushary-session-start-hook.js +32 -32
- package/dist/bin/pushary-setup.js +60 -127
- package/dist/bin/pushary-stats.js +5 -5
- package/dist/bin/pushary-status.js +15 -15
- package/dist/bin/pushary-stop-hook.js +28 -28
- package/dist/bin/pushary-stopfailure-hook.js +28 -28
- package/dist/bin/pushary-suggestions.js +4 -4
- package/dist/bin/pushary-transcript-register.js +19 -19
- package/dist/bin/pushary-transcripts.js +7 -7
- package/dist/bin/pushary-upgrade.js +231 -105
- package/dist/bin/pushary-wait.js +9 -9
- package/dist/bin/pushary.js +6 -6
- package/dist/{chunk-EEEJ2JIL.js → chunk-2ABTSGFT.js} +3 -3
- package/dist/{chunk-DUQO4C4I.js → chunk-2OY3ZZ5N.js} +3 -3
- package/dist/{chunk-MIXWMA73.js → chunk-3EVPNIBE.js} +3 -3
- package/dist/{chunk-WTJM7PSL.js → chunk-6J2JC2RT.js} +3 -3
- package/dist/{chunk-EADXTSHE.js → chunk-7Z7Q4GGS.js} +2 -2
- package/dist/{chunk-MZBRL5H5.js → chunk-A2A2YTMG.js} +108 -25
- package/dist/{chunk-KEL5MXRL.js → chunk-AHV4LNB5.js} +1 -1
- package/dist/{chunk-G3OMOTJ4.js → chunk-AXPCESYO.js} +3 -3
- package/dist/{chunk-3EUBQARL.js → chunk-C2WCPBF7.js} +1 -1
- package/dist/chunk-CJVVKOSR.js +73 -0
- package/dist/{chunk-U6RVDUJ5.js → chunk-CULUZTWQ.js} +283 -41
- package/dist/{chunk-N5MZH5A6.js → chunk-CVQYGMSR.js} +4 -4
- package/dist/{chunk-VKVSRCBO.js → chunk-D2FX3EPW.js} +1 -1
- package/dist/{chunk-62CVUUNU.js → chunk-DB3ONZB4.js} +2 -2
- package/dist/{chunk-WGMW7OXW.js → chunk-DE4Y6TCC.js} +6 -6
- package/dist/{chunk-YYCTF4Q5.js → chunk-E4FJTUH4.js} +1 -1
- package/dist/{chunk-EUGNVLMG.js → chunk-EPCXUP3P.js} +3 -1
- package/dist/{chunk-PRNFSORD.js → chunk-EX3GAPA4.js} +1 -1
- package/dist/{chunk-TCVMK6GI.js → chunk-EYK3GSRH.js} +4 -4
- package/dist/{chunk-R6OYCUNK.js → chunk-GPEGOGRJ.js} +1 -1
- package/dist/chunk-GU3EJCVV.js +43 -0
- package/dist/{chunk-Y4ZH64UK.js → chunk-HQ6G3B5R.js} +2 -2
- package/dist/{chunk-5S2VBSJI.js → chunk-HZVVNGEW.js} +2 -2
- package/dist/{chunk-IWJKSIB4.js → chunk-IPVKH2ST.js} +1 -1
- package/dist/{chunk-UOQRM7JQ.js → chunk-J5TIV3J6.js} +5 -5
- package/dist/{chunk-IRZG3HEU.js → chunk-JU6W3XAU.js} +1 -1
- package/dist/{chunk-G62JL2NT.js → chunk-JYG4B33G.js} +1 -1
- package/dist/{chunk-OTNOANMX.js → chunk-JZTHGAPA.js} +8 -8
- package/dist/{chunk-7RUJKCR4.js → chunk-KGDWDSNL.js} +2 -2
- package/dist/{chunk-6JQFIHZC.js → chunk-KVQBWI5T.js} +3 -3
- package/dist/{chunk-OVC5QXN5.js → chunk-LXQ5FBBD.js} +1 -1
- package/dist/{chunk-VE7TXLR4.js → chunk-M5ICYGHT.js} +3 -3
- package/dist/{chunk-YPUBA2FL.js → chunk-M5JDZ45W.js} +4 -4
- package/dist/{chunk-O3JDWNLU.js → chunk-MDEPU45E.js} +183 -28
- package/dist/{chunk-P2VIBGXA.js → chunk-MPWXGONV.js} +1 -1
- package/dist/{chunk-YC27PROF.js → chunk-NGDD6TXY.js} +20 -5
- package/dist/{chunk-G4GLCLKK.js → chunk-NQTHFF4W.js} +138 -17
- package/dist/{chunk-NOI3XTCY.js → chunk-OKXS7WDZ.js} +1 -1
- package/dist/{chunk-LPNJLKBQ.js → chunk-OLQRRFBX.js} +1 -1
- package/dist/{chunk-D6OODZCM.js → chunk-P7WQEVWA.js} +2 -2
- package/dist/{chunk-62VT3BPH.js → chunk-Q7E4I6UA.js} +28 -16
- package/dist/{chunk-BIH2Y2HP.js → chunk-R7437YI3.js} +2 -2
- package/dist/{chunk-RLW3JWDY.js → chunk-RHR6NARM.js} +2 -2
- package/dist/{chunk-WPX67AKT.js → chunk-SAXBC4AZ.js} +1 -1
- package/dist/{chunk-IPSRMLCJ.js → chunk-SIFVFP6T.js} +1 -1
- package/dist/{chunk-7OA34PNW.js → chunk-SLFABHW3.js} +40 -10
- package/dist/{chunk-AWVNAYGD.js → chunk-TY4JT7W3.js} +1 -1
- package/dist/{chunk-KJXUIPS4.js → chunk-UI36QSBI.js} +28 -16
- package/dist/{chunk-G6RRVJOG.js → chunk-VQKRG3AC.js} +6 -6
- package/dist/{chunk-ZKJ34T2F.js → chunk-WE2J62NC.js} +31 -17
- package/dist/{chunk-LHC45YUC.js → chunk-ZSZSSJCV.js} +1 -1
- package/dist/{chunk-BGBLLHZ4.js → chunk-ZVSKMPBZ.js} +1 -1
- package/dist/{reapply-PH5T4BGR.js → reapply-CW3MA66V.js} +9 -9
- package/dist/src/index.js +20 -20
- package/package.json +1 -1
- package/dist/chunk-5GB22QYL.js +0 -255
- package/dist/chunk-VYPJHGG6.js +0 -92
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SETUP_FLAGS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZVSKMPBZ.js";
|
|
4
4
|
import {
|
|
5
5
|
parseFlags
|
|
6
6
|
} from "./chunk-GMXKITVA.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
CLAUDE_CONNECTOR_URL,
|
|
15
15
|
COWORK_CONNECTOR_LIMIT,
|
|
16
16
|
COWORK_STANDING_INSTRUCTIONS
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-NQTHFF4W.js";
|
|
18
18
|
|
|
19
19
|
// src/cli/cowork.ts
|
|
20
20
|
import { readFileSync } from "fs";
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CLI_PACKAGE_NAMES,
|
|
2
3
|
HOOK_BUDGETS,
|
|
3
4
|
HOOK_LOCATOR_BINARY,
|
|
5
|
+
OWNERSHIP_PROBE_COMMAND,
|
|
6
|
+
classifyGlobalFolder,
|
|
7
|
+
classifyGlobalInstall,
|
|
8
|
+
cmdShimTarget,
|
|
9
|
+
decideCommandOwner,
|
|
10
|
+
globalInstallTarget,
|
|
11
|
+
globalPackageFolder,
|
|
12
|
+
globalRootFor,
|
|
4
13
|
isReleaseVersion,
|
|
14
|
+
ownPackageName,
|
|
5
15
|
withHookHoldBudget
|
|
6
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-NQTHFF4W.js";
|
|
7
17
|
|
|
8
18
|
// src/npm.ts
|
|
9
19
|
import { execFileSync, execSync } from "child_process";
|
|
10
|
-
import { existsSync, readFileSync, realpathSync } from "fs";
|
|
20
|
+
import { existsSync, readFileSync, readlinkSync, realpathSync } from "fs";
|
|
11
21
|
import { dirname, isAbsolute, join, relative, resolve } from "path";
|
|
12
|
-
var
|
|
13
|
-
var LATEST_RELEASE_URL = `https://registry.npmjs.org/${AGENT_HOOKS_PACKAGE}/latest`;
|
|
22
|
+
var latestReleaseUrl = (packageName) => `https://registry.npmjs.org/${packageName}/latest`;
|
|
14
23
|
var REGISTRY_TIMEOUT_MS = 5e3;
|
|
15
24
|
var LATEST_TAG = "latest";
|
|
16
25
|
var cleanNpmEnv = () => {
|
|
@@ -36,15 +45,21 @@ var execNpm = (args, options = {}) => {
|
|
|
36
45
|
env: { ...cleanNpmEnv(), ...options.env ?? {} }
|
|
37
46
|
});
|
|
38
47
|
};
|
|
39
|
-
var
|
|
48
|
+
var GLOBAL_PREFIX_TIMEOUT_MS = 5e3;
|
|
49
|
+
var readGlobalPrefix = () => {
|
|
40
50
|
try {
|
|
41
|
-
const prefix = execNpm("prefix -g --no-workspaces", { timeout:
|
|
42
|
-
|
|
43
|
-
return candidates.find(existsSync);
|
|
51
|
+
const prefix = execNpm("prefix -g --no-workspaces", { timeout: GLOBAL_PREFIX_TIMEOUT_MS }).toString().trim();
|
|
52
|
+
return prefix === "" ? void 0 : prefix;
|
|
44
53
|
} catch {
|
|
45
54
|
return void 0;
|
|
46
55
|
}
|
|
47
56
|
};
|
|
57
|
+
var resolveGlobalBinary = (name) => {
|
|
58
|
+
const prefix = readGlobalPrefix();
|
|
59
|
+
if (prefix === void 0) return void 0;
|
|
60
|
+
const candidates = process.platform === "win32" ? [join(prefix, `${name}.cmd`), join(prefix, name)] : [join(prefix, "bin", name)];
|
|
61
|
+
return candidates.find(existsSync);
|
|
62
|
+
};
|
|
48
63
|
var resolvePathBinary = (name, platform = process.platform) => {
|
|
49
64
|
try {
|
|
50
65
|
return execFileSync(platform === "win32" ? "where" : "which", [name], {
|
|
@@ -155,29 +170,79 @@ var AGENT_HOOKS_RUNTIME_FILES = [
|
|
|
155
170
|
"data/cursor-plugin/hooks/hooks.json",
|
|
156
171
|
"data/cursor-plugin/mcp.json",
|
|
157
172
|
"data/cursor-plugin/scripts/pushary-gate.mjs",
|
|
173
|
+
"data/cursor-plugin/scripts/redaction.mjs",
|
|
158
174
|
"data/vscode-plugin/.claude-plugin/plugin.json",
|
|
159
175
|
"data/vscode-plugin/hooks/hooks.json",
|
|
160
176
|
"data/vscode-plugin/.mcp.json",
|
|
161
|
-
"data/vscode-plugin/scripts/pushary-gate.mjs"
|
|
177
|
+
"data/vscode-plugin/scripts/pushary-gate.mjs",
|
|
178
|
+
"data/vscode-plugin/scripts/redaction.mjs"
|
|
162
179
|
];
|
|
163
|
-
var globalPackageBinsPresent = (name) =>
|
|
180
|
+
var globalPackageBinsPresent = (name, prefix, platform) => packageBinsPresent(globalPackageFolder(globalRootFor(prefix, platform), name, platform), prefix, platform, AGENT_HOOKS_RUNTIME_FILES);
|
|
181
|
+
var errorCode = (error) => typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
182
|
+
var realpathOrUndefined = (path) => {
|
|
164
183
|
try {
|
|
165
|
-
|
|
166
|
-
const prefix = execNpm("prefix -g --no-workspaces", { timeout: 5e3 }).toString().trim();
|
|
167
|
-
return packageBinsPresent(join(root, ...name.split("/")), prefix, process.platform, AGENT_HOOKS_RUNTIME_FILES);
|
|
184
|
+
return realpathSync(path);
|
|
168
185
|
} catch {
|
|
169
|
-
return
|
|
186
|
+
return void 0;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
var definedPaths = (paths) => paths.filter((path) => path !== void 0);
|
|
190
|
+
var readPosixCommandLink = (prefix) => {
|
|
191
|
+
const command = join(prefix, "bin", OWNERSHIP_PROBE_COMMAND);
|
|
192
|
+
try {
|
|
193
|
+
const target = resolve(dirname(command), readlinkSync(command));
|
|
194
|
+
return { kind: "resolved", targets: definedPaths([target, realpathOrUndefined(command)]) };
|
|
195
|
+
} catch (error) {
|
|
196
|
+
if (errorCode(error) === "ENOENT") return { kind: "absent" };
|
|
197
|
+
const real = realpathOrUndefined(command);
|
|
198
|
+
return real === void 0 ? { kind: "unreadable" } : { kind: "resolved", targets: [real] };
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
var readWindowsCommandLink = (prefix) => {
|
|
202
|
+
const shim = join(prefix, `${OWNERSHIP_PROBE_COMMAND}.cmd`);
|
|
203
|
+
try {
|
|
204
|
+
const target = cmdShimTarget(prefix, readFileSync(shim, "utf8"));
|
|
205
|
+
return target === void 0 ? { kind: "unreadable" } : { kind: "resolved", targets: [target] };
|
|
206
|
+
} catch (error) {
|
|
207
|
+
return errorCode(error) === "ENOENT" ? { kind: "absent" } : { kind: "unreadable" };
|
|
170
208
|
}
|
|
171
209
|
};
|
|
210
|
+
var readCommandLink = (prefix, platform) => platform === "win32" ? readWindowsCommandLink(prefix) : readPosixCommandLink(prefix);
|
|
211
|
+
var readFolderManifest = (folder) => {
|
|
212
|
+
try {
|
|
213
|
+
return { kind: "read", manifest: JSON.parse(readFileSync(join(folder, "package.json"), "utf8")) };
|
|
214
|
+
} catch {
|
|
215
|
+
return { kind: "unreadable" };
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
var readGlobalFolder = (root, name, platform = process.platform) => classifyGlobalFolder(name, readFolderManifest(globalPackageFolder(root, name, platform)));
|
|
219
|
+
var installedIfOurs = (folder) => folder.kind === "ours" ? [folder.installed] : [];
|
|
220
|
+
var readInstalledCliPackages = (root, platform = process.platform) => CLI_PACKAGE_NAMES.flatMap((name) => installedIfOurs(readGlobalFolder(root, name, platform)));
|
|
221
|
+
var globalRootsFor = (prefix, platform) => {
|
|
222
|
+
const root = globalRootFor(prefix, platform);
|
|
223
|
+
return definedPaths([root, realpathOrUndefined(root)]);
|
|
224
|
+
};
|
|
225
|
+
var readCommandOwner = (prefix, platform = process.platform) => decideCommandOwner({
|
|
226
|
+
platform,
|
|
227
|
+
globalRoots: globalRootsFor(prefix, platform),
|
|
228
|
+
link: readCommandLink(prefix, platform),
|
|
229
|
+
installed: readInstalledCliPackages(globalRootFor(prefix, platform), platform).map((installed) => installed.name)
|
|
230
|
+
});
|
|
231
|
+
var NPM_UNAVAILABLE_OWNER = { kind: "unknown", reason: "npm_unavailable" };
|
|
232
|
+
var readGlobalCliInstallAt = (prefix, platform = process.platform) => classifyGlobalInstall(readInstalledCliPackages(globalRootFor(prefix, platform), platform), readCommandOwner(prefix, platform));
|
|
233
|
+
var readGlobalCliInstall = (platform = process.platform) => {
|
|
234
|
+
const prefix = readGlobalPrefix();
|
|
235
|
+
return prefix === void 0 ? { kind: "unavailable" } : readGlobalCliInstallAt(prefix, platform);
|
|
236
|
+
};
|
|
172
237
|
var resolveGlobalBinDir = (probe) => {
|
|
173
238
|
if (process.platform === "win32") return void 0;
|
|
174
239
|
const resolved = resolveGlobalBinary(probe);
|
|
175
240
|
return resolved ? resolved.slice(0, resolved.length - probe.length - 1) : void 0;
|
|
176
241
|
};
|
|
177
242
|
var quoteIfNeeded = (path) => /\s/.test(path) ? `"${path}"` : path;
|
|
178
|
-
var fetchLatestPublishedVersion = async (request
|
|
243
|
+
var fetchLatestPublishedVersion = async (request) => {
|
|
179
244
|
try {
|
|
180
|
-
const response = await (request.fetchImpl ?? fetch)(
|
|
245
|
+
const response = await (request.fetchImpl ?? fetch)(latestReleaseUrl(request.packageName), {
|
|
181
246
|
signal: AbortSignal.timeout(request.timeoutMs ?? REGISTRY_TIMEOUT_MS)
|
|
182
247
|
});
|
|
183
248
|
if (!response.ok) return void 0;
|
|
@@ -190,29 +255,42 @@ var fetchLatestPublishedVersion = async (request = {}) => {
|
|
|
190
255
|
};
|
|
191
256
|
var POSIX_SHELL_WORD = /^[\w@%+=:,./-]+$/;
|
|
192
257
|
var quoteForPosixShell = (value) => POSIX_SHELL_WORD.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
|
|
193
|
-
var
|
|
258
|
+
var installPackageGlobally = (request, runNpm = execNpm) => {
|
|
194
259
|
const prefixFlag = request.prefix === void 0 ? "" : ` --prefix ${quoteForPosixShell(request.prefix)}`;
|
|
195
|
-
const spec = quoteForPosixShell(`${
|
|
260
|
+
const spec = quoteForPosixShell(`${request.packageName}@${request.version}`);
|
|
196
261
|
runNpm(`install -g --no-workspaces${prefixFlag} ${spec}`, { timeout: request.timeoutMs });
|
|
197
262
|
};
|
|
198
263
|
var needsGlobalInstall = (requested, installed, binaryPresent) => requested !== installed || !binaryPresent;
|
|
264
|
+
var planGlobalInstall = (platform) => {
|
|
265
|
+
const prefix = readGlobalPrefix();
|
|
266
|
+
const owner = prefix === void 0 ? NPM_UNAVAILABLE_OWNER : readCommandOwner(prefix, platform);
|
|
267
|
+
return { prefix, packageName: globalInstallTarget(owner, ownPackageName()) };
|
|
268
|
+
};
|
|
269
|
+
var plannedGlobalPackage = () => planGlobalInstall(process.platform).packageName;
|
|
270
|
+
var installedVersionOf = (prefix, name, platform) => {
|
|
271
|
+
const folder = readGlobalFolder(globalRootFor(prefix, platform), name, platform);
|
|
272
|
+
return folder.kind === "ours" ? folder.installed.version : void 0;
|
|
273
|
+
};
|
|
274
|
+
var asCachedResult = (result) => result === "installed" ? "cached" : result;
|
|
199
275
|
var installState;
|
|
200
276
|
var installGlobally = (options) => {
|
|
201
277
|
if (installState) {
|
|
202
|
-
return installState.then(
|
|
278
|
+
return installState.then(asCachedResult);
|
|
203
279
|
}
|
|
204
280
|
const started = (async () => {
|
|
205
281
|
if (!npmIsOnPath()) throw new NpmMissingError();
|
|
282
|
+
const platform = process.platform;
|
|
283
|
+
const { prefix, packageName } = planGlobalInstall(platform);
|
|
206
284
|
const pinned = process.env.PUSHARY_PIN_GLOBAL_VERSION !== "0";
|
|
207
|
-
if (pinned && !needsGlobalInstall(
|
|
285
|
+
if (pinned && prefix !== void 0 && !needsGlobalInstall(
|
|
208
286
|
options.version,
|
|
209
|
-
|
|
210
|
-
globalPackageBinsPresent(
|
|
287
|
+
installedVersionOf(prefix, packageName, platform),
|
|
288
|
+
globalPackageBinsPresent(packageName, prefix, platform)
|
|
211
289
|
)) {
|
|
212
290
|
return "skipped";
|
|
213
291
|
}
|
|
214
292
|
const version = pinned && options.version && options.version !== "0.0.0" ? options.version : LATEST_TAG;
|
|
215
|
-
|
|
293
|
+
installPackageGlobally({ packageName, version, timeoutMs: options.timeoutMs ?? 12e4 });
|
|
216
294
|
return "installed";
|
|
217
295
|
})();
|
|
218
296
|
installState = started;
|
|
@@ -670,10 +748,11 @@ export {
|
|
|
670
748
|
registeredCommands,
|
|
671
749
|
namesOurBinary,
|
|
672
750
|
registrationHolderOf,
|
|
673
|
-
AGENT_HOOKS_PACKAGE,
|
|
674
751
|
LATEST_TAG,
|
|
752
|
+
cleanNpmEnv,
|
|
675
753
|
npmErrorMessage,
|
|
676
754
|
execNpm,
|
|
755
|
+
readGlobalPrefix,
|
|
677
756
|
resolveGlobalBinary,
|
|
678
757
|
resolvePathBinary,
|
|
679
758
|
npmIsOnPath,
|
|
@@ -682,9 +761,13 @@ export {
|
|
|
682
761
|
resolveBinary,
|
|
683
762
|
resolvePackageVersionFromBinary,
|
|
684
763
|
resolveGlobalPackageVersion,
|
|
764
|
+
readGlobalFolder,
|
|
765
|
+
readGlobalCliInstallAt,
|
|
766
|
+
readGlobalCliInstall,
|
|
685
767
|
resolveGlobalBinDir,
|
|
686
768
|
fetchLatestPublishedVersion,
|
|
687
|
-
|
|
769
|
+
installPackageGlobally,
|
|
770
|
+
plannedGlobalPackage,
|
|
688
771
|
installGlobally,
|
|
689
772
|
holdBudgetOf,
|
|
690
773
|
guardBinary,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CLAUDE_HOOK_EVENTS,
|
|
3
3
|
supportedClaudeEvents
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3EVPNIBE.js";
|
|
5
5
|
import {
|
|
6
6
|
guardBinary,
|
|
7
7
|
holdBudgetOf,
|
|
8
8
|
isProtectedByScope,
|
|
9
9
|
registerHookEntry
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-A2A2YTMG.js";
|
|
11
11
|
import {
|
|
12
12
|
HOOK_LOCATOR_BINARY,
|
|
13
13
|
withHookHoldBudget
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NQTHFF4W.js";
|
|
15
15
|
|
|
16
16
|
// src/claude-config.ts
|
|
17
17
|
import { join } from "path";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUTO_DECISION_WINDOW_MS,
|
|
3
|
+
claimThrottle,
|
|
4
|
+
deriveToolTarget,
|
|
5
|
+
permissionDeniedAction,
|
|
6
|
+
releaseThrottle,
|
|
7
|
+
reportEvent
|
|
8
|
+
} from "./chunk-CULUZTWQ.js";
|
|
9
|
+
import {
|
|
10
|
+
DEFAULT_SESSION
|
|
11
|
+
} from "./chunk-N6IOSZOE.js";
|
|
12
|
+
import {
|
|
13
|
+
machineDecisionFor,
|
|
14
|
+
shouldDeferToNativeMode,
|
|
15
|
+
wireVerdictFor
|
|
16
|
+
} from "./chunk-NQTHFF4W.js";
|
|
17
|
+
|
|
18
|
+
// src/machine-decision-audit.ts
|
|
19
|
+
import { basename } from "path";
|
|
20
|
+
var reportMachineDenial = async (input, verdict, agent) => {
|
|
21
|
+
const decision = machineDecisionFor(wireVerdictFor(verdict, 0));
|
|
22
|
+
if (!decision) return;
|
|
23
|
+
const sessionKey = input.session_id || DEFAULT_SESSION;
|
|
24
|
+
const toolTarget = deriveToolTarget(input.tool_name, input.tool_input);
|
|
25
|
+
const throttleKey = `machinedecision:${agent.type}:${sessionKey}:${input.tool_name}:${decision.origin}:${toolTarget ?? ""}`;
|
|
26
|
+
const throttle = claimThrottle(throttleKey, AUTO_DECISION_WINDOW_MS);
|
|
27
|
+
if (throttle === "throttled") return;
|
|
28
|
+
if (throttle === "unavailable") {
|
|
29
|
+
console.error("[Pushary] Could not access the audit throttle; reporting this denial without deduplication.");
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const response = await reportEvent({
|
|
33
|
+
event: "permission_denied",
|
|
34
|
+
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35
|
+
toolUseId: input.tool_use_id,
|
|
36
|
+
agentType: agent.type,
|
|
37
|
+
agentName: `${agent.label} - ${basename(input.cwd ?? process.cwd())}`,
|
|
38
|
+
action: permissionDeniedAction(input.tool_name),
|
|
39
|
+
sessionId: input.session_id,
|
|
40
|
+
decisionSource: "policy_auto",
|
|
41
|
+
decisionOrigin: decision.origin,
|
|
42
|
+
decisionOutcome: decision.outcome,
|
|
43
|
+
toolName: input.tool_name,
|
|
44
|
+
toolTarget
|
|
45
|
+
}, { maxAttempts: 1, timeoutMs: 800, requireOk: true, skipDrain: true });
|
|
46
|
+
if (response?.ok !== true) throw new Error("Audit delivery was not acknowledged");
|
|
47
|
+
} catch {
|
|
48
|
+
console.error("[Pushary] Could not record the machine denial. The action remains blocked; its audit delivery will be retried on the next matching denial.");
|
|
49
|
+
if (throttle === "passed") {
|
|
50
|
+
try {
|
|
51
|
+
releaseThrottle(throttleKey);
|
|
52
|
+
} catch {
|
|
53
|
+
console.error("[Pushary] Could not reset the failed audit throttle.");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/native-defer.ts
|
|
60
|
+
var nativeDeferOptions = () => {
|
|
61
|
+
const respect = process.env.PUSHARY_RESPECT_PERMISSION_MODE;
|
|
62
|
+
const bypass = process.env.PUSHARY_DEFER_BYPASS;
|
|
63
|
+
return {
|
|
64
|
+
respectPermissionMode: !(respect === "0" || respect === "false"),
|
|
65
|
+
deferBypass: bypass === "1" || bypass === "true"
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
var defersToNativeMode = (permissionMode, toolName) => shouldDeferToNativeMode(permissionMode, toolName, nativeDeferOptions());
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
reportMachineDenial,
|
|
72
|
+
defersToNativeMode
|
|
73
|
+
};
|