@pushary/agent-hooks 0.25.0 → 0.26.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.
Files changed (94) hide show
  1. package/dist/bin/pushary-clean.js +1 -1
  2. package/dist/bin/pushary-codex-hook.js +1 -1
  3. package/dist/bin/pushary-codex.js +1 -1
  4. package/dist/bin/pushary-doctor.js +21 -9
  5. package/dist/bin/pushary-gemini-hook.js +1 -1
  6. package/dist/bin/pushary-hook.js +2 -2
  7. package/dist/bin/pushary-post-hook.js +1 -1
  8. package/dist/bin/pushary-prompt-hook.js +1 -1
  9. package/dist/bin/pushary-setup.js +7 -19
  10. package/dist/bin/pushary-stop-hook.js +1 -1
  11. package/dist/{chunk-GYPPVD3P.js → chunk-A7DQCA2N.js} +1 -1
  12. package/dist/{chunk-O2QL6U6G.js → chunk-SA4BDS7T.js} +1 -1
  13. package/dist/{chunk-JPRRYC5X.js → chunk-SLX4AONG.js} +25 -0
  14. package/dist/src/index.js +2 -2
  15. package/package.json +1 -1
  16. package/dist/chunk-22CV7V7A.js +0 -38
  17. package/dist/chunk-2BE2IPMO.js +0 -315
  18. package/dist/chunk-2CRLBMOX.js +0 -244
  19. package/dist/chunk-2HMNOZPY.js +0 -109
  20. package/dist/chunk-2I6DLXJN.js +0 -219
  21. package/dist/chunk-2Q6XPZ4Q.js +0 -395
  22. package/dist/chunk-3LC4YUMA.js +0 -194
  23. package/dist/chunk-3MIR7ODJ.js +0 -112
  24. package/dist/chunk-3QZESA66.js +0 -222
  25. package/dist/chunk-4Z4MB37G.js +0 -96
  26. package/dist/chunk-5GFUI5N6.js +0 -132
  27. package/dist/chunk-5JEDLXEC.js +0 -99
  28. package/dist/chunk-5LTQNC7R.js +0 -824
  29. package/dist/chunk-5QHQVXWN.js +0 -174
  30. package/dist/chunk-6A3WCJO2.js +0 -416
  31. package/dist/chunk-6QWFMVCD.js +0 -328
  32. package/dist/chunk-6SRXMZAN.js +0 -99
  33. package/dist/chunk-7PTU7TGE.js +0 -96
  34. package/dist/chunk-AB4KX4XT.js +0 -109
  35. package/dist/chunk-AC4UYAGX.js +0 -136
  36. package/dist/chunk-ACE77TKQ.js +0 -328
  37. package/dist/chunk-BHAMEPOP.js +0 -323
  38. package/dist/chunk-BYNYYZWW.js +0 -412
  39. package/dist/chunk-C5TFTNHG.js +0 -244
  40. package/dist/chunk-CH53PBQN.js +0 -265
  41. package/dist/chunk-DF3BM6BF.js +0 -195
  42. package/dist/chunk-DKZVKEOW.js +0 -175
  43. package/dist/chunk-EMPL27ZV.js +0 -96
  44. package/dist/chunk-EQJXMEIR.js +0 -175
  45. package/dist/chunk-FGZZRCOG.js +0 -194
  46. package/dist/chunk-FXYTRZHC.js +0 -177
  47. package/dist/chunk-GTJGZBTQ.js +0 -328
  48. package/dist/chunk-HJMFYDWY.js +0 -222
  49. package/dist/chunk-HRQEECB6.js +0 -315
  50. package/dist/chunk-HWEMAAOY.js +0 -370
  51. package/dist/chunk-IBWCHA5M.js +0 -10
  52. package/dist/chunk-KTM4ZQ3W.js +0 -96
  53. package/dist/chunk-KTP2EPVB.js +0 -27
  54. package/dist/chunk-KYARP7KP.js +0 -97
  55. package/dist/chunk-M2N5DYWN.js +0 -247
  56. package/dist/chunk-M4GDBGXF.js +0 -824
  57. package/dist/chunk-M5F2L4KF.js +0 -177
  58. package/dist/chunk-M6S3M6E3.js +0 -244
  59. package/dist/chunk-N7VXDBQU.js +0 -6
  60. package/dist/chunk-O6A5RHWY.js +0 -122
  61. package/dist/chunk-ODUXELPM.js +0 -219
  62. package/dist/chunk-OF5WIOYS.js +0 -129
  63. package/dist/chunk-OP4QAN23.js +0 -99
  64. package/dist/chunk-P4JH2Q7Z.js +0 -102
  65. package/dist/chunk-PMD5JSV3.js +0 -242
  66. package/dist/chunk-PSSHNBEL.js +0 -177
  67. package/dist/chunk-QEPRH7JB.js +0 -315
  68. package/dist/chunk-QRXWPZKN.js +0 -308
  69. package/dist/chunk-QY4L6XHN.js +0 -384
  70. package/dist/chunk-RNWPCELY.js +0 -176
  71. package/dist/chunk-RSHN2AQ7.js +0 -29
  72. package/dist/chunk-RZLVE57X.js +0 -38
  73. package/dist/chunk-SDCIKREA.js +0 -241
  74. package/dist/chunk-SDREQWNI.js +0 -175
  75. package/dist/chunk-SH26ZOHU.js +0 -159
  76. package/dist/chunk-TRLBBLSS.js +0 -176
  77. package/dist/chunk-U6OXZPYC.js +0 -384
  78. package/dist/chunk-UIBTFZUD.js +0 -314
  79. package/dist/chunk-USUCPCUC.js +0 -156
  80. package/dist/chunk-V4GLWPD7.js +0 -174
  81. package/dist/chunk-VC6U3QGF.js +0 -142
  82. package/dist/chunk-VIST7ACL.js +0 -88
  83. package/dist/chunk-VUNL35KE.js +0 -16
  84. package/dist/chunk-VWBNI4SC.js +0 -174
  85. package/dist/chunk-W5KRWUNE.js +0 -262
  86. package/dist/chunk-WCGKLHCL.js +0 -154
  87. package/dist/chunk-WNXGIEX7.js +0 -219
  88. package/dist/chunk-WPVL6VIT.js +0 -160
  89. package/dist/chunk-XPVSZIA3.js +0 -315
  90. package/dist/chunk-Y633ZIJF.js +0 -384
  91. package/dist/chunk-YCL4GUFR.js +0 -222
  92. package/dist/chunk-YTMKB44I.js +0 -220
  93. package/dist/chunk-ZWBS3T7Q.js +0 -244
  94. package/dist/pushary-mode-T7XOPI6Z.js +0 -83
