linkgravity 1.8.1 → 1.9.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/hooks/hook.js +1 -1
- package/npm-scripts/register-hook.js +30 -15
- package/package.json +1 -1
- package/src/core/agy_runner.py +1 -8
package/hooks/hook.js
CHANGED
|
@@ -9,7 +9,7 @@ const LGY_CONFIG_FILE = path.join(os.homedir(), '.gemini', 'linkgravity', 'lgy.j
|
|
|
9
9
|
// Not "localhost" - the server binds 127.0.0.1 and node resolves localhost to ::1 first.
|
|
10
10
|
const APPROVE_HOST = '127.0.0.1';
|
|
11
11
|
const APPROVE_PORT = 18080;
|
|
12
|
-
const TIMEOUT_MS =
|
|
12
|
+
const TIMEOUT_MS = 86400 * 1000;
|
|
13
13
|
|
|
14
14
|
function emit(payload) {
|
|
15
15
|
// Exits explicitly: the keep-alive socket and its hour-long timer stay open after the
|
|
@@ -20,7 +20,7 @@ const HOOK_REGISTRATIONS = [
|
|
|
20
20
|
eventType: 'PreToolUse',
|
|
21
21
|
name: 'discord-approval',
|
|
22
22
|
fileName: 'hook.js',
|
|
23
|
-
defaultTimeout:
|
|
23
|
+
defaultTimeout: 86400,
|
|
24
24
|
wrapInMatcher: true,
|
|
25
25
|
},
|
|
26
26
|
{
|
|
@@ -130,7 +130,7 @@ function removeRetiredHooks(config) {
|
|
|
130
130
|
return removedAny;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
function registerHook({ allowFirstTimeCreate = true, quiet = false } = {}) {
|
|
133
|
+
function registerHook({ allowFirstTimeCreate = true, quiet = false, resetTimeouts = false } = {}) {
|
|
134
134
|
const config = loadHooksConfig();
|
|
135
135
|
config.hooks = config.hooks || {};
|
|
136
136
|
|
|
@@ -180,19 +180,34 @@ function registerHook({ allowFirstTimeCreate = true, quiet = false } = {}) {
|
|
|
180
180
|
hookEntry.command = command;
|
|
181
181
|
console.log(`🔗 Registered agy ${reg.eventType} hook '${reg.name}' -> ${scriptPath}`);
|
|
182
182
|
wroteChange = true;
|
|
183
|
-
} else
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
183
|
+
} else {
|
|
184
|
+
let changedThisEntry = false;
|
|
185
|
+
if (hookEntry.command !== command) {
|
|
186
|
+
backupBeforeFirstChange();
|
|
187
|
+
console.log(
|
|
188
|
+
`🔗 Fixing agy ${reg.eventType} hook '${reg.name}' in ${hooksJsonPath}` +
|
|
189
|
+
(backedUp ? ` (previous version backed up to ${hooksJsonPath}.bak)` : '') +
|
|
190
|
+
`:\n was: ${hookEntry.command}\n now: ${command}`,
|
|
191
|
+
);
|
|
192
|
+
hookEntry.command = command;
|
|
193
|
+
changedThisEntry = true;
|
|
194
|
+
}
|
|
195
|
+
// Only setup resets timeout - a passive `update` must not clobber a user-customized value.
|
|
196
|
+
if (resetTimeouts && hookEntry.timeout !== reg.defaultTimeout) {
|
|
197
|
+
backupBeforeFirstChange();
|
|
198
|
+
console.log(
|
|
199
|
+
`🔗 Resetting agy ${reg.eventType} hook '${reg.name}' timeout: ${hookEntry.timeout}s -> ${reg.defaultTimeout}s`,
|
|
200
|
+
);
|
|
201
|
+
hookEntry.timeout = reg.defaultTimeout;
|
|
202
|
+
changedThisEntry = true;
|
|
203
|
+
}
|
|
204
|
+
if (changedThisEntry) {
|
|
205
|
+
wroteChange = true;
|
|
206
|
+
} else if (!quiet) {
|
|
207
|
+
console.log(
|
|
208
|
+
`🔗 agy ${reg.eventType} hook '${reg.name}' already up to date -> ${scriptPath}`,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
196
211
|
}
|
|
197
212
|
}
|
|
198
213
|
|
package/package.json
CHANGED
package/src/core/agy_runner.py
CHANGED
|
@@ -208,13 +208,6 @@ async def run_agy(
|
|
|
208
208
|
stdout_chunks.append(clean)
|
|
209
209
|
if stream_queue is not None:
|
|
210
210
|
await stream_queue.put((clean, False))
|
|
211
|
-
if (
|
|
212
|
-
"(Calls tool:" in clean
|
|
213
|
-
or "Tool Output:" in clean
|
|
214
|
-
or "Tool Execute:" in clean
|
|
215
|
-
or clean.startswith("● ")
|
|
216
|
-
):
|
|
217
|
-
await stream_queue.put(("__SPLIT__", True))
|
|
218
211
|
|
|
219
212
|
async def read_stderr():
|
|
220
213
|
while True:
|
|
@@ -229,7 +222,7 @@ async def run_agy(
|
|
|
229
222
|
gather_task = asyncio.create_task(_gather_pipes())
|
|
230
223
|
wait_task = asyncio.create_task(proc.wait())
|
|
231
224
|
|
|
232
|
-
# Slices let the timeout pause
|
|
225
|
+
# Slices let the timeout pause while an approval is pending (hook.js waits up to 24h).
|
|
233
226
|
from config import session_manager as _sm
|
|
234
227
|
|
|
235
228
|
poll_slice = 5.0
|