@@ -1,136 +0,0 @@
1
- // src/claude-config.ts
2
- var PUSHARY_MCP_URL = "https://pushary.com/api/mcp/mcp";
3
- var PUSHARY_PERMISSION_RULE = "mcp__pushary__*";
4
- var asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
5
- var ensureRecord = (target, key) => {
6
- const existing = asRecord(target[key]);
7
- if (existing) return existing;
8
- const created = {};
9
- target[key] = created;
10
- return created;
11
- };
12
- var isPusharyPermission = (rule) => typeof rule === "string" && (rule.includes("pushary") || rule.includes("MCP(pushary"));
13
- var isPusharyHook = (entry) => {
14
- const hooks = asRecord(entry)?.hooks;
15
- if (!Array.isArray(hooks)) return false;
16
- return hooks.some((hook) => {
17
- const command = String(asRecord(hook)?.command ?? "");
18
- return command.includes("pushary-hook") || command.includes("pushary-post-hook") || command.includes("pushary-stop-hook");
19
- });
20
- };
21
- var addClaudeMcpServer = (config, apiKey) => {
22
- const mcpServers = ensureRecord(config, "mcpServers");
23
- mcpServers.pushary = {
24
- type: "http",
25
- url: PUSHARY_MCP_URL,
26
- headers: { Authorization: `Bearer ${apiKey}` }
27
- };
28
- };
29
- var removeClaudeMcpServers = (config) => {
30
- let changed = false;
31
- const removeFrom = (target) => {
32
- const mcpServers = asRecord(target.mcpServers);
33
- if (!mcpServers?.pushary) return;
34
- delete mcpServers.pushary;
35
- if (Object.keys(mcpServers).length === 0) delete target.mcpServers;
36
- changed = true;
37
- };
38
- removeFrom(config);
39
- const projects = asRecord(config.projects);
40
- if (projects) {
41
- for (const project of Object.values(projects)) {
42
- const projectConfig = asRecord(project);
43
- if (projectConfig) removeFrom(projectConfig);
44
- }
45
- }
46
- return changed;
47
- };
48
- var addPusharyToolPermissions = (settings) => {
49
- const permissions = ensureRecord(settings, "permissions");
50
- const allow = Array.isArray(permissions.allow) ? permissions.allow : [];
51
- const filtered = allow.filter((rule) => !isPusharyPermission(rule));
52
- if (!filtered.includes(PUSHARY_PERMISSION_RULE)) {
53
- filtered.push(PUSHARY_PERMISSION_RULE);
54
- }
55
- permissions.allow = filtered;
56
- };
57
- var addPusharyHooks = (settings) => {
58
- const hooks = ensureRecord(settings, "hooks");
59
- const preToolUse = Array.isArray(hooks.PreToolUse) ? hooks.PreToolUse : [];
60
- if (!preToolUse.some(isPusharyHook)) {
61
- preToolUse.push({
62
- matcher: "Bash|Write|Edit",
63
- hooks: [{
64
- type: "command",
65
- command: "pushary-hook",
66
- timeout: 120
67
- }]
68
- });
69
- hooks.PreToolUse = preToolUse;
70
- }
71
- const postToolUse = Array.isArray(hooks.PostToolUse) ? hooks.PostToolUse : [];
72
- if (!postToolUse.some(isPusharyHook)) {
73
- postToolUse.push({
74
- matcher: "Bash|Write|Edit",
75
- hooks: [{
76
- type: "command",
77
- command: "pushary-post-hook",
78
- timeout: 10
79
- }]
80
- });
81
- hooks.PostToolUse = postToolUse;
82
- }
83
- const stop = Array.isArray(hooks.Stop) ? hooks.Stop : [];
84
- if (!stop.some(isPusharyHook)) {
85
- stop.push({
86
- hooks: [{
87
- type: "command",
88
- command: "pushary-stop-hook",
89
- timeout: 10
90
- }]
91
- });
92
- hooks.Stop = stop;
93
- }
94
- };
95
- var removePusharySettings = (settings) => {
96
- let changed = removeClaudeMcpServers(settings);
97
- const permissions = asRecord(settings.permissions);
98
- if (permissions && Array.isArray(permissions.allow)) {
99
- const filtered = permissions.allow.filter((rule) => !isPusharyPermission(rule));
100
- if (filtered.length !== permissions.allow.length) {
101
- if (filtered.length === 0) {
102
- delete permissions.allow;
103
- } else {
104
- permissions.allow = filtered;
105
- }
106
- if (Object.keys(permissions).length === 0) delete settings.permissions;
107
- changed = true;
108
- }
109
- }
110
- const hooks = asRecord(settings.hooks);
111
- if (hooks) {
112
- for (const key of ["PreToolUse", "PostToolUse", "Stop"]) {
113
- const entries = hooks[key];
114
- if (!Array.isArray(entries)) continue;
115
- const filtered = entries.filter((entry) => !isPusharyHook(entry));
116
- if (filtered.length !== entries.length) {
117
- if (filtered.length === 0) {
118
- delete hooks[key];
119
- } else {
120
- hooks[key] = filtered;
121
- }
122
- changed = true;
123
- }
124
- }
125
- if (Object.keys(hooks).length === 0) delete settings.hooks;
126
- }
127
- return changed;
128
- };
129
-
130
- export {
131
- addClaudeMcpServer,
132
- removeClaudeMcpServers,
133
- addPusharyToolPermissions,
134
- addPusharyHooks,
135
- removePusharySettings
136
- };
@@ -1,328 +0,0 @@
1
- import {
2
- extractPolicyArg,
3
- isApprovalMode,
4
- isSafeReadOnlyCommand,
5
- matchRankWeight,
6
- matchToolPattern
7
- } from "./chunk-USUCPCUC.js";
8
- import {
9
- callMcpTool,
10
- withRetry
11
- } from "./chunk-DWED7BS3.js";
12
- import {
13
- getBaseUrl
14
- } from "./chunk-NKXSILEW.js";
15
-
16
- // src/validate.ts
17
- var isPolicyConfig = (data) => {
18
- if (!data || typeof data !== "object") return false;
19
- const d = data;
20
- return Array.isArray(d.policies) && typeof d.defaultTimeoutSeconds === "number" && typeof d.defaultTimeoutAction === "string";
21
- };
22
- var isAskUserResponse = (data) => {
23
- if (!data || typeof data !== "object") return false;
24
- const d = data;
25
- return typeof d.correlationId === "string" && typeof d.status === "string";
26
- };
27
- var isWaitForAnswerResponse = (data) => {
28
- if (!data || typeof data !== "object") return false;
29
- const d = data;
30
- return typeof d.answered === "boolean";
31
- };
32
-
33
- // src/api.ts
34
- var askUser = async (apiKey, params) => {
35
- const result = await callMcpTool(apiKey, "ask_user", { ...params, wait: false }, { maxRetries: 3 });
36
- if (!isAskUserResponse(result)) throw new Error("Invalid ask_user response");
37
- return result;
38
- };
39
- var waitForAnswer = async (apiKey, correlationId, timeoutMs = 3e4) => {
40
- const result = await callMcpTool(apiKey, "wait_for_answer", {
41
- correlationId,
42
- timeoutMs
43
- });
44
- if (!isWaitForAnswerResponse(result)) throw new Error("Invalid wait_for_answer response");
45
- return result;
46
- };
47
- var cancelQuestion = async (apiKey, correlationId) => {
48
- await callMcpTool(apiKey, "cancel_question", { correlationId });
49
- };
50
- var sendNotification = async (apiKey, params) => {
51
- await callMcpTool(apiKey, "send_notification", { ...params }, { maxRetries: 3 });
52
- };
53
-
54
- // src/policy.ts
55
- import { createHash } from "crypto";
56
- import { existsSync, readFileSync, writeFileSync } from "fs";
57
- import { join } from "path";
58
- import { tmpdir } from "os";
59
- var CACHE_TTL_MS = 60 * 1e3;
60
- var cacheFile = (apiKey) => {
61
- const hash = createHash("sha256").update(apiKey).digest("hex").slice(0, 12);
62
- return join(tmpdir(), `pushary-policy-${hash}.json`);
63
- };
64
- var fetchPolicy = async (apiKey) => {
65
- return withRetry(async () => {
66
- const baseUrl = getBaseUrl();
67
- const response = await fetch(`${baseUrl}/api/mcp/policy`, {
68
- headers: { "Authorization": `Bearer ${apiKey}` },
69
- signal: AbortSignal.timeout(1e4)
70
- });
71
- if (!response.ok) {
72
- throw new Error(`Failed to fetch policy: ${response.status}`);
73
- }
74
- const raw = await response.json();
75
- if (!isPolicyConfig(raw)) throw new Error("Invalid policy response");
76
- return raw;
77
- }, { maxAttempts: 2 });
78
- };
79
- var getPolicy = async (apiKey, expectedVersion) => {
80
- const path = cacheFile(apiKey);
81
- let staleCache = null;
82
- if (existsSync(path)) {
83
- try {
84
- const stat = readFileSync(path, "utf-8");
85
- const cached = JSON.parse(stat);
86
- if (!isPolicyConfig(cached)) throw new Error("Corrupted cache");
87
- const versionStale = expectedVersion != null && (cached._policyVersion ?? null) !== expectedVersion;
88
- const ttlFresh = !cached._cachedAt || Date.now() - cached._cachedAt < CACHE_TTL_MS;
89
- if (ttlFresh && !versionStale) {
90
- return cached;
91
- }
92
- staleCache = cached;
93
- } catch {
94
- }
95
- }
96
- try {
97
- const policy = await fetchPolicy(apiKey);
98
- try {
99
- writeFileSync(path, JSON.stringify({ ...policy, _cachedAt: Date.now(), _policyVersion: expectedVersion ?? null }), "utf-8");
100
- } catch {
101
- }
102
- return policy;
103
- } catch {
104
- if (staleCache) return staleCache;
105
- throw new Error("Failed to fetch policy and no cached policy available");
106
- }
107
- };
108
- var findBestMatch = (policies, toolName, arg) => {
109
- let best;
110
- let bestWeight = 0;
111
- let bestLength = -1;
112
- for (const candidate of policies) {
113
- const rank = matchToolPattern(candidate.tool, toolName, arg);
114
- if (rank === "none") continue;
115
- const weight = matchRankWeight(rank);
116
- const length = rank === "prefix" ? candidate.tool.length : -1;
117
- if (weight > bestWeight || weight === bestWeight && length > bestLength) {
118
- best = { policy: candidate, rank };
119
- bestWeight = weight;
120
- bestLength = length;
121
- }
122
- }
123
- return best;
124
- };
125
- var autoApprove = (tool) => ({
126
- tool,
127
- timeoutSeconds: 0,
128
- timeoutAction: "approve",
129
- mode: "terminal_only",
130
- pushFirstSeconds: 0
131
- });
132
- var resolvePolicy = (config, toolName, modeOverride, toolInput) => {
133
- const arg = toolInput ? extractPolicyArg(toolName, toolInput) : void 0;
134
- const match = findBestMatch(config.policies, toolName, arg);
135
- let base = match?.policy ?? config.policies.find((p) => p.tool === "*") ?? {
136
- tool: toolName,
137
- timeoutSeconds: config.defaultTimeoutSeconds,
138
- timeoutAction: config.defaultTimeoutAction,
139
- mode: config.defaultMode ?? "push_first",
140
- pushFirstSeconds: config.defaultPushFirstSeconds ?? 20
141
- };
142
- const governedBySpecificRule = match?.rank === "exact" || match?.rank === "prefix";
143
- if (!governedBySpecificRule && toolName === "Bash" && typeof arg === "string" && isSafeReadOnlyCommand(arg)) {
144
- base = autoApprove(base.tool);
145
- }
146
- const effectiveOverride = modeOverride ?? config.modeOverride;
147
- if (effectiveOverride) {
148
- return { ...base, mode: effectiveOverride };
149
- }
150
- return base;
151
- };
152
- var toPolicyVersion = (value) => typeof value === "string" || typeof value === "number" ? String(value) : null;
153
- var fetchModeState = async (apiKey, sessionId) => {
154
- try {
155
- const baseUrl = getBaseUrl();
156
- const url = sessionId ? `${baseUrl}/api/mcp/mode?session=${encodeURIComponent(sessionId)}` : `${baseUrl}/api/mcp/mode`;
157
- const response = await fetch(url, {
158
- headers: { "Authorization": `Bearer ${apiKey}` },
159
- signal: AbortSignal.timeout(3e3)
160
- });
161
- if (!response.ok) return { mode: null, kill: false, policyVersion: null };
162
- const data = await response.json();
163
- const mode = data.override?.mode;
164
- return {
165
- mode: isApprovalMode(mode) ? mode : null,
166
- kill: data.kill === true,
167
- policyVersion: toPolicyVersion(data.policyVersion)
168
- };
169
- } catch {
170
- return { mode: null, kill: false, policyVersion: null };
171
- }
172
- };
173
- var fetchModeOverride = async (apiKey) => (await fetchModeState(apiKey)).mode;
174
-
175
- // src/describe.ts
176
- import { isAbsolute, relative } from "path";
177
- var hookPrefixes = {
178
- Bash: (input) => `bash: ${input.command ?? "(no command)"}`,
179
- Write: (input) => `write file: ${input.file_path ?? "(unknown path)"}`,
180
- Edit: (input) => `edit file: ${input.file_path ?? "(unknown path)"}`,
181
- Read: (input) => `read file: ${input.file_path ?? "(unknown path)"}`
182
- };
183
- var eventPrefixes = {
184
- Bash: (input) => `ran: ${String(input.command ?? "").slice(0, 120)}`,
185
- Write: (input) => `wrote: ${input.file_path ?? "unknown"}`,
186
- Edit: (input) => `edited: ${input.file_path ?? "unknown"}`,
187
- Read: (input) => `read: ${input.file_path ?? "unknown"}`
188
- };
189
- var describeToolCall = (toolName, toolInput, format = "hook") => {
190
- const prefixes = format === "hook" ? hookPrefixes : eventPrefixes;
191
- const builder = prefixes[toolName];
192
- if (builder) return builder(toolInput);
193
- return format === "hook" ? `${toolName}: ${JSON.stringify(toolInput).slice(0, 200)}` : `${toolName}: done`;
194
- };
195
- var TOOL_TARGET_MAX_LENGTH = 80;
196
- var deriveCommandHead = (command) => {
197
- if (typeof command !== "string") return void 0;
198
- const head = command.trim().split(/\s+/).slice(0, 2).join(" ");
199
- return head ? head.slice(0, TOOL_TARGET_MAX_LENGTH) : void 0;
200
- };
201
- var deriveToolTarget = (toolName, toolInput) => {
202
- if (toolName === "Bash") {
203
- return deriveCommandHead(toolInput.command);
204
- }
205
- if (toolName === "Edit" || toolName === "Write") {
206
- const filePath = toolInput.file_path;
207
- if (typeof filePath !== "string") return void 0;
208
- const separator = Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\"));
209
- const base = filePath.slice(separator + 1);
210
- const dot = base.lastIndexOf(".");
211
- if (dot <= 0) return void 0;
212
- return base.slice(dot).slice(0, TOOL_TARGET_MAX_LENGTH);
213
- }
214
- return void 0;
215
- };
216
- var RECEIPT_TARGET_MAX_LENGTH = 256;
217
- var isToolResultError = (toolResult) => {
218
- try {
219
- return Boolean(toolResult && ("error" in toolResult || "is_error" in toolResult));
220
- } catch {
221
- return false;
222
- }
223
- };
224
- var relativizeReceiptPath = (filePath, cwd) => {
225
- if (!cwd || !isAbsolute(filePath)) return filePath;
226
- return relative(cwd, filePath);
227
- };
228
- var deriveReceiptMeta = (toolName, toolInput, toolResult, cwd) => {
229
- try {
230
- const ok = !isToolResultError(toolResult);
231
- if (toolName === "Edit" || toolName === "Write") {
232
- const filePath = toolInput.file_path;
233
- if (typeof filePath !== "string" || !filePath) return void 0;
234
- return {
235
- kind: toolName === "Edit" ? "edit" : "write",
236
- target: relativizeReceiptPath(filePath, cwd).slice(0, RECEIPT_TARGET_MAX_LENGTH),
237
- ok
238
- };
239
- }
240
- if (toolName === "Bash") {
241
- const head = deriveCommandHead(toolInput.command);
242
- if (!head) return void 0;
243
- return {
244
- kind: head === "git commit" ? "commit" : "bash",
245
- target: head,
246
- ok
247
- };
248
- }
249
- return void 0;
250
- } catch {
251
- return void 0;
252
- }
253
- };
254
-
255
- // src/identity.ts
256
- import { createHash as createHash2 } from "crypto";
257
- import { hostname } from "os";
258
- var deriveMachineId = (host) => createHash2("sha256").update(host).digest("hex").slice(0, 8);
259
- var getMachineId = () => deriveMachineId(hostname());
260
-
261
- // src/pending.ts
262
- import { join as join2 } from "path";
263
- import { tmpdir as tmpdir2 } from "os";
264
- import { existsSync as existsSync2, mkdirSync, writeFileSync as writeFileSync2, readdirSync, unlinkSync, rmSync, statSync } from "fs";
265
- var PENDING_DIR = join2(tmpdir2(), "pushary-pending");
266
- var DEFAULT_SESSION = "_no_session";
267
- var GRACE_MS = 10 * 60 * 1e3;
268
- var sanitize = (sessionId) => sessionId.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 128) || DEFAULT_SESSION;
269
- var dirFor = (sessionId) => join2(PENDING_DIR, sanitize(sessionId));
270
- var isDefaultSession = (sessionId) => sanitize(sessionId) === DEFAULT_SESSION;
271
- var savePendingQuestion = (sessionId, correlationId) => {
272
- const dir = dirFor(sessionId);
273
- if (!existsSync2(dir)) mkdirSync(dir, { recursive: true });
274
- writeFileSync2(join2(dir, correlationId), "", "utf-8");
275
- };
276
- var listPendingQuestions = (sessionId) => {
277
- const dir = dirFor(sessionId);
278
- let files;
279
- try {
280
- files = readdirSync(dir);
281
- } catch {
282
- return [];
283
- }
284
- if (!isDefaultSession(sessionId)) return files;
285
- const cutoff = Date.now() - GRACE_MS;
286
- return files.filter((name) => {
287
- try {
288
- return statSync(join2(dir, name)).mtimeMs < cutoff;
289
- } catch {
290
- return false;
291
- }
292
- });
293
- };
294
- var removePendingQuestion = (sessionId, correlationId) => {
295
- try {
296
- unlinkSync(join2(dirFor(sessionId), correlationId));
297
- } catch {
298
- }
299
- };
300
- var removePendingSession = (sessionId) => {
301
- try {
302
- rmSync(dirFor(sessionId), { recursive: true, force: true });
303
- } catch {
304
- }
305
- };
306
-
307
- export {
308
- isPolicyConfig,
309
- askUser,
310
- waitForAnswer,
311
- cancelQuestion,
312
- sendNotification,
313
- getPolicy,
314
- resolvePolicy,
315
- fetchModeState,
316
- fetchModeOverride,
317
- describeToolCall,
318
- deriveToolTarget,
319
- isToolResultError,
320
- deriveReceiptMeta,
321
- getMachineId,
322
- DEFAULT_SESSION,
323
- isDefaultSession,
324
- savePendingQuestion,
325
- listPendingQuestions,
326
- removePendingQuestion,
327
- removePendingSession
328
- };